/**
  * @param PreBroadcastEvent $event
  */
 public function onPreBroadcast(PreBroadcastEvent $event)
 {
     /** @var LiveBroadcast $liveBroadcast */
     $liveBroadcast = $event->getLiveBroadcast();
     $output = $event->getOutput();
     if ($output instanceof OutputYouTube) {
         $redirectUri = $this->redirectService->getOAuthRedirectUrl();
         $this->youTubeApiService->initApiClients($redirectUri);
         $streamUrl = $this->youTubeApiService->getStreamUrl($liveBroadcast, $output->getChannel());
         if ($streamUrl) {
             $output->setStreamUrl($streamUrl);
         }
     }
 }
 /**
  * Start the actual broadcast
  * @throws LiveBroadcastOutputException
  * @throws \Martin1982\LiveBroadcastBundle\Exception\LiveBroadcastInputException
  */
 protected function startBroadcast()
 {
     $media = $this->plannedBroadcast->getInput();
     $input = $this->inputService->getInputInterface($media)->generateInputCmd();
     /** @var OutputYouTube $outputService */
     $outputService = $this->outputService->getOutputInterface($this->channel);
     $outputService->setStreamUrl($this->youTubeApiService->getStreamUrl($this->plannedBroadcast, $this->channel));
     $output = $outputService->generateOutputCmd();
     $this->logger->info('YouTube start broadcast', array('broadcast_id' => $this->plannedBroadcast->getBroadcastId()));
     $this->command->startProcess($input, $output, array('broadcast_id' => $this->plannedBroadcast->getBroadcastId(), 'channel_id' => $this->channel->getChannelId()));
 }