ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
module.audio-video.matroska.php
Go to the documentation of this file.
1 <?php
4 // available at http://getid3.sourceforge.net //
5 // or http://www.getid3.org //
7 // See readme.txt for more details //
9 // //
10 // module.audio-video.matriska.php //
11 // module for analyzing Matroska containers //
12 // dependencies: NONE //
13 // ///
15 
16 
18 {
19 
20  function getid3_matroska(&$fd, &$ThisFileInfo) {
21 
22  $ThisFileInfo['fileformat'] = 'matroska';
23 
24  fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
25 
26  //$ThisFileInfo['matroska']['raw']['a'] = $this->EBML2Int(fread($fd, 4));
27 
28  $ThisFileInfo['error'][] = 'Mastroka parsing not enabled in this version of getID3()';
29  return false;
30 
31  }
32 
33 
34  function EBML2Int($EBMLstring) {
35  // http://matroska.org/specs/
36 
37  // Element ID coded with an UTF-8 like system:
38  // 1xxx xxxx - Class A IDs (2^7 -2 possible values) (base 0x8X)
39  // 01xx xxxx xxxx xxxx - Class B IDs (2^14-2 possible values) (base 0x4X 0xXX)
40  // 001x xxxx xxxx xxxx xxxx xxxx - Class C IDs (2^21-2 possible values) (base 0x2X 0xXX 0xXX)
41  // 0001 xxxx xxxx xxxx xxxx xxxx xxxx xxxx - Class D IDs (2^28-2 possible values) (base 0x1X 0xXX 0xXX 0xXX)
42  // Values with all x at 0 and 1 are reserved (hence the -2).
43 
44  // Data size, in octets, is also coded with an UTF-8 like system :
45  // 1xxx xxxx - value 0 to 2^7-2
46  // 01xx xxxx xxxx xxxx - value 0 to 2^14-2
47  // 001x xxxx xxxx xxxx xxxx xxxx - value 0 to 2^21-2
48  // 0001 xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^28-2
49  // 0000 1xxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^35-2
50  // 0000 01xx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^42-2
51  // 0000 001x xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^49-2
52  // 0000 0001 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^56-2
53 
54  if (0x80 & ord($EBMLstring{0})) {
55  $EBMLstring{0} = chr(ord($EBMLstring{0}) & 0x7F);
56  } elseif (0x40 & ord($EBMLstring{0})) {
57  $EBMLstring{0} = chr(ord($EBMLstring{0}) & 0x3F);
58  } elseif (0x20 & ord($EBMLstring{0})) {
59  $EBMLstring{0} = chr(ord($EBMLstring{0}) & 0x1F);
60  } elseif (0x10 & ord($EBMLstring{0})) {
61  $EBMLstring{0} = chr(ord($EBMLstring{0}) & 0x0F);
62  } elseif (0x08 & ord($EBMLstring{0})) {
63  $EBMLstring{0} = chr(ord($EBMLstring{0}) & 0x07);
64  } elseif (0x04 & ord($EBMLstring{0})) {
65  $EBMLstring{0} = chr(ord($EBMLstring{0}) & 0x03);
66  } elseif (0x02 & ord($EBMLstring{0})) {
67  $EBMLstring{0} = chr(ord($EBMLstring{0}) & 0x01);
68  } elseif (0x01 & ord($EBMLstring{0})) {
69  $EBMLstring{0} = chr(ord($EBMLstring{0}) & 0x00);
70  } else {
71  return false;
72  }
73  return getid3_lib::BigEndian2Int($EBMLstring);
74  }
75 
76 }
77 
78 ?>