/** * @test * @depends createLiveStreamOutput * @return LiveStream */ public function createLiveStream(Output $output) { $encodingProfiles = EncodingProfile::getListAll(); $this->assertGreaterThan(0, count($encodingProfiles)); $liveStream = LiveStream::create("testliveinstance", "stream", $encodingProfiles[0], $output, 30); $this->assertNotNull($liveStream->id); return $liveStream; }
public function create($label, $streamKey, $encProfId, $outputId, $timeshift) { Bitcodin::setApiToken($this->session->api_key); try { Bitcodin::setApiToken($this->session->api_key); $encProf = EncodingProfile::get($encProfId); $output = Output::get($outputId); LiveStream::create($label, $streamKey, $encProf, $output, $timeshift); } catch (\Exception $ex) { echo "<div class='top-buffer'></div><div class='alert alert-danger' role='alert'>" . $ex->getMessage() . "</div>"; } redirect('overview'); }
/* 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"; /* * **************************************************