/** may be static, if all paramters filled -- When you have to send forward stats data to the home node */ function createForwardObject($type, $data, $objId = 0, $nodeId = 0) { global $db; if (!$objId) { $objId = $this->id; } // the id of the target object if (!$nodeId) { $nodeId = $this->getNodeId(); } // the id of the node to send this to $obj = new sotf_Object("sotf_to_forward"); $obj->setAll(array('prog_id' => $objId, 'node_id' => $nodeId, 'type' => $type, 'entered' => $db->getTimestampTz(), 'data' => serialize($data))); $obj->create(); }
function startStreaming() { global $config, $page, $db; if ($config['httpStreaming']) { $this->makeLocalPlaylist(); $this->url = $config['tmpUrl'] . '/pl_' . $this->getTmpId() . '.m3u'; return; } // check if the stream has started already (Win+IE+Media player) $urls = $db->getCol("SELECT url FROM sotf_streams WHERE host='" . getHostName() . "' AND started < CURRENT_TIMESTAMP AND started > CURRENT_TIMESTAMP - interval '15 seconds'"); if (count($urls) == 1) { debug("found url for Win Explorer", $urls[0]); $this->url = $urls[0]; // found stream so we can return return; } $this->stopMyStream(); if ($config['tamburineURL']) { // streaming with tamburine + XML-RPC // playlist reset($this->audioFiles); while (list(, $audioFile) = each($this->audioFiles)) { $songs[] = $audioFile['path']; } $rpc = new rpc_Utils(); //$rpc->debug = true; $response = $rpc->callTamburine('setpls', $songs); if (is_null($response)) { raiseError("no reply from tamburine server"); } else { $this->url = $response[2]; $this->streamId = $response[1]; } if (!$this->url) { raiseError("Could not find mount point for stream!"); } } elseif ($config['tamburineCMD']) { // streaming with tbrcmd if (!$this->localPlaylist) { $this->makeLocalPlaylist(); } $cmd = $config['tamburineCMD'] . " setpls " . $this->localPlaylist . " 2>&1"; exec($cmd, $output, $retval); debug("cmd", $cmd); //debug("output", $output); //debug("retval", $retval); $lines = array_values(preg_grep('/Fatal Error:/', $output)); if (count($lines) > 0) { raiseError(join(", ", $lines)); // TODO: restart tamburine (??) } //$lines = preg_grep('/Stream\[(\d+)\]\s+spawned on (\S+)/', $output); foreach ($output as $line) { if (preg_match('/Stream\\[(\\d+)\\]\\s+spawned on (\\S+)/', $line, $mm)) { $this->streamId = $mm[1]; $this->url = $mm[2]; break; } } if (!$this->url) { raiseError("Could not find mount point for stream!"); } } else { // command-line streaming if (!$this->localPlaylist) { $this->makeLocalPlaylist(); } $this->url = 'http://' . $config['iceServer'] . ':' . $config['icePort'] . '/' . $this->getMountPoint() . "\n"; //$url = preg_replace('/^.*\/repository/', 'http://sotf2.dsd.sztaki.hu/node/repository', $filepath); // TODO: calculate bitrate from all files... $bitrate = $this->audioFiles[0]['bitrate']; if (!$bitrate) { $bitrate = 24; } $this->cmdStart($this->localPlaylist, $this->getMountPoint(), $bitrate); //$this->cmdStart2($bitrate); } if ($this->url) { $streamData = array('pid' => $this->streamId, 'url' => $this->url, 'started' => $db->getTimestamp(), 'length' => round($this->totalLength), 'will_end_at' => $db->getTimestamp(time() + round($this->totalLength)), 'host' => getHostName()); debug("streamData", $streamData); $_SESSION['stream'] = $streamData; $obj = new sotf_Object('sotf_streams'); $obj->setAll($streamData); $obj->create(); // TODO wait until stream really starts sleep(3); } }