PageRenderTime 49ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/phpvideotoolkit/adapters/ffmpeg-php/php-reader/tests/TestID3Frame.php

http://phpvideotoolkit.googlecode.com/
PHP | 1218 lines | 682 code | 86 blank | 450 comment | 77 complexity | cc10bc10dc603597bcba8ad37dfc2692 MD5 | raw file
Possible License(s): GPL-2.0
  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 Tests
  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: TestID3Frame.php 111 2008-09-05 17:20:56Z svollbehr $
  36. */
  37. /**#@+ @ignore */
  38. require_once("PHPUnit/Framework.php");
  39. require_once("Reader.php");
  40. /**#@-*/
  41. /**
  42. * Unit test case for all ID3 frames.
  43. *
  44. * @package php-reader
  45. * @subpackage Tests
  46. * @author Ryan Butterfield <buttza@gmail.com>
  47. * @copyright Copyright (c) 2008 The PHP Reader Project Workgroup
  48. * @license http://code.google.com/p/php-reader/wiki/License New BSD License
  49. * @version $Rev: 111 $
  50. */
  51. final class TestID3Frame extends PHPUnit_Framework_TestCase
  52. {
  53. private $testText = "abcdefghijklmnopqrstuvwxyz1234567890!@#\$%^&*()-";
  54. private $testLink = "http://www.abcdefghijklmnopqrstuvwxyz.com.xyz/qwerty.php?asdf=1234&zxcv=%20";
  55. private $testDate = "20070707";
  56. private $testCurrency = "AUD";
  57. private $testIdentifier = "TEST";
  58. private $testPrice = "169.12";
  59. private $testInt8 = -0x7a;
  60. private $testInt16 = -0x7aff;
  61. private $testInt24 = 0x7affca;
  62. private $testInt32 = -0x7affcafe;
  63. private $testUInt8 = 0xfa;
  64. private $testUInt16 = 0xfaff;
  65. private $testUInt32 = 0xfaffcafe;
  66. /**
  67. * Data provider for the ID3 frame test case. Finds all frames and builds
  68. * input combinations necessary to test all variations of each frame.
  69. */
  70. public static function provider()
  71. {
  72. /* Ignore WIP frames */
  73. $ignore = array("ASPI.php", "MLLT.php");
  74. /* Load all frames */
  75. $dir = opendir("../src/ID3/Frame");
  76. while (($file = readdir($dir)) !== false)
  77. if (preg_match("/^.+\.php$/", $file) && !in_array($file, $ignore))
  78. require_once("ID3/Frame/" . $file);
  79. foreach (get_declared_classes() as $class)
  80. if (strpos($class, "ID3_Frame_") === 0)
  81. $identifiers[] = substr($class, 10);
  82. closedir($dir);
  83. /* Build up all valid combinations */
  84. $tests = array();
  85. foreach ($identifiers as $identifier)
  86. {
  87. if (!method_exists("TestID3Frame", "frame" . $identifier . "0"))
  88. continue; // skip if no handlers registered
  89. $class = "ID3_Frame_" . $identifier;
  90. $encodings = $languages = $timings = array(null);
  91. if (in_array("ID3_Encoding", class_implements($class)))
  92. array_push($encodings, ID3_Encoding::ISO88591, ID3_Encoding::UTF16,
  93. ID3_Encoding::UTF16BE, ID3_Encoding::UTF8);
  94. if (in_array("ID3_Language", class_implements($class)))
  95. array_push($languages, "eng", "und");
  96. if (in_array("ID3_Timing", class_implements($class)))
  97. array_push($timings, ID3_Timing::MPEG_FRAMES, ID3_Timing::MILLISECONDS);
  98. foreach ($encodings as $encoding)
  99. foreach ($languages as $language)
  100. foreach ($timings as $timing)
  101. $tests[] = array($identifier, $encoding, $language, $timing);
  102. }
  103. return $tests;
  104. }
  105. /**
  106. * Test a given frame by identifier, its text encoding (if provided),
  107. * its language (if provided) and its timing (also if provided).
  108. *
  109. * The test involves finding frame functions that will test the given frame
  110. * identifier, constructing and setting up the frame, testing the constructed
  111. * frame, saving the frame to a string then re-creating the frame using the
  112. * string and testing for a final time.
  113. *
  114. * @param string $identifier The frame identifier.
  115. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  116. * in this frame.
  117. * @param string $language The language code.
  118. * @param integer $timing The timing format.
  119. *
  120. * @dataProvider provider
  121. */
  122. public function testFrame($identifier, $encoding, $language, $timing)
  123. {
  124. /* Iterate through all test case functions for this frame identifier */
  125. $class = "ID3_Frame_" . $identifier;
  126. $test = 0;
  127. while (method_exists($this, $method = "frame" . $identifier . $test++)) {
  128. /* Setup and verify the frame */
  129. $frame = new $class();
  130. call_user_func(array($this, $method),
  131. $frame, true, $encoding, $language, $timing);
  132. call_user_func(array($this, $method),
  133. $frame, false, $encoding, $language, $timing);
  134. if (isset($encoding)) {
  135. $this->assertTrue(method_exists($frame, "setEncoding"));
  136. $frame->setEncoding($encoding);
  137. $this->assertTrue(method_exists($frame, "getEncoding"));
  138. $this->assertEquals($encoding, $frame->getEncoding());
  139. }
  140. if (isset($language)) {
  141. $this->assertTrue(method_exists($frame, "setLanguage"));
  142. $frame->setLanguage($language);
  143. $this->assertTrue(method_exists($frame, "getLanguage"));
  144. $this->assertEquals($language, $frame->getLanguage());
  145. }
  146. if (isset($timing)) {
  147. $this->assertTrue(method_exists($frame, "setFormat"));
  148. $frame->setFormat($timing);
  149. $this->assertTrue(method_exists($frame, "getFormat"));
  150. $this->assertEquals($timing, $frame->getFormat());
  151. }
  152. for ($i = 0; $i < 2; $i++) {
  153. /* Convert to string representation and store in an in-memory buffer */
  154. if ($i > 0)
  155. $existing = $data;
  156. $length = strlen($data = "" . $frame);
  157. if ($i > 0)
  158. $this->assertEquals($existing, $data);
  159. $this->assertTrue(($fd = fopen("php://temp", "r+b")) !== false);
  160. $this->assertEquals($length, fwrite($fd, $data, $length));
  161. $this->assertTrue(rewind($fd));
  162. /* Construct a frame using the reader and verify */
  163. $frame = new $class($reader = new Reader($fd));
  164. call_user_func(array($this, $method),
  165. $frame, false, $encoding, $language, $timing);
  166. if (isset($encoding))
  167. $this->assertEquals($encoding, $frame->getEncoding());
  168. if (isset($language))
  169. $this->assertEquals($language, $frame->getLanguage());
  170. if (isset($timing))
  171. $this->assertEquals($timing, $frame->getFormat());
  172. }
  173. }
  174. }
  175. /**
  176. * The first AbstractLink frame test.
  177. *
  178. * @param ID3_Frame_AbstractLink $frame The frame to test.
  179. * @param boolean $construct Whether construction or testing should occur.
  180. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  181. * in this frame.
  182. * @param string $language The language code.
  183. * @param integer $timing The timing format.
  184. */
  185. /*private function frameAbstractLink0(&$frame, $construct, $encoding, $language, $timing) {
  186. $link = $this->testLink;
  187. if ($construct)
  188. $frame->setLink($link);
  189. else
  190. $this->assertEquals($link, $frame->getLink());
  191. }*/
  192. /**
  193. * The first AbstractText frame test.
  194. *
  195. * @param ID3_Frame_AbstractText $frame The frame to test.
  196. * @param boolean $construct Whether construction or testing should occur.
  197. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  198. * in this frame.
  199. * @param string $language The language code.
  200. * @param integer $timing The timing format.
  201. */
  202. /*private function frameAbstractText0
  203. (&$frame, $construct, $encoding, $language, $timing)
  204. {
  205. $text = $this->convert($this->testText, $encoding);
  206. if ($construct)
  207. $frame->setText($text);
  208. else
  209. $this->assertEquals($text, $frame->getText());
  210. }*/
  211. /**
  212. * The first AENC frame test.
  213. *
  214. * @param ID3_Frame_AENC $frame The frame to test.
  215. * @param boolean $construct Whether construction or testing should occur.
  216. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  217. * in this frame.
  218. * @param string $language The language code.
  219. * @param integer $timing The timing format.
  220. */
  221. private function frameAENC0
  222. (&$frame, $construct, $encoding, $language, $timing)
  223. {
  224. $owner = $this->testText;
  225. $previewStart = $this->testUInt16;
  226. $previewLength = $this->testUInt16 - 1;
  227. $encryptionInfo = $this->testText;
  228. if ($construct) {
  229. $frame->setOwner($owner);
  230. $frame->setPreviewStart($previewStart);
  231. $frame->setPreviewLength($previewLength);
  232. $frame->setEncryptionInfo($encryptionInfo);
  233. } else {
  234. $this->assertEquals($owner, $frame->getOwner());
  235. $this->assertEquals($previewStart, $frame->getPreviewStart());
  236. $this->assertEquals($previewLength, $frame->getPreviewLength());
  237. $this->assertEquals($encryptionInfo, $frame->getEncryptionInfo());
  238. }
  239. }
  240. /**
  241. * The first APIC frame test.
  242. *
  243. * @param ID3_Frame_APIC $frame The frame to test.
  244. * @param boolean $construct Whether construction or testing should occur.
  245. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  246. * in this frame.
  247. * @param string $language The language code.
  248. * @param integer $timing The timing format.
  249. */
  250. private function frameAPIC0
  251. (&$frame, $construct, $encoding, $language, $timing)
  252. {
  253. $mimeType = $this->testText;
  254. $imageType = $this->testUInt8;
  255. $description = $this->convert($this->testText, $encoding);
  256. $imageData = $this->testText;
  257. $imageSize = strlen($imageData);
  258. if ($construct) {
  259. $frame->setMimeType($mimeType);
  260. $frame->setImageType($imageType);
  261. $frame->setDescription($description);
  262. $frame->setImageData($imageData);
  263. } else {
  264. $this->assertEquals($mimeType, $frame->getMimeType());
  265. $this->assertEquals($imageType, $frame->getImageType());
  266. $this->assertEquals($description, $frame->getDescription());
  267. $this->assertEquals($imageData, $frame->getImageData());
  268. $this->assertEquals($imageSize, $frame->getImageSize());
  269. }
  270. }
  271. /**
  272. * The first COMM frame test.
  273. *
  274. * @param ID3_Frame_COMM $frame The frame to test.
  275. * @param boolean $construct Whether construction or testing should occur.
  276. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  277. * in this frame.
  278. * @param string $language The language code.
  279. * @param integer $timing The timing format.
  280. */
  281. private function frameCOMM0
  282. (&$frame, $construct, $encoding, $language, $timing)
  283. {
  284. $description = $this->convert($this->testText, $encoding);
  285. $text = $this->convert($this->testText, $encoding);
  286. if ($construct) {
  287. $frame->setDescription($description);
  288. $frame->setText($text);
  289. } else {
  290. $this->assertEquals($description, $frame->getDescription());
  291. $this->assertEquals($text, $frame->getText());
  292. }
  293. }
  294. /**
  295. * The first COMR frame test.
  296. *
  297. * @param ID3_Frame_COMR $frame The frame to test.
  298. * @param boolean $construct Whether construction or testing should occur.
  299. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  300. * in this frame.
  301. * @param string $language The language code.
  302. * @param integer $timing The timing format.
  303. */
  304. private function frameCOMR0
  305. (&$frame, $construct, $encoding, $language, $timing)
  306. {
  307. $currency = $this->testCurrency;
  308. $price = $this->testText;
  309. $date = $this->testDate;
  310. $contact = $this->testLink;
  311. $delivery = $this->testUInt8;
  312. $seller = $this->convert($this->testText, $encoding);
  313. $description = $this->convert($this->testText, $encoding);
  314. $mimeType = $this->testText;
  315. $imageData = $this->testText;
  316. $imageSize = strlen($imageData);
  317. if ($construct) {
  318. $frame->setCurrency($currency);
  319. $frame->setPrice($price);
  320. $frame->setDate($date);
  321. $frame->setContact($contact);
  322. $frame->setDelivery($delivery);
  323. $frame->setSeller($seller);
  324. $frame->setDescription($description);
  325. $frame->setMimeType($mimeType);
  326. $frame->setImageData($imageData);
  327. } else {
  328. $this->assertEquals($currency, $frame->getCurrency());
  329. $this->assertEquals($price, $frame->getPrice());
  330. $this->assertEquals($date, $frame->getDate());
  331. $this->assertEquals($contact, $frame->getContact());
  332. $this->assertEquals($delivery, $frame->getDelivery());
  333. $this->assertEquals($seller, $frame->getSeller());
  334. $this->assertEquals($description, $frame->getDescription());
  335. $this->assertEquals($mimeType, $frame->getMimeType());
  336. $this->assertEquals($imageData, $frame->getImageData());
  337. $this->assertEquals($imageSize, $frame->getImageSize());
  338. }
  339. }
  340. /**
  341. * The first ENCR frame test.
  342. *
  343. * @param ID3_Frame_ENCR $frame The frame to test.
  344. * @param boolean $construct Whether construction or testing should occur.
  345. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  346. * in this frame.
  347. * @param string $language The language code.
  348. * @param integer $timing The timing format.
  349. */
  350. private function frameENCR0
  351. (&$frame, $construct, $encoding, $language, $timing)
  352. {
  353. $owner = $this->testLink;
  354. $method = $this->testInt8;
  355. $encryptionData = $this->testText;
  356. if ($construct) {
  357. $frame->setOwner($owner);
  358. $frame->setMethod($method);
  359. $frame->setEncryptionData($encryptionData);
  360. } else {
  361. $this->assertEquals($owner, $frame->getOwner());
  362. $this->assertEquals($method, $frame->getMethod());
  363. $this->assertEquals($encryptionData, $frame->getEncryptionData());
  364. }
  365. }
  366. /**
  367. * The first EQU2 frame test.
  368. *
  369. * @param ID3_Frame_EQU2 $frame The frame to test.
  370. * @param boolean $construct Whether construction or testing should occur.
  371. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  372. * in this frame.
  373. * @param string $language The language code.
  374. * @param integer $timing The timing format.
  375. */
  376. private function frameEQU20
  377. (&$frame, $construct, $encoding, $language, $timing)
  378. {
  379. $interpolation = $this->testInt8;
  380. $device = $this->testText;
  381. $adjustments[0] = -32767.0 / 512.0;
  382. $adjustments[2047] = -1.0;
  383. $adjustments[8191] = 0.0;
  384. $adjustments[16383] = 1.0;
  385. $adjustments[32767] = 32767.0 / 512.0;
  386. if ($construct) {
  387. foreach ($adjustments as $frequency => $adjustment)
  388. $frame->addAdjustment($frequency, $adjustment);
  389. $this->assertEquals($adjustments, $frame->getAdjustments());
  390. $frame->setInterpolation($interpolation);
  391. $frame->setDevice($device);
  392. $frame->setAdjustments($adjustments);
  393. } else {
  394. $this->assertEquals($interpolation, $frame->getInterpolation());
  395. $this->assertEquals($device, $frame->getDevice());
  396. $this->assertEquals($adjustments, $frame->getAdjustments());
  397. }
  398. }
  399. /**
  400. * The first EQUA frame test.
  401. *
  402. * @param ID3_Frame_EQUA $frame The frame to test.
  403. * @param boolean $construct Whether construction or testing should occur.
  404. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  405. * in this frame.
  406. * @param string $language The language code.
  407. * @param integer $timing The timing format.
  408. */
  409. private function frameEQUA0
  410. (&$frame, $construct, $encoding, $language, $timing)
  411. {
  412. $adjustments[0] = -65535;
  413. $adjustments[2047] = -4096;
  414. $adjustments[8191] = 0;
  415. $adjustments[16383] = 4096;
  416. $adjustments[32767] = 65535;
  417. if ($construct) {
  418. foreach ($adjustments as $frequency => $adjustment)
  419. $frame->addAdjustment($frequency, $adjustment);
  420. $this->assertEquals($adjustments, $frame->getAdjustments());
  421. $frame->setAdjustments($adjustments);
  422. } else {
  423. $this->assertEquals($adjustments, $frame->getAdjustments());
  424. }
  425. }
  426. /**
  427. * The first ETCO frame test.
  428. *
  429. * @param ID3_Frame_ETCO $frame The frame to test.
  430. * @param boolean $construct Whether construction or testing should occur.
  431. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  432. * in this frame.
  433. * @param string $language The language code.
  434. * @param integer $timing The timing format.
  435. */
  436. private function frameETCO0
  437. (&$frame, $construct, $encoding, $language, $timing)
  438. {
  439. $events[0] = array_search("Intro end", ID3_Frame_ETCO::$types);
  440. $events[0xFFFF] = array_search("Verse start", ID3_Frame_ETCO::$types);
  441. $events[0xFFFFF] = array_search("Verse end", ID3_Frame_ETCO::$types);
  442. $events[0xFFFFFF] = array_search
  443. ("Audio end (start of silence)", ID3_Frame_ETCO::$types);
  444. $events[0xFFFFFFFF] = array_search
  445. ("Audio file ends", ID3_Frame_ETCO::$types);
  446. if ($construct)
  447. $frame->setEvents($events);
  448. else
  449. $this->assertEquals($events, $frame->getEvents());
  450. }
  451. /**
  452. * The first GEOB frame test.
  453. *
  454. * @param ID3_Frame_GEOB $frame The frame to test.
  455. * @param boolean $construct Whether construction or testing should occur.
  456. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  457. * in this frame.
  458. * @param string $language The language code.
  459. * @param integer $timing The timing format.
  460. */
  461. private function frameGEOB0
  462. (&$frame, $construct, $encoding, $language, $timing)
  463. {
  464. $mimeType = $this->testText;
  465. $filename = $this->convert($this->testText, $encoding);
  466. $description = $this->convert($this->testText, $encoding);
  467. $objectData = $this->testText;
  468. if ($construct) {
  469. $frame->setMimeType($mimeType);
  470. $frame->setFilename($filename);
  471. $frame->setDescription($description);
  472. $frame->setObjectData($objectData);
  473. } else {
  474. $this->assertEquals($mimeType, $frame->getMimeType());
  475. $this->assertEquals($filename, $frame->getFilename());
  476. $this->assertEquals($description, $frame->getDescription());
  477. $this->assertEquals($objectData, $frame->getObjectData());
  478. }
  479. }
  480. /**
  481. * The first GRID frame test.
  482. *
  483. * @param ID3_Frame_GRID $frame The frame to test.
  484. * @param boolean $construct Whether construction or testing should occur.
  485. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  486. * in this frame.
  487. * @param string $language The language code.
  488. * @param integer $timing The timing format.
  489. */
  490. private function frameGRID0
  491. (&$frame, $construct, $encoding, $language, $timing)
  492. {
  493. $owner = $this->testLink;
  494. $group = $this->testUInt8;
  495. $groupData = $this->testText;
  496. if ($construct) {
  497. $frame->setOwner($owner);
  498. $frame->setGroup($group);
  499. $frame->setGroupData($groupData);
  500. } else {
  501. $this->assertEquals($owner, $frame->getOwner());
  502. $this->assertEquals($group, $frame->getGroup());
  503. $this->assertEquals($groupData, $frame->getGroupData());
  504. }
  505. }
  506. /**
  507. * The first IPLS frame test.
  508. *
  509. * @param ID3_Frame_IPLS $frame The frame to test.
  510. * @param boolean $construct Whether construction or testing should occur.
  511. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  512. * in this frame.
  513. * @param string $language The language code.
  514. * @param integer $timing The timing format.
  515. */
  516. private function frameIPLS0
  517. (&$frame, $construct, $encoding, $language, $timing)
  518. {
  519. $testText = $this->convert($this->testText, $encoding);
  520. for ($i = 0; $i < 3; $i++)
  521. $people[] = array($testText => $testText);
  522. if ($construct) {
  523. foreach ($people as $entry)
  524. foreach ($entry as $involvement => $person)
  525. $frame->addPerson($involvement, $person);
  526. $this->assertEquals($people, $frame->getPeople());
  527. $frame->setPeople($people);
  528. } else {
  529. $this->assertEquals($people, $frame->getPeople());
  530. }
  531. }
  532. /**
  533. * The first LINK frame test.
  534. *
  535. * @param ID3_Frame_LINK $frame The frame to test.
  536. * @param boolean $construct Whether construction or testing should occur.
  537. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  538. * in this frame.
  539. * @param string $language The language code.
  540. * @param integer $timing The timing format.
  541. */
  542. private function frameLINK0
  543. (&$frame, $construct, $encoding, $language, $timing)
  544. {
  545. $target = $this->testIdentifier;
  546. $url = $this->testLink;
  547. $qualifier = $this->testText;
  548. if ($construct) {
  549. $frame->setTarget($target);
  550. $frame->setUrl($url);
  551. $frame->setQualifier($qualifier);
  552. } else {
  553. $this->assertEquals($target, $frame->getTarget());
  554. $this->assertEquals($url, $frame->getUrl());
  555. $this->assertEquals($qualifier, $frame->getQualifier());
  556. }
  557. }
  558. /**
  559. * The first MCDI frame test.
  560. *
  561. * @param ID3_Frame_MCDI $frame The frame to test.
  562. * @param boolean $construct Whether construction or testing should occur.
  563. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  564. * in this frame.
  565. * @param string $language The language code.
  566. * @param integer $timing The timing format.
  567. */
  568. private function frameMCDI0
  569. (&$frame, $construct, $encoding, $language, $timing)
  570. {
  571. $data = $this->testText;
  572. if ($construct)
  573. $frame->setData($data);
  574. else
  575. $this->assertEquals($data, $frame->getData());
  576. }
  577. /**
  578. * The first OWNE frame test.
  579. *
  580. * @param ID3_Frame_OWNE $frame The frame to test.
  581. * @param boolean $construct Whether construction or testing should occur.
  582. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  583. * in this frame.
  584. * @param string $language The language code.
  585. * @param integer $timing The timing format.
  586. */
  587. private function frameOWNE0
  588. (&$frame, $construct, $encoding, $language, $timing)
  589. {
  590. $currency = $this->testCurrency;
  591. $price = $this->testPrice;
  592. $date = $this->testDate;
  593. $seller = $this->convert($this->testText, $encoding);
  594. if ($construct) {
  595. $frame->setCurrency($currency);
  596. $frame->setPrice(0.0 + $price);
  597. $frame->setDate($date);
  598. $frame->setSeller($seller);
  599. } else {
  600. $this->assertEquals($currency, $frame->getCurrency());
  601. $this->assertEquals($price, $frame->getPrice());
  602. $this->assertEquals($date, $frame->getDate());
  603. $this->assertEquals($seller, $frame->getSeller());
  604. }
  605. }
  606. /**
  607. * The first PCNT frame test.
  608. *
  609. * @param ID3_Frame_PCNT $frame The frame to test.
  610. * @param boolean $construct Whether construction or testing should occur.
  611. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  612. * in this frame.
  613. * @param string $language The language code.
  614. * @param integer $timing The timing format.
  615. */
  616. private function framePCNT0
  617. (&$frame, $construct, $encoding, $language, $timing)
  618. {
  619. $counter = $this->testUInt32;
  620. if ($construct) {
  621. for ($i = 0; $i < 123; $i++)
  622. $frame->addCounter();
  623. $this->assertEquals(123, $frame->getCounter());
  624. $frame->setCounter($counter);
  625. } else {
  626. $this->assertEquals($counter, $frame->getCounter());
  627. }
  628. }
  629. /**
  630. * The first POPM frame test.
  631. *
  632. * @param ID3_Frame_POPM $frame The frame to test.
  633. * @param boolean $construct Whether construction or testing should occur.
  634. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  635. * in this frame.
  636. * @param string $language The language code.
  637. * @param integer $timing The timing format.
  638. */
  639. private function framePOPM0
  640. (&$frame, $construct, $encoding, $language, $timing)
  641. {
  642. $owner = $this->testLink;
  643. $rating = $this->testUInt8;
  644. $counter = $this->testUInt32;
  645. if ($construct) {
  646. $frame->setOwner($owner);
  647. $frame->setRating($rating);
  648. $frame->setCounter($counter);
  649. } else {
  650. $this->assertEquals($owner, $frame->getOwner());
  651. $this->assertEquals($rating, $frame->getRating());
  652. $this->assertEquals($counter, $frame->getCounter());
  653. }
  654. }
  655. /**
  656. * The first POSS frame test.
  657. *
  658. * @param ID3_Frame_POSS $frame The frame to test.
  659. * @param boolean $construct Whether construction or testing should occur.
  660. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  661. * in this frame.
  662. * @param string $language The language code.
  663. * @param integer $timing The timing format.
  664. */
  665. private function framePOSS0
  666. (&$frame, $construct, $encoding, $language, $timing)
  667. {
  668. $position = $this->testUInt32;
  669. if ($construct)
  670. $frame->setPosition($position);
  671. else
  672. $this->assertEquals($position, $frame->getPosition());
  673. }
  674. /**
  675. * The first PRIV frame test.
  676. *
  677. * @param ID3_Frame_PRIV $frame The frame to test.
  678. * @param boolean $construct Whether construction or testing should occur.
  679. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  680. * in this frame.
  681. * @param string $language The language code.
  682. * @param integer $timing The timing format.
  683. */
  684. private function framePRIV0
  685. (&$frame, $construct, $encoding, $language, $timing)
  686. {
  687. $owner = $this->testText;
  688. $privateData = $this->testText;
  689. if ($construct) {
  690. $frame->setOwner($owner);
  691. $frame->setPrivateData($privateData);
  692. } else {
  693. $this->assertEquals($owner, $frame->getOwner());
  694. $this->assertEquals($privateData, $frame->getPrivateData());
  695. }
  696. }
  697. /**
  698. * The first RBUF frame test.
  699. *
  700. * @param ID3_Frame_RBUF $frame The frame to test.
  701. * @param boolean $construct Whether construction or testing should occur.
  702. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  703. * in this frame.
  704. * @param string $language The language code.
  705. * @param integer $timing The timing format.
  706. */
  707. private function frameRBUF0
  708. (&$frame, $construct, $encoding, $language, $timing)
  709. {
  710. $bufferSize = $this->testInt24;
  711. $flags = $this->testInt8;
  712. $offset = $this->testInt32;
  713. if ($construct) {
  714. $frame->setBufferSize($bufferSize);
  715. $frame->setInfoFlags($flags);
  716. $frame->setOffset($offset);
  717. } else {
  718. $this->assertEquals($bufferSize, $frame->getBufferSize());
  719. $this->assertEquals($flags, $frame->getInfoFlags());
  720. $this->assertEquals($offset, $frame->getOffset());
  721. }
  722. }
  723. /**
  724. * The first RVA2 frame test.
  725. *
  726. * @param ID3_Frame_RVA2 $frame The frame to test.
  727. * @param boolean $construct Whether construction or testing should occur.
  728. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  729. * in this frame.
  730. * @param string $language The language code.
  731. * @param integer $timing The timing format.
  732. */
  733. private function frameRVA20
  734. (&$frame, $construct, $encoding, $language, $timing)
  735. {
  736. $device = $this->testText;
  737. $adjustments[0] = array(ID3_Frame_RVA2::channelType => 0,
  738. ID3_Frame_RVA2::volumeAdjustment => -32767.0 / 512.0,
  739. ID3_Frame_RVA2::peakVolume => 0x0);
  740. $adjustments[1] = array(ID3_Frame_RVA2::channelType => 1,
  741. ID3_Frame_RVA2::volumeAdjustment => -8191.0 / 512.0,
  742. ID3_Frame_RVA2::peakVolume => 0x7f);
  743. $adjustments[2] = array(ID3_Frame_RVA2::channelType => 2,
  744. ID3_Frame_RVA2::volumeAdjustment => -2047.0 / 512.0,
  745. ID3_Frame_RVA2::peakVolume => 0xff);
  746. $adjustments[3] = array(ID3_Frame_RVA2::channelType => 3,
  747. ID3_Frame_RVA2::volumeAdjustment => -1.0,
  748. ID3_Frame_RVA2::peakVolume => 0x7fff);
  749. $adjustments[4] = array(ID3_Frame_RVA2::channelType => 4,
  750. ID3_Frame_RVA2::volumeAdjustment => 0.0,
  751. ID3_Frame_RVA2::peakVolume => 0xffff);
  752. $adjustments[5] = array(ID3_Frame_RVA2::channelType => 5,
  753. ID3_Frame_RVA2::volumeAdjustment => 1.0,
  754. ID3_Frame_RVA2::peakVolume => 0x7fffff);
  755. $adjustments[6] = array(ID3_Frame_RVA2::channelType => 6,
  756. ID3_Frame_RVA2::volumeAdjustment => 2047.0 / 512.0,
  757. ID3_Frame_RVA2::peakVolume => 0xffffff);
  758. $adjustments[7] = array(ID3_Frame_RVA2::channelType => 7,
  759. ID3_Frame_RVA2::volumeAdjustment => 8191.0 / 512.0,
  760. ID3_Frame_RVA2::peakVolume => 0x7fffffff);
  761. $adjustments[8] = array(ID3_Frame_RVA2::channelType => 8,
  762. ID3_Frame_RVA2::volumeAdjustment => 32767.0 / 512.0,
  763. ID3_Frame_RVA2::peakVolume => 0xffffffff);
  764. if ($construct) {
  765. $frame->setDevice($device);
  766. $frame->setAdjustments($adjustments);
  767. } else {
  768. $this->assertEquals($device, $frame->getDevice());
  769. $this->assertEquals($adjustments, $frame->getAdjustments());
  770. }
  771. }
  772. /**
  773. * The first RVAD frame test.
  774. *
  775. * @param ID3_Frame_RVAD $frame The frame to test.
  776. * @param boolean $construct Whether construction or testing should occur.
  777. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  778. * in this frame.
  779. * @param string $language The language code.
  780. * @param integer $timing The timing format.
  781. */
  782. private function frameRVAD0
  783. (&$frame, $construct, $encoding, $language, $timing)
  784. {
  785. $adjustments[ID3_Frame_RVAD::right] = -0xffff;
  786. $adjustments[ID3_Frame_RVAD::left] = 0xffff;
  787. $adjustments[ID3_Frame_RVAD::peakRight] = 0xffff;
  788. $adjustments[ID3_Frame_RVAD::peakLeft] = 0xfff;
  789. if ($construct)
  790. $frame->setAdjustments($adjustments);
  791. else
  792. $this->assertEquals($adjustments, $frame->getAdjustments());
  793. }
  794. /**
  795. * The second RVAD frame test.
  796. *
  797. * @param ID3_Frame_RVAD $frame The frame to test.
  798. * @param boolean $construct Whether construction or testing should occur.
  799. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  800. * in this frame.
  801. * @param string $language The language code.
  802. * @param integer $timing The timing format.
  803. */
  804. private function frameRVAD1
  805. (&$frame, $construct, $encoding, $language, $timing)
  806. {
  807. $adjustments[ID3_Frame_RVAD::right] = -0xffff;
  808. $adjustments[ID3_Frame_RVAD::left] = 0xffff;
  809. $adjustments[ID3_Frame_RVAD::peakRight] = 0xffff;
  810. $adjustments[ID3_Frame_RVAD::peakLeft] = 0xfff;
  811. $adjustments[ID3_Frame_RVAD::rightBack] = -0xff;
  812. $adjustments[ID3_Frame_RVAD::leftBack] = 0xff;
  813. $adjustments[ID3_Frame_RVAD::peakRightBack] = 0xff;
  814. $adjustments[ID3_Frame_RVAD::peakLeftBack] = 0xf;
  815. if ($construct)
  816. $frame->setAdjustments($adjustments);
  817. else
  818. $this->assertEquals($adjustments, $frame->getAdjustments());
  819. }
  820. /**
  821. * The third RVAD frame test.
  822. *
  823. * @param ID3_Frame_RVAD $frame The frame to test.
  824. * @param boolean $construct Whether construction or testing should occur.
  825. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  826. * in this frame.
  827. * @param string $language The language code.
  828. * @param integer $timing The timing format.
  829. */
  830. private function frameRVAD2
  831. (&$frame, $construct, $encoding, $language, $timing)
  832. {
  833. $adjustments[ID3_Frame_RVAD::right] = -0xffff;
  834. $adjustments[ID3_Frame_RVAD::left] = 0xffff;
  835. $adjustments[ID3_Frame_RVAD::peakRight] = 0xffff;
  836. $adjustments[ID3_Frame_RVAD::peakLeft] = 0xfff;
  837. $adjustments[ID3_Frame_RVAD::rightBack] = -0xff;
  838. $adjustments[ID3_Frame_RVAD::leftBack] = 0xff;
  839. $adjustments[ID3_Frame_RVAD::peakRightBack] = 0xff;
  840. $adjustments[ID3_Frame_RVAD::peakLeftBack] = 0xf;
  841. $adjustments[ID3_Frame_RVAD::center] = 0xf;
  842. $adjustments[ID3_Frame_RVAD::peakCenter] = 0x7;
  843. if ($construct)
  844. $frame->setAdjustments($adjustments);
  845. else
  846. $this->assertEquals($adjustments, $frame->getAdjustments());
  847. }
  848. /**
  849. * The fourth RVAD frame test.
  850. *
  851. * @param ID3_Frame_RVAD $frame The frame to test.
  852. * @param boolean $construct Whether construction or testing should occur.
  853. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  854. * in this frame.
  855. * @param string $language The language code.
  856. * @param integer $timing The timing format.
  857. */
  858. private function frameRVAD3
  859. (&$frame, $construct, $encoding, $language, $timing)
  860. {
  861. $adjustments[ID3_Frame_RVAD::right] = -0xffff;
  862. $adjustments[ID3_Frame_RVAD::left] = 0xffff;
  863. $adjustments[ID3_Frame_RVAD::peakRight] = 0xffff;
  864. $adjustments[ID3_Frame_RVAD::peakLeft] = 0xfff;
  865. $adjustments[ID3_Frame_RVAD::rightBack] = -0xff;
  866. $adjustments[ID3_Frame_RVAD::leftBack] = 0xff;
  867. $adjustments[ID3_Frame_RVAD::peakRightBack] = 0xff;
  868. $adjustments[ID3_Frame_RVAD::peakLeftBack] = 0xf;
  869. $adjustments[ID3_Frame_RVAD::center] = 0xf;
  870. $adjustments[ID3_Frame_RVAD::peakCenter] = 0x7;
  871. $adjustments[ID3_Frame_RVAD::bass] = 0x0;
  872. $adjustments[ID3_Frame_RVAD::peakBass] = 0x0;
  873. if ($construct)
  874. $frame->setAdjustments($adjustments);
  875. else
  876. $this->assertEquals($adjustments, $frame->getAdjustments());
  877. }
  878. /**
  879. * The first RVRB frame test.
  880. *
  881. * @param ID3_Frame_RVRB $frame The frame to test.
  882. * @param boolean $construct Whether construction or testing should occur.
  883. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  884. * in this frame.
  885. * @param string $language The language code.
  886. * @param integer $timing The timing format.
  887. */
  888. private function frameRVRB0
  889. (&$frame, $construct, $encoding, $language, $timing)
  890. {
  891. $reverbLeft = $this->testUInt16;
  892. $reverbRight = $this->testUInt16 - 1;
  893. $reverbBouncesLeft = $this->testUInt8;
  894. $reverbBouncesRight = $this->testUInt8 - 1;
  895. $reverbFeedbackLtoL = $this->testUInt8 - 2;
  896. $reverbFeedbackLtoR = $this->testUInt8 - 3;
  897. $reverbFeedbackRtoR = $this->testUInt8 - 4;
  898. $reverbFeedbackRtoL = $this->testUInt8 - 5;
  899. $premixLtoR = $this->testUInt8 - 6;
  900. $premixRtoL = $this->testUInt8 - 7;
  901. if ($construct) {
  902. $frame->setReverbLeft($reverbLeft);
  903. $frame->setReverbRight($reverbRight);
  904. $frame->setReverbBouncesLeft($reverbBouncesLeft);
  905. $frame->setReverbBouncesRight($reverbBouncesRight);
  906. $frame->setReverbFeedbackLtoL($reverbFeedbackLtoL);
  907. $frame->setReverbFeedbackLtoR($reverbFeedbackLtoR);
  908. $frame->setReverbFeedbackRtoR($reverbFeedbackRtoR);
  909. $frame->setReverbFeedbackRtoL($reverbFeedbackRtoL);
  910. $frame->setPremixLtoR($premixLtoR);
  911. $frame->setPremixRtoL($premixRtoL);
  912. } else {
  913. $this->assertEquals($reverbLeft, $frame->getReverbLeft());
  914. $this->assertEquals($reverbRight, $frame->getReverbRight());
  915. $this->assertEquals($reverbBouncesLeft, $frame->getReverbBouncesLeft());
  916. $this->assertEquals($reverbBouncesRight, $frame->getReverbBouncesRight());
  917. $this->assertEquals($reverbFeedbackLtoL, $frame->getReverbFeedbackLtoL());
  918. $this->assertEquals($reverbFeedbackLtoR, $frame->getReverbFeedbackLtoR());
  919. $this->assertEquals($reverbFeedbackRtoR, $frame->getReverbFeedbackRtoR());
  920. $this->assertEquals($reverbFeedbackRtoL, $frame->getReverbFeedbackRtoL());
  921. $this->assertEquals($premixLtoR, $frame->getPremixLtoR());
  922. $this->assertEquals($premixRtoL, $frame->getPremixRtoL());
  923. }
  924. }
  925. /**
  926. * The first SEEK frame test.
  927. *
  928. * @param ID3_Frame_SEEK $frame The frame to test.
  929. * @param boolean $construct Whether construction or testing should occur.
  930. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  931. * in this frame.
  932. * @param string $language The language code.
  933. * @param integer $timing The timing format.
  934. */
  935. private function frameSEEK0
  936. (&$frame, $construct, $encoding, $language, $timing)
  937. {
  938. $minOffset = $this->testInt32;
  939. if ($construct)
  940. $frame->setMinimumOffset($minOffset);
  941. else
  942. $this->assertEquals($minOffset, $frame->getMinimumOffset());
  943. }
  944. /**
  945. * The first SIGN frame test.
  946. *
  947. * @param ID3_Frame_SIGN $frame The frame to test.
  948. * @param boolean $construct Whether construction or testing should occur.
  949. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  950. * in this frame.
  951. * @param string $language The language code.
  952. * @param integer $timing The timing format.
  953. */
  954. private function frameSIGN0
  955. (&$frame, $construct, $encoding, $language, $timing)
  956. {
  957. $group = $this->testUInt8;
  958. $signature = $this->testText;
  959. if ($construct) {
  960. $frame->setGroup($group);
  961. $frame->setSignature($signature);
  962. } else {
  963. $this->assertEquals($group, $frame->getGroup());
  964. $this->assertEquals($signature, $frame->getSignature());
  965. }
  966. }
  967. /**
  968. * The first SYLT frame test.
  969. *
  970. * @param ID3_Frame_SYLT $frame The frame to test.
  971. * @param boolean $construct Whether construction or testing should occur.
  972. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  973. * in this frame.
  974. * @param string $language The language code.
  975. * @param integer $timing The timing format.
  976. */
  977. private function frameSYLT0
  978. (&$frame, $construct, $encoding, $language, $timing)
  979. {
  980. $type = $this->testUInt8;
  981. $description = $this->convert($this->testText, $encoding);
  982. $events[0] = $description;
  983. $events[0xFFFF] = $description;
  984. $events[0xFFFFF] = $description;
  985. $events[0xFFFFFF] = $description;
  986. $events[0xFFFFFFFF] = $description;
  987. if ($construct) {
  988. $frame->setType($type);
  989. $frame->setDescription($description);
  990. $frame->setEvents($events);
  991. } else {
  992. $this->assertEquals($type, $frame->getType());
  993. $this->assertEquals($description, $frame->getDescription());
  994. $this->assertEquals($events, $frame->getEvents());
  995. }
  996. }
  997. /**
  998. * The first SYTC frame test.
  999. *
  1000. * @param ID3_Frame_SYTC $frame The frame to test.
  1001. * @param boolean $construct Whether construction or testing should occur.
  1002. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  1003. * in this frame.
  1004. * @param string $language The language code.
  1005. * @param integer $timing The timing format.
  1006. */
  1007. private function frameSYTC0
  1008. (&$frame, $construct, $encoding, $language, $timing)
  1009. {
  1010. $events[0] = ID3_Frame_SYTC::BEAT_FREE;
  1011. $events[0xFFFF] = ID3_Frame_SYTC::SINGLE_BEAT;
  1012. $events[0xFFFFF] = 0xFF;
  1013. $events[0xFFFFFF] = 0xFF + 1;
  1014. $events[0xFFFFFFFF] = 0xFF + 0xFF;
  1015. if ($construct)
  1016. $frame->setEvents($events);
  1017. else
  1018. $this->assertEquals($events, $frame->getEvents());
  1019. }
  1020. /**
  1021. * The first TXXX frame test.
  1022. *
  1023. * @param ID3_Frame_TXXX $frame The frame to test.
  1024. * @param boolean $construct Whether construction or testing should occur.
  1025. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  1026. * in this frame.
  1027. * @param string $language The language code.
  1028. * @param integer $timing The timing format.
  1029. */
  1030. private function frameTXXX0
  1031. (&$frame, $construct, $encoding, $language, $timing)
  1032. {
  1033. $description = $this->convert($this->testText, $encoding);
  1034. $text = $this->convert($this->testText, $encoding);
  1035. if ($construct) {
  1036. $frame->setDescription($description);
  1037. $frame->setText($text);
  1038. } else {
  1039. $this->assertEquals($description, $frame->getDescription());
  1040. $this->assertEquals($text, $frame->getText());
  1041. }
  1042. }
  1043. /**
  1044. * The first USER frame test.
  1045. *
  1046. * @param ID3_Frame_USER $frame The frame to test.
  1047. * @param boolean $construct Whether construction or testing should occur.
  1048. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  1049. * in this frame.
  1050. * @param string $language The language code.
  1051. * @param integer $timing The timing format.
  1052. */
  1053. private function frameUSER0
  1054. (&$frame, $construct, $encoding, $language, $timing)
  1055. {
  1056. $text = $this->convert($this->testText, $encoding);
  1057. if ($construct)
  1058. $frame->setText($text);
  1059. else
  1060. $this->assertEquals($text, $frame->getText());
  1061. }
  1062. /**
  1063. * The first USLT frame test.
  1064. *
  1065. * @param ID3_Frame_USLT $frame The frame to test.
  1066. * @param boolean $construct Whether construction or testing should occur.
  1067. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  1068. * in this frame.
  1069. * @param string $language The language code.
  1070. * @param integer $timing The timing format.
  1071. */
  1072. private function frameUSLT0
  1073. (&$frame, $construct, $encoding, $language, $timing)
  1074. {
  1075. $description = $this->convert($this->testText, $encoding);
  1076. $text = $this->convert($this->testText, $encoding);
  1077. if ($construct) {
  1078. $frame->setDescription($description);
  1079. $frame->setText($text);
  1080. } else {
  1081. $this->assertEquals($description, $frame->getDescription());
  1082. $this->assertEquals($text, $frame->getText());
  1083. }
  1084. }
  1085. /**
  1086. * The first WXXX frame test.
  1087. *
  1088. * @param ID3_Frame_WXXX $frame The frame to test.
  1089. * @param boolean $construct Whether construction or testing should occur.
  1090. * @param integer $encoding The {@link ID3_Encoding text encoding} for strings
  1091. * in this frame.
  1092. * @param string $language The language code.
  1093. * @param integer $timing The timing format.
  1094. */
  1095. private function frameWXXX0
  1096. (&$frame, $construct, $encoding, $language, $timing)
  1097. {
  1098. $description = $this->convert($this->testText, $encoding);
  1099. $link = $this->testLink;
  1100. if ($construct) {
  1101. $frame->setDescription($description);
  1102. $frame->setLink($link);
  1103. } else {
  1104. $this->assertEquals($description, $frame->getDescription());
  1105. $this->assertEquals($link, $frame->getLink());
  1106. }
  1107. }
  1108. /**
  1109. * Helper function to convert a string into a string of the given encoding.
  1110. *
  1111. * @param string $text The string to convert.
  1112. * @param integer $encoding The text encoding to convert to.
  1113. * @return string
  1114. */
  1115. private static function convert($text, $encoding)
  1116. {
  1117. switch ($encoding) {
  1118. case ID3_Encoding::ISO88591:
  1119. return iconv("ascii", "ISO-8859-1", $text);
  1120. case ID3_Encoding::UTF16:
  1121. return iconv("ascii", "UTF-16", $text);
  1122. case ID3_Encoding::UTF16LE:
  1123. return substr(iconv("ascii", "UTF-16LE", $text), 2);
  1124. case ID3_Encoding::UTF16BE:
  1125. return iconv("ascii", "UTF-16BE", $text);
  1126. default: // ID3_Encoding::UTF8
  1127. return iconv("ascii", "UTF-8", $text);
  1128. }
  1129. }
  1130. }