<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">First you need to figure out exactly when/how you’re going to decide when to add a new stream.  I.e., you need to figure out what event will cause this to happen.<div class=""><br class=""></div><div class="">If it’s simply a delayed task - within the event loop (i.e., set up using “TaskScheduler::scheduleDelayedTask()”) - then you don’t need ‘event triggers’ at all.  Instead, simply add the new stream from the ‘delayed task’.  Ditto if the event occurs as a result of reading data from a socket.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">If, however, you decide to do this from some external thread (i.e., from the thread that is *not* running the LIVE555 event loop), then you can call “triggerEvent()” from this external thread.  Note that “triggerEvent()” is the *only* LIVE555 code that you may call from this external thread; all other LIVE555 calls *must* be done from within the ‘LIVE555 event loop’ thread.</div><div class=""><br class=""></div><div class="">If you decide to use ‘event triggers’ (triggered from an external thread), then you are sort of on the right track, with a couple of corrections:</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="">myRTSPClient::createNew(env,url,etc.){<br class="">    …<br class="">    addStreamEventTriggerId = envir().taskScheduler().createEventTrigger(addStreamToLoop);<br class=""></div></blockquote><div class=""><br class=""></div>Note that the function parameter to “createEventTrigger()” has to have the proper “TaskFunc” signature:</div><div class=""><span class="Apple-tab-span" style="white-space:pre">    </span>typedef void TaskFunc(void* clientData);</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><blockquote type="cite" class="">myClient =  myRTSPClient::createNew(env, url, etc.);<br class="">ourScheduler->triggerEvent(myRTSPClient::addStreamEventTriggerId, myClient);<br class=""></blockquote><br class=""></div><div class="">Because you are calling “triggerEvent()” from an external thread (again, if you’re in the LIVE555 event loop thread when you decide to create a new stream, then you don’t need event triggers at all), you can’t call “myRTSPClient::createNew()” from within that thread.  Instead, the “myRTSPClient::createNew()” call should occur (along with a subsequent “sendDescribeCommand()”) within the event handler function - i.e., within the LIVE555 event loop.</div><div class=""><br class=""></div><div class="">So, to get this, you can do something like:</div><div class=""><br class=""></div><div class="">///// Within the LIVE555 thread:</div><div class=""><br class=""></div><div class="">void newStreamHandler(void* clientData) {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">       </span>char* url = (char*)clientData;</div><div class=""><span class="Apple-tab-span" style="white-space:pre">    </span>myRTSPClient* myClient =  myRTSPClient::createNew(env, url, etc.);</div><div class=""><span class="Apple-tab-span" style="white-space:pre">   </span>myClient->addStreamToLoop();</div><div class="">}</div><div class=""><br class=""></div><div class="">TaskScheduler* live555TaskScheduler = &(envir().taskScheduler()); // A global variable</div><div class="">EventTriggerId newStreamEventTrigger =  envir().taskScheduler().createEventTrigger(newStreamHandler); // A global variable</div><div class=""><span class="Apple-tab-span" style="white-space:pre">    </span>// Note that you need to create only one event trigger</div><div class=""><br class=""></div><div class="">envir().taskScheduler().doEventLoop(); // does not return</div><div class=""><br class=""></div><div class="">///// Then later, within a separate thread:</div><div class=""><br class=""></div><div class="">live555TaskScheduler->triggerEvent(newStreamEventTrigger, url_for_the_new_stream);</div><div class=""><br class=""></div><br class=""><div apple-content-edited="true" class="">
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;  ">Ross Finlayson<br class="">Live Networks, Inc.<br class=""><a href="http://www.live555.com/" class="">http://www.live555.com/</a></span>
</div>
<br class=""></body></html>