File_Ogg
[ class tree: File_Ogg ] [ index: File_Ogg ] [ all elements ]

Source for file Bitstream.php

Documentation is available at Bitstream.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------------+
  4. // | File_Ogg PEAR Package for Accessing Ogg Bitstreams                         |
  5. // | Copyright (c) 2005-2007                                                    |
  6. // | David Grant <david@grant.org.uk>                                           |
  7. // | Tim Starling <tstarling@wikimedia.org>                                     |
  8. // +----------------------------------------------------------------------------+
  9. // | This library is free software; you can redistribute it and/or              |
  10. // | modify it under the terms of the GNU Lesser General Public                 |
  11. // | License as published by the Free Software Foundation; either               |
  12. // | version 2.1 of the License, or (at your option) any later version.         |
  13. // |                                                                            |
  14. // | This library is distributed in the hope that it will be useful,            |
  15. // | but WITHOUT ANY WARRANTY; without even the implied warranty of             |
  16. // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU          |
  17. // | Lesser General Public License for more details.                            |
  18. // |                                                                            |
  19. // | You should have received a copy of the GNU Lesser General Public           |
  20. // | License along with this library; if not, write to the Free Software        |
  21. // | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA |
  22. // +----------------------------------------------------------------------------+
  23.  
  24.  
  25. /**
  26.  * @author      David Grant <david@grant.org.uk>, Tim Starling <tstarling@wikimedia.org>
  27.  * @category    File
  28.  * @copyright   David Grant <david@grant.org.uk>, Tim Starling <tstarling@wikimedia.org>
  29.  * @license     http://www.gnu.org/copyleft/lesser.html GNU LGPL
  30.  * @link        http://pear.php.net/package/File_Ogg
  31.  * @package     File_Ogg
  32.  * @version     CVS: $Id: Bitstream.php,v 1.4 2008/01/31 04:41:44 tstarling Exp $
  33.  */
  34. {
  35.     /**
  36.      * The serial number of this logical stream.
  37.      *
  38.      * @var     int 
  39.      * @access  private
  40.      */
  41.     var $_streamSerial;
  42.     /**
  43.      * @access  private
  44.      */
  45.     var $_streamList;
  46.     /**
  47.      * @access  private
  48.      */
  49.     var $_filePointer;
  50.     /**
  51.      * The number of bits used in this stream.
  52.      *
  53.      * @var     int 
  54.      * @access  private
  55.      */
  56.     var $_streamSize;
  57.  
  58.     /**
  59.      * The last granule position in the stream
  60.      * @var     int 
  61.      * @access  private
  62.      */
  63.     var $_lastGranulePos;
  64.  
  65.     /**
  66.      * Constructor for a generic logical stream.
  67.      *
  68.      * @param   int     $streamSerial   Serial number of the logical stream.
  69.      * @param   array   $streamData     Data for the requested logical stream.
  70.      * @param   string  $filePath       Location of a file on the filesystem.
  71.      * @param   pointer $filePointer    File pointer for the current physical stream.
  72.      * @access  private
  73.      */
  74.     function File_Ogg_Bitstream($streamSerial$streamData$filePointer)
  75.     {
  76.         $this->_streamSerial    $streamSerial;
  77.         $this->_streamList      $streamData;
  78.         $this->_filePointer     $filePointer;
  79.         $this->_lastGranulePos  = 0;
  80.         // This gives an accuracy of approximately 99.7% to the streamsize of ogginfo.
  81.         foreach $streamData as $packet {
  82.             $this->_streamSize += $packet['data_length'];
  83.             # Reject -1 as a granule pos, that means no segment finished in the packet
  84.             if $packet['abs_granule_pos'!= 'ffffffffffffffff' {
  85.                 $this->_lastGranulePos max($this->_lastGranulePos$packet['abs_granule_pos']);
  86.             }
  87.         }
  88.         $this->_group $streamData[0]['group'];
  89.     }
  90.  
  91.     /**
  92.      * Gives the serial number of this stream.
  93.      *
  94.      * The stream serial number is of fairly academic importance, as it makes little
  95.      * difference to the end user.  The serial number is used by the Ogg physical
  96.      * stream to distinguish between concurrent logical streams.
  97.      *
  98.      * @return  int 
  99.      * @access  public
  100.      */
  101.     function getSerial()
  102.     {
  103.         return ($this->_streamSerial);
  104.     }
  105.     
  106.     /**
  107.      * Gives the size (in bits) of this stream.
  108.      *
  109.      * This function returns the size of the Vorbis stream within the Ogg
  110.      * physical stream.
  111.      *
  112.      * @return  int 
  113.      * @access  public
  114.      */
  115.     function getSize()
  116.     {
  117.         return ($this->_streamSize);
  118.     }
  119.  
  120.     /**
  121.      * Get the multiplexed group ID
  122.      */
  123.     function getGroup()
  124.     {
  125.         return $this->_group;
  126.     }
  127.  
  128. }
  129.  
  130. ?>

Documentation generated on Mon, 11 Mar 2019 15:15:21 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.