getid3_ogg::ParseOggPageHeader() –

You appear to be a bot. Output may be restricted

Description

Usage

$array|false = getid3_ogg::ParseOggPageHeader();

Parameters

Returns

array|false

Source

File name: wordpress/wp-includes/ID3/module.audio.ogg.php


Lines:

1 to 52 of 52
  public function ParseOggPageHeader() {
    // http://xiph.org/ogg/vorbis/doc/framing.html
    $oggheader = array();
    $oggheader['page_start_offset'] = $this->ftell(); // where we started from in the file

    $filedata = $this->fread($this->getid3->fread_buffer_size());
    $filedataoffset = 0;
    while ((substr($filedata, $filedataoffset++, 4) != 'OggS')) {
      if (($this->ftell() - $oggheader['page_start_offset']) >= $this->getid3->fread_buffer_size()) {
        // should be found before here
        return false;
      }
      if ((($filedataoffset + 28) > strlen($filedata)) || (strlen($filedata) < 28)) {
        if ($this->feof() || (($filedata .= $this->fread($this->getid3->fread_buffer_size())) === '')) {
          // get some more data, unless eof, in which case fail
          return false;
        }
      }
    }
    $filedataoffset += strlen('OggS') - 1; // page, delimited by 'OggS'

    $oggheader['stream_structver']  = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
    $filedataoffset += 1;
    $oggheader['flags_raw']         = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
    $filedataoffset += 1;
    $oggheader['flags']['fresh']    = (bool) ($oggheader['flags_raw'] & 0x01); // fresh packet
    $oggheader['flags']['bos']      = (bool) ($oggheader['flags_raw'] & 0x02); // first page of logical bitstream (bos)
    $oggheader['flags']['eos']      = (bool) ($oggheader['flags_raw'] & 0x04); // last page of logical bitstream (eos)

    $oggheader['pcm_abs_position']  = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 8));
    $filedataoffset += 8;
    $oggheader['stream_serialno']   = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
    $filedataoffset += 4;
    $oggheader['page_seqno']        = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
    $filedataoffset += 4;
    $oggheader['page_checksum']     = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 4));
    $filedataoffset += 4;
    $oggheader['page_segments']     = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
    $filedataoffset += 1;
    $oggheader['page_length'] = 0;
    for ($i = 0; $i < $oggheader['page_segments']; $i++) {
      $oggheader['segment_table'][$i] = getid3_lib::LittleEndian2Int(substr($filedata, $filedataoffset, 1));
      $filedataoffset += 1;
      $oggheader['page_length'] += $oggheader['segment_table'][$i];
    }
    $oggheader['header_end_offset'] = $oggheader['page_start_offset'] + $filedataoffset;
    $oggheader['page_end_offset']   = $oggheader['header_end_offset'] + $oggheader['page_length'];
    $this->fseek($oggheader['header_end_offset']);

    return $oggheader;
  }
 

 View on GitHub View on Trac