Skip to content

Commit

Permalink
Fix bug with missing input stream service
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin de Keijzer committed Aug 15, 2016
1 parent 1bd38f9 commit 1efe226
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
3 changes: 3 additions & 0 deletions EventListener/YouTubePostBroadcastListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class YouTubePostBroadcastListener implements EventSubscriberInterface
* @param YouTubeApiService $youTubeApiService
* @param Router $router
* @param string $redirectRoute
* @throws \Symfony\Component\Routing\Exception\InvalidParameterException
* @throws \Symfony\Component\Routing\Exception\MissingMandatoryParametersException
* @throws \Symfony\Component\Routing\Exception\RouteNotFoundException
*/
public function __construct(YouTubeApiService $youTubeApiService, Router $router, $redirectRoute)
{
Expand Down
15 changes: 13 additions & 2 deletions EventListener/YouTubePostBroadcastLoopListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Martin1982\LiveBroadcastBundle\Entity\Metadata\YouTubeEvent;
use Martin1982\LiveBroadcastBundle\Event\PostBroadcastLoopEvent;
use Martin1982\LiveBroadcastBundle\Exception\LiveBroadcastOutputException;
use Martin1982\LiveBroadcastBundle\Service\StreamInput\InputMonitorStream;
use Martin1982\LiveBroadcastBundle\Service\StreamOutput\OutputYouTube;
use Martin1982\LiveBroadcastBundle\Service\YouTubeApiService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
Expand Down Expand Up @@ -53,6 +54,9 @@ class YouTubePostBroadcastLoopListener implements EventSubscriberInterface
* @param KernelInterface $kernel
* @param Router $router
* @param $redirectRoute
* @throws \Symfony\Component\Routing\Exception\InvalidParameterException
* @throws \Symfony\Component\Routing\Exception\MissingMandatoryParametersException
* @throws \Symfony\Component\Routing\Exception\RouteNotFoundException
*/
public function __construct(
EntityManager $entityManager,
Expand All @@ -79,6 +83,7 @@ public function __construct(
* Get planned streams which aren't live yet on the monitor
*
* @param PostBroadcastLoopEvent $event
* @throws \Martin1982\LiveBroadcastBundle\Exception\LiveBroadcastOutputException
*/
public function onPostBroadcastLoop(PostBroadcastLoopEvent $event)
{
Expand Down Expand Up @@ -157,13 +162,19 @@ protected function hasRunningTestStream(YouTubeEvent $event, $runningProcesses)
* Start a test stream with a placeholder image
*
* @param YouTubeEvent $event
* @throws \InvalidArgumentException
* @throws \RuntimeException
* @throws \Martin1982\LiveBroadcastBundle\Exception\LiveBroadcastInputException
*/
protected function startTestStream(YouTubeEvent $event)
{
$placeholderImage = $this->kernel->locateResource('@LiveBroadcastBundle') . '/Resources/images/placeholder.png';

$inputService = new MediaMonitorStream();
$inputService->setMonitorImage($placeholderImage);
$inputMedia = new MediaMonitorStream();
$inputMedia->setMonitorImage($placeholderImage);

$inputService = new InputMonitorStream();
$inputService->setMedia($inputMedia);

$streamUrl = $this->youTubeApiService->getStreamUrl($event->getBroadcast(), $event->getChannel());

Expand Down
17 changes: 16 additions & 1 deletion EventListener/YouTubeSwitchMonitorListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Martin1982\LiveBroadcastBundle\Entity\Metadata\YouTubeEvent;
use Martin1982\LiveBroadcastBundle\Event\SwitchMonitorEvent;
use Martin1982\LiveBroadcastBundle\Exception\LiveBroadcastOutputException;
use Martin1982\LiveBroadcastBundle\Service\StreamInputService;
use Martin1982\LiveBroadcastBundle\Service\StreamOutput\OutputYouTube;
use Martin1982\LiveBroadcastBundle\Service\StreamOutputService;
use Martin1982\LiveBroadcastBundle\Service\YouTubeApiService;
Expand Down Expand Up @@ -46,6 +47,11 @@ class YouTubeSwitchMonitorListener implements EventSubscriberInterface
*/
protected $outputService;

/**
* @var StreamInputService
*/
protected $inputService;

/**
* @var YouTubeApiService
*/
Expand All @@ -55,20 +61,25 @@ class YouTubeSwitchMonitorListener implements EventSubscriberInterface
* YouTubeSwitchMonitorListener constructor.
* @param SchedulerCommandsInterface $command
* @param StreamOutputService $outputService
* @param StreamInputService $inputService
* @param YouTubeApiService $youTubeApiService
* @param Router $router
* @param $redirectRoute
* @throws \Exception
* @throws \Symfony\Component\Routing\Exception\InvalidParameterException
* @throws \Symfony\Component\Routing\Exception\MissingMandatoryParametersException
* @throws \Symfony\Component\Routing\Exception\RouteNotFoundException
*/
public function __construct(
SchedulerCommandsInterface $command,
StreamOutputService $outputService,
StreamInputService $inputService,
YouTubeApiService $youTubeApiService,
Router $router,
$redirectRoute
) {
$this->command = $command;
$this->outputService = $outputService;
$this->inputService = $inputService;
$this->youTubeApiService = $youTubeApiService;

$redirectUri = $router->generate(
Expand All @@ -88,6 +99,10 @@ public function onSwitchMonitor(SwitchMonitorEvent $event)
$this->plannedBroadcast = $event->getPlannedBroadcast();
$this->channel = $event->getChannel();

if (!$this->channel instanceof ChannelYouTube) {
return;
}

$this->youTubeApiService->transitionState(
$this->plannedBroadcast,
$this->channel,
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ services:
- { name: kernel.event_subscriber }
live.broadcast.youtube_switch_monitor_listener:
class: Martin1982\LiveBroadcastBundle\EventListener\YouTubeSwitchMonitorListener
arguments: ["@live.broadcast.scheduler.commands", "@live.broadcast.streamoutput.service", "@live.broadcast.youtubeapi.service", "@router", "%live_broadcast_yt_redirect_route%"]
arguments: ["@live.broadcast.scheduler.commands", "@live.broadcast.streamoutput.service", "@live.broadcast.streaminput.service", "@live.broadcast.youtubeapi.service", "@router", "%live_broadcast_yt_redirect_route%"]
tags:
- { name: kernel.event_subscriber }

Expand Down

0 comments on commit 1efe226

Please sign in to comment.