error management

8 posts / 0 new
Last post
Offline
Last seen: 8 years 7 months ago
Joined: 10/28/2010
Posts: 22
error management

HI,

I would read mp4 video file using NDDS, I have a problem of memory violation error.

 

Did any one  gives some help.

the idl file contains:

 

module MultimediaStream {

 

//#pragma DCPS_DATA_TYPE "MultimediaStream::Packet"

//#pragma DCPS_DATA_KEY "Messenger::Message subject_id"

 

  const long PACKET_SIZE = 1000;

  typedef sequence<octet, PACKET_SIZE> ByteSeq;

 

  struct Packet {

 long seqNum;

 long byteCount;

      ByteSeq bytes;

 char *data; // Ajouter par akram

  };

};

 

 

The publisher code for data writing is :

 

 

instance = MultimediaStream::PacketTypeSupport::create_data_ex( DDS_BOOLEAN_FALSE);

    if (instance == NULL) {

        std::cerr << "! Unable to create an instance of the data" << std::endl;

        std::cerr << "! This problem most likely is caused by out of memory" << std::endl;

        goto exitFn;

    }

 

/* Sets the length of the sequence we are sending */

    if (!DDS_OctetSeq_ensure_length(&instance->bytes, dataSize, MultimediaStream::PACKET_SIZE)) {

        std::cerr << "! Unable to set payload size to " << dataSize << std::endl;

        std::cerr << "! Perhaps you are using a value too big " << "(max allowed size is"  << MultimediaStream::PACKET_SIZE<< ")" << std::endl;

        goto exitFn;

    }

 

for (count=0; (sample_count == 0) || (count < sample_count); ++count) {

 

        printf("Writing MultimediaStream::Packet, count %d\n", count);

 

        /* Modify the data to be sent here */

 

std::ifstream source( "C:\\movie.mp4",std::ios_base::binary );

//std::ofstream destination( "C:\\movie_dest.mp4",std::ios_base::binary );

char buff[1024];

while ( !source.eof() )

{

source.read( instance->data, sizeof( instance->data ) );

instance->byteCount=source.gcount();

instance->seqNum=source.gcount();

// instance->bytes = (DDS) instance->data;

//destination.write ( buff, source.gcount() );

retcode = MultimediaStream_Packet_writer->write(*instance, instance_handle);

        if (retcode != RETCODE_OK) {

            printf("write error %d\n", retcode);

        }

 

}

Keywords:
Gerardo Pardo's picture
Offline
Last seen: 1 day 10 hours ago
Joined: 06/02/2010
Posts: 601

Hello,

 

I think the issue is that you are never allocating the memory for instance->data

 

In the IDL you define the 'data' field in the struct Packet to be of type 'char *' consequently this will be mapped to simple a 'char *' in the generated C++ structure.

 

The result of this syntax is that the function MultimediaStream::PacketTypeSupport::create_data_ex() function will not allocate any memory for it and will leave the 'instance->data' poiner set to NULL. That explains the memory violation when you call  the function:

      source.read( instance->data, sizeof( instance->data ) );

 

But I do not think using the 'char *data' will do what you want. This IDL syntax would only allow you to send a single character, not an array of characters.

 

I see you have declared a ByteSeq bytes; element which you are then setting to hold MultimediaStream::PACKET_SIZE  I am guessing what you really wanted was to copy the data in 'source' into the 'instance->bytes' array.

 

So I would first re-define the struct Packet to not have the 'data' pointer. I also do not see why you need the byteCount field as this appers to me will simply be the length of the 'bytes' array which is already part of the array. In other words I would define it as:

 

 struct Packet {
  long seqNum;
          ByteSeq bytes;
  };

 

Given that you are correctly using the DDS_OctetSeq_ensure_length() operation to size the 'bytes' array to contain the maximum number of bytes you expect this memory will be properly allocated so you can copy the data from the source there using the operation:

 

/* Copy data into the buffer underlying the sequence */
source.read(DDS_OctetSeq_get_contiguous_buffer(&instance->bytes), 
                DDS_OctetSeq_get_maximum(&instance->bytes ));
/* Set the length of the sequence to match the number of bytes copied */
DDS_OctetSeq_set_length(&instance->bytes, source.gcount() );

Hope this helps!

 


 

Offline
Last seen: 8 years 7 months ago
Joined: 10/28/2010
Posts: 22

Hi Gerardo,

thanks for your replay.  

I have a compilation prblem because the arguments of the function read (ifstream), and it works with :

 

/* Copy data into the buffer underlying the sequence */

source.read((char*)DDS_OctetSeq_get_contiguous_buffer(&instance->bytes), DDS_OctetSeq_get_maximum(&instance->bytes ));

 

 

I would set a DSCP value to the datawriter transport_priority qos but the have 0 as the value when I capture the traffic with wireshark.

the code is like this:

 

DDS_DataWriterQos writer_qos;

// initialize writer_qos with default values

publisher->get_default_datawriter_qos(writer_qos);

int tos = 10;

writer_qos.transport_priority.value = tos;

// make QoS changes

(writer_qos.transport_priority.value & 0x7 ) << 9;

 

   /* To customize data writer QoS, use 

       the configuration file USER_QOS_PROFILES.xml */

    writer = publisher->create_datawriter(topic,

 writer_qos, 

 NULL /* listener */,

  STATUS_MASK_NONE);

if (writer == NULL) {

        printf("create_datawriter error\n");

        publisher_shutdown(participant);

        return -1;

    }

 

 

Any suggestions

 

thanks.

 

Akram Hakiri

Offline
Last seen: 8 years 7 months ago
Joined: 10/28/2010
Posts: 22

Hi Gerardo,

thanks for your replay.  

I have a compilation prblem because the arguments of the function read (ifstream), and it works with :

 

/* Copy data into the buffer underlying the sequence */

source.read((char*)DDS_OctetSeq_get_contiguous_buffer(&instance->bytes), DDS_OctetSeq_get_maximum(&instance->bytes ));

 

 

I would set a DSCP value to the datawriter transport_priority qos but the have 0 as the value when I capture the traffic with wireshark.

the code is like this:

 

DDS_DataWriterQos writer_qos;

// initialize writer_qos with default values

publisher->get_default_datawriter_qos(writer_qos);

int tos = 10;

writer_qos.transport_priority.value = tos;

// make QoS changes

(writer_qos.transport_priority.value & 0x7 ) << 9;

 

   /* To customize data writer QoS, use 

       the configuration file USER_QOS_PROFILES.xml */

    writer = publisher->create_datawriter(topic,

 writer_qos, 

 NULL /* listener */,

  STATUS_MASK_NONE);

if (writer == NULL) {

        printf("create_datawriter error\n");

        publisher_shutdown(participant);

        return -1;

    }

 

 

Any suggestions

 

thanks.

 

Akram Hakiri

Fernando Garcia's picture
Offline
Last seen: 4 months 6 days ago
Joined: 05/18/2011
Posts: 199

 

The transport_priority QoS  is used to tell the underlying transport mechanism (e.g UDP or shared memory)  how to configure its priority. Each individual transport maps that to something according to its capabilities. This indirection is necessary because the range of priorities, or their meaning, may differ from transport to transport. A particular transport can even ignore it if it does not support prioritization.

 

Looking at the documentation it seems to me that the builtin UDP transport  supports prioritization, but the default configuration you get out of the box disables it.  You can read about this here:

http://community.rti.com/docs/html/api_cpp/group__NDDS__Transport__UDPv4__Plugin.html

 

Specifically read the comments associated with the dds.transport.UDPv4.builtin.transport_priority_mask. The documentation says by default it is set to zero which disables it.

So it seems that top get what you want you would need to minimally set:

dds.transport.UDPv4.builtin.transport_priority_mask

And potentially modify the default value of these other two to fit your needs.

NDDS_Transport_UDPv4_Property_t::transport_priority_mapping_low

NDDS_Transport_UDPv4_Property_t::transport_priority_mapping_high

 

The easiest way to do this is using the XML QoS Profiles.

 

 

 

 

Offline
Last seen: 5 years 3 weeks ago
Joined: 03/09/2019
Posts: 1

Thanks a lot!

As a feedback:

  1. I noticed that if I have .MKV files in the video_folder and use videotype='.mkv' => It does not work! (even though I can read .mkv files in my own python/oepncv scripts, it doesn't read in the Docker)
  2. I had to convert .MKV files to .MP4. Keeping both in the same folder, i can watch all movies on cinema apk.I must use videotype='.mp4' in dlc.analyze_videos() fcn, otherwise it doesnt do anything.
  3. In dlc.create_labeled_video(), besides using videotype='.mp4', I had to use [] (brackets) if I was to process all videos of the folder!
Offline
Last seen: 4 years 11 months ago
Joined: 04/11/2019
Posts: 1

I saw that in the event that I have .MKV documents in the video_folder and use videotype='.mkv' => It doesn't work! (despite the fact that I can peruse .mkv records in my very own python/oepncv contents, it doesn't peruse in the Docker)

I needed to change over.MKV documents to .MP4. Keeping both in a similar organizer, I can observe all motion pictures on mobdro apk.I must utilize videotype='.mp4' in dlc.analyze_videos() fcn, else it doesnt do anything.

In dlc.create_labeled_video(), other than utilizing videotype='.mp4', I needed to utilize [] (sections) if I somehow happened to process all recordings of the envelope!

Offline
Last seen: 4 years 4 months ago
Joined: 11/28/2019
Posts: 1

 A new theory of cognitive biases, called error management theory (EMT), proposes that psychological mechanisms are designed.

Panda Helper app is a third party app. Panda helper utilize to download all app,

Its help iso app and apk app download the payment and free apps available

it is easy to download on update version

But Panda Helper doesn’t require jailbreaking and is free of these threats.

Though Panda Helper regular app is free, to access the VIP features. Click to more information

 

https://pandahelperdownload.com/