Add support for basic RIFF format

git-svn-id: http://php-reader.googlecode.com/svn/trunk@256 51a70ab9-7547-0410-9469-37e369ee0574
This commit is contained in:
svollbehr
2012-01-26 05:29:00 +00:00
parent 7ad54f1699
commit 4135abea31
33 changed files with 1412 additions and 0 deletions

75
src/Zend/Media/Riff.php Normal file
View File

@@ -0,0 +1,75 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/ContainerChunk.php';
/**#@-*/
/**
* This class represents a file in Resource Interchange File Format as described in Multimedia Programming Interface
* and Data Specifications 1.0 by Microsoft Corporation (April 15, 1994; Revision: 3.0).
*
* The Resource Interchange File Format (RIFF), a tagged file structure, is a general specification upon which many file
* formats can be defined. The main advantage of RIFF is its extensibility; file formats based on RIFF can be
* future-proofed, as format changes can be ignored by existing applications. The RIFF file format is suitable for the
* following multimedia tasks:
* o Playing back multimedia data
* o Recording multimedia data
* o Exchanging multimedia data between applications and across platforms
*
* The structure of a RIFF file is similar to the structure of an Electronic Arts IFF file. RIFF is not actually a file
* format itself (since it does not represent a specific kind of information), but its name contains the words
* interchange file format in recognition of its roots in IFF. Refer to the EA IFF definition document, EA IFF 85
* Standard for Interchange Format Files, for a list of reasons to use a tagged file format. The following is current
* (as per revision 3.0 of the specification) list of registered RIFF types.
* o PAL -- RIFF Palette Format
* o RDIB -- RIFF Device Independent Bitmap Format
* o RMID -- RIFF MIDI Format
* o RMMP -- RIFF Multimedia Movie File Format
* o WAVE -- Waveform Audio Format
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff extends Zend_Media_Riff_ContainerChunk
{
/** @var string */
private $_filename = null;
/**
* Constructs the class with given file.
*
* @param string|resource|Zend_Io_Reader $filename The path to the file, file descriptor of an opened file, or a
* {@link Zend_Io_Reader} instance.
* @throws Zend_Media_Riff_Exception if given file descriptor is not valid or an error occurs in stream handling.
*/
public function __construct($filename)
{
if ($filename instanceof Zend_Io_Reader) {
$reader = &$filename;
} else {
$this->_filename = $filename;
require_once('Zend/Io/FileReader.php');
try {
$reader = new Zend_Io_FileReader($filename);
} catch (Zend_Io_Exception $e) {
require_once 'Zend/Media/Riff/Exception.php';
throw new Zend_Media_Riff_Exception($e->getMessage());
}
}
parent::__construct($reader);
}
}

View File

@@ -0,0 +1,125 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**
* This class represents the basic building block of a RIFF file, called a chunk.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Box.php 177 2010-03-09 13:13:34Z svollbehr $
*/
abstract class Zend_Media_Riff_Chunk
{
/**
* The reader object.
*
* @var Reader
*/
protected $_reader;
/** @var integer */
protected $_identifier;
/** @var integer */
protected $_size;
/**
* Constructs the class with given parameters and options.
*
* @param Zend_Io_Reader $reader The reader object.
*/
public function __construct($reader)
{
$this->_reader = $reader;
$this->_identifier = $this->_reader->read(4);
$this->_size = $this->_reader->readUInt32LE();
}
/**
* Returns a four-character code that identifies the representation of the chunk data. A program reading a RIFF file
* can skip over any chunk whose chunk ID it doesn't recognize; it simply skips the number of bytes specified by
* size plus the pad byte, if present.
*
* @return string
*/
public final function getIdentifier()
{
return $this->_identifier;
}
/**
* Sets the four-character code that identifies the representation of the chunk data.
*
* @param string $identifier The chunk identifier.
*/
public final function setIdentifier($identifier)
{
$this->_identifier = $identifier;
}
/**
* Returns the size of chunk data. This size value does not include the size of the identifier or size fields or the
* pad byte at the end of chunk data.
*
* @return integer
*/
public final function getSize()
{
return $this->_size;
}
/**
* Sets the size of chunk data. This size value must not include the size of the identifier or size fields or the
* pad byte at the end of chunk data.
*
* @param integer $size The size of chunk data.
*/
public final function setSize($size)
{
$this->_size = $size;
}
/**
* Magic function so that $obj->value will work.
*
* @param string $name The field name.
* @return mixed
*/
public function __get($name)
{
if (method_exists($this, 'get' . ucfirst(strtolower($name)))) {
return call_user_func(array($this, 'get' . ucfirst(strtolower($name))));
} else {
require_once('Zend/Media/Riff/Exception.php');
throw new Zend_Media_Riff_Exception('Unknown field: ' . $name);
}
}
/**
* Magic function so that assignments with $obj->value will work.
*
* @param string $name The field name.
* @param string $value The field value.
* @return mixed
*/
public function __set($name, $value)
{
if (method_exists($this, 'set' . ucfirst(strtolower($name)))) {
call_user_func(array($this, 'set' . ucfirst(strtolower($name))), $value);
} else {
require_once('Zend/Media/Riff/Exception.php');
throw new Zend_Media_Riff_Exception('Unknown field: ' . $name);
}
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/Chunk.php';
/**#@-*/
/**
* The <i>Compound File Element Group</i> chunk stores the actual elements of data referenced by the
* {@link Zend_Media_Riff_Chunk_Ctoc CTOC} chunk. The CGRP chunk contains all the compound file elements, concatenated
* together into one contiguous block of data. Some of the elements in the CGRP chunk might be unused, if the element
* was marked for deletion or was altered and stored elsewhere within the CGRP chunk.
*
* Elements within the CGRP chunk are of arbitrary size and can appear in a specific or arbitrary order, depending upon
* the file format definition. Each element is identified by a corresponding {@link Zend_Media_Riff_Chunk_Ctoc CTOC}
* table entry.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
* @todo Implementation
*/
final class Zend_Media_Riff_Chunk_Cgrp extends Zend_Media_Riff_Chunk
{
/**
* Constructs the class with given parameters and options.
*
* @param Zend_Io_Reader $reader The reader object.
*/
public function __construct($reader)
{
parent::__construct($reader);
require_once('Zend/Media/Riff/Exception.php');
throw new Zend_Media_Riff_Exception('Not yet implemented');
}
}

View File

@@ -0,0 +1,172 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/Chunk.php';
/**#@-*/
/**
* The <i>Character Set</i> chunk defines the code page and country, language, and dialect codes for the file. These
* values can be overridden for specific file elements.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Cset extends Zend_Media_Riff_Chunk
{
/** @var integer */
private $_codePage;
/** @var integer */
private $_countryCode;
/** @var integer */
private $_language;
/** @var integer */
private $_dialect;
/**
* Constructs the class with given parameters and options.
*
* @param Zend_Io_Reader $reader The reader object.
*/
public function __construct($reader)
{
parent::__construct($reader);
$this->_codePage = $this->_reader->readUInt16LE();
$this->_countryCode = $this->_reader->readUInt16LE();
$this->_language = $this->_reader->readUInt16LE();
$this->_dialect = $this->_reader->readUInt16LE();
}
/**
* Returns the code page used for file elements. If the CSET chunk is not present, or if this field has value zero,
* assume standard ISO-8859-1 code page (identical to code page 1004 without code points defined in hex columns 0,
* 1, 8, and 9).
*
* @return integer
*/
public final function getCodePage()
{
return $this->_codePage;
}
/**
* Sets the code page used for file elements. Value can be one of the following.
* o 000 None (ignore this field)
* o 001 USA
* o 002 Canada
* o 003 Latin America
* o 030 Greece
* o 031 Netherlands
* o 032 Belgium
* o 033 France
* o 034 Spain
* o 039 Italy
* o 041 Switzerland
* o 043 Austria
* o 044 United Kingdom
* o 045 Denmark
* o 046 Sweden
* o 047 Norway
* o 049 West Germany
* o 052 Mexico
* o 055 Brazil
* o 061 Australia
* o 064 New Zealand
* o 081 Japan
* o 082 Korea
* o 086 Peoples Republic of China
* o 088 Taiwan
* o 090 Turkey
* o 351 Portugal
* o 352 Luxembourg
* o 354 Iceland
* o 358 Finland
*
* @param string $type The code page used for file elements.
*/
public final function setCodePage($codePage)
{
$this->_codePage = $codePage;
}
/**
* Returns the country code used for file elements. See the file format specification for a list of currently
* defined country codes. If the CSET chunk is not present, or if this field has value zero, assume USA (country
* code 001).
*
* @return integer
*/
public final function getCountryCode()
{
return $this->_countryCode;
}
/**
* Sets the country code used for file elements.
*
* @param string $type The country code used for file elements.
*/
public final function setCountryCode($countryCode)
{
$this->_countryCode = $countryCode;
}
/**
* Returns the language used for file elements. See the file format specification for a list of language codes.
* If the CSET chunk is not present, or if these fields have value zero, assume US English (language code 9,
* dialect code 1).
*
* @return integer
*/
public final function getLanguage()
{
return $this->_language;
}
/**
* Sets the language used for file elements.
*
* @param string $type The language used for file elements.
*/
public final function setLanguage($language)
{
$this->_language = $language;
}
/**
* Returns the dialect used for file elements. See the file format specification for a list of dialect codes.
* If the CSET chunk is not present, or if these fields have value zero, assume US English (language code 9,
* dialect code 1).
*
* @return integer
*/
public final function getDialect()
{
return $this->_dialect;
}
/**
* Sets the dialect used for file elements.
*
* @param string $type The dialect used for file elements.
*/
public final function setDialect($dialect)
{
$this->_dialect = $dialect;
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/Chunk.php';
/**#@-*/
/**
* The <i>Compound File Table of Contents</i> chunk functions mainly as an index, allowing direct access to elements
* within a compound file. The CTOC chunk also contains information about the attributes of the entire file and of each
* media element within the file.
*
* To provide the maximum flexibility for defining compound file formats, the CTOC chunk can be customized at several
* levels. The CTOC chunk contains fields whose length and usage is defined by other CTOC fields. This parameterization
* adds complexity, but it provides flexibility to file format designers and allows applications to correctly read data
* without necessarily knowing the specific file format definition.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
* @todo Implementation
*/
final class Zend_Media_Riff_Chunk_Ctoc extends Zend_Media_Riff_Chunk
{
/**
* Constructs the class with given parameters and options.
*
* @param Zend_Io_Reader $reader The reader object.
*/
public function __construct($reader)
{
parent::__construct($reader);
require_once('Zend/Media/Riff/Exception.php');
throw new Zend_Media_Riff_Exception('Not yet implemented');
}
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/StringChunk.php';
/**#@-*/
/**
* The <i>Archival Location</i> chunk indicates where the subject of the file is archived.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Iarl extends Zend_Media_Riff_StringChunk
{
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/StringChunk.php';
/**#@-*/
/**
* The <i>Artist</i> chunk lists the artist of the original subject of the file.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Iart extends Zend_Media_Riff_StringChunk
{
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/StringChunk.php';
/**#@-*/
/**
* The <i>Commissioned</i> chunk lists the name of the person or organization that commissioned the subject of the file.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Icms extends Zend_Media_Riff_StringChunk
{
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/StringChunk.php';
/**#@-*/
/**
* The <i>Comments</i> chunk provides general comments about the file or the subject of the file. If the comment is
* several sentences long, end each sentence with a period. Do not include newline characters.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Icmt extends Zend_Media_Riff_StringChunk
{
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/StringChunk.php';
/**#@-*/
/**
* The <i>Copyright</i> chunk records the copyright information for the file. If there are multiple copyrights, separate
* them by a semicolon followed by a space.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Icop extends Zend_Media_Riff_StringChunk
{
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/StringChunk.php';
/**#@-*/
/**
* The <i>Creation date</i> chunk specifies the date the subject of the file was created. List dates in year-month-day
* format, padding one-digit months and days with a zero on the left.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Icrd extends Zend_Media_Riff_StringChunk
{
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/StringChunk.php';
/**#@-*/
/**
* The <i>Cropped</i> chunk describes whether an image has been cropped and, if so, how it was cropped.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Icrp extends Zend_Media_Riff_StringChunk
{
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/StringChunk.php';
/**#@-*/
/**
* The <i>Dimensions</i> chunk specifies the size of the original subject of the file.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Idim extends Zend_Media_Riff_StringChunk
{
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/StringChunk.php';
/**#@-*/
/**
* The <i>Dots Per Inch</i> chunk stores dots per inch setting of the digitizer used to produce the file.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Idpi extends Zend_Media_Riff_StringChunk
{
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/StringChunk.php';
/**#@-*/
/**
* The <i>Engineer</i> stores the name of the engineer who worked on the file. If there are multiple engineers, separate
* the names by a semicolon and a blank.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Ieng extends Zend_Media_Riff_StringChunk
{
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/StringChunk.php';
/**#@-*/
/**
* The <i>Genre</i> chunk describes the original work, such as, landscape, portrait, still life, etc.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Ignr extends Zend_Media_Riff_StringChunk
{
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/StringChunk.php';
/**#@-*/
/**
* The <i>Keywords</i> provides a list of keywords that refer to the file or subject of the file. Separate multiple
* keywords with a semicolon and a blank.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Ikey extends Zend_Media_Riff_StringChunk
{
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/StringChunk.php';
/**#@-*/
/**
* The <i>Lightness</i> chunk describes the changes in lightness settings on the digitizer required to produce the file.
* Note that the format of this information depends on hardware used.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Ilgt extends Zend_Media_Riff_StringChunk
{
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/StringChunk.php';
/**#@-*/
/**
* The <i>Medium</i> describes the original subject of the file.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Imed extends Zend_Media_Riff_StringChunk
{
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/StringChunk.php';
/**#@-*/
/**
* The <i>Name</i> chunk stores the title of the subject of the file.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Inam extends Zend_Media_Riff_StringChunk
{
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/StringChunk.php';
/**#@-*/
/**
* The <i>Palette Setting</i> specifies the number of colors requested when digitizing an image.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Iplt extends Zend_Media_Riff_StringChunk
{
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/StringChunk.php';
/**#@-*/
/**
* The <i>Product</i> chunk specifies the name of the title the file was originally intended for.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Iprd extends Zend_Media_Riff_StringChunk
{
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/StringChunk.php';
/**#@-*/
/**
* The <i>Subject</i> describes the conbittents of the file.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Isbj extends Zend_Media_Riff_StringChunk
{
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/StringChunk.php';
/**#@-*/
/**
* The <i>Software</i> identifies the name of the software package used to create the file.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Isft extends Zend_Media_Riff_StringChunk
{
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/StringChunk.php';
/**#@-*/
/**
* The <i>Sharpness</i> chunk identifies the changes in sharpness for the digitizer required to produce the file (the
* format depends on the hardware used).
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Ishp extends Zend_Media_Riff_StringChunk
{
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/StringChunk.php';
/**#@-*/
/**
* The <i>Source</i> chunk identifies the name of the person or organization who supplied the original subject of the file.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Isrc extends Zend_Media_Riff_StringChunk
{
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/StringChunk.php';
/**#@-*/
/**
* The <i>Source Form</i> chunk identifies the original form of the material that was digitized, such as slide, paper, map,
* and so forth. This is not necessarily the same as {@link Zend_Media_Riff_Chunk_Imed IMED}.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Isrf extends Zend_Media_Riff_StringChunk
{
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/StringChunk.php';
/**#@-*/
/**
* The <i>Technician</i> chunk identifies the technician who digitized the subject file.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Itch extends Zend_Media_Riff_StringChunk
{
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/StringChunk.php';
/**#@-*/
/**
* The <i>Filler</i> chunk represents padding, filler or outdated information. It contains no relevant data; it is a
* space filler of arbitrary size.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_Junk extends Zend_Media_Riff_Chunk
{
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/ContainerChunk.php';
/**#@-*/
/**
* The <i>LIST</i> chunk contains a list, or ordered sequence, of subchunks.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
final class Zend_Media_Riff_Chunk_List extends Zend_Media_Riff_ContainerChunk
{
}

View File

@@ -0,0 +1,142 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/Chunk.php';
/**#@-*/
/**
* This class represents a container chunk, ie a chunk that contains multiple other chunks.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Box.php 177 2010-03-09 13:13:34Z svollbehr $
*/
abstract class Zend_Media_Riff_ContainerChunk extends Zend_Media_Riff_Chunk
{
/** @var string */
protected $_type;
/** @var Array */
private $_chunks = array();
/**
* Constructs the class with given parameters and options.
*
* @param Zend_Io_Reader $reader The reader object.
*/
public function __construct($reader)
{
parent::__construct($reader);
$startOffset = $this->_reader->getOffset();
$this->_type = $this->_reader->read(4);
while (($this->_reader->getOffset() - $startOffset) < $this->_size) {
$offset = $this->_reader->getOffset();
$identifier = $this->_reader->read(4);
$size = $this->_reader->readUInt32LE();
$this->_reader->setOffset($offset);
if (@fopen
($file = 'Zend/Media/Riff/Chunk/' .
ucfirst(strtolower(rtrim($identifier, ' '))) . '.php', 'r', true) !== false) {
require_once($file);
}
if (class_exists($classname = 'Zend_Media_Riff_Chunk_' . ucfirst(strtolower(rtrim($identifier, ' '))))) {
$this->_chunks[] = new $classname($this->_reader);
$this->_reader->setOffset($offset + 8 + $size);
} else {
trigger_error('Unknown RIFF chunk: \'' . $identifier . '\' skipped', E_USER_WARNING);
$this->_reader->skip(8 + $size);
}
}
}
/**
* Returns a four-character code that identifies the contents of the container chunk.
*
* @return string
*/
public final function getType()
{
return $this->_type;
}
/**
* Sets the four-character code that identifies the contents of the container chunk.
*
* @param string $type The chunk container type.
*/
public final function setType($type)
{
$this->_type = $type;
}
/**
* Returns all the chunks this chunk contains as an array.
*
* @return Array
*/
public final function getChunks()
{
return $this->_chunks;
}
/**
* Returns an array of chunks matching the given identifier or an empty array if no chunks matched the identifier.
*
* The identifier may contain wildcard characters '*' and '?'. The asterisk matches against zero or more characters,
* and the question mark matches any single character.
*
* Please note that one may also use the shorthand $obj->identifier to access the first chunk with the identifier
* given. Wildcards cannot be used with the shorthand.
*
* @param string $identifier The chunk identifier.
* @return Array
*/
public final function getChunksByIdentifier($identifier)
{
$matches = array();
$searchPattern = "/^" . str_replace(array("*", "?"), array(".*", "."), $identifier) . "$/i";
foreach ($this->_chunks as $chunk) {
if (preg_match($searchPattern, rtrim($chunk->getIdentifier(), ' '))) {
$matches[] = $chunk;
}
}
return $matches;
}
/**
* Magic function so that $obj->value will work. The method will first attempt to return the first contained chunk
* whose identifier matches the given name, and if not found, invoke a getter method.
*
* If there are no chunks or getter methods with the given name, an exception is thrown.
*
* @param string $name The chunk or field name.
* @return mixed
*/
public function __get($name)
{
$chunks = $this->getChunksByIdentifier($name);
if (count($chunks) > 0) {
return $chunks[0];
}
if (method_exists($this, 'get' . ucfirst($name))) {
return call_user_func(array($this, 'get' . ucfirst($name)));
}
require_once 'Zend/Media/Riff/Exception.php';
throw new Zend_Media_Riff_Exception('Unknown chunk/field: ' . $name);
}
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Exception.php';
/**#@-*/
/**
* The Zend_Media_Riff_Exception is thrown whenever an error occurs within the {@link Zend_Media_Riff} class or a
* related class.
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
class Zend_Media_Riff_Exception extends Zend_Media_Exception
{}

View File

@@ -0,0 +1,67 @@
<?php
/**
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/
/**#@+ @ignore */
require_once 'Zend/Media/Riff/Chunk.php';
/**#@-*/
/**
* This class represents a chunk that contains a text string.
*
* {{@internal The contained text string is a NULL-terminated string (ZSTR) that consists of a series of characters
* followed by a terminating NULL character. The ZSTR is better than a simple character sequence (STR) because many
* programs are easier to write if strings are NULL-terminated. ZSTR is preferred to a string with a size prefix (BSTR
* or WSTR) because the size of the string is already available as the chunk size value, minus one for the terminating
* NULL character.}}
*
* @category Zend
* @package Zend_Media
* @subpackage Riff
* @author Sven Vollbehr <sven@vollbehr.eu>
* @copyright Copyright (c) 2011 Sven Vollbehr
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Box.php 177 2010-03-09 13:13:34Z svollbehr $
*/
abstract class Zend_Media_Riff_StringChunk extends Zend_Media_Riff_Chunk
{
/** @var string */
protected $_value;
/**
* Constructs the class with given parameters and options.
*
* @param Zend_Io_Reader $reader The reader object.
*/
public function __construct($reader)
{
parent::__construct($reader);
$this->_value = rtrim($this->_reader->read($this->_size), "\0");
}
/**
* Returns the text string value.
*
* @return string
*/
public final function getValue()
{
return $this->_value;
}
/**
* Sets the text string value.
*
* @param string $type The text string value.
*/
public final function setValue($value)
{
$this->_value = $value;
}
}