在 wowza 中流式传输目标
Stream Target in wowza
我已经在 curl 的帮助下通过 php 实现了创建流目标。
<?php
$service_url = 'http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/liveSource';
$curl = curl_init($service_url);
$curl_post_data ='
{
"restURI": "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive"
"stream_target": {
"name": “defaultTarget”,
"provider": "rtmp",
"username": "liveSource",
"password": "Welcomehere",
"stream_name": “customTarget”,
"primary_url": "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/liveSource",
} "https://api.cloud.wowza.com/api/v1/stream_targets"
}';
$headers = array(
'Content-Type: application/json; charset=utf-8',
'Accept: application/json; charset=utf-8'
);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data);
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$curl_response = curl_exec($curl);
curl_close($curl);
echo $curl_response;
?>
但它显示错误为成功为错误代码 401
{"message":"The request requires user authentication","success":false,"wowzaServer":"4.4.0","code":"401"}
如果您尝试在 Wowza Streaming 引擎中创建一个流目标,我将从一个简单的示例开始,如下所示:
<?php
// Modify values here
$entryName = "ppSource";
$appName = "live";
$streamName = "myStream";
$userName = "user";
$password = "pass";
$profile = "rtmp";
$server = "localhost";
// End modification
$url = "http://{$server}:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/{$appName}/pushpublish/mapentries/{$entryName}";
$json = "{
\"restURI\": \"http://{$server}:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/{$appName}/pushpublish/mapentries/{$entryName}\",
\"serverName\":\"_defaultServer_\",
\"sourceStreamName\": \"{$streamName}\",
\"entryName\": \"{$entryName}\",
\"profile\": \"{$profile}\",
\"host\": \"{$server}\",
\"application\":\"{$appName}\",
\"userName\":\"{$userName}\",
\"password\":\"{$password}\",
\"streamName\":\"{$streamName}\"
}'";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_HEADER ,0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1);
// curl_setopt($ch, CURLOPT_USERPWD, "user:pass");
// curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept:application/json; charset=utf-8',
'Content-type:application/json; charset=utf-8',
'Content-Length: '.strlen($json)));
$contents = curl_exec($ch);
curl_close($ch);
$obj = json_decode($contents);
var_dump($obj);
但是,如果您尝试通过我们的云启动直播流 api,这里有一个小示例(仅),说明您的请求可能是什么样子:
// Modify values here
$cloudApiKey = "xxxxxxxxxxx";
$cloudApiAccessKey="xxxxxxxxxx";
// End modification
$url = "https://api.cloud.wowza.com/api/v1/live_streams";
$json = "{
\"live_stream\": {
\"id\": \"1234abcd\",
\"name\": \"MyLiveStream\",
\"transcoder_type\": \"transcoded\",
\"billing_mode\": \"pay_as_you_go\",
\"broadcast_location\": \"us_west_california\",
\"recording\": false,
\"encoder\": \"wowza_gocoder\",
\"delivery_method\": \"push\",
\"use_stream_source\": false,
\"aspect_ratio_width\": 1280,
\"aspect_ratio_height\": 720,
\"connection_code\": \"033334\",
\"connection_code_expires_at\": \"2015-11-25T12:06:38.453-08:00\",
\"source_connection_information\": {
\"primary_server\": \"6022e9.entrypoint.cloud.wowza.com\",
\"host_port\": 1935,
\"application\": \"app-464b\",
\"stream_name\": \"32a5814b\",
\"disable_authentication\": false,
\"username\": \"client2\",
\"password\": \"1234abcd\"
},
\"player_responsive\": true,
\"player_countdown\": false,
\"player_embed_code\": \"in_progress\",
\"player_hds_playback_url\": \"http://wowzadev-f.akamaihd.net/z/32a5814b_1@7217/manifest.f4m\",
\"player_hls_playback_url\": \"http://wowzadev-f.akamaihd.net/i/32a5814b_1@7217/master.m3u8\",
\"hosted_page\": true,
\"hosted_page_title\": \"MyLiveStream\",
\"hosted_page_url\": \"in_progress\",
\"hosted_page_sharing_icons\": true
}
}";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_HEADER ,0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept:application/json; charset=utf-8',
'Content-type:application/json; charset=utf-8',
'wsc-api-key: '.$cloudApiKey,
'wsc-access-key: '.$cloudApiAccessKey,
);
$contents = curl_exec($ch);
curl_close($ch);
这是从 examples page 获得的,并经过修改以适应 PHP 相关请求。
谢谢,
马特
我已经在 curl 的帮助下通过 php 实现了创建流目标。
<?php
$service_url = 'http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/liveSource';
$curl = curl_init($service_url);
$curl_post_data ='
{
"restURI": "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/testlive"
"stream_target": {
"name": “defaultTarget”,
"provider": "rtmp",
"username": "liveSource",
"password": "Welcomehere",
"stream_name": “customTarget”,
"primary_url": "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/liveSource",
} "https://api.cloud.wowza.com/api/v1/stream_targets"
}';
$headers = array(
'Content-Type: application/json; charset=utf-8',
'Accept: application/json; charset=utf-8'
);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data);
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$curl_response = curl_exec($curl);
curl_close($curl);
echo $curl_response;
?>
但它显示错误为成功为错误代码 401
{"message":"The request requires user authentication","success":false,"wowzaServer":"4.4.0","code":"401"}
如果您尝试在 Wowza Streaming 引擎中创建一个流目标,我将从一个简单的示例开始,如下所示:
<?php
// Modify values here
$entryName = "ppSource";
$appName = "live";
$streamName = "myStream";
$userName = "user";
$password = "pass";
$profile = "rtmp";
$server = "localhost";
// End modification
$url = "http://{$server}:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/{$appName}/pushpublish/mapentries/{$entryName}";
$json = "{
\"restURI\": \"http://{$server}:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/{$appName}/pushpublish/mapentries/{$entryName}\",
\"serverName\":\"_defaultServer_\",
\"sourceStreamName\": \"{$streamName}\",
\"entryName\": \"{$entryName}\",
\"profile\": \"{$profile}\",
\"host\": \"{$server}\",
\"application\":\"{$appName}\",
\"userName\":\"{$userName}\",
\"password\":\"{$password}\",
\"streamName\":\"{$streamName}\"
}'";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_HEADER ,0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1);
// curl_setopt($ch, CURLOPT_USERPWD, "user:pass");
// curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept:application/json; charset=utf-8',
'Content-type:application/json; charset=utf-8',
'Content-Length: '.strlen($json)));
$contents = curl_exec($ch);
curl_close($ch);
$obj = json_decode($contents);
var_dump($obj);
但是,如果您尝试通过我们的云启动直播流 api,这里有一个小示例(仅),说明您的请求可能是什么样子:
// Modify values here
$cloudApiKey = "xxxxxxxxxxx";
$cloudApiAccessKey="xxxxxxxxxx";
// End modification
$url = "https://api.cloud.wowza.com/api/v1/live_streams";
$json = "{
\"live_stream\": {
\"id\": \"1234abcd\",
\"name\": \"MyLiveStream\",
\"transcoder_type\": \"transcoded\",
\"billing_mode\": \"pay_as_you_go\",
\"broadcast_location\": \"us_west_california\",
\"recording\": false,
\"encoder\": \"wowza_gocoder\",
\"delivery_method\": \"push\",
\"use_stream_source\": false,
\"aspect_ratio_width\": 1280,
\"aspect_ratio_height\": 720,
\"connection_code\": \"033334\",
\"connection_code_expires_at\": \"2015-11-25T12:06:38.453-08:00\",
\"source_connection_information\": {
\"primary_server\": \"6022e9.entrypoint.cloud.wowza.com\",
\"host_port\": 1935,
\"application\": \"app-464b\",
\"stream_name\": \"32a5814b\",
\"disable_authentication\": false,
\"username\": \"client2\",
\"password\": \"1234abcd\"
},
\"player_responsive\": true,
\"player_countdown\": false,
\"player_embed_code\": \"in_progress\",
\"player_hds_playback_url\": \"http://wowzadev-f.akamaihd.net/z/32a5814b_1@7217/manifest.f4m\",
\"player_hls_playback_url\": \"http://wowzadev-f.akamaihd.net/i/32a5814b_1@7217/master.m3u8\",
\"hosted_page\": true,
\"hosted_page_title\": \"MyLiveStream\",
\"hosted_page_url\": \"in_progress\",
\"hosted_page_sharing_icons\": true
}
}";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_HEADER ,0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept:application/json; charset=utf-8',
'Content-type:application/json; charset=utf-8',
'wsc-api-key: '.$cloudApiKey,
'wsc-access-key: '.$cloudApiAccessKey,
);
$contents = curl_exec($ch);
curl_close($ch);
这是从 examples page 获得的,并经过修改以适应 PHP 相关请求。
谢谢, 马特