Wowza Community

Add audio status to HTTP Provider

I have a custom HTTP provider that is provides more detailed info (better connection counts and whether a publisher is connected or not) and I would like to add a status of whether the stream contains audio or not. Is getAudioSize() on IMediaStream the right method to use? Will it be 0 if there is no audio stream provided or should I be using some other property?

Thanks

You might look at IMediaStream.isReceiveAudio and/or utilize getPlayPackets to examine if audio exists.

What you could do is use IMediaStreamActionNotify3.onCodecInfoAudio() and WMSProperties.

onCodecInfoAudio() won’t run if there is not audio.

public void onCodecInfoAudio(IMediaStream stream,
				MediaCodecInfoAudio codecInfoAudio) {
			System.out.println("onCodecInfoAudio[" + stream.getContextStr() + " Audio Codec" + codecInfoAudio.toCodecsStr() + "]: ");
// Set Property on the stream.
stream.getProperties().setProperty("audioCodec", codecInfoAudio.toCodecsStr() );
		}

Then in your HTTPProvider, drill down to the stream and see if the property exists:

String audioCodec = stream.getProperties().getPropertyStr("audioCodec");

Richard

Hello sethtvn

Upon further review, it seems that isReceiveAudio may not work as I originally thought. After some testing, I found success upon obtaining a reference to AMFPacket and checking for audio (packet.isAudio()). The IMediaStream.getAudioSize function will return 0 if there is no audio but you can only rely on that after data from the stream is actually hitting Wowza. You might check this after stream.getPlayPackets() is no longer empty (in a thread). Alternatively you might use the IMediaStreamActionNotify3 interface and if you receive onCodecInfoAudio event it will indicate audio is available.

Thanks,

Matt

Thanks Matt, I looked at isReceiveAudio and it says “Is client currently receiving audio. Controlled by client side call receiveAudio.”. Would that for sure work? I’m not sure what the client side call receiveAudio is in this context.

" The IMediaStream.getAudioSize function will return 0 if there is no audio but you can only rely on that after data from the stream is actually hitting Wowza."

So in the case of live streams, checking this would work?

What I’m trying to do add a status to my HTTP provider xml output that shows wether a live stream contains audio or not and then in my web application display a status to the end user so they know before clicking on stream whether it has audio or not. The live streams are all published by independent users and they often stream without audio, sometimes they will disable and re-enable audio in the same day while streaming (when they want some privacy, etc).