Wowza Community

Is it posible to get name of current playing video of smil?

Is it posible to get name of current playing video of smil? I want to print this information for the user.

If you mean identify the bitrate or resolution version in the smil:

For HTTP sessions, you can implement the IVHostHTTPStreamerRequestValidator interface in order to check all incoming HTTP sessions, You can then have code that tracks the sessions and checks when it changes the bitrate requested in the chunk request ID. You can identify each session through the session ID.

For example:

public class HTTPRequestHandler implements IVHostHTTPStreamerRequestValidator{
public boolean validateHTTPStreamerRequest(RtmpRequestMessage arg0,HostPort arg1, String arg2) { 
// check request path
return true;
}
}

Create the class that sets the validator via the IVHostNotify interface:

public class VHostListener implements IVHostNotify{
public void onVHostCreate(IVHost vhost) {
vhost.setHTTPStreamerRequestValidator(new HTTPRequestHandler());
}
}

Add it as a vhost listener within your conf/Server.xml file as follows:

<VHostListeners>
<VHostListener>
<BaseClass>path.to.your.VHostListener</BaseClass>
</VHostListener>
</VHostListeners>

Do refer to our Java API docs for more information on this interface and its methods and feel free to submit a support ticket to receive more help.

Hello, thanks for your reply, but mi question is if I can get the NAME of the VIDEO playing. Like a shoutcast/icecast that sho the name of current song playing.

Ok @Cesar Fernandes there is a way but it requires a little bit of work creating a custom module. Most Shoutcasts have the metadata which would include the artist name and name of song. To access that though, you’ll need to create a listener for that metadata and then print it out in the wowza logs.

So, to do that you need to have that metadata added as an ID3 tag to the HLS.

package com.wowza.wms.support.modules.plugins;

import java.util.*;
import com.wowza.wms.amf.*;
import com.wowza.wms.application.*;
import com.wowza.wms.httpstreamer.cupertinostreaming.livestreampacketizer.*;
import com.wowza.wms.media.mp3.model.idtags.*;
import com.wowza.wms.module.*;
import com.wowza.wms.stream.livepacketizer.*;

public class ModuleCupertinoLiveOnTextToID3 extends ModuleBase
{
    class LiveStreamPacketizerDataHandler implements IHTTPStreamerCupertinoLivePacketizerDataHandler2
    {
        private LiveStreamPacketizerCupertino liveStreamPacketizer = null;

        private String lastTitle = null;

        public LiveStreamPacketizerDataHandler(LiveStreamPacketizerCupertino liveStreamPacketizer)
        {
            this.liveStreamPacketizer = liveStreamPacketizer;
        }

        public void onFillChunkStart(LiveStreamPacketizerCupertinoChunk chunk)
        {
            getLogger().info("ModuleCupertinoLiveOnTextToID3.onFillChunkStart["+ liveStreamPacketizer.getContextStr()+"]: chunkId:"+chunk.getChunkIndexForPlaylist());

            // Add custom M3U tag to chunklist header
            CupertinoUserManifestHeaders userManifestHeaders = liveStreamPacketizer.getUserManifestHeaders(chunk.getRendition());
            if (userManifestHeaders != null)
                userManifestHeaders.addHeader("MY-USER-HEADER-DATA", "LAST-CHUNK-TIME  :", (new Date()).toString());

            //  Add ID3 tag to start of chunk
            ID3Frames id3Frames = liveStreamPacketizer.getID3FramesHeader();
            addID3Tag(id3Frames);
        }

        public void onFillChunkEnd(LiveStreamPacketizerCupertinoChunk chunk, long timecode)
        {
            getLogger().info("ModuleCupertinoLiveOnTextToID3.onFillChunkEnd["+liveStreamPacketizer.getContextStr()+"]: chunkId:"+chunk.getChunkIndexForPlaylist());
        }

        public void onFillChunkMediaPacket(LiveStreamPacketizerCupertinoChunk chunk, CupertinoPacketHolder holder, AMFPacket packet)
        {

        }

        public void onFillChunkDataPacket(LiveStreamPacketizerCupertinoChunk chunk, CupertinoPacketHolder holder, AMFPacket packet, ID3Frames id3Frames)
        {
            while(true)
            {
                byte[] buffer = packet.getData();
                if (buffer == null)
                    break;

                if (packet.getSize() <= 2)
                    break;

                int offset = 0;
                if (buffer[0] == 0)
                    offset++;

                AMFDataList amfList = new AMFDataList(buffer, offset, buffer.length-offset);

                if (amfList.size() <= 1)
                    break;

                if (amfList.get(0).getType() == AMFData.DATA_TYPE_STRING)
                {
                    String metaDataStr = amfList.getString(0);
                    AMFDataObj dataObj = amfList.getObject(1);

                    if (!metaDataStr.equalsIgnoreCase("onMetaData"))
                        break;

                    AMFDataItem textData = (AMFDataItem)dataObj.get("StreamTitle");
                    if (textData == null)
                        break;

                    lastTitle = textData.toString();

                    getLogger().info("ModuleCupertinoLiveOnTextToID3.onFillChunkDataPacket[" + liveStreamPacketizer.getContextStr() + "] Send string: "+lastTitle);
                }

                addID3Tag(id3Frames);

                break;
            }
        }

        private void addID3Tag(ID3Frames id3Frames)
        {
            if (lastTitle != null)
            {
                // Add ID3 tag with text data in chunk based on timecode order
                ID3V2FrameTextInformation comment = new ID3V2FrameTextInformation(ID3V2FrameBase.TAG_TIT2);
                comment.setValue(new String(lastTitle));
                id3Frames.putFrame(comment);
                getLogger().info("ModuleCupertinoLiveOnTextToID3.addID3Tag[" + liveStreamPacketizer.getContextStr() +"]  Added ID3 Tag: " + lastTitle);
            }
        }
    }

    class LiveStreamPacketizerListener extends LiveStreamPacketizerActionNotifyBase
    {
        public void onLiveStreamPacketizerCreate(ILiveStreamPacketizer liveStreamPacketizer, String streamName)
        {
            if (liveStreamPacketizer instanceof LiveStreamPacketizerCupertino)
            {
                getLogger().info("ModuleCupertinoLiveOnTextToID3#MyLiveListener.onLiveStreamPacketizerCreate["+((LiveStreamPacketizerCupertino)liveStreamPacketizer).getContextStr()+"]");
                ((LiveStreamPacketizerCupertino)liveStreamPacketizer).setDataHandler(new LiveStreamPacketizerDataHandler((LiveStreamPacketizerCupertino)liveStreamPacketizer));
            }
        }
    }

    public void onAppStart(IApplicationInstance appInstance)
    {
        appInstance.addLiveStreamPacketizerListener(new LiveStreamPacketizerListener());

        getLogger().info("ModuleCupertinoLiveOnTextToID3.onAppStart["+appInstance.getContextStr()+"]");
    }
}

I’m checking for you to see if we can do this in a REST API call or in JAVA. Be back with a response shortly.

If you want some help with this, submit a support ticket and please ask them to reference ticket # 182734 where this module is explained.

I had a feeling that’s what you meant. Let me see if there is a way and not just have the id number.