Wowza Community

MediaCaster starting for already published streams

Hi,

I have an application based on ModuleAddAudioTrack.

The differences are:

I start the live video source on appStart to keep it running and I use a IMediaStreamNameAliasProvider.

I start live stream source at appStart using:

appInstance.setApplicationTimeout(0);

appInstance.getMediaCasterStreams().acquire(“video-source”);

as in the ModuleAddAudioTrack I create 2 new stream on “video-source” publish event.

I create this 2 stream as in example module using:

publisher = Publisher.createInstance(this.appInstance);

publisher.setFileExtension(“flv”);

publisher.setStreamType(“live”);

publisher.publish(“video”, “live”);

audioSource = Stream.createInstance(this.appInstance, “video-audio");

playlist = new Playlist(“audiosource”);

playlist.setRepeat(true);

playlist.addItem(audioSourcePath, 0, -1);

playlist.open(this.audioSource);

It works.

I can get the “video”, “video-source” , “video-audio” streams using all protocols.

But behind the scene something strange happens when I call “video” and “video-audio” using RTSP or RTMP

It works showing the expected content o the player, but Wowza keeps a MediaCaster instance “video” or “video-audio” trying to connect a stream source. I can see it because Mediacaster events I am logging and because of logging I have in resolveStreamAlias. As this method do not have a valid replies for “video” and “video-audio” I return the name (I’ve tried return null too). it causes logs of MediaCaster connectFailure.

As the the streams named “video” and “video-audio” are already running correctly (I can see it through the player and WowzaStreamEngineManager), it should not start the MediaCaster, right?

Using HLS protocol something similar happens, but instead start a media caster I get successive calls on resolvePlayAlias.

Here is a resume of my logs:

  • After start video-source on App

video-source onMediaCasterCreate

video-source onConnectStart

video-source resolveStreamAlias

video-source onMediaStreamCreate

video-source onSetSourceStream

video-source onPublish

video onMediaStreamCreate

video-source onConnectSuccess

video onPublish

video-audio onMediaStreamCreate

video-audio onPublish

  • After connect video-source using RTSP or RTMP client - THIS STREAM RUNS AS EXPECTED

video-source onMediaStreamCreate

video-source resolvePlayAlias

video-source MediaStreamMediaCasterPlay: startPlay

video-source onRegisterPlayer

video-source onPlay

  • After close RTSP or RTMP connection

video-source onUnRegisterPlayer

video-source onStop

video-source onDestroy

  • After connect videousing RTSP or RTMP - NOW MEDIACASTER START WITH NO REASON this strea in already published

video onMediaStreamCreate

video resolvePlayAlias - HERE I RETURN “video”, right?

video MediaStreamMediaCasterPlay: startPlay

video onMediaCasterCreate - I THINK IT SHOULD NOT START

video onRegisterPlayer

video MediaCaster.onConnectStart

video resolveStreamAlias - HERE I RETURN “video”. I THINK THIS METHOS SHOULD NOT BE CALLED

video MediaCaster.onConnectFailure

video MediaCaster.onConnectStart

video resolveStreamAlias - HERE I RETURN “video”. I THINK THIS METHOS SHOULD NOT BE CALLED

video MediaCaster.onConnectFailure

  • After close RTSP or RTMP connection

video onUnRegisterPlayer

video onStop

video onDestroy

What I am missing the avoid to start the MediaCaster unnecessarily? The stream are already running.

I am missing something?

My application streamtype is “rtp-live-lowlatency”.

Does it happen because streamtype for “video” should be “live”? If it is the problem How do a set streamType on steam name basis?

Thanks.

Rafael Sobral

Hi,

In your code I can see

publisher = Publisher.createInstance(this.appInstance);

publisher.setFileExtension(“flv”);

publisher.setStreamType(“live”);

publisher.publish(“video”, “live”);

but then no data being send to it. This will be why it is constantly trying to reconnect. If there is no data, then Wowza will drop the connection and reconnnect, it may be doing this as the stream is empty.

Andrew.

Hi Andrew,

The stream is not empty because is plays correctly on the player.

I use the methods bellow in a loop to add the content to the stream, just like in ModuleAddAudioTrack:

this.publisher.addAudioData(APacket.getData(), APacket.getData().length, APacket.getAbsTimecode() + offsetTimeCode);

this.publisher.addVideoData(VPacket.getData(), VPacket.getData().length, VPacket.getAbsTimecode());

I added the following statement in onConnect method of Module and it is not firing MediaCaster anymore.

client.setStreamType(“live”);

The following post was very helpfull to get closer to understand what is going on.

I would like to know if it is the correct approach.

I would like to known too if it is possible to set it on stream basis and not on client connection basis as I did. To avoid it affect all stream in client connection.

Thanks.

Aloha,

Rafael Sobral