Results 1 to 10 of 24

Thread: Module for authorizing requests for all stream types - getting the client request url

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Module for authorizing requests for all stream types - getting the client request url

    I'm writing a module that will integrate wowza with a streaming media control panel we're building. This module will call one of our application's authorization service to determine if the user is authorized to view the content they're requesting. Our authorization service takes in 2 parameters:
    1. The user/client IP
    2. The original request string

    I'm almost done with this module, and have found a lot of useful information in this forum, but I'd like to check with you before I finalize a few things. My first question relates to getting the entire original client request URL. This was harder than it should be, and I had to do it differently for each stream type. Have a look at the following code blocks:

    HTTP Streams:
    For the http streams, I used the onHTTPSessionCreate event. I couldn't find an easy way to just get the client's request URL, so I had to piece it together like so:

    String hostName = httpSession.getHTTPHeader("host");
    int requestPort = httpSession.getServerPort();
    String relativeUri = httpSession.getUri();
    String queryStr = httpSession.getQueryStr();
    String requestPath = String.format("http://%s:%s/%s?%s", hostName, requestPort, relativeUri, queryStr);

    Is this the right way of getting the entire client request URL? If there is a better way, please let me know.

    RTSP Streams:
    RTSP streams are by far the easiest. I used the onRTPSessionCreate event for my auth logic, and here is the code I used to get the client request url:

    String requestPath = rtpSession.getUri();

    That's how it should be!...

    RTMP Streams:
    For RTMP streams, I had to create a class named StreamListener that implements the IMediaStreamActionNotify interface, and then in the module's onStreamCreate event, I added that listener. I had to do it this way because the URL is not availble for RTMP streams until the onplay event. So I overrode the onPlay event and had to do this to get the client's request URL:

    String streamSourceUri = client.getUri();
    String queryStr = stream.getQueryStr();
    String requestPath = String.format("%s/%s?%s", streamSourceUri, streamName, queryStr);
    (the streamName variable is a input parameter to the onPlay event)

    Is this the right way of getting the client's request URL for RTMP streams? If not, please let me know of the best way.

    I hate that I had to piece the URLs together for RTMP and HTTP streams. It's tougher than it should be, and you lose some stuff, like the file type prefix (mp4:/path1/path2). I wish there was an easier way to get the request URL in one shot.

    My second question relates to the client's IP address. The methods for getting the IP address are inconsistent.

    String ipAddressClient = httpSession.getIpAddress();
    This returns back an IPv6 address

    String ipAddressClient = rtpSession.getIp();
    This returns back an IPv4 address

    IClient client = stream.getClient();
    String ipAddressClient = client.getIp();
    This returns back an IPv6 address

    I need the client's IPv4 address. Is there any way to get that for RTMP and HTTP connections?

    Last edited by seanngreen; 02-06-2013 at 07:03 PM.

Similar Threads

  1. Wowza module to start stream on HLS request
    By cipris in forum General Forum
    Replies: 4
    Last Post: 12-12-2014, 02:47 AM
  2. Samsung TV app: changing ordering of URL parameters for HLS requests
    By jules27 in forum Media Players and Devices Discussion
    Replies: 2
    Last Post: 06-19-2012, 05:00 PM
  3. Intercepting client requests for streams
    By michael401 in forum Server-side Modules and Code Samples Discussion
    Replies: 5
    Last Post: 02-26-2012, 08:12 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