Stream files PHP query examples for the Wowza Streaming Engine REST API

Wowza Streaming Engine media server software includes a REST Application Programming Interface (API) that you can use to configure, manage, and monitor the media server through HTTP requests. This article describes how to identify, add, and manage stream files in a Wowza Streaming Engine media server by using basic PHP requests to query the Wowza Streaming Engine REST service.

Notes:

Contents


Get a list of stream files
Add a stream file
Update a stream file
Connect a stream file
Remove a stream file
For developers

Get a list of stream files


The following example shows how to get a list of existing stream files (files with a .stream extension) from a given application:
$sf = new com\wowza\StreamFile("live");
$response = $sf->getAll();
This request returns a result similar to the following:
{"serverName":"_defaultServer_","streamFiles":[{"id":"cameratest","href":"/v2/servers/_defaultServer_/vhosts/_defaultVHost_/streamfiles/cameratest"},{"id":"shoutcast","href":"/v2/servers/_defaultServer_/vhosts/_defaultVHost_/streamfiles/shoutcast"},{"id":"test","href":"/v2/servers/_defaultServer_/vhosts/_defaultVHost_/streamfiles/test"},{"id":"testme","href":"/v2/servers/_defaultServer_/vhosts/_defaultVHost_/streamfiles/testme"},{"id":"church","href":"/v2/servers/_defaultServer_/vhosts/_defaultVHost_/streamfiles/church"}]}
Similarly, to get a specific stream file configuration (in this case, myStream.stream in the live application), use the following request:
 $sf = new com\wowza\StreamFile("live","myStream");
$response = $sf->get();
This request returns a result similar to the following:
{"version":"1446568438000","serverName":"_defaultServer_","name":"myStream"}

Add a stream file


The following example uses a create command to add a stream file to the live application:
$wowzaApplication = new com\wowza\Application("live");
$sf = new com\wowza\StreamFile($wowzaApplication->getName(), "newStream");
$response = $sf->create(array("uri"=>"rtsp://localhost/vod/mp4:BigBuckBunny_115k.mov","streamTimeout"=>1200,"rtspSessionTimeout"=>800), "rtp");

Update a stream file


After you've initiated the stream file using an add stream file request, use the update command to define or change the stream file's parameters:
$wowzaApplication = new com\wowza\Application("live");
$sf = new com\wowza\StreamFile($wowzaApplication->getName(), "myStream");
$response = $sf->update(array("uri"=>"rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov","streamTimeout"=>"1100","rtspSessionTimeout"=>"600"));

Connect a stream file


To connect to the stream file, use the following request:
$sf = new com\wowza\StreamFile("live", "myStream");
$response = $sf->connect();

Disconnect a stream file


To disconnect the stream file, use the following request:
$sf = new com\wowza\StreamFile("live", "myStream");
$response = $sf->disconnect();

Remove a stream file


When you're done with the stream file, delete it with the following request:
$wowzaApplication = new com\wowza\Application("live");
$sf = new com\wowza\StreamFile($wowzaApplication->getName(), "myStream");
$response = $sf->remove();

For developers


Source code is available on GitHub.

Wowza Media Systems™ provides developers with a platform to create streaming applications and solutions. See Wowza Developer Tools to learn more about our APIs and SDK.
Originally Published: For Wowza Streaming Engine on 12-16-2016.
 

If you're having problems or want to discuss this article, post in our forum.