Detect failure of mediacaster stream?

I’m wondering how to detect the failure of a mediacaster stream while it’s being played, or even just the failure to connect up initially. I’ve tried the “addMediaCasterListener” method on the application object, but nothing catches it. I can see in the logs this:

Successful connection for mediacaster: 2 - - -

ShoutCastDecoder.checkHeader[mystream.stream]: HTTP response: 404

The first line is from the class I’m using to detect connections etc for the listener, the second is from some internal class I guess. As you can see, the connection success is firing but the HTTP response is 404… How do I grab that?

More importantly though, I need to know when a mediacaster stream fails part way through. Any ideas?

Hello

One option would be to check the streams last packet to see if there is an associated timecode. You could do this twice (~200ms apart) and compare the timecodes. You can check the timecode similar to the following:

// Example only 
IApplication app = vhost.getApplication("live"); 
IApplicationInstance instance = app.getAppInstance("_definst_"); 
IMediaStream stream = instance.getStreams().getStream("myStream");
if (stream != null && stream.getLastPacket() != null)
{
    if (stream.getLastPacket().getAbsTimecode() > 0)
   {
      // looks like stream is valid
   }
} 

Thanks,

Matt

Thanks Matt. I was really hoping for the event like the internal Wowza runtime gets (as log entries go by like crazy for the “switch”) and not have to brute force check it and run my own event. I’ll see what I can do with this then.