I’ve searched the forums for this answer, but no luck.
I’m using FME to broadcast a video stream to Wowza. It works fine. But I need a way to tell my MySQL DB about the current stream, so others can access it.
Wowza has to send a request to “http://…webservice.php” with POST/GET variables
When I publish a stream, I want Wowza to tell my “webservice.php” by POST/GET that “public-ip-of-server”, “stream”, “streamname” has been started, so my webservice can update my database.
When I stop publishing the stream, I want Wowza to run the webservice again, with a different POST/GET variable, so it can tell the DB that stream has ended.
I know very litle Java, so it’s hard for me to edit the code. I’m using the LiveStreamRecordzip module to record, and my “webservice.php” does the job of renaming file and move it to my S3 bucket, when recording is done )
That’s my plan.
Could anyone cooperate with me and suggest me the best way to accomplish this POST/GET functinality?
Second, this is probably not the best way to do it. Making HTTP calls to PHP is pretty inefficient. So under heavy load this is most likely not going to perform great. I would suggest that you do the DB updates directly from Java using JDBC. That being said…
If you still want to do it with HTTP then take a look at the com.wowza.HTTPUtils class. It contains pre-built methods for making HTTP requests.
I made some adjustments. Are you using the wizard to create new Wowza Class Module? It will help. You should not alter the signature of methods like onStreamCreate, I don’t think they will work properly.
// put this with the other imports
import java.net.*;
String url = "http://yourdomain/somepage.php?var=val";
try
{
URL url = new URL(url);
URLConnection connect = url.openConnection();
connect.getContent();
}
catch(Exception e)
{
}
That last was just a snip, to use instead HTTPUtils, just that part. You should put that together with the complete Wowza Module before, which I made some modifications to already. It’s what I have used.
The Wowza IDE has two very useful wizards from the menu. Use these for new Project and Wowza Class files to be sure you are setting up correctly.
File --> New --> Wowza Media Server Pro Project
File --> New --> Wowza Media Server Pro Module Class
Ok, I know absolutly no Java. But I’ve accomplished to create a project with the IDE tools, and tried to collect some data I’ve found on the forums.
HTTPutils gives me an error, I’m not sure this is correct.
We’re soon going bigscale on EC2 for normal streaming, and this part with Live streaming will also be running in the next week, so it would be cool to have this running asap.
Thank you for response Richard, this is what I’ve done so far:
I create a new “Wowza Media Server Project”.
Project name: webservice
Project settings: default
Package: com.wowza.wms.module
Name: Webservice
Custom method: empty
Method events: empty
Inserting the code you posted above into Webservice.java, but with
package com.wowza.wms.module;
at the top of the code.
I tried running the code from Wowza IDE, and connect with FME. Logs tell me that the stream is published, and unpublished, but it does not reach my webservice. (I’ve made sure the http://myurl/webservice.php exists, and the PHP code just simply inserts a empty row on my DB" (not based on any POST data wowza sends). So, all in all, Wowza does not call the webservice.
INFO session connect 127.0.0.1 -
INFO stream create - -
INFO stream publish livestream -
INFO stream unpublish livestream -
INFO stream destroy livestream -
Am I missing out on something important here? Do I have to BUILD the jar file and include it manually, when testing/debugging? So what is the next step?
Because stream-name doesn’t excist before onPublish, I wonder how I can fetch it out, and use it with onStreamCreate? I tried the different approaches on the forum, but it doesn’t quite seem to work.