<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">Hi,</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "> I have been trying to debug an issue with a program I have written by looking at examples from the testProgs folder, where I receive a H264 ES over RTP & store it into a file. I have noticed that if I run the program after I start the RTP source, I can successfully receive the stream and dump it into a file. However, if I run my program prior to launching the RTP source, I am unable to receive the stream and dump it into a file.</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "> Any help in debugging the issue will be greatly appreciated. Source follows.</div><div
style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">Thanks,</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">Roshan</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; ">---------------------------------------------------------------------</div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div><div><div><font face="times new roman, new york, times, serif">#include <liveMedia.hh></font></div><div><font face="times new roman, new york, times, serif">#include <BasicUsageEnvironment.hh></font></div><div><font face="times new roman, new york, times, serif">#include <GroupsockHelper.hh></font></div><div><font face="times new roman, new york, times,
serif"><br></font></div><div><font face="times new roman, new york, times, serif">UsageEnvironment* env;</font></div><div><font face="times new roman, new york, times, serif">char const* outputFileName = "rx_file.264";</font></div><div><font face="times new roman, new york, times, serif"><br></font></div><div><font face="times new roman, new york, times, serif">const unsigned short inputPortNum = 15000;</font></div><div><font face="times new roman, new york, times, serif"><br></font></div><div><font face="times new roman, new york, times, serif">// A structure to hold the state of the current session.</font></div><div><font face="times new roman, new york, times, serif">// It is used in the "afterPlaying()" function to clean up the session.</font></div><div><font face="times new roman, new york, times, serif">struct sessionState_t {</font></div><div><font face="times new roman, new york, times, serif"> RTPSource* source;</font></div><div><font
face="times new roman, new york, times, serif"> H264VideoFileSink* sink;</font></div><div><font face="times new roman, new york, times, serif">};</font></div><div><font face="times new roman, new york, times, serif"><br></font></div><div><font face="times new roman, new york, times, serif">struct sessionState_t sessionState;</font></div><div><font face="times new roman, new york, times, serif"><br></font></div><div><font face="times new roman, new york, times, serif"><br></font></div><div><font face="times new roman, new york, times, serif">void afterPlaying(void *);</font></div><div><font face="times new roman, new york, times, serif"><br></font></div><div><font face="times new roman, new york, times, serif">int main() {</font></div><div><font face="times new roman, new york, times, serif"> // Begin by setting up our usage environment:</font></div><div><font face="times new roman, new york, times, serif"> TaskScheduler* scheduler =
BasicTaskScheduler::createNew();</font></div><div><font face="times new roman, new york, times, serif"> env = BasicUsageEnvironment::createNew(*scheduler);</font></div><div><font face="times new roman, new york, times, serif"> </font></div><div><font face="times new roman, new york, times, serif"> // Create the data sink</font></div><div><font face="times new roman, new york, times, serif"> sessionState.sink = H264VideoFileSink::createNew(*env, outputFileName, NULL, 100000);</font></div><div><font face="times new roman, new york, times, serif"> </font></div><div><font face="times new roman, new york, times, serif"> char const* sessionAddressStr = "0.0.0.0";</font></div><div><font face="times new roman, new york, times, serif"><br></font></div><div><font face="times new roman, new york, times, serif"> const unsigned char ttl = 255;</font></div><div><font face="times new roman, new york, times,
serif"><br></font></div><div><font face="times new roman, new york, times, serif"> struct in_addr sessionAddress;</font></div><div><font face="times new roman, new york, times, serif"> sessionAddress.s_addr = our_inet_addr(sessionAddressStr);</font></div><div><font face="times new roman, new york, times, serif"> const Port rtpPort(inputPortNum);</font></div><div><font face="times new roman, new york, times, serif"><br></font></div><div><font face="times new roman, new york, times, serif"> Groupsock* rtpGroupsock = new Groupsock(*env, sessionAddress, rtpPort, ttl);</font></div><div><font face="times new roman, new york, times, serif"><br></font></div><div><font face="times new roman, new york, times, serif"> OutPacketBuffer::maxSize = 100000;</font></div><div><font face="times new roman, new york, times, serif"><br></font></div><div><font face="times new roman, new york, times, serif"> // Create the data
source</font></div><div><font face="times new roman, new york, times, serif"> sessionState.source = H264VideoRTPSource::createNew(*env, rtpGroupsock, 96);</font></div><div><font face="times new roman, new york, times, serif"><br></font></div><div><font face="times new roman, new york, times, serif"> // Finally, start receiving the stream:</font></div><div><font face="times new roman, new york, times, serif"> *env << "Beginning receiving stream...\n";</font></div><div><font face="times new roman, new york, times, serif"><br></font></div><div><font face="times new roman, new york, times, serif"> FramedSource* framedSource;</font></div><div><font face="times new roman, new york, times, serif"> framedSource = H264VideoStreamDiscreteFramer::createNew(*env, sessionState.source);</font></div><div><font face="times new roman, new york, times, serif"><br></font></div><div><font face="times new roman, new york, times,
serif"> sessionState.sink->startPlaying(*framedSource, afterPlaying, NULL);</font></div><div><span style="font-family: 'times new roman', 'new york', times, serif; "> </span><br></div><div><font face="times new roman, new york, times, serif"> env->taskScheduler().doEventLoop(); // does not return</font></div><div><span style="font-family: 'times new roman', 'new york', times, serif; "><br></span></div><div><span style="font-family: 'times new roman', 'new york', times, serif; "> return 0; // only to prevent compiler warning</span><br></div><div><font face="times new roman, new york, times, serif">}</font></div><div><font face="times new roman, new york, times, serif"><br></font></div><div><font face="times new roman, new york, times, serif">void afterPlaying(void *) {</font></div><div><font face="times new roman, new york, times, serif"> *env << "...done receiving\n";</font></div><div><font face="times new roman,
new york, times, serif"><br></font></div><div><font face="times new roman, new york, times, serif"> // End by closing the media:</font></div><div><font face="times new roman, new york, times, serif"> Medium::close(sessionState.sink);</font></div><div><font face="times new roman, new york, times, serif"> Medium::close(sessionState.source);</font></div><div><font face="times new roman, new york, times, serif">}</font></div></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><br></div></div></body></html>