Wowza Community

MediaCasterStreamManager controls start/stop/record of RTP, MPEG-TS and SHOUTcast

This package provides a Flash tool to interface with the MediaCasterStreamManager API. This to tool is used to start and stop the publishing of non-pushed based encoder streams such as Native RTP, MPEG-TS and SHOUTcast. It provides greater control over the publishing and recording process when using these encoder technologies. This tool is designed to work with the live, live-lowlatency and liverepeater-origin stream types rather than the MediaCaster stream types (rtp-live[-*] and shoutcast[-*]). The MediaCasterStreamManager API can also be accessed using the JMX/JConsole interface to the server. The MediaCasterStreamManager interface is available in JConsole in the MBean tab in the application folder of the application you wish to control.

MediaCasterStreamManager.zip

Note: Wowza Pro 1.6.0-patch17 or greater required

Enjoy,

Charlie

You will need to rename the file after it has completed being written.

Charlie

Try changing AVSyncMethod to one of the other two valid values. It sounds like the encoder you are using does not generate RTCP packets.

Charlie

Same answer. I know VLC doesn’t generate RTCP packets. See which of the other two values gives you better results. Also, be sure you modify your command line to increase the key frame rate.

Change the encoder part:

from:
venc=x264,vcodec=x264
to:
venc=x264{keyint=2},vcodec=x264

Charlie

This will increase the frequency at which the encoder generates key frames. It will improve stream startup time since the stream needs a key frame to start. Yes, you will most likely need to regenerate the SDP file.

Charlie

Upgrade to the most recent patch (patch21) from here:

http://www.wowza.com/devbuild.html

Charlie

Someone else reported a similar issue and it was due to the fact that Wowza Pro does not send RTCP RR packets. See if there is a way to configure Darwin so that it is not depending on these packets. At this time we do not have plans to implement RTCP RR packets.

Charlie

You are probably moving or copying the file before it has completely been written. The file is done being written the the unpublish event is throw/logged. Before that the duration written to the file header is zero.

Wowza Pro does have a way if the duration is incorrect in the header to derive it by looking at the last packet in the file.

Charlie

I believe that is correct. I don’t think the stream has been written after stopStream. I believe this operation is asynchronous. You will need to use the IMediaStreamActionNotify2 interface and add a listener to get notification of the onUnPublish event.

Charlie

Be sure that each time you start the stream you select rtp-record from the list of media caster stream types in the MediaCasterStreamManager.

Charlie

Thank you Charlie, as I told you before, it works great.

But now I would like to know if there’s a way to control the recorded file name.

For now, if stream name is “stream.sdp”, recorded file name is always “stream.sdp.flv”.

To avoid erasing previous recorded files, I would like to set name to “streamXXXXXXXXXXXX.flv” where XXXXXXXXXXXX is current date/time (YYYYMMDDHHMM).

What do I need to change in ModuleMediaCasterStreamManager.java to do this ? startStream() method parameters ?

Thx.

If you recording using the mediacasterstreammanager the file is not properly closed until the mediacasterstreammanager is used to stop the stream. If you grab the file before the stream is stopped then the moov atom will not be written properly.

If this is not the problem then please send me the errant file and I will have a look (charlie@wowza.com).

Charlie

Please describe in detail how you are connecting to Darwin. Is it through RTSP or native RTP. Are you seeing any log statements when the stream stops. Be sure to install the most recent patch. Some of the RTSP re-streaming code has been improved (http://www.wowza.com/devbuild.html).

I need a lot more detail to help.

Charlie

I need to think about this more. It is a clear need. The source code for the MediaCasterStreamManager is included in the package. So you can fashion a different solution to fit your needs. I will continue to think about how to make this a more straight forward operation.

Charlie

The easiest way is change the StreamType to “rtp-live-record”

Richard

Try this:

package
import com.wowza.wms.amf.AMFDataItem;
import com.wowza.wms.amf.AMFDataObj;
import com.wowza.wms.amf.AMFPacket;
import com.wowza.wms.application.WMSProperties;
import com.wowza.wms.module.*;
import com.wowza.wms.stream.IMediaStream;
import com.wowza.wms.stream.IMediaStreamActionNotify;
import com.wowza.wms.stream.IMediaStreamActionNotify2;
public class MediaStreamActionNotify2Example extends ModuleBase {
	
	public void onStreamCreate(IMediaStream stream) {
		getLogger().info("onStreamCreate by: " + stream.getClientId());
		IMediaStreamActionNotify actionNotify  = new StreamListener();
		
		WMSProperties props = stream.getProperties();
		synchronized(props)
		{
			props.put("streamActionNotifier", actionNotify);
		}
		stream.addClientListener(actionNotify);
	}
	public void onStreamDestroy(IMediaStream stream) {
		getLogger().info("onStreamDestroy by: " + stream.getClientId());
		
		IMediaStreamActionNotify actionNotify = null;
		WMSProperties props = stream.getProperties();
		synchronized(props)
		{
			actionNotify = (IMediaStreamActionNotify)stream.getProperties().get("streamActionNotifier");
		}
		if (actionNotify != null)
		{
			stream.removeClientListener(actionNotify);
			getLogger().info("removeClientListener: "+stream.getSrc());
		}
	}
	
	class StreamListener  implements IMediaStreamActionNotify2 
	{
		public void onPlay(IMediaStream stream, String streamName, double playStart, double playLen, int playReset) 
		{
			
		}
		public void onMetaData(IMediaStream stream, AMFPacket metaDataPacket) 
		{
			
		}
		
		public void onPauseRaw(IMediaStream stream, boolean isPause, double location) 
		{
			
		}
		public void onSeek(IMediaStream stream, double location)
		{
			getLogger().info("onSeek");
		}
		
		public void onStop(IMediaStream stream)
		{
			getLogger().info("onStop By: " + stream.getClientId());
		}
		
		public void onUnPublish(IMediaStream stream, String streamName, boolean isRecord, boolean isAppend)
		{
			getLogger().info("onUN Publish");
		}
		public  void onPublish(IMediaStream stream, String streamName, boolean isRecord, boolean isAppend)
		{
			getLogger().info("onPublish");					
		}
		public void onPause(IMediaStream stream, boolean isPause, double location)
		{
			getLogger().info("onPause");
		}
	}
}

Richard

I don’t have experience with that package yet, but I took a look at the included source, and there is a stopMediaCasterStream method that returns results to the calling client. You might be able to use that on the client.

In AS3 (untested) I think it will look something like this:

netconnection.call("stopMediaCasterStream", new Responder(mediacasterResponse));
private function mediacasterResponse(response:Object):void
{
 if (response.description.indexOf("Stream stopped:")>-1)
  {
    trace("stream ready to move");
  }
}

Richard

I think you are right. So just copy and paste 3 things from the Java Example I sent into ModuleMediaCasterStreamManager.java

public void onStreamCreate(IMediaStream stream) {

}

public void onStreamDestroy(IMediaStream stream) {

}

class StreamListener implements IMediaStreamActionNotify2

}

Richard

This won’t work:

mystream=rtmp://xxx.xx.xx.xx/live/definst/livestream

Because you are using a rtmp url for stream name.

alias = stream name

This will work:

mystream=livestream

But for that to work you have to be sending an actual live stream named “livestream” with an encoder such as Wirecast that will push a live stream over rtmp to Wowza. Then in a player you can play a stream “mystream” and the alias system will kick in and transform mystream to livestream, if that’s useful.

With rtsp streams, where the stream name itself is a url like rtsp://ipcamera-ip:554, and you can use an alias to simplify:

mystream= rtsp://ipcamera-ip:554

In this case the rtsp url is a stream name. So “mystream” will be expanded by the alias system to the rtsp url.

Richard

Great!, thanks for the update. glad it’s working.

Richard