PageRenderTime 51ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/app/vendors/adapters/ffmpeg-php/php-reader/src/ID3/Frame/LINK.php

https://github.com/mariuz/firetube
PHP | 172 lines | 33 code | 14 blank | 125 comment | 1 complexity | 97943eed8c03a02147e7735f3baff46a MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /**
  3. * PHP Reader Library
  4. *
  5. * Copyright (c) 2008 The PHP Reader Project Workgroup. All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. *
  10. * - Redistributions of source code must retain the above copyright notice,
  11. * this list of conditions and the following disclaimer.
  12. * - Redistributions in binary form must reproduce the above copyright notice,
  13. * this list of conditions and the following disclaimer in the documentation
  14. * and/or other materials provided with the distribution.
  15. * - Neither the name of the project workgroup nor the names of its
  16. * contributors may be used to endorse or promote products derived from this
  17. * software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  20. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  23. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  24. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  25. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  26. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  27. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  28. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  29. * POSSIBILITY OF SUCH DAMAGE.
  30. *
  31. * @package php-reader
  32. * @subpackage ID3
  33. * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
  34. * @license http://code.google.com/p/php-reader/wiki/License New BSD License
  35. * @version $Id: LINK.php 75 2008-04-14 23:57:21Z svollbehr $
  36. */
  37. /**#@+ @ignore */
  38. require_once("ID3/Frame.php");
  39. /**#@-*/
  40. /**
  41. * The <i>Linked information</i> frame is used to keep information duplication
  42. * as low as possible by linking information from another ID3v2 tag that might
  43. * reside in another audio file or alone in a binary file. It is recommended
  44. * that this method is only used when the files are stored on a CD-ROM or other
  45. * circumstances when the risk of file separation is low.
  46. *
  47. * Data should be retrieved from the first tag found in the file to which this
  48. * link points. There may be more than one LINK frame in a tag, but only one
  49. * with the same contents.
  50. *
  51. * A linked frame is to be considered as part of the tag and has the same
  52. * restrictions as if it was a physical part of the tag (i.e. only one
  53. * {@link ID3_Frame_RVRB} frame allowed, whether it's linked or not).
  54. *
  55. * Frames that may be linked and need no additional data are
  56. * {@link ID3_Frame_ASPI}, {@link ID3_Frame_ETCO}, {@link ID3_Frame_EQU2},
  57. * {@link ID3_Frame_MCDI}, {@link ID3_Frame_MLLT}, {@link ID3_Frame_OWNE},
  58. * {@link ID3_Frame_RVA2}, {@link ID3_Frame_RVRB}, {@link ID3_Frame_SYTC}, the
  59. * text information frames (ie frames descendats of
  60. * {@link ID3_Frame_AbstractText}) and the URL link frames (ie frames descendants
  61. * of {@link ID3_Frame_AbstractLink}).
  62. *
  63. * The {@link ID3_Frame_AENC}, {@link ID3_Frame_APIC}, {@link ID3_Frame_GEOB}
  64. * and {@link ID3_Frame_TXXX} frames may be linked with the content descriptor
  65. * as additional ID data.
  66. *
  67. * The {@link ID3_Frame_USER} frame may be linked with the language field as
  68. * additional ID data.
  69. *
  70. * The {@link ID3_Frame_PRIV} frame may be linked with the owner identifier as
  71. * additional ID data.
  72. *
  73. * The {@link ID3_Frame_COMM}, {@link ID3_Frame_SYLT} and {@link ID3_Frame_USLT}
  74. * frames may be linked with three bytes of language descriptor directly
  75. * followed by a content descriptor as additional ID data.
  76. *
  77. * @package php-reader
  78. * @subpackage ID3
  79. * @author Sven Vollbehr <svollbehr@gmail.com>
  80. * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
  81. * @license http://code.google.com/p/php-reader/wiki/License New BSD License
  82. * @version $Rev: 75 $
  83. */
  84. final class ID3_Frame_LINK extends ID3_Frame
  85. {
  86. /** @var string */
  87. private $_target;
  88. /** @var string */
  89. private $_url;
  90. /** @var string */
  91. private $_qualifier;
  92. /**
  93. * Constructs the class with given parameters and parses object related data.
  94. *
  95. * @param Reader $reader The reader object.
  96. * @param Array $options The options array.
  97. */
  98. public function __construct($reader = null, &$options = array())
  99. {
  100. parent::__construct($reader, $options);
  101. if ($reader === null)
  102. return;
  103. $this->_target = substr($this->_data, 0, 4);
  104. list($this->_url, $this->_qualifier) =
  105. preg_split("/\\x00/", substr($this->_data, 4), 2);
  106. }
  107. /**
  108. * Returns the target tag identifier.
  109. *
  110. * @return string
  111. */
  112. public function getTarget() { return $this->_target; }
  113. /**
  114. * Sets the target tag identifier.
  115. *
  116. * @param string $target The target tag identifier.
  117. */
  118. public function setTarget($target) { $this->_target = $target; }
  119. /**
  120. * Returns the target tag URL.
  121. *
  122. * @return string
  123. */
  124. public function getUrl() { return $this->_url; }
  125. /**
  126. * Sets the target tag URL.
  127. *
  128. * @param string $url The target URL.
  129. */
  130. public function setUrl($url) { $this->_url = $url; }
  131. /**
  132. * Returns the additional data to identify further the tag.
  133. *
  134. * @return string
  135. */
  136. public function getQualifier() { return $this->_qualifier; }
  137. /**
  138. * Sets the additional data to be used in tag identification.
  139. *
  140. * @param string $identifier The qualifier.
  141. */
  142. public function setQualifier($qualifier)
  143. {
  144. $this->_qualifier = $qualifier;
  145. }
  146. /**
  147. * Returns the frame raw data.
  148. *
  149. * @return string
  150. */
  151. public function __toString()
  152. {
  153. $this->setData
  154. (Transform::toString8(substr($this->_target, 0, 4), 4) .
  155. $this->_url . "\0" . $this->_qualifier);
  156. return parent::__toString();
  157. }
  158. }