Improved code and comments: add ID3v1 write support, add unit tests

git-svn-id: http://php-reader.googlecode.com/svn/trunk@39 51a70ab9-7547-0410-9469-37e369ee0574
This commit is contained in:
svollbehr
2008-03-26 17:27:22 +00:00
parent 3914cfdacc
commit 1182f0e0ff
107 changed files with 2107 additions and 963 deletions

View File

@@ -2,6 +2,8 @@
/**
* PHP Reader Library
*
* Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
@@ -10,7 +12,7 @@
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the BEHR Software Systems nor the names of its
* - Neither the name of the project workgroup nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
@@ -28,8 +30,8 @@
*
* @package php-reader
* @subpackage ID3
* @copyright Copyright (c) 2008 BEHR Software Systems
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
* @version $Id$
*/
@@ -44,9 +46,9 @@ require_once("Object.php");
*
* @package php-reader
* @subpackage ID3
* @author Sven Vollbehr <sven.vollbehr@behrss.eu>
* @copyright 2008 BEHR Software Systems
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Sven Vollbehr <svollbehr@gmail.com>
* @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
* @license http://code.google.com/p/php-reader/wiki/License New BSD License
* @version $Rev$
*/
class ID3_Frame extends ID3_Object
@@ -138,9 +140,9 @@ class ID3_Frame extends ID3_Object
{
parent::__construct($reader);
$this->_identifier = $this->_reader->getString8(4);
$this->_size = $this->decodeSynchsafe32($this->_reader->getUInt32BE());
$this->_flags = $this->_reader->getUInt16BE();
$this->_identifier = $this->_reader->readString8(4);
$this->_size = $this->decodeSynchsafe32($this->_reader->readUInt32BE());
$this->_flags = $this->_reader->readUInt16BE();
$this->_data = $this->_reader->read($this->_size);
}
@@ -150,7 +152,17 @@ class ID3_Frame extends ID3_Object
* @return string
*/
public function getIdentifier() { return $this->_identifier; }
/**
* Sets the frame identifier.
*
* @param string $identifier The identifier.
*/
public function setIdentifier($identifier)
{
$this->_identifier = $identifier;
}
/**
* Returns the size of the data in the final frame, after encryption,
* compression and unsynchronisation. The size is excluding the frame header.
@@ -158,7 +170,7 @@ class ID3_Frame extends ID3_Object
* @return integer
*/
public function getSize() { return $this->_size; }
/**
* Checks whether or not the flag is set. Returns <var>true</var> if the flag
* is set, <var>false</var> otherwise.
@@ -167,4 +179,24 @@ class ID3_Frame extends ID3_Object
* @return boolean
*/
public function hasFlag($flag) { return ($this->_flags & $flag) == $flag; }
/**
* Returns the frame flags byte.
*
* @return integer
*/
public function getFlags($flags)
{
return $this->_flags;
}
/**
* Sets the frame flags byte.
*
* @param string $flags The flags byte.
*/
public function setFlags($flags)
{
$this->_flags = $flags;
}
}