Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: maximum bitrate control

  1. #11
    Join Date
    May 2013
    Posts
    18

    Default

    Thanks for the help, Roger.

    here is the resulting module. feel free to publish it in case someone might be interested in the functionality.
    /* 
     * (C)opyleft 2013 <roman.hlynovskiy@gmail.com>
     * This module will strip out all chunks having higher bitrate than specified in "maxbitrate" http request based on initial smil file containing all chunks details
     * request example: http://127.0.0.1:1935/vod/amlst:samp...itrate=2864000
     */
    
    package com.wowza.wms.plugin.test.module;
    
    import java.util.*;
    import com.wowza.util.*;
    import com.wowza.wms.http.HTTPProviderMediaList;
    import com.wowza.wms.httpstreamer.model.IHTTPStreamerSession;
    import com.wowza.wms.logging.WMSLoggerFactory;
    import com.wowza.wms.medialist.*;
    import com.wowza.wms.module.*;
    import com.wowza.wms.stream.*;
    import com.wowza.wms.util.MediaListUtils;
    import com.wowza.wms.application.*;
    
    public class ModuleAMLSTTest extends ModuleBase 
    {
    	IApplicationInstance appInstance = null;
    	public static final String PROPERTY_maxbitrate = "maxbitrate";
    	
    	class MyMediaListProvider implements IMediaListProvider
    	{
    		public MediaList resolveMediaList(IMediaListReader mediaListReader, IMediaStream stream, String streamName)
    		{			
    			
    			//WMSLoggerFactory.getLogger(ModuleAMLSTTest.class).warn("ModuleAMLSTTest.resolveMediaList: Loading BFG9K...");
    			
    			IHTTPStreamerSession  	HTTPClient = null;
    			try { HTTPClient = stream.getHTTPStreamerSession(); } catch (Exception client) {}
    			int maxBitrate = 0;
    			
    			
    			if ( HTTPClient != null ) {
    				String queryStr = HTTPClient.getQueryStr();
    				Map<String, String> queryParams = HTTPUtils.splitQueryStr(queryStr);
    				
    				String indexStr = PROPERTY_maxbitrate;
    				
    				if (queryParams.containsKey(indexStr)) 
    					maxBitrate = Integer.parseInt(queryParams.get(indexStr));
                    
    			}
    			
    			String streamExt = "smil";
    			//WMSLoggerFactory.getLogger(ModuleAMLSTTest.class).warn("stream name is " + streamName);
    			
    			MediaList mediaList = MediaListUtils.parseMediaList(appInstance, streamName, streamExt, null);
    
    			if (maxBitrate != 0) {
    				//WMSLoggerFactory.getLogger(ModuleAMLSTTest.class).warn("max bitrate is set to: "+ maxBitrate);
    
    				List<MediaListSegment> segments = mediaList.getSegment();
    				for (MediaListSegment segment : segments) {
    					List<MediaListRendition> renditions = segment.getRenditions();
    					
    					for (MediaListRendition rendition : renditions) {
    						int totalBitrate = rendition.getBitrateTotal();
    	
    						if (totalBitrate > maxBitrate)
    							segment.removeRendition(rendition);
    	
    					}
    				}
    				
    			}
    							
    			return mediaList;
    		}
    	}
    	
    	public void onAppStart(IApplicationInstance appInstance)
    	{
    		this.appInstance = appInstance;
    		appInstance.setMediaListProvider(new MyMediaListProvider());
    	}
    	
    }
    Last edited by roger_l; 10-24-2013 at 01:14 PM. Reason: formatting

  2. #12
    Join Date
    May 2013
    Posts
    18

    Question

    Hello Roger,

    it seems there is a strange problem with compatibility of this module with httpOriginMode. As soon as httpOrigin is turned on, it seems that wowza somehow starts caching smil replies which causes incorrect behavior of the module.

    here is example:

    requesting full list
    root@dev:~# wget -qO- "http://127.0.0.1:1935/vod/jr01/video_1328530578/transcoded/amlst:m.smil/playlist.m3u8"
    #EXTM3U
    #EXT-X-VERSION:3
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=464000,RESOLUTION=432x240
    chunklist_b464000.m3u8
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=314000,RESOLUTION=288x160
    chunklist_b314000.m3u8
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=728000,RESOLUTION=480x270
    chunklist_b728000.m3u8
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1264000,RESOLUTION=640x360
    chunklist_b1264000.m3u8
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1864000,RESOLUTION=848x480
    chunklist_b1864000.m3u8

    requesting limited bitrate list, still whole list is returned
    root@dev:~# wget -qO- "http://127.0.0.1:1935/vod/jr01/video_1328530578/transcoded/amlst:m.smil/playlist.m3u8?maxbitrate=728000"
    #EXTM3U
    #EXT-X-VERSION:3
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=464000,RESOLUTION=432x240
    chunklist_b464000.m3u8?maxbitrate=728000
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=314000,RESOLUTION=288x160
    chunklist_b314000.m3u8?maxbitrate=728000
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=728000,RESOLUTION=480x270
    chunklist_b728000.m3u8?maxbitrate=728000
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1264000,RESOLUTION=640x360
    chunklist_b1264000.m3u8?maxbitrate=728000
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1864000,RESOLUTION=848x480
    chunklist_b1864000.m3u8?maxbitrate=728000

    requesting limited bitrate list again, now it works!
    root@dev:~# wget -qO- "http://127.0.0.1:1935/vod/jr01/video_1328530578/transcoded/amlst:m.smil/playlist.m3u8?maxbitrate=728000"
    #EXTM3U
    #EXT-X-VERSION:3
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=464000,RESOLUTION=432x240
    chunklist_b464000.m3u8?maxbitrate=728000
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=314000,RESOLUTION=288x160
    chunklist_b314000.m3u8?maxbitrate=728000
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=728000,RESOLUTION=480x270
    chunklist_b728000.m3u8?maxbitrate=728000

    requesting another limited bitrate list again, it works!
    root@dev:~# wget -qO- "http://127.0.0.1:1935/vod/jr01/video_1328530578/transcoded/amlst:m.smil/playlist.m3u8?maxbitrate=1264000"
    #EXTM3U
    #EXT-X-VERSION:3
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=464000,RESOLUTION=432x240
    chunklist_b464000.m3u8?maxbitrate=1264000
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=314000,RESOLUTION=288x160
    chunklist_b314000.m3u8?maxbitrate=1264000
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=728000,RESOLUTION=480x270
    chunklist_b728000.m3u8?maxbitrate=1264000
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1264000,RESOLUTION=640x360
    chunklist_b1264000.m3u8?maxbitrate=1264000

    requesting first limited bitrate list again, it still returns result for a previous query
    root@dev:~# wget -qO- "http://127.0.0.1:1935/vod/jr01/video_1328530578/transcoded/amlst:m.smil/playlist.m3u8?maxbitrate=728000"
    #EXTM3U
    #EXT-X-VERSION:3
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=464000,RESOLUTION=432x240
    chunklist_b464000.m3u8?maxbitrate=728000
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=314000,RESOLUTION=288x160
    chunklist_b314000.m3u8?maxbitrate=728000
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=728000,RESOLUTION=480x270
    chunklist_b728000.m3u8?maxbitrate=728000
    #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1264000,RESOLUTION=640x360
    chunklist_b1264000.m3u8?maxbitrate=728000


    also what I see, the requests with incorrect answers are not getting logged at all. also if I wait from 5 to 10 seconds between each request, the answers are correct.
    is it normail wowza behavior or a "feature"?
    Last edited by nother; 12-16-2013 at 03:50 AM.

  3. #13
    Join Date
    Dec 2007
    Posts
    21,962

    Default

    The IMediaListProvider API (amlst method), is not going to work correctly with HTTPOrigin mode turned on. The CDN that is caching is going to cache the smil file too. Clients are expected to stream from the CDN, not Wowza.

    Richard

  4. #14
    Join Date
    May 2013
    Posts
    18

    Default

    Hello Richard,

    it seems I'm trying to achieve something which was never expected to happen - different smil structures with the same request.
    while httpOrigin is on, wowza expects upfront CDN to cache smil requests. Our CDN is ok to cache those requests, but they should definitely correct (which is not the case here).

    is it possible to introduce a feature in the next minor release similar to cupertinoCacheControlPlaylist max-age property for the smil files or some other workaround which would make wowza understand that a query with params is not the same as the query without params.

    p.s. wouldn't httporigin mode also break 'audioindex' support from wms-plugin-collection ? I feel it would be the same issue since wowza will continue to provide the same chunks upon same request even with different params?



    Roman

  5. #15
    Join Date
    Dec 2007
    Posts
    21,962

    Default

    Roman,

    I think an initial request from the CDN should run the IMediaListProvider, but no, what you describe, dynamic MediaList per playback session, is not going to work with HTTP Origin mode. Clients are streaming from the CDN cache, not Wowza. Yes, also, using an audioindex and other techniques involving Wowza directly with the playback client will not work.

    Richard

  6. #16

    Default

    Hi Roman,

    Query params do not work with http origin mode enabled because Wowza creates the playback stream based on the stream name and not the query params. With http origin, the first request for a stream name will create the playback stream and that request's params will be used. A future request for the same stream name but with different params will not create a new stream and it's params will be ignored. The only exception is the DVR param used to turn on DVR mode.

    There is a workaround however. If you pass a unique stream name into Wowza then that will create a new stream each time. You can then use the StreamNameAlias api to map your unique name to the real stream name.

    I would suggest implementing the IMediaStreamNameAliasProvider interface and then remap the names in the resolvePlayAlias method. If you need separate mappings for different player types then use the IMediaStreamNameAliasProvider2 interface which has separate resolvePlayAlias methods for each player type.

    This method will be called for the smil file as well as the mp4 files. You should just have to remap the smil file names and pass thru the mp4 file names unchanged.

    Roger.

  7. #17
    Join Date
    May 2013
    Posts
    18

    Default

    Richard, Roger

    thanks for all those clarifications. after all those suggestions we found another way to fix a problem.

    we do use fixed names for smil files naming, so this line from the module:

    MediaList mediaList = MediaListUtils.parseMediaList(appInstance, streamName, streamExt, null);

    changes to:

    MediaList mediaList = MediaListUtils.parseMediaList(appInstance, "media", streamExt, null);

    and a request for unique smil is: http://127.0.0.1:1935/vod/amlst:RAND...itrate=2864000

    while RANDOM_STRING is really random it works like a charm

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •