Wowza Community

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

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

Yes, definitely.

Richard

You can use the built-in StreamManger in Wowza 2:

http://www.wowza.com/community/t/-/82

Richard

I have installed the mediacasterstreammanager module.

But when I try to connect via the mediacasterstreammanager client with:

Server: rtmp://server-ip/live --> connect

Stream: xxxx.sdp

Nothing shows up in the Active window and I get this error on the server:

INFO session connect-pending xx.xxx.xx.198 -

INFO session connect xx.xxx.xx.198 -

ERROR server comment - invoke(getMediaCasterStreamList): java.lang.NoSuchMethodError: com.wowza.wms.util.ModuleUtils.checkModulePassword(Lcom/wowza/wms/amf/AMFDataList;ILjava/lang/String;)Z: com.wowza.wms.plugin.mediacasterstreammanager.ModuleMediaCasterStreamManager.getMediaCasterStreamList(null:-1)

java.lang.NoSuchMethodError: com.wowza.wms.util.ModuleUtils.checkModulePassword(Lcom/wowza/wms/amf/AMFDataList;ILjava/lang/String;)Z

at com.wowza.wms.plugin.mediacasterstreammanager.ModuleMediaCasterStreamManager.getMediaCasterStreamList(Unknown Source)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at com.wowza.wms.module.ModuleFunction.invoke(ModuleFunction.java:86)

at com.wowza.wms.module.ModuleFunctions.invoke(ModuleFunctions.java:151)

at com.wowza.wms.request.RequestProcessFunctions.processFunctions(RequestProcessFunctions.java:107)

at com.wowza.wms.client.ClientWorker.processNextReq(ClientWorker.java:102)

at com.wowza.wms.request.RTMPRequestAdapter.service(RTMPRequestAdapter.java:350)

at com.wowza.wms.server.ServerHandler.serviceRequest(ServerHandler.java:479)

at com.wowza.wms.server.ServerHandler.handleMessageReceived(ServerHandler.java:270)

at com.wowza.wms.server.ServerHandler.messageReceived(ServerHandler.java:347)

at com.wowza.wms.server.ServerHandlerThreadedSession.run(ServerHandlerThreadedSession.java:108)

at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

at java.lang.Thread.run(Thread.java:619)

ERROR server comment - invoke(startMediaCasterStream): java.lang.NoSuchMethodError: com.wowza.wms.util.ModuleUtils.checkModulePassword(Lcom/wowza/wms/amf/AMFDataList;ILjava/lang/String;)Z: com.wowza.wms.plugin.mediacasterstreammanager.ModuleMediaCasterStreamManager.startMediaCasterStream(null:-1)

java.lang.NoSuchMethodError: com.wowza.wms.util.ModuleUtils.checkModulePassword(Lcom/wowza/wms/amf/AMFDataList;ILjava/lang/String;)Z

at com.wowza.wms.plugin.mediacasterstreammanager.ModuleMediaCasterStreamManager.startMediaCasterStream(Unknown Source)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at com.wowza.wms.module.ModuleFunction.invoke(ModuleFunction.java:86)

at com.wowza.wms.module.ModuleFunctions.invoke(ModuleFunctions.java:151)

at com.wowza.wms.request.RequestProcessFunctions.processFunctions(RequestProcessFunctions.java:107)

at com.wowza.wms.client.ClientWorker.processNextReq(ClientWorker.java:102)

at com.wowza.wms.request.RTMPRequestAdapter.service(RTMPRequestAdapter.java:350)

at com.wowza.wms.server.ServerHandler.serviceRequest(ServerHandler.java:479)

at com.wowza.wms.server.ServerHandler.handleMessageReceived(ServerHandler.java:270)

at com.wowza.wms.server.ServerHandler.messageReceived(ServerHandler.java:347)

at com.wowza.wms.server.ServerHandlerThreadedSession.run(ServerHandlerThreadedSession.java:108)

at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

at java.lang.Thread.run(Thread.java:619)

What is done wrong?

Thanks

… I thought that patch was already in place, but not…

Thanks.

When I set the Streamtype on rtp-live-record, for instance in the nativeRTP application, and I make a recording by connecting to the NativeRTP application, I am able to playback that recording, for instance in the nativeRTP of Fastplay application.

When I do a recording via the mediacasterstreammanager I am not able to playback the file in any of the WMS applications. Although when I download the file I can playback the file with VLC at good quality.

What is going different between these two ways of recording? And what can be done to get good recordings via the Mediacasterstreammanager which can be played back in standard WMS applications.

Thanks.

Has somebody a answer on this one?

Regards

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

Ok, that’s what I’ve done and it works great !

Since I use this module, I noticed record starts after a long time. Looking at logs, I see this :

INFO server comment 2009-02-16 12:05:30 33.155 UDPTransport.firstPacket: /XXX.XXX.XXX.XXX:XXXX

INFO server comment 2009-02-16 12:05:30 33.167 UDPTransport.firstPacket: /XXX.XXX.XXX.XXX:XXXX

WARN server comment 2009-02-16 12:05:38 41.165 Waiting for RTCP packet. See docs for (Application.xml: RTP/AVSyncMethod and RTP/MaxRTCPWaitTime).

WARN server comment 2009-02-16 12:05:39 41.274 Waiting for RTCP packet. See docs for (Application.xml: RTP/AVSyncMethod and RTP/MaxRTCPWaitTime).

WARN server comment 2009-02-16 12:05:42 45.173 RTCPHandler.isTimeSyncReady: Hit MaxRTCPWaitTime synchronizing on system clock.

Looking at Application.xml, StreamType is “live”, AVSyncMethod is “senderreport” and MaxRTCPWaitTime is “12000”.

So I guess nothing happens before a 12 seconds delay.

Do I need to change anything to make record start faster ?

Thank you.