<div dir="ltr"><div><div><div><div>HI Ross,<br><br></div>I have modified Indexer utility ( MPEG2TransportStreamIndexer.cpp ) to delete all the dynamic objects.<br></div>Code:<br>#include <liveMedia.hh><br>#include <BasicUsageEnvironment.hh><br>
<br>void afterPlaying(void* clientData); // forward<br><br>UsageEnvironment* env;<br>char const* programName;<br><br>void usage() {<br> *env << "usage: " << programName << " <transport-stream-file-name>\n";<br>
*env << "\twhere <transport-stream-file-name> ends with \".ts\"\n";<br> exit(1);<br>}<br> TaskScheduler* scheduler;<br> FramedSource* input;<br> FramedSource* indexer;<br> MediaSink* output;<br>
<br>int main(int argc, char const** argv) {<br> // Begin by setting up our usage environment:<br> scheduler = BasicTaskScheduler::createNew();<br> env = BasicUsageEnvironment::createNew(*scheduler);<br><br> // Parse the command line:<br>
programName = argv[0];<br> if (argc != 2) usage();<br><br> char const* inputFileName = argv[1];<br> // Check whether the input file name ends with ".ts":<br> int len = strlen(inputFileName);<br> if (len < 4 || strcmp(&inputFileName[len-3], ".ts") != 0) {<br>
*env << "ERROR: input file name \"" << inputFileName<br> << "\" does not end with \".ts\"\n";<br> usage();<br> }<br><br> // Open the input file (as a 'byte stream file source'):<br>
input = ByteStreamFileSource::createNew(*env, inputFileName, TRANSPORT_PACKET_SIZE);<br> if (input == NULL) {<br> *env << "Failed to open input file \"" << inputFileName << "\" (does it exist?)\n";<br>
exit(1);<br> }<br><br> // Create a filter that indexes the input Transport Stream data:<br> indexer = MPEG2IFrameIndexFromTransportStream::createNew(*env, input);<br><br> // The output file name is the same as the input file name, except with suffix ".tsx":<br>
char* outputFileName = new char[len+2]; // allow for trailing x\0<br> sprintf(outputFileName, "%sx", inputFileName);<br><br> // Open the output file (for writing), as a 'file sink':<br> output = FileSink::createNew(*env, outputFileName);<br>
if (output == NULL) <br> {<br> *env << "Failed to open output file \"" << outputFileName << "\"\n";<br> exit(1);<br> }<br><br> // Start playing, to generate the output index file:<br>
*env << "Writing index file \"" << outputFileName << "\"...";<br> output->startPlaying(*indexer, afterPlaying, NULL);<br><br> env->taskScheduler().doEventLoop(); // does not return<br>
<br> return 0; // only to prevent compiler warning<br>}<br><br>void afterPlaying(void* /*clientData*/) {<br> *env << "...done\n";<br><br> Medium::close(output);<br> Medium::close(input);<br> Medium::close(indexer);<br>
<br> delete scheduler;<br> env->reclaim();<br><br> exit(0);<br>}<br><br><br></div>As you can see agterPlaying function, is it right way to delete all objects because valgrind tool showing memory leaks at closing <br>
</div>of "indexer" object.<br><div><br>Leaks:<br><div>==29177== 80(16 direct,64 indirect) bytes in 1 block are definitely lost in loss record 3 of 3<br>
</div>==29177== at 0x402BA13: operator new(unsigned int)(vg_replace_malloc.c:313)<br>==29177== by 0x8055B67: _Tables::getOurTables(<div>UsageEnvironment &,unsigned char)<br>==29177== by 0x6524B67: MediaLookupTables::ourMedia(UsageEnvironment)<br>
==29177== by 0x5874C6A: Medium::close(UsageEnvironment &,char const *)<br>==29177== by 0x424CCB7: Medium::close(Medium*)<br>==29177== by 0x5345C67: FramedFilter::~FramedFilter()<br>==29177== by 0x5345C67: MPEG2IFrameIndexFromTransportStream::~MPEG2IFrameIndexFromTransportStream()<br>
==29177== by 0x5345C67: Medium::close(Medium*)<br><br></div><div>Thanks & Regards,<br></div><div>John<br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, May 21, 2014 at 10:29 PM, john dicostanzo <span dir="ltr"><<a href="mailto:john95018@gmail.com" target="_blank">john95018@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div><div><div>Hi,<br></div>I am using Live555 library for my vod server, vod server create index file and announce transport stream.<br>
</div></div>For Indexing, I am using code as reference from MPEG2TransportStreamIndexer.cpp<br>
</div>but when i close and delete all the dynamic objects,valgrind shows memory leaks on it.<br><br></div>Leaks:<br></div><div>==29177== 80(16 direct,64 indirect) bytes in 1 block are definitely lost in loss record 3 of 3<br>
</div>==29177== at 0x402BA13: operator new(unsigned int)(vg_replace_malloc.c:313)<br></div>==29177== by 0x8055B67: _Tables::getOurTables(UsageEnvironment &,unsigned char)<br>==29177== by 0x6524B67: MediaLookupTables::ourMedia(UsageEnvironment)<br>
==29177== by 0x5874C6A: Medium::close(UsageEnvironment &,char const *)<br>==29177== by 0x424CCB7: Medium::close(Medium*)<br>==29177== by 0x5345C67: FramedFilter::~FramedFilter()<br>==29177== by 0x5345C67: MPEG2IFrameIndexFromTransportStream::~MPEG2IFrameIndexFromTransportStream()<br>
==29177== by 0x5345C67: Medium::close(Medium*)<br><br></div><div>I don't know, why its creating new dynamic object in Medium::close(operator new(unsigned int)(vg_replace_malloc.c:313))<br><br></div>Thanks,<br></div>John<br>
</div>
</blockquote></div><br></div>