コード例 #1
0
ファイル: FlvFile.php プロジェクト: nakonechny/PhpYamdi
 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();
 }
コード例 #2
0
 public function testReadWrite()
 {
     /* byte-image of a valid flv header */
     $bytes = 'FLV' . chr(1) . chr(5) . chr(0) . chr(0) . chr(0) . chr(9);
     /* preparing mock streams */
     $inputStub = $this->getMock('Yamdi_InputStream', array(), array(''), '', false, false);
     $inputStub->expects($this->any())->method('read')->will($this->returnValue($bytes));
     $outputMock = $this->getMock('Yamdi_OutputStream', array(), array(''), '', false, false);
     $outputMock->expects($this->once())->method('write')->with($this->equalTo($bytes))->will($this->returnValue(strlen($bytes)));
     /* reading tag */
     $tag = new Yamdi_FlvFileHeader();
     $tag->read($inputStub);
     $this->assertEquals($tag->signature, 'FLV');
     $this->assertEquals($tag->version, 1);
     $this->assertEquals($tag->flags, 5);
     $this->assertEquals($tag->headersize, 9);
     /* writing tag */
     $tag->write($outputMock);
 }
コード例 #3
0
 public function testReadWrite()
 {
     /* byte image of a valid flv header */
     $bytes = 'FLV' . chr(1) . chr(5) . chr(0) . chr(0) . chr(0) . chr(9);
     /* preparing mock streams */
     $inputStream = new MockYamdi_InputStream();
     $inputStream->setReturnValue('read', $bytes);
     $outputStream = new MockYamdi_OutputStream();
     $outputStream->setReturnValue('write', strlen($bytes));
     $outputStream->expect('write', array($bytes));
     /* reading tag */
     $tag = new Yamdi_FlvFileHeader();
     $tag->read($inputStream);
     $this->assertEqual($tag->signature, 'FLV');
     $this->assertEqual($tag->version, 1);
     $this->assertEqual($tag->flags, 5);
     $this->assertEqual($tag->headersize, 9);
     /* writing tag */
     $tag->write($outputStream);
 }