/** * Remove an object. * @param ChunsuObject $removeme The object to remove. * @param DataSource $source The data source to remove the object from. * @return bool TRUE is successful, FALSE otherwise. */ function remove(&$removeme, &$source) { if (IsLogEnabled('DEBUG')) { LogDebug("removing " . get_class($removeme), $this); } return FALSE; }
/** * Shut down the data source. * <p>When a fatal log event is not encountered, but FALSE is returned, * it means that the shutdown mechanism has not been implemented for * the data source a particular level. This behavior is only expected * when calling DataSource::shutdown() explicitly. * @return bool TRUE if successful, FALSE otherwise. */ function shutdown() { if ($this->isConnected) { if (IsLogEnabled('DEBUG')) { LogDebug("shutting down: " . print_r($this, TRUE), $this); } $this->isConnected = FALSE; return FALSE; } else { if (IsLogEnabled('DEBUG')) { LogDebug("already shut down", $this); } return TRUE; } }
function WriteFragment($download, &$opt) { $this->frags[$download['id']] = $download; $available = count($this->frags); for ($i = 0; $i < $available; $i++) { if (isset($this->frags[$this->lastFrag + 1])) { $frag = $this->frags[$this->lastFrag + 1]; if ($frag['response'] !== false) { LogDebug("Writing fragment " . $frag['id'] . " to flv file"); if (!isset($opt['file'])) { $opt['debug'] = false; if ($this->play) { $outFile = STDOUT; } else { if ($this->outFile) { if ($opt['filesize']) { $outFile = JoinUrl($this->outDir, $this->outFile . '-' . $this->fileCount++ . ".flv"); } else { $outFile = JoinUrl($this->outDir, $this->outFile . ".flv"); } } else { if ($opt['filesize']) { $outFile = JoinUrl($this->outDir, $this->baseFilename . '-' . $this->fileCount++ . ".flv"); } else { $outFile = JoinUrl($this->outDir, $this->baseFilename . ".flv"); } } } $this->InitDecoder(); $this->DecodeFragment($frag['response'], $frag['id'], $opt); $opt['file'] = WriteFlvFile($outFile, $this->audio, $this->video); if ($this->metadata) { WriteMetadata($this, $opt['file']); } $opt['debug'] = $this->debug; $this->InitDecoder(); } $flvData = $this->DecodeFragment($frag['response'], $frag['id'], $opt); if (strlen($flvData)) { $status = fwrite($opt['file'], $flvData, strlen($flvData)); if (!$status) { LogError("Failed to write flv data"); } if (!$this->play) { $this->filesize = ftell($opt['file']) / (1024 * 1024); } } $this->lastFrag = $frag['id']; } else { $this->lastFrag += 1; LogDebug("Skipping failed fragment " . $this->lastFrag); } unset($this->frags[$this->lastFrag]); } else { break; } if ($opt['tDuration'] and $opt['duration'] + $this->duration >= $opt['tDuration']) { LogInfo(""); LogInfo($opt['duration'] + $this->duration . " seconds of content has been recorded successfully.", true); return STOP_PROCESSING; } if ($opt['filesize'] and $this->filesize >= $opt['filesize']) { $this->filesize = 0; $opt['duration'] += $this->duration; fclose($opt['file']); unset($opt['file']); } } if (!count($this->frags)) { unset($this->frags); } return true; }
/** * Log a debug message. * @param string $message The message. */ function debug($message) { LogDebug($message, $this); }
$dataLength = ReadInt32($decTable, $decPos + 5); $decPos += 9; if ($encrypted) { $rawLength = ReadInt32($decTable, $decPos); $decPos += 4; } else { $rawLength = $dataLength; } LogDebug("Time: {$time}, DataLength: {$dataLength}, RawLength: {$rawLength}"); // Decrypt encrypted tags $data = substr($file, $filePos, $dataLength); if ($encrypted) { LogDebug("Encrypted Packet: " . hexlify($data)); mcrypt_generic_init($td, $key, $iv); $data = mdecrypt_generic($td, $data); LogDebug("Decrypted Packet: " . hexlify($data)); $data = substr($data, 0, $rawLength); } // Create video tag if ($type == 1) { // Create codec tag if ($version == 2) { $codecTag = " "; WriteByte($codecTag, 0, 7 | ($keyframe ? 16 : 32)); WriteByte($codecTag, 1, $config ? 0 : 1); WriteInt24($codecTag, 2, 0); } else { $codecTag = ""; } // Create flv tag $flvTag = " ";
/** * Save an object. * @param ChunsuObject $saveme The object to save. * @param DataSource $source The data source to save the object to. * @return bool TRUE is successful, FALSE otherwise. */ function save(&$saveme, &$source) { parent::save($saveme, $source); if ($saveme->isChanged()) { if ($saveme->config->get('create-on-save') && $saveme->is_new) { $saveme->commit(); // flatten changes into core $gen = new SQLGenerator($saveme->getCore()); $savequeries = $gen->replace($this->config); } else { $params = $saveme->changeset; $pk = $this->config->getPrimaryKey(); $pkalias = $pk->get('alias'); $params[$pkalias] = $saveme->get($pkalias); foreach ($this->config->getForeignKeys() as $fk) { $fkalias = $fk->get('alias'); $params[$fkalias] = $saveme->get($fkalias); } $gen = new SQLGenerator($params); $savequeries = $gen->update($this->config); } foreach ($savequeries as $sq) { $cursor =& $source->query($sq); if (!$cursor->getNext()) { LogError("save query failed! saving " . print_r($saveme, TRUE)); return FALSE; } } $saveme->is_new = FALSE; if ($pkval = $cursor->get('generated-id')) { $pkfield =& $this->config->get('primary-key'); $pka =& $pkfield->get('alias'); // for "replace into", treat this save as a load $saveme->is_loaded = TRUE; $opkval = $saveme->get($pka); if ($opkval == 'new') { $opkval = NULL; } if (!is_null($opkval) && $pkval != $opkval) { LogError("Primary key mismatch: {$pkval} != {$opkval} saving " . $saveme->trace()); LogFatal("Primary key mismatch: {$pkval} != {$opkval}"); } // reset the primary key with the value assigned by the // data source $saveme->set($pkval, $pka); $saveme->commit(); if (IsLogEnabled('DEBUG')) { LogDebug("set {$pka} to {$pkval}: " . $saveme->trace()); } } if ($rows = $cursor->get('affected-rows') > 1) { LogWarning($rows . " records written saving " . print_r($saveme, TRUE)); } } return TRUE; }
$pVideoTagLen = $totalTagLen; } else { LogDebug(sprintf("%s\n" . $format, "Skipping small sized video packet", "VIDEO", $packetTS, $prevVideoTS, $packetSize)); } } else { LogDebug(sprintf("%s\n" . $format, "Skipping video packet", "VIDEO", $packetTS, $prevVideoTS, $packetSize)); } if (!$video) { $video = true; } break; case SCRIPT_DATA: if ($metadata) { $pMetaTagPos = ftell($flvOut); fwrite($flvOut, $flvTag, $totalTagLen); LogDebug(sprintf($format . "%-16s", "META", $packetTS, 0, $packetSize, $pMetaTagPos)); } break; } $filePos += $totalTagLen; $cFilePos = floor($filePos / (1024 * 1024)); if ($cFilePos > $pFilePos) { printf("Processed %d/%.2f MB\r", $cFilePos, $fileSize); $pFilePos = $cFilePos; } } // Set proper Audio/Video marker WriteByte($flvHeader, 4, $audio << 2 | $video); fseek($flvOut, 0); fwrite($flvOut, $flvHeader, $flvHeaderLen); fclose($flvIn);
$range = explode(':', $line, 2); $range = $range[1]; $range = explode('@', trim($range)); $t =& $byteRange[]; $t['start'] = trim($range[1]); $t['len'] = trim($range[0]); } } // Read encryption key $key = file_get_contents($argv[3]); if ($key === false) { die("Failed to open key file."); } $iv = $key; LogDebug("Key: " . hexlify($key)); LogDebug("IV : " . hexlify($iv)); // Retrieve and decrypt encrypted blobs $decData = ""; $td = mcrypt_module_open('rijndael-128', '', 'cbc', ''); mcrypt_generic_init($td, $key, $iv); $input = fopen($argv[2], 'rb'); if ($input === false) { die("Failed to open input file."); } $output = fopen($argv[4], 'wb'); if ($output === false) { die("Failed to open output file."); } foreach ($byteRange as $range) { fseek($input, $range['start']); $encData = fread($input, $range['len']);