Streaming live audio data over DDS!!! PreviousNext
Data Distribution Service (DDS) Forum > DDS Technical Forum >
Message/Author
Next message jeetendra kumar  posted on Monday, July 16, 2012 - 11:39 am
Hi DDS Community,
I am using openDDS to pass the audio data from publisher to subscriber side.
But the problem is that I am not getting anything on the subscriber side. I am very clueless about that. I tried to print the value from published and subscriber side, but it throwing tons of data both side. So totally I am confused with the output.

I am enclosing the code snippet that I used for this app. I am using 3rd party library also to get the audio data in this. But that's workign fine without the DDS infrastructure. Following are the code:

//Messenger.idl

#include "tao/OctetSeq.pidl"
module Messenger {
#pragma DCPS_DATA_TYPE "Messenger::Message"
struct Message {
CORBA::-OctetSeq userData;
};
};

//publisher.cpp

#define NUM_SECONDS (60)
#define FRAMES_PER_BUFFER (1024)
#define NUM_CHANNELS (2)
numBytes = FRAMES_PER_BUFFER * NUM_CHANNELS * SAMPLE_SIZE ;

Messenger::Message message;//instantiating the Message
DDS::InstanceHandle_t handle = message_writer->register_instance(message);//registering the message instance with DDS
message.userData.length(numBytes);//assigning the length of octet data

for( i=0; i<(NUM_SECONDS*SAMPLE_RATE)/FRAMES_PER_BUFFER; ++i )
{
if((retVal=GetStreamReadAvailable(stream)) >= 0){
err=ReadStream( stream, sampleBlock, FRAMES_PER_BUFFER ); if(err=ERROR) goto error;
for(CORBA::ULong jj=0;jj<FRAMES_PER_BUFFER;++jj) //1. assigning the audio data from sampleBlock to octet data
{ message.userData[jj]=sampleBlock[jj];}
DDS::ReturnCode_t error = message_writer->write(message, handle);//2. writing the octet data over DDS by using write method
}
}

//DataReaderListenerImpl.cpp
//(IN subscriber side)
void DataReaderListenerImpl::on_data_available(DDS::DataReader_ptr reader)throw(CORBA::SystemException)
{
try {
Messenger::MessageDataReader_var reader_i =Messenger::MessageDataReader::_narrow(reader);
Messenger::MessageSeq messages;
DDS::SampleInfoSeq info;
DDS::ReturnCode_t error = reader_i->take(messages,
info,
DDS::LENGTH_UNLIMITED,
DDS::ANY_SAMPLE_STATE,
DDS::ANY_VIEW_STATE,
DDS::ANY_INSTANCE_STATE);
if (error == DDS::RETCODE_OK)
{
for (unsigned int ii = 0; ii < messages.length(); ++ii)
{
const DDS::SampleInfo& si = info[ii];//sample data getting from DDS
if (si.valid_data && ((IsStreamActive( stream ) ) == 1))
{
const Messenger::Message& message = messages[ii];
if((message.userData.mb() >0) && (GetStreamWriteAvailable(stream)==1))
{
err = WriteStream( stream,message.userData.get_buffer(), FRAMES_PER_BUFFER );//3. using the octet data to pass into WriteStream
if (err=ERROR) goto error;
}
}
}//END for loop
}
}catch (const CORBA::Exception& e) {
e._tao_print_exception("Exception caught in on_data_available():");
ACE_OS::exit(-1);
}
}


I have the doubt in following area:
comment1. while assigning the audioData to octet data(message.userData)
comment2. writing the octet data over DDS by using write method
comment3. using the octet data(message.userData.get_buffer()) to pass into WriteStream

and with that, can we see the data in subscriber side while debugging.

Please have a look on my snippet code and suggest that where is the problem while passing audio data from publisher to subscriber.

Any help in this will be really appreciated.

Thanks In Advance!!!

Bye,
Jeetendra
Back to top
Add Your Message Here
Post:
Username: Posting Information:
This is a private posting area. Only registered users and moderators may post messages here.
Password:
Options: Post as "Anonymous"
Enable HTML code in message
Automatically activate URLs in message
Action: