Exemple #1
0
 /**
  * @param string $filename
  * @return Yamdi_InputStream
  */
 protected function read($filename)
 {
     $this->sourceFilename = $filename;
     /*
      * File to read 
      */
     $stream = new Yamdi_InputStream($this->sourceFilename);
     /*
      * Constant header
      */
     $this->header->read($stream);
     if (!$this->header->isValid()) {
         throw new Exception('File ' . $this->sourceFilename . ' is not of flv format');
     }
     /*
      * Constant size of zero tag
      */
     $this->zeroTagSize->read($stream);
     // $this->zeroTagSize->size should be zero
     /*
      * First tag (meta)
      */
     $this->metadataTag->read($stream);
     if (!$this->metadataTag->isMeta()) {
         throw new Exception('No metadata tag found if file ' . $this->sourceFilename);
     }
     $tagBodyString = $this->metadataTag->readTagBody($stream);
     $this->metadataTagBodyLenghth = strlen($tagBodyString);
     $this->metadata->read($tagBodyString);
     /*
      * Previous tag size
      */
     $this->metadataTagSize->read($stream);
     $this->sourceMediaTagsStartPosition = $stream->getPosition();
     return $stream;
 }
 /**
  * @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();
 }