Results 1 to 5 of 5

Thread: Getting the sessionId of goCoder when a stream is started.

  1. #1
    Join Date
    Aug 2011
    Posts
    14

    Question Getting the sessionId of goCoder when a stream is started.

    I need to get the clientId / sessionId of any client that is publishing a stream. I can get the get a valid RTMP "clientId" from within onPublish, however, I only ever get a -1 (or null) returned back in that method when requesting the sessionId of an RTP (goCoder) stream.

    I can get a valid sessionId back from "onRTPSessionCreate and onRTPSessionDestroy", however, I have no idea from those method if the RTP session is a play or publish.

    I've seen an earlier thread from 2010 asking the same question and the response was to get the information from IMediaCasterNotify2. However, even in a very basic module that initiates IMediaCasterNotify2 via onAppStart, none of the methods are ever called by goCoder when publishing or destroying a stream. Either I'm missing one of the callbacks in the example mediacaster implementation, or goCoder doesn't invoke mediacaster.

    So, how can I get the RTPSessionId of a client that "Publishing" a stream (ala goCoder) and know that it is a publish stream and not a player method?

    PHP Code:
    package com.css.module;

    import com.wowza.wms.application.*;
    import com.wowza.wms.amf.*;
    import com.wowza.wms.client.*;
    import com.wowza.wms.module.*;
    import com.wowza.wms.request.*;
    import com.wowza.wms.stream.*;
    import com.wowza.wms.rtp.model.*;
    import com.wowza.wms.httpstreamer.model.*;
    import com.wowza.wms.httpstreamer.cupertinostreaming.httpstreamer.*;
    import com.wowza.wms.httpstreamer.smoothstreaming.httpstreamer.*;
    import com.wowza.wms.mediacaster.IMediaCaster;
    import com.wowza.wms.mediacaster.IMediaCasterNotify2;

    public class 
    RtpTest extends ModuleBase {

        public 
    void doSomething(IClient clientRequestFunction function,
                
    AMFDataList params) {
            
    getLogger().info("doSomething");
            
    sendResult(clientparams"Hello Wowza");
        }

        public 
    void onAppStart(IApplicationInstance appInstance) {
            
    String fullname appInstance.getApplication().getName() + "/"
                    
    appInstance.getName();
            
    getLogger().info("onAppStart: " fullname);
            
            
    appInstance.addMediaCasterListener(new mediacasterNotify());

        }

        public 
    void onAppStop(IApplicationInstance appInstance) {
            
    String fullname appInstance.getApplication().getName() + "/"
                    
    appInstance.getName();
            
    getLogger().info("onAppStop: " fullname);
        }

        public 
    void onRTPSessionCreate(RTPSession rtpSession) {
            
    getLogger().info("onRTPSessionCreate: " rtpSession.getSessionId());
        }

        public 
    void onRTPSessionDestroy(RTPSession rtpSession) {
            
    getLogger().info("onRTPSessionDestroy: " rtpSession.getSessionId());
        }

        class 
    mediacasterNotify implements  IMediaCasterNotify2
          
    {

            public 
    void onConnectFailure(IMediaCaster mediaCaster) {
              
              
    getLogger().info("onConnectFailure");
            }

            public 
    void onConnectStart(IMediaCaster mediaCaster) {
              
              
    getLogger().info("onConnectStart");
              
            }

            public 
    void onConnectSuccess(IMediaCaster mediaCaster) {
              
              
    getLogger().info("onConnectSuccess");
            }

            public 
    void onStreamStart(IMediaCaster mediaCaster) {
              
              
    getLogger().info("onStreamStart");
            }

            public 
    void onStreamStop(IMediaCaster mediaCaster) {
              
              
    getLogger().info("onStreamStop");
            }

            public 
    void onMediaCasterCreate(IMediaCaster mediaCaster) {
              
              
    getLogger().info("onMediaCasterCreate");
            }

            public 
    void onMediaCasterDestroy(IMediaCaster mediaCaster) {
              
              
    getLogger().info("onMediaCasterDestroy");
            }

            public 
    void onRegisterPlayer(IMediaCaster mediaCaster,
                
    IMediaStreamPlay player) {
              
              
    getLogger().info("onRegisterPlayer");
            }

            public 
    void onSetSourceStream(IMediaCaster mediaCaster,
                
    IMediaStream stream) {
              
              
    getLogger().info("onSetSourceStream");
            }

            public 
    void onUnRegisterPlayer(IMediaCaster mediaCaster,
                
    IMediaStreamPlay player) {
              
              
    getLogger().info("onUnRegisterPlayer");
            }
            
          }


    Here is console output when starting and stopping the publishing of a stream via goCoder. Note that none of the mediacaster callbacks are invoked.

    PHP Code:
    INFO server comment Wowza Media Server is started!
    INFO server comment onAppStartrtptest/_definst_
    INFO application app
    -start _definst_ rtptest/_definst_
    INFO server comment 
    onRTPSessionCreate331222317
    INFO rtsp connect 331222317 
    -
    INFO stream create - -
    INFO rtsp announce 331222317 -
    INFO stream publish internap -
    INFO rtsp publish 331222317 -
    INFO stream unpublish internap -
    INFO stream destroy internap -
    INFO server comment onRTPSessionDestroy331222317
    INFO rtsp disconnect 331222317 


  2. #2
    Join Date
    Aug 2011
    Posts
    14

    Default

    So a follow up....

    Do I need to add an actionListener (IRTSPActionNotify) in the onRTPSessionCreate and then take action in onSetup or onRecord?

    Is onRecord or onAnnounce (IRTSPActionNotify) the same as an onPublish? Does a "record" from an RTP/RTSP stream cause a publish? Is that where I should be getting a sessionId from when goCoder starts to publish a stream?

    Bryan
    Last edited by bnystrom; 05-20-2013 at 05:09 PM.

  3. #3
    Join Date
    May 2011
    Posts
    455

    Default

    You can treat GoCoder sessions as a publish, not play.

    -Lisa

  4. #4
    Join Date
    Aug 2011
    Posts
    14

    Default

    Lisa,

    My questions were regarding callbacks for any RTP/RTSP encoder/publisher, not so much about goCoder itself. I really don't know if an incoming RTSP session is from goCoder (publisher) or a player and need to deal with that. This particular app has to deal with both players and encoders/publishers from either RTMP or RTSP. At this point, I pretty much figured out what needed to be done to add RTSP to the mix. Thanks.

    Bryan

  5. #5

    Default

    Hi,

    You should be able to use Notify3, here

    http://www.wowza.com/forums/content....-codec-info%29

    It does work for RTSP streams.

    In the onPublish event you should then be able to get the session for RTMP/RTSP with something like

    PHP Code:

    RTPSession tempSession 
    null;
    IClient tempCSession null;
    String SessionID "";

                try
                {
                    
    tempCSession stream.getClient();
                } catch (
    Exception e ) {}
                
                if ( 
    tempCSession != null )
                { 
                
    SessionID String.valueOf(tempCSession.getClientId());
                }

                try
                {
                
    tempSession stream.getRTPStream().getSession();
                }

                if ( 
    tempSession != null )
                { 
                
    SessionID tempSession.getSessionId();
                } 
    So if it is RTMP or RTSP you should get a SessionID.

    Andrew

Similar Threads

  1. How to cancel playing started by Stream class
    By notreg in forum Server-side Modules and Code Samples Discussion
    Replies: 4
    Last Post: 11-02-2011, 08:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •