Streaming live audio data over DDS!!! PreviousNext
Data Distribution Service (DDS) Forum > DDS Technical Forum >
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:


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


#define NUM_SECONDS (60)
#define FRAMES_PER_BUFFER (1024)
#define NUM_CHANNELS (2)

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

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

//(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,
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():");

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!!!

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