protected function write($filename) { /* * File to write */ $stream = new Yamdi_OutputStream($filename); if (!$this->header->isValid()) { throw new Exception('Must read an flv file before writing it'); } /* * Writing preamble tags */ $this->header->write($stream); $this->zeroTagSize->write($stream); $this->writeMetaBlock($stream); $this->writeMediaBlocks($stream); $stream->close(); }
/** * @deprecated */ public function testMetadataWriteback() { /* * File to read */ $stream = new Yamdi_InputStream(dirname(__FILE__) . '/../trailer_2.flv'); /* * Constant header */ $header = new Yamdi_FlvFileHeader(); $header->read($stream); $this->assertEqual(true, $header->isValid()); /* * Constant size of zero tag */ $zeroTagSize = new Yamdi_FlvTagSize(); $zeroTagSize->read($stream); $this->assertEqual(0, $zeroTagSize->size); // allways 0 /* * First tag (should be meta) */ $tag = new Yamdi_FlvTag(); $tag->read($stream); $this->assertTrue($tag->isMeta()); $metadata = new Yamdi_FlvMetadataBody(); $tagBody = $tag->readTagBody($stream); $metadata->read($tagBody); $this->assertEqual(strlen($tagBody), strlen($metadata->write())); /* * Cleanup */ $stream->close(); }