/**
  * Retrieve what is broadcasting.
  *
  * @return RunningBroadcast[]
  */
 protected function updateRunningBroadcasts()
 {
     $this->runningBroadcasts = array();
     $this->logger->debug('Retrieve running broadcasts');
     $processStrings = $this->schedulerCommands->getRunningProcesses();
     foreach ($processStrings as $processString) {
         $runningItem = new RunningBroadcast($this->schedulerCommands->getBroadcastId($processString), $this->schedulerCommands->getProcessId($processString), $this->schedulerCommands->getChannelId($processString), $this->schedulerCommands->getEnvironment($processString), $this->schedulerCommands->isMonitorStream($processString));
         if ($runningItem->isValid($this->schedulerCommands->getKernelEnvironment())) {
             $this->runningBroadcasts[] = $runningItem;
         }
     }
     return $this->runningBroadcasts;
 }
 /**
  * Clean up running monitor streams
  */
 protected function cleanMonitorStreams()
 {
     $runningStreams = $this->commands->getRunningProcesses();
     foreach ($runningStreams as $streamCmd) {
         $process = $this->createRunningProcess($streamCmd);
         if ($process->isMonitor() === false) {
             continue;
         }
         $eventRepository = $this->entityManager->getRepository('LiveBroadcastBundle:Metadata\\YouTubeEvent');
         $event = $eventRepository->find($process->getBroadcastId());
         if ($event && $event->getLastKnownState() >= YouTubeEvent::STATE_LOCAL_COMPLETE) {
             $this->commands->stopProcess($process->getProcessId());
         }
     }
 }