/** * @test * @depends waitForLiveStream * * @param LiveStream $liveStream * * @throws \Exception */ public function terminateLiveStream(LiveStream $liveStream) { LiveStream::delete($liveStream->id); echo "Waiting until live stream is TERMINATED...\n"; while ($liveStream->status != LiveStream::STATUS_TERMINATED) { sleep(2); $liveStream->update(); if ($liveStream->status == LiveStream::STATUS_ERROR) { echo "ERROR occurred!"; throw new \Exception("Error occurred during Live stream deletion"); } } $this->assertNotEquals($liveStream->status, LiveStream::STATUS_ERROR); $this->assertEquals($liveStream->status, LiveStream::STATUS_TERMINATED); }
public function update_tab($status, $page = 0, $selectedId = -1) { Bitcodin::setApiToken($this->session->api_key); try { $page_limit = $this->session->page_limit; if ($status == 'RUNNING') { $liveInstances = LiveStream::getAll(array('RUNNING', 'STARTING', 'STOPPING')); } else { $liveInstances = LiveStream::getAll($status, $page_limit, $page_limit * $page); } if (!isset($liveInstances) or $liveInstances === NULL) { $liveInstances = array(); } $count = LiveStream::getCount(); $data['count'] = $count; $data['liveInstances'] = $liveInstances; $data['status'] = $status; $num_pages = 0; if ($status == 'RUNNING') { $num_pages = ceil($count->running / $page_limit); } elseif ($status == 'TERMINATED') { $num_pages = ceil($count->terminated / $page_limit); } elseif ($status == 'ERROR') { $num_pages = ceil($count->error / $page_limit); } $data['num_pages'] = $num_pages; $data['active_page'] = $page; $data['selected_id'] = $selectedId; echo $this->load->view('templates/livestreams', $data, TRUE); if ($selectedId != -1) { foreach ($liveInstances as $liveInstance) { if ($liveInstance->id == $selectedId) { $data['selected_instance'] = $liveInstance; } } echo $this->load->view('templates/details.php', $data, TRUE); } } catch (\Exception $ex) { echo "<div class='top-buffer'></div><div class='alert alert-danger' role='alert'>" . $ex->getMessage() . "</div>"; } }
/* CREATE OUTPUT */ $outputConfig = new \bitcodin\S3OutputConfig(); $outputConfig->name = "Livestream Output Config"; $outputConfig->accessKey = "YOUR ACCESS KEY"; $outputConfig->secretKey = "YOUR SECRET KEY"; $outputConfig->bucket = "YOUR BUCKETNAME"; $outputConfig->prefix = "livestream" . $namingPostfix; $outputConfig->makePublic = true; $output = \bitcodin\Output::create($outputConfig); /* CREATE LIVE STREAM */ $livestreamName = "livestream-test-" . $namingPostfix; $livestreamStreamKey = "livestreamtestone"; $timeShift = 30; $liveEdgeOffset = 10; // Defines the offset in seconds to the time the first segment of your livestream was available. Value range: 1 to 3600 $liveInstance = \bitcodin\LiveStream::create($livestreamName, $livestreamStreamKey, $encodingProfile, $output, $timeShift, $liveEdgeOffset); echo "Waiting until live stream is RUNNING...\n"; while ($liveInstance->status != $liveInstance::STATUS_RUNNING) { sleep(2); $liveInstance->update(); if ($liveInstance->status == $liveInstance::STATUS_ERROR) { echo "ERROR occurred!"; throw new \Exception("Error occurred during Live stream creation"); } } echo "Livestream RTMP push URL: " . $liveInstance->rtmpPushUrl . "\n"; echo "Stream Key: " . $liveInstance->streamKey . "\n"; echo "MPD URL: " . $liveInstance->mpdUrl . "\n"; echo "HLS URL: " . $liveInstance->hlsUrl . "\n"; /* * **************************************************
$audio = new AudioStreamConfig(); $audio->bitrate = 128000; $encodingProfileConfig->audioStreamConfigs[] = $audio; /* CREATE ENCODING PROFILE */ $encodingProfile = EncodingProfile::create($encodingProfileConfig); /* CREATE OUTPUT */ $outputConfig = new GcsOutputConfig(); $outputConfig->name = "Livestream Output Config"; $outputConfig->accessKey = "YOUR GCS ACCESS KEY"; $outputConfig->secretKey = "YOUR GCS SECRET KEY"; $outputConfig->bucket = "YOUR GCS BUCKET"; $outputConfig->prefix = "livestream" . date("YmdHis"); $outputConfig->makePublic = true; $output = Output::create($outputConfig); /* CREATE LIVE STREAM */ $liveInstance = LiveStream::create("live-stream-test", "stream", $encodingProfile, $output, 30); echo "Waiting until live stream is RUNNING...\n"; while ($liveInstance->status != $liveInstance::STATUS_RUNNING) { sleep(2); $liveInstance->update(); if ($liveInstance->status == $liveInstance::STATUS_ERROR) { echo "ERROR occurred!"; throw new \Exception("Error occurred during Live stream creation"); } } echo "Livestream RTMP push URL: " . $liveInstance->rtmpPushUrl . "\n"; echo "Stream Key: " . $liveInstance->streamKey . "\n"; echo "MPD URL: " . $liveInstance->mpdUrl . "\n"; echo "HLS URL: " . $liveInstance->hlsUrl . "\n"; /* * **************************************************