Example #1
0
 /**
  * Process the raw data from a binary stream
  * 
  * @return  void
  */
 public function processData(Woops_Flv_Binary_Stream $stream)
 {
     $this->_dataSize = $stream->u24Int();
     $this->_timestamp = $stream->u24Int();
     $this->_timestampExtended = $stream->unsignedChar();
     $this->_streamId = $stream->u24Int();
 }
Example #2
0
 /**
  * Process the raw data from a binary stream
  * 
  * @return  void
  */
 public function processData(Woops_Flv_Binary_Stream $stream)
 {
     // Gets the FLV signature
     $signature = $stream->unsignedChar() << 16 | $stream->unsignedChar() << 8 | $stream->unsignedChar();
     // Checks the FLV signature
     if ($signature !== self::SIGNATURE) {
         // Error - Invalid FLV signature
         throw new Woops_Flv_Header_Exception('Invalid FLV signature (' . $signature . ')', Woops_Flv_Header_Exception::EXCEPTION_BAD_SIGNATURE);
     }
     // Gets the FLV version
     $this->_version = $stream->unsignedChar();
     // Gets the flags
     $flags = $stream->unsignedChar();
     // Sets the audio and video flags
     $this->_hasAudio = (bool) ($flags & 0x4);
     $this->_hasVideo = (bool) ($flags & 0x1);
     // Gets the data offset
     $this->_dataOffset = $stream->bigEndianUnsignedLong();
 }
Example #3
0
 /**
  * Class constructor
  * 
  * @param   resource    The file handle for which to create a binary stream
  * @param   boolean     Whether to close the file handle or not
  * @return  void
  * @see     Woops_Flv_Binary_Stream::__construct
  */
 public function __construct($handle, $closeHandle = true)
 {
     // Checks if the file exists
     if (!is_resource($handle)) {
         // Error - The file does not exist
         throw new Woops_Flv_Binary_File_Resource_Stream_Exception('Passed argument must be a valid file handle', Woops_Flv_Binary_File_Resource_Stream_Exception::EXCEPTION_NO_RESOURCE);
     }
     // Storage
     $data = '';
     // Reads until the end of the file handle
     while (!feof($handle)) {
         // Reads from the file handle
         $data .= fread($handle, 8192);
     }
     // Checks if we must close the file handle
     if ($closeHandle) {
         // Closes the file handle
         fclose($handle);
     }
     // Calls the parent constructor
     parent::__construct($data);
 }