trunk/ MP4Info/ Box/ ftyp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<?php
/**
*
MP4Info
*
* @author Tommy Lacroix <lacroix.tommy@gmail.com>
*
@copyrightCopyright (c) 2006-2009 Tommy Lacroix
* @license LGPL version 3, http://www.gnu.org/licenses/lgpl.html
*
@package php-mp4info
* @link $HeadURL$
*/
//
---
/**
*
4.3 File Type Box (FTYP)
*
* @author Tommy Lacroix <lacroix.tommy@gmail.com>
*
@version 1.1.20090611$Id$
*/
class MP4Info_Box_ftyp extends
MP4Info_Box {
/**
* Major brand
*
* @var int
*/
protected $majorBrand;
/**
* Minor brand
*
* @var int
*/
protected
$minorBrand;
/**
* Compatible brands
*
* @var int[]
*/
protected $compatibleBrands;
/**
* Major Brands' names
*
* @var {n:Str,n:Str,...}
* @static
*/
protected static $brandNames =
array(
'3g2a' => '3GPP2
Media (.3G2)',
'3ge6' => '3GPP
(.3GP) Release 6 MBMS Extended Presentations',
'3ge7' => '3GPP
(.3GP) Release 7 MBMS Extended Presentations',
'3gg6' => '3GPP
Release 6 General Profile',
'3gp1' => '3GPP
Media (.3GP) Release 1 ? (non-existent)',
'3gp2' => '3GPP
Media (.3GP) Release 2 ? (non-existent)',
'3gp3' => '3GPP
Media (.3GP) Release 3 ? (non-existent)',
'3gp4' => '3GPP
Media (.3GP) Release 4',
'3gp5' => '3GPP
Media (.3GP) Release 5',
'3gp6' => '3GPP
Media (.3GP) Release 6 Basic Profile',
'3gr6' => '3GPP
Media (.3GP) Release 6 Progressive Download',
'3gs6' => '3GPP
Media (.3GP) Release 6 Streaming Servers',
'3gs7' => '3GPP
Media (.3GP) Release 7 Streaming Servers',
'avc1' => 'MP4
Base w/ AVC ext ',
'caep' => 'Canon
Digital Camera',
'caqv' => 'Casio
Digital Camera',
'cdes' => 'Convergent
Design',
'f4v' => 'Video
for Adobe Flash Player 9+ (.F4V)',
'f4p' => 'Protected
Video for Adobe Flash Player 9+ (.F4P)',
'f4a' => 'Audio
for Adobe Flash Player 9+ (.F4A)',
'f4b' => 'Audio
Book for Adobe Flash Player 9+ (.F4B)',
'isc2' => 'ISMACryp
2.0 Encrypted File',
'iso2' => 'MP4
Base Media v2 ',
'isom' => 'MP4
Base Media v1 ',
'jp2' => 'JPEG
2000 Image (.JP2) ',
'jp20' => 'Unknown,
from GPAC samples (prob non-existent)',
'jpm' => 'JPEG
2000 Compound Image (.JPM) ',
'jpx' => 'JPEG
2000 w/ extensions (.JPX) ',
'kddi' => '3GPP2
EZmovie for KDDI 3G Cellphones',
'm4a ' => 'Apple
iTunes AAC-LC (.M4A) Audio',
'm4b ' => 'Apple
iTunes AAC-LC (.M4B) Audio Book',
'm4p ' => 'Apple
iTunes AAC-LC (.M4P) AES Protected Audio',
'm4v ' => 'Apple
iTunes Video (.M4V) Video',
'm4vh' => 'Apple
TV (.M4V)',
'm4vp' => 'Apple
iPhone (.M4V)',
'mj2s' => 'Motion
JPEG 2000 Simple Profile',
'mjp2' => 'Motion
JPEG 2000 General Profile',
'mmp4' => 'MPEG-4/3GPP
Mobile Profile (.MP4 / .3GP) (for NTT)',
'mp21' => 'MPEG-21
',
'mp41' => 'MP4
v1 ',
'mp42' => 'MP4
v2 ',
'mp71' => 'MP4
w/ MPEG-7 Metadata ',
'mppi' => 'Photo
Player, MAF ',
'mqt' => 'Sony
/ Mobile QuickTime (.MQV)',
'msnv' => 'MPEG-4
(.MP4) for SonyPSP',
'ndas' => 'MP4
v2 Nero Digital AAC Audio',
'ndsc' => 'MPEG-4
(.MP4) Nero Cinema Profile',
'ndsh' => 'MPEG-4
(.MP4) Nero HDTV Profile',
'ndsm' => 'MPEG-4
(.MP4) Nero Mobile Profile',
'ndsp' => 'MPEG-4
(.MP4) Nero Portable Profile',
'ndss' => 'MPEG-4
(.MP4) Nero Standard Profile',
'ndxc' => 'H.264/MPEG-4
AVC (.MP4) Nero Cinema Profile',
'ndxh' => 'H.264/MPEG-4
AVC (.MP4) Nero HDTV Profile',
'ndxm' => 'H.264/MPEG-4
AVC (.MP4) Nero Mobile Profile',
'ndxp' => 'H.264/MPEG-4
AVC (.MP4) Nero Portable Profile',
'ndxs' => 'H.264/MPEG-4
AVC (.MP4) Nero Standard Profile',
'odcf ' => 'OMA
DCF DRM Format 2.0 (OMA-TS-DRM-DCF-V2_0-20060303-A)',
'opf2 ' => 'OMA
PDCF DRM Format 2.1 (OMA-TS-DRM-DCF-V2_1-20070724-C)',
'opx2 ' => 'OMA
PDCF DRM + XBS extensions (OMA-TS-DRM_XBS-V1_0-20070529-C)',
'qt ' => 'Apple
QuickTime (.MOV/QT)',
'sdv' => 'SD
Memory Card Video',
);
/**
* Constructor
*
* @author Tommy Lacroix <lacroix.tommy@gmail.com>
* @param int $totalSize
* @param int $boxType
* @param file|string $data
* @param MP4Info_Box $parent
* @return MP4Info_Box_ftyp
* @access public
* @throws MP4Info_Exception
*/
public function __construct($totalSize,
$boxType, $data, $parent) {
if (!self::isCompatible($boxType,
$parent)) {
throw new
MP4Info_Exception('This box isn\'t "ftyp"',MP4Info_Exception::CODE_INCOMPATIBLE,$boxType);
}
//
Call ancestor
parent::__construct($totalSize,
$boxType, false, $parent);
// Get data
$data = self::getDataFrom3rd($data,
$totalSize);
//
Unpack
$ar = unpack('NmajorBrand/NminorVersion/N*compatibleBrands',$data);
$compatibleBrands = array();
foreach ($ar as
$k=>$v) {
if (substr($k,0,16) == 'compatibleBrands') {
$compatibleBrands[] = $v;
}
}
// Save properties
$this->majorBrand = $ar['majorBrand'];
$this->minorVersion = $ar['minorVersion'];
$this->compatibleBrands = $compatibleBrands;
} // Constructor
/**
* Check if block is compatible with class
*
* @author Tommy Lacroix <lacroix.tommy@gmail.com>
* @param int
$boxType
* @param MP4Info_Box $parent
* @return bool
* @access public
* @static
*/
static function isCompatible($boxType,
$parent) {
return
$boxType == 0x66747970;
} //
isCompatible method
/**
* Major brand getter
*
* @author Tommy Lacroix <lacroix.tommy@gmail.com>
* @return int
* @access
public
*/
public function
getMajorBrand() {
return
$this->majorBrand;
} //
getMajorBrand method
/**
* Minor version getter
*
* @author Tommy Lacroix <lacroix.tommy@gmail.com>
* @return int
* @access
public
*/
public function
getMinorVersion() {
return
$this->minorVersion;
} //
getMinorVersion method
/**
* Compatible brands getter
*
* @author Tommy Lacroix <lacroix.tommy@gmail.com>
* @return int[]
* @access
public
*/
public function
getCompatibleBrands() {
return
$this->compatibleBrands;
} //
getCompatibleBrands method
/**
* Convert a brand 32bit code to a string
*
* @author Tommy Lacroix <lacroix.tommy@gmail.com>
* @param int $brand
* @return string
* @access public
* @static
*/
public static function
brandToString($brand) {
if (isset(self::$$brandNames[$brand])) {
return self::$$brandNames[$brand];
} else {
return $brand;
}
} // brandToString method
/**
* String converter
*
* @author Tommy Lacroix <lacroix.tommy@gmail.com>
* @return string
* @access public
*/
public function
toString() {
return '';
} // toString method
} //
MP4Info_Box_ftyp method
http://code.google.com/p/php-mp4info/source/browse/trunk/MP4Info/Box/ftyp.php?spec=svn2&r=2
页:
[1]