Ejemplo n.º 1
0
 public function startEngine(X_Threads_Thread $thread)
 {
     // assume all parameters are ready
     $thread->log("Spawning VLC...");
     $this->vlc->spawn();
     $thread->log("VLC execution finished");
 }
 public function startEngine(X_Threads_Thread $thread)
 {
     // assume all parameters are ready
     $thread->log("Spawning RTMPDump (rtmpdump-weebtv | vlc)...");
     $source = $this->getParam('source');
     // set the path
     if (X_Env::isWindows()) {
         X_RtmpDumpWeebTv::getInstance()->setPath(APPLICATION_PATH . '/../bin/rtmpdump-weebtv-win/rtmpdump-weebtv.exe');
     } else {
         X_RtmpDumpWeebTv::getInstance()->setPath(APPLICATION_PATH . '/../bin/rtmpdump-weebtv-linux/rtmpdump-weebtv');
     }
     $weebPlugin = X_VlcShares_Plugins::broker()->getPlugins('weebtv');
     if ($weebPlugin instanceof X_VlcShares_Plugins_WeebTv && X_VlcShares_Plugins::helpers()->streamer()->isRegistered('vlc')) {
         // try to get reference to vlc-streamer
         /* @var $vlcStreamer X_Streamer_Engine_Vlc */
         $vlcStreamer = X_VlcShares_Plugins::helpers()->streamer()->get('vlc');
         // get the channel id
         $source = substr($source, strlen('rtmpdump-weebtv://'));
         // make the plugin to parse params from server and build a rtmpdump-weebtv uri
         $source = $weebPlugin->getLinkParams($source);
         // always live
         $command = (string) X_RtmpDumpWeebTv::getInstance()->parseUri($source);
         $vlcStreamer->getVlcWrapper()->setPipe($command);
         $vlcStreamer->setSource('-');
         $vlcStreamer->setParam('profile', "#std{access=http{mime=video/x-flv},mux=ffmpeg{mux=flv},dst=0.0.0.0:{$weebPlugin->getStreamingPort()}/stream}");
         // redirect std error to null
         // and force quite
         //X_Env::execute("$command -q 2> /dev/null", X_Env::EXECUTE_OUT_NONE, X_Env::EXECUTE_PS_WAIT);
         //X_Env::execute($command, X_Env::EXECUTE_OUT_NONE, X_Env::EXECUTE_PS_WAIT);
         $vlcStreamer->getVlcWrapper()->spawn();
         $thread->log("RTMPDump execution finished");
     } else {
         $thread->log("RTMPDump-weebtv cannot be started without weebtv plugin and vlc streamer");
     }
 }
Ejemplo n.º 3
0
 public function startEngine(X_Threads_Thread $thread)
 {
     // assume all parameters are ready
     $thread->log("Spawning SopCast...");
     $source = $this->getParam('source');
     $command = (string) X_SopCast::getInstance()->setUri($source);
     X_Env::execute($command, X_Env::EXECUTE_OUT_NONE, X_Env::EXECUTE_PS_WAIT);
     //$this->vlc->spawn();
     $thread->log("SopCast execution finished");
 }
Ejemplo n.º 4
0
 public function deQueue(X_Threads_Thread $thread)
 {
     $queue = $this->getZendQueue($thread->getId());
     $message = $queue->receive(1, 0);
     if (count($message) > 0) {
         $message = $message->current();
         $queue->deleteMessage($message);
         return @unserialize($message->body);
     } else {
         // invoke queue removal
         return new X_Threads_Message_Wait();
     }
 }
Ejemplo n.º 5
0
 public function run($params = array(), X_Threads_Thread $thread)
 {
     $this->thread = $thread;
     $streamerId = X_Env::isset_or($params['streamerId'], false);
     $streamerClass = X_Env::isset_or($params['streamerClass'], false);
     $params = X_Env::isset_or($params['params'], array());
     if (!$streamerId) {
         $thread->log("Sorry dude, no streamerId submitted. Can't do anything");
         return X_Threads_Thread::RETURN_INVALID_PARAMS;
     }
     /* @var $streamer X_Streamer_Engine_Vlc */
     $streamer = X_VlcShares_Plugins::helpers()->streamer()->get($streamerId);
     $streamer->setParams($params);
     $streamer->startEngine($thread);
     return self::RETURN_NORMAL;
 }
Ejemplo n.º 6
0
 public function startEngine(X_Threads_Thread $thread)
 {
     // assume all parameters are ready
     $thread->log("Spawning RTMPDump (rtmpdump | vlc)...");
     $source = $this->getParam('source');
     if (X_VlcShares_Plugins::helpers()->streamer()->isRegistered('vlc')) {
         $command = (string) X_RtmpDump::getInstance()->parseUri($source);
         $streamPort = X_VlcShares_Plugins::helpers()->rtmpdump()->getStreamPort();
         // try to get reference to vlc-streamer
         /* @var $vlcStreamer X_Streamer_Engine_Vlc */
         $vlcStreamer = X_VlcShares_Plugins::helpers()->streamer()->get('vlc');
         $vlcStreamer->getVlcWrapper()->setPipe($command);
         $vlcStreamer->setSource('-');
         $vlcStreamer->setParam('profile', "#std{access=http{mime=video/x-flv},mux=ffmpeg{mux=flv},dst=0.0.0.0:{$streamPort}/}");
         //X_Env::execute($command, X_Env::EXECUTE_OUT_NONE, X_Env::EXECUTE_PS_WAIT);
         $vlcStreamer->getVlcWrapper()->spawn();
         //$this->vlc->spawn();
         $thread->log("RTMPDump execution finished");
     } else {
         $thread->log("RTMPDump cannot be started without vlc streamer");
     }
 }
Ejemplo n.º 7
0
 /**
  * Send an UDP packet with $buf content
  * 
  * @param string $buf
  * @param int $delay
  * @param string $host
  * @param int $port
  * @return boolean
  */
 private function _udpSend($buf, $delay = 15, $host = "239.255.255.250", $port = 1900, $bind = '0')
 {
     // create socket
     $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
     if (!$socket) {
         $this->thread->log("Socket creation failed");
         return false;
     }
     // bind socket
     if (!socket_bind($socket, $bind)) {
         $this->thread->log("Socket bind failed");
         socket_close($socket);
         return false;
     }
     // send packet
     if (false === socket_sendto($socket, $buf, strlen($buf), 0, $host, $port)) {
         $this->thread->log("Sendto failed");
         socket_close($socket);
         return false;
     }
     usleep($delay * 1000);
     // microsecond * 1000 = milliseconds
     return true;
 }
Ejemplo n.º 8
0
 /**
  * Create a new thread if $threadId is not already running
  * 
  * @param string $threadId
  * @return X_Threads_Thread_Info|X_Threads_Thread
  */
 public function newThread($threadId)
 {
     $thread = $this->getMonitor()->getThread($threadId);
     if ($thread->getState() == X_Threads_Thread_Info::STOPPED) {
         // create a new thread and return it
         $thread = new X_Threads_Thread($threadId, $this);
         if (!$this->isLogger()) {
             $thread->setLogger(new X_Threads_Logger_Null());
         } else {
             $thread->setLogger(new X_Threads_Logger_File("vlcShares.thread-{$threadId}.log", X_Debug::getLogPath()));
             // redirect standard debug too if enabled
             if (X_Debug::isEnabled()) {
                 X_Debug::i("Forking debug log to {" . X_Debug::getLogPath() . "/vlcShares.thread-{$threadId}.log");
                 X_Debug::init(X_Debug::getLogPath() . "/vlcShares.thread-{$threadId}.log", X_Debug::getLevel());
             }
         }
     }
     return $thread;
 }