Am I doing something wrong, or do we have a bug in LiveStream API? How can three different sources show three different live stream names for the very same Ingestion?
By some reason, the inserted LiveStream object comes with a response that does not match YouTube Web Page.
Sections of this question:
PHP Code for live stream
$streamSnippet = new \Google_Service_YouTube_LiveStreamSnippet();
$streamSnippet->setTitle($cameraName);
$cdn = new \Google_Service_YouTube_CdnSettings();
$cdn->setFormat($cameraName);
$cdn->setIngestionType('rtmp');
$streamInsert = new \Google_Service_YouTube_LiveStream();
$streamInsert->setSnippet($streamSnippet);
$streamInsert->setCdn($cdn);
$streamInsert->setKind('youtube#liveStream');
$liveStream = $youtube->liveStreams->insert('snippet,cdn',$streamInsert, array());
API Result into $liveStream
Google_Service_YouTube_LiveStream Object
(
[cdnType:protected] => Google_Service_YouTube_CdnSettings
...
[etag] => "5C5HHOaBSHC5ZXfkrT4ZlRCi01A/lY9i12sOWOAkTwfchEAQUxEWdX8"
[id] => UOzxsX96_We6MrMTsP5RiA1480670405575117
[kind] => youtube#liveStream
...
[modelData:protected] => Array
(
...
[cdn] => Array
(
[format] => 1440p
[ingestionType] => rtmp
[ingestionInfo] => Array
(
[streamName] => 9zfr-ggd9-brtf-XXXX
[ingestionAddress] => rtmp://a.rtmp.youtube.com/live2
[backupIngestionAddress] => rtmp://b.rtmp.youtube.com/live2?backup=1
)
[resolution] => 1440p
[frameRate] => 30fps
)
)
...
)
PHP Code for broadcast insert & binding
$broadcastInsert = new \Google_Service_YouTube_LiveBroadcast();
$broadcastInsert->setSnippet($broadcastSnippet);
$broadcastInsert->setStatus($status);
$broadcastInsert->setKind('youtube#liveBroadcast');
$broadcastsResponse = $youtube->liveBroadcasts->insert('snippet,status',$broadcastInsert, array());
$bindBroadcastResponse = $youtube->liveBroadcasts->bind($broadcastsResponse['id'],'id,contentDetails',array('streamId' => $liveStream['id'],));
Response into $bindBroadcastResponse
Google_Service_YouTube_LiveBroadcast Object
(
...
[etag] => "5C5HHOaBSHC5ZXfkrT4ZlRCi01A/_2Jev_YmRlYUwMBX1ptq_Kp8uVs"
[id] => idd8f7dSLzk
[kind] => youtube#liveBroadcast
...
[modelData:protected] => Array
(
[contentDetails] => Array
(
[boundStreamId] => UOzxsX96_We6MrMTsP5RiA1480670405575117
...
)
)
)
YouTube LiveStream API Explorer
If I list all the streams later, using LiveStream API Explorer, see image below, I got a third different result (see code below).
{
"kind": "youtube#liveStreamListResponse",
"etag": "\"5C5HHOaBSHC5ZXfkrT4ZlRCi01A/RGcoFd2XK9IZmX0hgw_pFxuaeC4\"",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#liveStream",
"etag": "\"5C5HHOaBSHC5ZXfkrT4ZlRCi01A/d-ptvs6HC_oItk2Kv2PtrovurCk\"",
"id": "UOzxsX96_We6MrMTsP5RiA1480670405575117",
"snippet": ...,
"cdn": {
"format": "1440p",
"ingestionType": "rtmp",
"ingestionInfo": {
"streamName": "1wzh-zjwb-b0fr-XXXX",
"ingestionAddress": "rtmp://a.rtmp.youtube.com/live2",
"backupIngestionAddress": "rtmp://b.rtmp.youtube.com/live2?backup=1"
},
"resolution": "1440p",
"frameRate": "30fps"
}
}
]
}
Recap
PHP-> Google_Service_YouTube_LiveBroadcast[id] => idd8f7dSLzk
PHP-> Google_Service_YouTube_LiveStream->modelData[cdn][ingestionInfo][streamName] => 9zfr-ggd9-brtf-XXXX
API Explorer -> items[0].cdn.ingestionInfo.streamName => "1wzh-zjwb-b0fr-XXXX"
And the result in YouTube page does not match
After very long time, someone replied the bug I have filled to Google.
This is the response from this thread:
It's not necessarily expected for the stream key provided by the API to match the stream key provided by the user interface. However, if the two stream keys are different, both should work.
Please respond on this bug if you're seeing an issue where the stream keys are different and only one of them works.
The thing is that I had tried previously to cast using the stream name I got from the API, but it had not worked.
Testing now, it works.