<?php
/**
* SeekQuarry/Yioop --
* Open Source Pure PHP Search Engine, Crawler, and Indexer
*
* Copyright (C) 2009 - 2026 Chris Pollett chris@pollett.org
*
* LICENSE:
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* END LICENSE
*
* @author Chris Pollett chris@pollett.org
* @license https://www.gnu.org/licenses/ GPL3
* @link https://www.seekquarry.com/
* @copyright 2009 - 2026
* @filesource
*/
namespace seekquarry\yioop\library\av_processing;
/**
* MediaPacket one whole piece of compressed sound, pulled back out of the file
* it was stored in. A sound file does not hold one long run of compressed
* sound. It holds many small pieces, each covering a fraction of a second, and
* it may cut a piece in half and store the halves in different places. What
* this class holds is one piece, put back together, along with where in the
* recording it belongs and which sound within the file it came from. A file can
* carry more than one sound at once, so pieces are kept apart by the stream
* number they arrived under.
*/
class MediaPacket
{
/**
* data stores the compressed sound itself, as it was stored.
* @var string
*/
public $data;
/**
* stream stores which sound within the file this piece belongs to. A file
* may carry several at once and this keeps them apart.
* @var int
*/
public $stream;
/**
* position stores where this piece belongs in the recording, counted in
* samples at forty-eight thousand samples a second, or -1 where the file
* did not say. Only
* some pieces carry a position; the rest follow on from the last one that
* did.
* @var int
*/
public $position;
/**
* number stores how many pieces of this sound came before this one,
* counting from zero.
* @var int
*/
public $number;
/**
* is_last stores whether this is the last piece of its sound in the file.
* @var bool
*/
public $is_last;
/**
* __construct builds a piece of sound from its content and where it belongs
* in samples at forty-eight thousand a second, or -1 where unstated
*
* @param string $data the compressed sound itself
* @param int $stream which sound within the file it belongs to
* @param int $position where it belongs in the recording, counted
* @param int $number how many pieces came before it
* @param bool $is_last whether it is the last piece of its sound
*/
public function __construct($data, $stream, $position, $number,
$is_last)
{
$this->data = $data;
$this->stream = $stream;
$this->position = $position;
$this->number = $number;
$this->is_last = $is_last;
}
}