Skip to content

Instantly share code, notes, and snippets.

@aleics
Last active October 28, 2015 08:42
Show Gist options
  • Save aleics/6c40ff04b7a9d432fff0 to your computer and use it in GitHub Desktop.
Save aleics/6c40ff04b7a9d432fff0 to your computer and use it in GitHub Desktop.
Nginx on_publish + SOAP Request (C#)
It is possible with the nginx to make a request when the nginx detect an input stream on our application
(more info: https://github.com/arut/nginx-rtmp-module/wiki/Directives).
As you can see on the wiki of the nginx rtmp module, different triggers are defined (on_play, on_publish,
etc.). To detect a new stream coming in our nginx it will be an "on_publish" event called.
With this method it will be sended diferent parameters too. This parameters will be sended as a form post
data.
The parameters sended on the form post are:
- clientid - tcurl
- name - app
- call - pageurl
- addr - swfurl
- type - flashver
The on_publish method can be declared on the nginx.conf file as it follows:
application live {
live on;
meta copy;
drop_idle_publisher 10s;
idle_streams off;
interleave on;
on_publish http://localhost/Service.asmx/nginx_on_publish_method;
}
With the "on_publish" method added on the live application configuration, it will be called the "nginx_on_publish_method"
when a new stream will be detected on the nginx.
On the Service.asmx it will have to be declared the different parameters on the web method:
[WebMethod]
public bool nginx_on_publish_method(string app, string flashver, string swfurl, string tcurl, string pageurl, string addr, string clientid, string call, string name){
...
}
It is more intuitive to declare the parameters on the method, but the form post data can be obtained
like this too:
[WebMethod]
public bool nginx_on_publish_method(){
System.Collections.Specialized.NameValueCollection data = HttpContext.Current.Request.Form;
}
This process can be implemented for every notify method declared on the nginx rtmp module.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment