You can use the Wowza Streaming Engine™ media server software REST API to identify, add, and manage stream files in a Wowza Streaming Engine instance.
A stream file is an alias for a complex, URI-based stream name from a source such as an MPEG-TS encoder or IP camera. For example, a stream from an MPEG-TS encoder might have a name like udp://0.0.0.0:10000. You can replace that with a stream file such as mycoolevent.stream. Players can then use mycoolevent.stream in playback URLs in place of the URI-based stream name. Stream files are stored in the /Library/WowzaStreamingEngine/content directory and have a .stream file extension.
Notes:
- Wowza Streaming Engine 4.3.0 or later is required.
- PHP examples for the tasks in this article are available in the tests folder of the PHP REST Library for Wowza Streaming Engine on GitHub.
- Reference documentation for the Wowza Streaming Engine REST API is available by using OpenAPI (Swagger), which you can download and install locally. See Access reference documentation for the Wowza Streaming Engine REST API.
Contents
Get a list of stream files
Add a stream file
Update a stream file
Connect a stream file
Disconnect a stream file
Remove a stream file
Get a list of stream files
View a list of stream files associated with an application (testlive, in this example):
curl -X GET \ -H "Accept:application/json; charset=utf-8" \ -H "Content-Type:application/json; charset=utf-8" \ http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamfiles
The command should return a response that lists the stream files (metallica and saosin in this example) and looks something like this:
{ "serverName": "_defaultServer_", "streamFiles": [ { "id": "metallica", "href": "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamfiles/metallica" }, { "id": "saosin", "href": "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamfiles/saosin" } ] }
View the details of a stream file (metallica, in this example):
curl -X GET \ -H 'Accept:application/json; charset=utf-8' \ -H 'Content-type:application/json; charset=utf-8' \ http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamfiles/metallica
The command should return a response that shows the stream file's name and the source URI, like this:
{ "version": "1430317484000", "serverName": "_defaultServer_", "uri": "udp://0.0.0.0:10000", "name": "metallica" }
Add a stream file
Add a stream file (creedence, in this example):
curl -X POST \ -H 'Accept:application/json; charset=utf-8' \ -H 'Content-Type:application/json; charset=utf-8' \ http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamfiles \ -d' { "name": "creedence", "serverName": "_defaultServer_", "uri": "udp://1.2.3.4:10000" }'
The command should return a response that looks something like this:
{
"success": true,
"message": "",
"data": null
}
Update a stream file
Customize the advanced properties of a stream file. The following example changes the URI to an Axis IP camera and reduces the stream timeout and reconnect wait time for the stream file creedence:
curl -X PUT \ -H 'Accept: application/json; charset=utf-8' \ -H 'Content-Type: application/json; charset=utf-8' \ http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamfiles/creedence/adv \ -d '{ "sourceControlDriver": "", "advancedSettings": [{ "sectionName": "Common", "canRemove": false, "defaultValue": "null", "documented": false, "name": "uri", "section": "null", "type": "string", "value": "rtsp://user:pass@[ip-camera]:554/axis-media/media.amp?videocodec=h264&streamprofile=400", "enabled": false }, { "sectionName": "Common", "canRemove": true, "defaultValue": "12000", "documented": true, "name": "streamTimeout", "section": "null", "type": "integer", "value": "0", "enabled": true }, { "sectionName": "Common", "canRemove": false, "defaultValue": "3000", "documented": true, "name": "reconnectWaitTime", "section": "null", "type": "integer", "value": "0", "enabled": true }], "serverName": "_defaultServer_", "version": "" }'
The command should return a response that looks something like this:
{ "success": true, "message:" "", "data": null }
Connect a stream file
Initiate the connection of a stream file (creedence, in this example):
curl -X PUT \ -H 'Accept:application/json; charset=utf-8' \ -H 'Content-type:application/json; charset=utf-8' \ "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamfiles/creedence/actions/connect?connectAppName=testlive&appInstance=_definst_&mediaCasterType=rtp"
Disconnect a stream file
Disconnect a stream file (creedence, in this example):
curl -X PUT \ -H 'Accept:application/json; charset=utf-8' \ -H 'Content-Type:application/json; charset=utf-8' \ http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/instances/_definst_/incomingstreams/creedence.stream/actions/disconnectStream
Note: Stream files must be disconnected before they can be deleted.
Remove a stream file
Delete a stream file (creedence, in this example):
curl -X DELETE \ -H 'Accept:application/json; charset=utf-8' \ http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive/streamfiles/creedence
Admin
— Jacquelyn B on 02/18/2019
If you're receiving a 401 error in your response, you may need to adjust your authentication method or include your set username and password in your requests. For more information, see <a href="https://www.wowza.com/docs/how-to-change-the-authentication-method-for-the-wowza-streaming-engine-rest-api">Change the authentication method for the Wowza Streaming Engine REST API</a>.
— Michel on 02/18/2019
We get "code":"401","wowzaServer":"4.7.7","message":"The request requires user authentication","success":false}