Using the EvoStream Media Server API
The EvoStream Media Server (EMS) API can be accessed in two ways. The first is through an ASCII telnet interface. The second is by using HTTP requests. The API is identical for both methods of access.
The API functions parameters are NOT case sensitive.
ASCII
The ASCII interface is often the first interface used by users. It can be accessed easily through the telnet application (available on all operating systems) or through common scripting languages.
To access the API via the telnet interface, a telnet application will need to be launched on the same computer that the EMS is running on. The command to open telnet from a command prompt should look something like the following:
telnet localhost 1112
If you are on Windows 7 you may need to enable telnet. To do this, go to the Control Panel -> Programs -> Turn Windows Features on and off. Turn the telnet program on.
Please also note that on Windows, the default telnet behavior will need to be changed. You will need to turn local echo and new line mode on for proper behavior. Once you have entered telnet, exit the telnet session by typing “ctrl+]”.Then enter the following commands:
set localecho
set crlf
Press Enter/Return again to return to the Windows telnet session.
Once the telnet session is established, you can type out commands that will be immediately executed on the server.
An example of a command request/response from a telnet session would be the following:
Request:
version
Response:
{“data”:”1.5″,”description”:”Version”,”status”:”SUCCESS”}
HTTP
To access the API via the HTTP interface, you simply need to make an HTTP request on the server with the command you wish to execute. By default, the port used for these HTTP requests is 7777. The HTTP interface port can be changed in the main configuration file used by the EMS (typically config.lua).
All of the API functions are available via HTTP, but the request must be formatted slightly differently. To make an API call over HTTP, you must use the following general format: http://IP:7777/functionName?params=base64(firstParam=*** secondParam=YYY …)
In example, to call pullStream on an EMS running locally you would first need to base64 encode your parameters: Base64(uri=rtmp://IP/live/myStream localstreamname=testStream) results in: dXJpPXJ0bXA6Ly9JUC9saXZlL215U3RyZWFtIGxvY2Fsc3RyZWFtbmFtZT10ZXN0U3RyZWFt
http://192.168.5.5:7777/pullstream?params= dXJpPXJ0bXA6Ly9JUC9saXZlL215U3RyZWFtIGxvY2Fsc3RyZWFtbmFtZT10ZXN0U3RyZWFt
PHP and JavaScript
PHP and JavaScript functions are also provided. These functions simply wrap the HTTP interface calls. They can be found in the web_ui directory.
JSON
The EMS API provides return responses from most of the API functions. These responses are formatted in JSON so that they can be easily parsed and used by third party systems and applications. These responses will be identical, regardless of whether you are using the ASCII or HTTP interface.
When using the ASCII interface, it may be necessary to use a JSON interpreter so that responses can be more human-readable. A good JSON interpreter can be found at:
http://chris.photobooks.com/json/default.htm or at http://json.parser.online.fr/.