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

**URL:** <https://community.wowza.com/t/mediacasterstreammanager-controls-start-stop-record-of-rtp-mpeg-ts-and-shoutcast/54>\
**Category:** Wowza Streaming Engine\
**Created:** [January 26, 2009, 12:48pm UTC](https://community.wowza.com/t/mediacasterstreammanager-controls-start-stop-record-of-rtp-mpeg-ts-and-shoutcast/54 "2009-01-26T12:48:58Z")\
**Posts on this page:** 16\
**Page:** 3

<div class="post-metadata">

**Author:** ![Matthias\_Kutscher](https://avatars.discourse-cdn.com/v4/letter/m/71e660/32.png) [@Matthias\_Kutscher](https://community.wowza.com/u/Matthias_Kutscher)\
**Post date:** [July 5, 2009, 8:57pm UTC](https://community.wowza.com/t/mediacasterstreammanager-controls-start-stop-record-of-rtp-mpeg-ts-and-shoutcast/54/41 "2009-07-05T20:57:17Z")

</div>

Here the complete code (sorry, I needed to remove some parts of our business logic - it’s a project at our university)

S2.java:

```auto
package de.mpgz.camm;
import com.wowza.wms.*;
public class S2 extends ModuleBase {
	
	private IApplicationInstance appInstance = null;
	public void onAppStart(IApplicationInstance appInstance) {
		String fullname = appInstance.getApplication().getName() + "/"
				+ appInstance.getName();
		getLogger().info("onAppStart: " + fullname);
		
		// RESTRICT TO DEFAULT INSTANCE
		if(!appInstance.getName().equalsIgnoreCase(ApplicationInstance.DEFAULT_APPINSTANCE_NAME))
		{
			appInstance.shutdown(false, false);
		} else {
			// Save Instance
			this.appInstance = appInstance;
		}
	}
    
        public void startMediaCasterStream(String group, String streamName, String mediaCasterType, String name, String size, int bitrate)
	{
		try
		{
			while(true)
			{
				getLogger().info("ModuleMediaCasterStreamManager.startMediaCasterStream["+mediaCasterType+"]: "+streamName);
				
				MediaCasterStreamMap mediaCasterMap = this.appInstance.getMediaCasterStreams();
				IVHost vhost = this.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;
				}
				
				boolean success = mediaCasterStreamManager.startStream(streamName, mediaCasterType);
				if (success)
				{ getLogger().info("ModuleMediaCasterStreamManager.startMediaCasterStream: Stream started: "+streamName);
				}
				else
				{
					getLogger().info("ModuleMediaCasterStreamManager.startMediaCasterStream: Stream failed: "+streamName);
				}
				break;
			}
		}
		catch (Exception e)
		{
			getLogger().error("ModuleMediaCasterStreamManager.startMediaCasterStream: "+e.toString());
		}
	}
	
	// NEEDED INFO: streamName (glf.sdp)
	public void stopMediaCasterStream(String streamName)
	{
		try
		{
			while(true)
			{
				getLogger().info("ModuleMediaCasterStreamManager.stopMediaCasterStream: "+streamName);
						
				MediaCasterStreamMap mediaCasterMap = this.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.stopMediaCasterStream: "+e.toString());
		}
	}
}

```

CaMMServerListener.java:

```auto
package de.mpgz.camm;
import com.wowza.wms.*;
import edu.emory.mathcs.backport.java.util.concurrent.locks.WMSReadWriteLock;
public class CaMMServerListener implements IServerNotify {
	private CaMM_S2 Main;
	public void onServerCreate(IServer server) {
		// TODO Auto-generated method stub
		this.Main = new CaMM_S2(server);
	}
	
	private void loadAndLockAppInstance(IVHost vhost, String appName, String appInstanceName)
	{
		IApplication localApplication = null;
		IApplicationInstance localAppInstance = null;
		
		WMSReadWriteLock appLock = vhost.getApplicationLock();
		appLock.writeLock().lock();
		try
		{
	    	localApplication = vhost.getApplication(appName);
    		if (localApplication != null)
    		{
	    		localAppInstance = localApplication.getAppInstance(appInstanceName);
	    		localAppInstance.setApplicationTimeout(0);
	    		if(appName.equalsIgnoreCase("live"))
	    		{
	    			this.Main.setLiveApplication((S2)localAppInstance.getModuleInstance("S2"));
	    		}
    		} else {
    			WMSLoggerFactory.getLogger(null).warn("Application folder ([install-location]/applications/"+appName+") is missing");
    		}
		}
		catch (Exception e)
		{
			WMSLoggerFactory.getLogger(null).error("CaMMServerListener.loadAndLockAppInstance: "+ appName + " - " + e.toString());
		}
		finally
		{
			appLock.writeLock().unlock();
		}
	}
	public void onServerInit(IServer server) {
		IVHost vhost = VHostSingleton.getInstance(VHost.VHOST_DEFAULT);
		loadAndLockAppInstance(vhost, "live", ApplicationInstance.DEFAULT_APPINSTANCE_NAME);
		
		this.Main.startup();
	}
	public void onServerShutdownStart(IServer server) {
		this.Main.shutdown();
	}
	public void onServerShutdownComplete(IServer server) {
		// TODO Auto-generated method stub
	}
}

```

conf/live/Application.xml:

```auto
                        <Module>
				<Name>S2</Name>
				<Description>CaMM S2 Plugin</Description>
				<Class>de.mpgz.camm.S2</Class>
			</Module>

```

conf/Server.xml

```auto
                        <ServerListener>
                            <BaseClass>de.mpgz.camm.CaMMServerListener</BaseClass>
                        </ServerListener>

```

(You can use auto-generated imports to keep them small.)

And instead of “this.Main = new CaMM\_S2(server);” in the CaMMServerListener you can use your own class to check if the .sdp file is existing or wait for network connections (like we do).

---

<div class="post-metadata">

**Author:** ![Markus\_Roth](https://avatars.discourse-cdn.com/v4/letter/m/85e7bf/32.png) [@Markus\_Roth](https://community.wowza.com/u/Markus_Roth)\
**Post date:** [February 27, 2009, 1:16pm UTC](https://community.wowza.com/t/mediacasterstreammanager-controls-start-stop-record-of-rtp-mpeg-ts-and-shoutcast/54/42 "2009-02-27T13:16:49Z")

</div>

Hi Charlie,

I am testing the MediaCasterStreamManger. I try to record an stream delivered by Darwin Streaming Server 6. My problem is that Wowza server records only 2 minutes. The recording works perfect, but the Wowza server receives/requests no more data from the Darwin Streaming server after the 2 minutes. (Connecton to dss closes after 2 minutes)

(another setup together with same encoder, darwin server and the rtplive application works perfect)

regards

schaba

---

<div class="post-metadata">

**Author:** ![Markus\_Roth](https://avatars.discourse-cdn.com/v4/letter/m/85e7bf/32.png) [@Markus\_Roth](https://community.wowza.com/u/Markus_Roth)\
**Post date:** [February 27, 2009, 6:03pm UTC](https://community.wowza.com/t/mediacasterstreammanager-controls-start-stop-record-of-rtp-mpeg-ts-and-shoutcast/54/43 "2009-02-27T18:03:57Z")

</div>

i am using your

/client/mediacasterstreammanager.html

into the field Stream in enter for example my Darwin Streamin URL:

rtsp://c14005-l.m.core.cdn.streamfarm.net/14005dgcom/live/3745ebs/ebs\_stream01.sdp

its an public stream, delivered by our Dariwin6 Streaming Server.

When I press the Start Stream button the stream will be recorded for 2 minutes.

When I watch the traffic on the network interfaces I can see udp packets between darwin and the wowza server (Port 6970 / 699x). But after 2 minutes no more udp pakets can be seen on the network interface.

Or is it possible to record the stream using a relayed stream from darwin to wowza, because the rtplive application, which I already use, works perfect.

Wowza URL:

rtmp://c14005-l.z.core.cdn.streamfarm.net/rtplive/14005dgcom/live/3745ebs/ebs\_stream01.sdp

(i have installed WowzaMediaServerPro1.6.0-patch22)

---

<div class="post-metadata">

**Author:** ![Markus\_Roth](https://avatars.discourse-cdn.com/v4/letter/m/85e7bf/32.png) [@Markus\_Roth](https://community.wowza.com/u/Markus_Roth)\
**Post date:** [March 2, 2009, 10:34am UTC](https://community.wowza.com/t/mediacasterstreammanager-controls-start-stop-record-of-rtp-mpeg-ts-and-shoutcast/54/44 "2009-03-02T10:34:27Z")

</div>

Is there a way to record the stream I already push with darwin to the woza server?

rtmp://wowzaserveradress/rtplive/streamname.sdp

---

<div class="post-metadata">

**Author:** ![Roman\_Shmelev](https://avatars.discourse-cdn.com/v4/letter/r/e5b9ba/32.png) [@Roman\_Shmelev](https://community.wowza.com/u/Roman_Shmelev)\
**Post date:** [May 15, 2009, 11:41am UTC](https://community.wowza.com/t/mediacasterstreammanager-controls-start-stop-record-of-rtp-mpeg-ts-and-shoutcast/54/45 "2009-05-15T11:41:30Z")

</div>

Hi!

Is there any way to record MediaCasterStreams if there is no even application instance running?

I mean sheduled recording: separate thread will determine that it is time to start recording - it will launch Application Instance, then start mediaCasterStream

Thank you!

---

<div class="post-metadata">

**Author:** ![Roman\_Shmelev](https://avatars.discourse-cdn.com/v4/letter/r/e5b9ba/32.png) [@Roman\_Shmelev](https://community.wowza.com/u/Roman_Shmelev)\
**Post date:** [May 15, 2009, 12:12pm UTC](https://community.wowza.com/t/mediacasterstreammanager-controls-start-stop-record-of-rtp-mpeg-ts-and-shoutcast/54/46 "2009-05-15T12:12:12Z")

</div>

Uh… finally found IVHost.startApplicationInstance… will try it.

---

<div class="post-metadata">

**Author:** ![Alejandro\_Ferrari](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@Alejandro\_Ferrari](https://community.wowza.com/u/Alejandro_Ferrari)\
**Post date:** [July 3, 2009, 6:37pm UTC](https://community.wowza.com/t/mediacasterstreammanager-controls-start-stop-record-of-rtp-mpeg-ts-and-shoutcast/54/47 "2009-07-03T18:37:30Z")

</div>

Hi Charlie,

Currently I use the MediaCaster Client, for start/stop the Live Streaming… is possible make the same but directly from ServerSide, the idea is don’t use FlashClient…

If this possible, you have any example?

Thanks

Alejandro

---

<div class="post-metadata">

**Author:** ![Alejandro\_Ferrari](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@Alejandro\_Ferrari](https://community.wowza.com/u/Alejandro_Ferrari)\
**Post date:** [July 3, 2009, 6:57pm UTC](https://community.wowza.com/t/mediacasterstreammanager-controls-start-stop-record-of-rtp-mpeg-ts-and-shoutcast/54/48 "2009-07-03T18:57:40Z")

</div>

Thanks, currently I use the 1.7 version with VLC and SDP file, and don’t need MediaCaster for start from the cliente, only call to the SDP File inside the Content directory… really me ask is for I test the same with 2.0 Preview version and don’t work without MediaCasterClient interface.

Here my need, and I’m a SysAdmin and don’t programing in Java, me home solution now are, use VNC Server start the Browser, open Flash Interface and start the Stream, this Work but is very very bad idea… thanks again…

Alejandro

---

<div class="post-metadata">

**Author:** ![Alejandro\_Ferrari](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@Alejandro\_Ferrari](https://community.wowza.com/u/Alejandro_Ferrari)\
**Post date:** [July 4, 2009, 4:19pm UTC](https://community.wowza.com/t/mediacasterstreammanager-controls-start-stop-record-of-rtp-mpeg-ts-and-shoutcast/54/49 "2009-07-04T16:19:49Z")

</div>

Matthias,

Yes, please… an example is appreciated… thanks…

---

<div class="post-metadata">

**Author:** ![Alejandro\_Ferrari](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@Alejandro\_Ferrari](https://community.wowza.com/u/Alejandro_Ferrari)\
**Post date:** [July 5, 2009, 3:47pm UTC](https://community.wowza.com/t/mediacasterstreammanager-controls-start-stop-record-of-rtp-mpeg-ts-and-shoutcast/54/50 "2009-07-05T15:47:52Z")

</div>

Thanks a lot… only one more question, inside the Wowza, you have one example how setting this? for example in Application.xml

Thanks again… I understand the code perfectly…

---

<div class="post-metadata">

**Author:** ![Maumene\_Alexandre](https://avatars.discourse-cdn.com/v4/letter/m/f475e1/32.png) [@Maumene\_Alexandre](https://community.wowza.com/u/Maumene_Alexandre)\
**Post date:** [September 28, 2010, 3:02pm UTC](https://community.wowza.com/t/mediacasterstreammanager-controls-start-stop-record-of-rtp-mpeg-ts-and-shoutcast/54/51 "2010-09-28T15:02:40Z")

</div>

Can it be use with Wowza2 too?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Maumene\_Alexandre](https://avatars.discourse-cdn.com/v4/letter/m/f475e1/32.png) [@Maumene\_Alexandre](https://community.wowza.com/u/Maumene_Alexandre)\
**Post date:** [September 28, 2010, 3:07pm UTC](https://community.wowza.com/t/mediacasterstreammanager-controls-start-stop-record-of-rtp-mpeg-ts-and-shoutcast/54/52 "2010-09-28T15:07:24Z")

</div>

Ok,

I’ve install the module but I get “Missing function: startMediaCasterStream” in Wowza’s logs ☹

---

<div class="post-metadata">

**Author:** ![Maumene\_Alexandre](https://avatars.discourse-cdn.com/v4/letter/m/f475e1/32.png) [@Maumene\_Alexandre](https://community.wowza.com/u/Maumene_Alexandre)\
**Post date:** [September 28, 2010, 3:17pm UTC](https://community.wowza.com/t/mediacasterstreammanager-controls-start-stop-record-of-rtp-mpeg-ts-and-shoutcast/54/53 "2010-09-28T15:17:55Z")

</div>

I’ve made a mistake when I’ve installed the module.

It’s now work correctly.

---

<div class="post-metadata">

**Author:** ![Maumene\_Alexandre](https://avatars.discourse-cdn.com/v4/letter/m/f475e1/32.png) [@Maumene\_Alexandre](https://community.wowza.com/u/Maumene_Alexandre)\
**Post date:** [September 28, 2010, 3:53pm UTC](https://community.wowza.com/t/mediacasterstreammanager-controls-start-stop-record-of-rtp-mpeg-ts-and-shoutcast/54/54 "2010-09-28T15:53:33Z")

</div>

Hi,

I would like to add the method getMediaCasterType to MediaCasterStreamManager module because I want to get by flash if a stream is in rtp type or rtp-record type.

I’ve take a look at the source code of MediaCasterManager but I don’t know how to implement the getMediaCasterType method.

Can you help me?

---

<div class="post-metadata">

**Author:** ![Fedya\_Mosalov](https://avatars.discourse-cdn.com/v4/letter/f/ecccb3/32.png) [@Fedya\_Mosalov](https://community.wowza.com/u/Fedya_Mosalov)\
**Post date:** [November 12, 2009, 8:43pm UTC](https://community.wowza.com/t/mediacasterstreammanager-controls-start-stop-record-of-rtp-mpeg-ts-and-shoutcast/54/55 "2009-11-12T20:43:59Z")

</div>

I have installed the StreamNameAlias module and put one alias in StreamNameAlias.txt:

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

Then I have tried two scenarios with MediaCasterStreamManager web client.

First scenario:

1. Start stream rtmp://xx.xx.xx.xx/live/_definst_/livestream with type ‘liverepeater’ via MediaCasterStreamManager web client.

2. Connect to ‘mystream’ (described above in StreamNameAlias.txt) and see video in flash video player.

3. Stop stream.

4. Video has stopped in the player.

That’s ok.

Second scenario:

1. Connect to ‘mystream’ (described above in StreamNameAlias.txt) and see video in flash video player.

2. Try to start stream with the same name via MediaCasterStreamManager web client and get **"MediaCaster already exists[mediacaster]: rtmp://xxx.xx.xx.xx/live/_definst_/livestream"**

3. Then I try to stop the stream and get **"Stream not found: rtmp://xxx.xx.xx.xx/live/_definst_/livestream"**

In the second scenario stream is not listed in _Active:_ field. So, why I can’t stop the stream which has been automatically created when the player was connected?

---

<div class="post-metadata">

**Author:** ![Fedya\_Mosalov](https://avatars.discourse-cdn.com/v4/letter/f/ecccb3/32.png) [@Fedya\_Mosalov](https://community.wowza.com/u/Fedya_Mosalov)\
**Post date:** [November 13, 2009, 1:57am UTC](https://community.wowza.com/t/mediacasterstreammanager-controls-start-stop-record-of-rtp-mpeg-ts-and-shoutcast/54/56 "2009-11-13T01:57:18Z")

</div>

> This won’t work:
> 
> mystream=rtmp://xxx.xx.xx.xx/live/_definst_/livestream
> 
> Because you are using a rtmp url for stream name.

It works! The application type is ‘liverepeater’ if it matters. I use two applications: one is ‘live’ and another is ‘liverepeater’. Aliases concern a ‘liverepeater’ application.

[Previous page](https://community.wowza.com/t/mediacasterstreammanager-controls-start-stop-record-of-rtp-mpeg-ts-and-shoutcast/54.md?page=2)
