Results 1 to 5 of 5

Thread: Launching Record on a non-existing stream via HTTPProvider

  1. #1
    Join Date
    Feb 2010
    Posts
    121

    Unhappy Launching Record on a non-existing stream via HTTPProvider

    Hi There,

    I'm actually trying to make a Record Module for Wowza Server which can record live stream coming from VLC.
    All the records will be triggered by a HTTP Provider, so you will be able to send HTTP request like this (http://localhost:9098/recordModule?s...ame=camera.sdp) to launch a record.
    But my problem is that I don't know how to launch a record on a stream that doesn't exists. is it possible to create the stream manually or to simulate a client call to launch the stream ?

  2. #2

    Default

    You can use the MediaCaster API to start the stream. The code to start/stop the stream looks like this:

    Code:
    public boolean startMediaCasterStream(String streamName, String mediaCasterType)
    {
    	boolean success = false;
    	try
    	{
    		while(true)
    		{
    			MediaCasterStreamMap mediaCasterMap = appInstance.getMediaCasterStreams();
    			IVHost vhost = appInstance.getVHost();
    			MediaCasterStreamManager mediaCasterStreamManager = mediaCasterMap.getStreamManager();
    
    			MediaCasterList mediaCasterList = vhost.getMediaCasterList();
    			MediaCasterItem mediaCasterDef = mediaCasterList.getMediaCasterDef(mediaCasterType);
    
    			if (mediaCasterDef == null)
    			{
    				getLogger().warn("ModuleMediaCasterStreamManager.startMediaCasterStream: MediaCaster type not found: "+mediaCasterType);
    				break;
    			}
    
    			MediaCasterStreamItem mediaCasterStream = mediaCasterMap.getMediaCaster(streamName);
    			if (mediaCasterStream != null)
    			{
    				getLogger().warn("ModuleMediaCasterStreamManager.startMediaCasterStream: MediaCaster already exists[mediacaster]: "+streamName);
    				break;
    			}
    
    			success = mediaCasterStreamManager.startStream(streamName, mediaCasterType);
    			if (success)
    				getLogger().info("ModuleMediaCasterStreamManager.startMediaCasterStream: Stream started: "+streamName);
    			else
    				getLogger().warn("ModuleMediaCasterStreamManager.startMediaCasterStream: Stream start failed: "+streamName);
    			break;
    		}
    	}
    	catch (Exception e)
    	{
    		getLogger().error("ModuleMediaCasterStreamManager.startMediaCasterStream: "+e.toString());
    	}
    
    	return success;
    }
    
    public void stopMediaCasterStream(String streamName)
    {
    	try
    	{
    		while(true)
    		{
    			MediaCasterStreamMap mediaCasterMap = appInstance.getMediaCasterStreams();
    			MediaCasterStreamManager mediaCasterStreamManager = mediaCasterMap.getStreamManager();
    
    			boolean success = mediaCasterStreamManager.stopStream(streamName);
    			if (success)
    			{
    				getLogger().info("ModuleStreamStarter.stopMediaCasterStream: Stream stopped: "+streamName);
    			}
    			else
    			{
    				getLogger().warn("ModuleMediaCasterStreamManager.stopMediaCasterStream: Stream not found: "+streamName);
    			}
    			break;
    		}
    	}
    	catch (Exception e)
    	{
    		getLogger().error("ModuleMediaCasterStreamManager.startMediaCasterStream: "+e.toString());
    	}
    }
    So in your case to start/stop the stream it would be:

    Code:
    startMediaCasterStream("camera.sdp", "rtp");
    stopMediaCasterStream("camera.sdp");
    Charlie

  3. #3
    Join Date
    Feb 2010
    Posts
    121

    Question

    Thank You so much !

    I used Charlie's code because I need to stream RTP,
    and now I can see the stream starting and playing in wowza logs.
    But there is another thing I didn't success to do in my Record Module, it's to retreive the IMediaStream instance corresponding to the stream created.
    My method to access the stream instance was :

    IMediaStream stream = appInstance.getStreams().getStream(streamName);

    but it returns always null !

    How is it possible ?

  4. #4

    Default

    Check the list of stream names. Maybe you have the wrong stream name:

    appInstance.getStreams().getPublishStreamNames()

    It will return the list of currently active stream names.

    Charlie

  5. #5
    Join Date
    Feb 2010
    Posts
    121

    Smile

    ok It's works fine it was just an error in my code ...
    Thank you again for your help it really helps me !

Posting Permissions

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