ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
GetId3\Module\AudioVideo\Ts Class Reference

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

+ Inheritance diagram for GetId3\Module\AudioVideo\Ts:
+ Collaboration diagram for GetId3\Module\AudioVideo\Ts:

Public Member Functions

 analyze ()
 
 TSscramblingControlLookup ($raw)
 
- 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 MPEG Transport Stream (.ts) 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 Ts.php.

Member Function Documentation

◆ analyze()

GetId3\Module\AudioVideo\Ts::analyze ( )
Returns
boolean

Definition at line 36 of file Ts.php.

References $info, GetId3\Lib\Helper\BigEndian2Int(), GetId3\Handler\BaseHandler\fread(), GetId3\Handler\BaseHandler\fseek(), GetId3\Lib\Helper\PrintHexBytes(), and GetId3\Module\AudioVideo\Ts\TSscramblingControlLookup().

37  {
38  $info = &$this->getid3->info;
39 
40  fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
41  $TSheader = fread($this->getid3->fp, 19);
42  $magic = "\x47";
43  if (substr($TSheader, 0, 1) != $magic) {
44  $info['error'][] = 'Expecting "'.Helper::PrintHexBytes($magic).'" at '.$info['avdataoffset'].', found '.Helper::PrintHexBytes(substr($TSheader, 0, 1)).' instead.';
45 
46  return false;
47  }
48  $info['fileformat'] = 'ts';
49 
50  // http://en.wikipedia.org/wiki/.ts
51 
52  $offset = 0;
53  $info['ts']['packet']['sync'] = Helper::BigEndian2Int(substr($TSheader, $offset, 1)); $offset += 1;
54  $pid_flags_raw = Helper::BigEndian2Int(substr($TSheader, $offset, 2)); $offset += 2;
55  $SAC_raw = Helper::BigEndian2Int(substr($TSheader, $offset, 1)); $offset += 1;
56  $info['ts']['packet']['flags']['transport_error_indicator'] = (bool) ($pid_flags_raw & 0x8000); // Set by demodulator if can't correct errors in the stream, to tell the demultiplexer that the packet has an uncorrectable error
57  $info['ts']['packet']['flags']['payload_unit_start_indicator'] = (bool) ($pid_flags_raw & 0x4000); // 1 means start of PES data or PSI otherwise zero only.
58  $info['ts']['packet']['flags']['transport_high_priority'] = (bool) ($pid_flags_raw & 0x2000); // 1 means higher priority than other packets with the same PID.
59  $info['ts']['packet']['packet_id'] = ($pid_flags_raw & 0x1FFF) >> 0;
60 
61  $info['ts']['packet']['raw']['scrambling_control'] = ($SAC_raw & 0xC0) >> 6;
62  $info['ts']['packet']['flags']['adaption_field_exists'] = (bool) ($SAC_raw & 0x20);
63  $info['ts']['packet']['flags']['payload_exists'] = (bool) ($SAC_raw & 0x10);
64  $info['ts']['packet']['continuity_counter'] = ($SAC_raw & 0x0F) >> 0; // Incremented only when a payload is present
65  $info['ts']['packet']['scrambling_control'] = $this->TSscramblingControlLookup($info['ts']['packet']['raw']['scrambling_control']);
66 
67  if ($info['ts']['packet']['flags']['adaption_field_exists']) {
68  $AdaptionField_raw = Helper::BigEndian2Int(substr($TSheader, $offset, 2)); $offset += 2;
69  $info['ts']['packet']['adaption']['field_length'] = ($AdaptionField_raw & 0xFF00) >> 8; // Number of bytes in the adaptation field immediately following this byte
70  $info['ts']['packet']['adaption']['flags']['discontinuity'] = (bool) ($AdaptionField_raw & 0x0080); // Set to 1 if current TS packet is in a discontinuity state with respect to either the continuity counter or the program clock reference
71  $info['ts']['packet']['adaption']['flags']['random_access'] = (bool) ($AdaptionField_raw & 0x0040); // Set to 1 if the PES packet in this TS packet starts a video/audio sequence
72  $info['ts']['packet']['adaption']['flags']['high_priority'] = (bool) ($AdaptionField_raw & 0x0020); // 1 = higher priority
73  $info['ts']['packet']['adaption']['flags']['pcr'] = (bool) ($AdaptionField_raw & 0x0010); // 1 means adaptation field does contain a PCR field
74  $info['ts']['packet']['adaption']['flags']['opcr'] = (bool) ($AdaptionField_raw & 0x0008); // 1 means adaptation field does contain an OPCR field
75  $info['ts']['packet']['adaption']['flags']['splice_point'] = (bool) ($AdaptionField_raw & 0x0004); // 1 means presence of splice countdown field in adaptation field
76  $info['ts']['packet']['adaption']['flags']['private_data'] = (bool) ($AdaptionField_raw & 0x0002); // 1 means presence of private data bytes in adaptation field
77  $info['ts']['packet']['adaption']['flags']['extension'] = (bool) ($AdaptionField_raw & 0x0001); // 1 means presence of adaptation field extension
78  if ($info['ts']['packet']['adaption']['flags']['pcr']) {
79  $info['ts']['packet']['adaption']['raw']['pcr'] = Helper::BigEndian2Int(substr($TSheader, $offset, 6)); $offset += 6;
80  }
81  if ($info['ts']['packet']['adaption']['flags']['opcr']) {
82  $info['ts']['packet']['adaption']['raw']['opcr'] = Helper::BigEndian2Int(substr($TSheader, $offset, 6)); $offset += 6;
83  }
84  }
85 
86  $info['error'][] = 'MPEG Transport Stream (.ts) parsing not enabled in this version of GetId3Core() ['.$this->getid3->version().']';
87 
88  return false;
89 
90  }
static PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8')
Definition: Helper.php:36
fseek($bytes, $whence=SEEK_SET)
$info
Definition: example_052.php:80
TSscramblingControlLookup($raw)
Definition: Ts.php:97
static BigEndian2Int($byteword, $synchsafe=false, $signed=false)
Definition: Helper.php:374
+ Here is the call graph for this function:

◆ TSscramblingControlLookup()

GetId3\Module\AudioVideo\Ts::TSscramblingControlLookup (   $raw)
Parameters
type$raw
Returns
type

Definition at line 97 of file Ts.php.

References array.

Referenced by GetId3\Module\AudioVideo\Ts\analyze().

98  {
99  $TSscramblingControlLookup = array(0x00=>'not scrambled', 0x01=>'reserved', 0x02=>'scrambled, even key', 0x03=>'scrambled, odd key');
100 
101  return (isset($TSscramblingControlLookup[$raw]) ? $TSscramblingControlLookup[$raw] : 'invalid');
102  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

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