# Add audio status to HTTP Provider

**URL:** <https://community.wowza.com/t/add-audio-status-to-http-provider/43315>\
**Category:** Wowza Developer Dojo\
**Tags:** wowza-streaming-server-java-api\
**Created:** [July 1, 2014, 7:46am UTC](https://community.wowza.com/t/add-audio-status-to-http-provider/43315 "2014-07-01T07:46:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![First\_Last](https://avatars.discourse-cdn.com/v4/letter/f/a698b9/32.png) [@First\_Last](https://community.wowza.com/u/First_Last)\
**Post date:** [July 1, 2014, 7:46am UTC](https://community.wowza.com/t/add-audio-status-to-http-provider/43315/1 "2014-07-01T07:46:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Matt\_Young](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/matt_young/32/389_2.png) [@Matt\_Young](https://community.wowza.com/u/Matt_Young)\
**Post date:** [July 2, 2014, 6:20am UTC](https://community.wowza.com/t/add-audio-status-to-http-provider/43315/2 "2014-07-02T06:20:27Z")

</div>

You might look at IMediaStream.isReceiveAudio and/or utilize [getPlayPackets](https://www.wowza.com/forums/showthread.php?6165-Detect-if-the-live-encoder-has-stopped&p=24904#post24904) to examine if audio exists.

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [July 9, 2014, 2:55pm UTC](https://community.wowza.com/t/add-audio-status-to-http-provider/43315/3 "2014-07-09T14:55:28Z")

</div>

What you could do is use [IMediaStreamActionNotify3.onCodecInfoAudio()](https://www.wowza.com/docs/how-to-use-imediastreamactionnotify3-interface-to-listen-for-rtmp-stream-events-includes-codec-info%28includes-codec-info%29) and WMSProperties.

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

```auto
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:

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

```

Richard

---

<div class="post-metadata">

**Author:** ![Matt\_Young](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/matt_young/32/389_2.png) [@Matt\_Young](https://community.wowza.com/u/Matt_Young)\
**Post date:** [July 3, 2014, 6:59am UTC](https://community.wowza.com/t/add-audio-status-to-http-provider/43315/4 "2014-07-03T06:59:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![First\_Last](https://avatars.discourse-cdn.com/v4/letter/f/a698b9/32.png) [@First\_Last](https://community.wowza.com/u/First_Last)\
**Post date:** [July 2, 2014, 10:53am UTC](https://community.wowza.com/t/add-audio-status-to-http-provider/43315/5 "2014-07-02T10:53:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![First\_Last](https://avatars.discourse-cdn.com/v4/letter/f/a698b9/32.png) [@First\_Last](https://community.wowza.com/u/First_Last)\
**Post date:** [July 9, 2014, 6:38am UTC](https://community.wowza.com/t/add-audio-status-to-http-provider/43315/6 "2014-07-09T06:38:06Z")

</div>

" 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).
