StreamNameAlias doesn't honor querystring

Have a look at this sample code:

public class MyAliasTest extends ModuleBase implements IMediaStreamNameAliasProvider {
  public String resolvePlayAlias(IApplicationInstance appInstance, String name) {
    return name + "?test=true";
  }
  public String resolveStreamAlias(IApplicationInstance appInstance, String name) { 
    return name + "?test=true";
  }
}

This generates an error:

MediaReaderH264.open[vod/_definst_]: Not found: /usr/local/WowzaStreamingEngine/content/sample.mp4?test=true.: java.io.FileNotFoundException: /usr/local/WowzaStreamingEngine/content/sample.mp4_test=true (No such file or directory)|at java.io.RandomAccessFile.open(Native Method)|at java.io.RandomAccessFile.<init>(RandomAccessFile.java:241)|at com.wowza.io.WowzaRandomAccessFile.<init>(WowzaRandomAccessFile.java:12)|at com.wowza.io.DirectRandomAccessReader.open(DirectRandomAccessReader.java:222)|at com.wowza.wms.mediareader.h264.MediaReaderH264.open(MediaReaderH264.java:250)|

This code however:

public class MyAliasTest extends ModuleBase implements IMediaStreamNameAliasProvider {
  public String resolvePlayAlias(IApplicationInstance appInstance, String name) {
    return name;
  }
  public String resolveStreamAlias(IApplicationInstance appInstance, String name) { 
    return name;
  }
}

… together with this URL: http://[wowza-ip]/vod/sample.mp4?test=true, will strip away the entire querystring, so that the variable queryStr is empty when I try

public void onHTTPSessionCreate(IHTTPStreamerSession httpSession) {
  String queryStr = httpSession.getQueryStr();
}

What happens behind resolvePlayAlias and resolveStreamAlias so that the querystring doesn’t work? I want it to work as in the first sample above …

I tested IMediaStreamNameAliasProvider.resolvePlayAlias() and did get any error. But your IMediaStreamNameAliasProvider is incomplete, there are several overloads of resolveStreamPlayAlias(), and you only have one. I used the Flash handler:

public String resolvePlayAlias(IApplicationInstance appInstance,
			String name, IClient client) {
		getLogger().info("Resolve Play Flash: " + name);
						
		return name + "?test=true";
	}

Richard

There are only two overloads for IMediaStreamNameAliasProvider, but another 5 for IMediaStreamNameAliasProvider2; so I implemented the latter and tried again. Indeed this works for the Flash handler (RTMP), but with HLS, the overload resolvePlayAlias(IApplicationInstance appInstance, String name, IHTTPStreamerSession httpSession) generates the error that I mentioned in my first post.

By the way: updated to 4.0.3, to make sure I got all the fixes, but this is still a problem

Hi Karel,

The reason that your first example doesn’t work is because the resolvePlayAlias methods are used to resolve the actual file name that will be located in the file system.

Wowza will look in the file system for a file called sample.mp4_test=true. It first swaps out any illegal characters which is why the ? is replaced with a _.

This is what the error is telling you.

I’m not sure why you don’t get the query string in the session with the second example. When I test the following, it works.

public class AliasTest extends ModuleBase implements IMediaStreamNameAliasProvider
{
	public String resolvePlayAlias(IApplicationInstance appInstance, String name)
	{
		return name;
	}
	public String resolveStreamAlias(IApplicationInstance appInstance, String name)
	{
		return name;
	}
	public void onAppStart(IApplicationInstance appInstance)
	{
		appInstance.setStreamNameAliasProvider(this);
	}
	public void onHTTPSessionCreate(IHTTPStreamerSession httpSession)
	{
		String queryStr = httpSession.getQueryStr();
		getLogger().info("onHTTPSessionCreate: " + queryStr);
	}
}

using this player url

http://localhost:1935/vod/sample.mp4/playlist.m3u8?test=true

This example is basically identical to the internal IMediaStreamNameAliasProvider implementation that is used when one is not set. The only other thing the default one does is intercept .play & .stream file names.

Using the IMediaStreamNameAliasProvider interface, you don’t have access to the http session so you need to use the IMediaStreamNameAliasProvider2 interface to gain access to the session.

Roger.