Wowza Community

IMediaStreamActionNotify3 vs streams started with MediaCasterStreamManager

Hi!

We have MediaCasterStreamManager instance starting some streams with startStream(name, type) method.

We have void ModuleBase:: onStreamCreate(IMediaStream stream) overloaded, to add an IMediaStreamActionNotify3 to the stream when its created.

Now once we get notifications about stream events, we would like to monitor somehow if stream was succesfully started, is running healthy, or is down for some reason.

onPublish happens regardless of stream health, if we startStream(“test”, “thisURLdoesNotExist”) it still throws onPublish. Ok, lets say we can use onMetaData, onCodecInfoAudio and onCodecInfoVideo as those are fired only if URL is right and stream is actually published.

But how to determine when/if it goes down for some reason (is not available from URL anymore)? We can see stream resets by timeout, but no event is fired (i suppose it have to be onUnPublish/onPublish pair fired on every timeout reset?)

We have older implementation where streams are started from Wowza user interface, not using MediaCasterStreamManager, and it efficiently fires onPublish/onUnPublish events on timeout reset.

Many thanks, Alex.

Hello Alex

In thinking about this scenario, one way is to check (on another thread) the stream in question and get the latest packet and see if its available. If it is then you can at least be assured data is coming into Wowza. It might look something like the following:

IMediaStream stream = appInstance.getStreams().getStream(streamName);
if(stream.getLastPacket() != null && stream.getLastPacket().getAbsTimecode()>0){
   // good to go...
}

Thanks,

Matt

Hi,

onPublish is fired when the mediaCaster is first started. This is the same for both the API methods and the GUI (starting streams from the Stream Files page).

onUnPublish is fired when the mediaCaster is shut down.

To capture when the mediaCaster actually starts or stops the connection and stream from the remote server, you will also need to implement the IMediaCasterNotify2 interface. This interface provides event methods that will fire for all of the mediaCaster events.

The ones you will primarily be interested in are

onConnectStart - fired when a connection or reconnection is started but before it actually starts

onConnectSuccess - fired once the connection is successfully made

onConnectFailure - fired if the connection attempt fails

onStreamStart - fired when the stream actually starts running

onStreamStop - fired when the stream stops running

When a mediaCaster first starts, you will see the following event order (assuming a successful start)

onConnectStart -> onConnectSuccess -> onStreamStart

If the mediaCaster resets, you will see onStreamStop -> onConnectStart -> onConnectSuccess hopefully followed by onStreamStart

If the remote stream cannot be located then you will see onConnectStart -> onConnectSuccess repeated each time the mediaCaster resets until it shuts down.

If the remote server cannot be located, you will see onConnectStart -> onConnectFailure repeated each time it resets.

You set your module to use the interface by calling the appInstance.addMediaCasterListener form your module. This only needs to be done once and probably from the onAppStart method.

ModuleLoopUntilLive in the Module Collection shows how to use the interface and also detect in the onPublish & onUnPublish methods if the workflow should be handed off to the mediaCaster listener.

Roger.

Thanks Matt, it makes sense.

But i wonder why does behaviour differs with streams started with GUI and with MediaCaster? Is it by design, or we do something wrong, or it is just a bug?

Thanks, Alex.