ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
GetId3\Module\Audio\Rkau Class Reference

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

+ Inheritance diagram for GetId3\Module\Audio\Rkau:
+ Collaboration diagram for GetId3\Module\Audio\Rkau:

Public Member Functions

 analyze ()
 
 RKAUqualityLookup (&$RKAUdata)
 
- Public Member Functions inherited from GetId3\Handler\BaseHandler
 __construct (GetId3Core $getid3, $call_module=null)
 
 analyze ()
 Analyze from file pointer. More...
 
 AnalyzeString (&$string)
 Analyze from string instead. More...
 
 saveAttachment (&$ThisFileInfoIndex, $filename, $offset, $length)
 

Additional Inherited Members

- Protected Member Functions inherited from GetId3\Handler\BaseHandler
 ftell ()
 
 fread ($bytes)
 
 fseek ($bytes, $whence=SEEK_SET)
 
 feof ()
 
 isDependencyFor ($module)
 
 error ($text)
 
 warning ($text)
 
- Protected Attributes inherited from GetId3\Handler\BaseHandler
 $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 //.

module for analyzing Shorten Audio files

Author
James Heinrich info@.nosp@m.geti.nosp@m.d3.or.nosp@m.g http://www.getid3.org

Definition at line 29 of file Rkau.php.

Member Function Documentation

◆ analyze()

GetId3\Module\Audio\Rkau::analyze ( )
Returns
boolean

Reimplemented from GetId3\Handler\BaseHandler.

Definition at line 36 of file Rkau.php.

37 {
38 $info = &$this->getid3->info;
39
40 fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
41 $RKAUHeader = fread($this->getid3->fp, 20);
42 $magic = 'RKA';
43 if (substr($RKAUHeader, 0, 3) != $magic) {
44 $info['error'][] = 'Expecting "'.Helper::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.Helper::PrintHexBytes(substr($RKAUHeader, 0, 3)).'"';
45
46 return false;
47 }
48
49 $info['fileformat'] = 'rkau';
50 $info['audio']['dataformat'] = 'rkau';
51 $info['audio']['bitrate_mode'] = 'vbr';
52
53 $info['rkau']['raw']['version'] = Helper::LittleEndian2Int(substr($RKAUHeader, 3, 1));
54 $info['rkau']['version'] = '1.'.str_pad($info['rkau']['raw']['version'] & 0x0F, 2, '0', STR_PAD_LEFT);
55 if (($info['rkau']['version'] > 1.07) || ($info['rkau']['version'] < 1.06)) {
56 $info['error'][] = 'This version of GetId3Core() ['.$this->getid3->version().'] can only parse RKAU files v1.06 and 1.07 (this file is v'.$info['rkau']['version'].')';
57 unset($info['rkau']);
58
59 return false;
60 }
61
62 $info['rkau']['source_bytes'] = Helper::LittleEndian2Int(substr($RKAUHeader, 4, 4));
63 $info['rkau']['sample_rate'] = Helper::LittleEndian2Int(substr($RKAUHeader, 8, 4));
64 $info['rkau']['channels'] = Helper::LittleEndian2Int(substr($RKAUHeader, 12, 1));
65 $info['rkau']['bits_per_sample'] = Helper::LittleEndian2Int(substr($RKAUHeader, 13, 1));
66
67 $info['rkau']['raw']['quality'] = Helper::LittleEndian2Int(substr($RKAUHeader, 14, 1));
68 $this->RKAUqualityLookup($info['rkau']);
69
70 $info['rkau']['raw']['flags'] = Helper::LittleEndian2Int(substr($RKAUHeader, 15, 1));
71 $info['rkau']['flags']['joint_stereo'] = (bool) (!($info['rkau']['raw']['flags'] & 0x01));
72 $info['rkau']['flags']['streaming'] = (bool) ($info['rkau']['raw']['flags'] & 0x02);
73 $info['rkau']['flags']['vrq_lossy_mode'] = (bool) ($info['rkau']['raw']['flags'] & 0x04);
74
75 if ($info['rkau']['flags']['streaming']) {
76 $info['avdataoffset'] += 20;
77 $info['rkau']['compressed_bytes'] = Helper::LittleEndian2Int(substr($RKAUHeader, 16, 4));
78 } else {
79 $info['avdataoffset'] += 16;
80 $info['rkau']['compressed_bytes'] = $info['avdataend'] - $info['avdataoffset'] - 1;
81 }
82 // Note: compressed_bytes does not always equal what appears to be the actual number of compressed bytes,
83 // sometimes it's more, sometimes less. No idea why(?)
84
85 $info['audio']['lossless'] = $info['rkau']['lossless'];
86 $info['audio']['channels'] = $info['rkau']['channels'];
87 $info['audio']['bits_per_sample'] = $info['rkau']['bits_per_sample'];
88 $info['audio']['sample_rate'] = $info['rkau']['sample_rate'];
89
90 $info['playtime_seconds'] = $info['rkau']['source_bytes'] / ($info['rkau']['sample_rate'] * $info['rkau']['channels'] * ($info['rkau']['bits_per_sample'] / 8));
91 $info['audio']['bitrate'] = ($info['rkau']['compressed_bytes'] * 8) / $info['playtime_seconds'];
92
93 return true;
94
95 }
fseek($bytes, $whence=SEEK_SET)
static LittleEndian2Int($byteword, $signed=false)
Definition: Helper.php:413
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
Definition: Helper.php:36
RKAUqualityLookup(&$RKAUdata)
Definition: Rkau.php:102
$info
Definition: example_052.php:80

References $info, GetId3\Handler\BaseHandler\fread(), GetId3\Handler\BaseHandler\fseek(), GetId3\Lib\Helper\LittleEndian2Int(), GetId3\Lib\Helper\PrintHexBytes(), and GetId3\Module\Audio\Rkau\RKAUqualityLookup().

+ Here is the call graph for this function:

◆ RKAUqualityLookup()

GetId3\Module\Audio\Rkau::RKAUqualityLookup ( $RKAUdata)
Parameters
type$RKAUdata
Returns
boolean

Definition at line 102 of file Rkau.php.

103 {
104 $level = ($RKAUdata['raw']['quality'] & 0xF0) >> 4;
105 $quality = $RKAUdata['raw']['quality'] & 0x0F;
106
107 $RKAUdata['lossless'] = (($quality == 0) ? true : false);
108 $RKAUdata['compression_level'] = $level + 1;
109 if (!$RKAUdata['lossless']) {
110 $RKAUdata['quality_setting'] = $quality;
111 }
112
113 return true;
114 }

Referenced by GetId3\Module\Audio\Rkau\analyze().

+ Here is the caller graph for this function:

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