Store PushPublish services details for use with PushPublish.Connect/Disconnect Depending on the type of some settings may or may not be required. All services require atleast a destination stream, service name. For Akamai destinations the Akamai Host and Stream IDs are required. For RTMP the settings are based on what the service designates as necessary, but can include host address, port, application and instance. Transcoded streams should be group together with the adaptive_group setting designating them with the same group name. Autopush will allow stream to auto connect to the destination when it is published. Lastly, push_source will enable/disable pushing of the source stream for instances where overlays are being added to the transcoded streams.
Akamai HLS pushes require an Akamai Host and Stream ID. To push a single stream into both Akamai's primary and backup streams, enable lock_servers and set the primary_server and backup_server properties to match.
Facebook pushes requires a destination host url and stream.
Requires destination host address and stream
Requires no additional fields. Default host url: a.rtmp.youtube.com, use dst_host to change if different.
RTMP Services will require a host address, and may also require a destination app, instance, port, username and password to connect.
Icecast pushes require a host address, port, username, and password
Requires no additional fields. Default host url: live.twitch.tv, use dst_host to change if different.
$request = array( 'command' => 'pushpublish.add', 'api_key' => 'APX4GKLM0RKQLSP2FBO1ROPKSSW47DZE', 'timestamp' => time(), 'cdn' => 158, 'service_name' => 'akamai', 'dst_stream' => 'destination_stream_name', 'adaptive_group' => 'group1', //optional /* Default Source Params */ 'app' => 'demo-origin', //optional 'stream' => 'livestream', //optional 'autopush' => true, //optional /* Akamai Params */ 'host_id' => 'akamai_host_id', 'stream_id' => 'akamai_stream_id', 'event_name' => 'my_event', //optional 'push_source' => true, //optional 'redundant_playlist' => 1, //optional 'playback_ssl' => 0, //optional 'addEndListOnDisconnect' => false, //optional /* Advanced Settings */ 'playlist_count' => 0, //optional 'playlist_timeout' => 120000, //optional 'playlist_across_sessions' => 0, //optional 'relative_playlist' => 0, //optional 'bitrate_order' => 'high2low', //optional 'send_ssl' => 1, //optional 'primary_server' => 'PRI1', //optional 'backup_server' => 'BAK1', //optional 'lock_servers' => 1, /* RTMP Params */ 'dst_host' => 'rtmp.host.com', //do not include rtmp:// 'dst_port' => 1935, 'dst_app' => 'destination_app', 'dst_appinst' => 'destination_instance', 'username' => 'rtmp_user', 'password' => 'rtmp_pass', ); //Create request signature $json_request = json_encode($request); $sig = base64_encode(hash_hmac('sha256', $json_request, '8fc8c48da81e6a2a06a9556379bf798af508dc0792497c678b4c3532ba8b637f', true)); $request['signature'] = $sig; $json_request = json_encode($request); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://api.scaleengine.net/stable/'); // Set the URL curl_setopt($ch, CURLOPT_POST, true); // Perform a POST curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // If not set, curl prints output to the browser curl_setopt($ch, CURLOPT_HEADER, false); // If set, curl returns headers as part of the data stream curl_setopt($ch, CURLOPT_POSTFIELDS, array('json' => $json_request)); //'Json' string or 'PHP' serialized return //If your PHP host does not have a proper SSL certificate bundle, you will need to turn off SSL Certificate Verification //This is dangerous, and should only be done temporarily until a proper certificate bundle can be installed //curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // Turns off verification of the SSL certificate. //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Turns off verification of the SSL certificate. $response = curl_exec($ch); //Execute the API Call if (!$response) { die('Failed to connect to ScaleEngine API'); } //Decode the response as an associative array $arrResponse = json_decode($response, true); if ($arrResponse) { //Operation completed successfully //TODO Add work here print_r($arrResponse); } else { //Operation failed echo 'An error occured processing your request:'; print_r($response); }
command | [REQUIRED] [string] - API command to execute |
cdn | [REQUIRED] [int] - The ScaleEngine CDN ID of your account |
api_key | [REQUIRED] [string] - The API key provided as part of your account |
timestamp | [REQUIRED] [int] - The unix timestamp of your request, used to prevent authenticated API requests from being replayed |
service_name | [REQUIRED] [string] - service type.
Available services:
|
dst_stream | [REQUIRED] [string] - PushPublish Destination Stream Name |
adaptive_group | [OPTIONAL] [string] - Name for a group of transcoded streams |
app | [OPTIONAL] [string] - The ScaleEngine Application name |
stream | [OPTIONAL] [string] - Stream name |
autopush | [OPTIONAL] [boolean] - Push stream to destination when it is published. |
host_id | [OPTIONAL] [string] - Service Host ID |
stream_id | [OPTIONAL] [int] - Service Stream ID |
event_name | [OPTIONAL] [String] - Akamai stream event name. |
push_source | [OPTIONAL] [boolean] - Push source stream to destination. Default true |
dst_host | [OPTIONAL] [string] - Destination Host Address. Do not inlcude protocol or port in the address. |
dst_port | [OPTIONAL] [int] - Destination Port Number. |
dst_app | [OPTIONAL] [string] - Destination Application Name |
dst_appinst | [OPTIONAL] [string] - Destination Application Instance Name |
playlist_count | [OPTIONAL] [int] - How many chunks to have on the manifest for each rendition. [Default: 0] |
playlist_timeout | [OPTIONAL] [int] - How many milliseconds to keep the playlist after the encoder disconnects. [Default: 120,000] |
playlist_across_sessions | [OPTIONAL] [int] - Set to 1, keep the playlist when the encoder disconnects, instead of starting over. [Default: 0] |
relative_playlist | [OPTIONAL] [int] - [Default: false] |
bitrate_order | [OPTIONAL] [string] - "high2low" shows the top bitrate first in the rendition list, or "low2high" shows the lowest bitrate first. [Default: high2low]. |
primary_server | [OPTIONAL] [string] - Locks the Primary PushPublish destination to the specific Server Tag. If the primary_server matches the backup_server, pushes to akamai will push redundantly to both primary and backup destinations. |
backup_server | [OPTIONAL] [string] - Locks the Backup PushPublish destination to a specific Server Tag. |
lock_servers | [OPTIONAL] [int] - Set to 1 to lock the Primary and Backup Servers, preventing all other sources from pushing streams to this server. [Default: 0] |
redundant_playlist | [OPTIONAL] [int] - Creates the playlist.m3u8 file with both akamai primary and backup (-b) urls; Set to 1 to enable [Default: 0] |
send_ssl | [OPTIONAL] [boolean] - Push to RTMP Sources using SSL. default: false |
playback_ssl | [OPTIONAL] [boolean] - Enables Akamai Manifests to use HTTPS urls. default: false |
addEndListOnDisconnect | [OPTIONAL] [boolean] - Add End List tag to chunklist when Stream Disconnects. (default false) |
username | [OPTIONAL] [String] - RTMP Username |
password | [OPTIONAL] [String] - RTMP Password |
{ "message": "PushPublish services stored", "status": "success", "handle_time":"0.3795 seconds", "push_service_id" : 1 }
message | [string] - Debugging message |
status | [string] - "success" or "failure" |
handle_time | [float] - The amount of time spent processing your request |
push_service_id | [int] - ID of the stored PushPublish Service details |