Wowza Community

Stream class stream controller

Just received your answer Richard. Don’t know where to go now :frowning:

I read all the postings in that thread and didn’t find how to make specific Stream entity common to both way to handle it.

Also, I don’t know where the error line in logs come from … Will investigate more on this …

Sorry, I don’t understand. To be clear, when I read this :

You can use this with (or without) the server listener stream scheduler. If this application module is used in the same application that the scheduler populates with Streams and Playlists, you can use this application can be used to control those Streams and Playlists.

I understand that if “Stream1” is created in scheduler with “pl1”, I can for instance add items to “pl1” from controller. “Stream1” and “pl1” are shared between scheduler and controller. Is it right ?

Hi Richard,

I would like to know if possible DELETE files from a playlist.

We have one module than allow to AddItems to one playlist dynamically without problems, but we have some doubt about how we can Remove items from this list on the fly.

Can you tell me if have some function for doing this with the API?

SORRY: The answer is in a old post: http://www.wowza.com/forums/showpost.php?p=35672&postcount=19

Boolean success = stream.removeFromPlaylist("Extremists.flv");

Thanks in advance,

Alejandro

Thanks for your quick reply.

I am assuming the module is "ServerPublisher (Wowza Media Server 2 Advanced required)

Server Listener that uses the new Stream class to publish live streams from static content. You can also schedule streams, like a TV station".

If this is the module, I have already have this done. It worked using the scheduler but am not able to use this with this http://www.wowza.com/downloads/forums/collection/client/StreamClassControl.zip.

I am trying to follow this instructions "Enter a Stream (I filled in “StreamNew”), then click “add stream”

Enter a Playlist (I filled in “playlistNew”), then click “add playlist”

Add at least one item to the playlist (I filled in “mp4:Extremists.m4v” with start of 0 and length -1), click “add Item to playlist”

Then click “open playlist on stream”

Then in above, enter the streamname, “StreamNew” and click “Play”

To add a new item, enter a new video name with start and length, and click “add item to playlist”, then click open “open playlist on stream again”. If the video is currently playing, the new item will start playing after the current one or when it cycles through to the end. You can also click “play next item”

Thanks.

The /conf/live/Application.xml now looks like this:

true

localhost

live

${com.wowza.wms.context.VHostConfigHome}/content

${com.wowza.wms.context.VHostConfigHome}/keys

cupertinostreaming,smoothstreaming

-1

*

*

*

*

digest

digest

senderreport

12000

*

base

Base

com.wowza.wms.module.ModuleCore

properties

Properties

com.wowza.wms.module.ModuleProperties

logging

Client Logging

com.wowza.wms.module.ModuleClientLogging

flvplayback

FLVPlayback

com.wowza.wms.module.ModuleFLVPlayback

ModuleMediaCasterStreamManager

ModuleMediaCasterStreamManager

com.wowza.wms.plugin.mediacasterstreammanager.ModuleMediaCasterStreamManager

mediaCasterStreamManagerPassword

!()$£&^%"!901

Does that seems right?

Thanks.

Thanks fot your help.

This is now the amended version.

true

live

${com.wowza.wms.context.VHostConfigHome}/content

${com.wowza.wms.context.VHostConfigHome}/keys

cupertinostreaming,smoothstreaming

-1

*

*

*

*

digest

digest

senderreport

12000

*

base

Base

com.wowza.wms.module.ModuleCore

properties

Properties

com.wowza.wms.module.ModuleProperties

logging

Client Logging

com.wowza.wms.module.ModuleClientLogging

flvplayback

FLVPlayback

com.wowza.wms.module.ModuleFLVPlayback

ModuleMediaCasterStreamManager

ModuleMediaCasterStreamManager

com.wowza.wms.plugin.mediacasterstreammanager.ModuleMediaCasterStreamManager

streamcontroller

ModuleStreamControl

com.wowza.wms.plugin.collection.module.ModuleStreamControl

streamcontroller

ModuleStreamControl

com.wowza.wms.plugin.collection.module.ModuleStreamControl

mediaCasterStreamManagerPassword

!()$£&^%"!901

Does this sound right now?

Thanks again.

The new version is like this:

true

live

${com.wowza.wms.context.VHostConfigHome}/content

${com.wowza.wms.context.VHostConfigHome}/keys

cupertinostreaming,smoothstreaming

-1

*

*

*

*

digest

digest

senderreport

12000

*

base

Base

com.wowza.wms.module.ModuleCore

properties

Properties

com.wowza.wms.module.ModuleProperties

logging

Client Logging

com.wowza.wms.module.ModuleClientLogging

flvplayback

FLVPlayback

com.wowza.wms.module.ModuleFLVPlayback

ModuleMediaCasterStreamManager

ModuleMediaCasterStreamManager

com.wowza.wms.plugin.mediacasterstreammanager.ModuleMediaCasterStreamManager

streamcontroller

ModuleStreamControl

com.wowza.wms.plugin.collection.module.ModuleStreamControl

mediaCasterStreamManagerPassword

!()$£&^%"!901

"

But now am even getting this error:

WARN server comment 2009-12-21 13:51:42 - - - - - 307.825 - - - - - - - Missing function: createStream

WARN server comment 2009-12-21 13:51:52 - - - - - 318.18 - - - - - - - Missing function: deleteStream

WARN server comment 2009-12-21 13:51:54 - - - - - 320.007 - - - - - - - Missing function: releaseStream

WARN server comment 2009-12-21 13:51:54 - - - - - 320.007 - - - - - - - Missing function: FCPublish

WARN server comment 2009-12-21 13:51:54 - - - - - 320.008 - - - - - - - Missing function: createStream

WARN server comment 2009-12-21 13:52:04 - - - - - 330.362 - - - - - - - Missing function: deleteStream

WARN server comment 2009-12-21 13:52:06 - - - - - 332.211 - - - - - - - Missing function: releaseStream

WARN server comment 2009-12-21 13:52:06 - - - - - 332.211 - - - - - - - Missing function: FCPublish

WARN server comment 2009-12-21 13:52:06 - - - - - 332.212 - - - - - - - Missing function: createStream

WARN server comment 2009-12-21 13:52:16 - - - - - 342.552 - - - - - - - Missing function: deleteStream

WARN server comment 2009-12-21 13:52:18 - - - - - 344.395 - - - - - - - Missing function: releaseStream

WARN server comment 2009-12-21 13:52:18 - - - - - 344.395 - - - - - - - Missing function: FCPublish

WARN server comment 2009-12-21 13:52:18 - - - - - 344.396 - - - - - - - Missing function: createStream

WARN server comment 2009-12-21 13:52:29 - - - - - 354.753 - - - - - - - Missing function: deleteStream

WARN server comment 2009-12-21 13:52:30 - - - - - 356.565 - - - - - - - Missing function: releaseStream

WARN server comment 2009-12-21 13:52:30 - - - - - 356.566 - - - - - - - Missing function: FCPublish

WARN server comment 2009-12-21 13:52:30 - - - - - 356.566 - - - - - - - Missing function: createStream

Thanks so much. That works now.

Much appreciated.

Hi Richard,

Is there a way i can recompile the “Modified Live Stream Player”. I have added secure token and the changed the url to “rtmpe” plus 1 or 2 things. - This is a modified version of Wowza Live Player with these features.

Thanks.

In the following function of openPlaylistOnStream, I do not know how to handle exception. It assumes the stream/file in the playlist is available. But this is not always the case. I hope it will raise some exception when the file is deleted or the live stream is not published yet.

I did find that for a live stream, if it is not published yet, it will start playing once the live stream is published. But if it can raise some exception, I think developer may need that for some handling. For my case, the streaming just hangs on one frame of last static video and waits there. This is not good. I hope it continues playing the static video and alerts a warning that live streaming is not published yet. And for static video, the same. I have two sets of static video, one is uploaded by the customer, one is the system default. Customers usually forget their videos or deleted their videos, if I can detect an exception while opening playlist on stream, I will let the progam automatically switch to my system default, which is usually there.

What I am asking is that playlist.open(stream) will raise exceptions in one way or another. Please consider my requirement.

public void openPlaylistOnStream(IClient client, RequestFunction function, AMFDataList params) {

String streamName = getParamString(params, PARAM1);

String playlistName = getParamString(params, PARAM2);

Stream stream = (Stream)client.getAppInstance().getProperties().getProperty(streamName);

Playlist playlist = (Playlist)client.getAppInstance().getProperties().getProperty(playlistName);

playlist.open(stream);

}

When using LiveStudio.html I ran into 2 problems.

  1. I got this security issue:

SecurityError: Error #2060: Security sandbox violation: ExternalInterface caller file:///C:/Wowza2.1.1_Development/examples/StreamClassControl/LiveStudio.swf cannot access file:///C:/Wowza2.1.1_Development/examples/StreamClassControl/LiveStudio.html.

  1. How can I add my secureToken’s shared secret? I changed in Player.as the shared secret. But how to compile?

Maybe somebody else can help me.

I’m able to compile Player.as into LifeStudio.swf and LiveStudio.mxml into LifeStudio.swf. But both have a much smaller filesize than the original LiveStudio.swf. So I assume that something is wrong.

How do the 2 files (Player.as & LiveStudio.mxml) relate to each other? Do I need to compile both or only one?

I only want to change the shared secret and get a new swf file.

Is the source code of class ModuleStreamControl at the beginning of the thread the latest u have? Is it updated?

Also, to your 1st question: yes, you can remove a PlaylistItem like this:

Boolean success = stream.removeFromPlaylist("Extremists.flv");

Richard

This I dont understand.

Shouldn’t be instead of “Extremists.flv” a stream name?

In the docu it says:

Remove all items matching the given stream name from the playlist.

But a playlist is only attached to one stream anyway. Isn’t it?

These all I understood.

But what about my questions?

I’m back with this functionality, and would appreciate this next way of implementation.

First some background on our setup. We have an “automation” server that runs services based on the request. It is built in Java (if that matters for this or not) and we are looking to have this stream controller class perform specific actions request by our automation services.

We need to be able to “talk” to the wowza server from our automation server by sending things such as nextItem(wowzaIP,myStream2,indexNum,startTime,lengthTime) to the specific wowza server’s ip. Is there a simple implementation for this type of action to be handled or a set of other modules that need to be installed for this type of communication?

Hi guys,

I’m testing this with a local Developer’s WMS. I like the idea of having a “channel” playing saved videos and being able to “push” live streams on demand. So far I have the playlist (A.K.A. SMIL file) working with the LiveStudio.html player but when I try to “push” a live stream from Wirecast into the playlist, I get null errors in the server’s console:

ERROR server comment - invoke(addItemToPlaylist): java.lang.NullPointerException: com.wowza.wms.plugin.collection.module.ModuleStreamControl.addItemTo

Playlist(ModuleStreamControl.java:32)

java.lang.NullPointerException

at com.wowza.wms.plugin.collection.module.ModuleStreamControl.addItemToPlaylist(ModuleStreamControl.java:32)

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(Unknown Source)

at com.wowza.wms.module.ModuleFunctions.invoke(Unknown Source)

at com.wowza.wms.request.RequestProcessFunctions.processFunctions(Unknown Source)

at com.wowza.wms.client.ClientWorker.processNextReq(Unknown Source)

at com.wowza.wms.request.RTMPRequestAdapter.service(Unknown Source)

at com.wowza.wms.server.ServerHandler.serviceRequest(Unknown Source)

at com.wowza.wms.server.ServerHandler.handleMessageReceived(Unknown Source)

at com.wowza.wms.server.ServerHandler.messageReceived(Unknown Source)

at com.wowza.wms.server.ServerHandlerThreadedSession.run(Unknown Source)

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)

I’m doing the following:

In my SMIL file I have:

and I load it in LiveStudio.html as:

Server: rtmp://localhost/live

Stream: Stream1

Click “Connect” then click “Play” and the playlist plays fine. Then I add the following into the bottom controls:

Stream: Stream1

Playlist: pl1

add item to playlist: liveStream.flv 0 -2 (liveStream is the name of my live stream from Wirecast)

And when I hit the button “add item to playlist” the error pops up in the server’s console. The playlist isn’t interrupted or anything.

My live/Application.xml is set to live-record and I added the streamcontroller module.

What might be the problem?

Thanks in advance!

Hi Richard,

Thanks for your reply. I’m mixing stream file types just for testing… in the production server, only .flv files will be used. Thanks for the tip :wink:

Anyway, back to the issue. I changed my SMIL file to be like this:

<smil>
    <head>
    </head>
    <body>
        <stream name="Stream1"></stream>
        
        <playlist name="pl1" playOnStream="Stream1" repeat="true" scheduled="2009-12-11 16:25:30">
            <video src="flv:liveStream_0.flv" start="0" length="15" />
            <video src="mp4:Extremists.m4v" start="0" length="15" />
            <video src="liveStream" start="-2" length="-1" />
        </playlist>
    </body>
</smil>

but now only the live stream is played and when I stop the live feed, the player stops instead of resuming the regular “channel” (saved videos) which is my goal. I would need ppl to watch the channel and suddenly start watching the live feed without refreshing their browsers. Is this possible using this module? How should I write my SMIL file?

Thanks again,

All right, I see what you mean. I think it could be possible if the controller app was running ok.

Anyways do you know any other mods that could be used (alone or together) to achieve this? Or maybe with this same module but setting up my SMIL differently?

Thanks again.

Ok, I found the following here:

The easiest solution is to send a command to all the connected clients that tells them to play a different stream. Use the appInstance.broadcastMsg() method. Then when the stream is available again, send the same message to the clients to have them switch back to the live stream.

Server side:

appInstance.broadcastMsg("switchToStream", streamName);

Client side (AS2):

nc.switchToStream = function(streamName)
{
    ns.play(streamName);
}

Server side, use a Thread that sits in a loose sleep loop that uses the Date function to check the time and triggers the event:

Another solution is to disconnect all clients whent the live feed is over. You can do this with a call to IClient.setShutdownClient(true) for each of the connected clients. Next, add code to the client side that does a reconnect on disconnect. When they reconnect have them reconnect to a different stream.

Take a look at this article. It discusses a method for scheduling event triggers:

http://www.onjava.com/pub/a/onjava/2004/03/10/quartz.html

This is straight forward. Trying to mess with redirecting packets server side is just going to get complicated.

I hope this helps.

Charlie

This is just what I need. My only question is: How can I instruct my WMS appInstance.broadcastMsg(“switchToStream”, streamName); ?

Charlie is talking about a loop that makes that call at HH:MM:SS but I would need to call it by hand. My show won’t be live at the same hour every day and won’t last exactly the same each time.

If I could call that function by hand, I could force all the connected clients to watch my live feed and then call the function again so they can continue watching recorded media.

It would also be great if WMS could execute that function (using different stream names) when it detects a live feed and again when the live feed is over. Is that possible? Livestream.com makes exaclty that… how do they do it? What’s the magic trick?

Thanks in advance,