/**
  * Test if the correct output instance is returned for a given channel
  */
 public function testGetOutputInterface()
 {
     $outputFacebook = new OutputFacebook();
     $outputTwitch = new OutputTwitch();
     $channelTwitch = new ChannelTwitch();
     $channelTwitch->setStreamKey('key');
     $channelTwitch->setStreamServer('server');
     $service = new StreamOutputService();
     $service->addStreamOutput($outputFacebook, 'Facebook');
     $service->addStreamOutput($outputTwitch, 'Twitch');
     $twitch = $service->getOutputInterface($channelTwitch);
     self::assertEquals('-vcodec copy -acodec copy -f flv "rtmp://server/app/key"', $twitch->generateOutputCmd());
 }
 /**
  * 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()));
 }
 /**
  * Initiate a new broadcast.
  *
  * @param LiveBroadcast $broadcast
  * @param BaseChannel   $channel
  */
 protected function startBroadcast(LiveBroadcast $broadcast, BaseChannel $channel)
 {
     try {
         $input = $this->inputService->getInputInterface($broadcast->getInput());
         $output = $this->outputService->getOutputInterface($channel);
         $preBroadcastEvent = new PreBroadcastEvent($broadcast, $output);
         $this->dispatcher->dispatch(PreBroadcastEvent::NAME, $preBroadcastEvent);
         $this->logger->info('Start broadcast', array('broadcast_id' => $broadcast->getBroadcastId(), 'broadcast_name' => $broadcast->getName(), 'channel_id' => $channel->getChannelId(), 'channel_name' => $channel->getChannelName(), 'input_cmd' => $input->generateInputCmd(), 'output_cmd' => $output->generateOutputCmd()));
         $this->schedulerCommands->startProcess($input->generateInputCmd(), $output->generateOutputCmd(), array('broadcast_id' => $broadcast->getBroadcastId(), 'channel_id' => $channel->getChannelId()));
         $postBroadcastEvent = new PostBroadcastEvent($broadcast, $output);
         $this->dispatcher->dispatch(PostBroadcastEvent::NAME, $postBroadcastEvent);
     } catch (LiveBroadcastException $ex) {
         $this->logger->error('Could not start broadcast', array('broadcast_id' => $broadcast->getBroadcastId(), 'broadcast_name' => $broadcast->getName(), 'exception' => $ex->getMessage()));
     }
 }