I happen to use the following data class because I want to hang onto a few 
items.

    //Call back instance and session pointer container.
    class MVSRTSPClient;
    class MVSClientData
    {
        public:
            MVSClientData(MVSRTSPClient* instancePtr, MediaSubsession* 
subsessionPtr)
                :   instancePtr_(instancePtr),
                    subsessionPtr_(subsessionPtr){}

        MVSRTSPClient* instancePtr_;
        MediaSubsession* subsessionPtr_;
    };

Then I just cast it when I get called back

Ie

void callbackSubsessionAfterPLAYING(void* vclient)
    {
         boost::mutex::scoped_lock lock(MVS::CMVSRTSPClient::AFTERPlayMutex_);

        // Begin by closing this media subsession's stream:
        MVSClientData* client = (MVSClientData*) vclient;
        MediaSubsession* subsession = (MediaSubsession*)client->subsessionPtr_;
        Medium::close(subsession->sink);
        subsession->sink = NULL;

        // Next, check whether *all* subsessions' streams have now been closed:
        MediaSession& session = subsession->parentSession();
        MediaSubsessionIterator iter(session);
        while ((subsession = iter.next()) != NULL) {
            if (subsession->sink != NULL) return; // this subsession is still 
active
        }

        // All subsessions' streams have now been closed
        MVSRTSPClient* mySelf = (MVSRTSPClient*) client->instancePtr_;
        mySelf->sessionAfterPlaying();
    }


The locking is because I have many instances and many threads




From: live-devel-boun...@ns.live555.com 
[mailto:live-devel-boun...@ns.live555.com] On Behalf Of Ross Finlayson
Sent: Friday, December 09, 2011 10:41 AM
To: LIVE555 Streaming Media - development & use
Subject: Re: [Live-devel] Stop specific streams.

So I am trying to create a event trigger, but I am unsure on how to proceed. 
The taskScheduler->createEventTrigger() function expects a taskFunc object and 
I am not sure what this is.

It's quite simple.  It's this:
            typedef void TaskFunc(void* clientData);
I.e., it's a void function that takes a "void*" as argument.

 Is it similar to a callback?

Yes, but it's 'called back' from within the event loop, when the event is 
'triggered'.


If so, how do I cast my function do a taskFunc object? I currently having 
something like this, which is way off:

void killStream() {};

"kilStream()" needs a single void* parameter.  Don't you want to specify a 
specific stream that you want to 'kill'?  If so, then you can use that as your 
parameter (cast it to a void*) when you later call "triggerEvent()".


taskSched->createEventTrigger(&killstream);

Yes, but you'll need to remember the result "EventTriggerId" of this call, so 
you can later use it in your call to "triggerEvent()".

If you're still unsure about how to use event triggers, then you can see an 
example in "liveMedia/DeviceSource.cpp".



 I am also still unsure about the mechanisms for actually stopping the streams.

OK, this is a completely different question.

To remove (and delete) a "ServerMediaSession" object from the server, simply 
call
            RTSPServer::removeServerMediaSession()
***Do not*** call "Medium::close()" on the "ServerMediaSession" object; that is 
done automatically by "removeServerMediaSession()".  Note, however, that 
although this will prevent any future clients from accessing this stream, it 
will not stop any streaming that's current ongoing for this 
"ServerMediaSession".  If you want to do that, you would need to delete the 
"RTSPServer::RTSPClientSession" object for each currently active client.  (This 
has the same effect as the client having done a RTSP "TEARDOWN".)

Ross Finlayson
Live Networks, Inc.
http://www.live555.com/

_______________________________________________
live-devel mailing list
live-devel@lists.live555.com
http://lists.live555.com/mailman/listinfo/live-devel

Reply via email to