Results 1 to 4 of 4

Thread: StreamNameAlias doesn't honor querystring

  1. Question 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 ...
    Last edited by karelboek; 04-03-2014 at 06:13 AM. Reason: Wowza 4.0.1

  2. #2
    Join Date
    Dec 2007
    Posts
    21,962

    Default

    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

  3. Default

    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

  4. #4

    Default

    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.

Similar Threads

  1. QueryString in onConnect method always empty
    By nkarnick in forum General Forum
    Replies: 3
    Last Post: 02-21-2013, 04:07 PM
  2. Why repeater can not pass the querystring to origin?
    By xmlyyuan in forum General Forum
    Replies: 1
    Last Post: 05-22-2012, 10:42 AM
  3. Start and Duration Querystring Options
    By rynando in forum Server Administration Discussion
    Replies: 6
    Last Post: 10-14-2011, 10:50 AM

Posting Permissions

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