Wowza Community

HDS Streaming with jwplayer.smil loses querystring parameters

Hello,

We use custom token authentication to authorize users to be able to watch a stream. This works great for most all types of streaming, but I just found a problem with HDS streaming and the use of jwplayer.smil. See the problem is that the output generated when /jwplayer.smil is requested doesn’t have the querystring parameters on it. Here’s an example:

Request for the smil:

http://74.121.236.123/ChaosMedia/_definst_/smil:2014/1383-baker_solo/1383-baker_solo.smil/jwplayer.smil?AuthToken=ERvU3kupA9dB-Ww-nqKZZ49Sk6zuhkn82WTfw9CU_dbUMeaVBjSMxdOP1mi7rWGSLSwPpS3t9RcUqsWnu0OhgFuFYxSH9_D5NHUiHH-nj4aq4HgGeBrZlNxYOcRPGjJYitRaAXJQVV9He84l6DyUmw%3D%3D

Generated smil:

<smil>
	<head>
		<meta base="rtmp://74.121.236.123/ChaosMedia/_definst_"/>
	</head>
	<body>
		<switch>
			<video src="mp4:2014/1383-baker_solo/1383-chaosmen_baker_320.SM.mp4" system-bitrate="751000"/>
			<video src="mp4:2014/1383-baker_solo/1383-chaosmen_baker_640.MD.mp4" system-bitrate="1451000"/>
			<video src="mp4:2014/1383-baker_solo/1383-chaosmen_baker_1024.LG.mp4" system-bitrate="1956000"/>
			<video src="mp4:2014/1383-baker_solo/1383-chaosmen_baker_1280.HD.mp4" system-bitrate="2285000"/>
		</switch>
	</body>
</smil>

Notice that the video src attributes don’t have the AuthToken querystring param that the original request for the smil has. This is a major issue for us because without that, our system can’t authorize the request. This works perfectly fine with HLS streaming:

Request for m3u8:

http://74.121.236.123:80/ChaosMedia/_definst_/smil:2014/1383-baker_solo/1383-baker_solo.smil/playlist.m3u8?AuthToken=ERvU3kupA9dB-Ww-nqKZZ49Sk6zuhkn82WTfw9CU_dbUMeaVBjSMxdOP1mi7rWGSLSwPpS3t9RcUqsWnu0OhgFuFYxSH9_D5NHUiHH-nj4aq4HgGeBrZlNxYOcRPGjJYitRaAXJQVV9He84l6DyUmw%3D%3D

Generated m3u8:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=751000
chunklist_w2083149689_b751000.m3u8?AuthToken=ERvU3kupA9dB-Ww-nqKZZ49Sk6zuhkn82WTfw9CU_dbUMeaVBjSMxdOP1mi7rWGSLSwPpS3t9RcUqsWnu0OhgFuFYxSH9_D5NHUiHH-nj4aq4HgGeBrZlNxYOcRPGjJYitRaAXJQVV9He84l6DyUmw%3D%3D
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1451000
chunklist_w2083149689_b1451000.m3u8?AuthToken=ERvU3kupA9dB-Ww-nqKZZ49Sk6zuhkn82WTfw9CU_dbUMeaVBjSMxdOP1mi7rWGSLSwPpS3t9RcUqsWnu0OhgFuFYxSH9_D5NHUiHH-nj4aq4HgGeBrZlNxYOcRPGjJYitRaAXJQVV9He84l6DyUmw%3D%3D
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1956000
chunklist_w2083149689_b1956000.m3u8?AuthToken=ERvU3kupA9dB-Ww-nqKZZ49Sk6zuhkn82WTfw9CU_dbUMeaVBjSMxdOP1mi7rWGSLSwPpS3t9RcUqsWnu0OhgFuFYxSH9_D5NHUiHH-nj4aq4HgGeBrZlNxYOcRPGjJYitRaAXJQVV9He84l6DyUmw%3D%3D
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2285000
chunklist_w2083149689_b2285000.m3u8?AuthToken=ERvU3kupA9dB-Ww-nqKZZ49Sk6zuhkn82WTfw9CU_dbUMeaVBjSMxdOP1mi7rWGSLSwPpS3t9RcUqsWnu0OhgFuFYxSH9_D5NHUiHH-nj4aq4HgGeBrZlNxYOcRPGjJYitRaAXJQVV9He84l6DyUmw%3D%3D

Notice that the AuthToken querystring param was preserved in the output.

Is there anyway I can get the /jwplayer.smil to carry over the querystring params? This is a major show stopper for us right now…

Thanks,

Sean

Hello,

We use custom token authentication to authorize users to be able to watch a stream. This works great for most all types of streaming, but I just found a problem with HDS streaming and the use of jwplayer.smil. See the problem is that the output generated when /jwplayer.smil is requested doesn’t have the querystring parameters on it. . . .

Is there anyway I can get the /jwplayer.smil to carry over the querystring params? This is a major show stopper for us right now…

Hi Sean,

The JW Player smil is actually returning RTMP information and not HDS information.

The reason that your query string is not appended to the streams in the returned smil is because there isn’t anything in the http provider to do so. If you needed this functionality, you would need to edit the http provider code and add that. The source code for this http provider is here, Source code for HTTPProviderMediaList in Wowza Media Server.

The original query params are stored in a map called queryMap. It would just be a matter of re-attaching this to your stream urls when the smil output is created.

This is an example of how I would do it. the first part deals with standard query params that probably shouldn’t be in the output.

			String queryStr = req.getQueryString();
			if (queryStr == null)
			{
				WMSLoggerFactory.getLogger(HTTPProviderMediaList.class).warn("HTTPProviderMediaList.onHTTPRequest: Query string missing");
				break;
			}
			Map<String, String> queryMap = HTTPUtils.splitQueryStr(queryStr);
			String streamName = null;
			String comboAppStr = null;
			String formatStr = "smil";
			String domainStr = req.getHeader("host");
			String protocolStr = "rtmp";
			String url = req.getHeader("context");
			if (url == null)
				break;
			if (url.indexOf("crossdomain.xml") >= 0)
			{
				WMSLoggerFactory.getLogger(HTTPProviderMediaList.class).warn("HTTPProviderMediaList.onHTTPRequest: crossdomain.xml request");
				crossdomainHandler.handleCrossdomainRequest(vhost, req, resp);
				return;
			}
			int qloc = url.indexOf("?");
			if (qloc >= 0)
				url = url.substring(0, qloc);
			url = HTTPStreamerUtils.urlDecode(url);
			// change get for remove so the default params are removed.  remove will return the same result but will also remove the entry from the map.
			if (queryMap.[B]remove[/B]("streamname") != null)
				streamName = queryMap.get("streamname");
			if (queryMap.[B]remove[/B]("format") != null)
				formatStr = queryMap.get("format");
			if (queryMap.[B]remove[/B]("application") != null)
				comboAppStr = queryMap.get("application");
			if (queryMap.[B]remove[/B]("protocol") != null)
				protocolStr = queryMap.get("protocol");
			if (queryMap.[B]remove[/B]("domain") != null)
				domainStr = queryMap.get("domain");
			// new code
			//set queryStr to null and then rebuild with remaining params.
			queryStr = null;
			if(!queryMap.isEmpty())
			{
				for(String key : queryMap.keySet())
				{
					if(queryStr != null)
						queryStr += "&";
					queryStr += key + "=" + queryMap.get(key);
				}
			}
			. . . 
			String urlStr = "";
			if (rendtion.getName() != null)
				urlStr = " src=\""+rendtion.getName() + [B](queryStr != null ? "?" + queryStr : "") +[/B] "\"";
			. . .

This code sample will strip the default params from the query string and then rebuild it with you custom params. It can then be added to the stream urls.

Roger.

Sean

JWPlayer does not support HDS.

Sean

JWPlayer does not support HDS.

Please read the post rather than just the title.

You should probably urlencode queryMap.get(key) as it would have been decoded when stored in the map.

Roger.

Hi Sean,

That was changed in the source code back in December but it looks like the article was never updated.

I’ll update the article with the current source code now. There have also been some logging changes since then.

Roger.

I updated the title to say RTMP Dynamic Streaming. But as Roger was alluding to, my problem is not getting the streaming to work. my problem is that the querystring params are not present when requesting jwplayer.smil. Also, regarding RTMP dynamic streaming you can see what I mean in this post (scroll down to the Dynamic Streaming section): http://www.longtailvideo.com/support/jw-player/28854/using-rtmp-streaming/

Thank you Roger,

I’m going to try this today…

Hi Roger,

I finally got around to trying this and it works great, however I’ve noticed something strange. The bitrates returned by my version of the httpprovider are all wrong. They have all been divided by 1000.

Here’s the output of the original HTTPProviderMediaList:

I did but didn’t understand it., if he is trying to use HDS with JW Player it is not possible.

Hi,

Yes that HTTP Provider should still be valid for version 4.

Paul

Hi Wowza Support,

I am having the same issue and I would like to know where to find the HTTPProviderMediaList Class ?? so I can add the lines you mentioned in the comments above . My problem is the same using jwplayer smil ABR the query string is losed when I try to catch it from wowza log.

Thanks for your help :slight_smile:

Hi Roger,

Where can I find the http provider code ? so I can add the lines needed to make query string work

Hi Sean,

That was changed in the source code back in December but it looks like the article was never updated.

I’ll update the article with the current source code now. There have also been some logging changes since then.

Roger.

We are having the same issue as the OP where we need to pass custom query string parameters to the video sources in the generated smil file via jwplayer.smil.

  • Is creating a custom HTTPProviderMediaList is still the preferred method for this?

  • Is the latest HTTPProviderMediaList code for 4.x available? The posted code is for 3.5 and we’d like to make sure we don’t miss any new logic in the module when customizing it.

Thank you!