/** * 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())); } }
/** * Start a monitor stream with a placeholder image * * @param YouTubeEvent $event * @throws \InvalidArgumentException * @throws \RuntimeException * @throws \Martin1982\LiveBroadcastBundle\Exception\LiveBroadcastInputException */ protected function startMonitorStream(YouTubeEvent $event) { $placeholderImage = $this->kernel->locateResource('@LiveBroadcastBundle') . '/Resources/images/placeholder.png'; $inputMedia = new MediaMonitorStream(); $inputMedia->setMonitorImage($placeholderImage); $inputService = new InputMonitorStream(); $inputService->setMedia($inputMedia); $streamUrl = $this->getYouTubeApiService()->getStreamUrl($event->getBroadcast(), $event->getChannel()); $outputService = new OutputYouTube(); $outputService->setChannel($event->getChannel()); $outputService->setStreamUrl($streamUrl); $metadata = array('broadcast_id' => $event->getBroadcast()->getBroadcastId(), 'channel_id' => $event->getChannel()->getChannelId(), 'monitor_stream' => 'yes'); try { $this->logger->info('YouTube start monitor stream', array('broadcast_id' => $metadata['broadcast_id'])); $this->commands->startProcess($inputService->generateInputCmd(), $outputService->generateOutputCmd(), $metadata); } catch (LiveBroadcastOutputException $e) { return; } }