rtMedia for WordPress, BuddyPress and bbPress - Version 2.0.1

Version Description

  • Replaced codec finding library
  • Fixed warning on activities page
Download this release

Release Info

Developer rtcamp
Plugin Icon 128x128 rtMedia for WordPress, BuddyPress and bbPress
Version 2.0.1
Comparing to
See all releases

Code changes from version 2.0 to 2.0.1

includes/bp-media-class-wordpress.php CHANGED
@@ -100,23 +100,19 @@ class BP_Media_Host_Wordpress {
100
switch ($type) {
101
case 'video/mp4' :
102
$type = 'video';
103
- include_once(trailingslashit(BP_MEDIA_PLUGIN_DIR) . 'includes/lib/MP4Info.php');
104
try {
105
- $vid_info = MP4Info::getInfo($file);
106
- } catch (MP4Info_Exception $e) {
107
- wp_delete_post($post_id, true);
108
- unlink($file);
109
- $activity_content = false;
110
- throw new Exception(__('MP4 file you have uploaded is currupt.', 'bp-media'));
111
} catch (Exception $e) {
112
wp_delete_post($post_id, true);
113
unlink($file);
114
$activity_content = false;
115
throw new Exception(__('MP4 file you have uploaded is currupt.', 'bp-media'));
116
}
117
- if (is_object($vid_info)) {
118
- if (isset($vid_info->hasVideo) && $vid_info->hasVideo && isset($vid_info->video)) {
119
- if (!(isset($vid_info->video->codecStr) && $vid_info->video->codecStr == 'H.264')) {
120
wp_delete_post($post_id, true);
121
unlink($file);
122
$activity_content = false;
@@ -126,7 +122,7 @@ class BP_Media_Host_Wordpress {
126
wp_delete_post($post_id, true);
127
unlink($file);
128
$activity_content = false;
129
- throw new Exception(__('The MP4 file you have uploaded contains no video.', 'bp-media'));
130
}
131
} else {
132
wp_delete_post($post_id, true);
100
switch ($type) {
101
case 'video/mp4' :
102
$type = 'video';
103
+ include_once(trailingslashit(BP_MEDIA_PLUGIN_DIR) . 'includes/lib/getid3/getid3.php');
104
try {
105
+ $getID3 = new getID3;
106
+ $vid_info = $getID3->analyze($file);
107
} catch (Exception $e) {
108
wp_delete_post($post_id, true);
109
unlink($file);
110
$activity_content = false;
111
throw new Exception(__('MP4 file you have uploaded is currupt.', 'bp-media'));
112
}
113
+ if (is_array($vid_info)) {
114
+ if (!array_key_exists('error',$vid_info)&& array_key_exists('fileformat', $vid_info) && array_key_exists('video', $vid_info)&&array_key_exists('fourcc',$vid_info['video'])) {
115
+ if (!($vid_info['fileformat']=='mp4'&&$vid_info['video']['fourcc']=='avc1')) {
116
wp_delete_post($post_id, true);
117
unlink($file);
118
$activity_content = false;
122
wp_delete_post($post_id, true);
123
unlink($file);
124
$activity_content = false;
125
+ throw new Exception(__('The MP4 file you have uploaded is using an unsupported video codec. Supported video codec is H.264.', 'bp-media'));
126
}
127
} else {
128
wp_delete_post($post_id, true);
includes/bp-media-filters.php CHANGED
@@ -1,11 +1,11 @@
1
<?php
2
- function bp_media_activity_permalink_filter($link, $activity_obj) {
3
- if ('media_upload' == $activity_obj->type) {
4
add_shortcode('bp_media_url', 'bp_media_shortcode_url');
5
$link = do_shortcode($activity_obj->primary_link);
6
remove_shortcode('bp_media_url');
7
}
8
- if ('activity_comment' == $activity_obj->type) {
9
$parent = bp_activity_get_meta($activity_obj->item_id, 'bp_media_parent_post');
10
if ($parent) {
11
$parent = new BP_Media_Host_Wordpress($parent);
@@ -16,8 +16,8 @@ function bp_media_activity_permalink_filter($link, $activity_obj) {
16
}
17
add_filter('bp_activity_get_permalink', 'bp_media_activity_permalink_filter', 10, 2);
18
19
- function bp_media_activity_action_filter($activity_action, $activity_obj) {
20
- if ('media_upload' == $activity_obj->type) {
21
add_shortcode('bp_media_action', 'bp_media_shortcode_action');
22
$activity_action = do_shortcode($activity_action);
23
remove_shortcode('bp_media_action');
@@ -26,8 +26,8 @@ function bp_media_activity_action_filter($activity_action, $activity_obj) {
26
}
27
add_filter('bp_get_activity_action', 'bp_media_activity_action_filter', 10, 2);
28
29
- function bp_media_activity_content_filter($activity_content, $activity_obj) {
30
- if ('media_upload' == $activity_obj->type) {
31
add_shortcode('bp_media_content', 'bp_media_shortcode_content');
32
$activity_content = do_shortcode($activity_content);
33
remove_shortcode('bp_media_content');
@@ -44,7 +44,6 @@ function bp_media_activity_parent_content_filter($content) {
44
remove_shortcode('bp_media_content');
45
return $content;
46
}
47
-
48
add_filter('bp_get_activity_parent_content', 'bp_media_activity_parent_content_filter');
49
50
function bp_media_delete_button_handler($link) {
1
<?php
2
+ function bp_media_activity_permalink_filter($link, $activity_obj = null) {
3
+ if ($activity_obj != null && 'media_upload' == $activity_obj->type) {
4
add_shortcode('bp_media_url', 'bp_media_shortcode_url');
5
$link = do_shortcode($activity_obj->primary_link);
6
remove_shortcode('bp_media_url');
7
}
8
+ if ($activity_obj != null && 'activity_comment' == $activity_obj->type) {
9
$parent = bp_activity_get_meta($activity_obj->item_id, 'bp_media_parent_post');
10
if ($parent) {
11
$parent = new BP_Media_Host_Wordpress($parent);
16
}
17
add_filter('bp_activity_get_permalink', 'bp_media_activity_permalink_filter', 10, 2);
18
19
+ function bp_media_activity_action_filter($activity_action, $activity_obj = null) {
20
+ if ($activity_obj != null && 'media_upload' == $activity_obj->type) {
21
add_shortcode('bp_media_action', 'bp_media_shortcode_action');
22
$activity_action = do_shortcode($activity_action);
23
remove_shortcode('bp_media_action');
26
}
27
add_filter('bp_get_activity_action', 'bp_media_activity_action_filter', 10, 2);
28
29
+ function bp_media_activity_content_filter($activity_content, $activity_obj = null ) {
30
+ if ($activity_obj != null && 'media_upload' == $activity_obj->type) {
31
add_shortcode('bp_media_content', 'bp_media_shortcode_content');
32
$activity_content = do_shortcode($activity_content);
33
remove_shortcode('bp_media_content');
44
remove_shortcode('bp_media_content');
45
return $content;
46
}
47
add_filter('bp_get_activity_parent_content', 'bp_media_activity_parent_content_filter');
48
49
function bp_media_delete_button_handler($link) {
includes/bp-media-functions.php CHANGED
@@ -69,8 +69,8 @@ function bp_media_show_formatted_error_message($messages, $type) {
69
echo '</div>';
70
}
71
72
- function bp_media_conditional_override_allowed_tags($content, $activity) {
73
- if ($activity->type == 'media_upload') {
74
add_filter('bp_activity_allowed_tags', 'bp_media_override_allowed_tags', 1);
75
}
76
return bp_activity_filter_kses($content);
69
echo '</div>';
70
}
71
72
+ function bp_media_conditional_override_allowed_tags($content, $activity=null) {
73
+ if ($activity != null && $activity->type == 'media_upload') {
74
add_filter('bp_activity_allowed_tags', 'bp_media_override_allowed_tags', 1);
75
}
76
return bp_activity_filter_kses($content);
includes/lib/MP4Info.php DELETED
@@ -1,257 +0,0 @@
1
- <?php
2
- /**
3
- * MP4Info
4
- *
5
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
6
- * @copyright Copyright (c) 2006-2009 Tommy Lacroix
7
- * @license LGPL version 3, http://www.gnu.org/licenses/lgpl.html
8
- * @package php-mp4info
9
- * @link $HeadURL: https://php-mp4info.googlecode.com/svn/trunk/MP4Info.php $
10
- */
11
-
12
- // ---
13
-
14
- /**
15
- * MP4Info main class
16
- *
17
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
18
- * @version 1.1.20090611 $Id: MP4Info.php 2 2009-06-11 14:12:31Z lacroix.tommy@gmail.com $
19
- */
20
- class MP4Info {
21
- // {{{ Audio codec types
22
- const MP4_AUDIO_CODEC_UNCOMPRESSED = 0x00;
23
- const MP4_AUDIO_CODEC_MP3 = 0x02;
24
- const MP4_AUDIO_CODEC_AAC = 0xe0;
25
- // }}}
26
-
27
- // {{{ Video codec types
28
- const MP4_VIDEO_CODEC_H264 = 0xe0;
29
- // }}}
30
-
31
-
32
- /**
33
- * Get information from MP4 file
34
- *
35
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
36
- * @param string $file
37
- * @return array
38
- * @access public
39
- * @static
40
- */
41
- public static function getInfo($file) {
42
- // Open file
43
- $f = fopen($file,'rb');
44
- if (!$f) {
45
- throw new Exception('Cannot open file: '.$file);
46
- }
47
-
48
- // Get all boxes
49
- try {
50
- while (($box = MP4Info_Box::fromStream($f))) {
51
- $boxes[] = $box;
52
- }
53
- } catch (Exception $e) { }
54
-
55
- // Close
56
- fclose($f);
57
-
58
- // Return info
59
- return self::getInfoFromBoxes($boxes);
60
- } // getInfo method
61
-
62
-
63
- /**
64
- * Get information from MP4 boxes
65
- *
66
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
67
- * @param string $file
68
- * @return array
69
- * @access public
70
- * @static
71
- */
72
- public static function getInfoFromBoxes($boxes, &$context=null) {
73
- if ($context === null) {
74
- $context = new stdClass();
75
- $context->hasVideo = false;
76
- $context->hasAudio = false;
77
- $context->video = new stdClass();
78
- $context->audio = new stdClass();
79
- }
80
-
81
- foreach ($boxes as &$box) {
82
- // Interpret box
83
- switch ($box->getBoxTypeStr()) {
84
- case 'hdlr':
85
- switch ($box->getHandlerType()) {
86
- case MP4Info_Box_hdlr::HANDLER_VIDEO:
87
- $context->hasVideo = true;
88
- break;
89
- case MP4Info_Box_hdlr::HANDLER_SOUND:
90
- $context->hasAudio = true;
91
- break;
92
- }
93
- break;
94
- case 'mvhd':
95
- $context->duration = $box->getRealDuration();
96
- break;
97
- case 'ilst':
98
- if ($box->hasValue('©too')) {
99
- $context->encoder = $box->getValue('©too');
100
- }
101
- break;
102
- case 'uuid':
103
- $meta = $box->getXMPMetaData();
104
- if ($meta !== false) {
105
- // Try to get duration
106
- if (!isset($context->duration)) {
107
- if (preg_match('/<(|[a-z]+:)duration[\s\n\r]([^>]*)>/im',$meta,$m)) {
108
- if (preg_match_all('/xmpDM:([a-z]+)="([^"]+)"/',$m[2],$mm)) {
109
- $value = $scale = false;
110
- foreach ($mm[1] as $k=>$v) {
111
- if (($v == 'value') || ($v == 'scale')) {
112
- if (preg_match('/^1\/([0-9]+)#x2F;',$mm[2][$k],$mmm)) {
113
- $mm[2][$k] = 1/$mmm[1];
114
- }
115
- $v = $mm[2][$k];
116
- }
117
- }
118
- if (($value !== false) && ($scale !== false)) {
119
- $context->duration = $value*$scale;
120
- }
121
- }
122
- }
123
- }
124
-
125
- // Try to get size
126
- if ((!isset($context->width)) || (!isset($context->height))) {
127
- if (preg_match('/<(|[a-z]+:)videoFrameSize[\s\n\r]([^>]*)>/im',$meta,$m)) {
128
- if (preg_match_all('/[a-z]:([a-z]+)="([^"]+)"/',$m[2],$mm)) {
129
- $w = $h = false;
130
- foreach ($mm[1] as $k=>$v) {
131
- if (($v == 'w') || ($v == 'h')) {
132
- $v = $mm[2][$k];
133
- }
134
- }
135
- if ($w != false) {
136
- $context->video->width = $w;
137
- $context->hasVideo = true;
138
- }
139
- if ($h != false) {
140
- $context->video->height = $h;
141
- $context->hasVideo = true;
142
- }
143
- }
144
- }
145
- }
146
-
147
- // Try to get encoder
148
- if (preg_match('/softwareAgent="([^"]+)"/i',$meta,$m)) {
149
- $context->encoder = $m[1];
150
- }
151
-
152
- // Try to get audio channels
153
- if (preg_match('/audioChannelType="([^"]+)"/i',$meta,$m)) {
154
- switch (strtolower($m[1])) {
155
- case 'stereo':
156
- case '2':
157
- $context->audio->channels = 2;
158
- $context->hasAudio = true;
159
- break;
160
- case 'mono':
161
- case '1':
162
- $context->audio->channels = 1;
163
- $context->hasAudio = true;
164
- break;
165
- case '5.1':
166
- case '5':
167
- $context->audio->channels = 5;
168
- $context->hasAudio = true;
169
- break;
170
- }
171
- }
172
-
173
- // Try to get audio frequency
174
- if (preg_match('/audioSampleRate="([^"]+)"/i',$meta,$m)) {
175
- $context->audio->frequency = $m[1]/1000;
176
- $context->hasAudio = true;
177
- }
178
-
179
- // Try to get video frame rate
180
- if (preg_match('/videoFrameRate="([^"]+)"/i',$meta,$m)) {
181
- $context->video->fps = $m[1];
182
- $context->hasVideo = true;
183
- }
184
-
185
- //print htmlentities($meta);
186
- }
187
- break;
188
- case 'stsd':
189
- $values = $box->getValues();
190
- foreach (array_keys($values) as $codec) {
191
- switch ($codec) {
192
- case '.mp3':
193
- $context->audio->codec = self::MP4_AUDIO_CODEC_MP3;
194
- $context->audio->codecStr = 'MP3';
195
- $context->hasAudio = true;
196
- break;
197
- case 'mp4a':
198
- case 'mp4s':
199
- $context->audio->codec = self::MP4_AUDIO_CODEC_AAC;
200
- $context->audio->codecStr = 'AAC';
201
- $context->hasAudio = true;
202
- break;
203
- case 'avc1':
204
- case 'h264':
205
- case 'H264':
206
- $context->video->codec = self::MP4_VIDEO_CODEC_H264;
207
- $context->video->codecStr = 'H.264';
208
- $context->hasVideo = true;
209
- break;
210
- }
211
- }
212
- break;
213
- case 'tkhd':
214
- if ($box->getWidth() > 0) {
215
- $context->hasVideo = true;
216
- $context->video->width = $box->getWidth();
217
- $context->video->height = $box->getHeight();
218
- $context->hasVideo = true;
219
- }
220
- break;
221
- }
222
-
223
- // Process children
224
- if ($box->hasChildren()) {
225
- self::getInfoFromBoxes($box->children(), $context);
226
- }
227
- }
228
-
229
- return $context;
230
- } // getInfoFromBoxes method
231
-
232
-
233
- /**
234
- * Display boxes for debugging
235
- *
236
- * @param MP4Info_Box[] $boxes
237
- * @param int $level
238
- * @access public
239
- * @static
240
- */
241
- public static function displayBoxes($boxes,$level=0) {
242
- foreach ($boxes as $box) {
243
- print str_repeat('&nbsp;',$level*4) . $box->toString() . '<br>';
244
- if ($box->hasChildren()) {
245
- $this->displayBoxes($box->children(), $level+1);
246
- }
247
- }
248
- } // displayBoxes method
249
- } // MP4Info class
250
-
251
- // ---
252
-
253
- // {{{ Dependencies
254
- include "MP4Info/Helper.php";
255
- include "MP4Info/Exception.php";
256
- include "MP4Info/Box.php";
257
- // }}} Dependencies
includes/lib/MP4Info/Box.php DELETED
@@ -1,446 +0,0 @@
1
- <?php
2
- /**
3
- * MP4Info
4
- *
5
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
6
- * @copyright Copyright (c) 2006-2009 Tommy Lacroix
7
- * @license LGPL version 3, http://www.gnu.org/licenses/lgpl.html
8
- * @package php-mp4info
9
- * @link $HeadURL: https://php-mp4info.googlecode.com/svn/trunk/MP4Info/Box.php $
10
- *
11
- * Based on:
12
- * - http://www.geocities.com/xhelmboyx/quicktime/formats/mp4-layout.txt
13
- * - http://neuron2.net/library/avc/c041828_ISO_IEC_14496-12_2005(E).pdf
14
- * - http://www.adobe.com/devnet/flv/pdf/video_file_format_spec_v10.pdf
15
- */
16
-
17
- // ---
18
-
19
- /**
20
- * MP4Info General Box
21
- *
22
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
23
- * @version 1.1.20090611 $Id: Box.php 2 2009-06-11 14:12:31Z lacroix.tommy@gmail.com $
24
- */
25
- class MP4Info_Box {
26
- /**
27
- * Total box size, including box header (8 bytes)
28
- *
29
- * @var int
30
- */
31
- protected $totalSize;
32
-
33
- /**
34
- * Box type, numeric
35
- *
36
- * @var int
37
- */
38
- protected $boxType;
39
-
40
- /**
41
- * Box type, string
42
- *
43
- * @var string
44
- */
45
- protected $boxTypeStr;
46
-
47
- /**
48
- * Box data
49
- *
50
- * @var string(binary)
51
- */
52
- protected $data;
53
-
54
- /**
55
- * Parent
56
- *
57
- * @var MP4Info_Box|false
58
- */
59
- protected $parent;
60
-
61
- /**
62
- * Children
63
- *
64
- * @var MP4Info_Box[]
65
- */
66
- protected $children = array();
67
-
68
- /**
69
- * Constructor
70
- *
71
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
72
- * @param int $totalSize
73
- * @param int $boxType
74
- * @param file|string $f
75
- * @param MP4Info_Box $parent
76
- * @access public
77
- */
78
- public function __construct($totalSize, $boxType, $f, $parent=false) {
79
- $this->totalSize = $totalSize;
80
- $this->boxType = $boxType;
81
- $this->boxTypeStr = pack('N',$boxType);
82
- $this->data = self::getDataFrom3rd($f,$totalSize);
83
- $this->parent = $parent;
84
- if ($parent != false) {
85
- $parent->addChild($this);
86
- }
87
- } // Constructor
88
-
89
- /**
90
- * Add a child to this box
91
- *
92
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
93
- * @param MP4Info_Box $child
94
- * @access public
95
- */
96
- public function addChild(&$child) {
97
- if (!$child instanceof MP4Info_Box) {
98
- throw new Exception('Child is not MP4Info_Box');
99
- }
100
- $this->children[] = &$child;
101
- }
102
-
103
- /**
104
- * Check if the box has children
105
- *
106
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
107
- * @return bool
108
- * @access public
109
- */
110
- public function hasChildren() {
111
- return count($this->children) > 0;
112
- } // hasChildren method
113
-
114
- /**
115
- * Get boxes' children
116
- *
117
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
118
- * @return MP4Info_Box[]
119
- * @access public
120
- */
121
- public function children() {
122
- return $this->children;
123
- } // children method
124
-
125
-
126
- /**
127
- * Get data from 3rd argument (file or string)
128
- *
129
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
130
- * @param file|string $f
131
- * @param int $totalSize
132
- * @return string
133
- * @access public
134
- * @static
135
- */
136
- public static function getDataFrom3rd($f, $totalSize) {
137
- // Get data
138
- if ($f === false) {
139
- return '';
140
- } else if (is_string($f)) {
141
- $data = substr($f,0,$totalSize-8);
142
- } else {
143
- $data = fread($f,$totalSize-8);
144
- }
145
-
146
- return $data;
147
- } // getDataFrom3rd method
148
-
149
-
150
- /**
151
- * Create an MP4Info_Box object from data
152
- *
153
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
154
- * @param int $totalSize
155
- * @param int $boxType
156
- * @param file|string $f
157
- * @param MP4Info_Box|false $parent
158
- * @return MP4Info_Box
159
- * @access public
160
- * @static
161
- */
162
- public static function factory($totalSize, $boxType, $f, $parent=false) {
163
- if (MP4Info_Box_Container::isCompatible($boxType,$parent)) {
164
- $box = new MP4Info_Box_Container($totalSize, $boxType, $f, $parent);
165
- } else if (MP4Info_Box_ftyp::isCompatible($boxType,$parent)) {
166
- $box = new MP4Info_Box_ftyp($totalSize, $boxType, $f, $parent);
167
- } else if (MP4Info_Box_uuid::isCompatible($boxType,$parent)) {
168
- $box = new MP4Info_Box_uuid($totalSize, $boxType, $f, $parent);
169
- } else if (MP4Info_Box_hdlr::isCompatible($boxType,$parent)) {
170
- $box = new MP4Info_Box_hdlr($totalSize, $boxType, $f, $parent);
171
- } else if (MP4Info_Box_mvhd::isCompatible($boxType,$parent)) {
172
- $box = new MP4Info_Box_mvhd($totalSize, $boxType, $f, $parent);
173
- } else if (MP4Info_Box_tkhd::isCompatible($boxType,$parent)) {
174
- $box = new MP4Info_Box_tkhd($totalSize, $boxType, $f, $parent);
175
- } else if (MP4Info_Box_mdhd::isCompatible($boxType,$parent)) {
176
- $box = new MP4Info_Box_mdhd($totalSize, $boxType, $f, $parent);
177
- } else if (MP4Info_Box_meta::isCompatible($boxType,$parent)) {
178
- $box = new MP4Info_Box_meta($totalSize, $boxType, $f, $parent);
179
- } else if (MP4Info_Box_stsd::isCompatible($boxType,$parent)) {
180
- $box = new MP4Info_Box_stsd($totalSize, $boxType, $f, $parent);
181
- } else if (MP4Info_Box_ilst::isCompatible($boxType,$parent)) {
182
- $box = new MP4Info_Box_ilst($totalSize, $boxType, $f, $parent);
183
- } else if (MP4Info_Box_ilst_sub::isCompatible($boxType,$parent)) {
184
- $box = new MP4Info_Box_ilst_sub($totalSize, $boxType, $f, $parent);
185
- } else {
186
- throw new Exception('Media type error');
187
- }
188
-
189
- // Return box
190
- return $box;
191
- } // factory method
192
-
193
-
194
- /**
195
- * Create a box from string
196
- *
197
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
198
- * @param string $data
199
- * @param MP4Info_Box|false $parent
200
- * @return MP4Info_Box
201
- * @access public
202
- * @static
203
- */
204
- public static function fromString(&$data,$parent=false) {
205
- if (strlen($data) < 8) {
206
- throw new Exception('Not enough data, need at least 8 bytes!');
207
- }
208
-
209
- $ar = unpack('NtotalSize/NboxType',$data);
210
- if ($ar['totalSize'] == 1) {
211
- // Size is bigger than 4GB :-O die
212
- // Skip ExtendedSize(UI64) and try to decode anyway
213
- $ar2 = unpack('N2extSize',substr($data,8));
214
- if ($ar2['extSize1'] > 0) {
215
- throw new Exception('Extended size not supported');
216
- } else {
217
- $ar['totalSize'] = $ar2['extSize2'];
218
- }
219
- $skip = 8;
220
- } else {
221
- $skip = 0;
222
- }
223
-
224
- // Check if we need to skip
225
- if (self::skipBoxType($ar['boxType'])) {
226
- //print '+++ Skipping box '.pack('N',$ar['boxType']).'<br>';
227
- $data = substr($data,$ar['totalSize']);
228
- return self::fromString($data,$parent);
229
- }
230
-
231
- // Check if box is a container, and skip to content if so
232
- if (self::ignoreBoxType($ar['boxType'])) {
233
- //print '+++ Ignoring box '.pack('N',$ar['boxType']).'<br>';
234
- $data = substr($data,8+$skip);
235
- return self::fromString($data,$parent);
236
- }
237
-
238
- // Create box
239
- $box = self::factory($ar['totalSize'],$ar['boxType'],substr($data,8+$skip),$parent);
240
- if ($box instanceof MP4Info_Box) {
241
- $data = substr($data,$box->getTotalSize());
242
- }
243
-
244
- return $box;
245
- } // fromString method
246
-
247
-
248
- /**
249
- * Create a box from file stream
250
- *
251
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
252
- * @param file $f
253
- * @param MP4Info_Box|false $parent
254
- * @return MP4Info_Box
255
- * @access public
256
- * @static
257
- */
258
- public static function fromStream($f,$parent=false) {
259
- // Get box header
260
- $buf = fread($f,8);
261
- if (strlen($buf) < 8) {
262
- return false;
263
- }
264
- $ar = unpack('NtotalSize/NboxType',$buf);
265
- if ($ar['totalSize'] == 1) {
266
- // Size is bigger than 4GB :-O die
267
- // Skip ExtendedSize(UI64) and try to decode anyway
268
- $buf = fread($f,8);
269
- $ar2 = unpack('N2extSize',$buf);
270
- if ($ar2['extSize1'] > 0) {
271
- throw new Exception('Extended size not supported');
272
- } else {
273
- $ar['totalSize'] = $ar2['extSize2'];
274
- }
275
- }
276
-
277
- // Check if we need to skip
278
- if (self::skipBoxType($ar['boxType'])) {
279
- //print '+++ Skipping box '.pack('N',$ar['boxType']).'<br>';
280
- fseek($f,$ar['totalSize']-8,SEEK_CUR);
281
- return self::fromStream($f,$parent);
282
- }
283
-
284
- // Check if box is a container, and skip it if so
285
- if (self::ignoreBoxType($ar['boxType'])) {
286
- //print '+++ Ignoring box '.pack('N',$ar['boxType']).' of size '.$ar['totalSize'].'<br>';
287
- return self::fromStream($f,$parent);
288
- }
289
-
290
- // Get box content
291
- if ($ar['totalSize'] > 0) {
292
- if ($ar['totalSize'] < 256*1024) {
293
- $data = fread($f,$ar['totalSize']-8);
294
- } else {
295
- $data = $f;
296
- }
297
- } else {
298
- $data = '';
299
- }
300
-
301
- // Create box object
302
- $box = MP4Info_Box::factory($ar['totalSize'], $ar['boxType'], $data, $parent);
303
- //print 'Got box from stream of type 0x'.dechex($ar['boxType']).'('.pack('N',$ar['boxType']).') and size '.$ar['totalSize'].' bytes: '.$box->toString().'<br>';
304
- return $box;
305
- } // fromStream method
306
-
307
-
308
- /**
309
- * Check if we need to ignore that box, based on type
310
- *
311
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
312
- * @param int $boxType
313
- * @return bool
314
- * @access public
315
- * @static
316
- * @todo Cleanup, legacy stuff
317
- */
318
- public static function ignoreBoxType($boxType) {
319
- return false;
320
- } // ignoreBoxType method
321
-
322
-
323
- /**
324
- * Check if we need to skip a box based on type
325
- *
326
- * @param int $boxType
327
- * @return bool
328
- * @access public
329
- * @static
330
- */
331
- public static function skipBoxType($boxType) {
332
- switch ($boxType) {
333
- case 0x696f6473: // iods 5.1 Initial Object Descriptor Box
334
- case 0x55c40000: // ??? ??
335
- case 0x6d646174: // mdat ?? Movie Data
336
- case 0x736d6864: // smhd 8.11.3 Sound Media Header Box
337
- case 0x766d6864: // vmhd 8.11.2 Video Media Header Box
338
- case 0x6e6d6864: // nmhd 8.11.5 Null Media Header Box
339
- case 0x64696e66: // dinf ??
340
- case 0x73747473: // stts 8.15.2 Decoding Time to Sample Box
341
- case 0x73747363: // stsc 8.18 Sample To Chunk Box
342
- case 0x7374737a: // stsz 8.17 Sample Size Boxes
343
- case 0x7374636f: // stco 8.19 Chunk Offset Box
344
- case 0x636f3634: // co64 8.19 Chunk Offset Box
345
- case 0x63747473: // ctts 8.15.3 Composition Time to Sample Box
346
- case 0x73747373: // stss 8.20 Sync Sample Box
347
- case 0x74726566: // tref 8.6 Track Reference Box
348
- return true;
349
- default:
350
- return false;
351
- }
352
- } // skipBoxType method
353
-
354
-
355
- /**
356
- * Total size getter
357
- *
358
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
359
- * @return int
360
- * @access public
361
- */
362
- public function getTotalSize() {
363
- return $this->totalSize;
364
- } // getTotalSize method
365
-
366
-
367
- /**
368
- * Box type getter
369
- *
370
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
371
- * @return int
372
- * @access public
373
- */
374
- public function getBoxType() {
375
- return $this->boxType;
376
- } // getBoxType method
377
-
378
-
379
- /**
380
- * Box type string getter
381
- *
382
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
383
- * @return string
384
- * @access public
385
- */
386
- public function getBoxTypeStr() {
387
- return $this->boxTypeStr;
388
- } // getBoxTypeStr method
389
-
390
-
391
- /**
392
- * Data getter
393
- *
394
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
395
- * @return string(binary)
396
- * @access public
397
- */
398
- public function getData() {
399
- return $this->data;
400
- } // getData method
401
-
402
-
403
- /**
404
- * stdClass converter
405
- *
406
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
407
- * @return stdClass
408
- * @access public
409
- */
410
- public function toStdClass() {
411
- $a = new stdClass();
412
- foreach ($this as $propName=>$prop) {
413
- if (($propName != 'children') && ($propName != 'parent') && ($propName != 'boxes')) {
414
- $a->{$propName} = $prop;
415
- }
416
- }
417
- return $a;
418
- } // toStdClass method
419
-
420
-
421
- /**
422
- * String converter
423
- *
424
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
425
- * @return string
426
- * @access public
427
- */
428
- public function toString() {
429
- return '[MP4Info_Box[0x'.dechex($this->boxType).'('.pack('N',$this->boxType).']]';
430
- } // toString method
431
- } // MP4Info_Box class
432
-
433
-
434
- // {{{ Dependencies
435
- include "Box/Container.php";
436
- include "Box/ftyp.php";
437
- include "Box/uuid.php";
438
- include "Box/hdlr.php";
439
- include "Box/tkhd.php";
440
- include "Box/mvhd.php";
441
- include "Box/mdhd.php";
442
- include "Box/meta.php";
443
- include "Box/stsd.php";
444
- include "Box/ilst.php";
445
- include "Box/ilst_sub.php";
446
- // }}} Dependencies
includes/lib/MP4Info/Box/Container.php DELETED
@@ -1,99 +0,0 @@
1
- <?php
2
- /**
3
- * MP4Info
4
- *
5
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
6
- * @copyright Copyright (c) 2006-2009 Tommy Lacroix
7
- * @license LGPL version 3, http://www.gnu.org/licenses/lgpl.html
8
- * @package php-mp4info
9
- * @link $HeadURL: https://php-mp4info.googlecode.com/svn/trunk/MP4Info/Box/Container.php $
10
- */
11
-
12
- // ---
13
-
14
- /**
15
- * Generic container box
16
- *
17
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
18
- * @version 1.1.20090611 $Id: Container.php 2 2009-06-11 14:12:31Z lacroix.tommy@gmail.com $
19
- */
20
- class MP4Info_Box_Container extends MP4Info_Box {
21
- /**
22
- * Constructor
23
- *
24
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
25
- * @param int $totalSize
26
- * @param int $boxType
27
- * @param file|string $data
28
- * @param MP4Info_Box $parent
29
- * @return MP4Info_Box_Container
30
- * @access public
31
- * @throws MP4Info_Exception
32
- */
33
- public function __construct($totalSize, $boxType, $data, $parent) {
34
- if (!self::isCompatible($boxType, $parent)) {
35
- throw new MP4Info_Exception('This box isn\'t a container',MP4Info_Exception::CODE_INCOMPATIBLE,$boxType);
36
- }
37
-
38
- // Call ancestor
39
- parent::__construct($totalSize, $boxType, false, $parent);
40
-
41
- // Unpack
42
- if (is_string($data)) {
43
- while ($data != '') {
44
- try {
45
- $box = MP4Info_Box::fromString($data, $this);
46
- if (!$box instanceof MP4Info_Box) {
47
- break;
48
- }
49
- } catch (Exception $e) {
50
- break;
51
- }
52
- }
53
- } else {
54
- do {
55
- try {
56
- $box = MP4Info_Box::fromStream($data, $this);
57
- if (!$box instanceof MP4Info_Box) {
58
- break;
59
- }
60
- } catch (Exception $e) {
61
- break;
62
- }
63
- } while ($box !== false);
64
- }
65
- } // Constructor
66
-
67
-
68
- /**
69
- * Check if block is compatible with class
70
- *
71
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
72
- * @param int $boxType
73
- * @param MP4Info_Box $parent
74
- * @return bool
75
- * @access public
76
- * @static
77
- */
78
- public static function isCompatible($boxType, $parent) {
79
- return ($boxType == 0x6D6F6F76) || // moov
80
- ($boxType == 0x7472616B) || // trak
81
- ($boxType == 0x6d646961) || // mdia
82
- ($boxType == 0x6D696E66) || // minf
83
- ($boxType == 0x7374626c) || // stbl
84
- ($boxType == 0x75647461) || // udta
85
- false;
86
- } // isCompatible method
87
-
88
-
89
- /**
90
- * String converter
91
- *
92
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
93
- * @return string
94
- * @access public
95
- */
96
- public function toString() {
97
- return '[MP4Info_Box_Container['.$this->boxTypeStr.']:'.count($this->children).']';
98
- } // toString method
99
- } // MP4Info_Box_Container method
includes/lib/MP4Info/Box/ftyp.php DELETED
@@ -1,231 +0,0 @@
1
- <?php
2
- /**
3
- * MP4Info
4
- *
5
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
6
- * @copyright Copyright (c) 2006-2009 Tommy Lacroix
7
- * @license LGPL version 3, http://www.gnu.org/licenses/lgpl.html
8
- * @package php-mp4info
9
- * @link $HeadURL: https://php-mp4info.googlecode.com/svn/trunk/MP4Info/Box/ftyp.php $
10
- */
11
-
12
- // ---
13
-
14
- /**
15
- * 4.3 File Type Box (FTYP)
16
- *
17
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
18
- * @version 1.1.20090611 $Id: ftyp.php 2 2009-06-11 14:12:31Z lacroix.tommy@gmail.com $
19
- */
20
- class MP4Info_Box_ftyp extends MP4Info_Box {
21
- /**
22
- * Major brand
23
- *
24
- * @var int
25
- */
26
- protected $majorBrand;
27
-
28
- /**
29
- * Minor brand
30
- *
31
- * @var int
32
- */
33
- protected $minorBrand;
34
-
35
- /**
36
- * Compatible brands
37
- *
38
- * @var int[]
39
- */
40
- protected $compatibleBrands;
41
-
42
- /**
43
- * Major Brands' names
44
- *
45
- * @var {n:Str,n:Str,...}
46
- * @static
47
- */
48
- protected static $brandNames = array(
49
- '3g2a' => '3GPP2 Media (.3G2)',
50
- '3ge6' => '3GPP (.3GP) Release 6 MBMS Extended Presentations',
51
- '3ge7' => '3GPP (.3GP) Release 7 MBMS Extended Presentations',
52
- '3gg6' => '3GPP Release 6 General Profile',
53
- '3gp1' => '3GPP Media (.3GP) Release 1 ? (non-existent)',
54
- '3gp2' => '3GPP Media (.3GP) Release 2 ? (non-existent)',
55
- '3gp3' => '3GPP Media (.3GP) Release 3 ? (non-existent)',
56
- '3gp4' => '3GPP Media (.3GP) Release 4',
57
- '3gp5' => '3GPP Media (.3GP) Release 5',
58
- '3gp6' => '3GPP Media (.3GP) Release 6 Basic Profile',
59
- '3gr6' => '3GPP Media (.3GP) Release 6 Progressive Download',
60
- '3gs6' => '3GPP Media (.3GP) Release 6 Streaming Servers',
61
- '3gs7' => '3GPP Media (.3GP) Release 7 Streaming Servers',
62
- 'avc1' => 'MP4 Base w/ AVC ext [ISO 14496-12:2005]',
63
- 'caep' => 'Canon Digital Camera',
64
- 'caqv' => 'Casio Digital Camera',
65
- 'cdes' => 'Convergent Design',
66
- 'f4v' => 'Video for Adobe Flash Player 9+ (.F4V)',
67
- 'f4p' => 'Protected Video for Adobe Flash Player 9+ (.F4P)',
68
- 'f4a' => 'Audio for Adobe Flash Player 9+ (.F4A)',
69
- 'f4b' => 'Audio Book for Adobe Flash Player 9+ (.F4B)',
70
- 'isc2' => 'ISMACryp 2.0 Encrypted File',
71
- 'iso2' => 'MP4 Base Media v2 [ISO 14496-12:2005]',
72
- 'isom' => 'MP4  Base Media v1 [IS0 14496-12:2003]',
73
- 'jp2' => 'JPEG 2000 Image (.JP2) [ISO 15444-1 ?]',
74
- 'jp20' => 'Unknown, from GPAC samples (prob non-existent)',
75
- 'jpm' => 'JPEG 2000 Compound Image (.JPM) [ISO 15444-6]',
76
- 'jpx' => 'JPEG 2000 w/ extensions (.JPX) [ISO 15444-2]',
77
- 'kddi' => '3GPP2 EZmovie for KDDI 3G Cellphones',
78
- 'm4a ' => 'Apple iTunes AAC-LC (.M4A) Audio',
79
- 'm4b ' => 'Apple iTunes AAC-LC (.M4B) Audio Book',
80
- 'm4p ' => 'Apple iTunes AAC-LC (.M4P) AES Protected Audio',
81
- 'm4v ' => 'Apple iTunes Video (.M4V) Video',
82
- 'm4vh' => 'Apple TV (.M4V)',
83
- 'm4vp' => 'Apple iPhone (.M4V)',
84
- 'mj2s' => 'Motion JPEG 2000 [ISO 15444-3] Simple Profile',
85
- 'mjp2' => 'Motion JPEG 2000 [ISO 15444-3] General Profile',
86
- 'mmp4' => 'MPEG-4/3GPP Mobile Profile (.MP4 / .3GP) (for NTT)',
87
- 'mp21' => 'MPEG-21 [ISO/IEC 21000-9]',
88
- 'mp41' => 'MP4 v1 [ISO 14496-1:ch13]',
89
- 'mp42' => 'MP4 v2 [ISO 14496-14]',
90
- 'mp71' => 'MP4 w/ MPEG-7 Metadata [per ISO 14496-12]',
91
- 'mppi' => 'Photo Player, MAF [ISO/IEC 23000-3]',
92
- 'mqt' => 'Sony / Mobile QuickTime (.MQV)',
93
- 'msnv' => 'MPEG-4 (.MP4) for SonyPSP',
94
- 'ndas' => 'MP4 v2 [ISO 14496-14] Nero Digital AAC Audio',
95
- 'ndsc' => 'MPEG-4 (.MP4) Nero Cinema Profile',
96
- 'ndsh' => 'MPEG-4 (.MP4) Nero HDTV Profile',
97
- 'ndsm' => 'MPEG-4 (.MP4) Nero Mobile Profile',
98
- 'ndsp' => 'MPEG-4 (.MP4) Nero Portable Profile',
99
- 'ndss' => 'MPEG-4 (.MP4) Nero Standard Profile',
100
- 'ndxc' => 'H.264/MPEG-4 AVC (.MP4) Nero Cinema Profile',
101
- 'ndxh' => 'H.264/MPEG-4 AVC (.MP4) Nero HDTV Profile',
102
- 'ndxm' => 'H.264/MPEG-4 AVC (.MP4) Nero Mobile Profile',
103
- 'ndxp' => 'H.264/MPEG-4 AVC (.MP4) Nero Portable Profile',
104
- 'ndxs' => 'H.264/MPEG-4 AVC (.MP4) Nero Standard Profile',
105
- 'odcf  ' => 'OMA DCF DRM Format 2.0 (OMA-TS-DRM-DCF-V2_0-20060303-A)',
106
- 'opf2 ' => 'OMA PDCF DRM Format 2.1 (OMA-TS-DRM-DCF-V2_1-20070724-C)',
107
- 'opx2  ' => 'OMA PDCF DRM + XBS extensions (OMA-TS-DRM_XBS-V1_0-20070529-C)',
108
- 'qt  ' => 'Apple QuickTime (.MOV/QT)',
109
- 'sdv' => 'SD Memory Card Video',
110
- );
111
-
112
-
113
- /**
114
- * Constructor
115
- *
116
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
117
- * @param int $totalSize
118
- * @param int $boxType
119
- * @param file|string $data
120
- * @param MP4Info_Box $parent
121
- * @return MP4Info_Box_ftyp
122
- * @access public
123
- * @throws MP4Info_Exception
124
- */
125
- public function __construct($totalSize, $boxType, $data, $parent) {
126
- if (!self::isCompatible($boxType, $parent)) {
127
- throw new MP4Info_Exception('This box isn\'t "ftyp"',MP4Info_Exception::CODE_INCOMPATIBLE,$boxType);
128
- }
129
-
130
- // Call ancestor
131
- parent::__construct($totalSize, $boxType, false, $parent);
132
-
133
- // Get data
134
- $data = self::getDataFrom3rd($data, $totalSize);
135
-
136
- // Unpack
137
- $ar = unpack('NmajorBrand/NminorVersion/N*compatibleBrands',$data);
138
- $compatibleBrands = array();
139
- foreach ($ar as $k=>$v) {
140
- if (substr($k,0,16) == 'compatibleBrands') {
141
- $compatibleBrands[] = $v;
142
- }
143
- }
144
-
145
- // Save properties
146
- $this->majorBrand = $ar['majorBrand'];
147
- $this->minorVersion = $ar['minorVersion'];
148
- $this->compatibleBrands = $compatibleBrands;
149
- } // Constructor
150
-
151
-
152
- /**
153
- * Check if block is compatible with class
154
- *
155
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
156
- * @param int $boxType
157
- * @param MP4Info_Box $parent
158
- * @return bool
159
- * @access public
160
- * @static
161
- */
162
- static function isCompatible($boxType, $parent) {
163
- return $boxType == 0x66747970;
164
- } // isCompatible method
165
-
166
-
167
- /**
168
- * Major brand getter
169
- *
170
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
171
- * @return int
172
- * @access public
173
- */
174
- public function getMajorBrand() {
175
- return $this->majorBrand;
176
- } // getMajorBrand method
177
-
178
-
179
- /**
180
- * Minor version getter
181
- *
182
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
183
- * @return int
184
- * @access public
185
- */
186
- public function getMinorVersion() {
187
- return $this->minorVersion;
188
- } // getMinorVersion method
189
-
190
-
191
- /**
192
- * Compatible brands getter
193
- *
194
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
195
- * @return int[]
196
- * @access public
197
- */
198
- public function getCompatibleBrands() {
199
- return $this->compatibleBrands;
200
- } // getCompatibleBrands method
201
-
202
-
203
- /**
204
- * Convert a brand 32bit code to a string
205
- *
206
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
207
- * @param int $brand
208
- * @return string
209
- * @access public
210
- * @static
211
- */
212
- public static function brandToString($brand) {
213
- if (isset(self::$brandNames[$brand])) {
214
- return self::$brandNames[$brand];
215
- } else {
216
- return $brand;
217
- }
218
- } // brandToString method
219
-
220
-
221
- /**
222
- * String converter
223
- *
224
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
225
- * @return string
226
- * @access public
227
- */
228
- public function toString() {
229
- return '[MP4Info_Box_ftyp]';
230
- } // toString method
231
- } // MP4Info_Box_ftyp method
includes/lib/MP4Info/Box/hdlr.php DELETED
@@ -1,140 +0,0 @@
1
- <?php
2
- /**
3
- * MP4Info
4
- *
5
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
6
- * @copyright Copyright (c) 2006-2009 Tommy Lacroix
7
- * @license LGPL version 3, http://www.gnu.org/licenses/lgpl.html
8
- * @package php-mp4info
9
- * @link $HeadURL: https://php-mp4info.googlecode.com/svn/trunk/MP4Info/Box/hdlr.php $
10
- */
11
-
12
- // ---
13
-
14
- /**
15
- * 8.9 Handler Reference Box (HDLR)
16
- *
17
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
18
- * @version 1.0.20090601 $Id: hdlr.php 2 2009-06-11 14:12:31Z lacroix.tommy@gmail.com $
19
- * @todo Factor this into a fullbox
20
- */
21
- class MP4Info_Box_hdlr extends MP4Info_Box {
22
- // {{{ Constants
23
- const HANDLER_VIDEO = 'vide';
24
- const HANDLER_SOUND = 'soun';
25
- // }}} Constants
26
-
27
- /**
28
- * Handler type
29
- *
30
- * @var uint32
31
- */
32
- protected $handlerType;
33
-
34
- /**
35
- * Name
36
- *
37
- * @var string
38
- */
39
- protected $name;
40
-
41
- /**
42
- * Timezone
43
- *
44
- * @var int
45
- * @static
46
- */
47
- protected static $timezone = false;
48
-
49
- /**
50
- * Constructor
51
- *
52
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
53
- * @param int $totalSize
54
- * @param int $boxType
55
- * @param file|string $data
56
- * @param MP4Info_Box $parent
57
- * @return MP4Info_Box_hdlr
58
- * @access public
59
- * @throws MP4Info_Exception
60
- */
61
- public function __construct($totalSize, $boxType, $data, $parent) {
62
- if (!self::isCompatible($boxType, $parent)) {
63
- throw new Exception('This box isn\'t "ftyp"');
64
- }
65
-
66
- // Get timezone
67
- if (self::$timezone === false) {
68
- self::$timezone = date('Z');
69
- }
70
-
71
- // Call ancestor
72
- parent::__construct($totalSize,$boxType,'',$parent);
73
-
74
- // Get data
75
- $data = self::getDataFrom3rd($data,$totalSize);
76
-
77
- // Unpack
78
- $ar = unpack('Cversion/C3flags',$data);
79
- if ($ar['version'] == 0) {
80
- // 32 bit
81
- $ar2 = unpack('Nctime/Nmtime/NtimeScale/Nduration',substr($data,4));
82
- $len = 6*4;
83
- } else if ($ar['version'] == 1) {
84
- // 64 bit
85
- $ar2 = unpack('N2ctime/N2mtime/NtimeScale/N2duration',substr($data,4));
86
- $len = 9*4;
87
- } else {
88
- throw new Exception('Unhandled version: '.$ar['version']);
89
- }
90
-
91
- // Save
92
- $this->version = $ar['version'];
93
- $this->flags = $ar['flags1']*65536+$ar['flags1']*256+$ar['flags1']*1;
94
- $this->ctime = date('r',(isset($ar2['ctime']) ? $ar2['ctime'] : $ar2['ctime1'])-2082826800-self::$timezone);
95
- $this->mtime = date('r',(isset($ar2['mtime']) ? $ar2['mtime'] : $ar2['mtime1'])-2082826800-self::$timezone);
96
- $this->timeScale = $ar2['timeScale'];
97
- $this->duration = (isset($ar2['duration']) ? $ar2['duration'] : $ar2['duration1']);
98
- $this->handlerType = substr($data,$len,4);
99
- $this->name = substr($data,$len+8,-1);
100
- } // Constructor
101
-
102
-
103
- /**
104
- * Check if block is compatible with class
105
- *
106
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
107
- * @param int $boxType
108
- * @param MP4Info_Box $parent
109
- * @return bool
110
- * @access public
111
- * @static
112
- */
113
- static public function isCompatible($boxType, $parent) {
114
- return $boxType == 0x68646c72;
115
- } // isCompatible method
116
-
117
-
118
- /**
119
- * Handler type getter
120
- *
121
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
122
- * @return int
123
- * @access public
124
- */
125
- public function getHandlerType() {
126
- return $this->handlerType;
127
- } // getHandlerType method
128
-
129
-
130
- /**
131
- * String converter
132
- *
133
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
134
- * @return string
135
- * @access public
136
- */
137
- public function toString() {
138
- return '[MP4Info_Box_hdlr:'.$this->handlerType.']';
139
- } // toString method
140
- } // MP4Info_Box_hdlr class
includes/lib/MP4Info/Box/ilst.php DELETED
@@ -1,122 +0,0 @@
1
- <?php
2
- /**
3
- * MP4Info
4
- *
5
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
6
- * @copyright Copyright (c) 2006-2009 Tommy Lacroix
7
- * @license LGPL version 3, http://www.gnu.org/licenses/lgpl.html
8
- * @package php-mp4info
9
- * @link $HeadURL: https://php-mp4info.googlecode.com/svn/trunk/MP4Info/Box/ilst.php $
10
- */
11
-
12
- // ---
13
-
14
- /**
15
- * x.x ??? (ILST)
16
- *
17
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
18
- * @version 1.0.20090601 $Id: ilst.php 2 2009-06-11 14:12:31Z lacroix.tommy@gmail.com $
19
- */
20
- class MP4Info_Box_ilst extends MP4Info_Box_Container {
21
- /**
22
- * Values
23
- *
24
- * @var {}
25
- * @access protected
26
- */
27
- protected $values = array();
28
-
29
-
30
- /**
31
- * Constructor
32
- *
33
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
34
- * @param int $totalSize
35
- * @param int $boxType
36
- * @param file|string $data
37
- * @param MP4Info_Box $parent
38
- * @return MP4Info_Box_ilst
39
- * @access public
40
- * @throws MP4Info_Exception
41
- */
42
- public function __construct($totalSize, $boxType, $data, $parent) {
43
- if (!self::isCompatible($boxType, $parent)) {
44
- throw new MP4Info_Exception('This box isn\'t "ilst"', MP4Info_Exception::CODE_INCOMPATIBLE, $boxType);
45
- }
46
-
47
- // Call ancestor
48
- parent::__construct($totalSize, $boxType, $data, $parent);
49
- } // Constructor
50
-
51
-
52
- /**
53
- * Check if block is compatible with class
54
- *
55
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
56
- * @param int $boxType
57
- * @param MP4Info_Box $parent
58
- * @return bool
59
- * @access public
60
- * @static
61
- */
62
- static public function isCompatible($boxType, $parent) {
63
- return $boxType == 0x696C7374;
64
- } // isCompatible method
65
-
66
-
67
- /**
68
- * Check if a given key has a value
69
- *
70
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
71
- * @param string $k
72
- * @return bool
73
- * @access public
74
- */
75
- public function hasValue($k) {
76
- return (isset($this->values[$k])) || (isset($this->values[utf8_decode($k)]));
77
- } // hasValue method
78
-
79
-
80
- /**
81
- * Get the value of a given key
82
- *
83
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
84
- * @param string $k
85
- * @return mixed
86
- * @access public
87
- */
88
- public function getValue($k) {
89
- if (isset($this->values[$k])) {
90
- return $this->values[$k];
91
- } else if (isset($this->values[utf8_decode($k)])) {
92
- return $this->values[utf8_decode($k)];
93
- } else {
94
- return false;
95
- }
96
- } // getValue method
97
-
98
-
99
- /**
100
- * Set a value for a given key
101
- *
102
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
103
- * @param string $k
104
- * @param mixed $v
105
- * @access public
106
- */
107
- public function setKeyValue($k,$v) {
108
- $this->values[$k] = $v;
109
- } // setKeyValue method
110
-
111
-
112
- /**
113
- * String converter
114
- *
115
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
116
- * @return string
117
- * @access public
118
- */
119
- public function toString() {
120
- return '[MP4Info_Box_ilst:'.count($this->boxes).']';
121
- } // toString method
122
- } // MP4Info_Box_ilst class
includes/lib/MP4Info/Box/ilst_sub.php DELETED
@@ -1,148 +0,0 @@
1
- <?php
2
- /**
3
- * MP4Info
4
- *
5
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
6
- * @copyright Copyright (c) 2006-2009 Tommy Lacroix
7
- * @license LGPL version 3, http://www.gnu.org/licenses/lgpl.html
8
- * @package php-mp4info
9
- * @link $HeadURL: https://php-mp4info.googlecode.com/svn/trunk/MP4Info/Box/ilst_sub.php $
10
- */
11
-
12
- // ---
13
-
14
- /**
15
- * x.x ILST sub blocks (numerous)
16
- *
17
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
18
- * @version 1.1.20090611 $Id: ilst_sub.php 2 2009-06-11 14:12:31Z lacroix.tommy@gmail.com $
19
- */
20
- class MP4Info_Box_ilst_sub extends MP4Info_Box {
21
- /**
22
- * Constructor
23
- *
24
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
25
- * @param int $totalSize
26
- * @param int $boxType
27
- * @param file|string $f
28
- * @param MP4Info_Box $parent
29
- * @return MP4Info_Box_ilst_sub
30
- * @access public
31
- * @throws MP4Info_Exception
32
- */
33
- public function __construct($totalSize, $boxType, $data, $parent) {
34
- if (!$parent instanceof MP4Info_Box_ilst) {
35
- throw new MP4Info_Exception('This box isn\'t "islt" child', MP4Info_Exception::CODE_INCOMPATIBLE, $boxType);
36
- }
37
-
38
- // Call ancestor
39
- parent::__construct($totalSize,$boxType,$data,$parent);
40
-
41
- // Get data
42
- $data = $this->data;
43
-
44
- // Unpack
45
- $type = self::getType($this->boxType);
46
- $ar = unpack('Nlen',$data);
47
- if (substr($data,4,4) == 'data') {
48
- $info = substr($data,8,$ar['len']-8);
49
- switch ($type) {
50
- case 'uint8':
51
- $info = reset(unpack('C',$info));
52
- break;
53
- case 'uint16':
54
- $info = reset(unpack('n',$info));
55
- break;
56
- case 'uint32':
57
- $info = reset(unpack('N',$info));
58
- break;
59
- case 'text':
60
- break;
61
- }
62
- $this->data = $info;
63
- $parent->setKeyValue($this->boxTypeStr, $info);
64
- } else {
65
- throw new MP4Info_Exception('Didn\'t get the "data" code');
66
- }
67
- } // Constructor
68
-
69
-
70
- /**
71
- * Check if block is compatible with class
72
- *
73
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
74
- * @param int $boxType
75
- * @param MP4Info_Box $parent
76
- * @return bool
77
- * @access public
78
- * @static
79
- */
80
- static public function isCompatible($boxType, $parent) {
81
- return ($parent instanceof MP4Info_Box_ilst);
82
- } // isCompatible method
83
-
84
-
85
- /**
86
- * Get sub type
87
- * http://atomicparsley.sourceforge.net/mpeg-4files.html
88
- *
89
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
90
- * @param int $boxType
91
- * @return string
92
- * @access protected
93
- * @static
94
- * @todo The © codes should be chr(...), as utf8 encoding messes things up
95
- */
96
- static protected function getType($boxType) {
97
- switch (pack('N',$boxType)) {
98
- case '©alb':
99
- case '©art':
100
- case 'aART':
101
- case '©cmt':
102
- case '©day':
103
- case '©nam':
104
- case '©gen':
105
- case '©wrt':
106
- case '©too':
107
- case 'cprt':
108
- case '©grp':
109
- case 'catg':
110
- case 'desc':
111
- case '©lyr':
112
- case 'tvnn':
113
- case 'tvsh':
114
- case 'tven':
115
- case 'purd':
116
- return 'text';
117
-
118
- case 'gnre':
119
- case 'trkn':
120
- case 'disk':
121
- case 'tmpo':
122
- case 'cpil':
123
- case 'rtng':
124
- case 'stik':
125
- case 'pcst':
126
- case 'purl':
127
- case 'egid':
128
- case 'tvsn':
129
- case 'tves':
130
- case 'pgap':
131
- return 'uint8';
132
- default:
133
- return '';
134
- }
135
- } // getType method
136
-
137
-
138
- /**
139
- * String converter
140
- *
141
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
142
- * @return string
143
- * @access public
144
- */
145
- public function toString() {
146
- return '[MP4Info_Box_ilst_sub['.$this->boxTypeStr.']:'.$this->getData().']';
147
- } // toString converter
148
- } // MP4Info_Box_ilst_sub class
includes/lib/MP4Info/Box/mdhd.php DELETED
@@ -1,146 +0,0 @@
1
- <?php
2
- /**
3
- * MP4Info
4
- *
5
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
6
- * @copyright Copyright (c) 2006-2009 Tommy Lacroix
7
- * @license LGPL version 3, http://www.gnu.org/licenses/lgpl.html
8
- * @package php-mp4info
9
- * @link $HeadURL: https://php-mp4info.googlecode.com/svn/trunk/MP4Info/Box/mdhd.php $
10
- */
11
-
12
- // ---
13
-
14
- /**
15
- * 8.8 Media Header Box (MDHD)
16
- *
17
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
18
- * @version 1.0.20090611 $Id: mdhd.php 2 2009-06-11 14:12:31Z lacroix.tommy@gmail.com $
19
- * @todo Factor this into a fullbox
20
- */
21
- class MP4Info_Box_mdhd extends MP4Info_Box {
22
- /**
23
- * Version
24
- *
25
- * @var int
26
- */
27
- protected $version;
28
-
29
- /**
30
- * Flags
31
- *
32
- * @var int
33
- */
34
- protected $flags;
35
-
36
- /**
37
- * Creation time
38
- *
39
- * @var string
40
- */
41
- protected $ctime;
42
-
43
- /**
44
- * Modification time
45
- *
46
- * @var unknown_type
47
- */
48
- protected $mtime;
49
-
50
- /**
51
- * Time scale
52
- *
53
- * @var int
54
- */
55
- protected $timeScale;
56
-
57
- /**
58
- * Duration
59
- *
60
- * @var int
61
- */
62
- protected $duration;
63
-
64
- /**
65
- * Time zone
66
- *
67
- * @var int
68
- * @static
69
- */
70
- protected static $timezone = false;
71
-
72
-
73
- /**
74
- * Constructor
75
- *
76
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
77
- * @param int $totalSize
78
- * @param int $boxType
79
- * @param file|string $data
80
- * @param MP4Info_Box $parent
81
- * @return MP4Info_Box_mdhd
82
- * @access public
83
- * @throws MP4Info_Exception
84
- */
85
- public function __construct($totalSize, $boxType, $data, $parent) {
86
- if (!self::isCompatible($boxType, $parent)) {
87
- throw new Exception('This box isn\'t "mdhd"');
88
- }
89
-
90
- // Get timezone
91
- if (self::$timezone === false) {
92
- self::$timezone = date('Z');
93
- }
94
-
95
- // Call ancestor
96
- parent::__construct($totalSize, $boxType, '', $parent);
97
-
98
- // Unpack
99
- $ar = unpack('Cversion/C3flags',$data);
100
- if ($ar['version'] == 0) {
101
- // 32 bit
102
- $ar2 = unpack('Nctime/Nmtime/NtimeScale/Nduration/nlanguage/ndummy',substr($data,4));
103
- } else if ($ar['version'] == 1) {
104
- // 64 bit
105
- $ar2 = unpack('N2ctime/N2mtime/NtimeScale/N2duration/nlanguage/ndummy',substr($data,4));
106
- } else {
107
- throw new Exception('Unhandled version: '.$ar['version']);
108
- }
109
-
110
- // Save
111
- $this->version = $ar['version'];
112
- $this->flags = $ar['flags1']*65536+$ar['flags1']*256+$ar['flags1']*1;
113
- $this->ctime = date('r',(isset($ar2['ctime']) ? $ar2['ctime'] : $ar2['ctime1'])-2082826800-self::$timezone);
114
- $this->mtime = date('r',(isset($ar2['mtime']) ? $ar2['mtime'] : $ar2['mtime1'])-2082826800-self::$timezone);
115
- $this->timeScale = $ar2['timeScale'];
116
- $this->duration = (isset($ar2['duration']) ? $ar2['duration'] : $ar2['duration1']);
117
- $this->language = MP4Info_Helper::fromPackedLetters($ar2['language'],1);
118
- } // Constructor
119
-
120
-
121
- /**
122
- * Check if block is compatible with class
123
- *
124
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
125
- * @param int $boxType
126
- * @param MP4Info_Box $parent
127
- * @return bool
128
- * @access public
129
- * @static
130
- */
131
- static function isCompatible($boxType, $parent) {
132
- return $boxType == 0x6d646864;
133
- } // isCompatible method
134
-
135
-
136
- /**
137
- * String converter
138
- *
139
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
140
- * @return string
141
- * @access public
142
- */
143
- public function toString() {
144
- return '[MP4Info_Box_mdhd]';
145
- } // toString method
146
- } // MP4Info_Box_mdhd class
includes/lib/MP4Info/Box/meta.php DELETED
@@ -1,69 +0,0 @@
1
- <?php
2
- /**
3
- * MP4Info
4
- *
5
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
6
- * @copyright Copyright (c) 2006-2009 Tommy Lacroix
7
- * @license LGPL version 3, http://www.gnu.org/licenses/lgpl.html
8
- * @package php-mp4info
9
- * @link $HeadURL: https://php-mp4info.googlecode.com/svn/trunk/MP4Info/Box/meta.php $
10
- */
11
-
12
- // ---
13
-
14
- /**
15
- * x.x Meta (META)
16
- *
17
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
18
- * @version 1.0.20090601 $Id: meta.php 2 2009-06-11 14:12:31Z lacroix.tommy@gmail.com $
19
- */
20
- class MP4Info_Box_meta extends MP4Info_Box_container {
21
-
22
- /**
23
- * Constructor
24
- *
25
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
26
- * @param int $totalSize
27
- * @param int $boxType
28
- * @param file|string $f
29
- * @param MP4Info_Box_meta $parent
30
- * @access public
31
- * @throws MP4Info_Exception
32
- */
33
- public function __construct($totalSize, $boxType, $data, $parent=false) {
34
- if (!self::isCompatible($boxType, $parent)) {
35
- throw new MP4Info_Exception('This box isn\'t "meta"',MP4Info_Exception::CODE_INCOMPATIBLE,false,$boxType);
36
- }
37
-
38
- $ar = unpack('Nlen',$data);
39
-
40
- parent::__construct($totalSize, $boxType, substr($data,4,$ar['len']), $parent);
41
- } // Constructor
42
-
43
-
44
- /**
45
- * Check if block is compatible with class
46
- *
47
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
48
- * @param int $boxType
49
- * @param MP4Info_Box $parent
50
- * @return bool
51
- * @access public
52
- * @static
53
- */
54
- static public function isCompatible($boxType, $parent) {
55
- return $boxType == 0x6D657461;
56
- } // isCompatible method
57
-
58
-
59
- /**
60
- * String converter
61
- *
62
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
63
- * @return string
64
- * @access public
65
- */
66
- public function toString() {
67
- return '[MP4Info_Box_meta:'.count($this->boxes).']';
68
- } // toString method
69
- } // MP4Info_Box_meta class
includes/lib/MP4Info/Box/mvhd.php DELETED
@@ -1,233 +0,0 @@
1
- <?php
2
- /**
3
- * MP4Info
4
- *
5
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
6
- * @copyright Copyright (c) 2006-2009 Tommy Lacroix
7
- * @license LGPL version 3, http://www.gnu.org/licenses/lgpl.html
8
- * @package php-mp4info
9
- * @link $HeadURL: https://php-mp4info.googlecode.com/svn/trunk/MP4Info/Box/mvhd.php $
10
- */
11
-
12
- // ---
13
-
14
- /**
15
- * x.x Movie Header (MVHD)
16
- *
17
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
18
- * @version 1.0.20090601 $Id: mvhd.php 2 2009-06-11 14:12:31Z lacroix.tommy@gmail.com $
19
- * @todo Factor this into a fullbox
20
- */
21
- class MP4Info_Box_mvhd extends MP4Info_Box {
22
- /**
23
- * Version
24
- *
25
- * @var int
26
- */
27
- protected $version;
28
-
29
- /**
30
- * Flags
31
- *
32
- * @var int
33
- */
34
- protected $flags;
35
-
36
- /**
37
- * Creation time
38
- *
39
- * @var string
40
- */
41
- protected $ctime;
42
-
43
- /**
44
- * Modification time
45
- *
46
- * @var unknown_type
47
- */
48
- protected $mtime;
49
-
50
- /**
51
- * Time scale
52
- *
53
- * @var int
54
- */
55
- protected $timeScale;
56
-
57
- /**
58
- * Duration
59
- *
60
- * @var int
61
- */
62
- protected $duration;
63
-
64
- /**
65
- * Rate
66
- *
67
- * @var int
68
- */
69
- protected $rate;
70
-
71
- /**
72
- * Volume
73
- *
74
- * @var int
75
- */
76
- protected $volume;
77
-
78
- /**
79
- * Time zone
80
- *
81
- * @var int
82
- * @static
83
- */
84
- protected static $timezone = false;
85
-
86
-
87
- /**
88
- * Constructor
89
- *
90
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
91
- * @param int $totalSize
92
- * @param int $boxType
93
- * @param file|string $data
94
- * @param MP4Info_Box $parent
95
- * @return MP4Info_Box_mvhd
96
- * @access public
97
- * @throws MP4Info_Exception
98
- */
99
- public function __construct($totalSize, $boxType, $data, $parent) {
100
- if (!self::isCompatible($boxType)) {
101
- throw new Exception('This box isn\'t "mvhd"');
102
- }
103
-
104
- // Get timezone
105
- if (self::$timezone === false) {
106
- self::$timezone = date('Z');
107
- }
108
-
109
- // Call ancestor's constructor
110
- parent::__construct($totalSize,$boxType,'',$parent);
111
-
112
- // Unpack
113
- $ar = unpack('Cversion/C3flags',$data);
114
- if ($ar['version'] == 0) {
115
- // 32 bit
116
- $ar2 = unpack('Nctime/Nmtime/NtimeScale/Nduration/Nrate/nvolume/ndummy/N2dummy2/N9matrix/N3dummy3/NnextTrack',substr($data,4));
117
- } else if ($ar['version'] == 1) {
118
- // 64 bit
119
- $ar2 = unpack('N2ctime/N2mtime/NtimeScale/N2duration/Nrate/nvolume/ndummy/N2dummy2/N9matrix/N3dummy3/NnextTrack',substr($data,4));
120
- } else {
121
- throw new Exception('Unhandled version: '.$ar['version']);
122
- }
123
-
124
- // Save
125
- $this->version = $ar['version'];
126
- $this->flags = $ar['flags1']*65536+$ar['flags1']*256+$ar['flags1']*1;
127
- $this->ctime = date('r',(isset($ar2['ctime']) ? $ar2['ctime'] : $ar2['ctime1'])-2082826800-self::$timezone);
128
- $this->mtime = date('r',(isset($ar2['mtime']) ? $ar2['mtime'] : $ar2['mtime1'])-2082826800-self::$timezone);
129
- $this->timeScale = $ar2['timeScale'];
130
- $this->duration = (isset($ar2['duration']) ? $ar2['duration'] : $ar2['duration1']);
131
- $this->rate = MP4Info_Helper::fromFixed16($ar2['rate']);
132
- $this->volume = MP4Info_Helper::fromFixed8($ar2['volume']);
133
- } // Constructor
134
-
135
-
136
- /**
137
- * Check if block is compatible with class
138
- *
139
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
140
- * @param int $boxType
141
- * @param MP4Info_Box $parent
142
- * @return bool
143
- * @access public
144
- * @static
145
- */
146
- static public function isCompatible($boxType) {
147
- return $boxType == 0x6D766864;
148
- } // isCompatible method
149
-
150
-
151
- /**
152
- * Creation time getter
153
- *
154
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
155
- * @return int
156
- * @access public
157
- */
158
- public function getCreationTime() {
159
- return $this->ctime;
160
- } // getCreationTime method
161
-
162
-
163
- /**
164
- * Time scale getter
165
- *
166
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
167
- * @return int
168
- * @access public
169
- */
170
- public function getTimeScale() {
171
- return $this->timeScale;
172
- } // getTimeScale method
173
-
174
-
175
- /**
176
- * Duration getter
177
- *
178
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
179
- * @return int
180
- * @access public
181
- */
182
- public function getDuration() {
183
- return $this->duration;
184
- } // getDuration method
185
-
186
-
187
- /**
188
- * Real duration getter
189
- *
190
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
191
- * @return float
192
- * @access public
193
- */
194
- public function getRealDuration() {
195
- return $this->duration/$this->timeScale;
196
- } // getRealDuration method
197
-
198
-
199
- /**
200
- * Rate getter
201
- *
202
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
203
- * @return int
204
- * @access public
205
- */
206
- public function getRate() {
207
- return $this->rate();
208
- } // getRate method
209
-
210
-
211
- /**
212
- * Volume getter
213
- *
214
- * @author Tommy Lacroix <lacroix.tommy@gmail.com>
215
- * @return int
216
- * @access public
217
- */
218
- public function getVolume() {
219
- return $this->volume();
220
- } // getVolume method
221
-
222
-
223