ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
getid3_rkau Class Reference

getID3() by James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g // More...

+ Inheritance diagram for getid3_rkau:
+ Collaboration diagram for getid3_rkau:

Public Member Functions

 Analyze ()
 
 RKAUqualityLookup (&$RKAUdata)
 
- Public Member Functions inherited from getid3_handler
 __construct (getID3 $getid3, $call_module=null)
 
 Analyze ()
 
 AnalyzeString ($string)
 
 setStringMode ($string)
 
 saveAttachment ($name, $offset, $length, $image_mime=null)
 

Additional Inherited Members

- Protected Member Functions inherited from getid3_handler
 ftell ()
 
 fread ($bytes)
 
 fseek ($bytes, $whence=SEEK_SET)
 
 feof ()
 
 isDependencyFor ($module)
 
 error ($text)
 
 warning ($text)
 
 notice ($text)
 
- Protected Attributes inherited from getid3_handler
 $getid3
 
 $data_string_flag = false
 
 $data_string = ''
 
 $data_string_position = 0
 
 $data_string_length = 0
 

Detailed Description

getID3() by James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g //

Definition at line 18 of file module.audio.rkau.php.

Member Function Documentation

◆ Analyze()

getid3_rkau::Analyze ( )

Definition at line 21 of file module.audio.rkau.php.

References $info, getid3_handler\error(), getid3_handler\fread(), getid3_handler\fseek(), getid3_lib\LittleEndian2Int(), getid3_lib\PrintHexBytes(), and RKAUqualityLookup().

21  {
22  $info = &$this->getid3->info;
23 
24  $this->fseek($info['avdataoffset']);
25  $RKAUHeader = $this->fread(20);
26  $magic = 'RKA';
27  if (substr($RKAUHeader, 0, 3) != $magic) {
28  $this->error('Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes(substr($RKAUHeader, 0, 3)).'"');
29  return false;
30  }
31 
32  $info['fileformat'] = 'rkau';
33  $info['audio']['dataformat'] = 'rkau';
34  $info['audio']['bitrate_mode'] = 'vbr';
35 
36  $info['rkau']['raw']['version'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 3, 1));
37  $info['rkau']['version'] = '1.'.str_pad($info['rkau']['raw']['version'] & 0x0F, 2, '0', STR_PAD_LEFT);
38  if (($info['rkau']['version'] > 1.07) || ($info['rkau']['version'] < 1.06)) {
39  $this->error('This version of getID3() ['.$this->getid3->version().'] can only parse RKAU files v1.06 and 1.07 (this file is v'.$info['rkau']['version'].')');
40  unset($info['rkau']);
41  return false;
42  }
43 
44  $info['rkau']['source_bytes'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 4, 4));
45  $info['rkau']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 8, 4));
46  $info['rkau']['channels'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 12, 1));
47  $info['rkau']['bits_per_sample'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 13, 1));
48 
49  $info['rkau']['raw']['quality'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 14, 1));
50  $this->RKAUqualityLookup($info['rkau']);
51 
52  $info['rkau']['raw']['flags'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 15, 1));
53  $info['rkau']['flags']['joint_stereo'] = (bool) (!($info['rkau']['raw']['flags'] & 0x01));
54  $info['rkau']['flags']['streaming'] = (bool) ($info['rkau']['raw']['flags'] & 0x02);
55  $info['rkau']['flags']['vrq_lossy_mode'] = (bool) ($info['rkau']['raw']['flags'] & 0x04);
56 
57  if ($info['rkau']['flags']['streaming']) {
58  $info['avdataoffset'] += 20;
59  $info['rkau']['compressed_bytes'] = getid3_lib::LittleEndian2Int(substr($RKAUHeader, 16, 4));
60  } else {
61  $info['avdataoffset'] += 16;
62  $info['rkau']['compressed_bytes'] = $info['avdataend'] - $info['avdataoffset'] - 1;
63  }
64  // Note: compressed_bytes does not always equal what appears to be the actual number of compressed bytes,
65  // sometimes it's more, sometimes less. No idea why(?)
66 
67  $info['audio']['lossless'] = $info['rkau']['lossless'];
68  $info['audio']['channels'] = $info['rkau']['channels'];
69  $info['audio']['bits_per_sample'] = $info['rkau']['bits_per_sample'];
70  $info['audio']['sample_rate'] = $info['rkau']['sample_rate'];
71 
72  $info['playtime_seconds'] = $info['rkau']['source_bytes'] / ($info['rkau']['sample_rate'] * $info['rkau']['channels'] * ($info['rkau']['bits_per_sample'] / 8));
73  $info['audio']['bitrate'] = ($info['rkau']['compressed_bytes'] * 8) / $info['playtime_seconds'];
74 
75  return true;
76 
77  }
RKAUqualityLookup(&$RKAUdata)
error($text)
Definition: getid3.php:1752
static LittleEndian2Int($byteword, $signed=false)
Definition: getid3.lib.php:292
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
Definition: getid3.lib.php:18
fread($bytes)
Definition: getid3.php:1683
fseek($bytes, $whence=SEEK_SET)
Definition: getid3.php:1711
$info
Definition: index.php:5
+ Here is the call graph for this function:

◆ RKAUqualityLookup()

getid3_rkau::RKAUqualityLookup ( $RKAUdata)

Definition at line 80 of file module.audio.rkau.php.

Referenced by Analyze().

80  {
81  $level = ($RKAUdata['raw']['quality'] & 0xF0) >> 4;
82  $quality = $RKAUdata['raw']['quality'] & 0x0F;
83 
84  $RKAUdata['lossless'] = (($quality == 0) ? true : false);
85  $RKAUdata['compression_level'] = $level + 1;
86  if (!$RKAUdata['lossless']) {
87  $RKAUdata['quality_setting'] = $quality;
88  }
89 
90  return true;
91  }
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: