Results 1 to 8 of 8

Thread: Need to stop stream programmatically, and your suggestions on our approach

  1. #1
    Join Date
    Nov 2011
    Posts
    14

    Default Need to stop stream programmatically, and your suggestions on our approach

    Hello folks,

    We are still building out our system API but I have a question for a functionality we're working on. So, there's a max X concurrent streams option in our system and we are building our system so that whenever a stream request is made, it goes to our middleware to authenticate and if it authenticates allright then we find other active stream(s) for that customer and end them, then we allow the new request to go through. In order to end the other active stream(s), we need to tell Wowza streamer which stream to end.

    Question: How do we specify a stream programmatically to Wowza so that it knows which stream to end? (I know that this setup relates to us storing the streamID in our "active_sessions" DB table but we can work that in as we're not over that part yet.)

    On a side note, can you please comment on the following approach and its efficiency? So, customer requires stream from Wowza, Wowza (via custom module we'll build) then asks our middleware "is this stream authorized?" and our middleware gives the OK or rejection. If stream is authorized, all other active streams to this customer are stopped (that is, middleware sends that command to Wowza... somehow, not clear on this yet) and customer then starts receiving stream.

    Thank you for your help.

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

    Default

    The approach you describe should be used very cautiously. JDBC and/or HTTP calls to authentication services can be a problem. You should minimize and use proper threading, and a good log messaging to enable debugging. One way to minimize is get everything you need for a client or session in one call, and store in the client or session object with WMSProperties. You can store a map or AMFDataOBJ and retrieve with cast.

    HashMap info = new HashMap();
    client.getProperties().setProperty("info", info);
    HashMap infoOut = (HashMap)client.getProperties().getProperty("info");
    Given a clientID or sessionID you can do:
    appInstance.getClientById(123456).setShutdownClient(true);
    
    IHTTPStreamerSession session = appInstance.getHTTPStreamerSessions().get(123456);
    Richard

  3. #3
    Join Date
    Nov 2011
    Posts
    14

    Default

    Thank you very much for your reply, Richard. I appreciate it.

    What if the SQL database lived on the same machine as the Wowza server? It's a very simple database schema consisting of 8-10 tables. This way, the database could be synchronizing with the main app/DB (MySQL has good replication functionality).

    If we ignore the 2nd posibility above (DB on same server as Wowza), then with the method you suggested, is this more-or-less how the flow?

    1) At start of session, user retrieves list of streams from main server to his environment (STB or web page)
    2) That session_id is stored in the main DB and customer only deals with Wowza server from there on << Question: does Wowza or main DB generate this client_id/session_id?
    3) Every requested stream is authenticated against the DB results that are now stored in Wowza server with that session_id
    4) If user wants to watch a stream, Wowza custom module will check if that user_id has an already ongoing stream and ends the ongoing stream (using the code you provided) and then allows stream to go through
    5) Every 24 hours, the main DB asks Wowza to delete sessions so users will have to retrieve list of streams again.

    Thank you very much for all your help.

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

    Default

    Having the db on same machine can help. Probably on another machine in the same LAN would be better. Good db design and indexing are critical wherever it is, I'm sure you know.

    ...does Wowza or main DB generate this client_id/session_id?
    Definitely Wowza, as there is no db involved unless you involve one.

    Richard

  5. #5
    Join Date
    Nov 2011
    Posts
    14

    Default

    Hello Richard,

    Sorry to bring back an old thread but I am close to finishing this project except for this part.

    After reviews, this is what the flow seems to be:

    1) Client app makes all requests to Wowza in this format: http://WOWZA_IP:1935/live/channel.st...ING_ALSO_IN_DB

    2) Wowza custom module executes the following code on the onHTTPSessionCreate event (based on this):
    * Check DB to see if this user's token is active.
    * If token is active, allow stream. Otherwise, reject.
    * If stream is allowed, add Wowza Session_ID to database's "active_sessions" table.

    Then I plan to have a separate cron script (every 1-5 minutes) that does the following:
    * Get all active sessions in a Wowza server
    * Check every session against database (match Wowza's list of active sessions with session_id's from DB)
    * Kill all orphaned Wowza sessions that do not have a corresponding row in "active_sessions" table.
    

    I have a few questions about implementing this:

    1) How do I get the newly allowed stream's Wowza Session_ID in onHTTPSessionCreate event?
    2) How do I implement this kill-script for orphaned Wowza sessions?
    2.1) If I write a Shell/Python script, how would I access all of Wowza's active streams for that server?
    2.2) Can I write a custom module which is executed on set interval that would take care of orphaned streams?

    Thank you in advance for your help about this.

  6. #6
    Join Date
    Sep 2011
    Posts
    1,933

    Default

    Hi
    I have a few questions about implementing this:

    1) How do I get the newly allowed stream's Wowza Session_ID in onHTTPSessionCreate event?
    2) How do I implement this kill-script for orphaned Wowza sessions?
    2.1) If I write a Shell/Python script, how would I access all of Wowza's active streams for that server?
    2.2) Can I write a custom module which is executed on set interval that would take care of orphaned streams?

    Thank you in advance for your help about this.
    Answers:
    1) Inside onHTTPSessionCreate(IHTTPStreamerSessionhttpSession) you can use httpSession.getSessionId()
    2) You will need to write a significant amount of custom code which is well beyond Wowza support I'm afraid so this will require the independent consultant list and/or the "find a consultant forum" which can be found here,
    http://www.wowza.com/forums/forumdis...ltant&tabid=70
    2.1) You would need to write a HTTPProvider that you can use your script to poll the server.
    2.2) Yes, you can find an example of a thread running here which will give you the starting point for the operation you want to perform but will need significant adjustment to do the task you have in mind.

    Jason

  7. #7
    Join Date
    Nov 2011
    Posts
    14

    Default

    Thanks for quick reply, Jason!

    How would I get the independent consultant list? Can you PM me here on the forum?

  8. #8
    Join Date
    Sep 2011
    Posts
    1,933

    Default

    Hi
    You can do this by sending your request for the independent consultants list by email to support@wowza.com.

    Jason

Similar Threads

  1. connect to RSTP incoming stream programmatically
    By stefan_ts in forum Live Streaming and Encoders
    Replies: 1
    Last Post: 10-13-2014, 05:55 AM
  2. advice on how to create a stream programmatically
    By tartartartartar in forum Server-side Modules and Code Samples Discussion
    Replies: 1
    Last Post: 01-02-2014, 05:19 PM
  3. control receive stream(stream manager) programmatically?
    By sktniran in forum Live Streaming and Encoder Discussion
    Replies: 2
    Last Post: 11-22-2011, 12:07 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
  •