Avifinfo

Parser::parse_meta()privateWP 1.0

Parses a "meta" box.

It looks for the primary item ID in the "pitm" box and recurses into other boxes to find its features.

Метод класса: Parser{}

Хуков нет.

Возвращает

Status. FOUND on success or an error on failure.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->parse_meta( $num_remaining_bytes );
$num_remaining_bytes(int) (обязательный)
The number of bytes that should be available from the resource.

Код Parser::parse_meta() WP 6.6.2

private function parse_meta( $num_remaining_bytes ) {
  do {
    $box    = new Box();
    $status = $box->parse( $this->handle, $this->num_parsed_boxes, $num_remaining_bytes );
    if ( $status != FOUND ) {
      return $status;
    }

    if ( $box->type == 'pitm' ) {
      // See ISO/IEC 14496-12:2015(E) 8.11.4.2
      $num_bytes_per_id = ( $box->version == 0 ) ? 2 : 4;
      if ( $num_bytes_per_id > $num_remaining_bytes ) {
        return INVALID;
      }
      if ( !( $data = read( $this->handle, $num_bytes_per_id ) ) ) {
        return TRUNCATED;
      }
      $primary_item_id = read_big_endian( $data, $num_bytes_per_id );
      if ( $primary_item_id > MAX_VALUE ) {
        return ABORTED;
      }
      $this->features->has_primary_item = true;
      $this->features->primary_item_id  = $primary_item_id;
      if ( !skip( $this->handle, $box->content_size - $num_bytes_per_id ) ) {
        return TRUNCATED;
      }
    } else if ( $box->type == 'iprp' ) {
      $status = $this->parse_iprp( $box->content_size );
      if ( $status != NOT_FOUND ) {
        return $status;
      }
    } else if ( $box->type == 'iref' ) {
      $status = $this->parse_iref( $box->content_size );
      if ( $status != NOT_FOUND ) {
        return $status;
      }
    } else {
      if ( !skip( $this->handle, $box->content_size ) ) {
        return TRUNCATED;
      }
    }
    $num_remaining_bytes -= $box->size;
  } while ( $num_remaining_bytes != 0 );
  // According to ISO/IEC 14496-12:2012(E) 8.11.1.1 there is at most one "meta".
  return INVALID;
}