FV Flowplayer Video Player - Version 2.1.52

Version Description

  • 2014/01/10 =

  • Bugfix - critical bugfix for playlist parsing

Download this release

Release Info

Developer FolioVision
Plugin Icon 128x128 FV Flowplayer Video Player
Version 2.1.52
Comparing to
See all releases

Code changes from version 1.2.17 to 2.1.52

Files changed (86) hide show
  1. flowplayer/LICENSE.txt → LICENSE.txt +701 -720
  2. controller/backend.php +1564 -165
  3. controller/frontend.php +308 -182
  4. controller/shortcodes.php +182 -100
  5. css/ad.css +60 -0
  6. css/admin.css +99 -0
  7. css/background.png +0 -0
  8. css/bigplay.png +0 -0
  9. css/bigplay.svg +1 -0
  10. css/close1.png +0 -0
  11. css/colorbox.css +36 -0
  12. css/controls.png +0 -0
  13. css/controls.svg +1 -0
  14. css/flowplayer.css +304 -108
  15. css/img/black.png +0 -0
  16. css/img/black@x2.png +0 -0
  17. css/img/black_rtl.png +0 -0
  18. css/img/black_rtl@x2.png +0 -0
  19. css/img/exit_btn.png +0 -0
  20. css/img/flowplayer.png +0 -0
  21. css/img/media-button.png +0 -0
  22. css/img/no_play_white.png +0 -0
  23. css/img/no_play_white@x2.png +0 -0
  24. css/img/play_black.png +0 -0
  25. css/img/play_black@x2.png +0 -0
  26. css/img/play_black_rtl.png +0 -0
  27. css/img/play_black_rtl@x2.png +0 -0
  28. css/img/play_white.png +0 -0
  29. css/img/play_white@x2.png +0 -0
  30. css/img/play_white_rtl.png +0 -0
  31. css/img/play_white_rtl@x2.png +0 -0
  32. css/img/playful_black.png +0 -0
  33. css/img/playful_black@x2.png +0 -0
  34. css/img/playful_black_rtl.png +0 -0
  35. css/img/playful_black_rtl@x2.png +0 -0
  36. css/img/playful_white.png +0 -0
  37. css/img/playful_white@x2.png +0 -0
  38. css/img/playful_white_rtl.png +0 -0
  39. css/img/playful_white_rtl@x2.png +0 -0
  40. css/img/playlist-buttons.png +0 -0
  41. css/img/techinfo.png +0 -0
  42. css/img/uploader-icons.png +0 -0
  43. css/img/white.png +0 -0
  44. css/img/white@x2.png +0 -0
  45. css/img/white_rtl.png +0 -0
  46. css/img/white_rtl@x2.png +0 -0
  47. css/loading.gif +0 -0
  48. flowplayer.php +31 -5
  49. flowplayer/README.txt +0 -302
  50. flowplayer/commercial/LICENSE_COMMERCIAL.txt +0 -166
  51. flowplayer/commercial/README.txt +0 -255
  52. flowplayer/commercial/flowplayer.commercial-3.1.5.swf +0 -0
  53. flowplayer/commercial/flowplayer.controls-3.1.5.swf +0 -0
  54. flowplayer/embed.min.js +3 -0
  55. flowplayer/flowplayer.audio-3.2.2.swf +0 -0
  56. flowplayer/flowplayer.controls.swf +0 -0
  57. flowplayer/flowplayer.min.js +0 -24
  58. flowplayer/flowplayer.swf +0 -0
  59. flowplayer/fv-flowplayer.min.js +341 -0
  60. flowplayer/style.css +0 -41
  61. images/admin-bar-sprite.png +0 -0
  62. images/button-bg.png +0 -0
  63. images/fabric-plaid-bg.png +0 -0
  64. images/finished_bg.png +0 -0
  65. images/fv-wp-flowplayer-led-monitor.png +0 -0
  66. images/icon.png.toobig +0 -0
  67. images/icon.png.tootiny +0 -0
  68. images/list-bullet.png +0 -0
  69. images/play.png +0 -0
  70. images/red-button-large.png +0 -0
  71. images/red-button.png +0 -0
  72. images/replay.png +0 -0
  73. images/share.png +0 -0
  74. images/wpspin.gif +0 -0
  75. includes/extra-functions.php +131 -0
  76. includes/fp-api.php +376 -0
  77. {view → includes}/getid3/extension.cache.dbm.php +208 -222
  78. {view → includes}/getid3/extension.cache.mysql.php +171 -171
  79. includes/getid3/extension.cache.sqlite3.php +264 -0
  80. {view → includes}/getid3/getid3.lib.php +1342 -1309
  81. {view → includes}/getid3/getid3.php +1776 -1397
  82. includes/getid3/module.audio-video.flv.php +729 -0
  83. {view → includes}/getid3/module.audio-video.matroska.php +1771 -1712
  84. {view → includes}/getid3/module.audio-video.mpeg.php +296 -292
  85. includes/getid3/module.audio-video.quicktime.php +2145 -0
  86. {view → includes}/getid3/module.audio-video.real.php +0 -428
flowplayer/LICENSE.txt → LICENSE.txt RENAMED
@@ -1,721 +1,702 @@
1
- The Flowplayer Free version is released under the
2
- GNU GENERAL PUBLIC LICENSE Version 3 (GPL).
3
-
4
- The GPL requires that you not remove the Flowplayer copyright notices
5
- from the user interface. See section 5.d below.
6
-
7
- Commercial licenses are available. The commercial player version
8
- does not require any Flowplayer notices or texts and also provides
9
- some additional features.
10
-
11
- ========================================================================
12
-
13
- ADDITIONAL TERM per GPL Section 7
14
- If you convey this program (or any modifications of it) and assume
15
- contractual liability for the program to recipients of it, you agree
16
- to indemnify Flowplayer, Ltd. for any liability that those contractual
17
- assumptions impose on Flowplayer, Ltd.
18
-
19
- Except as expressly provided herein, no trademark rights are granted in
20
- any trademarks of Flowplayer, Ltd. Licensees are granted a limited,
21
- non-exclusive right to use the mark Flowplayer and the Flowplayer logos
22
- in connection with unmodified copies of the Program and the copyright
23
- notices required by section 5.d of the GPL license. For the purposes
24
- of this limited trademark license grant, customizing the Flowplayer
25
- by skinning, scripting, or including PlugIns provided by Flowplayer, Ltd.
26
- is not considered modifying the Program.
27
-
28
- Licensees that do modify the Program, taking advantage of the open-source
29
- license, may not use the Flowplayer mark or Flowplayer logos and must
30
- change the fullscreen notice (and the non-fullscreen notice, if that
31
- option is enabled), the copyright notice in the dialog box, and the
32
- notice on the Canvas as follows:
33
-
34
- the full screen (and non-fullscreen equivalent, if activated) notice
35
- should read: "Based on Flowplayer source code"; in the context menu
36
- (right-click menu), the link to "About Flowplayer free version #.#.#"
37
- can remain. The copyright notice can remain, but must be supplemented with
38
- an additional notice, stating that the licensee modified the Flowplayer.
39
- A suitable notice might read "Flowplayer Source code modified by ModOrg 2009";
40
- for the canvas, the notice should read "Based on Flowplayer source code".
41
- In addition, licensees that modify the Program must give the modified
42
- Program a new name that is not confusingly similar to Flowplayer and
43
- may not distribute it under the name Flowplayer.
44
-
45
- ========================================================================
46
-
47
-
48
- GNU GENERAL PUBLIC LICENSE
49
- Version 3, 29 June 2007
50
-
51
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
52
- Everyone is permitted to copy and distribute verbatim copies
53
- of this license document, but changing it is not allowed.
54
-
55
- Preamble
56
-
57
- The GNU General Public License is a free, copyleft license for
58
- software and other kinds of works.
59
-
60
- The licenses for most software and other practical works are designed
61
- to take away your freedom to share and change the works. By contrast,
62
- the GNU General Public License is intended to guarantee your freedom to
63
- share and change all versions of a program--to make sure it remains free
64
- software for all its users. We, the Free Software Foundation, use the
65
- GNU General Public License for most of our software; it applies also to
66
- any other work released this way by its authors. You can apply it to
67
- your programs, too.
68
-
69
- When we speak of free software, we are referring to freedom, not
70
- price. Our General Public Licenses are designed to make sure that you
71
- have the freedom to distribute copies of free software (and charge for
72
- them if you wish), that you receive source code or can get it if you
73
- want it, that you can change the software or use pieces of it in new
74
- free programs, and that you know you can do these things.
75
-
76
- To protect your rights, we need to prevent others from denying you
77
- these rights or asking you to surrender the rights. Therefore, you have
78
- certain responsibilities if you distribute copies of the software, or if
79
- you modify it: responsibilities to respect the freedom of others.
80
-
81
- For example, if you distribute copies of such a program, whether
82
- gratis or for a fee, you must pass on to the recipients the same
83
- freedoms that you received. You must make sure that they, too, receive
84
- or can get the source code. And you must show them these terms so they
85
- know their rights.
86
-
87
- Developers that use the GNU GPL protect your rights with two steps:
88
- (1) assert copyright on the software, and (2) offer you this License
89
- giving you legal permission to copy, distribute and/or modify it.
90
-
91
- For the developers' and authors' protection, the GPL clearly explains
92
- that there is no warranty for this free software. For both users' and
93
- authors' sake, the GPL requires that modified versions be marked as
94
- changed, so that their problems will not be attributed erroneously to
95
- authors of previous versions.
96
-
97
- Some devices are designed to deny users access to install or run
98
- modified versions of the software inside them, although the manufacturer
99
- can do so. This is fundamentally incompatible with the aim of
100
- protecting users' freedom to change the software. The systematic
101
- pattern of such abuse occurs in the area of products for individuals to
102
- use, which is precisely where it is most unacceptable. Therefore, we
103
- have designed this version of the GPL to prohibit the practice for those
104
- products. If such problems arise substantially in other domains, we
105
- stand ready to extend this provision to those domains in future versions
106
- of the GPL, as needed to protect the freedom of users.
107
-
108
- Finally, every program is threatened constantly by software patents.
109
- States should not allow patents to restrict development and use of
110
- software on general-purpose computers, but in those that do, we wish to
111
- avoid the special danger that patents applied to a free program could
112
- make it effectively proprietary. To prevent this, the GPL assures that
113
- patents cannot be used to render the program non-free.
114
-
115
- The precise terms and conditions for copying, distribution and
116
- modification follow.
117
-
118
- TERMS AND CONDITIONS
119
-
120
- 0. Definitions.
121
-
122
- "This License" refers to version 3 of the GNU General Public License.
123
-
124
- "Copyright" also means copyright-like laws that apply to other kinds of
125
- works, such as semiconductor masks.
126
-
127
- "The Program" refers to any copyrightable work licensed under this
128
- License. Each licensee is addressed as "you". "Licensees" and
129
- "recipients" may be individuals or organizations.
130
-
131
- To "modify" a work means to copy from or adapt all or part of the work
132
- in a fashion requiring copyright permission, other than the making of an
133
- exact copy. The resulting work is called a "modified version" of the
134
- earlier work or a work "based on" the earlier work.
135
-
136
- A "covered work" means either the unmodified Program or a work based
137
- on the Program.
138
-
139
- To "propagate" a work means to do anything with it that, without
140
- permission, would make you directly or secondarily liable for
141
- infringement under applicable copyright law, except executing it on a
142
- computer or modifying a private copy. Propagation includes copying,
143
- distribution (with or without modification), making available to the
144
- public, and in some countries other activities as well.
145
-
146
- To "convey" a work means any kind of propagation that enables other
147
- parties to make or receive copies. Mere interaction with a user through
148
- a computer network, with no transfer of a copy, is not conveying.
149
-
150
- An interactive user interface displays "Appropriate Legal Notices"
151
- to the extent that it includes a convenient and prominently visible
152
- feature that (1) displays an appropriate copyright notice, and (2)
153
- tells the user that there is no warranty for the work (except to the
154
- extent that warranties are provided), that licensees may convey the
155
- work under this License, and how to view a copy of this License. If
156
- the interface presents a list of user commands or options, such as a
157
- menu, a prominent item in the list meets this criterion.
158
-
159
- 1. Source Code.
160
-
161
- The "source code" for a work means the preferred form of the work
162
- for making modifications to it. "Object code" means any non-source
163
- form of a work.
164
-
165
- A "Standard Interface" means an interface that either is an official
166
- standard defined by a recognized standards body, or, in the case of
167
- interfaces specified for a particular programming language, one that
168
- is widely used among developers working in that language.
169
-
170
- The "System Libraries" of an executable work include anything, other
171
- than the work as a whole, that (a) is included in the normal form of
172
- packaging a Major Component, but which is not part of that Major
173
- Component, and (b) serves only to enable use of the work with that
174
- Major Component, or to implement a Standard Interface for which an
175
- implementation is available to the public in source code form. A
176
- "Major Component", in this context, means a major essential component
177
- (kernel, window system, and so on) of the specific operating system
178
- (if any) on which the executable work runs, or a compiler used to
179
- produce the work, or an object code interpreter used to run it.
180
-
181
- The "Corresponding Source" for a work in object code form means all
182
- the source code needed to generate, install, and (for an executable
183
- work) run the object code and to modify the work, including scripts to
184
- control those activities. However, it does not include the work's
185
- System Libraries, or general-purpose tools or generally available free
186
- programs which are used unmodified in performing those activities but
187
- which are not part of the work. For example, Corresponding Source
188
- includes interface definition files associated with source files for
189
- the work, and the source code for shared libraries and dynamically
190
- linked subprograms that the work is specifically designed to require,
191
- such as by intimate data communication or control flow between those
192
- subprograms and other parts of the work.
193
-
194
- The Corresponding Source need not include anything that users
195
- can regenerate automatically from other parts of the Corresponding
196
- Source.
197
-
198
- The Corresponding Source for a work in source code form is that
199
- same work.
200
-
201
- 2. Basic Permissions.
202
-
203
- All rights granted under this License are granted for the term of
204
- copyright on the Program, and are irrevocable provided the stated
205
- conditions are met. This License explicitly affirms your unlimited
206
- permission to run the unmodified Program. The output from running a
207
- covered work is covered by this License only if the output, given its
208
- content, constitutes a covered work. This License acknowledges your
209
- rights of fair use or other equivalent, as provided by copyright law.
210
-
211
- You may make, run and propagate covered works that you do not
212
- convey, without conditions so long as your license otherwise remains
213
- in force. You may convey covered works to others for the sole purpose
214
- of having them make modifications exclusively for you, or provide you
215
- with facilities for running those works, provided that you comply with
216
- the terms of this License in conveying all material for which you do
217
- not control copyright. Those thus making or running the covered works
218
- for you must do so exclusively on your behalf, under your direction
219
- and control, on terms that prohibit them from making any copies of
220
- your copyrighted material outside their relationship with you.
221
-
222
- Conveying under any other circumstances is permitted solely under
223
- the conditions stated below. Sublicensing is not allowed; section 10
224
- makes it unnecessary.
225
-
226
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
227
-
228
- No covered work shall be deemed part of an effective technological
229
- measure under any applicable law fulfilling obligations under article
230
- 11 of the WIPO copyright treaty adopted on 20 December 1996, or
231
- similar laws prohibiting or restricting circumvention of such
232
- measures.
233
-
234
- When you convey a covered work, you waive any legal power to forbid
235
- circumvention of technological measures to the extent such circumvention
236
- is effected by exercising rights under this License with respect to
237
- the covered work, and you disclaim any intention to limit operation or
238
- modification of the work as a means of enforcing, against the work's
239
- users, your or third parties' legal rights to forbid circumvention of
240
- technological measures.
241
-
242
- 4. Conveying Verbatim Copies.
243
-
244
- You may convey verbatim copies of the Program's source code as you
245
- receive it, in any medium, provided that you conspicuously and
246
- appropriately publish on each copy an appropriate copyright notice;
247
- keep intact all notices stating that this License and any
248
- non-permissive terms added in accord with section 7 apply to the code;
249
- keep intact all notices of the absence of any warranty; and give all
250
- recipients a copy of this License along with the Program.
251
-
252
- You may charge any price or no price for each copy that you convey,
253
- and you may offer support or warranty protection for a fee.
254
-
255
- 5. Conveying Modified Source Versions.
256
-
257
- You may convey a work based on the Program, or the modifications to
258
- produce it from the Program, in the form of source code under the
259
- terms of section 4, provided that you also meet all of these conditions:
260
-
261
- a) The work must carry prominent notices stating that you modified
262
- it, and giving a relevant date.
263
-
264
- b) The work must carry prominent notices stating that it is
265
- released under this License and any conditions added under section
266
- 7. This requirement modifies the requirement in section 4 to
267
- "keep intact all notices".
268
-
269
- c) You must license the entire work, as a whole, under this
270
- License to anyone who comes into possession of a copy. This
271
- License will therefore apply, along with any applicable section 7
272
- additional terms, to the whole of the work, and all its parts,
273
- regardless of how they are packaged. This License gives no
274
- permission to license the work in any other way, but it does not
275
- invalidate such permission if you have separately received it.
276
-
277
- d) If the work has interactive user interfaces, each must display
278
- Appropriate Legal Notices; however, if the Program has interactive
279
- interfaces that do not display Appropriate Legal Notices, your
280
- work need not make them do so.
281
-
282
- A compilation of a covered work with other separate and independent
283
- works, which are not by their nature extensions of the covered work,
284
- and which are not combined with it such as to form a larger program,
285
- in or on a volume of a storage or distribution medium, is called an
286
- "aggregate" if the compilation and its resulting copyright are not
287
- used to limit the access or legal rights of the compilation's users
288
- beyond what the individual works permit. Inclusion of a covered work
289
- in an aggregate does not cause this License to apply to the other
290
- parts of the aggregate.
291
-
292
- 6. Conveying Non-Source Forms.
293
-
294
- You may convey a covered work in object code form under the terms
295
- of sections 4 and 5, provided that you also convey the
296
- machine-readable Corresponding Source under the terms of this License,
297
- in one of these ways:
298
-
299
- a) Convey the object code in, or embodied in, a physical product
300
- (including a physical distribution medium), accompanied by the
301
- Corresponding Source fixed on a durable physical medium
302
- customarily used for software interchange.
303
-
304
- b) Convey the object code in, or embodied in, a physical product
305
- (including a physical distribution medium), accompanied by a
306
- written offer, valid for at least three years and valid for as
307
- long as you offer spare parts or customer support for that product
308
- model, to give anyone who possesses the object code either (1) a
309
- copy of the Corresponding Source for all the software in the
310
- product that is covered by this License, on a durable physical
311
- medium customarily used for software interchange, for a price no
312
- more than your reasonable cost of physically performing this
313
- conveying of source, or (2) access to copy the
314
- Corresponding Source from a network server at no charge.
315
-
316
- c) Convey individual copies of the object code with a copy of the
317
- written offer to provide the Corresponding Source. This
318
- alternative is allowed only occasionally and noncommercially, and
319
- only if you received the object code with such an offer, in accord
320
- with subsection 6b.
321
-
322
- d) Convey the object code by offering access from a designated
323
- place (gratis or for a charge), and offer equivalent access to the
324
- Corresponding Source in the same way through the same place at no
325
- further charge. You need not require recipients to copy the
326
- Corresponding Source along with the object code. If the place to
327
- copy the object code is a network server, the Corresponding Source
328
- may be on a different server (operated by you or a third party)
329
- that supports equivalent copying facilities, provided you maintain
330
- clear directions next to the object code saying where to find the
331
- Corresponding Source. Regardless of what server hosts the
332
- Corresponding Source, you remain obligated to ensure that it is
333
- available for as long as needed to satisfy these requirements.
334
-
335
- e) Convey the object code using peer-to-peer transmission, provided
336
- you inform other peers where the object code and Corresponding
337
- Source of the work are being offered to the general public at no
338
- charge under subsection 6d.
339
-
340
- A separable portion of the object code, whose source code is excluded
341
- from the Corresponding Source as a System Library, need not be
342
- included in conveying the object code work.
343
-
344
- A "User Product" is either (1) a "consumer product", which means any
345
- tangible personal property which is normally used for personal, family,
346
- or household purposes, or (2) anything designed or sold for incorporation
347
- into a dwelling. In determining whether a product is a consumer product,
348
- doubtful cases shall be resolved in favor of coverage. For a particular
349
- product received by a particular user, "normally used" refers to a
350
- typical or common use of that class of product, regardless of the status
351
- of the particular user or of the way in which the particular user
352
- actually uses, or expects or is expected to use, the product. A product
353
- is a consumer product regardless of whether the product has substantial
354
- commercial, industrial or non-consumer uses, unless such uses represent
355
- the only significant mode of use of the product.
356
-
357
- "Installation Information" for a User Product means any methods,
358
- procedures, authorization keys, or other information required to install
359
- and execute modified versions of a covered work in that User Product from
360
- a modified version of its Corresponding Source. The information must
361
- suffice to ensure that the continued functioning of the modified object
362
- code is in no case prevented or interfered with solely because
363
- modification has been made.
364
-
365
- If you convey an object code work under this section in, or with, or
366
- specifically for use in, a User Product, and the conveying occurs as
367
- part of a transaction in which the right of possession and use of the
368
- User Product is transferred to the recipient in perpetuity or for a
369
- fixed term (regardless of how the transaction is characterized), the
370
- Corresponding Source conveyed under this section must be accompanied
371
- by the Installation Information. But this requirement does not apply
372
- if neither you nor any third party retains the ability to install
373
- modified object code on the User Product (for example, the work has
374
- been installed in ROM).
375
-
376
- The requirement to provide Installation Information does not include a
377
- requirement to continue to provide support service, warranty, or updates
378
- for a work that has been modified or installed by the recipient, or for
379
- the User Product in which it has been modified or installed. Access to a
380
- network may be denied when the modification itself materially and
381
- adversely affects the operation of the network or violates the rules and
382
- protocols for communication across the network.
383
-
384
- Corresponding Source conveyed, and Installation Information provided,
385
- in accord with this section must be in a format that is publicly
386
- documented (and with an implementation available to the public in
387
- source code form), and must require no special password or key for
388
- unpacking, reading or copying.
389
-
390
- 7. Additional Terms.
391
-
392
- "Additional permissions" are terms that supplement the terms of this
393
- License by making exceptions from one or more of its conditions.
394
- Additional permissions that are applicable to the entire Program shall
395
- be treated as though they were included in this License, to the extent
396
- that they are valid under applicable law. If additional permissions
397
- apply only to part of the Program, that part may be used separately
398
- under those permissions, but the entire Program remains governed by
399
- this License without regard to the additional permissions.
400
-
401
- When you convey a copy of a covered work, you may at your option
402
- remove any additional permissions from that copy, or from any part of
403
- it. (Additional permissions may be written to require their own
404
- removal in certain cases when you modify the work.) You may place
405
- additional permissions on material, added by you to a covered work,
406
- for which you have or can give appropriate copyright permission.
407
-
408
- Notwithstanding any other provision of this License, for material you
409
- add to a covered work, you may (if authorized by the copyright holders of
410
- that material) supplement the terms of this License with terms:
411
-
412
- a) Disclaiming warranty or limiting liability differently from the
413
- terms of sections 15 and 16 of this License; or
414
-
415
- b) Requiring preservation of specified reasonable legal notices or
416
- author attributions in that material or in the Appropriate Legal
417
- Notices displayed by works containing it; or
418
-
419
- c) Prohibiting misrepresentation of the origin of that material, or
420
- requiring that modified versions of such material be marked in
421
- reasonable ways as different from the original version; or
422
-
423
- d) Limiting the use for publicity purposes of names of licensors or
424
- authors of the material; or
425
-
426
- e) Declining to grant rights under trademark law for use of some
427
- trade names, trademarks, or service marks; or
428
-
429
- f) Requiring indemnification of licensors and authors of that
430
- material by anyone who conveys the material (or modified versions of
431
- it) with contractual assumptions of liability to the recipient, for
432
- any liability that these contractual assumptions directly impose on
433
- those licensors and authors.
434
-
435
- All other non-permissive additional terms are considered "further
436
- restrictions" within the meaning of section 10. If the Program as you
437
- received it, or any part of it, contains a notice stating that it is
438
- governed by this License along with a term that is a further
439
- restriction, you may remove that term. If a license document contains
440
- a further restriction but permits relicensing or conveying under this
441
- License, you may add to a covered work material governed by the terms
442
- of that license document, provided that the further restriction does
443
- not survive such relicensing or conveying.
444
-
445
- If you add terms to a covered work in accord with this section, you
446
- must place, in the relevant source files, a statement of the
447
- additional terms that apply to those files, or a notice indicating
448
- where to find the applicable terms.
449
-
450
- Additional terms, permissive or non-permissive, may be stated in the
451
- form of a separately written license, or stated as exceptions;
452
- the above requirements apply either way.
453
-
454
- 8. Termination.
455
-
456
- You may not propagate or modify a covered work except as expressly
457
- provided under this License. Any attempt otherwise to propagate or
458
- modify it is void, and will automatically terminate your rights under
459
- this License (including any patent licenses granted under the third
460
- paragraph of section 11).
461
-
462
- However, if you cease all violation of this License, then your
463
- license from a particular copyright holder is reinstated (a)
464
- provisionally, unless and until the copyright holder explicitly and
465
- finally terminates your license, and (b) permanently, if the copyright
466
- holder fails to notify you of the violation by some reasonable means
467
- prior to 60 days after the cessation.
468
-
469
- Moreover, your license from a particular copyright holder is
470
- reinstated permanently if the copyright holder notifies you of the
471
- violation by some reasonable means, this is the first time you have
472
- received notice of violation of this License (for any work) from that
473
- copyright holder, and you cure the violation prior to 30 days after
474
- your receipt of the notice.
475
-
476
- Termination of your rights under this section does not terminate the
477
- licenses of parties who have received copies or rights from you under
478
- this License. If your rights have been terminated and not permanently
479
- reinstated, you do not qualify to receive new licenses for the same
480
- material under section 10.
481
-
482
- 9. Acceptance Not Required for Having Copies.
483
-
484
- You are not required to accept this License in order to receive or
485
- run a copy of the Program. Ancillary propagation of a covered work
486
- occurring solely as a consequence of using peer-to-peer transmission
487
- to receive a copy likewise does not require acceptance. However,
488
- nothing other than this License grants you permission to propagate or
489
- modify any covered work. These actions infringe copyright if you do
490
- not accept this License. Therefore, by modifying or propagating a
491
- covered work, you indicate your acceptance of this License to do so.
492
-
493
- 10. Automatic Licensing of Downstream Recipients.
494
-
495
- Each time you convey a covered work, the recipient automatically
496
- receives a license from the original licensors, to run, modify and
497
- propagate that work, subject to this License. You are not responsible
498
- for enforcing compliance by third parties with this License.
499
-
500
- An "entity transaction" is a transaction transferring control of an
501
- organization, or substantially all assets of one, or subdividing an
502
- organization, or merging organizations. If propagation of a covered
503
- work results from an entity transaction, each party to that
504
- transaction who receives a copy of the work also receives whatever
505
- licenses to the work the party's predecessor in interest had or could
506
- give under the previous paragraph, plus a right to possession of the
507
- Corresponding Source of the work from the predecessor in interest, if
508
- the predecessor has it or can get it with reasonable efforts.
509
-
510
- You may not impose any further restrictions on the exercise of the
511
- rights granted or affirmed under this License. For example, you may
512
- not impose a license fee, royalty, or other charge for exercise of
513
- rights granted under this License, and you may not initiate litigation
514
- (including a cross-claim or counterclaim in a lawsuit) alleging that
515
- any patent claim is infringed by making, using, selling, offering for
516
- sale, or importing the Program or any portion of it.
517
-
518
- 11. Patents.
519
-
520
- A "contributor" is a copyright holder who authorizes use under this
521
- License of the Program or a work on which the Program is based. The
522
- work thus licensed is called the contributor's "contributor version".
523
-
524
- A contributor's "essential patent claims" are all patent claims
525
- owned or controlled by the contributor, whether already acquired or
526
- hereafter acquired, that would be infringed by some manner, permitted
527
- by this License, of making, using, or selling its contributor version,
528
- but do not include claims that would be infringed only as a
529
- consequence of further modification of the contributor version. For
530
- purposes of this definition, "control" includes the right to grant
531
- patent sublicenses in a manner consistent with the requirements of
532
- this License.
533
-
534
- Each contributor grants you a non-exclusive, worldwide, royalty-free
535
- patent license under the contributor's essential patent claims, to
536
- make, use, sell, offer for sale, import and otherwise run, modify and
537
- propagate the contents of its contributor version.
538
-
539
- In the following three paragraphs, a "patent license" is any express
540
- agreement or commitment, however denominated, not to enforce a patent
541
- (such as an express permission to practice a patent or covenant not to
542
- sue for patent infringement). To "grant" such a patent license to a
543
- party means to make such an agreement or commitment not to enforce a
544
- patent against the party.
545
-
546
- If you convey a covered work, knowingly relying on a patent license,
547
- and the Corresponding Source of the work is not available for anyone
548
- to copy, free of charge and under the terms of this License, through a
549
- publicly available network server or other readily accessible means,
550
- then you must either (1) cause the Corresponding Source to be so
551
- available, or (2) arrange to deprive yourself of the benefit of the
552
- patent license for this particular work, or (3) arrange, in a manner
553
- consistent with the requirements of this License, to extend the patent
554
- license to downstream recipients. "Knowingly relying" means you have
555
- actual knowledge that, but for the patent license, your conveying the
556
- covered work in a country, or your recipient's use of the covered work
557
- in a country, would infringe one or more identifiable patents in that
558
- country that you have reason to believe are valid.
559
-
560
- If, pursuant to or in connection with a single transaction or
561
- arrangement, you convey, or propagate by procuring conveyance of, a
562
- covered work, and grant a patent license to some of the parties
563
- receiving the covered work authorizing them to use, propagate, modify
564
- or convey a specific copy of the covered work, then the patent license
565
- you grant is automatically extended to all recipients of the covered
566
- work and works based on it.
567
-
568
- A patent license is "discriminatory" if it does not include within
569
- the scope of its coverage, prohibits the exercise of, or is
570
- conditioned on the non-exercise of one or more of the rights that are
571
- specifically granted under this License. You may not convey a covered
572
- work if you are a party to an arrangement with a third party that is
573
- in the business of distributing software, under which you make payment
574
- to the third party based on the extent of your activity of conveying
575
- the work, and under which the third party grants, to any of the
576
- parties who would receive the covered work from you, a discriminatory
577
- patent license (a) in connection with copies of the covered work
578
- conveyed by you (or copies made from those copies), or (b) primarily
579
- for and in connection with specific products or compilations that
580
- contain the covered work, unless you entered into that arrangement,
581
- or that patent license was granted, prior to 28 March 2007.
582
-
583
- Nothing in this License shall be construed as excluding or limiting
584
- any implied license or other defenses to infringement that may
585
- otherwise be available to you under applicable patent law.
586
-
587
- 12. No Surrender of Others' Freedom.
588
-
589
- If conditions are imposed on you (whether by court order, agreement or
590
- otherwise) that contradict the conditions of this License, they do not
591
- excuse you from the conditions of this License. If you cannot convey a
592
- covered work so as to satisfy simultaneously your obligations under this
593
- License and any other pertinent obligations, then as a consequence you may
594
- not convey it at all. For example, if you agree to terms that obligate you
595
- to collect a royalty for further conveying from those to whom you convey
596
- the Program, the only way you could satisfy both those terms and this
597
- License would be to refrain entirely from conveying the Program.
598
-
599
- 13. Use with the GNU Affero General Public License.
600
-
601
- Notwithstanding any other provision of this License, you have
602
- permission to link or combine any covered work with a work licensed
603
- under version 3 of the GNU Affero General Public License into a single
604
- combined work, and to convey the resulting work. The terms of this
605
- License will continue to apply to the part which is the covered work,
606
- but the special requirements of the GNU Affero General Public License,
607
- section 13, concerning interaction through a network will apply to the
608
- combination as such.
609
-
610
- 14. Revised Versions of this License.
611
-
612
- The Free Software Foundation may publish revised and/or new versions of
613
- the GNU General Public License from time to time. Such new versions will
614
- be similar in spirit to the present version, but may differ in detail to
615
- address new problems or concerns.
616
-
617
- Each version is given a distinguishing version number. If the
618
- Program specifies that a certain numbered version of the GNU General
619
- Public License "or any later version" applies to it, you have the
620
- option of following the terms and conditions either of that numbered
621
- version or of any later version published by the Free Software
622
- Foundation. If the Program does not specify a version number of the
623
- GNU General Public License, you may choose any version ever published
624
- by the Free Software Foundation.
625
-
626
- If the Program specifies that a proxy can decide which future
627
- versions of the GNU General Public License can be used, that proxy's
628
- public statement of acceptance of a version permanently authorizes you
629
- to choose that version for the Program.
630
-
631
- Later license versions may give you additional or different
632
- permissions. However, no additional obligations are imposed on any
633
- author or copyright holder as a result of your choosing to follow a
634
- later version.
635
-
636
- 15. Disclaimer of Warranty.
637
-
638
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
639
- APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
640
- HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
641
- OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
642
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
643
- PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
644
- IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
645
- ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
646
-
647
- 16. Limitation of Liability.
648
-
649
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
650
- WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
651
- THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
652
- GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
653
- USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
654
- DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
655
- PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
656
- EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
657
- SUCH DAMAGES.
658
-
659
- 17. Interpretation of Sections 15 and 16.
660
-
661
- If the disclaimer of warranty and limitation of liability provided
662
- above cannot be given local legal effect according to their terms,
663
- reviewing courts shall apply local law that most closely approximates
664
- an absolute waiver of all civil liability in connection with the
665
- Program, unless a warranty or assumption of liability accompanies a
666
- copy of the Program in return for a fee.
667
-
668
- END OF TERMS AND CONDITIONS
669
-
670
- How to Apply These Terms to Your New Programs
671
-
672
- If you develop a new program, and you want it to be of the greatest
673
- possible use to the public, the best way to achieve this is to make it
674
- free software which everyone can redistribute and change under these terms.
675
-
676
- To do so, attach the following notices to the program. It is safest
677
- to attach them to the start of each source file to most effectively
678
- state the exclusion of warranty; and each file should have at least
679
- the "copyright" line and a pointer to where the full notice is found.
680
-
681
- <one line to give the program's name and a brief idea of what it does.>
682
- Copyright (C) <year> <name of author>
683
-
684
- This program is free software: you can redistribute it and/or modify
685
- it under the terms of the GNU General Public License as published by
686
- the Free Software Foundation, either version 3 of the License, or
687
- (at your option) any later version.
688
-
689
- This program is distributed in the hope that it will be useful,
690
- but WITHOUT ANY WARRANTY; without even the implied warranty of
691
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
692
- GNU General Public License for more details.
693
-
694
- You should have received a copy of the GNU General Public License
695
- along with this program. If not, see <http://www.gnu.org/licenses/>.
696
-
697
- Also add information on how to contact you by electronic and paper mail.
698
-
699
- If the program does terminal interaction, make it output a short
700
- notice like this when it starts in an interactive mode:
701
-
702
- <program> Copyright (C) <year> <name of author>
703
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
704
- This is free software, and you are welcome to redistribute it
705
- under certain conditions; type `show c' for details.
706
-
707
- The hypothetical commands `show w' and `show c' should show the appropriate
708
- parts of the General Public License. Of course, your program's commands
709
- might be different; for a GUI interface, you would use an "about box".
710
-
711
- You should also get your employer (if you work as a programmer) or school,
712
- if any, to sign a "copyright disclaimer" for the program, if necessary.
713
- For more information on this, and how to apply and follow the GNU GPL, see
714
- <http://www.gnu.org/licenses/>.
715
-
716
- The GNU General Public License does not permit incorporating your program
717
- into proprietary programs. If your program is a subroutine library, you
718
- may consider it more useful to permit linking proprietary applications with
719
- the library. If this is what you want to do, use the GNU Lesser General
720
- Public License instead of this License. But first, please read
721
  <http://www.gnu.org/philosophy/why-not-lgpl.html>.
1
+ ADDITIONAL TERM per GPL Section 7
2
+
3
+ If you convey this program (or any modifications of it) and assume
4
+ contractual liability for the program to recipients of it, you agree to
5
+ indemnify Flowplayer, Ltd. for any liability that those contractual
6
+ assumptions impose on Flowplayer, Ltd.
7
+
8
+ Except as expressly provided herein, no trademark rights are granted
9
+ in any trademarks of Flowplayer, Ltd. Licensees are granted a limited,
10
+ non-exclusive right to use the mark Flowplayer and the Flowplayer
11
+ logos in connection with unmodified copies of the Program and the
12
+ copyright notices required by section 5.d of the GPL license. For the
13
+ purposes of this limited trademark license grant, customizing the
14
+ Flowplayer by skinning, scripting, or including plugins provided by
15
+ Flowplayer, Ltd. is not considered modifying the Program.
16
+
17
+ Licensees that do modify the Program, taking advantage of the
18
+ open-source license, may not use the Flowplayer mark or Flowplayer
19
+ logos and must change the logo as follows:
20
+
21
+ stating that the licensee modified the Flowplayer. A suitable notice
22
+ might read "Flowplayer Source code modified by ModOrg 2012"; for the
23
+ canvas, the notice should read "Based on Flowplayer source code".
24
+
25
+ In addition, licensees that modify the Program must give the modified
26
+ Program a new name that is not confusingly similar to Flowplayer and
27
+ may not distribute it under the name Flowplayer.
28
+
29
+ GNU GENERAL PUBLIC LICENSE
30
+ Version 3, 29 June 2007
31
+
32
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
33
+ Everyone is permitted to copy and distribute verbatim copies
34
+ of this license document, but changing it is not allowed.
35
+
36
+ Preamble
37
+
38
+ The GNU General Public License is a free, copyleft license for
39
+ software and other kinds of works.
40
+
41
+ The licenses for most software and other practical works are designed
42
+ to take away your freedom to share and change the works. By contrast,
43
+ the GNU General Public License is intended to guarantee your freedom to
44
+ share and change all versions of a program--to make sure it remains free
45
+ software for all its users. We, the Free Software Foundation, use the
46
+ GNU General Public License for most of our software; it applies also to
47
+ any other work released this way by its authors. You can apply it to
48
+ your programs, too.
49
+
50
+ When we speak of free software, we are referring to freedom, not
51
+ price. Our General Public Licenses are designed to make sure that you
52
+ have the freedom to distribute copies of free software (and charge for
53
+ them if you wish), that you receive source code or can get it if you
54
+ want it, that you can change the software or use pieces of it in new
55
+ free programs, and that you know you can do these things.
56
+
57
+ To protect your rights, we need to prevent others from denying you
58
+ these rights or asking you to surrender the rights. Therefore, you have
59
+ certain responsibilities if you distribute copies of the software, or if
60
+ you modify it: responsibilities to respect the freedom of others.
61
+
62
+ For example, if you distribute copies of such a program, whether
63
+ gratis or for a fee, you must pass on to the recipients the same
64
+ freedoms that you received. You must make sure that they, too, receive
65
+ or can get the source code. And you must show them these terms so they
66
+ know their rights.
67
+
68
+ Developers that use the GNU GPL protect your rights with two steps:
69
+ (1) assert copyright on the software, and (2) offer you this License
70
+ giving you legal permission to copy, distribute and/or modify it.
71
+
72
+ For the developers' and authors' protection, the GPL clearly explains
73
+ that there is no warranty for this free software. For both users' and
74
+ authors' sake, the GPL requires that modified versions be marked as
75
+ changed, so that their problems will not be attributed erroneously to
76
+ authors of previous versions.
77
+
78
+ Some devices are designed to deny users access to install or run
79
+ modified versions of the software inside them, although the manufacturer
80
+ can do so. This is fundamentally incompatible with the aim of
81
+ protecting users' freedom to change the software. The systematic
82
+ pattern of such abuse occurs in the area of products for individuals to
83
+ use, which is precisely where it is most unacceptable. Therefore, we
84
+ have designed this version of the GPL to prohibit the practice for those
85
+ products. If such problems arise substantially in other domains, we
86
+ stand ready to extend this provision to those domains in future versions
87
+ of the GPL, as needed to protect the freedom of users.
88
+
89
+ Finally, every program is threatened constantly by software patents.
90
+ States should not allow patents to restrict development and use of
91
+ software on general-purpose computers, but in those that do, we wish to
92
+ avoid the special danger that patents applied to a free program could
93
+ make it effectively proprietary. To prevent this, the GPL assures that
94
+ patents cannot be used to render the program non-free.
95
+
96
+ The precise terms and conditions for copying, distribution and
97
+ modification follow.
98
+
99
+ TERMS AND CONDITIONS
100
+
101
+ 0. Definitions.
102
+
103
+ "This License" refers to version 3 of the GNU General Public License.
104
+
105
+ "Copyright" also means copyright-like laws that apply to other kinds of
106
+ works, such as semiconductor masks.
107
+
108
+ "The Program" refers to any copyrightable work licensed under this
109
+ License. Each licensee is addressed as "you". "Licensees" and
110
+ "recipients" may be individuals or organizations.
111
+
112
+ To "modify" a work means to copy from or adapt all or part of the work
113
+ in a fashion requiring copyright permission, other than the making of an
114
+ exact copy. The resulting work is called a "modified version" of the
115
+ earlier work or a work "based on" the earlier work.
116
+
117
+ A "covered work" means either the unmodified Program or a work based
118
+ on the Program.
119
+
120
+ To "propagate" a work means to do anything with it that, without
121
+ permission, would make you directly or secondarily liable for
122
+ infringement under applicable copyright law, except executing it on a
123
+ computer or modifying a private copy. Propagation includes copying,
124
+ distribution (with or without modification), making available to the
125
+ public, and in some countries other activities as well.
126
+
127
+ To "convey" a work means any kind of propagation that enables other
128
+ parties to make or receive copies. Mere interaction with a user through
129
+ a computer network, with no transfer of a copy, is not conveying.
130
+
131
+ An interactive user interface displays "Appropriate Legal Notices"
132
+ to the extent that it includes a convenient and prominently visible
133
+ feature that (1) displays an appropriate copyright notice, and (2)
134
+ tells the user that there is no warranty for the work (except to the
135
+ extent that warranties are provided), that licensees may convey the
136
+ work under this License, and how to view a copy of this License. If
137
+ the interface presents a list of user commands or options, such as a
138
+ menu, a prominent item in the list meets this criterion.
139
+
140
+ 1. Source Code.
141
+
142
+ The "source code" for a work means the preferred form of the work
143
+ for making modifications to it. "Object code" means any non-source
144
+ form of a work.
145
+
146
+ A "Standard Interface" means an interface that either is an official
147
+ standard defined by a recognized standards body, or, in the case of
148
+ interfaces specified for a particular programming language, one that
149
+ is widely used among developers working in that language.
150
+
151
+ The "System Libraries" of an executable work include anything, other
152
+ than the work as a whole, that (a) is included in the normal form of
153
+ packaging a Major Component, but which is not part of that Major
154
+ Component, and (b) serves only to enable use of the work with that
155
+ Major Component, or to implement a Standard Interface for which an
156
+ implementation is available to the public in source code form. A
157
+ "Major Component", in this context, means a major essential component
158
+ (kernel, window system, and so on) of the specific operating system
159
+ (if any) on which the executable work runs, or a compiler used to
160
+ produce the work, or an object code interpreter used to run it.
161
+
162
+ The "Corresponding Source" for a work in object code form means all
163
+ the source code needed to generate, install, and (for an executable
164
+ work) run the object code and to modify the work, including scripts to
165
+ control those activities. However, it does not include the work's
166
+ System Libraries, or general-purpose tools or generally available free
167
+ programs which are used unmodified in performing those activities but
168
+ which are not part of the work. For example, Corresponding Source
169
+ includes interface definition files associated with source files for
170
+ the work, and the source code for shared libraries and dynamically
171
+ linked subprograms that the work is specifically designed to require,
172
+ such as by intimate data communication or control flow between those
173
+ subprograms and other parts of the work.
174
+
175
+ The Corresponding Source need not include anything that users
176
+ can regenerate automatically from other parts of the Corresponding
177
+ Source.
178
+
179
+ The Corresponding Source for a work in source code form is that
180
+ same work.
181
+
182
+ 2. Basic Permissions.
183
+
184
+ All rights granted under this License are granted for the term of
185
+ copyright on the Program, and are irrevocable provided the stated
186
+ conditions are met. This License explicitly affirms your unlimited
187
+ permission to run the unmodified Program. The output from running a
188
+ covered work is covered by this License only if the output, given its
189
+ content, constitutes a covered work. This License acknowledges your
190
+ rights of fair use or other equivalent, as provided by copyright law.
191
+
192
+ You may make, run and propagate covered works that you do not
193
+ convey, without conditions so long as your license otherwise remains
194
+ in force. You may convey covered works to others for the sole purpose
195
+ of having them make modifications exclusively for you, or provide you
196
+ with facilities for running those works, provided that you comply with
197
+ the terms of this License in conveying all material for which you do
198
+ not control copyright. Those thus making or running the covered works
199
+ for you must do so exclusively on your behalf, under your direction
200
+ and control, on terms that prohibit them from making any copies of
201
+ your copyrighted material outside their relationship with you.
202
+
203
+ Conveying under any other circumstances is permitted solely under
204
+ the conditions stated below. Sublicensing is not allowed; section 10
205
+ makes it unnecessary.
206
+
207
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
208
+
209
+ No covered work shall be deemed part of an effective technological
210
+ measure under any applicable law fulfilling obligations under article
211
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
212
+ similar laws prohibiting or restricting circumvention of such
213
+ measures.
214
+
215
+ When you convey a covered work, you waive any legal power to forbid
216
+ circumvention of technological measures to the extent such circumvention
217
+ is effected by exercising rights under this License with respect to
218
+ the covered work, and you disclaim any intention to limit operation or
219
+ modification of the work as a means of enforcing, against the work's
220
+ users, your or third parties' legal rights to forbid circumvention of
221
+ technological measures.
222
+
223
+ 4. Conveying Verbatim Copies.
224
+
225
+ You may convey verbatim copies of the Program's source code as you
226
+ receive it, in any medium, provided that you conspicuously and
227
+ appropriately publish on each copy an appropriate copyright notice;
228
+ keep intact all notices stating that this License and any
229
+ non-permissive terms added in accord with section 7 apply to the code;
230
+ keep intact all notices of the absence of any warranty; and give all
231
+ recipients a copy of this License along with the Program.
232
+
233
+ You may charge any price or no price for each copy that you convey,
234
+ and you may offer support or warranty protection for a fee.
235
+
236
+ 5. Conveying Modified Source Versions.
237
+
238
+ You may convey a work based on the Program, or the modifications to
239
+ produce it from the Program, in the form of source code under the
240
+ terms of section 4, provided that you also meet all of these conditions:
241
+
242
+ a) The work must carry prominent notices stating that you modified
243
+ it, and giving a relevant date.
244
+
245
+ b) The work must carry prominent notices stating that it is
246
+ released under this License and any conditions added under section
247
+ 7. This requirement modifies the requirement in section 4 to
248
+ "keep intact all notices".
249
+
250
+ c) You must license the entire work, as a whole, under this
251
+ License to anyone who comes into possession of a copy. This
252
+ License will therefore apply, along with any applicable section 7
253
+ additional terms, to the whole of the work, and all its parts,
254
+ regardless of how they are packaged. This License gives no
255
+ permission to license the work in any other way, but it does not
256
+ invalidate such permission if you have separately received it.
257
+
258
+ d) If the work has interactive user interfaces, each must display
259
+ Appropriate Legal Notices; however, if the Program has interactive
260
+ interfaces that do not display Appropriate Legal Notices, your
261
+ work need not make them do so.
262
+
263
+ A compilation of a covered work with other separate and independent
264
+ works, which are not by their nature extensions of the covered work,
265
+ and which are not combined with it such as to form a larger program,
266
+ in or on a volume of a storage or distribution medium, is called an
267
+ "aggregate" if the compilation and its resulting copyright are not
268
+ used to limit the access or legal rights of the compilation's users
269
+ beyond what the individual works permit. Inclusion of a covered work
270
+ in an aggregate does not cause this License to apply to the other
271
+ parts of the aggregate.
272
+
273
+ 6. Conveying Non-Source Forms.
274
+
275
+ You may convey a covered work in object code form under the terms
276
+ of sections 4 and 5, provided that you also convey the
277
+ machine-readable Corresponding Source under the terms of this License,
278
+ in one of these ways:
279
+
280
+ a) Convey the object code in, or embodied in, a physical product
281
+ (including a physical distribution medium), accompanied by the
282
+ Corresponding Source fixed on a durable physical medium
283
+ customarily used for software interchange.
284
+
285
+ b) Convey the object code in, or embodied in, a physical product
286
+ (including a physical distribution medium), accompanied by a
287
+ written offer, valid for at least three years and valid for as
288
+ long as you offer spare parts or customer support for that product
289
+ model, to give anyone who possesses the object code either (1) a
290
+ copy of the Corresponding Source for all the software in the
291
+ product that is covered by this License, on a durable physical
292
+ medium customarily used for software interchange, for a price no
293
+ more than your reasonable cost of physically performing this
294
+ conveying of source, or (2) access to copy the
295
+ Corresponding Source from a network server at no charge.
296
+
297
+ c) Convey individual copies of the object code with a copy of the
298
+ written offer to provide the Corresponding Source. This
299
+ alternative is allowed only occasionally and noncommercially, and
300
+ only if you received the object code with such an offer, in accord
301
+ with subsection 6b.
302
+
303
+ d) Convey the object code by offering access from a designated
304
+ place (gratis or for a charge), and offer equivalent access to the
305
+ Corresponding Source in the same way through the same place at no
306
+ further charge. You need not require recipients to copy the
307
+ Corresponding Source along with the object code. If the place to
308
+ copy the object code is a network server, the Corresponding Source
309
+ may be on a different server (operated by you or a third party)
310
+ that supports equivalent copying facilities, provided you maintain
311
+ clear directions next to the object code saying where to find the
312
+ Corresponding Source. Regardless of what server hosts the
313
+ Corresponding Source, you remain obligated to ensure that it is
314
+ available for as long as needed to satisfy these requirements.
315
+
316
+ e) Convey the object code using peer-to-peer transmission, provided
317
+ you inform other peers where the object code and Corresponding
318
+ Source of the work are being offered to the general public at no
319
+ charge under subsection 6d.
320
+
321
+ A separable portion of the object code, whose source code is excluded
322
+ from the Corresponding Source as a System Library, need not be
323
+ included in conveying the object code work.
324
+
325
+ A "User Product" is either (1) a "consumer product", which means any
326
+ tangible personal property which is normally used for personal, family,
327
+ or household purposes, or (2) anything designed or sold for incorporation
328
+ into a dwelling. In determining whether a product is a consumer product,
329
+ doubtful cases shall be resolved in favor of coverage. For a particular
330
+ product received by a particular user, "normally used" refers to a
331
+ typical or common use of that class of product, regardless of the status
332
+ of the particular user or of the way in which the particular user
333
+ actually uses, or expects or is expected to use, the product. A product
334
+ is a consumer product regardless of whether the product has substantial
335
+ commercial, industrial or non-consumer uses, unless such uses represent
336
+ the only significant mode of use of the product.
337
+
338
+ "Installation Information" for a User Product means any methods,
339
+ procedures, authorization keys, or other information required to install
340
+ and execute modified versions of a covered work in that User Product from
341
+ a modified version of its Corresponding Source. The information must
342
+ suffice to ensure that the continued functioning of the modified object
343
+ code is in no case prevented or interfered with solely because
344
+ modification has been made.
345
+
346
+ If you convey an object code work under this section in, or with, or
347
+ specifically for use in, a User Product, and the conveying occurs as
348
+ part of a transaction in which the right of possession and use of the
349
+ User Product is transferred to the recipient in perpetuity or for a
350
+ fixed term (regardless of how the transaction is characterized), the
351
+ Corresponding Source conveyed under this section must be accompanied
352
+ by the Installation Information. But this requirement does not apply
353
+ if neither you nor any third party retains the ability to install
354
+ modified object code on the User Product (for example, the work has
355
+ been installed in ROM).
356
+
357
+ The requirement to provide Installation Information does not include a
358
+ requirement to continue to provide support service, warranty, or updates
359
+ for a work that has been modified or installed by the recipient, or for
360
+ the User Product in which it has been modified or installed. Access to a
361
+ network may be denied when the modification itself materially and
362
+ adversely affects the operation of the network or violates the rules and
363
+ protocols for communication across the network.
364
+
365
+ Corresponding Source conveyed, and Installation Information provided,
366
+ in accord with this section must be in a format that is publicly
367
+ documented (and with an implementation available to the public in
368
+ source code form), and must require no special password or key for
369
+ unpacking, reading or copying.
370
+
371
+ 7. Additional Terms.
372
+
373
+ "Additional permissions" are terms that supplement the terms of this
374
+ License by making exceptions from one or more of its conditions.
375
+ Additional permissions that are applicable to the entire Program shall
376
+ be treated as though they were included in this License, to the extent
377
+ that they are valid under applicable law. If additional permissions
378
+ apply only to part of the Program, that part may be used separately
379
+ under those permissions, but the entire Program remains governed by
380
+ this License without regard to the additional permissions.
381
+
382
+ When you convey a copy of a covered work, you may at your option
383
+ remove any additional permissions from that copy, or from any part of
384
+ it. (Additional permissions may be written to require their own
385
+ removal in certain cases when you modify the work.) You may place
386
+ additional permissions on material, added by you to a covered work,
387
+ for which you have or can give appropriate copyright permission.
388
+
389
+ Notwithstanding any other provision of this License, for material you
390
+ add to a covered work, you may (if authorized by the copyright holders of
391
+ that material) supplement the terms of this License with terms:
392
+
393
+ a) Disclaiming warranty or limiting liability differently from the
394
+ terms of sections 15 and 16 of this License; or
395
+
396
+ b) Requiring preservation of specified reasonable legal notices or
397
+ author attributions in that material or in the Appropriate Legal
398
+ Notices displayed by works containing it; or
399
+
400
+ c) Prohibiting misrepresentation of the origin of that material, or
401
+ requiring that modified versions of such material be marked in
402
+ reasonable ways as different from the original version; or
403
+
404
+ d) Limiting the use for publicity purposes of names of licensors or
405
+ authors of the material; or
406
+
407
+ e) Declining to grant rights under trademark law for use of some
408
+ trade names, trademarks, or service marks; or
409
+
410
+ f) Requiring indemnification of licensors and authors of that
411
+ material by anyone who conveys the material (or modified versions of
412
+ it) with contractual assumptions of liability to the recipient, for
413
+ any liability that these contractual assumptions directly impose on
414
+ those licensors and authors.
415
+
416
+ All other non-permissive additional terms are considered "further
417
+ restrictions" within the meaning of section 10. If the Program as you
418
+ received it, or any part of it, contains a notice stating that it is
419
+ governed by this License along with a term that is a further
420
+ restriction, you may remove that term. If a license document contains
421
+ a further restriction but permits relicensing or conveying under this
422
+ License, you may add to a covered work material governed by the terms
423
+ of that license document, provided that the further restriction does
424
+ not survive such relicensing or conveying.
425
+
426
+ If you add terms to a covered work in accord with this section, you
427
+ must place, in the relevant source files, a statement of the
428
+ additional terms that apply to those files, or a notice indicating
429
+ where to find the applicable terms.
430
+
431
+ Additional terms, permissive or non-permissive, may be stated in the
432
+ form of a separately written license, or stated as exceptions;
433
+ the above requirements apply either way.
434
+
435
+ 8. Termination.
436
+
437
+ You may not propagate or modify a covered work except as expressly
438
+ provided under this License. Any attempt otherwise to propagate or
439
+ modify it is void, and will automatically terminate your rights under
440
+ this License (including any patent licenses granted under the third
441
+ paragraph of section 11).
442
+
443
+ However, if you cease all violation of this License, then your
444
+ license from a particular copyright holder is reinstated (a)
445
+ provisionally, unless and until the copyright holder explicitly and
446
+ finally terminates your license, and (b) permanently, if the copyright
447
+ holder fails to notify you of the violation by some reasonable means
448
+ prior to 60 days after the cessation.
449
+
450
+ Moreover, your license from a particular copyright holder is
451
+ reinstated permanently if the copyright holder notifies you of the
452
+ violation by some reasonable means, this is the first time you have
453
+ received notice of violation of this License (for any work) from that
454
+ copyright holder, and you cure the violation prior to 30 days after
455
+ your receipt of the notice.
456
+
457
+ Termination of your rights under this section does not terminate the
458
+ licenses of parties who have received copies or rights from you under
459
+ this License. If your rights have been terminated and not permanently
460
+ reinstated, you do not qualify to receive new licenses for the same
461
+ material under section 10.
462
+
463
+ 9. Acceptance Not Required for Having Copies.
464
+
465
+ You are not required to accept this License in order to receive or
466
+ run a copy of the Program. Ancillary propagation of a covered work
467
+ occurring solely as a consequence of using peer-to-peer transmission
468
+ to receive a copy likewise does not require acceptance. However,
469
+ nothing other than this License grants you permission to propagate or
470
+ modify any covered work. These actions infringe copyright if you do
471
+ not accept this License. Therefore, by modifying or propagating a
472
+ covered work, you indicate your acceptance of this License to do so.
473
+
474
+ 10. Automatic Licensing of Downstream Recipients.
475
+
476
+ Each time you convey a covered work, the recipient automatically
477
+ receives a license from the original licensors, to run, modify and
478
+ propagate that work, subject to this License. You are not responsible
479
+ for enforcing compliance by third parties with this License.
480
+
481
+ An "entity transaction" is a transaction transferring control of an
482
+ organization, or substantially all assets of one, or subdividing an
483
+ organization, or merging organizations. If propagation of a covered
484
+ work results from an entity transaction, each party to that
485
+ transaction who receives a copy of the work also receives whatever
486
+ licenses to the work the party's predecessor in interest had or could
487
+ give under the previous paragraph, plus a right to possession of the
488
+ Corresponding Source of the work from the predecessor in interest, if
489
+ the predecessor has it or can get it with reasonable efforts.
490
+
491
+ You may not impose any further restrictions on the exercise of the
492
+ rights granted or affirmed under this License. For example, you may
493
+ not impose a license fee, royalty, or other charge for exercise of
494
+ rights granted under this License, and you may not initiate litigation
495
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
496
+ any patent claim is infringed by making, using, selling, offering for
497
+ sale, or importing the Program or any portion of it.
498
+
499
+ 11. Patents.
500
+
501
+ A "contributor" is a copyright holder who authorizes use under this
502
+ License of the Program or a work on which the Program is based. The
503
+ work thus licensed is called the contributor's "contributor version".
504
+
505
+ A contributor's "essential patent claims" are all patent claims
506
+ owned or controlled by the contributor, whether already acquired or
507
+ hereafter acquired, that would be infringed by some manner, permitted
508
+ by this License, of making, using, or selling its contributor version,
509
+ but do not include claims that would be infringed only as a
510
+ consequence of further modification of the contributor version. For
511
+ purposes of this definition, "control" includes the right to grant
512
+ patent sublicenses in a manner consistent with the requirements of
513
+ this License.
514
+
515
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
516
+ patent license under the contributor's essential patent claims, to
517
+ make, use, sell, offer for sale, import and otherwise run, modify and
518
+ propagate the contents of its contributor version.
519
+
520
+ In the following three paragraphs, a "patent license" is any express
521
+ agreement or commitment, however denominated, not to enforce a patent
522
+ (such as an express permission to practice a patent or covenant not to
523
+ sue for patent infringement). To "grant" such a patent license to a
524
+ party means to make such an agreement or commitment not to enforce a
525
+ patent against the party.
526
+
527
+ If you convey a covered work, knowingly relying on a patent license,
528
+ and the Corresponding Source of the work is not available for anyone
529
+ to copy, free of charge and under the terms of this License, through a
530
+ publicly available network server or other readily accessible means,
531
+ then you must either (1) cause the Corresponding Source to be so
532
+ available, or (2) arrange to deprive yourself of the benefit of the
533
+ patent license for this particular work, or (3) arrange, in a manner
534
+ consistent with the requirements of this License, to extend the patent
535
+ license to downstream recipients. "Knowingly relying" means you have
536
+ actual knowledge that, but for the patent license, your conveying the
537
+ covered work in a country, or your recipient's use of the covered work
538
+ in a country, would infringe one or more identifiable patents in that
539
+ country that you have reason to believe are valid.
540
+
541
+ If, pursuant to or in connection with a single transaction or
542
+ arrangement, you convey, or propagate by procuring conveyance of, a
543
+ covered work, and grant a patent license to some of the parties
544
+ receiving the covered work authorizing them to use, propagate, modify
545
+ or convey a specific copy of the covered work, then the patent license
546
+ you grant is automatically extended to all recipients of the covered
547
+ work and works based on it.
548
+
549
+ A patent license is "discriminatory" if it does not include within
550
+ the scope of its coverage, prohibits the exercise of, or is
551
+ conditioned on the non-exercise of one or more of the rights that are
552
+ specifically granted under this License. You may not convey a covered
553
+ work if you are a party to an arrangement with a third party that is
554
+ in the business of distributing software, under which you make payment
555
+ to the third party based on the extent of your activity of conveying
556
+ the work, and under which the third party grants, to any of the
557
+ parties who would receive the covered work from you, a discriminatory
558
+ patent license (a) in connection with copies of the covered work
559
+ conveyed by you (or copies made from those copies), or (b) primarily
560
+ for and in connection with specific products or compilations that
561
+ contain the covered work, unless you entered into that arrangement,
562
+ or that patent license was granted, prior to 28 March 2007.
563
+
564
+ Nothing in this License shall be construed as excluding or limiting
565
+ any implied license or other defenses to infringement that may
566
+ otherwise be available to you under applicable patent law.
567
+
568
+ 12. No Surrender of Others' Freedom.
569
+
570
+ If conditions are imposed on you (whether by court order, agreement or
571
+ otherwise) that contradict the conditions of this License, they do not
572
+ excuse you from the conditions of this License. If you cannot convey a
573
+ covered work so as to satisfy simultaneously your obligations under this
574
+ License and any other pertinent obligations, then as a consequence you may
575
+ not convey it at all. For example, if you agree to terms that obligate you
576
+ to collect a royalty for further conveying from those to whom you convey
577
+ the Program, the only way you could satisfy both those terms and this
578
+ License would be to refrain entirely from conveying the Program.
579
+
580
+ 13. Use with the GNU Affero General Public License.
581
+
582
+ Notwithstanding any other provision of this License, you have
583
+ permission to link or combine any covered work with a work licensed
584
+ under version 3 of the GNU Affero General Public License into a single
585
+ combined work, and to convey the resulting work. The terms of this
586
+ License will continue to apply to the part which is the covered work,
587
+ but the special requirements of the GNU Affero General Public License,
588
+ section 13, concerning interaction through a network will apply to the
589
+ combination as such.
590
+
591
+ 14. Revised Versions of this License.
592
+
593
+ The Free Software Foundation may publish revised and/or new versions of
594
+ the GNU General Public License from time to time. Such new versions will
595
+ be similar in spirit to the present version, but may differ in detail to
596
+ address new problems or concerns.
597
+
598
+ Each version is given a distinguishing version number. If the
599
+ Program specifies that a certain numbered version of the GNU General
600
+ Public License "or any later version" applies to it, you have the
601
+ option of following the terms and conditions either of that numbered
602
+ version or of any later version published by the Free Software
603
+ Foundation. If the Program does not specify a version number of the
604
+ GNU General Public License, you may choose any version ever published
605
+ by the Free Software Foundation.
606
+
607
+ If the Program specifies that a proxy can decide which future
608
+ versions of the GNU General Public License can be used, that proxy's
609
+ public statement of acceptance of a version permanently authorizes you
610
+ to choose that version for the Program.
611
+
612
+ Later license versions may give you additional or different
613
+ permissions. However, no additional obligations are imposed on any
614
+ author or copyright holder as a result of your choosing to follow a
615
+ later version.
616
+
617
+ 15. Disclaimer of Warranty.
618
+
619
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
620
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
621
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
622
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
623
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
624
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
625
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
626
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
627
+
628
+ 16. Limitation of Liability.
629
+
630
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
631
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
632
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
633
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
634
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
635
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
636
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
637
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
638
+ SUCH DAMAGES.
639
+
640
+ 17. Interpretation of Sections 15 and 16.
641
+
642
+ If the disclaimer of warranty and limitation of liability provided
643
+ above cannot be given local legal effect according to their terms,
644
+ reviewing courts shall apply local law that most closely approximates
645
+ an absolute waiver of all civil liability in connection with the
646
+ Program, unless a warranty or assumption of liability accompanies a
647
+ copy of the Program in return for a fee.
648
+
649
+ END OF TERMS AND CONDITIONS
650
+
651
+ How to Apply These Terms to Your New Programs
652
+
653
+ If you develop a new program, and you want it to be of the greatest
654
+ possible use to the public, the best way to achieve this is to make it
655
+ free software which everyone can redistribute and change under these terms.
656
+
657
+ To do so, attach the following notices to the program. It is safest
658
+ to attach them to the start of each source file to most effectively
659
+ state the exclusion of warranty; and each file should have at least
660
+ the "copyright" line and a pointer to where the full notice is found.
661
+
662
+ <one line to give the program's name and a brief idea of what it does.>
663
+ Copyright (C) <year> <name of author>
664
+
665
+ This program is free software: you can redistribute it and/or modify
666
+ it under the terms of the GNU General Public License as published by
667
+ the Free Software Foundation, either version 3 of the License, or
668
+ (at your option) any later version.
669
+
670
+ This program is distributed in the hope that it will be useful,
671
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
672
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
673
+ GNU General Public License for more details.
674
+
675
+ You should have received a copy of the GNU General Public License
676
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
677
+
678
+ Also add information on how to contact you by electronic and paper mail.
679
+
680
+ If the program does terminal interaction, make it output a short
681
+ notice like this when it starts in an interactive mode:
682
+
683
+ <program> Copyright (C) <year> <name of author>
684
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
685
+ This is free software, and you are welcome to redistribute it
686
+ under certain conditions; type `show c' for details.
687
+
688
+ The hypothetical commands `show w' and `show c' should show the appropriate
689
+ parts of the General Public License. Of course, your program's commands
690
+ might be different; for a GUI interface, you would use an "about box".
691
+
692
+ You should also get your employer (if you work as a programmer) or school,
693
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
694
+ For more information on this, and how to apply and follow the GNU GPL, see
695
+ <http://www.gnu.org/licenses/>.
696
+
697
+ The GNU General Public License does not permit incorporating your program
698
+ into proprietary programs. If your program is a subroutine library, you
699
+ may consider it more useful to permit linking proprietary applications with
700
+ the library. If this is what you want to do, use the GNU Lesser General
701
+ Public License instead of this License. But first, please read
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
702
  <http://www.gnu.org/philosophy/why-not-lgpl.html>.
controller/backend.php CHANGED
@@ -1,166 +1,1565 @@
1
- <?php
2
- /**
3
- * Needed includes
4
- */
5
- include_once(dirname( __FILE__ ) . '/../models/flowplayer.php');
6
- include_once(dirname( __FILE__ ) . '/../models/flowplayer-backend.php');
7
- /**
8
- * Create the flowplayer_backend object
9
- */
10
- $fp = new flowplayer_backend();
11
- /**
12
- * WP Hooks
13
- */
14
- add_action('admin_head', 'flowplayer_head');
15
- add_action('admin_menu', 'flowplayer_admin');
16
- add_action('media_buttons', 'flowplayer_add_media_button', 30);
17
- add_action('media_upload_fv-wp-flowplayer', 'flowplayer_wizard');
18
- add_action('admin_init', 'fv_flowplayer_init');
19
- if(isset($_POST['_wp_http_referer']) && (strpos($_POST['_wp_http_referer'],'fvplayer')))
20
- add_filter('media_send_to_editor','fp_media_send_to_editor', 10, 3);
21
- add_action('the_content', 'flowplayer_content_remove_commas');
22
- function fv_flowplayer_init()
23
- {
24
- add_action( 'wp_ajax_fvp_ajax_action_checkvideo', 'fvp_ajax_action_checkvideo' );
25
- global $wp_rewrite;
26
- // $wp_rewrite->flush_rules(false);
27
- }
28
- function flowplayer_content_remove_commas($content){
29
- preg_match('/.*popup=\'(.*?)\'.*/', $content, $matches);
30
- $content_new = preg_replace('/\,/', '',$content);
31
- if (isset($matches[1]))
32
- $content_new = preg_replace('/popup=\'(.*?)\'/', 'popup=\''.$matches[1].'\'',$content_new);
33
- return $content_new;
34
- }
35
- /**
36
- * END WP Hooks
37
- */
38
- function fp_media_send_to_editor($html, $attachment_id, $attachment){
39
- if(isset($_POST['_wp_http_referer']) && (strpos($_POST['_wp_http_referer'],'fvplayer'))) {
40
- preg_match('/height=([0-9]+([a-z]+))/',$_POST['_wp_http_referer'],$matchesh);
41
- $video_flag = substr($matchesh[2],8);
42
- if (isset($attachment_id))
43
- {
44
- $attachment_url = wp_get_attachment_url($attachment_id);
45
- $path_parts = pathinfo($attachment_url);
46
- switch ($video_flag){
47
- case 'splash': setcookie("selected_image",$attachment_url);
48
- $selected_attachment = array('url'=>$attachment_url,'id'=>$attachment_id,'type'=>'splash');
49
- $uploaded_image = $attachment_url;
50
- break;
51
- case 'normal': setcookie("selected_video",$attachment_url);
52
- $selected_attachment = array('url'=>$attachment_url,'type'=>'normal');
53
- $uploaded_video = $attachment_url;
54
- break;
55
- case 'low': setcookie("selected_video_low",$attachment_url);
56
- $selected_attachment = array('url'=>$attachment_url,'type'=>'low');
57
- $uploaded_video_mobile = $attachment_url;
58
- break;
59
- case 'mobile': setcookie("selected_video_mobile",$attachment_url);
60
- $selected_attachment = array('url'=>$attachment_url,'type'=>'mobile');
61
- $uploaded_video_mobile = $attachment_url;
62
- break;
63
- case 'webm': setcookie("selected_video_webm",$attachment_url);
64
- $selected_attachment = array('url'=>$attachment_url,'type'=>'webm');
65
- $uploaded_video_mobile = $attachment_url;
66
- break;
67
- case 'trigp': setcookie("selected_video_3gp",$attachment_url);
68
- $selected_attachment = array('url'=>$attachment_url,'type'=>'3gp');
69
- $uploaded_video_mobile = $attachment_url;
70
- break;
71
- }
72
- }
73
- wp_enqueue_style('media');
74
- wp_iframe('flowplayer_wizard_function',$selected_attachment);
75
- die;
76
- }
77
- }
78
- function flowplayer_wizard() {
79
- //do the magic here
80
- setcookie("selected_video",'',time()-3600);
81
- setcookie("selected_image",'',time()-3600);
82
- wp_enqueue_style('media');
83
- wp_iframe('flowplayer_wizard_function','');
84
- }
85
- function flowplayer_wizard_function($selected_attachment) {
86
- if(get_option('wp_mobile_video_active')=='enabled')
87
- include dirname( __FILE__ ) . '/../../wp-mobile-video-player/view/wizard.php'; /// use the extended wizard
88
- else
89
- include dirname( __FILE__ ) . '/../view/wizard.php';
90
- }
91
- /**
92
- * Administrator environment function.
93
- */
94
- function flowplayer_admin () {
95
- // if we are in administrator environment
96
- if (function_exists('add_submenu_page')) {
97
- add_options_page(
98
- 'FV Wordpress Flowplayer',
99
- 'FV Wordpress Flowplayer',
100
- 8,
101
- basename(__FILE__),
102
- 'flowplayer_page'
103
- );
104
- }
105
- }
106
- /**
107
- * Outputs HTML code for bool options based on arg passed.
108
- * @param string Currently selected value ('true' or 'false').
109
- * @return string HTML code
110
- */
111
- function flowplayer_bool_select($current) {
112
- switch($current) {
113
- case "true":
114
- $html = '<option selected="selected" value="true">true</option><option value="false">false</option>';
115
- break;
116
- case "false":
117
- $html = '<option value="true" >true</option><option selected="selected" value="false">false</option>';
118
- break;
119
- default:
120
- $html = '<option value="true">true</option><option selected="selected" value="false">false</option>';
121
- break;
122
- }
123
- return $html;
124
- }
125
- /**
126
- * Displays administrator menu with configuration.
127
- */
128
- function flowplayer_page() {
129
- //initialize the class:
130
- $fp = new flowplayer();
131
- include dirname( __FILE__ ) . '/../view/admin.php';
132
- }
133
- /**
134
- * Checks for errors regarding access to configuration file. Displays errors if any occur.
135
- * @param object $fp Flowplayer class object.
136
- */
137
- function flowplayer_check_errors($fp){
138
- $html = '';
139
- // config file checks, exists, readable, writeable
140
- $conf_file = realpath(dirname(__FILE__)).'/wpfp.conf'; //Zdenka: I think here should be /../
141
- if(!file_exists($conf_file)){
142
- $html .= '<h3 style="font-weight: bold; color: #ff0000">'.$conf_file.' Does not exist please create it</h3>';
143
- } elseif(!is_readable($conf_file)){
144
- $html .= '<h3 style="font-weight: bold; color: #ff0000">'.$conf_file.' is not readable please check file permissions</h3>';
145
- } elseif(!is_writable($conf_file)){
146
- $html .= '<h3 style="font-weight: bold; color: #ff0000">'.$conf_file.' is not writable please check file permissions</h3>';
147
- }
148
- // return $html; //Zdenka : Why is this not here?
149
- }
150
- function flowplayer_add_media_button(){
151
- global $post;
152
- $plugins = get_option('active_plugins');
153
- $found = false;
154
- foreach ( $plugins AS $plugin ) {
155
- if( stripos($plugin,'foliopress-wysiwyg') !== FALSE )
156
- $found = true;
157
- }
158
- if(!$found)
159
- {
160
- $button_tip = 'Insert a Flash Video Player';
161
- $wizard_url = 'media-upload.php?post_id='.$post->ID.'&type=fv-wp-flowplayer';
162
- $button_src = RELATIVE_PATH.'/images/icon.png';
163
- echo '<a title="Add FV WP Flowplayer" href="'.$wizard_url.'&TB_iframe=true&width=500&height=300" class="thickbox" ><img src="' . $button_src . '" alt="' . $button_tip . '" /></a>';
164
- }
165
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  ?>
1
+ <?php
2
+
3
+ /* FV Wordpress Flowplayer - HTML5 video player with Flash fallback
4
+ Copyright (C) 2013 Foliovision
5
+
6
+ This program is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation, either version 3 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ include_once(dirname( __FILE__ ) . '/../models/flowplayer.php');
21
+ include_once(dirname( __FILE__ ) . '/../models/flowplayer-backend.php');
22
+
23
+ /**
24
+ * Create the flowplayer_backend object
25
+ */
26
+ $fv_fp = new flowplayer_backend();
27
+
28
+ /**
29
+ * WP Hooks
30
+ */
31
+ add_action('wp_ajax_fv_wp_flowplayer_support_mail', 'fv_wp_flowplayer_support_mail');
32
+ add_action('wp_ajax_fv_wp_flowplayer_check_mimetype', 'fv_wp_flowplayer_check_mimetype');
33
+ add_action('wp_ajax_fv_wp_flowplayer_check_template', 'fv_wp_flowplayer_check_template');
34
+ add_action('wp_ajax_fv_wp_flowplayer_check_files', 'fv_wp_flowplayer_check_files');
35
+
36
+ add_action('admin_head', 'flowplayer_head');
37
+ add_action('admin_menu', 'flowplayer_admin');
38
+ add_action('media_buttons', 'flowplayer_add_media_button', 30);
39
+
40
+
41
+ add_action('admin_init', 'fv_wp_flowplayer_admin_init');
42
+ add_action( 'wp_ajax_fv_foliopress_ajax_pointers', 'fv_wp_flowplayer_pointers_ajax' );
43
+ add_action('media_upload_fvplayer_video', 'fv_wp_flowplayer_media_upload');
44
+ add_action('media_upload_fvplayer_video_1', 'fv_wp_flowplayer_media_upload');
45
+ add_action('media_upload_fvplayer_video_2', 'fv_wp_flowplayer_media_upload');
46
+ add_action('media_upload_fvplayer_mobile', 'fv_wp_flowplayer_media_upload');
47
+ add_action('media_upload_fvplayer_splash', 'fv_wp_flowplayer_media_upload');
48
+ add_action('media_upload_fvplayer_logo', 'fv_wp_flowplayer_media_upload');
49
+ add_action('media_upload_fvplayer_subtitles', 'fv_wp_flowplayer_media_upload');
50
+
51
+
52
+ add_action( 'admin_enqueue_scripts', 'fv_wp_flowplayer_admin_enqueue_scripts' );
53
+ add_action( 'edit_form_after_editor', 'fv_wp_flowplayer_edit_form_after_editor' );
54
+
55
+ add_action( 'after_plugin_row', 'fv_wp_flowplayer_after_plugin_row', 10, 3 );
56
+
57
+ add_action( 'save_post', 'fv_wp_flowplayer_save_post', 9999 );
58
+
59
+ add_filter( 'get_user_option_closedpostboxes_fv_flowplayer_settings', 'fv_wp_flowplayer_closed_meta_boxes' );
60
+
61
+
62
+ //loading a video and splash image
63
+ if(
64
+ isset($_REQUEST['_wp_http_referer']) &&
65
+ (
66
+ strpos($_REQUEST['_wp_http_referer'],'type=fvplayer_video') ||
67
+ strpos($_REQUEST['_wp_http_referer'],'type=fvplayer_video_1') ||
68
+ strpos($_REQUEST['_wp_http_referer'],'type=fvplayer_video_2') ||
69
+ strpos($_REQUEST['_wp_http_referer'],'type=fvplayer_mobile') ||
70
+ strpos($_REQUEST['_wp_http_referer'],'type=fvplayer_splash') ||
71
+ strpos($_REQUEST['_wp_http_referer'],'type=fvplayer_subtitles')
72
+ )
73
+ ) {
74
+ add_filter('media_send_to_editor','fv_wp_flowplayer_media_send_to_editor', 10, 3);
75
+ //disable inserting the image to the editor
76
+ add_filter('image_send_to_editor', 'fv_wp_flowplayer_image_send_to_editor', 10);
77
+ }
78
+ else {
79
+ //loading a logo
80
+ if(isset($_POST['_wp_http_referer']) && (strpos($_POST['_wp_http_referer'],'type=fvplayer_logo'))) {
81
+ add_filter('media_send_to_editor','fp_media_send_to_settings', 10, 3);
82
+ }
83
+ }
84
+
85
+ if(
86
+ !empty($_GET['post_id']) &&
87
+ (
88
+ $_GET['type'] == 'fvplayer_video' ||
89
+ $_GET['type'] == 'fvplayer_video_1' ||
90
+ $_GET['type'] == 'fvplayer_video_2' ||
91
+ $_GET['type'] == 'fvplayer_mobile' ||
92
+ $_GET['type'] == 'fvplayer_splash' ||
93
+ $_GET['type'] == 'fvplayer_subtitles'
94
+ )
95
+ ) {
96
+ add_action( 'post-html-upload-ui', 'fv_wp_flowplayer_image_media_upload_html_bypass', 100 );
97
+ }
98
+
99
+ add_action('the_content', 'flowplayer_content_remove_commas');
100
+ add_filter('admin_print_scripts', 'flowplayer_print_scripts');
101
+ add_action('admin_print_styles', 'flowplayer_print_styles');
102
+ //conversion script via AJAX
103
+ add_action('wp_ajax_flowplayer_conversion_script', 'flowplayer_conversion_script');
104
+ add_action('admin_notices', 'fv_wp_flowplayer_admin_notice');
105
+
106
+
107
+ function flowplayer_activate() {
108
+ update_option( 'fv_wordpress_flowplayer_deferred_notices', 'FV Flowplayer upgraded - please click "Check template" and "Check videos" for automated check of your site at <a href="'.site_url().'/wp-admin/options-general.php?page=fvplayer">the settings page</a> for automated checks!' );
109
+ }
110
+
111
+
112
+ function flowplayer_content_remove_commas($content) {
113
+ preg_match('/.*popup=\'(.*?)\'.*/', $content, $matches);
114
+ $content_new = preg_replace('/\,/', '',$content);
115
+ if (isset($matches[1]))
116
+ $content_new = preg_replace('/popup=\'(.*?)\'/', 'popup=\''.$matches[1].'\'',$content_new);
117
+ return $content_new;
118
+ }
119
+
120
+
121
+ /**
122
+ * END WP Hooks
123
+ */
124
+
125
+
126
+ function fv_wp_flowplayer_media_send_to_editor($html, $attachment_id, $attachment) {
127
+
128
+ $video_types = array('flv','mov','avi','mpeg','mpg','asf','qt','wmv','mp4','m4v','mp3','webm','ogv');
129
+ $splash_types = array('jpg','jpeg','gif','png', 'bmp','jpe');
130
+ $subtitles_types = array('txt','vtt');
131
+
132
+ if (isset($attachment_id)) {
133
+ $attachment_url = wp_get_attachment_url($attachment_id);
134
+ $path_parts = pathinfo($attachment_url);
135
+ if (strpos($_POST['_wp_http_referer'],'type=fvplayer_splash')) {
136
+ setcookie("selected_image",$attachment_url);
137
+ $selected_attachment = array('url'=>$attachment_url,'id'=>$attachment_id);
138
+ }
139
+ else
140
+ if (strpos($_POST['_wp_http_referer'],'type=fvplayer_video_1')) {
141
+ setcookie("selected_video1",$attachment_url);
142
+ $selected_attachment = array('id'=>'src1', 'url'=>$attachment_url);
143
+ }
144
+ else
145
+ if (strpos($_POST['_wp_http_referer'],'type=fvplayer_video_2')) {
146
+ setcookie("selected_video2",$attachment_url);
147
+ $selected_attachment = array('id'=>'src2', 'url'=>$attachment_url);
148
+ }
149
+ else
150
+ if (strpos($_POST['_wp_http_referer'],'type=fvplayer_mobile')) {
151
+ setcookie("selected_mobile",$attachment_url);
152
+ $selected_attachment = array('id'=>'mobile', 'url'=>$attachment_url);
153
+ }
154
+ else
155
+ if (strpos($_POST['_wp_http_referer'],'type=fvplayer_subtitles')) {
156
+ setcookie("selected_subtitles",$attachment_url);
157
+ $selected_attachment = array('id'=>'subtitles', 'url'=>$attachment_url);
158
+ }
159
+ else {
160
+ setcookie("selected_video",$attachment_url);
161
+ $selected_attachment = array('id'=>'src', 'url'=>$attachment_url);
162
+ }
163
+ }
164
+
165
+ if (isset($selected_attachment['url'])) {
166
+ $path_parts = pathinfo($selected_attachment['url']);
167
+ if (in_array($path_parts['extension'], $video_types)) {
168
+ if ($selected_attachment['id'] == 'src1') {
169
+ $uploaded_video1 = $selected_attachment['url'];
170
+ }
171
+ else
172
+ if ($selected_attachment['id'] == 'src2') {
173
+ $uploaded_video2 = $selected_attachment['url'];
174
+ }
175
+ else
176
+ if ($selected_attachment['id'] == 'mobile') {
177
+ $uploaded_mobile = $selected_attachment['url'];
178
+ }
179
+ else {
180
+ $uploaded_video = $selected_attachment['url'];
181
+ }
182
+ }
183
+ if( in_array($path_parts['extension'], $splash_types) ) {
184
+ $uploaded_image = $selected_attachment['url'];
185
+ }
186
+ else if( in_array($path_parts['extension'], $subtitles_types) ) {
187
+ $uploaded_subtitles = $selected_attachment['url'];
188
+ }
189
+ }
190
+
191
+ $document_root = ( isset($_SERVER['SUBDOMAIN_DOCUMENT_ROOT']) && strlen(trim($_SERVER['SUBDOMAIN_DOCUMENT_ROOT'])) > 0 ) ? $_SERVER['SUBDOMAIN_DOCUMENT_ROOT'] : $_SERVER['DOCUMENT_ROOT'];
192
+
193
+ if (isset($uploaded_video)) {
194
+ $serv = $_SERVER['SERVER_NAME'];
195
+ $pattern = '/'.$serv.'(.*)/';
196
+ preg_match($pattern, $uploaded_video, $matches);
197
+ require_once( plugin_dir_path(__FILE__).'../includes/getid3/getid3.php');
198
+ // Initialize getID3 engine
199
+ $getID3 = new getID3;
200
+ if (empty($matches)) {
201
+ $ThisFileInfo = $getID3->analyze(realpath($document_root . $uploaded_video));
202
+ }
203
+ else {
204
+ $ThisFileInfo = $getID3->analyze(realpath($document_root . $matches[1]));
205
+ }
206
+ if (isset($ThisFileInfo['error'])) $file_error = "Could not read video details, please fill the width and height manually.";
207
+ //getid3_lib::CopyTagsToComments($ThisFileInfo);
208
+ $file_time = $ThisFileInfo['playtime_string']; // playtime in minutes:seconds, formatted string
209
+ $file_width = $ThisFileInfo['video']['resolution_x'];
210
+ $file_height = $ThisFileInfo['video']['resolution_y'];
211
+ $file_size = $ThisFileInfo['filesize'];
212
+ $file_size = round($file_size/(1024*1024),2);
213
+ }
214
+ if (!empty($uploaded_video)) {
215
+ ?>
216
+ <script type='text/javascript'>
217
+ window.parent.document.getElementById('fv_wp_flowplayer_field_src').value = "<?php echo esc_attr($uploaded_video) ?>";
218
+ <?php if (!empty($uploaded_video) && !isset($ThisFileInfo['error'])) { ?>
219
+ window.parent.document.getElementById('fv_wp_flowplayer_field_width').value = "<?php echo esc_attr(ceil($file_width)) ?>";
220
+ window.parent.document.getElementById('fv_wp_flowplayer_field_height').value = "<?php echo esc_attr(ceil($file_height)) ?>";
221
+ window.parent.document.getElementById('fv_wp_flowplayer_file_info').style.display = "table-row";
222
+ window.parent.document.getElementById('fv_wp_flowplayer_file_duration').innerHTML = "<?php echo esc_attr($file_time) ?>";
223
+ window.parent.document.getElementById('fv_wp_flowplayer_file_size').innerHTML = "<?php echo esc_attr($file_size) ?>";
224
+ <?php } ?>
225
+ window.parent.tb_remove();
226
+ </script>
227
+ <?php
228
+ }
229
+ else
230
+ if (!empty($uploaded_image)) {
231
+ ?>
232
+ <script type='text/javascript'>
233
+ window.parent.document.getElementById('fv_wp_flowplayer_field_splash').value = "<?php echo esc_attr($uploaded_image) ?>";
234
+ </script>
235
+ <?php
236
+ $conf = get_option( 'fvwpflowplayer' );
237
+ $post_thumbnail = false;
238
+
239
+ if( isset($conf["postthumbnail"]) ) {
240
+ $post_thumbnail = $conf["postthumbnail"];
241
+ }
242
+ if ( $post_thumbnail == 'true' && current_theme_supports( 'post-thumbnails') && isset($selected_attachment['id']) ) {
243
+ $post_id = (int)$_GET['post_id'];
244
+ update_post_meta( $post_id, '_thumbnail_id', $selected_attachment['id'] );
245
+ }
246
+ }
247
+ else
248
+ if (!empty($uploaded_video1)) {
249
+ ?>
250
+ <script type='text/javascript'>
251
+ window.parent.document.getElementById('fv_wp_flowplayer_field_src_1').value = "<?php echo esc_attr($uploaded_video1) ?>";
252
+ </script>
253
+ <?php
254
+ }
255
+ else
256
+ if (!empty($uploaded_video2)) {
257
+ ?>
258
+ <script type='text/javascript'>
259
+ window.parent.document.getElementById('fv_wp_flowplayer_field_src_2').value = "<?php echo esc_attr($uploaded_video2) ?>";
260
+ </script>
261
+ <?php
262
+ }
263
+ else
264
+ if (!empty($uploaded_mobile)) {
265
+ ?>
266
+ <script type='text/javascript'>
267
+ window.parent.document.getElementById('fv_wp_flowplayer_field_mobile').value = "<?php echo esc_attr($uploaded_mobile) ?>";
268
+ </script>
269
+ <?php
270
+ }
271
+ else
272
+ if( !empty($uploaded_subtitles) ) {
273
+ ?>
274
+ <script type='text/javascript'>
275
+ window.parent.document.getElementById('fv_wp_flowplayer_field_subtitles').value = "<?php echo esc_attr($uploaded_subtitles) ?>";
276
+ </script>
277
+ <?php
278
+ }
279
+ }
280
+
281
+
282
+ function fv_wp_flowplayer_image_send_to_editor() {
283
+ return '';
284
+ }
285
+
286
+
287
+ function fv_wp_flowplayer_image_media_upload_html_bypass() {
288
+ ?>
289
+ <p class="upload-html-bypass hide-if-no-js">
290
+ <?php _e('<strong>FV Wordpress Flowplayer Warning:</strong> Plese use <a href="#">the multi-file uploader</a>. Otherwise you will have to select the file in the Media Library.'); ?>
291
+ </p>
292
+ <?php
293
+ }
294
+
295
+
296
+ function fp_media_send_to_settings($html, $attachment_id, $attachment) {
297
+ if(isset($_POST['_wp_http_referer']) && (strpos($_POST['_wp_http_referer'],'type=fvplayer_logo'))) {
298
+ $logo_types = array('jpg','jpeg','gif','png', 'bmp','jpe');
299
+
300
+ if (isset($attachment_id)) {
301
+ $attachment_url = wp_get_attachment_url($attachment_id);
302
+ $path_parts = pathinfo($attachment_url);
303
+ if (in_array($path_parts['extension'], $logo_types)) {
304
+ $selected_attachment = $attachment_url;
305
+ }
306
+ }
307
+ ?>
308
+ <script type="text/javascript">
309
+ window.parent.document.getElementById("logo").value = '<?php echo $selected_attachment ?>';
310
+ window.parent.tb_remove();
311
+ </script>
312
+ <?php
313
+ }
314
+ }
315
+
316
+
317
+ /**
318
+ * Administrator environment function.
319
+ */
320
+ function flowplayer_admin () {
321
+ // if we are in administrator environment
322
+ if (function_exists('add_submenu_page')) {
323
+ add_options_page(
324
+ 'FV Wordpress Flowplayer',
325
+ 'FV Wordpress Flowplayer',
326
+ 'manage_options',
327
+ 'fvplayer',
328
+ 'flowplayer_page'
329
+ );
330
+ }
331
+ }
332
+
333
+
334
+ /**
335
+ * Outputs HTML code for bool options based on arg passed.
336
+ * @param string Currently selected value ('true' or 'false').
337
+ * @return string HTML code
338
+ */
339
+ function flowplayer_bool_select($current) {
340
+ switch($current) {
341
+ case "true":
342
+ $html = '<option selected="selected" value="true">true</option><option value="false">false</option>';
343
+ break;
344
+ case "false":
345
+ $html = '<option value="true" >true</option><option selected="selected" value="false">false</option>';
346
+ break;
347
+ default:
348
+ $html = '<option value="true">true</option><option selected="selected" value="false">false</option>';
349
+ break;
350
+ }
351
+ return $html;
352
+ }
353
+
354
+
355
+ /**
356
+ * Displays administrator menu with configuration.
357
+ */
358
+ function flowplayer_page() {
359
+ global $fv_fp;
360
+ include dirname( __FILE__ ) . '/../view/admin.php';
361
+ }
362
+
363
+
364
+ /**
365
+ * Checks for errors regarding access to configuration file. Displays errors if any occur.
366
+ * @param object $fv_fp Flowplayer class object.
367
+ */
368
+ function flowplayer_check_errors($fv_fp) {
369
+
370
+ }
371
+
372
+
373
+ function flowplayer_add_media_button() {
374
+ if( stripos( $_SERVER['REQUEST_URI'], 'post.php' ) === FALSE && stripos( $_SERVER['REQUEST_URI'], 'post-new.php' ) === FALSE ) {
375
+ return;
376
+ }
377
+
378
+ global $post;
379
+ $plugins = get_option('active_plugins');
380
+ $found = false;
381
+ foreach ( $plugins AS $plugin ) {
382
+ if( stripos($plugin,'foliopress-wysiwyg') !== FALSE )
383
+ $found = true;
384
+ }
385
+ $button_tip = 'Insert a Flash Video Player';
386
+ $wizard_url = 'media-upload.php?post_id='.$post->ID.'&type=fv-wp-flowplayer';
387
+ $button_src = FV_FP_RELATIVE_PATH.'/images/icon.png';
388
+ if(!$found) {
389
+ $img = '<img src="' . $button_src . '" alt="' . $button_tip . '" />';
390
+ }
391
+ echo '<a title="Add FV WP Flowplayer" href="#" class="fv-wordpress-flowplayer-button" >'.$img.'</a>';
392
+ }
393
+
394
+
395
+ function flowplayer_print_scripts() {
396
+ wp_enqueue_script('media-upload');
397
+ wp_enqueue_script('thickbox');
398
+ }
399
+
400
+
401
+ function flowplayer_print_styles() {
402
+ wp_enqueue_style('thickbox');
403
+ }
404
+
405
+
406
+ function flowplayer_conversion_script() {
407
+ global $wpdb;
408
+
409
+ $posts = $wpdb->get_results("SELECT ID, post_content FROM {$wpdb->posts} WHERE post_type != 'revision'");
410
+
411
+ $old_shorttag = '[flowplayer';
412
+ $new_shorttag = '[fvplayer';
413
+ $counter = 0;
414
+
415
+ echo '<ol>';
416
+ foreach($posts as $fv_post) {
417
+ if ( stripos( $fv_post->post_content, $old_shorttag ) !== false ) {
418
+ $update_post = array();
419
+ $update_post['ID'] = $fv_post->ID;
420
+ $update_post['post_content'] = str_replace( $old_shorttag, $new_shorttag, $fv_post->post_content );
421
+ wp_update_post( $update_post );
422
+ echo '<li><a href="' . get_permalink($fv_post->ID) . '">' . get_the_title($fv_post->ID) . '</a> updated</li>';
423
+ $counter++;
424
+ }
425
+ }
426
+ echo '</ol>';
427
+
428
+ echo '<strong>Conversion was succesful. Total number of converted posts: ' . $counter . '</strong>';
429
+
430
+ delete_option('fvwpflowplayer_conversion');
431
+
432
+ die();
433
+ }
434
+
435
+
436
+ function fv_wp_flowplayer_admin_notice() {
437
+ if( $notices = get_option('fv_wordpress_flowplayer_deferred_notices') ) {
438
+ echo '<div class="updated">
439
+ <p>'.$notices.'</p>
440
+ </div>';
441
+ }
442
+
443
+ $conversion = false; //(bool)get_option('fvwpflowplayer_conversion');
444
+ if ($conversion) {
445
+ echo '<div class="updated" id="fvwpflowplayer_conversion_notice"><p>';
446
+ printf(__('FV Wordpress Flowplayer has found old shortcodes in the content of your posts. <a href="%1$s">Run the conversion script.</a>'), get_admin_url() . 'options-general.php?page=fvplayer');
447
+ echo "</p></div>";
448
+ }
449
+
450
+ /*if( isset($_GET['page']) && $_GET['page'] == 'backend.php' ) {
451
+ $options = get_option( 'fvwpflowplayer' );
452
+ if( $options['key'] == 'false' ) {
453
+ echo '<div class="updated"><p>';
454
+ printf(__('Brand new version of Flowplayer for HTML5. <a href="http://foliovision.com/wordpress/plugins/fv-wordpress-flowplayer/buy">Licenses half price</a> in May.' ) );
455
+ echo "</p></div>";
456
+ }
457
+ }*/
458
+ }
459
+
460
+
461
+ function fv_wp_flowplayer_admin_enqueue_scripts( $page ) {
462
+ if( $page !== 'post.php' && $page !== 'post-new.php' ) {
463
+ return;
464
+ }
465
+ wp_register_script('fvwpflowplayer-domwindow', plugins_url().'/fv-wordpress-flowplayer/js/jquery.colorbox-min.js',array('jquery') );
466
+ wp_enqueue_script('fvwpflowplayer-domwindow');
467
+
468
+ wp_register_script('fvwpflowplayer-shortcode-editor', plugins_url().'/fv-wordpress-flowplayer/js/shortcode-editor.js',array('jquery') );
469
+ wp_enqueue_script('fvwpflowplayer-shortcode-editor');
470
+
471
+ wp_register_style('fvwpflowplayer-domwindow-css', plugins_url().'/fv-wordpress-flowplayer/css/colorbox.css','','1.0','screen');
472
+ wp_enqueue_style('fvwpflowplayer-domwindow-css');
473
+ }
474
+
475
+
476
+ /*
477
+ Trick media uploader to show video only, while making sure we use our custom type; Also save options
478
+ */
479
+ function fv_wp_flowplayer_admin_init() {
480
+ if( isset($_GET['type']) ) {
481
+ if( $_GET['type'] == 'fvplayer_video' || $_GET['type'] == 'fvplayer_video_1' || $_GET['type'] == 'fvplayer_video_2' || $_GET['type'] == 'fvplayer_mobile' ) {
482
+ $_GET['post_mime_type'] = 'video';
483
+ }
484
+ else if( $_GET['type'] == 'fvplayer_splash' || $_GET['type'] == 'fvplayer_logo' ) {
485
+ $_GET['post_mime_type'] = 'image';
486
+ }
487
+ }
488
+
489
+ if( isset($_POST['fv-wp-flowplayer-submit']) ) {
490
+ global $fv_fp;
491
+ if( method_exists($fv_fp,'_set_conf') ) {
492
+ $fv_fp->_set_conf();
493
+ } else {
494
+ echo 'Error saving FV Flowplayer options.';
495
+ }
496
+ }
497
+
498
+ global $fv_fp;
499
+ global $fv_wp_flowplayer_ver, $fv_wp_flowplayer_core_ver;
500
+ if( preg_match( '!^\$\d+!', $fv_fp->conf['key'] ) && isset($fv_fp->conf['key_automatic']) && $fv_fp->conf['key_automatic'] == 'true' ) {
501
+
502
+ $version = get_option( 'fvwpflowplayer_core_ver' );
503
+ if( version_compare( $fv_wp_flowplayer_core_ver, $version ) == 1 ) {
504
+ fv_wp_flowplayer_admin_key_update();
505
+ }
506
+ }
507
+
508
+ if(
509
+ preg_match( '!^\$\d+!', $fv_fp->conf['key'] ) && version_compare( $fv_wp_flowplayer_core_ver, get_option('fvwpflowplayer_core_ver') ) !== 0 && ( !isset($fv_fp->conf['key_automatic']) || $fv_fp->conf['key_automatic'] != 'true' )
510
+ ) {
511
+ global $fv_fp;
512
+ $fv_fp->pointer_boxes = array(
513
+ 'fv_flowplayer_key_automatic' => array(
514
+ 'id' => '#wpadminbar',
515
+ 'heading' => __('FV Flowplayer License Update', 'fv_flowplayer'),
516
+ 'content' => __('New version of FV Flowplayer core has been installed for your licensed website. Please accept the automatic license key updating (connects to Foliovision servers) or update the key manually by loggin into your Foliovision account.', 'fv_flowplayer'),
517
+ 'position' => array( 'edge' => 'top', 'align' => 'center' ),
518
+ 'button1' => __('Always auto-update', 'fv_flowplayer'),
519
+ 'button2' => __('I\'ll update it manually', 'fv_flowplayer')
520
+ )
521
+ );
522
+ } else if( version_compare( $fv_wp_flowplayer_core_ver, get_option('fvwpflowplayer_core_ver') ) !== 0 && preg_match( '!^\$\d+!', $fv_fp->conf['key'] ) == 0 ) {
523
+ update_option( 'fvwpflowplayer_core_ver', $fv_wp_flowplayer_core_ver );
524
+ }
525
+
526
+
527
+ if( isset($_GET['page']) && $_GET['page'] == 'fvplayer' ) {
528
+ wp_enqueue_script('common');
529
+ wp_enqueue_script('wp-lists');
530
+ wp_enqueue_script('postbox');
531
+ }
532
+
533
+
534
+ }
535
+
536
+
537
+ function fv_wp_flowplayer_admin_key_update() {
538
+ global $fv_wp_flowplayer_ver, $fv_wp_flowplayer_core_ver, $fv_fp;
539
+
540
+ $args = array(
541
+ 'body' => array( 'domain' => home_url(), 'plugin' => 'fv-wordpress-flowplayer', 'version' => $fv_wp_flowplayer_ver, 'core_ver' => $fv_wp_flowplayer_core_ver ),
542
+ 'timeout' => 20,
543
+ 'user-agent' => 'fv-wordpress-flowplayer-'.$fv_wp_flowplayer_ver.' ('.$fv_wp_flowplayer_core_ver.')'
544
+ );
545
+ $resp = wp_remote_post( 'http://foliovision.com/?fv_remote=true', $args );
546
+
547
+ if( $resp['body'] && $data = json_decode( $resp['body'] ) ) {
548
+ if( $data->domain && $data->key && stripos( home_url(), $data->domain ) !== false ) {
549
+ $fv_fp->conf['key'] = $data->key;
550
+ update_option( 'fvwpflowplayer', $fv_fp->conf );
551
+ update_option( 'fvwpflowplayer_core_ver', $fv_wp_flowplayer_core_ver );
552
+ return true;
553
+ }
554
+ } else {
555
+ return false;
556
+ }
557
+ }
558
+
559
+
560
+ function fv_wp_flowplayer_edit_form_after_editor( ) {
561
+ include dirname( __FILE__ ) . '/../view/wizard.php';
562
+ }
563
+
564
+
565
+ /*
566
+ Custom media uploader type is really just the default one
567
+ */
568
+ function fv_wp_flowplayer_media_upload() {
569
+ wp_media_upload_handler();
570
+ }
571
+
572
+
573
+ function fv_wp_flowplayer_after_plugin_row( $arg) {
574
+ $args = func_get_args();
575
+
576
+ if( $args[1]['Name'] == 'FV Wordpress Flowplayer' ) {
577
+ $options = get_option( 'fvwpflowplayer' );
578
+ if( $options['key'] == 'false' || $options['key'] == '' ) :
579
+ ?>
580
+ <tr class="plugin-update-tr fv-wordpress-flowplayer-tr">
581
+ <td class="plugin-update colspanchange" colspan="3">
582
+ <div class="update-message">
583
+ <a href="http://foliovision.com/wordpress/plugins/fv-wordpress-flowplayer/download">All Licenses 20% Off</a> - Christmas sale!
584
+ </div>
585
+ </td>
586
+ </tr>
587
+ <?php
588
+ endif;
589
+ }
590
+ }
591
+
592
+
593
+ function fv_wp_flowplayer_check_headers( $headers, $remotefilename, $random ) {
594
+ global $fv_fp;
595
+
596
+ $video_errors = array();
597
+
598
+ if( $headers && $headers['response']['code'] == '404' ) {
599
+ $video_errors[] = 'File not found (HTTP 404)!';
600
+ } else if( $headers && $headers['response']['code'] == '403' ) {
601
+ $video_errors[] = 'Access to video forbidden (HTTP 403)!';
602
+ } else if( $headers && $headers['response']['code'] != '200' && $headers['response']['code'] != '206' ) {
603
+ $video_errors[] = 'Can\'t check the video (HTTP '.$headers['response']['code'].')!';
604
+ } else {
605
+
606
+ if(
607
+ ( !isset($headers['headers']['accept-ranges']) || $headers['headers']['accept-ranges'] != 'bytes' ) &&
608
+ !isset($headers['headers']['content-range'])
609
+ ) {
610
+ $video_errors[] = 'Server does not support HTTP range requests! Please check "I\'m getting error about \'HTTP range requests\'" in <a href="http://foliovision.com/wordpress/plugins/fv-wordpress-flowplayer/faq">our FAQ</a>.';
611
+ }
612
+
613
+ if(
614
+ ( stripos( $remotefilename, '.mp4' ) !== FALSE && $headers['headers']['content-type'] != 'video/mp4' ) ||
615
+ ( stripos( $remotefilename, '.m4v' ) !== FALSE && $headers['headers']['content-type'] != 'video/x-m4v' ) ||
616
+ ( stripos( $remotefilename, '.webm' ) !== FALSE && $headers['headers']['content-type'] != 'video/webm' ) ||
617
+ ( stripos( $remotefilename, '.mov' ) !== FALSE && $headers['headers']['content-type'] != 'video/mp4' )
618
+ ) {
619
+ if( stripos( $remotefilename, '.mov' ) !== FALSE ) {
620
+ $meta_note_addition = ' Firefox on Windows does not like MOV files with video/quicktime mime type.';
621
+ } else if( stripos( $remotefilename, '.webm' ) !== FALSE ) {
622
+ $meta_note_addition = ' Older Firefox versions don\'t like WEBM files with mime type other than video/webm.';
623
+ } else {
624
+ $meta_note_addition = ' Some web browsers may experience playback issues in HTML5 mode (Internet Explorer 9 - 10).';
625
+ /*if( $fv_fp->conf['engine'] == 'default' ) {
626
+ $meta_note_addition .= ' Currently you are using the "Default (mixed)" <a href="'.site_url().'/wp-admin/options-general.php?page=fvplayer">Preferred Flowplayer engine</a> setting, so IE will always use Flash and will play fine.';
627
+ }*/
628
+ }
629
+
630
+ $fix = '<div class="fix-meta-'.$random.'" style="display: none; ">
631
+ <p>If the video is hosted on Amazon S3:</p>
632
+ <blockquote>Using your Amazon AWS Management Console, you can go though your videos and find file content type under the "Metadata" tab in an object\'s "Properties" pane and fix it to "video/mp4" for MP4, "video/x-m4v" for M4V files, "video/mp4" for MOV files and "video/webm" for WEBM files.</blockquote>
633
+ <p>If the video is hosted on your server, put this into your .htaccess:</p>
634
+ <pre>AddType video/mp4 .mp4
635
+ AddType video/webm .webm
636
+ AddType video/ogg .ogv
637
+ AddType application/x-mpegurl .m3u8
638
+ AddType video/x-m4v .m4v
639
+ AddType video/mp4 .mov
640
+ # hls transport stream segments:
641
+ AddType video/mp2t .ts</pre>
642
+ <p>If you are using Microsoft IIS, you need to use the IIS manager. Check our <a href="http://foliovision.com/wordpress/plugins/fv-wordpress-flowplayer/faq" target="_blank">FAQ</a> for more info.</p>
643
+ </div>';
644
+
645
+ $video_errors[] = '<p><strong>Bad mime type</strong>: Video served with a bad mime type <tt>'.$headers['headers']['content-type'].'</tt>!'.$meta_note_addition.' (<a href="#" onclick="jQuery(\'.fix-meta-'.$random.'\').toggle(); return false">show fix</a>)</p>'.$fix ;
646
+ }
647
+ }
648
+ return $video_errors;
649
+ }
650
+
651
+
652
+ // don't include body in our wp_remote_head requests. We have to use GET instead of HEAD because of Amazon
653
+ function fv_wp_flowplayer_http_api_curl( $handle ) {
654
+ curl_setopt( $handle, CURLOPT_NOBODY, true );
655
+ }
656
+
657
+
658
+ function fv_wp_flowplayer_check_mimetype( $URLs = false, $meta = false ) {
659
+ add_action( 'http_api_curl', 'fv_wp_flowplayer_http_api_curl' );
660
+
661
+ global $fv_wp_flowplayer_ver, $fv_fp;
662
+
663
+ if( !empty($meta) ) {
664
+ extract( $meta, EXTR_SKIP );
665
+ }
666
+
667
+ if( defined('DOING_AJAX') && DOING_AJAX && isset( $_POST['media'] ) && stripos( $_SERVER['HTTP_REFERER'], home_url() ) === 0 ) {
668
+ $URLs = json_decode( stripslashes( trim($_POST['media']) ));
669
+ }
670
+
671
+ if( isset($URLs) ) {
672
+ $all_sources = $URLs;
673
+
674
+ $video_warnings = array();
675
+ $video_errors = array();
676
+ $video_info = array();
677
+ $message = false;
678
+ $new_info = false;
679
+
680
+ foreach( $all_sources AS $source ) {
681
+ if( preg_match( '!^rtmp://!', $source, $match ) ) {
682
+ $found_rtmp = true;
683
+ } else {
684
+ if( preg_match('!^http://(www\.)?youtube!',$source) ) {
685
+ $video_errors[] = 'Youtube video embeding not supported yet. Please download the video file and put it in as a source directly.';
686
+ } else if( !isset($media) && !preg_match( '!\.(m3u8|m3u|avi)$!', $source) ) {
687
+ $media = $source;
688
+ }
689
+
690
+ if( preg_match( '!\.(mp4|m4v)$!', $source, $match ) ) {
691
+ $found_mp4 = true;
692
+ } else if( preg_match( '!\.mov$!', $source, $match ) ) {
693
+ $video_warnings[] = 'We recommend that you re-encode your MOV video into MP4 format. MOV is not be 100% compatible with HTML5 and might not play in Google Chrome. <a href="http://foliovision.com/wordpress/plugins/fv-wordpress-flowplayer/encoding#flash-only" target="_blank">Read our article about video encoding</a>';
694
+ } else if( preg_match( '!\.flv$!', $source, $match ) ) {
695
+ $found_flv = true;
696
+ } else if( preg_match( '!\.(m3u8|m3u)$!', $source, $match ) ) {
697
+ $found_m3u8 = true;
698
+ } else if( preg_match( '!\.(avi)$!', $source, $match ) ) {
699
+ $found_avi = true;
700
+ } else if( preg_match( '!\.(3gp)$!', $source, $match ) ) {
701
+ $found_3gp = true;
702
+ } else if( preg_match( '!\.(webm)$!', $source, $match ) ) {
703
+ $found_webm = true;
704
+ }
705
+ }
706
+ }
707
+
708
+ if( isset($found_flv) && !isset($found_mp4) ) {
709
+ $video_warnings[] = 'We recommend that you re-encode your FLV video into MP4 format or also provide the video in MP4 format. FLV is not compatible with HTML5 and won\'t play on devices without Flash (iPhone, iPad...). <a href="http://foliovision.com/wordpress/plugins/fv-wordpress-flowplayer/encoding#flash-only">Read our article about video encoding</a>';
710
+ }
711
+
712
+ if( isset($found_rtmp) && !isset($found_mp4) ) {
713
+ $video_warnings[] = 'We recommend that you also provide your RTMP video in MP4 format. RTMP is not compatible with HTML5 and won\'t play on devices without Flash (iPhone, iPad...). <a href="http://foliovision.com/wordpress/plugins/fv-wordpress-flowplayer/encoding#flash-only">Read our article about video encoding</a>';
714
+ }
715
+
716
+ if( isset($found_3gp) && !isset($found_mp4) ) {
717
+ $video_warnings[] = 'We recommend that you re-encode your 3GP video into a MP4 format. 3GP is not compatible with all HTML5 players so it won\'t play on these devices if they don\'t have Flash. <a href="http://foliovision.com/wordpress/plugins/fv-wordpress-flowplayer/encoding#flash-only">Read our article about video encoding</a>';
718
+ }
719
+
720
+ if( isset($found_m3u8) && count($all_sources) == 1 ) {
721
+ $video_warnings[] = 'We recommend that you also provide your M3U8 video in MP4 or WEBM format. HTTP Live Streaming (m3u8) is only supported by Apple iOS devices (iPhone, iPad...). <a href="http://foliovision.com/wordpress/plugins/fv-wordpress-flowplayer/encoding#flash-only">Read our article about video encoding</a>';
722
+ }
723
+
724
+ if( isset($found_avi) ) {
725
+ $video_errors[] = 'AVI format is not supported by neither HTML5 nor Flash. Please re-encode the video to MP4. <a href="http://foliovision.com/wordpress/plugins/fv-wordpress-flowplayer/encoding#flash-only">Read our article about video encoding</a>';
726
+ }
727
+
728
+ //$random = rand( 0, 10000 );
729
+ $random = (isset($_POST['hash'])) ? trim($_POST['hash']) : false;
730
+
731
+ if( isset($media) ) {
732
+ $remotefilename = $media;
733
+ $url_parts = parse_url( $remotefilename );
734
+ $url_parts_encoded = parse_url( $remotefilename );
735
+ if( !empty($url_parts['path']) ) {
736
+ $url_parts['path'] = join('/', array_map('rawurlencode', explode('/', $url_parts_encoded['path'])));
737
+ }
738
+ if( !empty($url_parts['query']) ) {
739
+ $url_parts['query'] = str_replace( '&amp;', '&', $url_parts_encoded['query'] );
740
+ }
741
+
742
+ $url_parts['path'] = str_replace( '%2B', '+', $url_parts['path'] );
743
+
744
+ $remotefilename_encoded = http_build_url($remotefilename, $url_parts);
745
+
746
+ if( $fv_fp->is_secure_amazon_s3($remotefilename_encoded) || 1>0 ) { // skip headers check for Amazon S3, as it's slow
747
+ $headers = false;
748
+ } else {
749
+ $headers = wp_remote_head( trim( str_replace(' ', '%20', $remotefilename_encoded ) ), array( 'method' => 'GET', 'redirection' => 3 ) );
750
+ }
751
+
752
+ if( is_wp_error($headers) ) {
753
+ $video_errors[] = 'Error checking '.$media.'!<br />'.print_r($headers,true);
754
+ } else {
755
+ if( $headers ) {
756
+ $video_errors += fv_wp_flowplayer_check_headers( $headers, $remotefilename, $random );
757
+ }
758
+
759
+ if( function_exists('is_utf8') && is_utf8($remotefilename) ) {
760
+ $video_errors[] = '<p><strong>UTF-8 error</strong>: Your file name is using non-latin characters, the file might not play in browsers using Flash for the video!</p>';
761
+ }
762
+
763
+ if( @ini_get('safe_mode') ) {
764
+ $video_warnings[] = 'Detailed video check is not available with PHP Safe Mode On. Please contact your webhost support.';
765
+ } else {
766
+
767
+ require_once( plugin_dir_path(__FILE__).'../includes/getid3/getid3.php');
768
+ $getID3 = new getID3;
769
+
770
+ preg_match( '~^\S+://([^/]+)~', $remotefilename, $remote_domain );
771
+ preg_match( '~^\S+://([^/]+)~', home_url(), $site_domain );
772
+
773
+ if( !function_exists('curl_init') ) {
774
+ $video_errors[] = 'cURL for PHP not found, please contact your server administrator.';
775
+ } else if( strlen($remote_domain[1]) > 0 && strlen($site_domain[1]) > 0 && $remote_domain[1] != $site_domain[1] ) {
776
+ $message = '<p>Analysis of <a class="bluelink" target="_blank" href="'.esc_attr($remotefilename_encoded).'">'.$remotefilename_encoded.'</a></p>';
777
+ $video_info['File'] = 'Remote';
778
+
779
+ // taken from: http://www.getid3.org/phpBB3/viewtopic.php?f=3&t=1141
780
+ $upload_dir = wp_upload_dir();
781
+ $localtempfilename = trailingslashit( $upload_dir['basedir'] ).'fv_flowlayer_tmp_'.md5(rand(1,999)).'_'.basename( substr($remotefilename_encoded,0,32) );
782
+
783
+ $out = fopen( $localtempfilename,'wb' );
784
+ if( $out ) {
785
+
786
+ $ch = curl_init();
787
+ curl_setopt( $ch, CURLOPT_URL, $remotefilename_encoded );
788
+ curl_setopt( $ch, CURLOPT_RANGE, '0-2097152' );
789
+ curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
790
+ if( !@ini_get('open_basedir') ) {
791
+ @curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
792
+ }
793
+ curl_setopt( $ch, CURLOPT_HEADER, true );
794
+ curl_setopt( $ch, CURLOPT_VERBOSE, 1 );
795
+ curl_setopt( $ch, CURLOPT_USERAGENT, 'FV Flowplayer video checker/'.$fv_wp_flowplayer_ver);
796
+
797
+ $data = curl_exec($ch);
798
+
799
+ $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
800
+ $header = substr($data, 0, $header_size);
801
+ $body = substr($data, $header_size);
802
+
803
+ file_put_contents( $localtempfilename, $body);
804
+ if($ch == false) {
805
+ $message .= 'CURL Error: '.curl_error ( $ch);
806
+ }
807
+ curl_close($ch);
808
+ fclose($out);
809
+
810
+ if( !$headers ) {
811
+ $headers = WP_Http::processHeaders( $header );
812
+
813
+ $video_errors += fv_wp_flowplayer_check_headers( $headers, $remotefilename, $random );
814
+ if( isset($hearders['headers']['server']) && $hearders['headers']['server'] == 'AmazonS3' && $headers['response']['code'] == '403' ) {
815
+ $error = new SimpleXMLElement($body);
816
+
817
+ if( stripos( $error->Message, 'Request has expired' ) !== false ) {
818
+ $video_errors[] = '<p><strong>Amazon S3</strong>: Your secure link is expired, there might be problem with your Amazon S3 plugin. Please test if the above URL opens in your browser.</p>';
819
+ } else {
820
+ $video_errors[] = '<p><strong>Amazon S3</strong>: '.$error->Message.'</p>';
821
+ }
822
+
823
+ }
824
+ }
825
+
826
+ $ThisFileInfo = $getID3->analyze( $localtempfilename );
827
+
828
+ if( !@unlink($localtempfilename) ) {
829
+ $video_errors[] = 'Can\'t remove temporary file for video analysis in <tt>'.$localtempfilename.'</tt>!';
830
+ }
831
+ } else {
832
+ $video_errors[] = 'Can\'t create temporary file for video analysis in <tt>'.$localtempfilename.'</tt>!';
833
+ }
834
+ } else {
835
+ $a_link = str_replace( '&amp;', '&', $remotefilename );
836
+ $message = '<p>Analysis of <a class="bluelink" target="_blank" href="'.esc_attr($a_link).'">'.$a_link.'</a></p>';
837
+ $video_info['File'] = 'Local';
838
+
839
+ $document_root = ( isset($_SERVER['SUBDOMAIN_DOCUMENT_ROOT']) && strlen(trim($_SERVER['SUBDOMAIN_DOCUMENT_ROOT'])) > 0 ) ? $_SERVER['SUBDOMAIN_DOCUMENT_ROOT'] : $_SERVER['DOCUMENT_ROOT'];
840
+
841
+ global $blog_id;
842
+ if( isset($blog_id) && $blog_id > 1 ) {
843
+ $upload_dir = wp_upload_dir();
844
+ if( stripos($remotefilename, $upload_dir['baseurl']) !== false ) {
845
+ $localtempfilename = str_replace( $upload_dir['baseurl'], $upload_dir['basedir'], $remotefilename );
846
+ } else {
847
+ $localtempfilename = preg_replace( '~^\S+://[^/]+~', trailingslashit($document_root), preg_replace( '~(\.[a-z]{1,4})/files/~', '$1/wp-content/blogs.dir/'.$blog_id.'/files/', $remotefilename ) );
848
+ }
849
+ } else {
850
+ $localtempfilename = preg_replace( '~^\S+://[^/]+~', trailingslashit($document_root), $remotefilename );
851
+ }
852
+
853
+ $ThisFileInfo = $getID3->analyze( $localtempfilename );
854
+ }
855
+
856
+
857
+ /*
858
+ Only check file length
859
+ */
860
+ if( isset($meta_action) && $meta_action == 'check_time' ) {
861
+
862
+ if( isset($ThisFileInfo['playtime_seconds']) ) {
863
+ $time = $ThisFileInfo['playtime_seconds'];
864
+ }
865
+ global $post;
866
+ $fv_flowplayer_meta = get_post_meta( $post->ID, '_fv_flowplayer', true );
867
+ $fv_flowplayer_meta = ($fv_flowplayer_meta) ? $fv_flowplayer_meta : array();
868
+ $fv_flowplayer_meta[sanitize_title($meta_original)] = array('time' => $time);
869
+ update_post_meta( $post->ID, '_fv_flowplayer', $fv_flowplayer_meta );
870
+ return;
871
+ }
872
+
873
+
874
+ if( isset($ThisFileInfo['error']) ) {
875
+ fv_wp_flowplayer_array_search_by_item( 'not correctly handled', $ThisFileInfo['error'], $check, true );
876
+ if( $check ) {
877
+ $video_info['Warning'] = 'Video checker doesn\'t support this format.';
878
+ } else {
879
+ $video_errors[] = implode( '<br />', $ThisFileInfo['error'] );
880
+ }
881
+ }
882
+
883
+ if( isset($ThisFileInfo['fileformat']) ) {
884
+ $video_info['Format'] = $ThisFileInfo['fileformat'];
885
+ }
886
+
887
+ if( isset($ThisFileInfo['quicktime']) ) {
888
+ if( !isset($ThisFileInfo['quicktime']['moov']) ) {
889
+ $video_warnings[] = 'Video meta data (moov-atom) not found at the start of the file! Please move the meta data to the start of video, otherwise it might have a slow start up time. Plese check the "How do I fix the bad metadata (moov) position?" question in <a href="http://foliovision.com/wordpress/plugins/fv-wordpress-flowplayer/faq" target="_blank">FAQ</a>.';
890
+ } else {
891
+ if( $ThisFileInfo['quicktime']['moov']['offset'] > 1024 ) {
892
+ $video_warnings[] = 'Meta Data (moov) not found at the start of the file (found at '. number_format( $ThisFileInfo['quicktime']['moov']['offset'] ).' byte)! Please move the meta data to the start of video, otherwise it might have a slow start up time. Plese check the "How do I fix the bad metadata (moov) position?" question in <a href="http://foliovision.com/wordpress/plugins/fv-wordpress-flowplayer/faq" target="_blank">FAQ</a>.';
893
+ } else {
894
+ $video_info['Moov position'] = $ThisFileInfo['quicktime']['moov']['offset'];
895
+ }
896
+
897
+ /*if( isset($ThisFileInfo['quicktime']['moov']['subatoms']) ) {
898
+ foreach( $ThisFileInfo['quicktime']['moov']['subatoms'] AS $subatom ) {
899
+ if( $subatom['hierarchy'] == 'trak' ) {
900
+
901
+ }
902
+ }
903
+ }*/
904
+
905
+ fv_wp_flowplayer_array_search_by_item( 'stts', $ThisFileInfo, $stts );
906
+ if( isset($stts[0]) && $stts[0]['number_entries'] > 1 ) {
907
+ $video_info['Seek points'] = $stts[0]['number_entries'].' (stts)';
908
+ } else {
909
+ if( isset($stts[0]['time_to_sample_table'][0]['sample_count']) ) {
910
+ $video_info['Seek points'] = $stts[0]['time_to_sample_table'][0]['sample_count'].' (stts sample count)';
911
+ } else {
912
+ //$video_warnings[] = 'Only one seeking point found, it might be slow to seek in the video.'; // not so useful
913
+ }
914
+ }
915
+
916
+ }
917
+ }
918
+
919
+ if( isset($ThisFileInfo['audio']['streams']) ) {
920
+ $count_streams = count( $ThisFileInfo['audio']['streams'] );
921
+ if( $count_streams == 1 ) {
922
+ $video_info['Audio'] = $count_streams.' stream, ';
923
+ } else {
924
+ $video_info['Audio'] = $count_streams.' streams, ';
925
+ }
926
+ foreach( $ThisFileInfo['audio']['streams'] AS $stream ) {
927
+ foreach( array( 'dataformat', 'codec', 'sample_rate', 'channels', 'bits_per_sample', 'channelmode' ) AS $item ) {
928
+ if( isset( $stream[$item] ) ) {
929
+ $add = $stream[$item];
930
+ switch( $item ) {
931
+ case 'codec' : $add = '('.$add.')'; break;
932
+ case 'sample_rate' : $add .= 'Hz, '; break;
933
+ case 'bits_per_sample' : $add .= 'bit, '; break;
934
+ case 'channels' : $add .= ' channels, '; break;
935
+ }
936
+ $video_info['Audio'] .= $add.' ';
937
+ }
938
+ }
939
+ $video_info['Audio'] .= '|';
940
+ }
941
+ $video_info['Audio'] = trim( $video_info['Audio'], '|' );
942
+ }
943
+
944
+ $video_info['Video'] = array();
945
+ if( isset($ThisFileInfo['video']['streams']) ) {
946
+ $count_streams = count( $ThisFileInfo['video']['streams'] );
947
+ if( $count_streams == 1 ) {
948
+ $video_info['Video'] = $count_streams.' stream, ';
949
+ } else {
950
+ $video_info['Video'] = $count_streams.' streams, ';
951
+ }
952
+ foreach( $ThisFileInfo['video']['streams'] AS $stream ) {
953
+ foreach( array( 'dataformat', 'resolution_x', 'resolution_y', 'frame_rate' ) AS $item ) {
954
+ if( isset( $stream[$item] ) ) {
955
+ $add = $stream[$item];
956
+ switch( $item ) {
957
+ case 'resolution_x' : $add .= ' x'; break;
958
+ case 'resolution_y' : $add .= ', '; break;
959
+ case 'frame_rate' : $add .= ' fps '; break;
960
+ }
961
+ $video_info['Video'] .= $add.' ';
962
+ }
963
+ }
964
+ $video_info['Video'] .= '|';
965
+ }
966
+ $video_info['Video'] = trim( $video_info['Video'], '|' );
967
+
968
+ if( isset($ThisFileInfo['video']['bitrate']) ) {
969
+ $video_info['Video'] .= number_format( ceil($ThisFileInfo['video']['bitrate']/1024) ).'Kbps ';
970
+ }
971
+ }
972
+
973
+ if( isset($ThisFileInfo['video']['fourcc']) ) {
974
+ if( !isset($video_info['Video']) ) $video_info['Video'] = array();
975
+ $video_info['Video'][] .= $ThisFileInfo['video']['fourcc'].' codec';
976
+ }
977
+
978
+ if( isset($ThisFileInfo['quicktime']['ftyp']['signature']) ) {
979
+ $video_info['Video'][] .= $ThisFileInfo['quicktime']['ftyp']['signature'].' file type ';
980
+ if( strcasecmp( trim($ThisFileInfo['quicktime']['ftyp']['signature']), 'M4V' ) === 0 && preg_match( '~.m4v$~', $remotefilename ) ) {
981
+ $m4v_note_addition = false;
982
+ /*if( $fv_fp->conf['engine'] == 'default' ) {
983
+ $m4v_note_addition = ' Currently you are using the "Default (mixed)" <a href="'.site_url().'/wp-admin/options-general.php?page=fvplayer">Preferred Flowplayer engine</a> setting, so Firefox on Windows will always use Flash for M4V and will play fine.';
984
+ } */
985
+ $video_errors[] = 'We recommend that you change file extension of M4V videos to MP4, to avoid issues with Firefox on PC. '.$m4v_note_addition;
986
+ }
987
+ }
988
+
989
+ if( isset($ThisFileInfo['video']['codec']) && $ThisFileInfo['video']['codec'] == 'MPEG-1' ) {
990
+ $video_info['Video'] = 'MPEG-1 Codec';
991
+ $video_errors[] = 'MPEG-1 is not a valid HTML5 video format. You need to re-encode the video into MP4.';
992
+ }
993
+
994
+ if( isset($video_info['Video']) && is_array($video_info['Video']) ) {
995
+ $video_info['Video'] = implode( ', ', $video_info['Video'] );
996
+
997
+ $video_format_info = array( 'avc1' => 'H.264 Encoder', 'mp42' => 'MS-MPEG4 v2 Decoder' );
998
+ foreach( $video_format_info AS $key => $item ) {
999
+ $video_info['Video'] = str_replace( $key, $key.' ('.$item.')', $video_info['Video'] );
1000
+ }
1001
+ }
1002
+
1003
+
1004
+ }
1005
+ } // end is_wp_error check
1006
+
1007
+ } // end isset($media)
1008
+
1009
+
1010
+ if( $video_errors ) {
1011
+ foreach( $video_errors AS $key => $item ) {
1012
+ if( preg_match( '!Atom at offset \d+ claims to go beyond end-of-file!', $item ) ) {
1013
+ unset( $video_errors[$key] ); // we are not interested in this particular warning, as we don't download the full file
1014
+ }
1015
+ }
1016
+ }
1017
+
1018
+
1019
+ if( $video_errors ) {
1020
+ $message_items = array();
1021
+ foreach( $video_errors AS $key => $item ) {
1022
+ if( $item && stripos( $item, '</p>' ) === false ) {
1023
+ $item = '<p><strong>Error</strong>: '.$item.'</p>';
1024
+ }
1025
+ $message_items[] = $item;
1026
+ }
1027
+ $message .= implode("\n", $message_items);
1028
+ }
1029
+
1030
+ if( $video_warnings ) {
1031
+ $message_items = array();
1032
+ foreach( $video_warnings AS $key => $item ) {
1033
+ if( $item && stripos( $item, '</p>' ) === false ) {
1034
+ $item = '<p><strong>Warning</strong>: '.$item.'</p>';
1035
+ }
1036
+ $message_items[] = $item;
1037
+ }
1038
+ $message .= implode("\n", $message_items);
1039
+ }
1040
+
1041
+
1042
+ if( isset($video_info) ) {
1043
+ $message_items = array();
1044
+ foreach( $video_info AS $key => $item ) {
1045
+ $message_item = '';
1046
+ if( !is_int($key) ) {
1047
+ $message_item .= $key.': ';
1048
+ }
1049
+ $message_item .= '<tt>'.$item.'</tt>';
1050
+ $message_items[] = $message_item;
1051
+ }
1052
+ $message .= '<p>'.implode("<br />\n", $message_items).'</p>';
1053
+ }
1054
+
1055
+ $message = '<div class="mail-content-notice">'.$message.'</div>';
1056
+
1057
+ if( isset($ThisFileInfo) && $ThisFileInfo ) {
1058
+ $more_info = var_export($ThisFileInfo,true);
1059
+
1060
+ $note = '(Note: read about remote file analysis in <a href="http://foliovision.com/wordpress/plugins/fv-wordpress-flowplayer/faq">FAQ</a>)';
1061
+ $more_info = str_replace( array('Unknown QuickTime atom type', 'Atom at offset'), array($note.' Unknown QuickTime atom type', $note.' Atom at offset'), $more_info );
1062
+
1063
+ $lines = explode( "\n", $more_info );
1064
+
1065
+ $depth = 0;
1066
+ $new_info = '<p>'.$note.'</p><div class="fv-wp-flowplayer-notice-parsed level-0">';
1067
+ foreach( $lines AS $line ) {
1068
+ $class = ( $depth > 0 ) ? ' indent' : '';
1069
+
1070
+ if( strcmp( trim($line), 'array (' ) == 0 ) {
1071
+ if( $depth == 0 ) {
1072
+ $new_info .= '<div class="fv-wp-flowplayer-notice-parsed level-0 row close"></div>';
1073
+ }
1074
+ $depth++;
1075
+ $new_info .= '<div class="fv-wp-flowplayer-notice-parsed level-'.$depth.''.$class.'">';
1076
+ continue;
1077
+ }
1078
+ if( strcmp( trim($line), '),' ) == 0 ) {
1079
+ $depth--;
1080
+ $new_info .= '</div><!-- .level-'.$depth.' -->';
1081
+ $new_info .= '<div class="fv-wp-flowplayer-notice-parsed level-'.$depth.' row close"></div>';
1082
+ continue;
1083
+ }
1084
+
1085
+
1086
+ if( $depth > 7 ) {
1087
+ $style = ' fv-wp-fp-hidden';
1088
+ } else {
1089
+ $style = '';
1090
+ }
1091
+
1092
+ $line_i = explode( " => ", trim($line), 2 );
1093
+ if( !$line_i ) {
1094
+ continue;
1095
+ }
1096
+
1097
+ $line_html = '<div class="row'.$class.$style.'"><span>'.ucfirst( str_replace( "' =>", '', trim($line_i[0],"' ")) ).'</span><span class="value">'.( (isset($line_i[1])) ? trim(rtrim($line_i[1],", "),"' ") : '' ).'</span><div style="clear:both;"></div></div>';
1098
+
1099
+ $new_info .= $line_html."\n";
1100
+ }
1101
+ $new_info .= '</div>';
1102
+
1103
+ }
1104
+
1105
+ $message .= '<div class="support-'.$random.'">';
1106
+ $message .= '<textarea id="wpfp_support_'.$random.'" class="wpfp_message_field" onclick="if( this.value == \'Enter your comment\' ) this.value = \'\'" style="width: 98%; height: 150px">Enter your comment</textarea>';
1107
+ $message .= '<p><a class="techinfo" href="#" onclick="jQuery(\'.more-'.$random.'\').toggle(); return false">Technical info</a> <img id="wpfp_spin_'.$random.'" src="'.site_url().'/wp-includes/images/wpspin.gif" style="display: none; " /> <input type="button" onclick="fv_wp_flowplayer_admin_support_mail(\''.$random.'\', this); return false" value="Send report to Foliovision" /></p>';
1108
+ $message .= '</div>';
1109
+ $message .= '<div class="more-'.$random.' mail-content-details" style="display: none; "><p>Plugin version: '.$fv_wp_flowplayer_ver.'</p>'.$new_info.'</div>';
1110
+
1111
+
1112
+ if( count($video_errors) > 0 ) {
1113
+ $issues_text = '<span class="vid-issues">Video Issues</span>';
1114
+ } else if( count($video_warnings) ) {
1115
+ $issues_text = '<span class="vid-warning">Video Warnings</span>';
1116
+ } else {
1117
+ $issues_text = '<span class="vid-ok">Video OK</span>';
1118
+ }
1119
+ $message = "<div onclick='fv_wp_flowplayer_admin_show_notice(\"$random\", this.parent); return false' class='fv_wp_flowplayer_notice_head'>Report Issue</div><small>Admin: <a class='fv_wp_flowplayer_dialog_link' href='#' onclick='fv_wp_flowplayer_admin_show_notice(\"$random\", this); return false'>$issues_text</a></small><div id='fv_wp_fp_notice_$random' class='fv_wp_fp_notice_content' style='display: none;'>$message</div>\n";
1120
+
1121
+ $json = @json_encode( array( $message, count( $video_errors ), count( $video_warnings ) ) );
1122
+ $last_error = ( function_exists('json_last_error') ) ? json_last_error() : true;
1123
+
1124
+ if( $last_error ) {
1125
+ if( function_exists('mb_check_encoding') && function_exists('utf8_encode') ) {
1126
+ if(!mb_check_encoding($message, 'UTF-8')) {
1127
+ $message = utf8_encode($message);
1128
+ }
1129
+ } else {
1130
+ $message = htmlentities( $message, ENT_QUOTES, 'utf-8', FALSE);
1131
+ $message = ( $message ) ? $message : 'Admin: Error parsing JSON';
1132
+ }
1133
+
1134
+ $json = json_encode( array( $message, count( $video_errors ), count( $video_warnings ) ) );
1135
+ $last_error = ( function_exists('json_last_error') ) ? json_last_error() : false;
1136
+ if( $last_error ) {
1137
+ echo json_encode( array( 'Admin: JSON error: '.$last_error, count( $video_errors ), count( $video_warnings ) ) );
1138
+ } else {
1139
+ echo $json;
1140
+ }
1141
+ } else {
1142
+ echo $json;
1143
+ }
1144
+ die();
1145
+
1146
+ } else {
1147
+ die('-1');
1148
+ }
1149
+ }
1150
+
1151
+
1152
+ // enter script URL, return false if it's not version 5
1153
+ function fv_wp_flowplayer_check_script_version( $url ) {
1154
+ $url_mod = preg_replace( '!\?.+!', '', $url );
1155
+ if( preg_match( '!flowplayer-([\d\.]+)!', $url_mod, $version ) && $version[1] ) {
1156
+ if( strpos( $version[1], '5' ) !== 0 ) {
1157
+ return -1;
1158
+ }
1159
+ }
1160
+
1161
+ global $fv_wp_flowplayer_ver;
1162
+ if( strpos( $url, '/fv-wordpress-flowplayer/flowplayer/fv-flowplayer.min.js?ver='.$fv_wp_flowplayer_ver ) !== false ) {
1163
+ return 1;
1164
+ }
1165
+ return 0;
1166
+ }
1167
+
1168
+
1169
+ function fv_wp_flowplayer_check_jquery_version( $url, &$array, $key ) {
1170
+ if( preg_match( '!/jquery(\.[a-zA-Z]{2,}|-[a-zA-Z]{3,})[^/]*?\.js!', $url ) ) { // jquery.ui.core.min.js, jquery-outline-1.1.js
1171
+ unset( $array[$key] );
1172
+ return 2;
1173
+ }
1174
+
1175
+ $url_mod = preg_replace( '!\?.+!', '', $url );
1176
+ if( preg_match( '!(\d+.[\d\.]+)!', $url_mod, $version ) && $version[1] ) {
1177
+ if( version_compare($version[1], '1.7.1') == -1 ) {
1178
+ return -1;
1179
+ } else {
1180
+ return 1;
1181
+ }
1182
+ }
1183
+
1184
+ // if jQuery is in the Wordpress install, we know that the ?ver= says what version it is
1185
+ if( strpos( $url, site_url().'/wp-includes/js/jquery/jquery.js' ) !== false ) {
1186
+ if( preg_match( '!(\d+.[\d\.]+)!', $url, $version ) && $version[1] ) {
1187
+ if( version_compare($version[1], '1.7.1') == -1 ) {
1188
+ return -1;
1189
+ } else {
1190
+ return 1;
1191
+ }
1192
+ }
1193
+ }
1194
+
1195
+ return 0;
1196
+ }
1197
+
1198
+
1199
+ function fv_wp_flowplayer_check_files() {
1200
+ if( stripos( $_SERVER['HTTP_REFERER'], home_url() ) === 0 ) {
1201
+ global $wpdb;
1202
+ define('VIDEO_DIR', '/videos/');
1203
+
1204
+ $videos1 = $wpdb->get_results( "SELECT ID, post_content FROM $wpdb->posts WHERE post_type != 'revision' AND post_content LIKE '%[flowplayer %'" );
1205
+ $videos2 = $wpdb->get_results( "SELECT ID, post_content FROM $wpdb->posts WHERE post_type != 'revision' AND post_content LIKE '%[fvplayer %'" );
1206
+
1207
+ $videos = array_merge( $videos1, $videos2 );
1208
+
1209
+ $source_servers = array();
1210
+
1211
+ $shortcodes_count = 0;
1212
+ $src_count = 0;
1213
+ if( count($videos) ) {
1214
+ foreach( $videos AS $post ) {
1215
+
1216
+ $shortcodes_count += preg_match_all( '!\[(?:flowplayer|fvplayer)[^\]]+\]!', $post->post_content, $post_videos );
1217
+ if( count($post_videos[0]) ) {
1218
+ foreach( $post_videos[0] AS $post_video ) {
1219
+ $post_video = preg_replace( '!popup=\'.*\'!', '', $post_video );
1220
+ $src_count += preg_match_all( '!(?:src|src1|src2|src3|mp4|webm|ogv)=[\'"](.*?(?:mp4|m4v))[\'"]!', $post_video, $sources1 );
1221
+ $src_count += preg_match_all( '!(?:src|src1|src2|src3|mp4|webm|ogv)=([^\'"].*?(?:mp4|m4v|flv))[\s\]]!', $post_video, $sources2 );
1222
+ $sources = array_merge( $sources1[1], $sources2[1] );
1223
+ if( count($sources) ) {
1224
+ foreach($sources AS $src ) {
1225
+ if( strpos( $src, '//' ) === 0 ) {
1226
+ $src = 'http:'.$src;
1227
+ } else if( strpos( $src, '/' ) === 0 ) {
1228
+ $src = home_url().$src;
1229
+ } else if( !preg_match( '!^\S+://!', $src ) ) {
1230
+ $src = home_url().VIDEO_DIR.$src;
1231
+ }
1232
+
1233
+ $server = preg_replace( '!(.*?//.*?)/.+!', '$1', $src );
1234
+
1235
+ $source_servers[$server][] = array( 'src' => $src, 'post_id' => $post->ID );
1236
+ }
1237
+ }
1238
+ }
1239
+ }
1240
+
1241
+ }
1242
+ }
1243
+
1244
+ $ok = array();
1245
+ $errors = array();
1246
+
1247
+ $count = 0;
1248
+ foreach( $source_servers AS $server => $videos ) {
1249
+
1250
+ //echo $server."\n";
1251
+
1252
+ if( stripos( trim($videos[0]['src']), 'rtmp://' ) === false ) {
1253
+ $headers = get_headers( trim($videos[0]['src']) );
1254
+ }
1255
+ if( isset($headers) && $headers ) {
1256
+
1257
+ $posts_links = '';
1258
+ foreach( $videos AS $video ) {
1259
+ $posts_links .= '<a href="'.home_url().'?p='.$video['post_id'].'">'.$video['post_id'].'</a> ';
1260
+ }
1261
+
1262
+ foreach( $headers AS $line ) {
1263
+ if( stripos( $line, 'Content-Type:' ) !== FALSE ) {
1264
+ preg_match( '~Content-Type: (\S+)$~', $line, $match );
1265
+ $mime_matched = ( isset($match[1]) ) ? $match[1] : '';
1266
+
1267
+ if(
1268
+ ( !preg_match( '~video/mp4$~', $line ) && stripos( $videos[0]['src'], '.mp4' ) !== FALSE ) ||
1269
+ ( !preg_match( '~video/x-m4v$~', $line ) && stripos( $videos[0]['src'], '.m4v' ) !== FALSE )
1270
+ ) {
1271
+ if( strpos( $server, 'amazonaws' ) !== false ) {
1272
+ $fix = '<p>It\'s important to set this correctly, otherwise the videos will not play in HTML5 mode in Internet Explorer 9 and 10.</p><blockquote><code>Using your Amazon AWS Management Console, you can go though your videos and find file content type under the "Metadata" tab in an object\'s "Properties" pane and fix it to "video/mp4" for MP4 and "video/x-m4v" for M4V files.</code></blockquote>';
1273
+ } else {
1274
+ $fix = '<p>It\'s important to set this correctly, otherwise the videos will not play in HTML5 mode in Internet Explorer 9 and 10.</p><p>Make sure you put this into your .htaccess file, or ask your server admin to upgrade the web server mime type configuration:</p> <blockquote><pre><code>AddType video/mp4 .mp4
1275
+ AddType video/webm .webm
1276
+ AddType video/ogg .ogv
1277
+ AddType application/x-mpegurl .m3u8
1278
+ AddType video/x-m4v .m4v
1279
+ # hls transport stream segments:
1280
+ AddType video/mp2t .ts</code></pre></blockquote>';
1281
+ }
1282
+
1283
+ $errors[] = 'Server <code>'.$server.'</code> uses bad mime type <code>'.$mime_matched.'</code> for MP4 or M4V videos! (<a href="#" onclick="jQuery(\'#fv-flowplayer-warning-'.$count.'\').toggle(); return false">click to see a list of posts</a>) (<a href="#" onclick="jQuery(\'#fv-flowplayer-info-'.$count.'\').toggle(); return false">show fix</a>) <div id="fv-flowplayer-warning-'.$count.'" style="display: none; ">'.$posts_links.'</div> <div id="fv-flowplayer-info-'.$count.'" style="display: none; ">'.$fix.'</div>';
1284
+ } else if(
1285
+ ( !preg_match( '~video/webm$~', $line ) && stripos( $videos[0]['src'], '.webm' ) !== FALSE )
1286
+ ) {
1287
+ if( strpos( $server, 'amazonaws' ) !== false ) {
1288
+ $fix = '<p>It\'s important to set this correctly, otherwise the videos will not play in older Firefox.</p><blockquote><code>Using your Amazon AWS Management Console, you can go though your videos and find file content type under the "Metadata" tab in an object\'s "Properties" pane and fix it to "video/webm" for WEBM videos.</code></blockquote>';
1289
+ } else {
1290
+ $fix = '<p>It\'s important to set this correctly, otherwise the videos will not play in older Firefox.</p><p>Make sure you put this into your .htaccess file, or ask your server admin to upgrade the web server mime type configuration:</p> <blockquote><pre><code>AddType video/mp4 .mp4
1291
+ AddType video/webm .webm
1292
+ AddType video/ogg .ogv
1293
+ AddType application/x-mpegurl .m3u8
1294
+ AddType video/x-m4v .m4v
1295
+ # hls transport stream segments:
1296
+ AddType video/mp2t .ts</code></pre></blockquote>';
1297
+ }
1298
+
1299
+ $errors[] = 'Server <code>'.$server.'</code> uses bad mime type <code>'.$mime_matched.'</code> for MP4 or M4V videos! (<a href="#" onclick="jQuery(\'#fv-flowplayer-warning-'.$count.'\').toggle(); return false">click to see a list of posts</a>) (<a href="#" onclick="jQuery(\'#fv-flowplayer-info-'.$count.'\').toggle(); return false">show fix</a>) <div id="fv-flowplayer-warning-'.$count.'" style="display: none; ">'.$posts_links.'</div> <div id="fv-flowplayer-info-'.$count.'" style="display: none; ">'.$fix.'</div>';
1300
+ } else if( stripos( $videos[0]['src'], '.mp4' ) !== FALSE || stripos( $videos[0]['src'], '.m4v' ) !== FALSE ) {
1301
+ $ok[] = 'Server <code>'.$server.'</code> appears to serve correct mime type <code>'.$mime_matched.'</code> for MP4 and M4V videos.';
1302
+ }
1303
+ }
1304
+ }
1305
+
1306
+ $count++;
1307
+ }
1308
+
1309
+ if( $server == 'http://lifeinamovie.com' ) {
1310
+ //break;
1311
+ }
1312
+
1313
+ }
1314
+
1315
+ $output = array( 'errors' => $errors, 'ok' => $ok/*, 'html' => $response['body'] */);
1316
+ echo json_encode($output);
1317
+ die();
1318
+ }
1319
+ die('-1');
1320
+ }
1321
+
1322
+
1323
+ function fv_wp_flowplayer_check_template() {
1324
+ $ok = array();
1325
+ $errors = array();
1326
+
1327
+ if( stripos( $_SERVER['HTTP_REFERER'], home_url() ) === 0 ) {
1328
+ $response = wp_remote_get( home_url().'?fv_wp_flowplayer_check_template=yes' );
1329
+ if( is_wp_error( $response ) ) {
1330
+ $error_message = $response->get_error_message();
1331
+ $output = array( 'error' => $error_message );
1332
+ } else {
1333
+
1334
+ $active_plugins = get_option( 'active_plugins' );
1335
+ foreach( $active_plugins AS $plugin ) {
1336
+ if( stripos( $plugin, 'wp-minify' ) !== false ) {
1337
+ $errors[] = "You are using <strong>WP Minify</strong>, so the script checks would not be accurate. Please check your videos manually.";
1338
+ $wp_minify_options = get_option('wp_minify');
1339
+ if( isset($wp_minify_options['js_in_footer']) && $wp_minify_options['js_in_footer'] ) {
1340
+ $errors[] = "Please make sure that you turn off Settings -> WP Minify -> 'Place Minified JavaScript in footer'.";
1341
+ }
1342
+ $output = array( 'errors' => $errors, 'ok' => $ok/*, 'html' => $response['body'] */);
1343
+ echo json_encode($output);
1344
+ die();
1345
+ }
1346
+ }
1347
+
1348
+ if( function_exists( 'w3_instance' ) && $minify = w3_instance('W3_Plugin_Minify') ) {
1349
+ if( $minify->_config->get_boolean('minify.js.enable') ) {
1350
+ $errors[] = "You are using <strong>W3 Total Cache</strong> with JS Minify enabled. The template check might not be accurate. Please check your videos manually.";
1351
+ }
1352
+ }
1353
+
1354
+ if( stripos($response['body'],'<!--fv-flowplayer-footer-->') === false ) {
1355
+ $errors[] = "It appears that your template is not using the wp_footer() hook. Advanced FV Flowplayer functions may not work properly.";
1356
+ } else {
1357
+ $ok[] = "wp_footer found in your template!";
1358
+ }
1359
+
1360
+ $response['body'] = preg_replace( '$<!--[\s\S]+?-->$', '', $response['body'] ); // handle HTML comments
1361
+
1362
+ // check Flowplayer scripts
1363
+ preg_match_all( '!<script[^>]*?src=[\'"]([^\'"]*?flowplayer[^\'"]*?\.js[^\'"]*?)[\'"][^>]*?>\s*?</script>!', $response['body'], $flowplayer_scripts );
1364
+ if( count($flowplayer_scripts[1]) > 0 ) {
1365
+ if( count($flowplayer_scripts[1]) > 1 ) {
1366
+ $errors[] = "It appears there are <strong>multiple</strong> Flowplayer scripts on your site, your videos might not be playing, please check. There might be some other plugin adding the script.";
1367
+ }
1368
+ foreach( $flowplayer_scripts[1] AS $flowplayer_script ) {
1369
+ $check = fv_wp_flowplayer_check_script_version( $flowplayer_script );
1370
+ if( $check == - 1 ) {
1371
+ $errors[] = "Flowplayer script <code>$flowplayer_script</code> is old version and won't play. You need to get rid of this script.";
1372
+ } else if( $check == 1 ) {
1373
+ $ok[] = "FV Flowplayer script found: <code>$flowplayer_script</code>!";
1374
+ $fv_flowplayer_pos = strpos( $response['body'], $flowplayer_script );
1375
+ }
1376
+ }
1377
+ } else if( count($flowplayer_scripts[1]) < 1 ) {
1378
+ $errors[] = "It appears there are <strong>no</strong> Flowplayer scripts on your site, your videos might not be playing, please check. Check your header.php file if it contains wp_head() function call!";
1379
+ }
1380
+
1381
+
1382
+ // check jQuery scripts
1383
+ preg_match_all( '!<script[^>]*?src=[\'"]([^\'"]*?jquery[^\'"]*?\.js[^\'"]*?)[\'"][^>]*?>\s*?</script>!', $response['body'], $jquery_scripts );
1384
+ if( count($jquery_scripts[1]) > 0 ) {
1385
+ foreach( $jquery_scripts[1] AS $jkey => $jquery_script ) {
1386
+ $check = fv_wp_flowplayer_check_jquery_version( $jquery_script, $jquery_scripts[1], $jkey );
1387
+ if( $check == - 1 ) {
1388
+ $errors[] = "jQuery library <code>$jquery_script</code> is old version and might not be compatible with Flowplayer.";
1389
+ } else if( $check == 1 ) {
1390
+ $ok[] = "jQuery library 1.7.1+ found: <code>$jquery_script</code>!";
1391
+ $jquery_pos = strpos( $response['body'], $jquery_script );
1392
+ } else if( $check == 2 ) {
1393
+ // nothing
1394
+ } else {
1395
+ $errors[] = "jQuery library <code>$jquery_script</code> found, but unable to check version, please make sure it's at least 1.7.1.";
1396
+ }
1397
+ }
1398
+ if( count($jquery_scripts[1]) > 1 ) {
1399
+ $errors[] = "It appears there are <strong>multiple</strong> jQuery libraries on your site, your videos might not be playing, please check.\n";
1400
+ }
1401
+ } else if( count($jquery_scripts[1]) < 1 ) {
1402
+ $errors[] = "It appears there are <strong>no</strong> jQuery library on your site, your videos might not be playing, please check.\n";
1403
+ }
1404
+
1405
+
1406
+ if( $fv_flowplayer_pos > 0 && $jquery_pos > 0 && $jquery_pos > $fv_flowplayer_pos ) {
1407
+ $errors[] = "It appears your Flowplayer JavaScript library is loading before jQuery. Your videos probably won't work. Please make sure your jQuery library is loading using the standard Wordpress function - wp_enqueue_scripts(), or move it above wp_head() in your header.php template.";
1408
+ }
1409
+
1410
+
1411
+ $output = array( 'errors' => $errors, 'ok' => $ok/*, 'html' => $response['body'] */);
1412
+ }
1413
+ echo json_encode($output);
1414
+ die();
1415
+ }
1416
+
1417
+ die('-1');
1418
+ }
1419
+
1420
+
1421
+ function fv_wp_flowplayer_array_search_by_item( $find, $in_array, &$found, $like = false ) {
1422
+ global $fv_wp_flowplayer_array_search_by_item_depth;
1423
+
1424
+ $fv_wp_flowplayer_array_search_by_item_depth++;
1425
+ if( $fv_wp_flowplayer_array_search_by_item_depth > 100 ) {
1426
+ return false;
1427
+ }
1428
+
1429
+ if( is_array( $in_array ) )
1430
+ {
1431
+ foreach( $in_array as $key=> $val )
1432
+ {
1433
+ if( is_array( $val ) ) {
1434
+ fv_wp_flowplayer_array_search_by_item( $find, $val, $found );
1435
+ } else {
1436
+ if( !$like && strcasecmp($find, $val) === 0 ) {
1437
+ $found[] = $in_array;
1438
+ } else if( $like && stripos($val, $find) !== false ) {
1439
+ $found[] = $in_array;
1440
+ }
1441
+ }
1442
+ }
1443
+ return false;
1444
+ }
1445
+ return false;
1446
+ }
1447
+
1448
+
1449
+ function fv_wp_flowplayer_support_mail() {
1450
+ if( isset( $_POST['notice'] ) && stripos( $_SERVER['HTTP_REFERER'], home_url() ) === 0 ) {
1451
+
1452
+ global $current_user;
1453
+ get_currentuserinfo();
1454
+
1455
+ $content = '<p>User: '.$current_user->display_name." (".$current_user->user_email.")</p>\n";
1456
+ $content .= '<p>User Agent: '.$_SERVER['HTTP_USER_AGENT']."</p>\n";
1457
+ $content .= '<p>Referer: '.$_SERVER['HTTP_REFERER']."</p>\n";
1458
+ $content .= "<p>Comment:</p>\n".wpautop( stripslashes($_POST['comment']) );
1459
+ $notice = str_replace( '<span class="value"', ': <span class="value"', stripslashes($_POST['notice']) );
1460
+ $notice .= str_replace( '<span class="value"', ': <span class="value"', stripslashes($_POST['details']) );
1461
+
1462
+ $content .= "<p>Video analysis:</p>\n".$notice;
1463
+
1464
+ global $fv_wp_flowplayer_support_mail_from, $fv_wp_flowplayer_support_mail_from_name;
1465
+
1466
+ //$headers = "Reply-To: \"$current_user->display_name\" <$current_user->user_email>\r\n";
1467
+ $fv_wp_flowplayer_support_mail_from_name = $current_user->display_name;
1468
+ $fv_wp_flowplayer_support_mail_from = $current_user->user_email;
1469
+
1470
+ add_filter( 'wp_mail_content_type', create_function('', "return 'text/html';") );
1471
+
1472
+ //add_action('phpmailer_init', 'fv_wp_flowplayer_support_mail_phpmailer_init' );
1473
+ wp_mail( 'fvplayer@foliovision.com', 'FV Flowplayer Quick Support Submission', $content );
1474
+
1475
+ die('1');
1476
+ }
1477
+ }
1478
+
1479
+
1480
+ function fv_wp_flowplayer_support_mail_phpmailer_init( $phpmailer ) {
1481
+ global $fv_wp_flowplayer_support_mail_from, $fv_wp_flowplayer_support_mail_from_name;
1482
+
1483
+ if( $fv_wp_flowplayer_support_mail_from_name ) {
1484
+ $phpmailer->FromName = trim( $fv_filled_in_phpmailer_init_from_name );
1485
+ }
1486
+ if( $fv_wp_flowplayer_support_mail_from ) {
1487
+ if( strcmp( trim($phpmailer->From), trim($fv_wp_flowplayer_support_mail_from) ) != 0 && !trim($phpmailer->Sender) ) {
1488
+ $phpmailer->Sender = trim($phpmailer->From);
1489
+ }
1490
+ $phpmailer->From = trim( $fv_wp_flowplayer_support_mail_from );
1491
+ }
1492
+
1493
+ }
1494
+
1495
+
1496
+ function fv_wp_flowplayer_save_post( $id ) {
1497
+ if( wp_is_post_revision($id) ) {
1498
+ return true;
1499
+ }
1500
+
1501
+ global $fv_fp;
1502
+ if( !isset($fv_fp->conf['amazon_bucket']) ) {
1503
+ return;
1504
+ }
1505
+
1506
+ $videos = array();
1507
+ $saved_post = get_post($id);
1508
+ preg_match_all( '~\[(?:flowplayer|fvplayer).*?\]~', $saved_post->post_content, $matches );
1509
+ if( isset($matches[0]) && count($matches[0]) ) {
1510
+ foreach( $matches[0] AS $shortcode ) {
1511
+ $process = false;
1512
+ foreach( $fv_fp->conf['amazon_bucket'] AS $bucket ) {
1513
+ if( strlen(trim($bucket)) > 0 && preg_match( '~[\'"](\S+?'.$bucket.'\S+?)[\'"]~', $shortcode, $process) ) {
1514
+ $videos[] = $process[1];
1515
+ break;
1516
+ }
1517
+ }
1518
+ }
1519
+ }
1520
+
1521
+ if( count($videos) > 0 ) {
1522
+ $videos = array_unique($videos);
1523
+ foreach( $videos AS $video ) {
1524
+ global $post;
1525
+ if( $fv_flowplayer_meta = get_post_meta( $post->ID, '_fv_flowplayer', true ) ) {
1526
+ if( isset($fv_flowplayer_meta[sanitize_title($video)]) ) {
1527
+ continue;
1528
+ }
1529
+ }
1530
+
1531
+ $video_secured = $fv_fp->get_amazon_secure($video, $fv_fp);
1532
+ fv_wp_flowplayer_check_mimetype( array($video_secured), array( 'meta_action' => 'check_time', 'meta_original' => $video ) );
1533
+ }
1534
+ }
1535
+ }
1536
+
1537
+
1538
+ function fv_wp_flowplayer_closed_meta_boxes( $closed ) {
1539
+ if ( false === $closed )
1540
+ $closed = array( 'fv_flowplayer_amazon_options', 'fv_flowplayer_interface_options', 'fv_flowplayer_default_options', 'fv_flowplayer_ads', 'fv_flowplayer_skin' );
1541
+
1542
+ return $closed;
1543
+ }
1544
+
1545
+
1546
+ function fv_wp_flowplayer_pointers_ajax() {
1547
+ if( isset($_POST['key']) && $_POST['key'] == 'fv_flowplayer_key_automatic' && isset($_POST['value']) ) {
1548
+ check_ajax_referer('fv_flowplayer_key_automatic');
1549
+ $conf = get_option( 'fvwpflowplayer' );
1550
+ if( $conf ) {
1551
+ $conf['key_automatic'] = ( $_POST['value'] == 'true' ) ? 'true' : 'false';
1552
+ if( $conf['key_automatic'] == 'true' ) {
1553
+ fv_wp_flowplayer_admin_key_update();
1554
+ $conf = get_option( 'fvwpflowplayer' );
1555
+ } else {
1556
+ global $fv_wp_flowplayer_core_ver;
1557
+ update_option( 'fvwpflowplayer_core_ver', $fv_wp_flowplayer_core_ver );
1558
+ }
1559
+ update_option( 'fvwpflowplayer', $conf );
1560
+ }
1561
+ die();
1562
+ }
1563
+ }
1564
+
1565
  ?>
controller/frontend.php CHANGED
@@ -1,183 +1,309 @@
1
- <?php
2
- /**
3
- * Needed includes
4
- */
5
- include_once(dirname( __FILE__ ) . '/../models/flowplayer.php');
6
- if(get_option('wp_mobile_video_active')=='enabled')
7
- include_once(dirname( __FILE__ ) . '/../../wp-mobile-video-player/models/flowplayer-frontend.php');
8
- else
9
- include_once(dirname( __FILE__ ) . '/../models/flowplayer-frontend.php');
10
- /**
11
- * WP Hooks
12
- */
13
- //add_action('the_content', 'flowplayer_content_remove_commas');
14
- add_action('wp_head', 'flowplayer_head');
15
- add_action('wp_footer','flowplayer_display_scripts');
16
- // Addition for 0.9.15
17
- //add_action('widget_text','flowplayer_content');
18
- add_filter('widget_text','do_shortcode');
19
- function fvfp_remove_shortcode_feed($content) {
20
- if(is_feed()) {
21
- $content = preg_replace('/\[flowplayer.*?\]/','',$content);
22
- $content = preg_replace('/<a id="wpfp_.*\/a>/','',$content);
23
- }
24
- return $content;
25
- }
26
- add_filter('the_excerpt_rss', 'fvfp_remove_shortcode_feed');
27
- add_filter('the_content_feed', 'fvfp_remove_shortcode_feed');
28
- /**
29
- * END WP Hooks
30
- */
31
- $GLOBALS['scripts'] = array();
32
- function flowplayer_content_remove_commas($content){
33
- preg_match('/.*popup=\'(.*?)\'.*/', $content, $matches);
34
- //var_dump($matches);
35
- $content_new = preg_replace('/\,/', '',$content);
36
- if (isset($matches[1]))
37
- $content_new = preg_replace('/popup=\'(.*?)\'/', 'popup=\''.$matches[1].'\'',$content_new);
38
- // var_dump($content_new);
39
- return $content_new;
40
- }
41
- /**
42
- * Replaces the flowplayer tags in post content by players and fills the $GLOBALS['scripts'] array.
43
- * @param string Content to be parsed
44
- * @return string Modified content string
45
- */
46
- function flowplayer_content( $content ) {
47
- $content_matches = array();
48
- preg_match_all('/\[flowplayer\ [^\]]+\]/i', $content, $content_matches);
49
- // process all found tags
50
- foreach ($content_matches[0] as $tag) {
51
- $ntag = str_replace("\'",'&#039;',$tag);
52
- // search for URL
53
- preg_match("/src='([^']*?)'/i",$ntag,$tmp);
54
- if( $tmp[1] == NULL ) {
55
- preg_match_all("/src=([^,\s\]]*)/i",$ntag,$tmp);
56
- $media = $tmp[1][0];
57
- }
58
- else
59
- $media = $tmp[1];
60
- //strip the additional /videos/ from the beginning if present
61
- preg_match('/(.*)\/videos\/(.*)/',$media,$matches);
62
- /* if ($matches[0] == NULL)
63
- $media = $matches[2];
64
- else
65
- $media = $matches[0];*/
66
- if ($matches[0] == NULL)
67
- $media = $media;
68
- elseif ($matches[1] == NULL){
69
- $media = $matches[2];//$tmp[1][0];
70
- }
71
- else{
72
- $media = $matches[2];
73
- }
74
- // var_dump($media);
75
- // width and heigth
76
- preg_match("/width=(\d*)/i",$ntag,$width);
77
- preg_match("/height=(\d*)/i",$ntag,$height);
78
- if( $width[1] != NULL)
79
- $arguments['width'] = $width[1];
80
- if( $height[1] != NULL)
81
- $arguments['height'] = $height[1];
82
- preg_match("/controlbar=\'?([a-zA-Z]*)\'?/i",$ntag,$controlbar);
83
- if( $controlbar[1] != NULL)
84
- $arguments['controlbar'] = $controlbar[1];
85
- preg_match("/redirect=\'?([^\s\]]*)\'?/i",$ntag,$redirect);
86
- if( $redirect[1] != NULL)
87
- $arguments['redirect'] = $redirect[1];
88
- // search for autoplay
89
- preg_match("/[\s]+autoplay([\s]|])+/i",$ntag,$tmp);
90
- if (isset($tmp[0])){
91
- $arguments['autoplay'] = true;
92
- }
93
- else
94
- {
95
- preg_match("/autoplay='([A-Za-z]*)'/i",$ntag,$tmp);
96
- if ( $tmp[1] == NULL )
97
- preg_match("/autoplay=([A-Za-z]*)/i",$ntag,$tmp);
98
- if (isset($tmp[1])) $arguments['autoplay'] = $tmp[1];
99
- }
100
- // search for popup in quotes
101
- preg_match("/popup='([^']*?)'/i",$ntag,$tmp);
102
- $arguments['popup'] = $tmp[1];
103
- // search for splash image
104
- preg_match("/splash='([^']*?)'/i",$ntag,$tmp); //quotes version
105
- if( $tmp[1] == NULL ) {
106
- preg_match_all("/splash=([^,\s\]]*)/i",$ntag,$tmp); //non quotes version
107
- preg_match('/(.*)\/videos\/(.*)/i',$tmp[1][0],$matches);
108
- if ($matches[0] == NULL)
109
- $arguments['splash'] = $tmp[1][0];
110
- elseif ($matches[1] == NULL){
111
- $arguments['splash'] = $matches[2];//$tmp[1][0];
112
- }
113
- else{
114
- $arguments['splash'] = $matches[2];
115
- }
116
- }
117
- else{
118
- preg_match('/(.*)\/videos\/(.*)/',$tmp[1],$matches);
119
- if ($matches[0] == NULL)
120
- $arguments['splash'] = $tmp[1];
121
- elseif ($matches[1] == NULL)
122
- $arguments['splash'] = $matches[2];
123
- else
124
- $arguments['splash'] = $matches[2];//$tmp[1];
125
- }
126
- if (trim($media) != '') {
127
- // build new player
128
- $fp = new flowplayer_frontend();
129
- $new_player = $fp->build_min_player($media,NULL,$arguments);
130
- $content = str_replace($tag, $new_player['html'],$content);
131
- $GLOBALS['scripts'][] = $new_player['script'];
132
- }
133
- }
134
- return $content;
135
- }
136
- /**
137
- * Prints flowplayer javascript content to the bottom of the page.
138
- */
139
- function flowplayer_display_scripts() {
140
- if (!empty($GLOBALS['scripts'])) {
141
- $conf = get_option( 'fvwpflowplayer' );
142
- if ($conf['optimizejs']=='true'){
143
- echo "<script type=\"text/javascript\" src=\"" . RELATIVE_PATH . "/flowplayer/flowplayer.min.js\"></script>\n";
144
- echo "<script type=\"text/javascript\" src=\"" . RELATIVE_PATH . "/js/checkvideo.js\"></script>\n";
145
- echo "<!--[if lt IE 7.]>
146
- <script defer type=\"text/javascript\" src=\"" . RELATIVE_PATH . "/js/pngfix.js\"></script>
147
- <![endif]-->
148
- <script type=\"text/javascript\">
149
- /*<![CDATA[*/
150
- function fp_replay(hash) {
151
- var fp = document.getElementById('wpfp_'+hash);
152
- var popup = document.getElementById('wpfp_'+hash+'_popup');
153
- fp.removeChild(popup);
154
- flowplayer('wpfp_'+hash).play();
155
- }
156
- function fp_share(hash) {
157
- var cp = document.getElementById('wpfp_'+hash+'_custom_popup');
158
- cp.innerHTML = '<div style=\"margin-top: 10px; text-align: center;\"><label for=\"permalink\" style=\"color: white;\">Permalink to this page:</label><input onclick=\"this.select();\" id=\"permalink\" name=\"permalink\" type=\"text\" value=\"http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']."\" /></div>';
159
- }
160
- /*]]>*/
161
- </script>";
162
- }
163
- echo "\n<script type=\"text/javascript\">\n\n\n";
164
- foreach ($GLOBALS['scripts'] as $scr) {
165
- echo $scr;
166
- }
167
- echo "\n\n//\n</script>\n";
168
- }
169
- }
170
- /**
171
- * This is the template tag. Use the standard Flowplayer shortcodes
172
- */
173
- function flowplayer($shortcode) {
174
- echo apply_filters('the_content',$shortcode);
175
- }
176
- add_filter( "the_content_feed", "strip_flowplayer_from_feed" ) ;
177
- function strip_flowplayer_from_feed($content)
178
- {
179
- preg_match('/(<img src[\s\S]*?class=\"splash\" \/>)/',$content,$matches);
180
- $content = preg_replace('/<p><a id=\"wpfp[\S\s]*?p>/',$matches[1],$content);
181
- return $content;
182
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  ?>
1
+ <?php
2
+ /* FV Wordpress Flowplayer - HTML5 video player with Flash fallback
3
+ Copyright (C) 2013 Foliovision
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+ include_once(dirname( __FILE__ ) . '/../models/flowplayer.php');
20
+ include_once(dirname( __FILE__ ) . '/../models/flowplayer-frontend.php');
21
+
22
+ $fv_fp = new flowplayer_frontend();
23
+
24
+ /**
25
+ * WP Hooks
26
+ */
27
+ //add_action('the_content', 'flowplayer_content_remove_commas');
28
+ add_action('wp_head', 'flowplayer_head');
29
+ add_action('wp_footer','flowplayer_prepare_scripts',9);
30
+ add_action('wp_footer','flowplayer_display_scripts',100);
31
+ // Addition for 0.9.15
32
+ add_action('widget_text','flowplayer_content');
33
+ add_action('wp_enqueue_scripts', 'flowplayer_jquery');
34
+ /**
35
+ * END WP Hooks
36
+ */
37
+
38
+
39
+ function flowplayer_content_remove_commas($content) {
40
+ preg_match('/.*popup=\'(.*?)\'.*/', $content, $matches);
41
+ $content_new = preg_replace('/\,/', '',$content);
42
+ if (isset($matches[1]))
43
+ $content_new = preg_replace('/popup=\'(.*?)\'/', 'popup=\''.$matches[1].'\'',$content_new);
44
+ return $content_new;
45
+ }
46
+
47
+ /**
48
+ * Replaces the flowplayer tags in post content by players and fills the $GLOBALS['fv_fp_scripts'] array.
49
+ * @param string Content to be parsed
50
+ * @return string Modified content string
51
+ */
52
+ function flowplayer_content( $content ) {
53
+ global $fv_fp;
54
+
55
+ $content_matches = array();
56
+ preg_match_all('/\[(flowplayer|fvplayer)\ [^\]]+\]/i', $content, $content_matches);
57
+
58
+ // process all found tags
59
+ foreach ($content_matches[0] as $tag) {
60
+ $ntag = str_replace("\'",'&#039;',$tag);
61
+ //search for URL
62
+ preg_match("/src='([^']*?)'/i",$ntag,$tmp);
63
+ if( $tmp[1] == NULL ) {
64
+ preg_match_all("/src=([^,\s\]]*)/i",$ntag,$tmp);
65
+ $media = $tmp[1][0];
66
+ }
67
+ else
68
+ $media = $tmp[1];
69
+
70
+ //strip the additional /videos/ from the beginning if present
71
+ preg_match('/(.*)\/videos\/(.*)/',$media,$matches);
72
+ if ($matches[0] == NULL)
73
+ $media = $media;
74
+ else if ($matches[1] == NULL) {
75
+ $media = $matches[2];
76
+ }
77
+ else {
78
+ $media = $matches[2];
79
+ }
80
+
81
+ unset($arguments['src']);
82
+ unset($arguments['src1']);
83
+ unset($arguments['src2']);
84
+ unset($arguments['width']);
85
+ unset($arguments['height']);
86
+ unset($arguments['autoplay']);
87
+ unset($arguments['splash']);
88
+ unset($arguments['splashend']);
89
+ unset($arguments['popup']);
90
+ unset($arguments['controlbar']);
91
+ unset($arguments['redirect']);
92
+ unset($arguments['loop']);
93
+
94
+ //width and heigth
95
+ preg_match("/width=(\d*)/i",$ntag,$width);
96
+ preg_match("/height=(\d*)/i",$ntag,$height);
97
+ if( $width[1] != NULL)
98
+ $arguments['width'] = $width[1];
99
+ if( $height[1] != NULL)
100
+ $arguments['height'] = $height[1];
101
+
102
+ //search for redirect
103
+ preg_match("/redirect='([^']*?)'/i",$ntag,$tmp);
104
+ if ($tmp[1])
105
+ $arguments['redirect'] = $tmp[1];
106
+
107
+ //search for autoplay
108
+ preg_match("/[\s]+autoplay([\s]|])+/i",$ntag,$tmp);
109
+ if (isset($tmp[0])){
110
+ $arguments['autoplay'] = true;
111
+ }
112
+ else {
113
+ preg_match("/autoplay='([A-Za-z]*)'/i",$ntag,$tmp);
114
+ if ( $tmp[1] == NULL )
115
+ preg_match("/autoplay=([A-Za-z]*)/i",$ntag,$tmp);
116
+ if (isset($tmp[1]))
117
+ $arguments['autoplay'] = $tmp[1];
118
+ }
119
+
120
+ //search for popup in quotes
121
+ preg_match("/popup='([^']*?)'/i",$ntag,$tmp);
122
+ if ($tmp[1])
123
+ $arguments['popup'] = $tmp[1];
124
+
125
+ //search for loop
126
+ preg_match("/[\s]+loop([\s]|])+/i",$ntag,$tmp);
127
+ if (isset($tmp[0])){
128
+ $arguments['loop'] = true;
129
+ }
130
+ else {
131
+ preg_match("/loop='([A-Za-z]*)'/i",$ntag,$tmp);
132
+ if ( $tmp[1] == NULL )
133
+ preg_match("/loop=([A-Za-z]*)/i",$ntag,$tmp);
134
+ if (isset($tmp[1]))
135
+ $arguments['loop'] = $tmp[1];
136
+ }
137
+
138
+ // search for splash image
139
+ preg_match("/splash='([^']*?)'/i",$ntag,$tmp); //quotes version
140
+ if( $tmp[1] == NULL ) {
141
+ preg_match_all("/splash=([^,\s\]]*)/i",$ntag,$tmp); //non quotes version
142
+ preg_match('/(.*)\/videos\/(.*)/i',$tmp[1][0],$matches);
143
+ if ($matches[0] == NULL)
144
+ $arguments['splash'] = $tmp[1][0];
145
+ else if ($matches[1] == NULL) {
146
+ $arguments['splash'] = $matches[2];//$tmp[1][0];
147
+ }
148
+ else {
149
+ $arguments['splash'] = $matches[2];
150
+ }
151
+ }
152
+ else {
153
+ preg_match('/(.*)\/videos\/(.*)/',$tmp[1],$matches);
154
+ if ($matches[0] == NULL)
155
+ $arguments['splash'] = $tmp[1];
156
+ elseif ($matches[1] == NULL)
157
+ $arguments['splash'] = $matches[2];
158
+ else
159
+ $arguments['splash'] = $matches[2];//$tmp[1];
160
+ }
161
+
162
+ // search for src1
163
+ preg_match("/src1='([^']*?)'/i",$ntag,$tmp); //quotes version
164
+ if( $tmp[1] == NULL ) {
165
+ preg_match_all("/src1=([^,\s\]]*)/i",$ntag,$tmp); //non quotes version
166
+ preg_match('/(.*)\/videos\/(.*)/i',$tmp[1][0],$matches);
167
+ if ($matches[0] == NULL)
168
+ $arguments['src1'] = $tmp[1][0];
169
+ else if ($matches[1] == NULL) {
170
+ $arguments['src1'] = $matches[2];//$tmp[1][0];
171
+ }
172
+ else {
173
+ $arguments['src1'] = $matches[2];
174
+ }
175
+ }
176
+ else {
177
+ preg_match('/(.*)\/videos\/(.*)/',$tmp[1],$matches);
178
+ if ($matches[0] == NULL)
179
+ $arguments['src1'] = $tmp[1];
180
+ elseif ($matches[1] == NULL)
181
+ $arguments['src1'] = $matches[2];
182
+ else
183
+ $arguments['src1'] = $matches[2];//$tmp[1];
184
+ }
185
+
186
+ // search for src1
187
+ preg_match("/src2='([^']*?)'/i",$ntag,$tmp); //quotes version
188
+ if( $tmp[1] == NULL ) {
189
+ preg_match_all("/src2=([^,\s\]]*)/i",$ntag,$tmp); //non quotes version
190
+ preg_match('/(.*)\/videos\/(.*)/i',$tmp[1][0],$matches);
191
+ if ($matches[0] == NULL)
192
+ $arguments['src2'] = $tmp[1][0];
193
+ else if ($matches[1] == NULL) {
194
+ $arguments['src2'] = $matches[2];//$tmp[1][0];
195
+ }
196
+ else {
197
+ $arguments['src2'] = $matches[2];
198
+ }
199
+ }
200
+ else {
201
+ preg_match('/(.*)\/videos\/(.*)/',$tmp[1],$matches);
202
+ if ($matches[0] == NULL)
203
+ $arguments['src2'] = $tmp[1];
204
+ elseif ($matches[1] == NULL)
205
+ $arguments['src2'] = $matches[2];
206
+ else
207
+ $arguments['src2'] = $matches[2];//$tmp[1];
208
+ }
209
+
210
+ //search for splashend
211
+ preg_match("/[\s]+splashend([\s]|])+/i",$ntag,$tmp);
212
+ if (isset($tmp[0])){
213
+ $arguments['splashend'] = true;
214
+ }
215
+ else {
216
+ preg_match("/splashend='([A-Za-z]*)'/i",$ntag,$tmp);
217
+ if ( $tmp[1] == NULL )
218
+ preg_match("/splashend=([A-Za-z]*)/i",$ntag,$tmp);
219
+ if (isset($tmp[1]))
220
+ $arguments['splashend'] = $tmp[1];
221
+ }
222
+
223
+ //search for controlbar
224
+ preg_match("/[\s]+controlbar([\s]|])+/i",$ntag,$tmp);
225
+ if (isset($tmp[0])){
226
+ $arguments['controlbar'] = true;
227
+ }
228
+ else {
229
+ preg_match("/controlbar='([A-Za-z]*)'/i",$ntag,$tmp);
230
+ if ( $tmp[1] == NULL )
231
+ preg_match("/controlbar=([A-Za-z]*)/i",$ntag,$tmp);
232
+ if (isset($tmp[1]))
233
+ $arguments['controlbar'] = $tmp[1];
234
+ }
235
+
236
+ if (trim($media) != '') {
237
+ // build new player
238
+ $new_player = $fv_fp->build_min_player($media,$arguments);
239
+ $content = str_replace($tag, $new_player['html'],$content);
240
+ if (!empty($new_player['script'])) {
241
+ $GLOBALS['fv_fp_scripts'] = $new_player['script'];
242
+ }
243
+ }
244
+ }
245
+ return $content;
246
+ }
247
+
248
+ /**
249
+ * Figure out if we need to include MediaElement.js
250
+ */
251
+ function flowplayer_prepare_scripts() {
252
+ global $fv_fp, $fv_wp_flowplayer_ver;
253
+ $sPluginUrl = preg_replace( '~^.*://~', '//', FV_FP_RELATIVE_PATH );
254
+
255
+ $sCommercialKey = (isset($fv_fp->conf['key']) && $fv_fp->conf['key'] != 'false' && strlen($fv_fp->conf['key']) > 0) ? $fv_fp->conf['key'] : '';
256
+ $sLogo = ($sCommercialKey && isset($fv_fp->conf['logo']) && $fv_fp->conf['logo'] != 'false' && strlen($fv_fp->conf['logo']) > 0) ? $fv_fp->conf['logo'] : '';
257
+
258
+ if( $fv_fp->load_mediaelement && !wp_script_is('wp-mediaelement') ) {
259
+ wp_enqueue_script( 'flowplayer-mediaelement', plugins_url( '/fv-wordpress-flowplayer/mediaelement/mediaelement-and-player.min.js' ), array('jquery'), $fv_wp_flowplayer_ver, true );
260
+ }
261
+ wp_localize_script( 'flowplayer', 'fv_flowplayer_playlists', $fv_fp->aPlaylists );
262
+ wp_localize_script( 'flowplayer', 'fv_fp_ajaxurl', site_url().'/wp-admin/admin-ajax.php' );
263
+
264
+ $aConf = array('embed' => array( 'library' => $sPluginUrl.'/flowplayer/fv-flowplayer.min.js', 'script' => $sPluginUrl.'/flowplayer/embed.min.js', 'skin' => $sPluginUrl.'/css/flowplayer.css', 'swf' => $sPluginUrl.'/flowplayer/flowplayer.swf?ver='.$fv_wp_flowplayer_ver ) );
265
+ if( $sCommercialKey ) $aConf['key'] = $sCommercialKey;
266
+ if( $sLogo ) $aConf['logo'] = $sLogo;
267
+ wp_localize_script( 'flowplayer', 'fv_flowplayer_conf', $aConf );
268
+ if( $fv_fp->conf['fixed_size'] == 'false' ) {
269
+ wp_localize_script( 'flowplayer', 'fv_flowplayer_safety_resize_do', array(true) );
270
+ }
271
+ if( current_user_can('manage_options') ) {
272
+ wp_localize_script( 'flowplayer', 'fv_flowplayer_admin_input', array(true) );
273
+ }
274
+ if( isset($GLOBALS['fv_fp_scripts']) ) {
275
+ foreach( $GLOBALS['fv_fp_scripts'] AS $sKey => $aScripts ) {
276
+ wp_localize_script( 'flowplayer', $sKey.'_array', $aScripts );
277
+ }
278
+ }
279
+ }
280
+
281
+ /**
282
+ * Prints flowplayer javascript content to the bottom of the page.
283
+ */
284
+ function flowplayer_display_scripts() {
285
+ global $fv_fp;
286
+
287
+ if( is_user_logged_in() || isset($_GET['fv_wp_flowplayer_check_template']) ) {
288
+ echo "\n<!--fv-flowplayer-footer-->\n\n";
289
+ }
290
+ }
291
+
292
+ /**
293
+ * This is the template tag. Use the standard Flowplayer shortcodes
294
+ */
295
+ function flowplayer($shortcode) {
296
+ echo apply_filters('the_content',$shortcode);
297
+ }
298
+
299
+
300
+ /*
301
+ Make sure our div won't be wrapped in any P tag.
302
+ */
303
+ function fv_flowplayer_the_content( $c ) {
304
+ $c = preg_replace( '!<p[^>]*?>(\[(?:fvplayer|flowplayer).*?\])</p>!', "\n".'$1'."\n", $c );
305
+ return $c;
306
+ }
307
+ add_filter( 'the_content', 'fv_flowplayer_the_content', 0 );
308
+
309
  ?>
controller/shortcodes.php CHANGED
@@ -1,100 +1,182 @@
1
- <?php
2
- require_once dirname( __FILE__ ) . '/../models/flowplayer.php';
3
- if (!class_exists('flowplayer_frontend'))
4
- require_once dirname( __FILE__ ) . '/../models/flowplayer-frontend.php';
5
-
6
- add_shortcode('flowplayer','flowplayer_content_handle');
7
-
8
- function flowplayer_content_handle( $atts ) {
9
- /// Addition 2010/07/12 mv
10
- $fp = new flowplayer_frontend();
11
- if( $fp->conf['commas'] == 'true' ) {
12
-
13
- if( !isset( $atts['src'] ) ) {
14
- foreach( $atts AS $key => $att ) {
15
- if( stripos( $att, 'src=' ) !== FALSE ) {
16
- $atts['src'] = preg_replace( '/^\s*?src=[\'"](.*)[\'"],\s*?$/', '$1', $att );
17
- $i = $key+1;
18
- unset( $atts[$key] ); // = ''; // let's remove it, so it won't confuse the rest of workaaround
19
- }
20
- }
21
- }
22
-
23
- if( !isset( $atts['splash'] ) ) {
24
- foreach( $atts AS $key => $att ) {
25
- if( stripos( $att, 'splash=' ) !== FALSE ) {
26
- $atts['splash'] = preg_replace( '/^\s*?splash=[\'"](.*)[\'"],\s*?$/', '$1', $att );
27
- unset( $atts[$key] ); // = ''; // let's remove it, so it won't confuse the rest of workaround
28
- }
29
- }
30
- }
31
-
32
- // the popup should really be a content of the shortcode, not an attribute
33
- // this part will fix the popup if there is any single quote in it.
34
- if( !isset( $atts['popup'] ) ) {
35
- $popup = array();
36
- $is_popup = false;
37
- foreach( $atts AS $key => $att ) {
38
- if( !is_numeric( $key ) ) continue;
39
- if( ( stripos( $att, 'popup=' ) !== FALSE || $is_popup ) && stripos( $att, 'src=' ) === FALSE && stripos( $att, 'splash=' ) === FALSE) {
40
- $popup[] = $att;
41
- $is_popup = true;
42
- unset( $atts[$key] ); // = ''; // let's remove it, so it won't confuse the rest of workaround
43
- }
44
- }
45
- $popup = implode( ' ', $popup );
46
- $atts['popup'] = preg_replace( '/^\s*?popup=[\'"](.*)[\'"]\s*?$/mi', '$1', $popup );
47
- }
48
-
49
- }
50
- /// End of addition
51
-
52
- extract( shortcode_atts( array(
53
- 'src' => '',
54
- 'src_mobile' => '',
55
- 'src_webm' => '',
56
- 'src_3gp' => '',
57
- 'src_low' => '',
58
- 'src_mobile' => '',
59
- 'width' => '',
60
- 'height' => '',
61
- 'width_mobile' => '',
62
- 'height_mobile' => '',
63
- 'autoplay' => '',
64
- 'splash' => '',
65
- 'popup' => '',
66
- 'controlbar' => '',
67
- 'redirect' => '',
68
- 'splashend' => ''
69
- ), $atts ) );
70
-
71
- $sources['normal'] = $src;
72
- $sources['low'] = $src_low;
73
- $sources['mobile'] = $src_mobile;
74
- $sources['webm'] = $src_webm;
75
- $sources['3gp'] = $src_3gp;
76
-
77
- $arguments['width'] = preg_replace('/\,/', '', $width);
78
- $arguments['height'] = preg_replace('/\,/', '', $height);
79
- $arguments['width_mobile'] = preg_replace('/\,/', '', $width_mobile);
80
- $arguments['height_mobile'] = preg_replace('/\,/', '', $height_mobile);
81
- $arguments['autoplay'] = preg_replace('/\,/', '', $autoplay);
82
- // $arguments['embed'] = $embed;
83
- $arguments['splash'] = preg_replace('/\,/', '', $splash);
84
- $arguments['splashend'] = preg_replace('/\,/', '', $splashend);
85
- $arguments['popup'] = $popup;
86
- $arguments['controlbar'] = preg_replace('/\,/', '', $controlbar);
87
- $arguments['redirect'] = preg_replace('/\,/', '', $redirect);
88
-
89
- $src = preg_replace('/\,/', '', $src);
90
- if (trim($src) != '') {
91
- // build new player
92
- //$fp = new flowplayer_frontend();
93
- $new_player = $fp->build_min_player($src,$sources,$arguments);
94
- $content = str_replace($src, $new_player['html'],$atts);
95
- $GLOBALS['scripts'][] = $new_player['script'];
96
- }
97
- return $new_player['html'];
98
- // return $content;
99
- }
100
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* FV Wordpress Flowplayer - HTML5 video player with Flash fallback
3
+ Copyright (C) 2013 Foliovision
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+ require_once dirname( __FILE__ ) . '/../models/flowplayer.php';
20
+ if (!class_exists('flowplayer_frontend'))
21
+ require_once dirname( __FILE__ ) . '/../models/flowplayer-frontend.php';
22
+
23
+ add_shortcode('flowplayer','flowplayer_content_handle');
24
+
25
+ add_shortcode('fvplayer','flowplayer_content_handle');
26
+
27
+ function flowplayer_content_handle( $atts, $content = null, $tag ) {
28
+ global $fv_fp;
29
+
30
+ if( $fv_fp->conf['parse_commas'] == 'true' ) {
31
+
32
+ if( !isset( $atts['src'] ) ) {
33
+ foreach( $atts AS $key => $att ) {
34
+ if( stripos( $att, 'src=' ) !== FALSE ) {
35
+ if( stripos( $att, ',' ) === FALSE ) { // if the broken attribute is not using ','
36
+ $atts['src'] = preg_replace( '/^\s*?src=[\'"](.*)[\'"].*?$/', '$1', $att );
37
+ } else {
38
+ $atts['src'] = preg_replace( '/^\s*?src=[\'"](.*)[\'"],\s*?$/', '$1', $att );
39
+ }
40
+ $i = $key+1;
41
+ unset( $atts[$key] ); // = ''; // let's remove it, so it won't confuse the rest of workaaround
42
+ }
43
+ }
44
+ }
45
+
46
+ if( !isset( $atts['splash'] ) ) {
47
+ foreach( $atts AS $key => $att ) {
48
+ if( stripos( $att, 'splash=' ) !== FALSE ) {
49
+ $atts['splash'] = preg_replace( '/^\s*?splash=[\'"](.*)[\'"],\s*?$/', '$1', $att );
50
+ unset( $atts[$key] ); // = ''; // let's remove it, so it won't confuse the rest of workaround
51
+ }
52
+ }
53
+ }
54
+
55
+ // the popup should really be a content of the shortcode, not an attribute
56
+ // this part will fix the popup if there is any single quote in it.
57
+ if( !isset( $atts['popup'] ) ) {
58
+ $popup = array();
59
+ $is_popup = false;
60
+ foreach( $atts AS $key => $att ) {
61
+ if( !is_numeric( $key ) ) continue;
62
+ if( ( stripos( $att, 'popup=' ) !== FALSE || $is_popup ) && stripos( $att, 'src=' ) === FALSE && stripos( $att, 'splash=' ) === FALSE && stripos( $att, 'ad=' ) === FALSE) {
63
+ $popup[] = $att;
64
+ $is_popup = true;
65
+ unset( $atts[$key] ); // = ''; // let's remove it, so it won't confuse the rest of workaround
66
+ }
67
+ }
68
+ $popup = implode( ' ', $popup );
69
+ $atts['popup'] = preg_replace( '/^\s*?popup=[\'"](.*)[\'"]\s*?$/mi', '$1', $popup );
70
+ }
71
+
72
+ // same for ad code
73
+ if( !isset( $atts['ad'] ) ) {
74
+ $ad = array();
75
+ $is_ad = false;
76
+ foreach( $atts AS $key => $att ) {
77
+ if( !is_numeric( $key ) ) continue;
78
+ if( ( stripos( $att, 'ad=' ) !== FALSE || $is_ad ) && stripos( $att, 'src=' ) === FALSE && stripos( $att, 'splash=' ) === FALSE && stripos( $att, 'popup=' ) === FALSE) {
79
+ $ad[] = $att;
80
+ $is_ad = true;
81
+ unset( $atts[$key] ); // = ''; // let's remove it, so it won't confuse the rest of workaround
82
+ }
83
+ }
84
+ $ad = implode( ' ', $ad );
85
+ $atts['ad'] = preg_replace( '/^\s*?ad=[\'"](.*)[\'"]\s*?$/mi', '$1', $ad );
86
+ }
87
+
88
+ }
89
+ /// End of addition
90
+
91
+ extract( shortcode_atts( array(
92
+ 'src' => '',
93
+ 'src1' => '',
94
+ 'src2' => '',
95
+ 'mobile' => '',
96
+ 'width' => '',
97
+ 'height' => '',
98
+ 'autoplay' => '',
99
+ 'splash' => '',
100
+ 'splashend' => '',
101
+ 'popup' => '',
102
+ 'controlbar' => '',
103
+ 'redirect' => '',
104
+ 'loop' => '',
105
+ 'engine' => '',
106
+ 'embed' => '',
107
+ 'subtitles' => '',
108
+ 'ad' => '',
109
+ 'ad_width' => '',
110
+ 'ad_height' => '',
111
+ 'ad_skip' => '',
112
+ 'align' => '',
113
+ 'rtmp' => '',
114
+ 'rtmp_path' => '',
115
+ 'playlist' => ''
116
+ ), $atts ) );
117
+
118
+ if( $fv_fp->conf['parse_commas'] == 'true' ) {
119
+ $arguments['width'] = preg_replace('/\,/', '', $width);
120
+ $arguments['height'] = preg_replace('/\,/', '', $height);
121
+ $arguments['autoplay'] = preg_replace('/\,/', '', $autoplay);
122
+ $arguments['splash'] = preg_replace('/\,/', '', $splash);
123
+ $arguments['src1'] = preg_replace('/\,/', '', $src1);
124
+ $arguments['src2'] = preg_replace('/\,/', '', $src2);
125
+ $arguments['mobile'] = preg_replace('/\,/', '', $mobile);
126
+ $arguments['splashend'] = preg_replace('/\,/', '', $splashend);
127
+ $arguments['popup'] = $popup;
128
+ $arguments['controlbar'] = preg_replace('/\,/', '', $controlbar);
129
+ $arguments['redirect'] = preg_replace('/\,/', '', $redirect);
130
+ $arguments['loop'] = preg_replace('/\,/', '', $loop);
131
+ $arguments['engine'] = preg_replace('/\,/', '', $engine);
132
+ $arguments['embed'] = preg_replace('/\,/', '', $embed);
133
+ $arguments['subtitles'] = preg_replace('/\,/', '', $subtitles);
134
+ $arguments['ad'] = preg_replace('/\,/', '', $ad);
135
+ $arguments['ad_width'] = preg_replace('/\,/', '', $ad_width);
136
+ $arguments['ad_height'] = preg_replace('/\,/', '', $ad_height);
137
+ $arguments['ad_skip'] = preg_replace('/\,/', '', $ad_skip);
138
+ $arguments['align'] = preg_replace('/\,/', '', $align);
139
+ $arguments['rtmp'] = preg_replace('/\,/', '', $rtmp);
140
+ $arguments['rtmp_path'] = preg_replace('/\,/', '', $rtmp_path);
141
+ $arguments['playlist'] = $playlist;
142
+ $src = trim( preg_replace('/\,/', '', $src) );
143
+ } else {
144
+ $arguments = shortcode_atts( array(
145
+ 'src' => '',
146
+ 'src1' => '',
147
+ 'src2' => '',
148
+ 'mobile' => '',
149
+ 'width' => '',
150
+ 'height' => '',
151
+ 'autoplay' => '',
152
+ 'splash' => '',
153
+ 'splashend' => '',
154
+ 'popup' => '',
155
+ 'controlbar' => '',
156
+ 'redirect' => '',
157
+ 'loop' => '',
158
+ 'engine' => '',
159
+ 'embed' => '',
160
+ 'subtitles' => '',
161
+ 'ad' => '',
162
+ 'ad_width' => '',
163
+ 'ad_height' => '',
164
+ 'ad_skip' => '',
165
+ 'align' => '',
166
+ 'rtmp' => '',
167
+ 'rtmp_path' => '',
168
+ 'playlist' => ''
169
+ ), $atts );
170
+ }
171
+
172
+
173
+ if( $src != '' || ( strlen($arguments['rtmp']) && strlen($arguments['rtmp_path']) ) ) {
174
+ // build new player
175
+ $new_player = $fv_fp->build_min_player($src,$arguments);
176
+ if (!empty($new_player['script'])) {
177
+ $GLOBALS['fv_fp_scripts'] = $new_player['script'];
178
+ }
179
+ }
180
+ return $new_player['html'];
181
+ }
182
+ ?>
css/ad.css ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Plugin Admin CSS Styles */
2
+
3
+ #fv_flowplayer_ad {
4
+ width: 690px;
5
+ height: 238px;
6
+ display: block;
7
+ margin: 20px 10px;
8
+ padding: 15px 10px 0 20px;
9
+ border: 1px solid #ccc;
10
+ background: url("../images/fabric-plaid-bg.png");
11
+ text-rendering: optimizelegibility;
12
+ color: #353535;
13
+ }
14
+ .text-part {
15
+ float: left;
16
+ width: 310px;
17
+ overflow: hidden;
18
+ display: inline-block;
19
+ }
20
+ .graphic-part {
21
+ float: right;
22
+ width: 320px;
23
+ }
24
+ #fv_flowplayer_ad h2 {
25
+ text-shadow: 1px 1px 1px #fff;
26
+ padding: 9px 0;
27
+ }
28
+ /* paragraph */
29
+ #fv_flowplayer_ad p {
30
+ font-size: 14px;
31
+ }
32
+ a.red-button {
33
+ background: url("../images/red-button-large.png") no-repeat center top;
34
+ height: 40px;
35
+ display: block;
36
+ color: #fff;
37
+ font-size: 16px;
38
+ font-weight: 400;
39
+ text-decoration: none;
40
+ line-height: 1.3;
41
+ padding: 10px 0;
42
+ width: 260px;
43
+ text-align: center;
44
+ }
45
+ .red-button:hover {
46
+ color: #fff;
47
+ }
48
+ .red-text {
49
+ color: #9d1a28;
50
+ font-size: 20px;
51
+ }
52
+ #fv_flowplayer_ad ul {
53
+ margin: 15px 0;
54
+ font-size: 16px;
55
+ }
56
+ #fv_flowplayer_ad ul li {
57
+ /* background: url("../images/list-bullet.png") no-repeat 0 center;
58
+ padding-left: 30px; */
59
+ margin-bottom: 2px;
60
+ }
css/admin.css ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #content .fv-wp-flowplayer-notice-small, .fv-wp-flowplayer-notice-small { color: <?php echo trim($this->conf['timeColor']); ?>; position: absolute; top: 1%; left: 1%; z-index: 2;}
2
+ #content .fv-wp-flowplayer-notice, .fv-wp-flowplayer-notice { color: black !important; background-color: #FFFFE0; border-color: #E6DB55; margin: -1%; padding: 0 0.6em; border-radius: 3px 3px 3px 3px; border-style: solid; border-width: 1px; line-height: 15px; z-index: 100; width: 97%; font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif }
3
+ #content .fv-wp-flowplayer-notice strong, .fv-wp-flowplayer-notice strong { font-weight: bold; }
4
+ #content .fv-wp-flowplayer-notice blockquote, .fv-wp-flowplayer-notice blockquote { font-size: 12px; }
5
+ #content .fv-wp-flowplayer-notice p, .fv-wp-flowplayer-notice p { font-family: sans-serif; font-size: 12px; margin: 0.5em 0; padding: 2px; color: #5b5b5b; }
6
+ .fv-wp-flowplayer-notice p tt { color: #000; }
7
+ .fv-wp-flowplayer-notice p tt.bluelink { color: #4189A7; }
8
+
9
+ #content .fv-wp-flowplayer-notice blockquote, #content .fv-wp-flowplayer-notice pre, .fv-wp-flowplayer-notice blockquote, .fv-wp-flowplayer-notice pre { padding: 5px; margin: 0; }
10
+ .fv-wp-flowplayer-notice textarea.wpfp_message_field { border: 1px solid #dedede; color: #8f8f8f; font-size: 12px; padding: 1%; }
11
+ .fv-wp-flowplayer-notice input[type="button"] { border: 1px solid #960c0c; color: #fff; border-radius: 4px; padding: 5px 8px; box-shadow: inset 0 0 1px #de3232; background: #ad1010; font-size: 12px; line-height: 18px; float: right; margin-bottom: 8px; }
12
+ #content .fv-wp-flowplayer-notice a.techinfo, .fv-wp-flowplayer-notice a.techinfo { background-image:url(img/techinfo.png); color: gray; background-repeat: no-repeat; background-position: left center; display: inline-block; min-height: 18px; padding-left: 24px; margin-top: 5px; }
13
+ #content .fv-wp-flowplayer-notice.fv-wp-flowplayer-error, .fv-wp-flowplayer-notice.fv-wp-flowplayer-error { background-color: #FFEBE8; border-color: #CC0000; }
14
+ #content .fv-wp-flowplayer-notice.fv-wp-flowplayer-notice, .fv-wp-flowplayer-notice.fv-wp-flowplayer-notice { background-color: #EDEDED; border-color: #c0c0c0; box-shadow: 0 0 4px #ccc; }
15
+ .fv-wp-flowplayer-notice-small .fv_wp_flowplayer_notice_head { display: none; }
16
+ .fv-wp-flowplayer-notice.fv-wp-flowplayer-notice .fv_wp_flowplayer_notice_head { display: block; text-align: center; font-size: 14px; border-bottom: 1px solid #7a7a7a; padding: 10px; line-height: 1; margin: 0 -0.6em 1em -0.6em; background-color: #e3e3e3; background-repeat: repeat-x; background-image: -moz-linear-gradient(top, #e3e3e3, #aeaeae); background-image: -ms-linear-gradient(top, #e3e3e3, #aeaeae); background-image: -webkit-linear-gradient(top, #e3e3e3, #aeaeae); background-image: -o-linear-gradient(top, #e3e3e3, #aeaeae); background-image: linear-gradient(top, #e3e3e3, #aeaeae); border-radius: 3px 3px 0 0; }
17
+
18
+ .fv-wp-flowplayer-notice-small .vid-issues { color: red; }
19
+ .fv-wp-flowplayer-notice-small .vid-warning { color: orange; }
20
+ .fv-wp-flowplayer-notice-small .vid-ok { color: green; }
21
+ .fv-wp-flowplayer-notice-small.fv-wp-flowplayer-notice .vid-issues { color: #670004; }
22
+ .fv-wp-flowplayer-notice-small.fv-wp-flowplayer-notice .vid-warning { color: #ac641e; }
23
+ .fv-wp-flowplayer-notice-small.fv-wp-flowplayer-notice .vid-ok { color: #114b00; }
24
+
25
+ .fv-wp-fp-hidden { display: none; }
26
+ .fv-wp-flowplayer-notice-parsed .row { text-align: left; border-bottom: 1px solid lightgray; border-right: 1px solid lightgray; border-left: 1px solid lightgray; padding-left: 5px; font-size: 12px; clear: both; }
27
+ .fv-wp-flowplayer-notice-parsed .close { height: 0px; }
28
+ .fv-wp-flowplayer-notice-parsed .value { border-left: 1px solid lightgray; display: inline-block; float: right; padding-left: 5px; width: 270px; /*height: 21px; overflow: hidden;*/ }
29
+ .fv-wp-flowplayer-notice-parsed.indent { margin-left: 10px; }
30
+ .fv-wp-flowplayer-notice-parsed.level-1 { background: #f8f8f8; }
31
+ .fv-wp-flowplayer-notice-parsed.level-2 { background: #f0f0f0; }
32
+ .fv-wp-flowplayer-notice-parsed.level-3 { background: #e8e8e8; }
33
+ .fv-wp-flowplayer-notice-parsed.level-4 { background: #e0e0e0; }
34
+ .fv-wp-flowplayer-notice-parsed.level-5 { background: #d8d8d8; }
35
+ .fv-wp-flowplayer-notice-parsed.level-6 { background: #d0d0d0; }
36
+ .fv-wp-flowplayer-notice-parsed.level-7 { background: #c8c8c8; }
37
+ .mail-content-details { height: 200px; overflow: auto; width: 100%; }
38
+ /* Administration edit */
39
+ .flowplayer-wrapper { min-width: 55%; display: inline-block; float: right;}
40
+ @media only screen and (max-width: 940px) {.flowplayer-wrapper { width: 100%; float: none;} .form-table2.flowplayer-settings {width: 100% !important;}}
41
+
42
+ #fv_flowplayer_ad {
43
+ width: 690px;
44
+ height: 238px;
45
+ display: block;
46
+ margin: 20px 10px;
47
+ padding: 15px 10px 0 20px;
48
+ border: 1px solid #ccc;
49
+ background: url("../images/fabric-plaid-bg.png");
50
+ text-rendering: optimizelegibility;
51
+ color: #353535;
52
+ }
53
+ .text-part {
54
+ float: left;
55
+ width: 310px;
56
+ overflow: hidden;
57
+ display: inline-block;
58
+ }
59
+ .graphic-part {
60
+ float: right;
61
+ width: 320px;
62
+ }
63
+ #fv_flowplayer_ad h2 {
64
+ text-shadow: 1px 1px 1px #fff;
65
+ padding: 9px 0;
66
+ }
67
+ /* paragraph */
68
+ #fv_flowplayer_ad p {
69
+ font-size: 14px;
70
+ }
71
+ a.red-button {
72
+ background: url("../images/red-button-large.png") no-repeat center top;
73
+ height: 40px;
74
+ display: block;
75
+ color: #fff;
76
+ font-size: 16px;
77
+ font-weight: 400;
78
+ text-decoration: none;
79
+ line-height: 1.3;
80
+ padding: 10px 0;
81
+ width: 260px;
82
+ text-align: center;
83
+ }
84
+ .red-button:hover {
85
+ color: #fff;
86
+ }
87
+ .red-text {
88
+ color: #9d1a28;
89
+ font-size: 20px;
90
+ }
91
+ #fv_flowplayer_ad ul {
92
+ margin: 15px 0;
93
+ font-size: 16px;
94
+ }
95
+ #fv_flowplayer_ad ul li {
96
+ /* background: url("../images/list-bullet.png") no-repeat 0 center;
97
+ padding-left: 30px; */
98
+ margin-bottom: 2px;
99
+ }
css/background.png ADDED
Binary file
css/bigplay.png ADDED
Binary file
css/bigplay.svg ADDED
@@ -0,0 +1 @@
 
1
+ <?xml version="1.0" standalone="no"?>
css/close1.png ADDED
Binary file
css/colorbox.css ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #fv-wordpress-flowplayer-popup { background: white; }
2
+
3
+ /*
4
+ ColorBox Core Style
5
+ The following rules are the styles that are consistant between themes.
6
+ Avoid changing this area to maintain compatability with future versions of ColorBox.
7
+ */
8
+ #colorbox, #cboxOverlay, #cboxWrapper{position:absolute; top:0; left:0; z-index:100; overflow:hidden;}
9
+ #cboxOverlay{position:fixed; width:100%; height:100%;}
10
+ #cboxMiddleLeft, #cboxBottomLeft{clear:left;}
11
+ #cboxContent{position:relative; overflow:hidden;}
12
+ #cboxLoadedContent{overflow:auto;}
13
+ #cboxLoadedContent iframe{display:block; width:100%; height:100%; border:0; background-color: white;}
14
+ #cboxTitle{margin:5px;}
15
+ #cboxLoadingOverlay, #cboxLoadingGraphic{position:absolute; top:0; left:0; width:100%;}
16
+ #cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow{cursor:pointer;}
17
+
18
+ /*
19
+ ColorBox example user style
20
+ The following rules are ordered and tabbed in a way that represents the
21
+ order/nesting of the generated HTML, so that the structure easier to understand.
22
+ */
23
+ #cboxOverlay{background:#111;}
24
+
25
+ #colorBox{}
26
+ #cboxContent{background:#fff; padding: 5px;background:url(loading.gif) 50% 50% no-repeat #fff; }
27
+ #cboxLoadedContent{margin-top:35px;}
28
+ #cboxTitle{position:absolute; top:0px; left:0; padding: 8px 0 8px 18.5%; width:100%; color:#9D1A28; font-size: 14px;}
29
+ #cboxCurrent{position:absolute; bottom:0px; left:100px; color:#999;}
30
+ #cboxSlideshow{position:absolute; bottom:0px; right:42px; color:#444;}
31
+ #cboxPrevious{position:absolute; bottom:0px; left:0; color:#444;}
32
+ #cboxNext{position:absolute; bottom:0px; left:63px; color:#444;}
33
+ /*#cboxLoadingOverlay{ text-align: center; background:url(loading.gif) 5px 5px no-repeat #fff;}*/
34
+ #cboxClose{position:absolute; top:2px; right:2px; display:block; color:#444; height: 16px; width: 16px; overflow: hidden; text-indent: 25px; background: url("img/uploader-icons.png") -98px 0 no-repeat transparent; border: 0; }
35
+ #cboxClose:hover { background-position: -98px 0; }
36
+
css/controls.png ADDED
Binary file
css/controls.svg ADDED
@@ -0,0 +1 @@
 
1
+ <?xml version="1.0" standalone="no"?>
css/flowplayer.css CHANGED
@@ -1,108 +1,304 @@
1
- .flowplayer_container
2
- {
3
- background: #0D0D0D url('../images/finished_bg.png') repeat-x;
4
- display: block;
5
- position: relative;
6
- border: solid 1px black;
7
- margin: 0 auto 0 auto !important;
8
- padding: 0 !important;
9
- text-align: center !important;
10
- }
11
- .flowplayer_container:hover
12
- {
13
- text-decoration: none;
14
- }
15
- /* SPLASH IMAGE */
16
- img.splash
17
- {
18
- position: absolute;
19
- top: 0 !important;
20
- left: 0 !important;
21
- width: 100% !important;
22
- height: 100% !important;
23
- cursor: pointer;
24
- background: none;
25
- border: none;
26
- margin: 0 !important;
27
- padding: 0 !important;
28
- }
29
- .splash_play_button
30
- {
31
- position: relative;
32
- margin: auto !important;
33
- cursor: pointer;
34
- background: none;
35
- border: none;
36
- padding: 0 !important;
37
- }
38
- /* POPUP */
39
- .popup_contents
40
- {
41
- visibility: hidden;
42
- position: absolute;
43
- /*top: -9999em;
44
- left: -9999em;*/
45
- }
46
- .flowplayer_popup
47
- {
48
- position: absolute;
49
- top: 0%;
50
- left: 0%;
51
- text-align: left;
52
- width: 100%;
53
- height: 100%;
54
- background: #000000;
55
- border: solid 1px #000000;
56
- color: #FFFFFF;
57
- padding: 0%;
58
- z-index: 999;
59
- }
60
- .wpfp_custom_popup
61
- {
62
- margin: 0;
63
- padding: 0;
64
- font-family: Arial, serif;
65
- }
66
- .wpfp_custom_popup a, .wpfp_custom_popup a:hover, .wpfp_custom_popup a:visited, .wpfp_custom_popup a:active
67
- {
68
- color: white;
69
- text-decoration: none;
70
- }
71
- .flowplayer_popup a, .flowplayer_popup a img
72
- {
73
- margin: auto !important;
74
- cursor: pointer !important;
75
- background: none !important;
76
- border: none;
77
- padding: 0 !important;
78
- }
79
- .wpfp_custom_popup input
80
- {
81
- width: 80%;
82
- margin: 5px;
83
- }
84
- .popup_controls
85
- {
86
- text-align: center;
87
- font-size: 100%;
88
- }
89
- .link_button{
90
- background: #0D0D0D url('../images/button-bg.png') repeat-x;
91
- padding: 5px 20px;
92
- margin-top: 15px;
93
- border: 1px solid #eeeeee;
94
- font-family: Arial, serif;
95
- font-size:11pt;
96
- z-index: 999;
97
- }
98
- .link_button a, .link_button a:visited, .link_button a:active{
99
- color:#fff;
100
- text-decoration: none;
101
- }
102
- .smallnote{
103
- font-size: 70%;
104
- color: #aaa;
105
- }
106
- .html5video{
107
- text-align:center;
108
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .flowplayer{position:relative;width:100%;background-size:contain;background-repeat:no-repeat;background-position:center center;display:inline-block;}
2
+ .flowplayer *{font-weight:inherit;font-family:inherit;font-style:inherit;text-decoration:inherit;font-size:100%;padding:0;border:0;margin:0;list-style-type:none}
3
+ .flowplayer a:focus{outline:0}
4
+ .flowplayer video{width:100%}
5
+ .flowplayer.is-ipad video{-webkit-transform:translateX(-2048px);}
6
+ .is-ready.flowplayer.is-ipad video{-webkit-transform:translateX(0)}
7
+ .flowplayer .fp-engine,.flowplayer .fp-ui,.flowplayer .fp-message{position:absolute;top:0;left:0;width:100%;height:100%;cursor:pointer;z-index:1}
8
+ .flowplayer .fp-message{display:none;text-align:center;cursor:default;}
9
+ .flowplayer .fp-message h2{font-size:120%;margin-bottom:1em}
10
+ .flowplayer .fp-message p{color:#666;font-size:95%}
11
+ .flowplayer .fp-controls{position:absolute;bottom:0;width:100%;}
12
+ .no-background.flowplayer .fp-controls{background-color:transparent !important;background-image:-moz-linear-gradient(transparent,transparent) !important;background-image:-webkit-gradient(linear,0 0,0 100%,from(transparent),to(transparent)) !important}
13
+ .is-fullscreen.flowplayer .fp-controls{bottom:3px}
14
+ .is-mouseover.flowplayer .fp-controls{bottom:0}
15
+ .flowplayer .fp-waiting{/*display:none;*/margin:19% auto;text-align:center; height: 0; }
16
+ .flowplayer .fp-waiting *{-webkit-box-shadow:0 0 5px #333;-moz-box-shadow:0 0 5px #333;box-shadow:0 0 5px #333}
17
+ .flowplayer .fp-waiting em{width:0em;height:0em;-webkit-border-radius:1em;-moz-border-radius:1em;border-radius:1em;background-color:rgba(255,255,255,0.8);display:inline-block; -webkit-animation:pulse .6s infinite;-moz-animation:pulse .6s infinite;animation:pulse .6s infinite;margin:.3em;opacity:0;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=0);}
18
+ .flowplayer .fp-waiting em:nth-child(1){-webkit-animation-delay:.3s;-moz-animation-delay:.3s;animation-delay:.3s}
19
+ .flowplayer .fp-waiting em:nth-child(2){-webkit-animation-delay:.45s;-moz-animation-delay:.45s;animation-delay:.45s}
20
+ .flowplayer .fp-waiting em:nth-child(3){-webkit-animation-delay:.6s;-moz-animation-delay:.6s;animation-delay:.6s}
21
+ .flowplayer .fp-waiting p{color:#ccc;font-weight:bold}
22
+ .flowplayer .fp-speed{font-size:30px;background-color:#333;background-color:rgba(51,51,51,0.8);color:#eee;margin:0 auto;text-align:center;width:120px;padding:.1em 0 0;opacity:0;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=0);-webkit-transition:opacity .5s;-moz-transition:opacity .5s;transition:opacity .5s;}
23
+ .flowplayer .fp-speed.fp-hilite{opacity:1;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=100)}
24
+ .flowplayer .fp-help{position:absolute;top:0;left:-9999em;z-index:100;background-color:#333;background-color:rgba(51,51,51,0.9);width:100%;height:100%;opacity:0;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=0);-webkit-transition:opacity .2s;-moz-transition:opacity .2s;transition:opacity .2s;text-align:center;}
25
+ .is-help.flowplayer .fp-help{left:0;opacity:1;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=100)}
26
+ .flowplayer .fp-help .fp-help-section{margin:3%;direction:ltr}
27
+ .flowplayer .fp-help .fp-help-basics{margin-top:6%}
28
+ .flowplayer .fp-help p{color:#eee;margin:.5em 0;font-size:14px;line-height:1.5;display:inline-block;margin:1% 2%}
29
+ .flowplayer .fp-help em{background:#eee;-webkit-border-radius:.3em;-moz-border-radius:.3em;border-radius:.3em;margin-right:.4em;padding:.3em .6em;color:#333}
30
+ .flowplayer .fp-help small{font-size:90%;color:#aaa}
31
+ .flowplayer .fp-help .fp-close{display:block}
32
+ @media (max-width: 600px){.flowplayer .fp-help p{font-size:9px}
33
+ }.flowplayer .fp-subtitle{position:absolute;bottom:40px;left:-99999em;z-index:10;text-align:center;width:100%;opacity:0;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=0);-webkit-transition:opacity .3s;-moz-transition:opacity .3s;transition:opacity .3s;}
34
+ .flowplayer .fp-subtitle p{display:inline;background-color:#333;background-color:rgba(51,51,51,0.9);color:#eee;padding:.1em .4em;font-size:16px;line-height:1.6;}
35
+ .flowplayer .fp-subtitle p:after{content:'';clear:both}
36
+ .flowplayer .fp-subtitle.fp-active{left:0;opacity:1;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=100)}
37
+ .flowplayer .fp-fullscreen,.flowplayer .fp-unload,.flowplayer .fp-mute,.flowplayer .fp-embed,.flowplayer .fp-close,.flowplayer .fp-play{background-image:url(img/white.png);background-size:37px 300px;}
38
+ .is-rtl.flowplayer .fp-fullscreen,.is-rtl.flowplayer .fp-unload,.is-rtl.flowplayer .fp-mute,.is-rtl.flowplayer .fp-embed,.is-rtl.flowplayer .fp-close,.is-rtl.flowplayer .fp-play{background-image:url(img/white_rtl.png)}
39
+ .color-light.flowplayer .fp-fullscreen,.color-light.flowplayer .fp-unload,.color-light.flowplayer .fp-mute,.color-light.flowplayer .fp-embed,.color-light.flowplayer .fp-close,.color-light.flowplayer .fp-play{background-image:url(img/black.png);}
40
+ .is-rtl.color-light.flowplayer .fp-fullscreen,.is-rtl.color-light.flowplayer .fp-unload,.is-rtl.color-light.flowplayer .fp-mute,.is-rtl.color-light.flowplayer .fp-embed,.is-rtl.color-light.flowplayer .fp-close,.is-rtl.color-light.flowplayer .fp-play{background-image:url(img/black_rtl.png)}
41
+ @media (-webkit-min-device-pixel-ratio: 2){.color-light.flowplayer .fp-fullscreen,.color-light.flowplayer .fp-unload,.color-light.flowplayer .fp-mute,.color-light.flowplayer .fp-embed,.color-light.flowplayer .fp-close,.color-light.flowplayer .fp-play{background-image:url(img/black@x2.png)}
42
+ .is-rtl.color-light.flowplayer .fp-fullscreen,.is-rtl.color-light.flowplayer .fp-unload,.is-rtl.color-light.flowplayer .fp-mute,.is-rtl.color-light.flowplayer .fp-embed,.is-rtl.color-light.flowplayer .fp-close,.is-rtl.color-light.flowplayer .fp-play{background-image:url(img/black_rtl@x2.png)}
43
+ }@media (-webkit-min-device-pixel-ratio: 2){.flowplayer .fp-fullscreen,.flowplayer .fp-unload,.flowplayer .fp-mute,.flowplayer .fp-embed,.flowplayer .fp-close,.flowplayer .fp-play{background-image:url(img/white@x2.png)}
44
+ .is-rtl.flowplayer .fp-fullscreen,.is-rtl.flowplayer .fp-unload,.is-rtl.flowplayer .fp-mute,.is-rtl.flowplayer .fp-embed,.is-rtl.flowplayer .fp-close,.is-rtl.flowplayer .fp-play{background-image:url(img/white_rtl@x2.png)}
45
+ }.is-splash.flowplayer .fp-ui,.is-paused.flowplayer .fp-ui{background:url(img/play_white.png) center no-repeat;background-size:12%;}
46
+ .is-error.flowplayer .fp-ui{background:url(img/no_play_white.png) center no-repeat;background-size:12%;}
47
+ .is-rtl.is-splash.flowplayer .fp-ui,.is-rtl.is-paused.flowplayer .fp-ui{background:url(img/play_white_rtl.png) center no-repeat;background-size:12%}
48
+ @media (-webkit-min-device-pixel-ratio: 2){.is-splash.flowplayer .fp-ui,.is-paused.flowplayer .fp-ui{background:url(img/play_white@x2.png) center no-repeat;background-size:12%}
49
+ .is-error.flowplayer .fp-ui {background:url(img/no_play_white@x2.png) center no-repeat;background-size:12%}
50
+ .is-rtl.is-splash.flowplayer .fp-ui,.is-rtl.is-paused.flowplayer .fp-ui{background:url(img/play_white_rtl@x2.png) center no-repeat;background-size:12%}
51
+ }.color-light.is-splash.flowplayer .fp-ui,.color-light.is-paused.flowplayer .fp-ui{background-image:url(img/play_black.png);}
52
+ .is-rtl.color-light.is-splash.flowplayer .fp-ui,.is-rtl.color-light.is-paused.flowplayer .fp-ui{background-image:url(img/play_black_rtl.png)}
53
+ @media (-webkit-min-device-pixel-ratio: 2){.color-light.is-splash.flowplayer .fp-ui,.color-light.is-paused.flowplayer .fp-ui{background-image:url(img/play_black@x2.png);}
54
+ .is-rtl.color-light.is-splash.flowplayer .fp-ui,.is-rtl.color-light.is-paused.flowplayer .fp-ui{background-image:url(img/play_black_rtl@x2.png)}
55
+ }.is-fullscreen.flowplayer .fp-ui{background-size:auto}
56
+ .is-seeking.flowplayer .fp-ui,.is-loading.flowplayer .fp-ui{background-image:none}
57
+ .flowplayer .fp-logo{position:absolute;top:auto;left:15px;bottom:30px;cursor:pointer;display:none;z-index:100;}
58
+ .flowplayer .fp-logo img{width:100%; border-radius: 0; box-shadow: none;}
59
+ .is-embedded.flowplayer .fp-logo{display:block}
60
+ .fixed-controls.flowplayer .fp-logo{bottom:15px}
61
+ .flowplayer .fp-fullscreen,.flowplayer .fp-unload,.flowplayer .fp-close{position:absolute;top:5px;left:auto;right:5px;display:block;width:30px;height:21px;background-position:12px -197px;cursor:pointer;}
62
+ .is-rtl.flowplayer .fp-fullscreen,.is-rtl.flowplayer .fp-unload,.is-rtl.flowplayer .fp-close{right:auto;left:5px;background-position:18px -197px}
63
+ .flowplayer .fp-unload,.flowplayer .fp-close{background-position:14px -175px;display:none;}
64
+ .is-rtl.flowplayer .fp-unload,.is-rtl.flowplayer .fp-close{background-position:14px -175px}
65
+ .flowplayer .fp-play{display:none;width:27px;height:20px;background-position:9px -24px;position:absolute;bottom:0;left:0;}
66
+ .is-rtl.flowplayer .fp-play{background-position:18px -24px;left:auto;right:0}
67
+ .play-button.flowplayer .fp-play{display:block}
68
+ .is-paused.flowplayer .fp-play{background-position:9px 7px;}
69
+ .is-rtl.is-paused.flowplayer .fp-play{background-position:18px 7px}
70
+ .flowplayer.is-ready.is-closeable .fp-unload{display:block}
71
+ .flowplayer.is-ready.is-closeable .fp-fullscreen{display:none}
72
+ .flowplayer.is-fullscreen .fp-fullscreen{background-position:10px -217px;display:block !important;}
73
+ .is-rtl.flowplayer.is-fullscreen .fp-fullscreen{background-position:21px -217px}
74
+ .flowplayer.is-fullscreen .fp-unload,.flowplayer.is-fullscreen .fp-close{display:none !important}
75
+ .flowplayer .fp-timeline{height:3px;position:relative;overflow:hidden;top:5px;height:10px;margin:0 150px 0 45px;}
76
+ .no-volume.flowplayer .fp-timeline{margin-right:60px}
77
+ .no-mute.flowplayer .fp-timeline{margin-right:140px}
78
+ .no-mute.no-volume.flowplayer .fp-timeline{margin-right:45px}
79
+ .play-button.flowplayer .fp-timeline{margin-left:67px}
80
+ .is-rtl.flowplayer .fp-timeline{margin:0 45px 0 150px;}
81
+ .no-volume.is-rtl.flowplayer .fp-timeline{margin-left:60px}
82
+ .no-mute.is-rtl.flowplayer .fp-timeline{margin-left:140px}
83
+ .no-mute.no-volume.is-rtl.flowplayer .fp-timeline{margin-left:45px}
84
+ .play-button.is-rtl.flowplayer .fp-timeline{margin-right:67px}
85
+ .is-long.flowplayer .fp-timeline{margin:0 180px 0 75px;}
86
+ .no-volume.is-long.flowplayer .fp-timeline{margin-right:90px}
87
+ .no-mute.is-long.flowplayer .fp-timeline{margin-right:75px}
88
+ .play-button.is-long.flowplayer .fp-timeline{margin-left:97px}
89
+ .is-rtl.is-long.flowplayer .fp-timeline{margin:75px 0 180px 0;}
90
+ .no-volume.is-rtl.is-long.flowplayer .fp-timeline{margin-left:90px}
91
+ .no-mute.is-rtl.is-long.flowplayer .fp-timeline{margin-left:75px}
92
+ .play-button.is-rtl.is-long.flowplayer .fp-timeline{margin-left:97px}
93
+ .aside-time.flowplayer .fp-timeline,.no-time.flowplayer .fp-timeline{margin:0 110px 0 5px}
94
+ .aside-time.no-volume.flowplayer .fp-timeline,.no-time.no-volume.flowplayer .fp-timeline{margin-right:20px}
95
+ .aside-time.no-mute.flowplayer .fp-timeline,.no-time.no-mute.flowplayer .fp-timeline{margin-right:5px}
96
+ .play-button.no-time.flowplayer .fp-timeline,.play-button.aside-time.flowplayer .fp-timeline{margin-left:27px}
97
+ .is-rtl.aside-time.flowplayer .fp-timeline,.is-rtl.no-time.flowplayer .fp-timeline{margin:0 5px 0 110px}
98
+ .is-rtl.aside-time.no-volume.flowplayer .fp-timeline,.is-rtl.no-time.no-volume.flowplayer .fp-timeline{margin-left:20px}
99
+ .is-rtl.aside-time.no-mute.flowplayer .fp-timeline,.is-rtl.no-time.no-mute.flowplayer .fp-timeline{margin-left:5px}
100
+ .is-rtl.play-button.no-time.flowplayer .fp-timeline,.is-rtl.play-button.aside-time.flowplayer .fp-timeline{margin-right:27px}
101
+ .flowplayer .fp-buffer,.flowplayer .fp-progress{position:absolute;top:0;left:auto;height:100%;cursor:col-resize}
102
+ .flowplayer .fp-buffer{-webkit-transition:width .25s linear;-moz-transition:width .25s linear;transition:width .25s linear}
103
+ .flowplayer.is-touch .fp-timeline{overflow:visible}
104
+ .flowplayer.is-touch .fp-progress{-webkit-transition:width .2s linear;-moz-transition:width .2s linear;transition:width .2s linear}
105
+ .flowplayer.is-touch .fp-timeline.is-dragging .fp-progress{-webkit-transition:right .1s linear,border .1s linear,top .1s linear,left .1s linear;-moz-transition:right .1s linear,border .1s linear,top .1s linear,left .1s linear;transition:right .1s linear,border .1s linear,top .1s linear,left .1s linear}
106
+ .flowplayer.is-touch.is-mouseover .fp-progress:after,.flowplayer.is-touch.is-mouseover .fp-progress:before{content:'';display:block;-webkit-border-radius:10px;-moz-border-radius:10px;border-radius:10px;position:absolute;right:-5px}
107
+ .flowplayer.is-touch.is-rtl.is-mouseover .fp-progress:after,.flowplayer.is-touch.is-rtl.is-mouseover .fp-progress:before{right:auto;left:-5px}
108
+ .flowplayer.is-touch.is-rtl.is-mouseover .fp-progress:after{left:-10px;-webkit-box-shadow:-1px 0 4px rgba(0,0,0,0.5);-moz-box-shadow:-1px 0 4px rgba(0,0,0,0.5);box-shadow:-1px 0 4px rgba(0,0,0,0.5)}
109
+ .flowplayer.is-touch.is-mouseover .fp-progress:before{width:10px;height:10px}
110
+ .flowplayer.is-touch.is-mouseover .fp-progress:after{height:10px;width:10px;top:-5px;right:-10px;border:5px solid rgba(255,255,255,0.65);-webkit-box-shadow:1px 0 4px rgba(0,0,0,0.5);-moz-box-shadow:1px 0 4px rgba(0,0,0,0.5);box-shadow:1px 0 4px rgba(0,0,0,0.5)}
111
+ .flowplayer.is-touch.is-mouseover .fp-timeline.is-dragging .fp-progress:after{border:10px solid #fff;-webkit-border-radius:20px;-moz-border-radius:20px;border-radius:20px;-webkit-transition:inherit;-moz-transition:inherit;transition:inherit;top:-10px;right:-15px}
112
+ .flowplayer.is-touch.is-rtl.is-mouseover .fp-timeline.is-dragging .fp-progress:after{left:-15px;right:auto;border:10px solid #fff}
113
+ .flowplayer .fp-volume{position:absolute;top:7.5px;right:5px;}
114
+ .is-rtl.flowplayer .fp-volume{right:auto;left:5px}
115
+ .flowplayer .fp-mute{position:relative;width:10px;height:15px;float:left;top:-5px;cursor:pointer;background-position:-2px -99px;}
116
+ .is-rtl.flowplayer .fp-mute{float:right;background-position:-25px -99px}
117
+ .no-mute.flowplayer .fp-mute{display:none}
118
+ .flowplayer .fp-volumeslider{width:90px;height:5px;cursor:col-resize;float:left;}
119
+ .is-rtl.flowplayer .fp-volumeslider{float:right}
120
+ .no-volume.flowplayer .fp-volumeslider{display:none}
121
+ .flowplayer .fp-volumelevel{height:100%}
122
+ .flowplayer .fp-time{text-shadow:0 0 1px #000;font-size:12px;font-weight:bold;color:#fff;width:100%;}
123
+ .flowplayer .fp-time.is-inverted .fp-duration{display:none}
124
+ .flowplayer .fp-time.is-inverted .fp-remaining{display:inline}
125
+ .flowplayer .fp-time em{width:37px;height:10px;line-height:10px;text-align:center;position:absolute;bottom:5px}
126
+ .no-time.flowplayer .fp-time{display:none}
127
+ .is-long.flowplayer .fp-time em{width:65px}
128
+ .flowplayer .fp-elapsed{left:5px;}
129
+ .play-button.flowplayer .fp-elapsed{left:27px}
130
+ .is-rtl.flowplayer .fp-elapsed{left:auto;right:5px;}
131
+ .play-button.is-rtl.flowplayer .fp-elapsed{right:27px}
132
+ .flowplayer .fp-remaining,.flowplayer .fp-duration{right:110px;color:#eee;}
133
+ .no-volume.flowplayer .fp-remaining,.no-volume.flowplayer .fp-duration{right:20px}
134
+ .no-mute.flowplayer .fp-remaining,.no-mute.flowplayer .fp-duration{right:100px}
135
+ .no-mute.no-volume.flowplayer .fp-remaining,.no-mute.no-volume.flowplayer .fp-duration{right:5px}
136
+ .is-rtl.flowplayer .fp-remaining,.is-rtl.flowplayer .fp-duration{right:auto;left:110px;}
137
+ .no-volume.is-rtl.flowplayer .fp-remaining,.no-volume.is-rtl.flowplayer .fp-duration{left:20px}
138
+ .no-mute.is-rtl.flowplayer .fp-remaining,.no-mute.is-rtl.flowplayer .fp-duration{left:100px}
139
+ .no-mute.no-volume.is-rtl.flowplayer .fp-remaining,.no-mute.no-volume.is-rtl.flowplayer .fp-duration{left:5px}
140
+ .flowplayer .fp-remaining{display:none}
141
+ .flowplayer.color-light .fp-time{color:#222;text-shadow:0 0 1px #fff}
142
+ .flowplayer.color-light .fp-remaining,.flowplayer.color-light .fp-duration{color:#666}
143
+ .flowplayer.aside-time .fp-time{position:absolute;top:5px;left:5px;bottom:auto !important;width:85px;}
144
+ .flowplayer.aside-time .fp-time strong,.flowplayer.aside-time .fp-time em{position:static}
145
+ .flowplayer.aside-time .fp-time .fp-elapsed{margin-right:5px;}
146
+ .is-rtl.flowplayer.aside-time .fp-time .fp-elapsed{margin-right:auto;margin-left:5px}
147
+ .flowplayer.is-long.aside-time .fp-time{width:130px}
148
+ .flowplayer.is-splash,.flowplayer.is-poster{cursor:pointer;}
149
+ .flowplayer.is-splash .fp-controls,.flowplayer.is-poster .fp-controls,.flowplayer.is-splash .fp-fullscreen,.flowplayer.is-poster .fp-fullscreen,.flowplayer.is-splash .fp-unload,.flowplayer.is-poster .fp-unload,.flowplayer.is-splash .fp-time,.flowplayer.is-poster .fp-time,.flowplayer.is-splash .fp-embed,.flowplayer.is-poster .fp-embed{display:none !important}
150
+ .flowplayer.is-poster .fp-engine{top:-9999em}
151
+ .flowplayer.is-loading .fp-waiting {height: 1em;}
152
+ .flowplayer.is-loading .fp-waiting em {width:1em;height:1em;}
153
+ .flowplayer.is-loading .fp-controls,.flowplayer.is-loading .fp-time{display:none}
154
+ .flowplayer.is-loading .fp-ui{background-position:-9999em}
155
+ .flowplayer.is-seeking .fp-waiting {height: 1em;}
156
+ .flowplayer.is-seeking .fp-waiting em {width:1em;height:1em;}
157
+ .flowplayer.is-fullscreen{position:fixed !important;top:0 !important;left:0 !important;border:0 !important;margin:0 !important;width:100% !important;height:100% !important;max-width:100% !important;max-height:100% !important;z-index:99999 !important;-webkit-box-shadow:0 !important;-moz-box-shadow:0 !important;box-shadow:0 !important;background-image:none !important;background-color:#000 !important;}
158
+ .is-rtl.flowplayer.is-fullscreen{left:auto !important;right:0 !important}
159
+ .flowplayer.is-error {border:1px solid #909090;}
160
+ .flowplayer.is-error h2{font-weight:bold;font-size:large;margin-top:10%}
161
+ .flowplayer.is-error .fp-message{display:block; background: rgba(255, 255, 255, 0.75) !important;}
162
+ .flowplayer.is-error object,.flowplayer.is-error video,.flowplayer.is-error .fp-controls,.flowplayer.is-error .fp-time,.flowplayer.is-error .fp-subtitle{display:none}
163
+ .flowplayer.is-ready.is-muted .fp-mute{opacity:.5;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=50)}
164
+ .flowplayer.is-mouseout .fp-controls{height:0;-webkit-transition:height .15s .3s;-moz-transition:height .15s .3s;transition:height .15s .3s}
165
+ .flowplayer.is-mouseout .fp-timeline{margin:0 !important}
166
+ .flowplayer.is-mouseout .fp-timeline{-webkit-transition:height .15s .3s,top .15s .3s,margin .15s .3s;-moz-transition:height .15s .3s,top .15s .3s,margin .15s .3s;transition:height .15s .3s,top .15s .3s,margin .15s .3s;height:4px;top:0;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}
167
+ .flowplayer.is-mouseout .fp-fullscreen,.flowplayer.is-mouseout .fp-unload,.flowplayer.is-mouseout .fp-elapsed,.flowplayer.is-mouseout .fp-remaining,.flowplayer.is-mouseout .fp-duration,.flowplayer.is-mouseout .fp-embed,.flowplayer.is-mouseout .fp-volume,.flowplayer.is-mouseout .fp-play{opacity:0;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=0);-webkit-transition:opacity .15s .3s;-moz-transition:opacity .15s .3s;transition:opacity .15s .3s}
168
+ .flowplayer.is-mouseover .fp-controls,.flowplayer.fixed-controls .fp-controls{height:20px}
169
+ .flowplayer.is-mouseover .fp-fullscreen,.flowplayer.fixed-controls .fp-fullscreen,.flowplayer.is-mouseover .fp-unload,.flowplayer.fixed-controls .fp-unload,.flowplayer.is-mouseover .fp-elapsed,.flowplayer.fixed-controls .fp-elapsed,.flowplayer.is-mouseover .fp-remaining,.flowplayer.fixed-controls .fp-remaining,.flowplayer.is-mouseover .fp-duration,.flowplayer.fixed-controls .fp-duration,.flowplayer.is-mouseover .fp-embed,.flowplayer.fixed-controls .fp-embed,.flowplayer.is-mouseover .fp-logo,.flowplayer.fixed-controls .fp-logo,.flowplayer.is-mouseover .fp-volume,.flowplayer.fixed-controls .fp-volume,.flowplayer.is-mouseover .fp-play,.flowplayer.fixed-controls .fp-play{opacity:1;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=100)}
170
+ .flowplayer.fixed-controls .fp-volume{display:block}
171
+ .flowplayer.fixed-controls .fp-controls{bottom:-20px;}
172
+ .is-fullscreen.flowplayer.fixed-controls .fp-controls{bottom:0}
173
+ .flowplayer.fixed-controls .fp-time em{bottom:-15px;opacity:1;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=100);}
174
+ .is-fullscreen.flowplayer.fixed-controls .fp-time em{bottom:5px}
175
+ .flowplayer.is-disabled .fp-progress{background-color:#999}
176
+ .flowplayer .fp-embed{position:absolute;top:5px;left:5px;display:block;width:25px;height:20px;background-position:3px -237px;}
177
+ .is-rtl.flowplayer .fp-embed{background-position:22px -237px;left:auto;right:5px}
178
+ .flowplayer .fp-embed-code{position:absolute;display:none;top:10px;left:40px;background-color:#333;padding:3px 5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 0 3px #ccc;-moz-box-shadow:0 0 3px #ccc;box-shadow:0 0 3px #ccc;font-size:12px;}
179
+ .flowplayer .fp-embed-code:before{content:'';width:0;height:0;position:absolute;top:2px;left:-10px;border:5px solid transparent;border-right-color:#333}
180
+ .is-rtl.flowplayer .fp-embed-code{left:auto;right:40px;}
181
+ .is-rtl.flowplayer .fp-embed-code:before{left:auto;right:-10px;border-right-color:transparent;border-left-color:#333}
182
+ .flowplayer .fp-embed-code textarea{width:400px;height:16px;font-family:monaco,"courier new",verdana;color:#777;white-space:nowrap;resize:none;overflow:hidden;border:0;outline:0;background-color:transparent;color:#ccc}
183
+ .flowplayer .fp-embed-code label{display:block;color:#999}
184
+ .flowplayer.is-embedding .fp-embed,.flowplayer.is-embedding .fp-embed-code{display:block;opacity:1;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=100)}
185
+ .flowplayer.aside-time .fp-embed{left:85px;}
186
+ .is-rtl.flowplayer.aside-time .fp-embed{left:auto;right:85px}
187
+ .flowplayer.aside-time .fp-embed-code{left:115px;}
188
+ .is-rtl.flowplayer.aside-time .fp-embed-code{left:auto;right:115px}
189
+ .flowplayer.aside-time.is-embedding .fp-time{opacity:1;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=100)}
190
+ .flowplayer.is-long.aside-time .fp-embed{left:130px;}
191
+ .is-rtl.flowplayer.is-long.aside-time .fp-embed{left:auto;right:130px}
192
+ .flowplayer.no-time .fp-embed{left:5px !important;}
193
+ .is-rtl.flowplayer.no-time .fp-embed{left:auto;right:5px !important}
194
+ .flowplayer.is-live .fp-timeline,.flowplayer.is-live .fp-duration,.flowplayer.is-live .fp-remaining{display:none}
195
+ .flowplayer .fp-context-menu{position:absolute;display:none;z-index:1001;background-color:#fff;padding:10px;border:1px solid #aaa;-webkit-box-shadow:0 0 4px #888;-moz-box-shadow:0 0 4px #888;box-shadow:0 0 4px #888;width:170px;}
196
+ .flowplayer .fp-context-menu li{text-align:center;padding:10px;color:#444;margin:0 -10px 0 -10px;}
197
+ .flowplayer .fp-context-menu li a{color:#00a7c8;font-size:110%}
198
+ .flowplayer .fp-context-menu li:hover:not(.copyright){background-color:#eee}
199
+ .flowplayer .fp-context-menu li.copyright{margin:0;padding-left:110px;background-image:url("img/flowplayer.png");background-repeat:no-repeat;background-size:100px 20px;background-position:5px 5px;border-bottom:1px solid #bbb;}
200
+ @media (-webkit-min-device-pixel-ratio: 2){.flowplayer .fp-context-menu li.copyright{background-image:url("img/flowplayer@2x.png")}
201
+ }@-moz-keyframes pulse{0%{opacity:0}
202
+ 100%{opacity:1}
203
+ }@-webkit-keyframes pulse{0%{opacity:0}
204
+ 100%{opacity:1}
205
+ }@-o-keyframes pulse{0%{opacity:0}
206
+ 100%{opacity:1}
207
+ }@-ms-keyframes pulse{0%{opacity:0}
208
+ 100%{opacity:1}
209
+ }@keyframes pulse{0%{opacity:0}
210
+ 100%{opacity:1}
211
+ }.flowplayer .fp-controls{background-color:#333;background-color:rgba(51,51,51,0.6)}
212
+ .flowplayer.fixed-controls .fp-controls{background-color:#333}
213
+ .flowplayer .fp-timeline{background-color:#666}
214
+ .flowplayer .fp-buffer{background-color:#eee}
215
+ .flowplayer .fp-progress{background-color:#00a7c8}
216
+ .flowplayer .fp-volumeslider{background-color:#000}
217
+ .flowplayer .fp-volumelevel{background-color:#fff}
218
+ .flowplayer .fp-play{height:24px}
219
+ .flowplayer.is-touch.is-mouseover .fp-progress:before{background-color:#00a7c8}
220
+ .flowplayer.color-light .fp-controls{background-color:rgba(255,255,255,0.6)}
221
+ .flowplayer.color-light.fixed-controls .fp-controls{background-color:#fff}
222
+ .flowplayer.color-light .fp-volumeslider{background-color:#ddd}
223
+ .flowplayer.color-light .fp-volumelevel{background-color:#222}
224
+ .flowplayer.color-alt .fp-progress{background-color:#fff}
225
+ .flowplayer.color-alt.is-touch.is-mouseover .fp-progress:before{background-color:#fff}
226
+ .flowplayer.color-alt .fp-buffer{background-color:#999}
227
+ .flowplayer.color-alt2 .fp-progress{background-color:#900}
228
+ .flowplayer.color-alt2.is-touch.is-mouseover .fp-progress:before{background-color:#900}
229
+
230
+ .flowplayer .fp-prev, .flowplayer .fp-next{/* next and prev buttons */position:absolute;top:44%;cursor:pointer;-webkit-transition:opacity .5s;-moz-transition:opacity .5s;transition:opacity .5s;background:url("img/playlist-buttons.png");opacity:0;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=0);height:20px;width:12px;}
231
+ .is-mouseover.is-ready.flowplayer .fp-prev,.is-mouseover.is-ready.flowplayer .fp-next{opacity:1;filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=100)}
232
+ .flowplayer .fp-prev{left:-20px;background-position:0 -200px;}
233
+ .flowplayer .fp-prev:hover{background-position:0 -300px}
234
+ .flowplayer .fp-next{right:-20px;background-position:0 -400px;}
235
+ .flowplayer .fp-next:hover{background-position:0 -500px}
236
+
237
+ .fp-playlist-external { text-align:center; }
238
+ .fp-playlist-external a { display:inline-block;width:120px;height:80px;margin:0 10px;-webkit-transition:all .3s;-moz-transition:all .3s;transition:all .3s;border:4px solid #fff;background:gray;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;background-size:auto 100px;background-position:center;}
239
+ .fp-playlist-external a:hover { border-color:#ccc }
240
+ .fp-playlist-external a.is-active { border-color:#52b9e4; }
241
+
242
+ .add_media span.wp-media-buttons-icon {
243
+ background: url("img/media-button.png") no-repeat scroll left top;
244
+ display: inline-block;
245
+ height: 16px;
246
+ margin: 0 2px;
247
+ vertical-align: text-top;
248
+ width: 16px;
249
+ }
250
+ #cboxWrapper a {
251
+ text-decoration: none;
252
+ }
253
+ a #add-format, a #add-rtmp {
254
+ background: #333;
255
+ border-radius: 2px;
256
+ color: #fff;
257
+ display: inline-block;
258
+ font-size: 16px;
259
+ font-weight: normal;
260
+ height: 18px;
261
+ line-height: 1rem;
262
+ margin: 0 5px 0 0;
263
+ text-align: center;
264
+ width: 18px;
265
+ padding: 0;
266
+ text-decoration: none;
267
+ }
268
+ #fv-wordpress-flowplayer-popup table {
269
+ width: 100%;
270
+ }
271
+ #fv-wordpress-flowplayer-popup table th {
272
+ text-align: right;
273
+ width: 18%;
274
+ padding: 4px 2px;
275
+ }
276
+ #fv-wordpress-flowplayer-popup table td {
277
+ padding: 4px 2px;
278
+ }
279
+
280
+
281
+ .flowplayer .fp-volume { text-align: left; }
282
+ #content .flowplayer .fp-embed-code, .flowplayer .fp-embed-code { padding: 3px 7px; }
283
+ #content .flowplayer a, .flowplayer a, .flowplayer a:hover { text-decoration: none; border-bottom: none; }
284
+
285
+ .flowplayer .wpfp_custom_ad { display: none; overflow: hidden; }
286
+ .flowplayer .wpfp_custom_ad img { height: auto; }
287
+ .flowplayer.is-playing .wpfp_custom_ad, .flowplayer.is-ready .wpfp_custom_ad { display: block; }
288
+ .flowplayer.is-poster .wpfp_custom_ad { display: none; }
289
+
290
+ .fv_fp_close { position: absolute; right: 2px; top: 2px; z-index: 2; }
291
+ .fv_fp_close a { display: block; width: 16px; height: 16px; background: url(img/exit_btn.png) }
292
+
293
+ .wpfp_custom_ad_content h1, .wpfp_custom_ad_content h2, .wpfp_custom_ad_content h3, .wpfp_custom_ad_content h4, .wpfp_custom_ad_content h5, .wpfp_custom_ad_content p { padding: 0 5px 2px 5px; margin: 0 5px 2px 5px; }
294
+
295
+ .flowplayer.alignleft { margin-right: 10px; margin-bottom: 10px; }
296
+ .flowplayer.alignright { margin-left: 10px; margin-bottom: 10px; }
297
+
298
+ /*
299
+ MediaElement.js
300
+ */
301
+ .mejs-container{position:relative;background:#000;font-family:Helvetica,Arial;text-align:left;vertical-align:top;text-indent:0; margin: 0 auto 28px auto; }
302
+ .me-plugin{position:absolute;}.mejs-embed,.mejs-embed body{width:100%;height:100%;margin:0;padding:0;background:#000;overflow:hidden;}.mejs-container-fullscreen{position:fixed;left:0;top:0;right:0;bottom:0;overflow:hidden;z-index:1000;}.mejs-container-fullscreen .mejs-mediaelement,.mejs-container-fullscreen video{width:100%;height:100%;}.mejs-clear{clear:both;}.mejs-background{position:absolute;top:0;left:0;}.mejs-mediaelement{position:absolute;top:0;left:0;width:100%;height:100%;}.mejs-poster{position:absolute;top:0;left:0;background-size:contain;background-position:50% 50%;background-repeat:no-repeat;}:root .mejs-poster img{display:none;}.mejs-poster img{border:0;padding:0;border:0;}.mejs-overlay{position:absolute;top:0;left:0;}.mejs-overlay-play{cursor:pointer;}.mejs-overlay-button{position:absolute;top:50%;left:50%;width:100px;height:100px;margin:-50px 0 0 -50px;background:url(bigplay.svg) no-repeat;}.no-svg .mejs-overlay-button{background-image:url(bigplay.png);}.mejs-overlay:hover .mejs-overlay-button{background-position:0 -100px;}.mejs-overlay-loading{position:absolute;top:50%;left:50%;width:80px;height:80px;margin:-40px 0 0 -40px;background:#333;background:url(background.png);background:rgba(0,0,0,0.9);background:-webkit-gradient(linear,0% 0,0% 100%,from(rgba(50,50,50,0.9)),to(rgba(0,0,0,0.9)));background:-webkit-linear-gradient(top,rgba(50,50,50,0.9),rgba(0,0,0,0.9));background:-moz-linear-gradient(top,rgba(50,50,50,0.9),rgba(0,0,0,0.9));background:-o-linear-gradient(top,rgba(50,50,50,0.9),rgba(0,0,0,0.9));background:-ms-linear-gradient(top,rgba(50,50,50,0.9),rgba(0,0,0,0.9));background:linear-gradient(rgba(50,50,50,0.9),rgba(0,0,0,0.9));}.mejs-overlay-loading span{display:block;width:80px;height:80px;background:transparent url(loading.gif) 50% 50% no-repeat;}.mejs-container .mejs-controls{position:absolute;list-style-type:none;margin:0;padding:0;bottom:0;left:0;background:url(background.png);background:rgba(0,0,0,0.7);background:-webkit-gradient(linear,0% 0,0% 100%,from(rgba(50,50,50,0.7)),to(rgba(0,0,0,0.7)));background:-webkit-linear-gradient(top,rgba(50,50,50,0.7),rgba(0,0,0,0.7));background:-moz-linear-gradient(top,rgba(50,50,50,0.7),rgba(0,0,0,0.7));background:-o-linear-gradient(top,rgba(50,50,50,0.7),rgba(0,0,0,0.7));background:-ms-linear-gradient(top,rgba(50,50,50,0.7),rgba(0,0,0,0.7));background:linear-gradient(rgba(50,50,50,0.7),rgba(0,0,0,0.7));height:30px;width:100%;}
303
+ .mejs-container .mejs-controls div{list-style-type:none;background-image:none;display:block;float:left;margin:0;padding:0;width:26px;height:26px;font-size:11px;line-height:11px;/*font-family:Helvetica,Arial*/;border:0;}
304
+ .mejs-controls .mejs-button button{cursor:pointer;display:block;font-size:0;line-height:0;text-decoration:none;margin:7px 5px;padding:0;position:absolute;height:16px;width:16px;border:0;background:transparent url(controls.svg) no-repeat;}.no-svg .mejs-controls .mejs-button button{background-image:url(controls.png);}.mejs-controls .mejs-button button:focus{outline:solid 1px yellow;}.mejs-container .mejs-controls .mejs-time{color:#fff;display:block;height:17px;width:auto;padding:8px 3px 0 3px;overflow:hidden;text-align:center;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;}.mejs-container .mejs-controls .mejs-time span{color:#fff;font-size:11px;line-height:12px;display:block;float:left;margin:1px 2px 0 0;width:auto;}.mejs-controls .mejs-play button{background-position:0 0;}.mejs-controls .mejs-pause button{background-position:0 -16px;}.mejs-controls .mejs-stop button{background-position:-112px 0;}.mejs-controls div.mejs-time-rail{width:200px;padding-top:5px;}.mejs-controls .mejs-time-rail span{display:block;position:absolute;width:180px;height:10px;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px;cursor:pointer;}.mejs-controls .mejs-time-rail .mejs-time-total{margin:5px;background:#333;background:rgba(50,50,50,0.8);background:-webkit-gradient(linear,0% 0,0% 100%,from(rgba(30,30,30,0.8)),to(rgba(60,60,60,0.8)));background:-webkit-linear-gradient(top,rgba(30,30,30,0.8),rgba(60,60,60,0.8));background:-moz-linear-gradient(top,rgba(30,30,30,0.8),rgba(60,60,60,0.8));background:-o-linear-gradient(top,rgba(30,30,30,0.8),rgba(60,60,60,0.8));background:-ms-linear-gradient(top,rgba(30,30,30,0.8),rgba(60,60,60,0.8));background:linear-gradient(rgba(30,30,30,0.8),rgba(60,60,60,0.8));}.mejs-controls .mejs-time-rail .mejs-time-buffering{width:100%;background-image:-o-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-ms-linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(-45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);-webkit-background-size:15px 15px;-moz-background-size:15px 15px;-o-background-size:15px 15px;background-size:15px 15px;-webkit-animation:buffering-stripes 2s linear infinite;-moz-animation:buffering-stripes 2s linear infinite;-ms-animation:buffering-stripes 2s linear infinite;-o-animation:buffering-stripes 2s linear infinite;animation:buffering-stripes 2s linear infinite;}@-webkit-keyframes buffering-stripes{from{background-position:0 0;}to{background-position:30px 0;}}@-moz-keyframes buffering-stripes{from{background-position:0 0;}to{background-position:30px 0;}}@-ms-keyframes buffering-stripes{from{background-position:0 0;}to{background-position:30px 0;}}@-o-keyframes buffering-stripes{from{background-position:0 0;}to{background-position:30px 0;}}@keyframes buffering-stripes{from{background-position:0 0;}to{background-position:30px 0;}}.mejs-controls .mejs-time-rail .mejs-time-loaded{background:#3caac8;background:rgba(60,170,200,0.8);background:-webkit-gradient(linear,0% 0,0% 100%,from(rgba(44,124,145,0.8)),to(rgba(78,183,212,0.8)));background:-webkit-linear-gradient(top,rgba(44,124,145,0.8),rgba(78,183,212,0.8));background:-moz-linear-gradient(top,rgba(44,124,145,0.8),rgba(78,183,212,0.8));background:-o-linear-gradient(top,rgba(44,124,145,0.8),rgba(78,183,212,0.8));background:-ms-linear-gradient(top,rgba(44,124,145,0.8),rgba(78,183,212,0.8));background:linear-gradient(rgba(44,124,145,0.8),rgba(78,183,212,0.8));width:0;}.mejs-controls .mejs-time-rail .mejs-time-current{background:#fff;background:rgba(255,255,255,0.8);background:-webkit-gradient(linear,0% 0,0% 100%,from(rgba(255,255,255,0.9)),to(rgba(200,200,200,0.8)));background:-webkit-linear-gradient(top,rgba(255,255,255,0.9),rgba(200,200,200,0.8));background:-moz-linear-gradient(top,rgba(255,255,255,0.9),rgba(200,200,200,0.8));background:-o-linear-gradient(top,rgba(255,255,255,0.9),rgba(200,200,200,0.8));background:-ms-linear-gradient(top,rgba(255,255,255,0.9),rgba(200,200,200,0.8));background:linear-gradient(rgba(255,255,255,0.9),rgba(200,200,200,0.8));width:0;}.mejs-controls .mejs-time-rail .mejs-time-handle{display:none;position:absolute;margin:0;width:10px;background:#fff;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;cursor:pointer;border:solid 2px #333;top:-2px;text-align:center;}.mejs-controls .mejs-time-rail .mejs-time-float{position:absolute;display:none;background:#eee;width:36px;height:17px;border:solid 1px #333;top:-26px;margin-left:-18px;text-align:center;color:#111;}.mejs-controls .mejs-time-rail .mejs-time-float-current{margin:2px;width:30px;display:block;text-align:center;left:0;}.mejs-controls .mejs-time-rail .mejs-time-float-corner{position:absolute;display:block;width:0;height:0;line-height:0;border:solid 5px #eee;border-color:#eee transparent transparent transparent;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;top:15px;left:13px;}.mejs-long-video .mejs-controls .mejs-time-rail .mejs-time-float{width:48px;}.mejs-long-video .mejs-controls .mejs-time-rail .mejs-time-float-current{width:44px;}.mejs-long-video .mejs-controls .mejs-time-rail .mejs-time-float-corner{left:18px;}.mejs-controls .mejs-fullscreen-button button{background-position:-32px 0;}.mejs-controls .mejs-unfullscreen button{background-position:-32px -16px;}.mejs-controls .mejs-mute button{background-position:-16px -16px;}.mejs-controls .mejs-unmute button{background-position:-16px 0;}.mejs-controls .mejs-volume-button{position:relative;}.mejs-controls .mejs-volume-button .mejs-volume-slider{display:none;height:115px;width:25px;background:url(background.png);background:rgba(50,50,50,0.7);-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;top:-115px;left:0;z-index:1;position:absolute;margin:0;}.mejs-controls .mejs-volume-button:hover{-webkit-border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px;}.mejs-controls .mejs-volume-button .mejs-volume-slider .mejs-volume-total{position:absolute;left:11px;top:8px;width:2px;height:100px;background:#ddd;background:rgba(255,255,255,0.5);margin:0;}.mejs-controls .mejs-volume-button .mejs-volume-slider .mejs-volume-current{position:absolute;left:11px;top:8px;width:2px;height:100px;background:#ddd;background:rgba(255,255,255,0.9);margin:0;}.mejs-controls .mejs-volume-button .mejs-volume-slider .mejs-volume-handle{position:absolute;left:4px;top:-3px;width:16px;height:6px;background:#ddd;background:rgba(255,255,255,0.9);cursor:N-resize;-webkit-border-radius:1px;-moz-border-radius:1px;border-radius:1px;margin:0;}.mejs-controls div.mejs-horizontal-volume-slider{height:26px;width:60px;position:relative;}.mejs-controls .mejs-horizontal-volume-slider .mejs-horizontal-volume-total{position:absolute;left:0;top:11px;width:50px;height:8px;margin:0;padding:0;font-size:1px;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px;background:#333;background:rgba(50,50,50,0.8);background:-webkit-gradient(linear,0% 0,0% 100%,from(rgba(30,30,30,0.8)),to(rgba(60,60,60,0.8)));background:-webkit-linear-gradient(top,rgba(30,30,30,0.8),rgba(60,60,60,0.8));background:-moz-linear-gradient(top,rgba(30,30,30,0.8),rgba(60,60,60,0.8));background:-o-linear-gradient(top,rgba(30,30,30,0.8),rgba(60,60,60,0.8));background:-ms-linear-gradient(top,rgba(30,30,30,0.8),rgba(60,60,60,0.8));background:linear-gradient(rgba(30,30,30,0.8),rgba(60,60,60,0.8));}.mejs-controls .mejs-horizontal-volume-slider .mejs-horizontal-volume-current{position:absolute;left:0;top:11px;width:50px;height:8px;margin:0;padding:0;font-size:1px;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px;background:#fff;background:rgba(255,255,255,0.8);background:-webkit-gradient(linear,0% 0,0% 100%,from(rgba(255,255,255,0.9)),to(rgba(200,200,200,0.8)));background:-webkit-linear-gradient(top,rgba(255,255,255,0.9),rgba(200,200,200,0.8));background:-moz-linear-gradient(top,rgba(255,255,255,0.9),rgba(200,200,200,0.8));background:-o-linear-gradient(top,rgba(255,255,255,0.9),rgba(200,200,200,0.8));background:-ms-linear-gradient(top,rgba(255,255,255,0.9),rgba(200,200,200,0.8));background:linear-gradient(rgba(255,255,255,0.9),rgba(200,200,200,0.8));}.mejs-controls .mejs-horizontal-volume-slider .mejs-horizontal-volume-handle{display:none;}.mejs-controls .mejs-captions-button{position:relative;}.mejs-controls .mejs-captions-button button{background-position:-48px 0;}.mejs-controls .mejs-captions-button .mejs-captions-selector{visibility:hidden;position:absolute;bottom:26px;right:-10px;width:130px;height:100px;background:url(background.png);background:rgba(50,50,50,0.7);border:solid 1px transparent;padding:10px;overflow:hidden;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;}.mejs-controls .mejs-captions-button .mejs-captions-selector ul{margin:0;padding:0;display:block;list-style-type:none!important;overflow:hidden;}.mejs-controls .mejs-captions-button .mejs-captions-selector ul li{margin:0 0 6px 0;padding:0;list-style-type:none!important;display:block;color:#fff;overflow:hidden;}.mejs-controls .mejs-captions-button .mejs-captions-selector ul li input{clear:both;float:left;margin:3px 3px 0 5px;}.mejs-controls .mejs-captions-button .mejs-captions-selector ul li label{width:100px;float:left;padding:4px 0 0 0;line-height:15px;font-family:helvetica,arial;font-size:10px;}.mejs-controls .mejs-captions-button .mejs-captions-translations{font-size:10px;margin:0 0 5px 0;}.mejs-chapters{position:absolute;top:0;left:0;-xborder-right:solid 1px #fff;width:10000px;z-index:1;}.mejs-chapters .mejs-chapter{position:absolute;float:left;background:#222;background:rgba(0,0,0,0.7);background:-webkit-gradient(linear,0% 0,0% 100%,from(rgba(50,50,50,0.7)),to(rgba(0,0,0,0.7)));background:-webkit-linear-gradient(top,rgba(50,50,50,0.7),rgba(0,0,0,0.7));background:-moz-linear-gradient(top,rgba(50,50,50,0.7),rgba(0,0,0,0.7));background:-o-linear-gradient(top,rgba(50,50,50,0.7),rgba(0,0,0,0.7));background:-ms-linear-gradient(top,rgba(50,50,50,0.7),rgba(0,0,0,0.7));background:linear-gradient(rgba(50,50,50,0.7),rgba(0,0,0,0.7));filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,startColorstr=#323232,endColorstr=#000000);overflow:hidden;border:0;}.mejs-chapters .mejs-chapter .mejs-chapter-block{font-size:11px;color:#fff;padding:5px;display:block;border-right:solid 1px #333;border-bottom:solid 1px #333;cursor:pointer;}.mejs-chapters .mejs-chapter .mejs-chapter-block-last{border-right:none;}.mejs-chapters .mejs-chapter .mejs-chapter-block:hover{background:#666;background:rgba(102,102,102,0.7);background:-webkit-gradient(linear,0% 0,0% 100%,from(rgba(102,102,102,0.7)),to(rgba(50,50,50,0.6)));background:-webkit-linear-gradient(top,rgba(102,102,102,0.7),rgba(50,50,50,0.6));background:-moz-linear-gradient(top,rgba(102,102,102,0.7),rgba(50,50,50,0.6));background:-o-linear-gradient(top,rgba(102,102,102,0.7),rgba(50,50,50,0.6));background:-ms-linear-gradient(top,rgba(102,102,102,0.7),rgba(50,50,50,0.6));background:linear-gradient(rgba(102,102,102,0.7),rgba(50,50,50,0.6));filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,startColorstr=#666666,endColorstr=#323232);}.mejs-chapters .mejs-chapter .mejs-chapter-block .ch-title{font-size:12px;font-weight:bold;display:block;white-space:nowrap;text-overflow:ellipsis;margin:0 0 3px 0;line-height:12px;}.mejs-chapters .mejs-chapter .mejs-chapter-block .ch-timespan{font-size:12px;line-height:12px;margin:3px 0 4px 0;display:block;white-space:nowrap;text-overflow:ellipsis;}.mejs-captions-layer{position:absolute;bottom:0;left:0;text-align:center;line-height:22px;font-size:12px;color:#fff;}.mejs-captions-layer a{color:#fff;text-decoration:underline;}.mejs-captions-layer[lang=ar]{font-size:20px;font-weight:normal;}.mejs-captions-position{position:absolute;width:100%;bottom:15px;left:0;}.mejs-captions-position-hover{bottom:45px;}.mejs-captions-text{padding:3px 5px;background:url(background.png);background:rgba(20,20,20,0.8);}.me-cannotplay a{color:#fff;font-weight:bold;}.me-cannotplay span{padding:15px;display:block;}.mejs-controls .mejs-loop-off button{background-position:-64px -16px;}.mejs-controls .mejs-loop-on button{background-position:-64px 0;}.mejs-controls .mejs-backlight-off button{background-position:-80px -16px;}.mejs-controls .mejs-backlight-on button{background-position:-80px 0;}.mejs-controls .mejs-picturecontrols-button{background-position:-96px 0;}.mejs-contextmenu{position:absolute;width:150px;padding:10px;border-radius:4px;top:0;left:0;background:#fff;border:solid 1px #999;z-index:1001;}.mejs-contextmenu .mejs-contextmenu-separator{height:1px;font-size:0;margin:5px 6px;background:#333;}.mejs-contextmenu .mejs-contextmenu-item{font-family:Helvetica,Arial;font-size:12px;padding:4px 6px;cursor:pointer;color:#333;}.mejs-contextmenu .mejs-contextmenu-item:hover{background:#2C7C91;color:#fff;}.mejs-controls .mejs-sourcechooser-button{position:relative;}.mejs-controls .mejs-sourcechooser-button button{background-position:-128px 0;}.mejs-controls .mejs-sourcechooser-button .mejs-sourcechooser-selector{visibility:hidden;position:absolute;bottom:26px;right:-10px;width:130px;height:100px;background:url(background.png);background:rgba(50,50,50,0.7);border:solid 1px transparent;padding:10px;overflow:hidden;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;}.mejs-controls .mejs-sourcechooser-button .mejs-sourcechooser-selector ul{margin:0;padding:0;display:block;list-style-type:none!important;overflow:hidden;}.mejs-controls .mejs-sourcechooser-button .mejs-sourcechooser-selector ul li{margin:0 0 6px 0;padding:0;list-style-type:none!important;display:block;color:#fff;overflow:hidden;}.mejs-controls .mejs-sourcechooser-button .mejs-sourcechooser-selector ul li input{clear:both;float:left;margin:3px 3px 0 5px;}.mejs-controls .mejs-sourcechooser-button .mejs-sourcechooser-selector ul li label{width:100px;float:left;padding:4px 0 0 0;line-height:15px;font-family:helvetica,arial;font-size:10px;}.mejs-postroll-layer{position:absolute;bottom:0;left:0;width:100%;height:100%;background:url(background.png);background:rgba(50,50,50,0.7);z-index:1000;overflow:hidden;}.mejs-postroll-layer-content{width:100%;height:100%;}.mejs-postroll-close{position:absolute;right:0;top:0;background:url(background.png);background:rgba(50,50,50,0.7);color:#fff;padding:4px;z-index:100;cursor:pointer;}
css/img/black.png ADDED
Binary file
css/img/black@x2.png ADDED
Binary file
css/img/black_rtl.png ADDED
Binary file
css/img/black_rtl@x2.png ADDED
Binary file
css/img/exit_btn.png ADDED
Binary file
css/img/flowplayer.png ADDED
Binary file
css/img/media-button.png ADDED
Binary file
css/img/no_play_white.png ADDED
Binary file
css/img/no_play_white@x2.png ADDED
Binary file
css/img/play_black.png ADDED
Binary file
css/img/play_black@x2.png ADDED
Binary file
css/img/play_black_rtl.png ADDED
Binary file
css/img/play_black_rtl@x2.png ADDED
Binary file
css/img/play_white.png ADDED
Binary file
css/img/play_white@x2.png ADDED
Binary file
css/img/play_white_rtl.png ADDED
Binary file
css/img/play_white_rtl@x2.png ADDED
Binary file
css/img/playful_black.png ADDED
Binary file
css/img/playful_black@x2.png ADDED
Binary file
css/img/playful_black_rtl.png ADDED
Binary file
css/img/playful_black_rtl@x2.png ADDED
Binary file
css/img/playful_white.png ADDED
Binary file
css/img/playful_white@x2.png ADDED
Binary file
css/img/playful_white_rtl.png ADDED
Binary file
css/img/playful_white_rtl@x2.png ADDED
Binary file
css/img/playlist-buttons.png ADDED
Binary file
css/img/techinfo.png ADDED
Binary file
css/img/uploader-icons.png ADDED
Binary file
css/img/white.png ADDED
Binary file
css/img/white@x2.png ADDED
Binary file
css/img/white_rtl.png ADDED
Binary file
css/img/white_rtl@x2.png ADDED
Binary file
css/loading.gif ADDED
Binary file
flowplayer.php CHANGED
@@ -1,20 +1,42 @@
1
  <?PHP
2
  /*
3
  Plugin Name: FV Wordpress Flowplayer
4
- Plugin URI: http://foliovision.com/seo-tools/wordpress/plugins/fv-wordpress-flowplayer
5
- Description: Embed videos (FLV, H.264, and MP4) into posts or pages. Uses modified version of flowplayer (with removed FP logo and copyright notice).
6
- Version: 1.2.17
7
  Author: Foliovision
8
  Author URI: http://foliovision.com/
 
 
9
  */
10
 
11
- if(is_admin()) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  /**
13
  * If administrator is logged, loads the controller for backend.
14
  */
15
 
16
  include( dirname( __FILE__ ) . '/controller/backend.php' );
17
- require_once(dirname( __FILE__ ) . '/controller/shortcodes.php');
 
18
 
19
  } else {
20
  /**
@@ -23,4 +45,8 @@ if(is_admin()) {
23
  include( dirname( __FILE__ ) . '/controller/frontend.php' );
24
  require_once( dirname( __FILE__ ) . '/controller/shortcodes.php');
25
  }
 
 
 
 
26
  ?>
1
  <?PHP
2
  /*
3
  Plugin Name: FV Wordpress Flowplayer
4
+ Plugin URI: http://foliovision.com/wordpress/plugins/fv-wordpress-flowplayer
5
+ Description: Embed videos (MP4, WEBM, OGV, FLV) into posts or pages. Uses Flowplayer 5.
6
+ Version: 2.1.52
7
  Author: Foliovision
8
  Author URI: http://foliovision.com/
9
+ License: GPL-3.0
10
+ License URI: http://www.gnu.org/licenses/gpl-3.0.txt
11
  */
12
 
13
+ /* FV Wordpress Flowplayer - HTML5 video player with Flash fallback
14
+ Copyright (C) 2013 Foliovision
15
+
16
+ This program is free software: you can redistribute it and/or modify
17
+ it under the terms of the GNU General Public License as published by
18
+ the Free Software Foundation, either version 3 of the License, or
19
+ (at your option) any later version.
20
+
21
+ This program is distributed in the hope that it will be useful,
22
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
+ GNU General Public License for more details.
25
+
26
+ You should have received a copy of the GNU General Public License
27
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
28
+ */
29
+
30
+ include( dirname( __FILE__ ) . '/includes/extra-functions.php' );
31
+
32
+ if( is_admin() ) {
33
  /**
34
  * If administrator is logged, loads the controller for backend.
35
  */
36
 
37
  include( dirname( __FILE__ ) . '/controller/backend.php' );
38
+
39
+ register_activation_hook( __FILE__, 'flowplayer_activate' );
40
 
41
  } else {
42
  /**
45
  include( dirname( __FILE__ ) . '/controller/frontend.php' );
46
  require_once( dirname( __FILE__ ) . '/controller/shortcodes.php');
47
  }
48
+
49
+ $fv_wp_flowplayer_ver = '2.1.52';
50
+ $fv_wp_flowplayer_core_ver = '5.4.6';
51
+
52
  ?>
flowplayer/README.txt DELETED
@@ -1,302 +0,0 @@
1
- Version history:
2
-
3
- 3.2.2
4
- -----
5
- Fixes:
6
- - Now recognizes following kind of urls as audio clips: 'mp3:audiostreamname' (ulrs with mp3 prefix and no extension)
7
- - Now ignores the duration from metadata if we already got one. Fix required for pseudostreaming
8
- - Fix to reuse buffered data when replaying a clip
9
-
10
- 3.2.1
11
- ---------
12
- - Support for RTMP redirects (tested with Wowza loadbalancing)
13
- - Fixed video size when no size info available in clip metadata
14
-
15
- Fixes:
16
- - Fix to correctly detect if the player SWF name contains a version number and if it does also use the version number
17
- when it automatically loads the controls plugin.
18
-
19
- 3.2.0
20
- -----
21
- - canvas, controlbar and the content plugin backgound color and border color can be now given with rgb() and rgba() CSS style syntax
22
- - Added onMouseOver() and onMouseOut() listener registration methods to the Flowplayer API
23
- - enhancements to RSS playlist. Converted parsing to E4X, yahoo media and flowplayer namespace support.
24
- - added feature to obtain bitrate and dimension information to a new clip custom property "bitrates" for future support for bitrate choosing.
25
- - added getter for playerSwfName config
26
- - if clip.url has the string "mp3:" in it, the clip.type will report 'audio'
27
- - added setKeyboardShortcutsEnabled(), addKeyListener(), removeKeyListener() to FlowplayerBase
28
- Fixes:
29
- - onSeek() was not fired when seeking while paused and when using RTMP. An extra onStart was fired too.
30
- - fireErrorExternal() was not working properly with an error PlayerEvent
31
- - countPlugins() was throwing an error when a plugin was not found
32
- - external swf files were not scaled properly
33
- - the logo was unnecessary shown when going fullscreen if logo.displayTime was being used
34
- - added a loadPluginWithConfig method to FlowplayerBase, accessible from javascript. Fixed double onload callback call.
35
- - now handles cuepoint parameters injected using the Adobe Media Encoder
36
- - showPlugin was not working when config.play was null
37
- - handles 3-part duration values included in FLV metadata, like "500.123.123"
38
- - player wasn't always reaching end of video
39
- - fixed broken buffering: false
40
- - fixed event dispatching when embedding flowplayer without flowplayer.js (=without playlist config field)
41
- - fixed safari crashes when unloading player
42
- - fixed scrubber behaviour with a playlist containing 2 images (or swf) in a row
43
- - fixed errors in logs when using an RSS playlist
44
- - fixed OverlayPlayButton that was showing even if it shouldn't on some cases
45
- - fixed wrong behavior when onBeforeFinish was returning false within playlists
46
- - /!\ Don't use the fadeIn / fadeOut controlbar's API while using autoHide.
47
- - fixed play state button with images
48
- - fixed splash image flickering
49
-
50
- 3.1.5
51
- -----
52
- Fixes:
53
- - The player went to a locked state when resuming playback after a period that was long enought to send the
54
- netConnection to an invalid state. Now when resuming playback on an invalid connection the clip starts again from
55
- the beginning. This is only when using RTMP connections and does not affect progressive download playback.
56
- - Custom netConnect and netStream events did not pass the info object to JS listeners
57
-
58
- 3.1.4
59
- -----
60
- Fixes:
61
- - player did not initialize if the controlbar plugin was disabled and if the play button overlay was disabled with play: null
62
- - works properly without cachebusting on IE
63
- - RSS playlist parsing now respects the isDefault attribute used in mRSS media group items
64
- - Fixed passing of connection arguments
65
-
66
- 3.1.3
67
- -----
68
- - enhancements to RSS playlist parsing: Now skips all media:content that have unsupported types. Now the type attribute
69
- of the media:content element is mandatory and has to be present in the RSS file
70
- - Possibility to pass a RSS file name with playFeed("playlist.rss") and setPlaylist("playlist.rss") calls.
71
- - changes to the ConnectionProvider and URLResolver APIs
72
- - Now automatically uses a plugin that is called 'rtmp' for all clips that have the rtmp-protocol in their URLs.
73
- - Added possibility to specify all clip properties in an RSS playlist
74
-
75
- Fixes:
76
- - the result of URL resolvers in now cached, and the resolvers will not be used again when a clip is replayed
77
- - some style properties like 'backgroundGradient' had no effect in config
78
- - video goes tiny on Firefox: http://flowplayer.org/forum/8/23226
79
- - RSS playlists: The 'type' attribute value 'audio/mp3' in the media:content element caused an error.
80
- - Dispatches onMetadata() if an URL resolver changes the clip URL (changes to a different file)
81
- - error codes and error message were not properly passed to onEvent JS listeners
82
-
83
- 3.1.2
84
- -----
85
- - The domain of the logo url must the same domain from where the player SWF is loaded from.
86
- - Fullscreen can be toggled by doublclick on the video area.
87
- Fixes:
88
- - Player was not initialized correctly when instream playlists were used and the provider used in the instream clips was defined in the common clip.
89
- - A separator in the Context Menu made the callbacks in the following menu items out of order. Related forum post: http://flowplayer.org/forum/8/22541
90
- - the width and height settings of a logo were ignored if the logo was a sWF file
91
- - volume control and mute/unmute were not working after an instream clip had been played
92
- - now possible to use RTMP for mp3 files
93
- - Issue 12: cuepointMultiplier was undefined in the clip object set to JS event listeners
94
- - Issue 14: onBeforeStop was unnecessarily fired when calling setPlaylist() and the player was not playing,
95
- additionally onStop was never fired even if onBeforeStop was
96
- - fixed screen vertical placement problems that reappeared with 3.1.1
97
- - The rotating animation now has the same size and position as it has after initialized
98
-
99
- 3.1.1
100
- -----
101
- - External configuration files
102
- - Instream playback
103
- - Added toggleFullscreen() the API
104
- - Possibility to specify controls configuration in clips
105
- - Seek target position is now sent in the onBeforeSeek event
106
- Fixes:
107
- - The screen size was initially too small on Firefox (Mac)
108
- - Did not persist a zero volume value: http://www.flowplayer.org/forum/8/18413
109
-
110
- 3.1.0
111
- -----
112
- New features:
113
- - clip's can have urlResolvers and connectionProviders
114
- - Added new configuration options 'connectionCallbacks' and 'streamCallbacks'. Both accept an Array of event names as a value.
115
- When these events get fired on the connection or stream object, corresponding Clip events will be fired by the player.
116
- This can be used for example when firing custom events from RTMP server apps
117
- - Added new clip event types: 'onConnectionEvent' and 'onStreamEvent' these get fired when the predefined events happen on the connection and stream objects.
118
- - Added Security.allowDomain() to allow loaded plugins to script the player
119
- - Added addClip(clip, index) to the API, index is optional
120
- - Possibility to view videos without metadata, using clip.metaData: false
121
- - Now the player's preloader uses the rotating animation instead of a percent text to indicate the progress
122
- of loading the player SWF. You can disable the aninamtion by setting buffering: false
123
- - calling close() now does not send the onStop event
124
- - Clip's custom properties are now present in the root of the clip argument in all clip events that are sent to JS.
125
-
126
- Bug fixes:
127
- - The preloader sometimes failed to initialize the player
128
- - Allow seeking while in buffering state: http://flowplayer.org/forum/8/16505
129
- - Replay of a RTMP stream was failing after the connection had expired
130
- - Security error when clicking on the screen if there is an image in the playlist loaded from a foreign domain
131
- - loadPlugin() was not working
132
- - now fullscreen works with Flash versions older than 9.0.115, in versions that do not support hardware scaling
133
- - replaying a RTMP stream with an image in front of the stream in the playlist was not working (video stayed hidden). Happened
134
- because the server does not send metadata if replaying the same stream.
135
- - the scrubber is disabled if the clip is not seekable in the first frame: http://flowplayer.org/forum/8/16526
136
- By default if the clip has one of following extensions (the typical flash video extensions) it is seekable
137
- in the first frame: 'f4b', 'f4p', 'f4v', 'flv'. Added new clip property seekableOnBegin that can be used to override the default.
138
-
139
- 3.0.6
140
- -----
141
- - added possibility to associate a linkUrl and linkWindow to the canvas
142
- Fixes:
143
- - fix for entering fullscreen for Flash versions that don't support the hardware scaled fullscreen-mode
144
- - when showing images the duration tracking starts only after the image has been completely loaded: http://flowplayer.org/forum/2/15301
145
- - fix for verifying license keys for domains that have more than 4 labels in them
146
- - if plugin loading failis because of a IO error, the plugin will be discarded and the player initialization continues:
147
-
148
- 3.0.4
149
- -----
150
- - The "play" pseudo-plugin now supports fadeIn(), fadeOut(), showPlugin(), hidePlugin() and
151
- additionally you can configure it like this:
152
- // make only the play button invisible (buffering animation is still used)
153
- play: { display: 'none' }
154
- // disable the play button and the buffering animation
155
- play: null
156
- // disable the buffering animation
157
- buffering: null
158
- - Added possibility to seek when in the buffering state: http://flowplayer.org/forum/3/13896
159
- - Added copyright notices and other GPL required entries to the user interface
160
-
161
- Fixes:
162
- - clip urls were not resolved correctly if the HTML page URL had a query string starting with a question mark (http://flowplayer.org/forum/8/14016#post-14016)
163
- - Fixed context menu for with IE (commercial version)
164
- - a cuepoint at time zero was fired several times
165
- - screen is now arranged correctly even when only bottom or top is defined for it in the configuration
166
- - Fixed context menu for with IE (commercial version)
167
- - a cuepoint at time zero was fired several times
168
- - screen is now arranged correctly even when only bottom or top is defined for it in the configuration
169
- - Now possible to call play() in an onError handler: http://flowplayer.org/forum/8/12939
170
- - Does not throw an error if the player cannot persist the volume on the client computer: http://flowplayer.org/forum/8/13286#post-13495
171
- - Triggering fullscreen does not pause the player in IE
172
- - The play button overlay no longer has a gap between it's pieces when a label is used: http://flowplayer.org/forum/8/14250
173
- - clip.update() JS call now resets the duration
174
- - a label configured for the play button overlay did not work in the commercial version
175
-
176
- 3.0.3
177
- -----
178
- - fixed cuepoint firing: Does not skip cuepoints any more
179
- - Plugins can now be loaded from a different domain to the flowplayer.swf
180
- - Specifying a clip to play by just using the 'clip' node in the configuration was not working, a playlist definition was required. This is now fixed.
181
- - Fixed: A playlist with different providers caused the onMetadata event to fire events with metadata from the previous clip in the playlist. Occurred when moving in the playlist with next() and prev()
182
- - the opacity setting now works with the logo
183
- - fadeOut() call to the "screen" plugin was sending the listenerId and pluginName arguments in wrong order
184
- - stop(), pause(), resume(), close() no longer return the flowplayer object to JS
185
- - changing the size of the screen in a onFullscreen listener now always works, there was a bug that caused this to fail occasionally
186
- - fixed using arbitrary SWFs as plugins
187
- - the API method setPlaylist() no longer starts playing if autoPlay: true, neither it starts buffering if autoBuffering: true
188
- - the API method play() now accepts an array of clip objects as an argument, the playlist is replaced with the specified clips and playback starts from the 1st clip
189
-
190
- 3.0.2
191
- -----
192
- - setting play: null now works again
193
- - pressing the play again button overlay does not open a linkUrl associated with a clip
194
- - now displays a live feed even when the RTMP server does not send any metadata and the onStart method is not therefore dispatched
195
- - added onMetaData clip event
196
- - fixed 'orig' scaling: the player went to 'fit' scaling after coming back from fullscreen. This is now fixed and the original dimensions are preserved in non-fullscreen mode.
197
- - cuepoint times are now given in milliseconds, the firing precision is 100 ms. All cuepoint times are rounded to the nearest 100 ms value (for example 1120 rounds to 1100)
198
- - backgroundGradient was drawn over the background image in the canvas and in the content and controlbar plugins. Now it's drawn below the image.
199
- - added cuepointMultiplier property to clips. This can be used to multiply the time values read from cuepoint metadata embedded into video files.
200
- - the player's framerate was increased to 24 FPS, makes all animations smoother
201
-
202
- 3.0.1
203
- -----
204
- - Fixed negative cuepoints from common clip. Now these are properly propagated to the clips in playlist.
205
- - buffering animation is now the same size as the play button overlay
206
- - commercial version now supports license keys that allows the use of subdomains
207
- - error messages are now automatically hidden after a 4 second delay. They are also hidden when a new clips
208
- starts playing (when onBeforeBegin is fired)
209
- - added possibility to disable the buffering animation like so: buffering: false
210
- - pressing the play button overlay does not open a linkUrl associated with a clip
211
- - license key verification failed if a port number was used in the URL (like in this url: http://mydomain.com:8080/video.html)
212
- - added audio support, clip has a new "image" property
213
- - workaround for missing "NetStream.Play.Start" notfication that was happending with Red5. Because of this issue the video was not shown.
214
- - commercial version has the possibility to change the zIndex of the logo
215
-
216
- 3.0.0
217
- -----
218
- - Removed security errors that happened when loading images from foreign domains (domains other than the domain of the core SWF).
219
- Using a backgroundImage on canvas, in the content plugin, and for the controls is also possible to be loaded
220
- from a foreign domain - BUT backgroundRepeat cannot be used for foreign images.
221
- - Now allows the embedding HTML to script the player even if the player is loaded from another domain.
222
- - Added a 'live' property to Clips, used for live streams.
223
- - A player embedded to a foreign domain now loads images, css files and other resources from the domain where the palyer SWF was loaded from. This is to generate shorter embed-codes.
224
- - Added linkUrl and linkWindow properties to the logo, in commercial version you can set these to point to a linked page. The linked page gets opened
225
- when the logo is clicked. Possible values for linkWindow:
226
- * "_self" specifies the current frame in the current window.
227
- * "_blank" specifies a new window.
228
- * "_parent" specifies the parent of the current frame.
229
- * "_top" specifies the top-level frame in the current window.
230
- - Added linkUrl and linkWindow properties to clips. The linked page is opened when the video are is clicked and the corresponding clip has a linkUrl specified.
231
- - Made the play button overlay and the "Play again" button slightly bigger.
232
-
233
- RC4
234
- ---
235
- - Now shows a "Play again" button at the end of the video/playlist
236
- - Commercial version shows a Flowplayer logo if invalidKey was supplied, but the otherwise the player works
237
- - setting play: null in configuration will disable the play button overlay
238
- - setting opacity for "play" also sets it for the buffering animation
239
- - Fixed firing of cuepoints too early. Cuepoint firing is now based on stream time and does not rely on timers
240
- - added onXMPData event listener
241
- - Should not stop playback too early before the clip is really completed
242
- - The START event is now delayed so that the metadata is available when the event is fired, METADATA event was removed,
243
- new event BEGIN that is dispatched when the playback has been successfully started. Metadata is not normally
244
- available when BEGIN is fired.
245
-
246
- RC3
247
- ---
248
- - stopBuffering() now dispatches the onStop event first if the player is playing/paused/buffering at the time of calling it
249
- - fixed detection of images based on file extensions
250
- - fixed some issues with having images in the playlist
251
- - made it possible to autoBuffer next video while showing an image (image without a duration)
252
-
253
- RC2
254
- ---
255
- - fixed: setting the screen height in configuration did not have any effect
256
-
257
- RC1
258
- -----
259
- - better error message if plugin loading fails, shows the URL used
260
- - validates our redesigned multidomain license key correctly
261
- - fix to prevent the play button going visible when the onBufferEmpty event occurs
262
- - the commercial swf now correctly loads the controls using version information
263
- - fixed: the play button overlay became invisible with long fadeOutSpeeds
264
-
265
- beta6
266
- -----
267
- - removed the onFirstFramePause event
268
- - playing a clip for the second time caused a doubled sound
269
- - pausing on first frame did not work on some FLV files
270
-
271
- beta5
272
- -----
273
- - logo only uses percentage scaling if it's a SWF file (there is ".swf" in it's url)
274
- - context menu now correctly builds up from string entries in configuration
275
- -always closes the previous connection before starting a new clip
276
-
277
- beta4
278
- -----
279
- - now it's possible to load a plugin into the panel without specifying any position/dimensions
280
- information, the plugin is placed to left: "50%", top: "50%" and using the plugin DisplayObject's width & height
281
- - The Flowplayer API was not fully initialized when onLoad was invoked on Flash plugins
282
-
283
- beta3
284
- -----
285
- - tweaking logo placement
286
- - "play" did not show up after repeated pause/resume
287
- - player now loads the latest controls SWF version, right now the latest SWF is called 'flowplayer.controls-3.0.0-beta2.swf'
288
-
289
- beta2
290
- -----
291
- - fixed support for RTMP stream groups
292
- - changed to loop through available fonts in order to find a suitable font also in IE
293
- - Preloader was broken on IE: When the player SWf was in browser's cache it did not initialize properly
294
- - Context menu now correctly handles menu items that are configured by their string labels only (not using json objects)
295
- - fixed custom logo positioning (was moved to the left edge of screen in fullscreen)
296
- - "play" now always follows the position and size of the screen
297
- - video was stretched below the controls in fullscreen when autoHide: 'never'
298
- - logo now takes 6.5% of the screen height, width is scaled so that the aspect ratio is preserved
299
-
300
- beta1
301
- -----
302
- - First public beta release
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
flowplayer/commercial/LICENSE_COMMERCIAL.txt DELETED
@@ -1,166 +0,0 @@
1
- FLOWPLAYER COMMERCIAL LICENSE version 0.1
2
- ==========================================
3
- Copyright (c) 2008 Flowplayer Ltd, all rights reserved
4
-
5
- Please read this License carefully before using, downloading or installing
6
- the Software (Flowplayer, as defined below). By using, downloading or
7
- installing the Software, Licensee is agreeing to be bound by this License
8
- and the licenses granted hereunder are subject to compliance with any and
9
- all terms of this License. IF YOU DO NOT ACCEPT THE TERMS AND CONDITIONS
10
- OF THIS LICENSE, DO NOT USE, DOWNLOAD, INSTALL OR DISTRIBUTE ANY OF THE
11
- LICENSED SOFTWARE.
12
-
13
- Terms and definitions
14
- =====================
15
-
16
- "Software" means the licensed Flowplayer software
17
-
18
- "Adaptation" means a derivative work based upon the Licensed Software resulting
19
- from any addition to, editing of or deletion from the substance or structure of the
20
- original source code or a compiled version of the Licensed Software or any previous
21
- Adaptations or a work that programmatically interacts with the Licensed Software.
22
-
23
- "Licensed Software" means the same as Software.
24
-
25
- "License" means this document.
26
-
27
- "Licensor" means Flowplayer Ltd.
28
-
29
- "License Key" means an alphanumeric key that is used to activate the Sofware. The License
30
- Key is provided by Licensor.
31
-
32
- "Licensee" means an individual or entity exercising rights under and complying with the
33
- terms of this License who has not previously violated the terms of this License with respect
34
- to the Software, or who has received express permission from the Licensor to exercise rights
35
- under this License despite a previous violation.
36
-
37
- License Grant
38
- =============
39
- Licensor hereby grants the Licensee a non-exclusive, non-transferable, non-assignable license,
40
- without the right to sublicense to: Access, display, integrate and use the Software in one
41
- (1) Internet domain that has been registered with Licensor. Licensor provides a license key
42
- that is tied to the domain name; and Make an Adaptation and access, display and integrate
43
- it in the one (1) Internet domain that has been registered with Licensor. The Adaptation must
44
- not remove the License Key logic from the Software so that the Adaptation only functions if a
45
- valid license key has been configured for it.
46
-
47
- Licensor hereby grants the Licensee a non-exclusive, worldwide, royalty-free, non-transferable,
48
- non-assignable patent license, without the right to sublicense, under any patent rights
49
- the Licensor holds in the Software to use, run, and modify the Software in the one (1) Internet
50
- domain that has been registered with Licensor, provided that any Adaptation made to the Software
51
- does not remove the License Key logic from the Software so that the Adaptation only functions
52
- if a valid license key has been configured for it.
53
-
54
- All rights not expressly granted by this Agreement are expressly reserved by Licensor.
55
-
56
- Applicability of License
57
- ========================
58
-
59
- This License applies to the Software version purchased by the Licensee.
60
- Additional later versions released by the Licensor are not part of this License.
61
-
62
- Protection of Licensed Software
63
- ===============================
64
-
65
- Except as specifically set forth herein or as otherwise agreed to between Licensor and Licensee,
66
- Licensee shall not have the right to copy, relicense, sell, lease, transfer, encumber, assign
67
- or make available for public use the Software. Any attempt to take any such actions is void,
68
- and will automatically terminate your rights under this License.
69
-
70
- Licensee shall use its best efforts to ensure that no unauthorized copy of the Licensed Programs
71
- shall be made, in whole or in part, in any form. Licensee shall prohibit all users of the Software
72
- from modifying, reverse-engineering or disassembling any part of the Software. All rights not
73
- expressly granted by Licensor are hereby reserved.
74
-
75
- Effective Date
76
- ==============
77
-
78
- The rights and licenses granted hereunder shall commence on the date any of the Software are
79
- electronically delivered to Licensee. Licensor agrees to make the Software available for
80
- electronic delivery to Licensee promptly after receipt by Licensor of the License Fee. For
81
- purposes of this Agreement, the License Fee means the amount of money required to be paid
82
- by Licensee to Licensor for legal usage of the Software under the terms of this agreement.
83
-
84
- Termination of the license
85
- ==========================
86
-
87
- This license is subject to termination by Licensor at any time if (a) Licensee violates any terms
88
- of this License, (b) Licensor has a reasonable basis to believe that Licensee's business is
89
- impairing Licensor's business.
90
-
91
- Ownership of Intellectual Property
92
- ==================================
93
-
94
- Licensor is the sole owner of all intellectual property rights pertaining to the Licensed Software.
95
- Licensor reserves all rights not expressly granted herein.
96
-
97
- NO WARRANTY
98
- ===========
99
-
100
- TO THE FULLEST EXTENT PERMISSIBLE UNDER APPLICABLE LAW, THE LICENSED SOFTWARE IS PROVIDED TO YOU "AS IS,"
101
- WITH ALL FAULTS, WITHOUT WARRANTY OF ANY KIND, AND YOUR USE IS AT YOUR SOLE RISK. THE ENTIRE RISK
102
- OF SATISFACTORY QUALITY AND PERFORMANCE RESIDES WITH YOU. LICENSOR DISCLAIMS ANY AND ALL EXPRESS,
103
- IMPLIED OR STATUTORY WARRANTIES, INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY, SATISFACTORY QUALITY,
104
- FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT OF THIRD PARTY RIGHTS, ANY WARRANTIES OR CONDITIONS
105
- OF TITLE, AND WARRANTIES (IF ANY) ARISING FROM A COURSE OF DEALING, USAGE, OR TRADE PRACTICE. LICENSOR
106
- DOES NOT WARRANT AGAINST INTERFERENCE WITH YOUR ENJOYMENT OF THE PROGRAM; THAT THE PROGRAM WILL MEET
107
- YOUR REQUIREMENTS; THAT OPERATION OF THE PROGRAM WILL BE UNINTERRUPTED OR ERROR-FREE, OR THAT THE PROGRAM
108
- WILL BE COMPATIBLE WITH THIRD PARTY SOFTWARE OR THAT ANY ERRORS IN THE PROGRAM WILL BE CORRECTED. NO ORAL
109
- OR WRITTEN ADVICE PROVIDED BY LICENSOR OR ANY AUTHORIZED REPRESENTATIVE SHALL CREATE A WARRANTY. SOME
110
- JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF OR LIMITATIONS ON IMPLIED WARRANTIES OR THE LIMITATIONS
111
- ON THE APPLICABLE STATUTORY RIGHTS OF A CONSUMER, SO SOME OR ALL OF THE ABOVE EXCLUSIONS AND LIMITATIONS
112
- MAY NOT APPLY TO YOU. LICENSEE IS SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USING AND
113
- DISTRIBUTING THE LICENSED SOFTWARE AND ASSUMES ALL RISKS ASSOCIATED WITH ITS EXERCISE OF RIGHTS UNDER
114
- THIS AGREEMENT, INCLUDING BUT NOT LIMITED TO THE RISKS AND COSTS OF PROGRAM ERRORS, COMPLIANCE WITH
115
- APPLICABLE LAWS, DAMAGE TO OR LOSS OF DATA, PROGRAMS OR EQUIPMENT, SUITABILITY FOR HOSTING AND
116
- UNAVAILABILITY OR INTERRUPTION OF OPERATIONS.
117
-
118
- Limitation of Liability
119
- =======================
120
- Except to the extent required by applicable law, THE CUMULATIVE, AGGREGATE LIABILITY OF LICENSOR
121
- TO LICENSEE FOR ALL CLAIMS RELATED TO THE LICENSED SOFTWARE AND THIS AGREEMENT, WILL NOT EXCEED
122
- THE TOTAL AMOUNT OF ALL LICENSE FEES PAID TO LICENSOR HEREUNDER. LICENSOR WILL NOT IN ANY CASE
123
- BE LIABLE FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, INDIRECT, PUNITIVE, OR EXEMPLARY DAMAGES
124
- ARISING IN ANY WAY OUT OF THE USE OF THE PRODUCT, THE SERVICES OR THIS AGREEMENT, INCLUDING
125
- WITHOUT LIMITATION, DAMAGES FOR LOST PROFIT, LOST REVENUE, LOSS OF USE, LOSS OF DATA, COSTS
126
- OF RECREATING LOST DATA, THE COST OF ANY SUBSTITUTE EQUIPMENT, PROGRAM, OR DATA, OR CLAIMS
127
- BY ANY THIRD PARTY, INCLUDING WITH LIMITATION THIRD PARTY CLAIMS OF INFRINGEMENT OF INTELLECTUAL
128
- PROPERTY RIGHTS, INFRINGEMENT OF COPYRIGHT, TRADEMARK, PATENT, OR TRADE SECRETS. LICENSEE'S
129
- SOLE AND EXCLUSIVE REMEDY IS SET FORTH IN THIS AGREEMENT. THE LIMITATION ON DAMAGES SET FORTH
130
- IN SECTION WILL NOT APPLY TO INDEMNIFICATION OBLIGATIONS OR BREACHES BY LICENSEE.
131
-
132
- Indemnity
133
- =========
134
- Licensee shall indemnify Licensor, its employees, officers, licensees and agents for all damages,
135
- costs and expenses, including, without limitation, attorneys’ fees, arising from any claims arising
136
- as a result of Licensee’s use of the Licensed Software, either as provided or as Adapted by Licensee.
137
-
138
- Export
139
- ======
140
- Licensee agrees and certifies that it will not export or re-export, directly or indirectly, the Licensed
141
- Software contrary to the laws of the United States or any other country.
142
-
143
- Severability
144
- ============
145
- If for any reason a court of competent jurisdiction finds any provision of this License or portion
146
- thereof, to be unenforceable, that provision of the License shall be enforced to the maximum extent
147
- permissible so as to affect the intent of the parties, and the remainder of this License shall
148
- continue in full force and effect.
149
-
150
- Governing Law
151
- =============
152
- This License shall be governed by the laws of Finland. Any disputes arising under this License
153
- shall be heard in the city of Espoo, Finland.
154
-
155
- Complete Agreement
156
- ===================
157
- This License constitutes the entire agreement between Licensor and Licensee with respect to the
158
- use of the Licensed Software and supersedes all prior or contemporaneous understandings
159
- or agreements, written or oral, regarding such subject matter. No one other than Licensor
160
- has the right to modify or amend this License.
161
-
162
- Waiver of Breach
163
- ================
164
- No term or provision of this License shall be deemed waived and no breach excused, unless such
165
- waiver or consent shall be in writing and signed by Licensor.
166
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
flowplayer/commercial/README.txt DELETED
@@ -1,255 +0,0 @@
1
- Version history:
2
-
3
- 3.1.5
4
- -----
5
- Fixes:
6
- - The player went to a locked state when resuming playback after a period that was long enought to send the
7
- netConnection to an invalid state. Now when resuming playback on an invalid connection the clip starts again from
8
- the beginning. This is only when using RTMP connections and does not affect progressive download playback.
9
- - Custom netConnect and netStream events did not pass the info object to JS listeners
10
-
11
- 3.1.4
12
- -----
13
- Fixes:
14
- - player did not initialize if the controlbar plugin was disabled and if the play button overlay was disabled with play: null
15
- - works properly without cachebusting on IE
16
- - RSS playlist parsing now respects the isDefault attribute used in mRSS media group items
17
- - Fixed passing of connection arguments
18
-
19
- 3.1.3
20
- -----
21
- - enhancements to RSS playlist parsing: Now skips all media:content that have unsupported types. Now the type attribute
22
- of the media:content element is mandatory and has to be present in the RSS file
23
- - Possibility to pass a RSS file name with playFeed("playlist.rss") and setPlaylist("playlist.rss") calls.
24
- - changes to the ConnectionProvider and URLResolver APIs
25
- - Now automatically uses a plugin that is called 'rtmp' for all clips that have the rtmp-protocol in their URLs.
26
- - Added possibility to specify all clip properties in an RSS playlist
27
-
28
- Fixes:
29
- - the result of URL resolvers in now cached, and the resolvers will not be used again when a clip is replayed
30
- - some style properties like 'backgroundGradient' had no effect in config
31
- - video goes tiny on Firefox: http://flowplayer.org/forum/8/23226
32
- - RSS playlists: The 'type' attribute value 'audio/mp3' in the media:content element caused an error.
33
- - Dispatches onMetadata() if an URL resolver changes the clip URL (changes to a different file)
34
- - error codes and error message were not properly passed to onEvent JS listeners
35
-
36
- 3.1.2
37
- -----
38
- - The domain of the logo url must the same domain from where the player SWF is loaded from.
39
- - Fullscreen can be toggled by doublclick on the video area.
40
- Fixes:
41
- - Player was not initialized correctly when instream playlists were used and the provider used in the instream clips was defined in the common clip.
42
- - A separator in the Context Menu made the callbacks in the following menu items out of order. Related forum post: http://flowplayer.org/forum/8/22541
43
- - the width and height settings of a logo were ignored if the logo was a sWF file
44
- - volume control and mute/unmute were not working after an instream clip had been played
45
- - now possible to use RTMP for mp3 files
46
- - Issue 12: cuepointMultiplier was undefined in the clip object set to JS event listeners
47
- - Issue 14: onBeforeStop was unnecessarily fired when calling setPlaylist() and the player was not playing,
48
- additionally onStop was never fired even if onBeforeStop was
49
- - fixed screen vertical placement problems that reappeared with 3.1.1
50
- - The rotating animation now has the same size and position as it has after initialized
51
-
52
- 3.1.1
53
- -----
54
- - External configuration files
55
- - Instream playback
56
- - Added toggleFullscreen() the API
57
- - Possibility to specify controls configuration in clips
58
- - Seek target position is now sent in the onBeforeSeek event
59
- Fixes:
60
- - The screen size was initially too small on Firefox (Mac)
61
- - Did not persist a zero volume value: http://www.flowplayer.org/forum/8/18413
62
-
63
- 3.1.0
64
- -----
65
- New features:
66
- - clip's can have urlResolvers and connectionProviders
67
- - Added new configuration options 'connectionCallbacks' and 'streamCallbacks'. Both accept an Array of event names as a value.
68
- When these events get fired on the connection or stream object, corresponding Clip events will be fired by the player.
69
- This can be used for example when firing custom events from RTMP server apps
70
- - Added new clip event types: 'onConnectionEvent' and 'onStreamEvent' these get fired when the predefined events happen on the connection and stream objects.
71
- - Added Security.allowDomain() to allow loaded plugins to script the player
72
- - Added addClip(clip, index) to the API, index is optional
73
- - Possibility to view videos without metadata, using clip.metaData: false
74
- - Now the player's preloader uses the rotating animation instead of a percent text to indicate the progress
75
- of loading the player SWF. You can disable the aninamtion by setting buffering: false
76
- - calling close() now does not send the onStop event
77
- - Clip's custom properties are now present in the root of the clip argument in all clip events that are sent to JS.
78
-
79
- Bug fixes:
80
- - The preloader sometimes failed to initialize the player
81
- - Allow seeking while in buffering state: http://flowplayer.org/forum/8/16505
82
- - Replay of a RTMP stream was failing after the connection had expired
83
- - Security error when clicking on the screen if there is an image in the playlist loaded from a foreign domain
84
- - loadPlugin() was not working
85
- - now fullscreen works with Flash versions older than 9.0.115, in versions that do not support hardware scaling
86
- - replaying a RTMP stream with an image in front of the stream in the playlist was not working (video stayed hidden). Happened
87
- because the server does not send metadata if replaying the same stream.
88
- - the scrubber is disabled if the clip is not seekable in the first frame: http://flowplayer.org/forum/8/16526
89
- By default if the clip has one of following extensions (the typical flash video extensions) it is seekable
90
- in the first frame: 'f4b', 'f4p', 'f4v', 'flv'. Added new clip property seekableOnBegin that can be used to override the default.
91
-
92
- 3.0.6
93
- -----
94
- - added possibility to associate a linkUrl and linkWindow to the canvas
95
- Fixes:
96
- - fix for entering fullscreen for Flash versions that don't support the hardware scaled fullscreen-mode
97
- - when showing images the duration tracking starts only after the image has been completely loaded: http://flowplayer.org/forum/2/15301
98
- - fix for verifying license keys for domains that have more than 4 labels in them
99
- - if plugin loading failis because of a IO error, the plugin will be discarded and the player initialization continues:
100
-
101
- 3.0.4
102
- -----
103
- - The "play" pseudo-plugin now supports fadeIn(), fadeOut(), showPlugin(), hidePlugin() and
104
- additionally you can configure it like this:
105
- // make only the play button invisible (buffering animation is still used)
106
- play: { display: 'none' }
107
- // disable the play button and the buffering animation
108
- play: null
109
- // disable the buffering animation
110
- buffering: null
111
- - Added possibility to seek when in the buffering state: http://flowplayer.org/forum/3/13896
112
- - Added copyright notices and other GPL required entries to the user interface
113
-
114
- Fixes:
115
- - clip urls were not resolved correctly if the HTML page URL had a query string starting with a question mark (http://flowplayer.org/forum/8/14016#post-14016)
116
- - Fixed context menu for with IE (commercial version)
117
- - a cuepoint at time zero was fired several times
118
- - screen is now arranged correctly even when only bottom or top is defined for it in the configuration
119
- - Fixed context menu for with IE (commercial version)
120
- - a cuepoint at time zero was fired several times
121
- - screen is now arranged correctly even when only bottom or top is defined for it in the configuration
122
- - Now possible to call play() in an onError handler: http://flowplayer.org/forum/8/12939
123
- - Does not throw an error if the player cannot persist the volume on the client computer: http://flowplayer.org/forum/8/13286#post-13495
124
- - Triggering fullscreen does not pause the player in IE
125
- - The play button overlay no longer has a gap between it's pieces when a label is used: http://flowplayer.org/forum/8/14250
126
- - clip.update() JS call now resets the duration
127
- - a label configured for the play button overlay did not work in the commercial version
128
-
129
- 3.0.3
130
- -----
131
- - fixed cuepoint firing: Does not skip cuepoints any more
132
- - Plugins can now be loaded from a different domain to the flowplayer.swf
133
- - Specifying a clip to play by just using the 'clip' node in the configuration was not working, a playlist definition was required. This is now fixed.
134
- - Fixed: A playlist with different providers caused the onMetadata event to fire events with metadata from the previous clip in the playlist. Occurred when moving in the playlist with next() and prev()
135
- - the opacity setting now works with the logo
136
- - fadeOut() call to the "screen" plugin was sending the listenerId and pluginName arguments in wrong order
137
- - stop(), pause(), resume(), close() no longer return the flowplayer object to JS
138
- - changing the size of the screen in a onFullscreen listener now always works, there was a bug that caused this to fail occasionally
139
- - fixed using arbitrary SWFs as plugins
140
- - the API method setPlaylist() no longer starts playing if autoPlay: true, neither it starts buffering if autoBuffering: true
141
- - the API method play() now accepts an array of clip objects as an argument, the playlist is replaced with the specified clips and playback starts from the 1st clip
142
-
143
- 3.0.2
144
- -----
145
- - setting play: null now works again
146
- - pressing the play again button overlay does not open a linkUrl associated with a clip
147
- - now displays a live feed even when the RTMP server does not send any metadata and the onStart method is not therefore dispatched
148
- - added onMetaData clip event
149
- - fixed 'orig' scaling: the player went to 'fit' scaling after coming back from fullscreen. This is now fixed and the original dimensions are preserved in non-fullscreen mode.
150
- - cuepoint times are now given in milliseconds, the firing precision is 100 ms. All cuepoint times are rounded to the nearest 100 ms value (for example 1120 rounds to 1100)
151
- - backgroundGradient was drawn over the background image in the canvas and in the content and controlbar plugins. Now it's drawn below the image.
152
- - added cuepointMultiplier property to clips. This can be used to multiply the time values read from cuepoint metadata embedded into video files.
153
- - the player's framerate was increased to 24 FPS, makes all animations smoother
154
-
155
- 3.0.1
156
- -----
157
- - Fixed negative cuepoints from common clip. Now these are properly propagated to the clips in playlist.
158
- - buffering animation is now the same size as the play button overlay
159
- - commercial version now supports license keys that allows the use of subdomains
160
- - error messages are now automatically hidden after a 4 second delay. They are also hidden when a new clips
161
- starts playing (when onBeforeBegin is fired)
162
- - added possibility to disable the buffering animation like so: buffering: false
163
- - pressing the play button overlay does not open a linkUrl associated with a clip
164
- - license key verification failed if a port number was used in the URL (like in this url: http://mydomain.com:8080/video.html)
165
- - added audio support, clip has a new "image" property
166
- - workaround for missing "NetStream.Play.Start" notfication that was happending with Red5. Because of this issue the video was not shown.
167
- - commercial version has the possibility to change the zIndex of the logo
168
-
169
- 3.0.0
170
- -----
171
- - Removed security errors that happened when loading images from foreign domains (domains other than the domain of the core SWF).
172
- Using a backgroundImage on canvas, in the content plugin, and for the controls is also possible to be loaded
173
- from a foreign domain - BUT backgroundRepeat cannot be used for foreign images.
174
- - Now allows the embedding HTML to script the player even if the player is loaded from another domain.
175
- - Added a 'live' property to Clips, used for live streams.
176
- - A player embedded to a foreign domain now loads images, css files and other resources from the domain where the palyer SWF was loaded from. This is to generate shorter embed-codes.
177
- - Added linkUrl and linkWindow properties to the logo, in commercial version you can set these to point to a linked page. The linked page gets opened
178
- when the logo is clicked. Possible values for linkWindow:
179
- * "_self" specifies the current frame in the current window.
180
- * "_blank" specifies a new window.
181
- * "_parent" specifies the parent of the current frame.
182
- * "_top" specifies the top-level frame in the current window.
183
- - Added linkUrl and linkWindow properties to clips. The linked page is opened when the video are is clicked and the corresponding clip has a linkUrl specified.
184
- - Made the play button overlay and the "Play again" button slightly bigger.
185
-
186
- RC4
187
- ---
188
- - Now shows a "Play again" button at the end of the video/playlist
189
- - Commercial version shows a Flowplayer logo if invalidKey was supplied, but the otherwise the player works
190
- - setting play: null in configuration will disable the play button overlay
191
- - setting opacity for "play" also sets it for the buffering animation
192
- - Fixed firing of cuepoints too early. Cuepoint firing is now based on stream time and does not rely on timers
193
- - added onXMPData event listener
194
- - Should not stop playback too early before the clip is really completed
195
- - The START event is now delayed so that the metadata is available when the event is fired, METADATA event was removed,
196
- new event BEGIN that is dispatched when the playback has been successfully started. Metadata is not normally
197
- available when BEGIN is fired.
198
-
199
- RC3
200
- ---
201
- - stopBuffering() now dispatches the onStop event first if the player is playing/paused/buffering at the time of calling it
202
- - fixed detection of images based on file extensions
203
- - fixed some issues with having images in the playlist
204
- - made it possible to autoBuffer next video while showing an image (image without a duration)
205
-
206
- RC2
207
- ---
208
- - fixed: setting the screen height in configuration did not have any effect
209
-
210
- RC1
211
- -----
212
- - better error message if plugin loading fails, shows the URL used
213
- - validates our redesigned multidomain license key correctly
214
- - fix to prevent the play button going visible when the onBufferEmpty event occurs
215
- - the commercial swf now correctly loads the controls using version information
216
- - fixed: the play button overlay became invisible with long fadeOutSpeeds
217
-
218
- beta6
219
- -----
220
- - removed the onFirstFramePause event
221
- - playing a clip for the second time caused a doubled sound
222
- - pausing on first frame did not work on some FLV files
223
-
224
- beta5
225
- -----
226
- - logo only uses percentage scaling if it's a SWF file (there is ".swf" in it's url)
227
- - context menu now correctly builds up from string entries in configuration
228
- -always closes the previous connection before starting a new clip
229
-
230
- beta4
231
- -----
232
- - now it's possible to load a plugin into the panel without specifying any position/dimensions
233
- information, the plugin is placed to left: "50%", top: "50%" and using the plugin DisplayObject's width & height
234
- - The Flowplayer API was not fully initialized when onLoad was invoked on Flash plugins
235
-
236
- beta3
237
- -----
238
- - tweaking logo placement
239
- - "play" did not show up after repeated pause/resume
240
- - player now loads the latest controls SWF version, right now the latest SWF is called 'flowplayer.controls-3.0.0-beta2.swf'
241
-
242
- beta2
243
- -----
244
- - fixed support for RTMP stream groups
245
- - changed to loop through available fonts in order to find a suitable font also in IE
246
- - Preloader was broken on IE: When the player SWf was in browser's cache it did not initialize properly
247
- - Context menu now correctly handles menu items that are configured by their string labels only (not using json objects)
248
- - fixed custom logo positioning (was moved to the left edge of screen in fullscreen)
249
- - "play" now always follows the position and size of the screen
250
- - video was stretched below the controls in fullscreen when autoHide: 'never'
251
- - logo now takes 6.5% of the screen height, width is scaled so that the aspect ratio is preserved
252
-
253
- beta1
254
- -----
255
- - First public beta release
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
flowplayer/commercial/flowplayer.commercial-3.1.5.swf DELETED
Binary file
flowplayer/commercial/flowplayer.controls-3.1.5.swf DELETED
Binary file
flowplayer/embed.min.js ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ /*
2
+ Flowplayer Embed 5.4.6 | flowplayer.org
3
+ */!function(){function c(e,t,n){if(e)return n(e);if(window.fp5ecc[t])return window.fp5ecc[t].push(n);window.fp5ecc[t]=[n];var r=document.createElement("script");r.onload=r.onreadystatechange=function(){var e=r.readyState;if(e===undefined||/complete|loaded/.test(e)){var n=window.fp5ecc[t];for(var i=0;i<n.length;i++)n[i]()}},r.async=!0,r.src=t,i.insertBefore(r,i.firstChild)}function h(e){if(window.fp5ecssc[e])return;window.fp5ecssc[e]=!0;var t=document.createElement("link");t.rel="stylesheet",t.type="text/css",t.href=e,i.insertBefore(t,i.firstChild)}var e,t=document.getElementsByTagName("script"),n=document.createElement("div");for(var r=0;r<t.length;r++)if(t[r].innerHTML.indexOf("<video")!==-1){e=t[r],e.parentNode.insertBefore(n,e),e.parentNode.removeChild(e);break}var i=document.getElementsByTagName("head")[0],s="//foliovision.com/flowplayer/5.4.6",o=e.getAttribute("data-library")||s+"/flowplayer.min.js",u=e.getAttribute("data-swf")||s+"/flowplayer.swf",a=e.getAttribute("data-skin")||s+"/flowplayer.css",f="//www.google-analytics.com/ga.js",l="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";window.fp5ecc=window.fp5ecc||{},window.fp5ecssc=window.fp5ecssc||{};var p=typeof jQuery!="undefined"?jQuery().jquery:"",d=p.split("."),v=typeof $!="undefined"&&jQuery!=$;c(Number(d[0])>=1&&Number(d[1])>=7,l,function(t){var r;!t&&v&&(r=jQuery.noConflict());var i=!t&&p!=="";c(typeof _gat!="undefined",f,function(){c(typeof flowplayer!="undefined",o,function(t){t||h(a),r=r||jQuery;var s=r(e),f=s.attr("src"),l=r(s.html().replace(/^[ \t\n\r]+/gm,"").replace(/[ \n\t\r]+$/gm,""));r(n).replaceWith(l),l.find(":not(video, source)").remove(),l.flowplayer({swf:u,e:1}),l.data("flowplayer").conf.embed={library:o,swf:u,script:f},i&&r.noConflict(!0)})})})}();
flowplayer/flowplayer.audio-3.2.2.swf DELETED
Binary file
flowplayer/flowplayer.controls.swf DELETED
Binary file
flowplayer/flowplayer.min.js DELETED
@@ -1,24 +0,0 @@
1
- /**
2
- * flowplayer.js 3.0.3. The Flowplayer API
3
- *
4
- * Copyright 2008 Flowplayer Oy
5
- *
6
- * This file is part of Flowplayer.
7
- *
8
- * Flowplayer is free software: you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation, either version 3 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * Flowplayer is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License
19
- * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>.
20
- *
21
- * Version: 3.0.3 - Wed Jan 07 2009 13:22:30 GMT-0000 (GMT+00:00)
22
- */
23
- (function(){function log(args){console.log("$f.fireEvent",[].slice.call(args));}function clone(obj){if(!obj||typeof obj!='object'){return obj;}var temp=new obj.constructor();for(var key in obj){if(obj.hasOwnProperty(key)){temp[key]=clone(obj[key]);}}return temp;}function each(obj,fn){if(!obj){return;}var name,i=0,length=obj.length;if(length===undefined){for(name in obj){if(fn.call(obj[name],name,obj[name])===false){break;}}}else{for(var value=obj[0];i<length&&fn.call(value,i,value)!==false;value=obj[++i]){}}return obj;}function el(id){return document.getElementById(id);}function extend(to,from,skipFuncs){if(to&&from){each(from,function(name,value){if(!skipFuncs||typeof value!='function'){to[name]=value;}});}}function select(query){var index=query.indexOf(".");if(index!=-1){var tag=query.substring(0,index)||"*";var klass=query.substring(index+1,query.length);var els=[];each(document.getElementsByTagName(tag),function(){if(this.className&&this.className.indexOf(klass)!=-1){els.push(this);}});return els;}}function stopEvent(e){e=e||window.event;if(e.preventDefault){e.stopPropagation();e.preventDefault();}else{e.returnValue=false;e.cancelBubble=true;}return false;}function bind(to,evt,fn){to[evt]=to[evt]||[];to[evt].push(fn);}function makeId(){return"_"+(""+Math.random()).substring(2,10);}var Clip=function(json,index,player){var self=this;var cuepoints={};var listeners={};self.index=index;if(typeof json=='string'){json={url:json};}extend(this,json,true);each(("Begin*,Start,Pause*,Resume*,Seek*,Stop*,Finish*,LastSecond,Update,BufferFull,BufferEmpty,BufferStop").split(","),function(){var evt="on"+this;if(evt.indexOf("*")!=-1){evt=evt.substring(0,evt.length-1);var before="onBefore"+evt.substring(2);self[before]=function(fn){bind(listeners,before,fn);return self;};}self[evt]=function(fn){bind(listeners,evt,fn);return self;};if(index==-1){if(self[before]){player[before]=self[before];}if(self[evt]){player[evt]=self[evt];}}});extend(this,{onCuepoint:function(points,fn){if(arguments.length==1){cuepoints.embedded=[null,points];return self;}if(typeof points=='number'){points=[points];}var fnId=makeId();cuepoints[fnId]=[points,fn];if(player.isLoaded()){player._api().fp_addCuepoints(points,index,fnId);}return self;},update:function(json){extend(self,json);if(player.isLoaded()){player._api().fp_updateClip(json,index);}var conf=player.getConfig();var clip=(index==-1)?conf.clip:conf.playlist[index];extend(clip,json,true);},_fireEvent:function(evt,arg1,arg2,target){if(evt=='onLoad'){each(cuepoints,function(key,val){if(val[0]){player._api().fp_addCuepoints(val[0],index,key);}});return false;}if(index!=-1){target=self;}if(evt=='onCuepoint'){var fn=cuepoints[arg1];if(fn){return fn[1].call(player,target,arg2);}}if(evt=='onStart'||evt=='onUpdate'){extend(target,arg1);if(!target.duration){target.duration=arg1.metaData.duration;}else{target.fullDuration=arg1.metaData.duration;}}var ret=true;each(listeners[evt],function(){ret=this.call(player,target,arg1,arg2);});return ret;}});if(json.onCuepoint){var arg=json.onCuepoint;self.onCuepoint.apply(self,typeof arg=='function'?[arg]:arg);delete json.onCuepoint;}each(json,function(key,val){if(typeof val=='function'){bind(listeners,key,val);delete json[key];}});if(index==-1){player.onCuepoint=this.onCuepoint;}};var Plugin=function(name,json,player,fn){var listeners={};var self=this;var hasMethods=false;if(fn){extend(listeners,fn);}each(json,function(key,val){if(typeof val=='function'){listeners[key]=val;delete json[key];}});extend(this,{animate:function(props,speed,fn){if(!props){return self;}if(typeof speed=='function'){fn=speed;speed=500;}if(typeof props=='string'){var key=props;props={};props[key]=speed;speed=500;}if(fn){var fnId=makeId();listeners[fnId]=fn;}if(speed===undefined){speed=500;}json=player._api().fp_animate(name,props,speed,fnId);return self;},css:function(props,val){if(val!==undefined){var css={};css[props]=val;props=css;}json=player._api().fp_css(name,props);extend(self,json);return self;},show:function(){this.display='block';player._api().fp_showPlugin(name);return self;},hide:function(){this.display='none';player._api().fp_hidePlugin(name);return self;},toggle:function(){this.display=player._api().fp_togglePlugin(name);return self;},fadeTo:function(o,speed,fn){if(typeof speed=='function'){fn=speed;speed=500;}if(fn){var fnId=makeId();listeners[fnId]=fn;}this.display=player._api().fp_fadeTo(name,o,speed,fnId);this.opacity=o;return self;},fadeIn:function(speed,fn){return self.fadeTo(1,speed,fn);},fadeOut:function(speed,fn){return self.fadeTo(0,speed,fn);},getName:function(){return name;},_fireEvent:function(evt,arg){if(evt=='onUpdate'){var json=player._api().fp_getPlugin(name);if(!json){return;}extend(self,json);delete self.methods;if(!hasMethods){each(json.methods,function(){var method=""+this;self[method]=function(){var a=[].slice.call(arguments);var ret=player._api().fp_invoke(name,method,a);return ret=='undefined'?self:ret;};});hasMethods=true;}}var fn=listeners[evt];if(fn){fn.call(self,arg);if(evt.substring(0,1)=="_"){delete listeners[evt];}}}});};function Player(wrapper,params,conf){var
24
- self=this,api=null,html,commonClip,playlist=[],plugins={},listeners={},playerId,apiId,playerIndex,activeIndex,swfHeight,wrapperHeight;extend(self,{id:function(){return playerId;},isLoaded:function(){return(api!==null);},getParent:function(){return wrapper;},hide:function(all){if(all){wrapper.style.height="0px";}if(api){api.style.height="0px";}return self;},show:function(){wrapper.style.height=wrapperHeight+"px";if(api){api.style.height=swfHeight+"px";}return self;},isHidden:function(){return api&&parseInt(api.style.height,10)===0;},load:function(fn){if(!api&&self._fireEvent("onBeforeLoad")!==false){each(players,function(){this.unload();});html=wrapper.innerHTML;flashembed(wrapper,params,{config:conf});if(fn){fn.cached=true;bind(listeners,"onLoad",fn);}}return self;},unload:function(){try{if(api&&api.fp_isFullscreen()){}}catch(error){return;}if(api&&html.replace(/\s/g,'')!==''&&!api.fp_isFullscreen()&&self._fireEvent("onBeforeUnload")!==false){api.fp_close();wrapper.innerHTML=html;self._fireEvent("onUnload");api=null;}return self;},getClip:function(index){if(index===undefined){index=activeIndex;}return playlist[index];},getCommonClip:function(){return commonClip;},getPlaylist:function(){return playlist;},getPlugin:function(name){var plugin=plugins[name];if(!plugin&&self.isLoaded()){var json=self._api().fp_getPlugin(name);if(json){plugin=new Plugin(name,json,self);plugins[name]=plugin;}}return plugin;},getScreen:function(){return self.getPlugin("screen");},getControls:function(){return self.getPlugin("controls");},getConfig:function(copy){return copy?clone(conf):conf;},getFlashParams:function(){return params;},loadPlugin:function(name,url,props,fn){if(typeof props=='function'){fn=props;props={};}var fnId=fn?makeId():"_";self._api().fp_loadPlugin(name,url,props,fnId);var arg={};arg[fnId]=fn;var p=new Plugin(name,null,self,arg);plugins[name]=p;return p;},getState:function(){return api?api.fp_getState():-1;},play:function(clip){function play(){if(clip!==undefined){self._api().fp_play(clip);}else{self._api().fp_play();}}if(api){play();}else{self.load(function(){play();});}return self;},getVersion:function(){var js="flowplayer.js 3.0.3";if(api){var ver=api.fp_getVersion();ver.push(js);return ver;}return js;},_api:function(){if(!api){throw"Flowplayer "+self.id()+" not loaded. Try moving your call to player's onLoad event";}return api;},_dump:function(){console.log(listeners);},setClip:function(clip){self.setPlaylist([clip]);},getIndex:function(){return playerIndex;}});each(("Click*,Load*,Unload*,Keypress*,Volume*,Mute*,Unmute*,PlaylistReplace,Fullscreen*,FullscreenExit,Error").split(","),function(){var name="on"+this;if(name.indexOf("*")!=-1){name=name.substring(0,name.length-1);var name2="onBefore"+name.substring(2);self[name2]=function(fn){bind(listeners,name2,fn);return self;};}self[name]=function(fn){bind(listeners,name,fn);return self;};});each(("pause,resume,mute,unmute,stop,toggle,seek,getStatus,getVolume,setVolume,getTime,isPaused,isPlaying,startBuffering,stopBuffering,isFullscreen,reset,close,setPlaylist").split(","),function(){var name=this;self[name]=function(arg){if(!api){return self;}var ret=(arg===undefined)?api["fp_"+name]():api["fp_"+name](arg);return ret=='undefined'?self:ret;};});self._fireEvent=function(evt,arg0,arg1,arg2){if(conf.debug){log(arguments);}if(!api&&evt=='onLoad'&&arg0=='player'){api=api||el(apiId);swfHeight=api.clientHeight;each(playlist,function(){this._fireEvent("onLoad");});each(plugins,function(name,p){p._fireEvent("onUpdate");});commonClip._fireEvent("onLoad");}if(evt=='onLoad'&&arg0!='player'){return;}if(evt=='onError'){if(typeof arg0=='string'||(typeof arg0=='number'&&typeof arg1=='number')){arg0=arg1;arg1=arg2;}}if(evt=='onContextMenu'){each(conf.contextMenu[arg0],function(key,fn){fn.call(self);});return;}if(evt=='onPluginEvent'){var name=arg0.name||arg0;var p=plugins[name];if(p){p._fireEvent("onUpdate",arg0);p._fireEvent(arg1);}return;}if(evt=='onPlaylistReplace'){playlist=[];var index=0;each(arg0,function(){playlist.push(new Clip(this,index++,self));});}var ret=true;if(arg0===0||(arg0&&arg0>=0&&arg0<playlist.length)){activeIndex=arg0;var clip=playlist[arg0];if(clip){ret=clip._fireEvent(evt,arg1,arg2);}if(!clip||ret!==false){ret=commonClip._fireEvent(evt,arg1,arg2,clip);}}var i=0;each(listeners[evt],function(){ret=this.call(self,arg0,arg1);if(this.cached){listeners[evt].splice(i,1);}if(ret===false){return false;}i++;});return ret;};function init(){if($f(wrapper)){$f(wrapper).getParent().innerHTML="";playerIndex=$f(wrapper).getIndex();players[playerIndex]=self;}else{players.push(self);playerIndex=players.length-1;}wrapperHeight=parseInt(wrapper.style.height,10)||wrapper.clientHeight;if(typeof params=='string'){params={src:params};}playerId=wrapper.id||"fp"+makeId();apiId=params.id||playerId+"_api";params.id=apiId;conf.playerId=playerId;if(typeof conf=='string'){conf={clip:{url:conf}};}conf.clip=conf.clip||{};if(wrapper.getAttribute("href",2)&&!conf.clip.url){conf.clip.url=wrapper.getAttribute("href",2);}commonClip=new Clip(conf.clip,-1,self);conf.playlist=conf.playlist||[conf.clip];var index=0;each(conf.playlist,function(){var clip=this;if(typeof clip=='object'&&clip.length){clip=""+clip;}if(!clip.url&&typeof clip=='string'){clip={url:clip};}each(conf.clip,function(key,val){if(clip[key]===undefined&&typeof val!='function'){clip[key]=val;}});conf.playlist[index]=clip;clip=new Clip(clip,index,self);playlist.push(clip);index++;});each(conf,function(key,val){if(typeof val=='function'){bind(listeners,key,val);delete conf[key];}});each(conf.plugins,function(name,val){if(val){plugins[name]=new Plugin(name,val,self);}});if(!conf.plugins||conf.plugins.controls===undefined){plugins.controls=new Plugin("controls",null,self);}params.bgcolor=params.bgcolor||"#000000";params.version=params.version||[9,0];params.expressInstall='http://www.flowplayer.org/swf/expressinstall.swf';function doClick(e){if(!self.isLoaded()&&self._fireEvent("onBeforeClick")!==false){self.load();}return stopEvent(e);}html=wrapper.innerHTML;if(html.replace(/\s/g,'')!==''){if(wrapper.addEventListener){wrapper.addEventListener("click",doClick,false);}else if(wrapper.attachEvent){wrapper.attachEvent("onclick",doClick);}}else{if(wrapper.addEventListener){wrapper.addEventListener("click",stopEvent,false);}self.load();}}if(typeof wrapper=='string'){flashembed.domReady(function(){var node=el(wrapper);if(!node){throw"Flowplayer cannot access element: "+wrapper;}else{wrapper=node;init();}});}else{init();}}var players=[];function Iterator(arr){this.length=arr.length;this.each=function(fn){each(arr,fn);};this.size=function(){return arr.length;};}window.flowplayer=window.$f=function(){var instance=null;var arg=arguments[0];if(!arguments.length){each(players,function(){if(this.isLoaded()){instance=this;return false;}});return instance||players[0];}if(arguments.length==1){if(typeof arg=='number'){return players[arg];}else{if(arg=='*'){return new Iterator(players);}each(players,function(){if(this.id()==arg.id||this.id()==arg||this.getParent()==arg){instance=this;return false;}});return instance;}}if(arguments.length>1){var swf=arguments[1];var conf=(arguments.length==3)?arguments[2]:{};if(typeof arg=='string'){if(arg.indexOf(".")!=-1){var instances=[];each(select(arg),function(){instances.push(new Player(this,clone(swf),clone(conf)));});return new Iterator(instances);}else{var node=el(arg);return new Player(node!==null?node:arg,swf,conf);}}else if(arg){return new Player(arg,swf,conf);}}return null;};extend(window.$f,{fireEvent:function(id,evt,a0,a1,a2){var p=$f(id);return p?p._fireEvent(evt,a0,a1,a2):null;},addPlugin:function(name,fn){Player.prototype[name]=fn;return $f;},each:each,extend:extend});if(document.all){window.onbeforeunload=function(){$f("*").each(function(){if(this.isLoaded()){this.close();}});};}if(typeof jQuery=='function'){jQuery.prototype.flowplayer=function(params,conf){if(!arguments.length||typeof arguments[0]=='number'){var arr=[];this.each(function(){var p=$f(this);if(p){arr.push(p);}});return arguments.length?arr[arguments[0]]:new Iterator(arr);}return this.each(function(){$f(this,clone(params),conf?clone(conf):{});});};}})();(function(){var jQ=typeof jQuery=='function';function isDomReady(){if(domReady.done){return false;}var d=document;if(d&&d.getElementsByTagName&&d.getElementById&&d.body){clearInterval(domReady.timer);domReady.timer=null;for(var i=0;i<domReady.ready.length;i++){domReady.ready[i].call();}domReady.ready=null;domReady.done=true;}}var domReady=jQ?jQuery:function(f){if(domReady.done){return f();}if(domReady.timer){domReady.ready.push(f);}else{domReady.ready=[f];domReady.timer=setInterval(isDomReady,13);}};function extend(to,from){if(from){for(key in from){if(from.hasOwnProperty(key)){to[key]=from[key];}}}return to;}function concatVars(vars){var out="";for(var key in vars){if(vars[key]){out+=[key]+'='+asString(vars[key])+'&';}}return out.substring(0,out.length-1);}function asString(obj){switch(typeOf(obj)){case'string':obj=obj.replace(new RegExp('(["\\\\])','g'),'\\$1');obj=obj.replace(/^\s?(\d+)%/,"$1pct");return'"'+obj+'"';case'array':return'['+map(obj,function(el){return asString(el);}).join(',')+']';case'function':return'"function()"';case'object':var str=[];for(var prop in obj){if(obj.hasOwnProperty(prop)){str.push('"'+prop+'":'+asString(obj[prop]));}}return'{'+str.join(',')+'}';}return String(obj).replace(/\s/g," ").replace(/\'/g,"\"");}function typeOf(obj){if(obj===null||obj===undefined){return false;}var type=typeof obj;return(type=='object'&&obj.push)?'array':type;}if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};});}function map(arr,func){var newArr=[];for(var i in arr){if(arr.hasOwnProperty(i)){newArr[i]=func(arr[i]);}}return newArr;}function getEmbedCode(p,c){var html='<embed type="application/x-shockwave-flash" ';if(p.id){extend(p,{name:p.id});}for(var key in p){if(p[key]!==null){html+=key+'="'+p[key]+'"\n\t';}}if(c){html+='flashvars=\''+concatVars(c)+'\'';}html+='/>';return html;}function getObjectCode(p,c,embeddable){var html='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';html+='width="'+p.width+'" height="'+p.height+'"';if(!p.id&&document.all){p.id="_"+(""+Math.random()).substring(5);}if(p.id){html+=' id="'+p.id+'"';}html+='>';if(document.all){p.src+=((p.src.indexOf("?")!=-1?"&":"?")+Math.random());}html+='\n\t<param name="movie" value="'+p.src+'" />';var e=extend({},p);e.id=e.width=e.height=e.src=null;for(var k in e){if(e[k]!==null){html+='\n\t<param name="'+k+'" value="'+e[k]+'" />';}}if(c){html+='\n\t<param name="flashvars" value=\''+concatVars(c)+'\' />';}if(embeddable){html+=getEmbedCode(p,c);}html+="</object>";return html;}function getFullHTML(p,c){return getObjectCode(p,c,true);}function getHTML(p,c){var isNav=navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length;return(isNav)?getEmbedCode(p,c):getObjectCode(p,c);}window.flashembed=function(root,userParams,flashvars){var params={src:'#',width:'100%',height:'100%',version:null,onFail:null,expressInstall:null,debug:false,allowfullscreen:true,allowscriptaccess:'always',quality:'high',type:'application/x-shockwave-flash',pluginspage:'http://www.adobe.com/go/getflashplayer'};if(typeof userParams=='string'){userParams={src:userParams};}extend(params,userParams);var version=flashembed.getVersion();var required=params.version;var express=params.expressInstall;var debug=params.debug;if(typeof root=='string'){var el=document.getElementById(root);if(el){root=el;}else{domReady(function(){flashembed(root,userParams,flashvars);});return;}}if(!root){return;}if(!required||flashembed.isSupported(required)){params.onFail=params.version=params.expressInstall=params.debug=null;root.innerHTML=getHTML(params,flashvars);return root.firstChild;}else if(params.onFail){var ret=params.onFail.call(params,flashembed.getVersion(),flashvars);if(ret===true){root.innerHTML=ret;}}else if(required&&express&&flashembed.isSupported([6,65])){extend(params,{src:express});flashvars={MMredirectURL:location.href,MMplayerType:'PlugIn',MMdoctitle:document.title};root.innerHTML=getHTML(params,flashvars);}else{if(root.innerHTML.replace(/\s/g,'')!==''){}else{root.innerHTML="<h2>Flash version "+required+" or greater is required</h2>"+"<h3>"+(version[0]>0?"Your version is "+version:"You have no flash plugin installed")+"</h3>"+"<p>Download latest version from <a href='"+params.pluginspage+"'>here</a></p>";}}return root;};extend(window.flashembed,{getVersion:function(){var version=[0,0];if(navigator.plugins&&typeof navigator.plugins["Shockwave Flash"]=="object"){var _d=navigator.plugins["Shockwave Flash"].description;if(typeof _d!="undefined"){_d=_d.replace(/^.*\s+(\S+\s+\S+$)/,"$1");var _m=parseInt(_d.replace(/^(.*)\..*$/,"$1"),10);var _r=/r/.test(_d)?parseInt(_d.replace(/^.*r(.*)$/,"$1"),10):0;version=[_m,_r];}}else if(window.ActiveXObject){try{var _a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{_a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");version=[6,0];_a.AllowScriptAccess="always";}catch(ee){if(version[0]==6){return;}}try{_a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(eee){}}if(typeof _a=="object"){_d=_a.GetVariable("$version");if(typeof _d!="undefined"){_d=_d.replace(/^\S+\s+(.*)$/,"$1").split(",");version=[parseInt(_d[0],10),parseInt(_d[2],10)];}}}return version;},isSupported:function(version){var now=flashembed.getVersion();var ret=(now[0]>version[0])||(now[0]==version[0]&&now[1]>=version[1]);return ret;},domReady:domReady,asString:asString,getHTML:getHTML,getFullHTML:getFullHTML});if(jQ){jQuery.prototype.flashembed=function(params,flashvars){return this.each(function(){flashembed(this,params,flashvars);});};}})();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
flowplayer/flowplayer.swf CHANGED
Binary file
flowplayer/fv-flowplayer.min.js ADDED
@@ -0,0 +1,341 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+
3
+ Flowplayer Unlimited v5.4.6 (2013-12-17) | flowplayer.org/license
4
+
5
+ */!function(e){function u(t,n){var r="obj"+(""+Math.random()).slice(2,15),i='<object class="fp-engine" id="'+r+'" name="'+r+'" ';i+=e.browser.msie?'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">':' data="'+t+'" type="application/x-shockwave-flash">';var s={width:"100%",height:"100%",allowscriptaccess:"always",wmode:"transparent",quality:"high",flashvars:"",movie:t+(e.browser.msie?"?"+r:""),name:r};return e.each(n,function(e,t){s.flashvars+=e+"="+t+"&"}),e.each(s,function(e,t){i+='<param name="'+e+'" value="'+t+'"/>'}),i+="</object>",e(i)}function l(e,t){return t=t||100,Math.round(e*t)/t}function c(e){return/mpegurl/i.test(e)?"application/x-mpegurl":"video/"+e}function h(e){return/^(video|application)/.test(e)||(e=c(e)),!!a.canPlayType(e).replace("no","")}function p(t,n){var r=e.grep(t,function(e){return e.type===n});return r.length?r[0]:null}function g(e){var t=e.attr("src"),n=e.attr("type")||"",r=t.split(m)[1];return n=/mpegurl/.test(n)?"mpegurl":n.replace("video/",""),{src:t,suffix:r||n,type:n||r}}function y(t){var n=this,r=[];e("source",t).each(function(){r.push(g(e(this)))}),r.length||r.push(g(t)),n.initialSources=r,n.resolve=function(t){return t?(e.isArray(t)?t={sources:e.map(t,function(t){var n,r=e.extend({},t);return e.each(t,function(e,t){n=e}),r.type=n,r.src=t[n],delete r[n],r})}:typeof t=="string"&&(t={src:t,sources:[]},e.each(r,function(e,n){n.type!="flash"&&t.sources.push({type:n.type,src:t.src.replace(m,"."+n.suffix+"$2")})})),t):{sources:r}}}function b(e){return e=parseInt(e,10),e>=10?e:"0"+e}function w(e){e=e||0;var t=Math.floor(e/3600),n=Math.floor(e/60);return e-=n*60,t>=1?(n-=t*60,t+":"+b(n)+":"+b(e)):b(n)+":"+b(e)}!function(e){if(!e.browser){var t=e.browser={},n=navigator.userAgent.toLowerCase(),r=/(chrome)[ \/]([\w.]+)/.exec(n)||/(safari)[ \/]([\w.]+)/.exec(n)||/(webkit)[ \/]([\w.]+)/.exec(n)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(n)||/(msie) ([\w.]+)/.exec(n)||n.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(n)||[];r[1]&&(t[r[1]]=!0,t.version=r[2]||"0")}}(jQuery),e(function(){typeof e.fn.flowplayer=="function"&&e("video").parent(".flowplayer").flowplayer()});var t=[],n=[],r=window.navigator.userAgent;window.flowplayer=function(r){return e.isFunction(r)?n.push(r):typeof r=="number"||r===undefined?t[r||0]:e(r).data("flowplayer")},e(window).on("beforeunload",function(){e.each(t,function(t,n){n.conf.splash?n.unload():n.bind("error",function(){e(".flowplayer.is-error .fp-message").remove()})})});var i=!1;try{typeof window.localStorage=="object"&&(window.localStorage.flowplayerTestStorage="test",i=!0)}catch(s){}e.extend(flowplayer,{version:"5.4.6",engine:{},conf:{},support:{},defaults:{debug:!1,disabled:!1,engine:"html5",fullscreen:window==window.top,keyboard:!0,ratio:9/16,adaptiveRatio:!1,flashfit:!1,rtmp:0,splash:!1,live:!1,swf:"//releases.flowplayer.org/5.4.6/commercial/flowplayer.swf",speeds:[.25,.5,1,1.5,2],tooltip:!0,volume:i?localStorage.muted=="true"?0:isNaN(localStorage.volume)?1:localStorage.volume||1:1,errors:["","Video loading aborted","Network error","Video not properly encoded","Video file not found","Unsupported video","Skin not found","SWF file not found","Subtitles not found","Invalid RTMP URL","Unsupported video format. Try installing Adobe Flash."],errorUrls:["","","","","","","","","","","http://get.adobe.com/flashplayer/"],playlist:[]}});var o=1;e.fn.flowplayer=function(r,i){return typeof r=="string"&&(r={swf:r}),e.isFunction(r)&&(i=r,r={}),!r&&this.data("flowplayer")||this.each(function(){var s=e(this).addClass("is-loading"),u=e.extend({},flowplayer.defaults,flowplayer.conf,r,s.data()),a=e("video",s).addClass("fp-engine").removeAttr("controls"),f=a.length?new y(a):null,l={},c,h;if(u.playlist.length){var p=a.attr("preload"),d;a.length&&a.replaceWith(d=e("<p />")),a=e("<video />").addClass("fp-engine"),d?d.replaceWith(a):s.prepend(a),flowplayer.support.video&&a.attr("preload",p),typeof u.playlist[0]=="string"?a.attr("src",u.playlist[0]):e.each(u.playlist[0],function(t,n){for(var r in n)n.hasOwnProperty(r)&&a.append(e("<source />").attr({type:"video/"+r,src:n[r]}))}),f=new y(a)}var v=s.data("flowplayer");v&&v.unload(),s.data("fp-player_id",s.data("fp-player_id")||o++);try{l=window.localStorage||l}catch(m){}var g=this.currentStyle&&this.currentStyle.direction==="rtl"||window.getComputedStyle&&window.getComputedStyle(this,null).getPropertyValue("direction")==="rtl";g&&s.addClass("is-rtl");var b=v||{conf:u,currentSpeed:1,volumeLevel:typeof u.volume=="undefined"?l.volume*1:u.volume,video:{},disabled:!1,finished:!1,loading:!1,muted:l.muted=="true"||u.muted,paused:!1,playing:!1,ready:!1,splash:!1,rtl:g,load:function(t,n){if(b.error||b.loading||b.disabled)return;t=f.resolve(t),e.extend(t,h.pick(t.sources));if(t.src){var r=e.Event("load");s.trigger(r,[b,t,h]),r.isDefaultPrevented()?b.loading=!1:(h.load(t),e.isFunction(t)&&(n=t),n&&s.one("ready",n))}return b},pause:function(e){return b.ready&&!b.seeking&&!b.disabled&&!b.loading&&(h.pause(),b.one("pause",e)),b},resume:function(){return b.ready&&b.paused&&!b.disabled&&(h.resume(),b.finished&&(b.trigger("resume",[b]),b.finished=!1)),b},toggle:function(){return b.ready?b.paused?b.resume():b.pause():b.load()},seek:function(t,n){if(b.ready){if(typeof t=="boolean"){var r=b.video.duration*.1;t=b.video.time+(t?r:-r)}t=c=Math.min(Math.max(t,0),b.video.duration).toFixed(1);var i=e.Event("beforeseek");s.trigger(i,[b,t]),i.isDefaultPrevented()?(b.seeking=!1,s.toggleClass("is-seeking",b.seeking)):(h.seek(t),e.isFunction(n)&&s.one("seek",n))}return b},seekTo:function(e,t){var n=e===undefined?c:b.video.duration*.1*e;return b.seek(n,t)},mute:function(e){return e===undefined&&(e=!b.muted),l.muted=b.muted=e,l.volume=isNaN(l.volume)?u.volume:l.volume,b.volume(e?0:l.volume,!0),b.trigger("mute",e),b},volume:function(e,t){return b.ready&&(e=Math.min(Math.max(e,0),1),t||(l.volume=e),h.volume(e)),b},speed:function(t,n){return b.ready&&(typeof t=="boolean"&&(t=u.speeds[e.inArray(b.currentSpeed,u.speeds)+(t?1:-1)]||b.currentSpeed),h.speed(t),n&&s.one("speed",n)),b},stop:function(){return b.ready&&(b.pause(),b.seek(0,function(){s.trigger("stop")})),b},unload:function(){return s.hasClass("is-embedding")||(u.splash?(b.trigger("unload"),h.unload()):b.stop()),b},disable:function(e){return e===undefined&&(e=!b.disabled),e!=b.disabled&&(b.disabled=e,b.trigger("disable",e)),b}};b.conf=e.extend(b.conf,u),e.each(["bind","one","unbind"],function(e,t){b[t]=function(e,n){return s[t](e,n),b}}),b.trigger=function(e,t){return s.trigger(e,[b,t]),b},s.data("flowplayer")||s.bind("boot",function(){e.each(["autoplay","loop","preload","poster"],function(e,t){var n=a.attr(t);n!==undefined&&(u[t]=n?n:!0)});if(u.splash||s.hasClass("is-splash")||!flowplayer.support.firstframe)b.forcedSplash=!u.splash&&!s.hasClass("is-splash"),b.splash=u.splash=u.autoplay=!0,s.addClass("is-splash"),flowplayer.support.video&&a.attr("preload","none");if(u.live||s.hasClass("is-live"))b.live=u.live=!0,s.addClass("is-live");e.each(n,function(e){this(b,s)}),h=flowplayer.engine[u.engine],h&&(h=h(b,s)),h.pick(f.initialSources)?b.engine=u.engine:e.each(flowplayer.engine,function(e,t){if(e!=u.engine)return h=this(b,s),h.pick(f.initialSources)&&(b.engine=e),!1}),t.push(b);if(!b.engine)return b.trigger("error",{code:flowplayer.support.flashVideo?5:10});u.splash?b.unload():b.load(),u.disabled&&b.disable(),h.volume(b.volumeLevel),s.one("ready",i)}).bind("load",function(t,n,r){u.splash&&e(".flowplayer").filter(".is-ready, .is-loading").not(s).each(function(){var t=e(this).data("flowplayer");t.conf.splash&&t.unload()}),s.addClass("is-loading"),n.loading=!0}).bind("ready",function(e,t,n){function r(){s.removeClass("is-loading"),t.loading=!1}n.time=0,t.video=n,u.splash?s.one("progress",r):r(),t.muted?t.mute(!0):t.volume(t.volumeLevel)}).bind("unload",function(e){u.splash&&a.remove(),s.removeClass("is-loading"),b.loading=!1}).bind("ready unload",function(e){var t=e.type=="ready";s.toggleClass("is-splash",!t).toggleClass("is-ready",t),b.ready=t,b.splash=!t}).bind("progress",function(e,t,n){t.video.time=n}).bind("speed",function(e,t,n){t.currentSpeed=n}).bind("volume",function(e,t,n){t.volumeLevel=Math.round(n*100)/100,t.muted?n&&t.mute(!1):l.volume=n}).bind("beforeseek seek",function(e){b.seeking=e.type=="beforeseek",s.toggleClass("is-seeking",b.seeking)}).bind("ready pause resume unload finish stop",function(e,t,n){b.paused=/pause|finish|unload|stop/.test(e.type),e.type=="ready"&&(b.paused=u.preload=="none",n&&(b.paused=!n.duration||!u.autoplay&&u.preload!="none")),b.playing=!b.paused,s.toggleClass("is-paused",b.paused).toggleClass("is-playing",b.playing),b.load.ed||b.pause()}).bind("finish",function(e){b.finished=!0}).bind("error",function(){a.remove()}),s.trigger("boot",[b,s]).data("flowplayer",b)})},!function(){var t=function(e){var t=/Version\/(\d\.\d)/.exec(e);return t&&t.length>1?parseFloat(t[1],10):0},n=flowplayer.support,r=e.browser,i=e("<video loop autoplay preload/>")[0],s=r.msie,o=navigator.userAgent,u=/iPad|MeeGo/.test(o)&&!/CriOS/.test(o),a=/iPad/.test(o)&&/CriOS/.test(o),f=/iP(hone|od)/i.test(o)&&!/iPad/.test(o),l=/Android/.test(o)&&!/Firefox/.test(o),c=/Android/.test(o)&&/Firefox/.test(o),h=/Silk/.test(o),p=/IEMobile/.test(o),d=u?t(o):0,v=l?parseFloat(/Android\ (\d\.\d)/.exec(o)[1],10):0;e.extend(n,{subtitles:!!i.addTextTrack,fullscreen:!l&&(typeof document.webkitCancelFullScreen=="function"&&!/Mac OS X 10_5.+Version\/5\.0\.\d Safari/.test(o)||document.mozFullScreenEnabled||typeof document.exitFullscreen=="function"),inlineBlock:!(s&&r.version<8),touch:"ontouchstart"in window,dataload:!u&&!f&&!p,zeropreload:!s&&!l,volume:!u&&!l&&!f&&!h&&!a,cachedVideoTag:!u&&!f&&!a&&!p,firstframe:!f&&!u&&!l&&!h&&!a&&!p&&!c,inlineVideo:!f&&!p&&(!l||v>=3),hlsDuration:!r.safari||u||f||a,seekable:!u&&!a});try{var m=navigator.plugins["Shockwave Flash"],g=s?(new ActiveXObject("ShockwaveFlash.ShockwaveFlash")).GetVariable("$version"):m.description;!s&&!m[0].enabledPlugin?n.flashVideo=!1:(g=g.split(/\D+/),g.length&&!g[0]&&(g=g.slice(1)),n.flashVideo=g[0]>9||g[0]==9&&g[3]>=115)}catch(y){}try{n.video=!!i.canPlayType,n.video&&i.canPlayType("video/mp4")}catch(b){n.video=!1}n.animation=function(){var t=["","Webkit","Moz","O","ms","Khtml"],n=e("<p/>")[0];for(var r=0;r<t.length;r++)if(n.style[t[r]+"AnimationName"]!=="undefined")return!0}()}(),window.attachEvent&&window.attachEvent("onbeforeunload",function(){__flash_savedUnloadHandler=__flash_unloadHandler=function(){}}),flowplayer.engine.flash=function(t,n){var r=t.conf,i=t.video,s,o,a,f={pick:function(t){if(flowplayer.support.flashVideo){var n=e.grep(t,function(e){return e.type=="flash"})[0];if(n)return n;for(var r=0,i;r<t.length;r++){i=t[r];if(/mp4|flv/.test(i.type))return i}}},load:function(i){function f(e){return e.replace(/&amp;/g,"%26").replace(/&/g,"%26").replace(/=/g,"%3D")}var l=e("video",n),c=f(i.src);is_absolute=/^https?:/.test(c);try{l.length>0&&flowplayer.support.video&&l[0].pause()}catch(h){}var p=function(){l.remove()},d=function(t){return e.grep(t,function(e){return!!l[0].canPlayType("video/"+e.type)}).length>0};flowplayer.support.video&&l.prop("autoplay")&&d(i.sources)?l.one("timeupdate",p):p(),!is_absolute&&!r.rtmp&&(c=e("<img/>").attr("src",c)[0].src);if(a)a.__play(c);else{s="fp"+(""+Math.random()).slice(3,15);var v={hostname:r.embedded?r.hostname:location.hostname,url:c,callback:"jQuery."+s};n.data("origin")&&(v.origin=n.data("origin")),is_absolute&&delete r.rtmp,e.each(["key","autoplay","preload","rtmp","loop","debug","preload","splash","bufferTime"],function(e,t){r[t]&&(v[t]=r[t])}),v.rtmp&&(v.rtmp=f(v.rtmp)),o=u(r.swf,v),o.prependTo(n),a=o[0],setTimeout(function(){try{if(!a.PercentLoaded())return n.trigger("error",[t,{code:7,url:r.swf}])}catch(e){}},5e3),setTimeout(function(){typeof a.PercentLoaded=="undefined"&&n.trigger("flashdisabled",[t])},1e3),e[s]=function(n,s){r.debug&&n!="status"&&console.log("--",n,s);var o=e.Event(n);switch(n){case"ready":s=e.extend(i,s);break;case"click":o.flash=!0;break;case"keydown":o.which=s;break;case"seek":i.time=s;break;case"status":t.trigger("progress",s.time),s.buffer<i.bytes&&!i.buffered?(i.buffer=s.buffer/i.bytes*i.duration,t.trigger("buffer",i.buffer)):i.buffered||(i.buffered=!0,t.trigger("buffered"))}n!="buffered"&&setTimeout(function(){t.trigger(o,s)},1)}}},speed:e.noop,unload:function(){a&&a.__unload&&a.__unload(),delete e[s],e("object",n).remove(),a=0}};e.each("pause,resume,seek,volume".split(","),function(e,r){f[r]=function(e){try{t.ready&&(r=="seek"&&t.video.time&&!t.paused&&t.trigger("beforeseek"),e===undefined?a["__"+r]():a["__"+r](e))}catch(i){if(typeof a["__"+r]=="undefined")return n.trigger("flashdisabled",[t]);throw i}}});var l=e(window);return t.bind("ready fullscreen fullscreen-exit",function(r){var i=n.height(),s=n.width();if(t.conf.flashfit||/full/.test(r.type)){var o=t.isFullscreen,u=o&&L,a=!flowplayer.support.inlineBlock,f=o?u?screen.width:l.width():s,c=o?u?screen.height:l.height():i,h=0,p=0,d=a?s:"",v=a?i:"",m,g;if(t.conf.flashfit||r.type==="fullscreen")m=t.video.width/t.video.height,g=t.video.height/t.video.width,v=Math.max(g*f),d=Math.max(m*c),v=v>c?d*g:v,v=Math.min(Math.round(v),c),d=d>f?v*m:d,d=Math.min(Math.round(d),f),p=Math.max(Math.round((c+p-v)/2),0),h=Math.max(Math.round((f+h-d)/2),0);e("object",n).css({width:d,height:v,marginTop:p,marginLeft:h})}}),f};var a=e("<video/>")[0],f={ended:"finish",pause:"pause",play:"resume",progress:"buffer",timeupdate:"progress",volumechange:"volume",ratechange:"speed",seeked:"seek",loadeddata:"ready",error:"error",dataunavailable:"error"},d,v=function(t){return d?d.attr({type:c(t.type),src:t.src}):d=e("<video/>",{src:t.src,type:c(t.type),"class":"fp-engine",autoplay:"autoplay",preload:"none","x-webkit-airplay":"allow"})};flowplayer.engine.html5=function(t,n){function m(r,s,u){if(r.listeners&&r.listeners.hasOwnProperty(n.data("fp-player_id")))return;(r.listeners||(r.listeners={}))[n.data("fp-player_id")]=!0,s.bind("error",function(n){try{if(n.originalEvent&&e(n.originalEvent.originalTarget).is("img"))return n.preventDefault();h(e(n.target).attr("type"))&&t.trigger("error",{code:4})}catch(r){}}),e.each(f,function(s,f){r.addEventListener(s,function(c){f=="progress"&&c.srcElement&&c.srcElement.readyState===0&&setTimeout(function(){t.video.duration||(f="error",t.trigger(f,{code:4}))},1e4),o.debug&&!/progress/.test(f)&&console.log(s,"->",f,c);if(!t.ready&&!/ready|error/.test(f)||!f||!e("video",n).length)return;var h=e.Event(f),p;switch(f){case"ready":p=e.extend(u,{duration:r.duration,width:r.videoWidth,height:r.videoHeight,url:r.currentSrc,src:r.currentSrc});try{p.seekable=r.seekable&&r.seekable.end(null)}catch(d){}a=a||setInterval(function(){try{p.buffer=r.buffered.end(null)}catch(e){}p.buffer&&(l(p.buffer,1e3)<l(p.duration,1e3)&&!p.buffered?t.trigger("buffer",c):p.buffered||(p.buffered=!0,t.trigger("buffer",c).trigger("buffered",c),clearInterval(a),a=0))},250);if(!o.live&&!p.duration&&!i.hlsDuration&&s==="loadeddata"){var v=function(){p.duration=r.duration;try{p.seekable=r.seekable&&r.seekable.end(null)}catch(e){}t.trigger(h,p),r.removeEventListener("durationchange",v)};r.addEventListener("durationchange",v);return}break;case"progress":case"seek":var m=t.video.duration;if(r.currentTime>0){p=Math.max(r.currentTime,0);break}if(f=="progress")return;case"speed":p=l(r.playbackRate);break;case"volume":p=l(r.volume);break;case"error":try{p=(c.srcElement||c.originalTarget).error}catch(g){return}}t.trigger(h,p)},!1)})}var r=e("video",n),i=flowplayer.support,s=e("track",r),o=t.conf,u,a,c;return u={pick:function(e){if(i.video){if(o.videoTypePreference){var t=p(e,o.videoTypePreference);if(t)return t}for(var n=0,r;n<e.length;n++)if(h(e[n].type))return e[n]}},load:function(u){if(o.splash&&!c)r=v(u).prependTo(n),i.inlineVideo||r.css({position:"absolute",top:"-9999em"}),s.length&&r.append(s.attr("default","")),o.loop&&r.attr("loop","loop"),c=r[0];else{c=r[0];var a=r.find("source");!c.src&&a.length&&(c.src=u.src,a.remove());if(t.video.src&&u.src!=t.video.src)r.attr("autoplay","autoplay"),c.src=u.src;else if(o.preload=="none"||!i.dataload)i.zeropreload?t.trigger("ready",u).trigger("pause").one("ready",function(){n.trigger("resume",[t])}):t.one("ready",function(){n.trigger("pause",[t])})}m(c,e("source",r).add(r),u),(o.preload!="none"||!i.zeropreload||!i.dataload)&&c.load(),o.splash&&c.load()},pause:function(){c.pause()},resume:function(){c.play()},speed:function(e){c.playbackRate=e},seek:function(e){try{var n=t.paused;c.currentTime=e,n&&c.pause()}catch(r){}},volume:function(e){c.volume=e},unload:function(){e("video.fp-engine",n).remove(),i.cachedVideoTag||(d=null),a=clearInterval(a),c=0}}};var m=/\.(\w{3,4})(\?.*)?$/i;e.throttle=function(e,t){var n;return function(){n||(e.apply(this,arguments),n=1,setTimeout(function(){n=0},t))}},e.fn.slider2=function(t){var n=/iPad/.test(navigator.userAgent)&&!/CriOS/.test(navigator.userAgent);return this.each(function(){var r=e(this),i=e(document),s=r.children(":last"),o,u,a,f,l,c,h,p,d=!1,v=function(){u=r.offset(),a=r.width(),f=r.height(),c=l?f:a,p=b(h)},m=function(e){!o&&e!=w.value&&(!h||e<h)&&(r.trigger("slide",[e]),w.value=e)},g=function(e){var n=e.pageX;!n&&e.originalEvent&&e.originalEvent.touches&&e.originalEvent.touches.length&&(n=e.originalEvent.touches[0].pageX);var r=l?e.pageY-u.top:n-u.left;r=Math.max(0,Math.min(p||c,r));var i=r/c;return l&&(i=1-i),t&&(i=1-i),y(i,0,!0)},y=function(e,t){t===undefined&&(t=0),e>1&&(e=1);var r=Math.round(e*1e3)/10+"%";if(!h||e<=h)n||s.stop(),d?s.css("width",r):s.animate(l?{height:r}:{width:r},t,"linear");return e},b=function(e){return Math.max(0,Math.min(c,l?(1-e)*f:e*a))},w={max:function(e){h=e},disable:function(e){o=e},slide:function(e,t,n){v(),n&&m(e),y(e,t)},disableAnimation:function(e){d=e!==!1}};v(),r.data("api",w).bind("mousedown.sld touchstart",function(t){t.preventDefault();if(!o){var n=e.throttle(m,100);v(),w.dragging=!0,r.addClass("is-dragging"),m(g(t)),i.bind("mousemove.sld touchmove",function(e){e.preventDefault(),n(g(e))}).one("mouseup touchend",function(){w.dragging=!1,r.removeClass("is-dragging"),i.unbind("mousemove.sld touchmove")})}})})},flowplayer(function(t,n){function o(t){return e(".fp-"+t,n)}function T(t){if(n.css("width")==="0px"||n.css("height")==="0px"||t!==flowplayer.defaults.ratio)parseInt(v,10)||h.css("paddingTop",t*100+"%");i.inlineBlock||e("object",n).height(n.height())}function N(e){n.toggleClass("is-mouseover",e).toggleClass("is-mouseout",!e)}var r=t.conf,i=flowplayer.support,s;n.find(".fp-ratio,.fp-ui").remove(),n.addClass("flowplayer").append(' <div class="ratio"/> <div class="ui"> <div class="waiting"><em/><em/><em/></div> <a class="fullscreen"/> <a class="unload"/> <p class="speed"/> <div class="controls"> <a class="play"></a> <div class="timeline"> <div class="buffer"/> <div class="progress"/> </div> <div class="volume"> <a class="mute"></a> <div class="volumeslider"> <div class="volumelevel"/> </div> </div> </div> <div class="time"> <em class="elapsed">00:00</em> <em class="remaining"/> <em class="duration">00:00</em> </div> <div class="message"><h2/><p/></div> </div>'.replace(/class="/g,'class="fp-'));var u=o("progress"),a=o("buffer"),f=o("elapsed"),l=o("remaining"),c=o("waiting"),h=o("ratio"),p=o("speed"),d=o("duration"),v=h.css("paddingTop"),m=o("timeline").slider2(t.rtl),g=m.data("api"),y=o("volume"),b=o("fullscreen"),E=o("volumeslider").slider2(t.rtl),S=E.data("api"),x=n.is(".fixed-controls, .no-toggle");g.disableAnimation(n.hasClass("is-touch")),i.animation||c.html("<p>loading &hellip;</p>"),T(r.ratio);try{r.fullscreen||b.remove()}catch(C){b.remove()}t.bind("ready",function(){var e=t.video.duration;g.disable(t.disabled||!e),r.adaptiveRatio&&T(t.video.height/t.video.width),d.add(l).html(w(e)),e>=3600&&n.addClass("is-long")||n.removeClass("is-long"),S.slide(t.volumeLevel)}).bind("unload",function(){v||h.css("paddingTop","")}).bind("buffer",function(){var e=t.video,n=e.buffer/e.duration;!e.seekable&&i.seekable&&g.max(n),n<1?a.css("width",n*100+"%"):a.css({width:"100%"})}).bind("speed",function(e,t,n){p.text(n+"x").addClass("fp-hilite"),setTimeout(function(){p.removeClass("fp-hilite")},1e3)}).bind("buffered",function(){a.css({width:"100%"}),g.max(1)}).bind("progress",function(){var e=t.video.time,n=t.video.duration;g.dragging||g.slide(e/n,t.seeking?0:250),f.html(w(e)),l.html("-"+w(n-e))}).bind("finish resume seek",function(e){n.toggleClass("is-finished",e.type=="finish")}).bind("stop",function(){f.html(w(0)),g.slide(0,100)}).bind("finish",function(){f.html(w(t.video.duration)),g.slide(1,100),n.removeClass("is-seeking")}).bind("beforeseek",function(){u.stop()}).bind("volume",function(){S.slide(t.volumeLevel)}).bind("disable",function(){var e=t.disabled;g.disable(e),S.disable(e),n.toggleClass("is-disabled",t.disabled)}).bind("mute",function(e,t,r){n.toggleClass("is-muted",r)}).bind("error",function(t,i,s){n.removeClass("is-loading").addClass("is-error");if(s){s.message=r.errors[s.code],i.error=!0;var o=e(".fp-message",n);e("h2",o).text((i.engine||"html5")+": "+s.message),e("p",o).text(s.url||i.video.url||i.video.src||r.errorUrls[s.code]),n.unbind("mouseenter click").removeClass("is-mouseover")}}).bind("mouseenter mouseleave",function(e){if(x)return;var t=e.type=="mouseenter",r;N(t),t?(n.bind("pause.x mousemove.x volume.x",function(){N(!0),r=new Date}),s=setInterval(function(){new Date-r>2e3&&(N(!1),r=new Date)},100)):(n.unbind(".x"),clearInterval(s))}).bind("mouseleave",function(){(g.dragging||S.dragging)&&n.addClass("is-mouseover").removeClass("is-mouseout")}).bind("click.player",function(n){if(e(n.target).is(".fp-ui, .fp-engine")||n.flash)return n.preventDefault(),t.toggle()}).bind("contextmenu",function(t){t.preventDefault();var r=n.offset(),i=e(window),s=t.clientX-r.left,o=t.clientY-r.top+i.scrollTop(),u=n.find(".fp-context-menu").css({left:s+"px",top:o+"px",display:"block"}).on("click",function(e){e.stopPropagation()});e("html").on("click.outsidemenu",function(t){u.hide(),e("html").off("click.outsidemenu")})}).bind("flashdisabled",function(){n.addClass("is-flash-disabled").one("ready",function(){n.removeClass("is-flash-disabled").find(".fp-flash-disabled").remove()}).append('<div class="fp-flash-disabled">Adobe Flash is disabled for this page, click player area to enable.</div>')}),r.poster&&n.css("backgroundImage","url("+r.poster+")");var k=n.css("backgroundColor"),L=n.css("backgroundImage")!="none"||k&&k!="rgba(0, 0, 0, 0)"&&k!="transparent";L&&!r.splash&&!r.autoplay&&t.bind("ready stop",function(){n.addClass("is-poster").one("progress",function(){n.removeClass("is-poster")})}),!L&&t.forcedSplash&&n.css("backgroundColor","#555"),e(".fp-toggle, .fp-play",n).click(t.toggle),e.each(["mute","fullscreen","unload"],function(e,n){o(n).click(function(){t[n]()})}),m.bind("slide",function(e,n){t.seeking=!0,t.seek(n*t.video.duration)}),E.bind("slide",function(e,n){t.volume(n)}),o("time").click(function(t){e(this).toggleClass("is-inverted")}),N(x)});var E,S,x="is-help";e(document).bind("keydown.fp",function(t){var n=E,r=t.ctrlKey||t.metaKey||t.altKey,i=t.which,s=n&&n.conf;if(!n||!s.keyboard||n.disabled)return;if(e.inArray(i,[63,187,191])!=-1)return S.toggleClass(x),!1;if(i==27&&S.hasClass(x))return S.toggleClass(x),!1;if(!r&&n.ready){t.preventDefault();if(t.shiftKey){i==39?n.speed(!0):i==37&&n.speed(!1);return}if(i<58&&i>47)return n.seekTo(i-48);switch(i){case 38:case 75:n.volume(n.volumeLevel+.15);break;case 40:case 74:n.volume(n.volumeLevel-.15);break;case 39:case 76:n.seeking=!0,n.seek(!0);break;case 37:case 72:n.seeking=!0,n.seek(!1);break;case 190:n.seekTo();break;case 32:n.toggle();break;case 70:s.fullscreen&&n.fullscreen();break;case 77:n.mute();break;case 81:n.unload()}}}),flowplayer(function(t,n){if(!t.conf.keyboard)return;n.bind("mouseenter mouseleave",function(e){E=!t.disabled&&e.type=="mouseenter"?t:0,E&&(S=n)}),n.append(' <div class="fp-help"> <a class="fp-close"></a> <div class="fp-help-section fp-help-basics"> <p><em>space</em>play / pause</p> <p><em>q</em>unload | stop</p> <p><em>f</em>fullscreen</p> <p><em>shift</em> + <em>&#8592;</em><em>&#8594;</em>slower / faster <small>(latest Chrome and Safari)</small></p> </div> <div class="fp-help-section"> <p><em>&#8593;</em><em>&#8595;</em>volume</p> <p><em>m</em>mute</p> </div> <div class="fp-help-section"> <p><em>&#8592;</em><em>&#8594;</em>seek</p> <p><em>&nbsp;. </em>seek to previous </p><p><em>1</em><em>2</em>&hellip;<em>6</em> seek to 10%, 20%, &hellip;60% </p> </div> </div> '),t.conf.tooltip&&e(".fp-ui",n).attr("title","Hit ? for help").on("mouseout.tip",function(){e(this).removeAttr("title").off("mouseout.tip")}),e(".fp-close",n).click(function(){n.toggleClass(x)})});var T=e.browser.mozilla?"moz":"webkit",N="fullscreen",C="fullscreen-exit",k,L=flowplayer.support.fullscreen,A=typeof document.exitFullscreen=="function",O=navigator.userAgent.toLowerCase(),M=/(safari)[ \/]([\w.]+)/.exec(O)&&!/(chrome)[ \/]([\w.]+)/.exec(O);e(document).bind(A?"fullscreenchange":T+"fullscreenchange",function(t){var n=e(document.webkitCurrentFullScreenElement||document.mozFullScreenElement||document.fullscreenElement||t.target);n.length&&!k?k=n.trigger(N,[n]):(k.trigger(C,[k]),k=null)}),flowplayer(function(t,n){if(!t.conf.fullscreen)return;var r=e(window),i={index:0,pos:0,play:!1},s;t.isFullscreen=!1,t.fullscreen=function(o){if(t.disabled)return;return o===undefined&&(o=!t.isFullscreen),o&&(s=r.scrollTop()),(T=="webkit"||M)&&t.engine=="flash"&&(i.index=t.video.index,t.conf.rtmp&&e.extend(i,{pos:t.video.time,play:t.playing})),L?o?A?n[0].requestFullscreen():(n[0][T+"RequestFullScreen"](Element.ALLOW_KEYBOARD_INPUT),M&&!document.webkitCurrentFullScreenElement&&!document.mozFullScreenElement&&n[0][T+"RequestFullScreen"]()):A?document.exitFullscreen():document[T+"CancelFullScreen"]():t.trigger(o?N:C,[t]),t};var o;n.bind("mousedown.fs",function(){+(new Date)-o<150&&t.ready&&t.fullscreen(),o=+(new Date)}),t.bind(N,function(e){n.addClass("is-fullscreen"),t.isFullscreen=!0}).bind(C,function(e){var i;!L&&t.engine==="html5"&&(i=n.css("opacity")||"",n.css("opacity",0)),n.removeClass("is-fullscreen"),!L&&t.engine==="html5"&&setTimeout(function(){n.css("opacity",i)}),t.isFullscreen=!1,r.scrollTop(s)}).bind("ready",function(){if(i.index>0)t.play(i.index),i.index=0;else if(i.pos&&!isNaN(i.pos)){var n=function(){i.play||t.pause(),e.extend(i,{pos:0,play:!1})};t.conf.live?(t.resume(),n()):t.resume().seek(i.pos,n)}})}),flowplayer(function(t,n){function s(){return e(r.query,n)}function o(){return e(r.query+"."+i,n)}var r=e.extend({active:"is-active",advance:!0,query:".fp-playlist a"},t.conf),i=r.active;t.play=function(n){return n===undefined?t.resume():typeof n=="number"&&!t.conf.playlist[n]?t:(typeof n!="number"&&t.load.apply(null,arguments),t.unbind("resume.fromfirst"),t.video.index=n,t.load(typeof t.conf.playlist[n]=="string"?t.conf.playlist[n].toString():e.map(t.conf.playlist[n],function(t){return e.extend({},t)})),t)},t.next=function(e){e&&e.preventDefault();var n=t.video.index;return n!=-1&&(n=n===t.conf.playlist.length-1?0:n+1,t.play(n)),t},t.prev=function(e){e&&e.preventDefault();var n=t.video.index;return n!=-1&&(n=n===0?t.conf.playlist.length-1:n-1,t.play(n)),t},e(".fp-next",n).click(t.next),e(".fp-prev",n).click(t.prev),r.advance&&n.unbind("finish.pl").bind("finish.pl",function(e,t){var i=t.video.index+1;i<t.conf.playlist.length||r.loop?(i=i===t.conf.playlist.length?0:i,n.removeClass("is-finished"),setTimeout(function(){t.play(i)})):(n.addClass("is-playing"),t.conf.playlist.length>1&&t.one("resume.fromfirst",function(){return t.play(0),!1}))});var u=!1;if(t.conf.playlist.length){u=!0;var a=n.find(".fp-playlist");if(!a.length){a=e('<div class="fp-playlist"></div>');var f=e(".fp-next,.fp-prev",n);f.length?f.eq(0).before(a):e("video",n).after(a)}a.empty(),e.each(t.conf.playlist,function(t,n){var r;if(typeof n=="string")r=n;else for(var i in n[0])if(n[0].hasOwnProperty(i)){r=n[0][i];break}a.append(e("<a />").attr({href:r,"data-index":t}))})}if(s().length){u||(t.conf.playlist=[],s().each(function(){var n=e(this).attr("href");e(this).attr("data-index",t.conf.playlist.length),t.conf.playlist.push(n)})),n.on("click",r.query,function(n){n.preventDefault();var i=e(n.target).closest(r.query),s=Number(i.attr("data-index"));s!=-1&&t.play(s)});var l=s().filter("[data-cuepoints]").length;t.bind("load",function(r,s,u){var a=o().removeClass(i),f=a.attr("data-index"),c=u.index=t.video.index||0,h=e('a[data-index="'+c+'"]',n).addClass(i),p=c==t.conf.playlist.length-1;n.removeClass("video"+f).addClass("video"+c).toggleClass("last-video",p),u.index=s.video.index=c,u.is_last=s.video.is_last=p,l&&(t.cuepoints=h.data("cuepoints"))}).bind("unload.pl",function(){o().toggleClass(i)})}t.conf.playlist.length&&(t.conf.loop=!1)});var _=/ ?cue\d+ ?/;flowplayer(function(t,n){function i(e){n[0].className=n[0].className.replace(_," "),e>=0&&n.addClass("cue"+e)}var r=0;t.cuepoints=t.conf.cuepoints||[],t.bind("progress",function(e,s,o){if(r&&o-r<.015)return r=o;r=o;var u=t.cuepoints||[];for(var a=0,f;a<u.length;a++)f=u[a],isNaN(f)||(f={time:f}),f.time<0&&(f.time=t.video.duration+f.time),f.index=a,Math.abs(f.time-o)<.125*t.currentSpeed&&(i(a),n.trigger("cuepoint",[t,f]))}).bind("unload seek",i),t.conf.generate_cuepoints&&t.bind("load",function(){e(".fp-cuepoint",n).remove()}).bind("ready",function(){var r=t.cuepoints||[],i=t.video.duration,s=e(".fp-timeline",n).css("overflow","visible");e.each(r,function(n,r){var o=r.time||r;o<0&&(o=i+r);var u=e("<a/>").addClass("fp-cuepoint fp-cuepoint"+n).css("left",o/i*100+"%");u.appendTo(s).mousedown(function(){return t.seek(o),!1})})})}),flowplayer(function(t,n,r){function u(e){var t=e.split(":");return t.length==2&&t.unshift(0),t[0]*60*60+t[1]*60+parseFloat(t[2].replace(",","."))}var i=e("track",n),s=t.conf;if(flowplayer.support.subtitles){t.subtitles=i.length&&i[0].track;if(s.nativesubtitles&&s.engine=="html5")return}i.remove();var o=/^(([0-9]{2}:)?[0-9]{2}:[0-9]{2}[,.]{1}[0-9]{3}) --\> (([0-9]{2}:)?[0-9]{2}:[0-9]{2}[,.]{1}[0-9]{3})(.*)/;t.subtitles=[];var a=i.attr("src");if(!a)return;setTimeout(function(){e.get(a,function(n){for(var r=0,i=n.split("\n"),s=i.length,a={},f,l,c,h;r<s;r++){l=o.exec(i[r]);if(l){f=i[r-1],c="<p>"+i[++r]+"</p><br/>";while(e.trim(i[++r])&&r<i.length)c+="<p>"+i[r]+"</p><br/>";a={title:f,startTime:u(l[1]),endTime:u(l[2]||l[3]),text:c},h={time:a.startTime,subtitle:a},t.subtitles.push(a),t.cuepoints.push(h),t.cuepoints.push({time:a.endTime,subtitleEnd:f}),a.startTime===0&&t.trigger("cuepoint",h)}}}).fail(function(){return t.trigger("error",{code:8,url:a}),!1})});var f=e("<div class='fp-subtitle'/>").appendTo(n),l;t.bind("cuepoint",function(e,t,n){n.subtitle?(l=n.index,f.html(n.subtitle.text).addClass("fp-active")):n.subtitleEnd&&(f.removeClass("fp-active"),l=n.index)}).bind("seek",function(n,r,i){l&&t.cuepoints[l]&&t.cuepoints[l].time>i&&(f.removeClass("fp-active"),l=null),e.each(t.cuepoints||[],function(e,n){var r=n.subtitle;r&&l!=n.index?i>=n.time&&(!r.endTime||i<=r.endTime)&&t.trigger("cuepoint",n):n.subtitleEnd&&i>=n.time&&n.index==l+1&&t.trigger("cuepoint",n)})})}),flowplayer(function(t,n){var r=t.conf.analytics,i=0,s=0;if(r){typeof _gat=="undefined"&&e.getScript("//google-analytics.com/ga.js");function o(e){if(i&&typeof _gat!="undefined"){var s=_gat._getTracker(r),o=t.video;s._setAllowLinker(!0),s._trackEvent("Video / Seconds played",t.engine+"/"+o.type,n.attr("title")||o.src.split("/").slice(-1)[0].replace(m,""),Math.round(i/1e3)),i=0}}t.bind("load unload",o).bind("progress",function(){t.seeking||(i+=s?+(new Date)-s:0,s=+(new Date))}).bind("pause",function(){s=0}),e(window).unload(o)}});var D=/IEMobile/.test(r);(flowplayer.support.touch||D)&&flowplayer(function(t,n){var i=/Android/.test(r)&&!/Firefox/.test(r)&&!/Opera/.test(r),s=/Silk/.test(r),o=i?parseFloat(/Android\ (\d\.\d)/.exec(r)[1],10):0;if(i){t.conf.videoTypePreference="mp4";if(!/Chrome/.test(r)&&o<4){var u=t.load;t.load=function(e,n){var r=u.apply(t,arguments);return t.trigger("ready",[t,t.video]),r}}}flowplayer.support.volume||n.addClass("no-volume no-mute"),n.addClass("is-touch"),n.find(".fp-timeline").data("api").disableAnimation();var a=!1;n.bind("touchmove",function(){a=!0}).bind("touchend click",function(r){if(a){a=!1;return}if(t.playing&&!n.hasClass("is-mouseover"))
6
+ return n.addClass("is-mouseover").removeClass("is-mouseout"),!1;t.paused&&n.hasClass("is-mouseout")&&!t.splash&&t.toggle(),t.paused&&D&&e("video.fp-engine",n)[0].play()}),t.conf.native_fullscreen&&typeof e("<video />")[0].webkitEnterFullScreen=="function"&&(t.fullscreen=function(){var t=e("video.fp-engine",n);t[0].webkitEnterFullScreen(),t.one("webkitendfullscreen",function(){t.prop("controls",!0).prop("controls",!1)})}),(i||s)&&t.bind("ready",function(){var r=e("video.fp-engine",n);r.one("canplay",function(){r[0].play()}),r[0].play(),t.bind("progress.dur",function(){var i=r[0].duration;i!==1&&(t.video.duration=i,e(".fp-duration",n).html(w(i)),t.unbind("progress.dur"))})})}),flowplayer(function(t,n){if(t.conf.embed===!1)return;var r=t.conf,i=e(".fp-ui",n),s=e("<a/>",{"class":"fp-embed",title:"Copy to your site"}).appendTo(i),o=e("<div/>",{"class":"fp-embed-code"}).append("<label>Right click to copy and paste this HTML code on your site to embed.</label><textarea/>").appendTo(i),u=e("textarea",o);t.embedCode=function(){var i=t.video,s=i.width||n.width(),o=i.height||n.height(),u=e("<div/>",{"class":"flowplayer",css:{width:s,height:o}}),a=e("<video/>").appendTo(u);e.each(["origin","analytics","key","rtmp"],function(e,t){r[t]&&u.attr("data-"+t,r[t])}),r.logo&&u.attr("data-logo",e("<img />").attr("src",r.logo)[0].src),e.each(i.sources,function(t,n){var i=n.src;if(!/^https?:/.test(n.src)&&n.type!=="flash"||!r.rtmp)i=e("<img/>").attr("src",n.src)[0].src;a.append(e("<source/>",{type:"video/"+n.type,src:i}))});var f={src:"//foliovision.com/flowplayer/5.4.6/embed.min.js"};e.isPlainObject(r.embed)&&(f["data-swf"]=r.embed.swf,f["data-library"]=r.embed.library,f.src=r.embed.script||f.src,r.embed.skin&&(f["data-skin"]=r.embed.skin));var l=e("<foo/>",f).append(u);return e("<p/>").append(l).html().replace(/<(\/?)foo/g,"<$1script")},n.fptip(".fp-embed","is-embedding"),u.click(function(){this.select()}),s.click(function(){u.text(t.embedCode()),u[0].focus(),u[0].select()})}),e.fn.fptip=function(t,n){return this.each(function(){function i(){r.removeClass(n),e(document).unbind(".st")}var r=e(this);e(t||"a",this).click(function(t){t.preventDefault(),r.toggleClass(n),r.hasClass(n)&&e(document).bind("keydown.st",function(e){e.which==27&&i()}).bind("click.st",function(t){e(t.target).parents("."+n).length||i()})})})}}(jQuery),flowplayer(function(e,t){function n(e){var t=s("<a/>")[0];return t.href=e,t.hostname}function r(e){var t="ab.ca,ac.ac,ac.at,ac.be,ac.cn,ac.il,ac.in,ac.jp,ac.kr,ac.th,ac.uk,adm.br,adv.br,ah.cn,am.br,arq.br,art.br,arts.ro,asn.au,asso.fr,asso.mc,bc.ca,bio.br,biz.pl,biz.tr,bj.cn,br.com,cn.com,cng.br,cnt.br,co.ac,co.at,co.gl,co.id,co.il,co.in,co.jp,co.kr,co.mg,co.ms,co.nz,co.th,co.uk,co.ve,co.vi,co.za,com.ag,com.ai,com.ar,com.au,com.br,com.cn,com.cy,com.de,com.do,com.ec,com.es,com.fj,com.fr,com.gl,com.gt,com.hk,com.hr,com.hu,com.kg,com.ki,com.lc,com.mg,com.mm,com.ms,com.mt,com.mu,com.mx,com.my,com.nf,com.ng,com.ni,com.pa,com.ph,com.pl,com.pt,com.qa,com.ro,com.ru,com.sb,com.sc,com.sg,com.sv,com.tr,com.tw,com.ua,com.uy,com.ve,com.vn,cq.cn,de.com,de.org,ecn.br,edu.au,edu.cn,edu.hk,edu.mm,edu.my,edu.pt,edu.qa,edu.tr,eng.br,ernet.in,esp.br,etc.br,eti.br,eu.com,eu.int,eu.lv,firm.in,firm.ro,fm.br,fot.br,fst.br,g12.br,gb.com,gb.net,gd.cn,gen.in,go.jp,go.kr,go.th,gov.au,gov.az,gov.br,gov.cn,gov.il,gov.in,gov.mm,gov.my,gov.qa,gov.sg,gov.tr,gov.tw,gs.cn,gv.ac,gv.at,gx.cn,gz.cn,he.cn,hi.cn,hk.cn,hl.cn,hu.com,id.au,idv.tw,in.ua,ind.br,ind.in,inf.br,info.pl,info.ro,info.tr,info.ve,iwi.nz,jl.cn,jor.br,js.cn,k12.il,k12.tr,kr.com,lel.br,ln.cn,ltd.uk,maori.nz,mb.ca,me.uk,med.br,mi.th,mil.br,mo.cn,muni.il,nb.ca,ne.jp,ne.kr,net.ag,net.ai,net.au,net.br,net.cn,net.do,net.gl,net.hk,net.il,net.in,net.kg,net.ki,net.lc,net.mg,net.mm,net.mu,net.ni,net.nz,net.pl,net.ru,net.sb,net.sc,net.sg,net.th,net.tr,net.tw,net.uk,net.ve,nf.ca,nm.cn,nm.kr,no.com,nom.br,nom.ni,nom.ro,ns.ca,nt.ca,nt.ro,ntr.br,nx.cn,odo.br,off.ai,on.ca,or.ac,or.at,or.jp,or.kr,or.th,org.ag,org.ai,org.au,org.br,org.cn,org.do,org.es,org.gl,org.hk,org.in,org.kg,org.ki,org.lc,org.mg,org.mm,org.ms,org.nf,org.ni,org.nz,org.pl,org.ro,org.ru,org.sb,org.sc,org.sg,org.tr,org.tw,org.uk,org.ve,pe.ca,plc.uk,ppg.br,presse.fr,pro.br,psc.br,psi.br,qc.ca,qc.com,qh.cn,rec.br,rec.ro,res.in,sa.com,sc.cn,sch.ul,se.com,se.net,sh.cn,sk.ca,slg.br,sn.cn,store.ro,tj.cn,tm.fr,tm.mc,tm.ro,tmp.br,tur.br,tv.br,tv.tr,tw.cn,uk.com,uk.net,us.com,uy.com,vet.br,waw.pl,web.ve,www.ro,xj.cn,xz.cn,yk.ca,yn.cn,zj.cn,zlg.br".split(",");e=e.toLowerCase();var n=e.split("."),r=n.length;if(r<2)return e;var i=n.slice(-2).join(".");return r>=3&&s.inArray(i,t)>=0?n.slice(-3).join("."):i}function i(e,t){t!="localhost"&&!parseInt(t.split(".").slice(-1))&&(t=r(t));var n=0;for(var i=t.length-1;i>=0;i--)n+=t.charCodeAt(i)*28939532831;n=(""+n).substring(0,7);for(i=0;i<e.length;i++)if(n===e[i].substring(1,8))return 1}var s=jQuery,o=e.conf,u=o.swf.indexOf("flowplayer.org")&&o.e&&t.data("origin"),a=u?n(u):location.hostname,f=o.key;location.protocol=="file:"&&(a="localhost"),e.load.ed=1,o.hostname=a,o.origin=u||location.href,u&&t.addClass("is-embedded"),typeof f=="string"&&(f=f.split(/,\s*/));if(f&&typeof i=="function"&&i(f,a))o.logo&&t.append(s("<a>",{"class":"fp-logo",href:u}).append(s("<img/>",{src:o.logo})));else{var l=s("<a/>").attr("onclick","").appendTo(t),c=s(".fp-controls",t),h=s('<div class="fp-context-menu"><ul><li class="copyright">&copy; 2013</li><li><a href="http://flowplayer.org">About Flowplayer</a></li><li><a href="http://flowplayer.org/license">GPL based license</a></li></ul></div>').appendTo(t);e.bind("pause resume finish unload",function(e,n){var r=-1;n.video.src&&s.each([["org","flowplayer","drive"],["org","flowplayer","my"]],function(e,t){return r=n.video.src.indexOf("://"+t.reverse().join(".")),r===-1}),/pause|resume/.test(e.type)&&n.engine!="flash"&&r!=4&&r!=5?(l.show().css({position:"absolute",left:16,bottom:36,zIndex:99999,width:120,height:27,backgroundImage:"url("+[".png","fplogo","/",".com","foliovision","//"].reverse().join("")+")"}),n.load.ed=l.is(":visible")&&s.contains(t[0],h[0]),n.load.ed||n.pause()):l.hide()})}});
7
+
8
+ /*
9
+ FV Flowplayer additions!
10
+ */
11
+ if( typeof(fv_flowplayer_admin_input) != "undefined" && fv_flowplayer_admin_input ) {
12
+ jQuery(document).keyup(function(e) {
13
+ if (e.keyCode == 27) { fv_wp_flowplayer_admin_show_notice(); } // esc
14
+ });
15
+
16
+ jQuery(document).click( function(event) {
17
+ if( jQuery(event.target).parents('.fv-wp-flowplayer-notice').length == 0 &&
18
+ jQuery(event.target).parents('.fv-wp-flowplayer-notice-small').length == 0 ) {
19
+ fv_wp_flowplayer_admin_show_notice();
20
+ }
21
+ } );
22
+ }
23
+
24
+ function fv_wp_flowplayer_admin_show_notice( id, link ) {
25
+ if( id == null && link == null ) {
26
+ var api = flowplayer(), currentPos;
27
+ if( typeof api != "undefined" ) {
28
+ api.disable(false);
29
+ }
30
+ jQuery('.fv-wp-flowplayer-notice .fv_wp_fp_notice_content').toggle();
31
+ jQuery('.fv-wp-flowplayer-notice').toggleClass("fv-wp-flowplayer-notice");
32
+ } else {
33
+ jQuery('#fv_wp_fp_notice_'+id).toggle();
34
+
35
+ var api = flowplayer(), currentPos;
36
+ if( jQuery('#fv_wp_fp_notice_'+id).parent().hasClass("fv-wp-flowplayer-notice") ) {
37
+ api.disable(false);
38
+ } else {
39
+ api.disable(true);
40
+ }
41
+
42
+ jQuery('#fv_wp_fp_notice_'+id).parent().toggleClass("fv-wp-flowplayer-notice");
43
+ }
44
+ }
45
+
46
+ function fv_wp_flowplayer_admin_support_mail( hash, button ) {
47
+ jQuery('.fv_flowplayer_submit_error').remove();
48
+
49
+ var comment_text = jQuery('#wpfp_support_'+hash).val();
50
+ var comment_words = comment_text.split(/\s/);
51
+ if( comment_words.length == 0 || comment_text.match(/Enter your comment/) ) {
52
+ jQuery('#wpfp_support_'+hash).before('<p class="fv_flowplayer_submit_error" style="display:none; "><strong>Please tell us what is wrong</strong>:</p>');
53
+ jQuery('.fv_flowplayer_submit_error').fadeIn();
54
+ return false;
55
+ }
56
+
57
+ if( comment_words.length < 7 ) {
58
+ jQuery('#wpfp_support_'+hash).before('<p class="fv_flowplayer_submit_error" style="display:none; "><strong>Please give us more information (a full sentence) so we can help you better</strong>:</p>');
59
+ jQuery('.fv_flowplayer_submit_error').fadeIn();
60
+ return false;
61
+ }
62
+
63
+ jQuery('#wpfp_spin_'+hash).show();
64
+ jQuery(button).attr("disabled", "disabled");
65
+
66
+ jQuery.post(
67
+ fv_fp_ajaxurl,
68
+ {
69
+ action: 'fv_wp_flowplayer_support_mail',
70
+ comment: comment_text,
71
+ notice: jQuery('#wpfp_notice_'+hash+' .mail-content-notice').html(),
72
+ details: jQuery('#wpfp_notice_'+hash+' .mail-content-details').html()
73
+ },
74
+ function( response ) {
75
+ jQuery('#wpfp_spin_'+hash).hide();
76
+ jQuery(button).removeAttr("disabled");
77
+ jQuery(button).after(' Message sent');
78
+ setTimeout( function() { fv_wp_flowplayer_admin_show_notice(hash) }, 1500 );
79
+ }
80
+ );
81
+ }
82
+
83
+ function fv_flowplayer_admin_test_media( hash, media ) {
84
+ jQuery(document).ready( function() {
85
+ jQuery('#wpfp_'+hash).append('<div id="wpfp_notice_'+hash+'" class="fv-wp-flowplayer-notice-small" title="This note is visible to logged-in admins only."><small>Admin note: Checking the video file...</small></div>');
86
+ jQuery.post( fv_fp_ajaxurl, { action: 'fv_wp_flowplayer_check_mimetype', media: media, hash: hash }, function( response ) {
87
+ var obj;
88
+ try {
89
+ obj = jQuery.parseJSON( response );
90
+
91
+ var extra_class = ( obj[1] > 0 ) ? ' fv-wp-flowplayer-error' : ' fv-wp-flowplayer-ok';
92
+ if( obj[1] == 0 && obj[2] > 0 ) {
93
+ extra_class = '';
94
+ }
95
+ jQuery('#wpfp_notice_'+hash).remove();
96
+ jQuery('#wpfp_'+hash).append('<div id="wpfp_notice_'+hash+'" class="fv-wp-flowplayer-notice-small'+extra_class+'" title="This note is visible to logged-in admins only.">'+obj[0]+'</div>');
97
+ } catch(e) {
98
+ jQuery('#wpfp_notice_'+hash).html('<p>Admin: Error parsing JSON</p>');
99
+ return;
100
+ }
101
+
102
+ } );
103
+ } );
104
+ }
105
+
106
+ function fv_flowplayer_autoplay( hash ) {
107
+ jQuery('#wpfp_'+hash).bind( 'ready', function() {
108
+ jQuery('#wpfp_'+hash).flowplayer().play();
109
+ });
110
+ }
111
+
112
+ function fv_flowplayer_amazon_s3( hash, time ) {
113
+ jQuery('#wpfp_'+hash).bind('error', function (e,api, error) {
114
+ var fv_fp_date = new Date();
115
+ if( error.code == 4 && fv_fp_date.getTime() > (fv_fp_utime + parseInt(time)) ) {
116
+ jQuery(e.target).find('.fp-message').delay(500).queue( function(n) {
117
+ jQuery(this).html('<h2>Video file expired.<br />Please reload the page and play it again.</h2>'); n();
118
+ } );
119
+ }
120
+ } );
121
+ }
122
+
123
+ function fv_flowplayer_browser_chrome_fail( hash, sAttributes, sVideo, bAutobuffer ) {
124
+ jQuery('#wpfp_'+hash).bind('error', function (e,api, error) {
125
+ if( /chrom(e|ium)/.test(navigator.userAgent.toLowerCase()) && error != null && ( error.code == 3 || error.code == 4 || error.code == 5 ) ) {
126
+ api.unload();
127
+ var html = jQuery('<div />').append(jQuery('#wpfp_'+hash+' .wpfp_custom_popup').clone()).html();
128
+ html += jQuery('<div />').append(jQuery('#wpfp_'+hash+' .wpfp_custom_ad').clone()).html();
129
+
130
+ jQuery('#wpfp_'+hash).attr('id','bad_wpfp_'+hash);
131
+ jQuery('#bad_wpfp_'+hash).after( '<div id="wpfp_'+hash+'" '+sAttributes+' data-engine="flash">'+html+'</div>' );
132
+ jQuery('#wpfp_'+hash).flowplayer({ playlist: [ [ {mp4: sVideo} ] ] });
133
+ // what about scripts?
134
+ if( bAutobuffer ) {
135
+ jQuery('#wpfp_'+hash).bind('ready', function(e, api) { api.play(); } );
136
+ } else {
137
+ jQuery('#wpfp_'+hash).flowplayer().play(0);
138
+ }
139
+ jQuery('#bad_wpfp_'+hash).remove();
140
+ }
141
+ });
142
+ }
143
+
144
+ function fv_flowplayer_browser_chrome_mp4( hash ) {
145
+ var match = window.navigator.appVersion.match(/Chrome\/(\d+)\./);
146
+ if( match != null ) {
147
+ var chrome_ver = parseInt(match[1], 10);
148
+ if(
149
+ ( /chrom(e|ium)/.test(navigator.userAgent.toLowerCase()) && chrome_ver < 28 && navigator.appVersion.indexOf("Win")!=-1 ) ||
150
+ ( /chrom(e|ium)/.test(navigator.userAgent.toLowerCase()) && chrome_ver < 27 && navigator.appVersion.indexOf("Linux")!=-1 )
151
+ ) {
152
+ jQuery('#wpfp_'+hash).attr('data-engine','flash');
153
+ }
154
+ }
155
+ }
156
+
157
+ function fv_flowplayer_browser_ff_m4v( hash ) {
158
+ if( jQuery.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1 ) {
159
+ jQuery('#wpfp_'+hash).attr('data-engine','flash');
160
+ }
161
+ }
162
+
163
+ function fv_flowplayer_browser_ie( hash ) {
164
+ if( jQuery.browser.msie && parseInt(jQuery.browser.version, 10) >= 9 ) {
165
+ jQuery('#wpfp_'+hash).attr('data-engine','flash');
166
+ }
167
+ }
168
+
169
+ if( (navigator.platform.indexOf("iPhone") != -1) || (navigator.platform.indexOf("iPod") != -1) || (navigator.platform.indexOf("iPad") != -1) || (navigator.userAgent.toLowerCase().indexOf("android") != -1) ) {
170
+ flowplayer(function (api, root) {
171
+ api.bind("error", function (e,api, error) {
172
+ if( error.code == 10 ) {
173
+ jQuery(e.target).find('.fp-message').html('<h2>Unsupported video format.<br />Please use a Flash compatible device.</h2>');
174
+ }
175
+ });
176
+ });
177
+ }
178
+
179
+ jQuery(document).ready( function() {
180
+ if( (navigator.platform.indexOf("iPhone") != -1) || (navigator.platform.indexOf("iPod") != -1) || (navigator.platform.indexOf("iPad") != -1) ) {
181
+ jQuery(window).trigger('load');
182
+ }
183
+ } );
184
+
185
+ function fv_flowplayer_loop( hash ) {
186
+ jQuery('#wpfp_'+hash).bind('finish', function() {
187
+ jQuery('#wpfp_'+hash).flowplayer().play();
188
+ });
189
+ }
190
+
191
+ function fv_flowplayer_mobile_switch(id) {
192
+ var regex = new RegExp("[\\?&]fv_flowplayer_mobile=([^&#]*)");
193
+ var results = regex.exec(location.search);
194
+ if(
195
+ (
196
+ (results != null && results[1] == 'yes') ||
197
+ (jQuery(window).width()<=320 || jQuery(window).height()<=480)
198
+ )
199
+ &&
200
+ (results == null || results[1] != 'no')
201
+ ) {
202
+ var fv_fp_mobile = false;
203
+ jQuery('#wpfp_'+id+' video source').each( function() {
204
+ if( jQuery(this).attr('id') != 'wpfp_'+id+'_mobile' ) {
205
+ fv_fp_mobile = true
206
+ jQuery(this).remove();
207
+ }
208
+ } );
209
+ if( fv_fp_mobile ) {
210
+ jQuery('#wpfp_'+id).after('<p class="fv-flowplayer-mobile-switch">Mobile browser detected, serving low bandwidth video. <a href="'+document.URL+'?fv_flowplayer_mobile=no">Click here</a> for full quality.</p>');
211
+ }
212
+ }
213
+ }
214
+
215
+ function fv_flowplayer_preroll_post( hash, media ) {
216
+ jQuery('#wpfp_'+hash).bind('finish', function (e,api, error) {
217
+ jQuery('#wpfp_'+hash).flowplayer().load( [ {mp4: media} ] )
218
+ } );
219
+ }
220
+
221
+ function fv_flowplayer_redirect( hash, url ) {
222
+ jQuery('#wpfp_'+hash).bind('finish', function() { window.open(url, '_blank'); } );
223
+ }
224
+
225
+ var fv_flowplayer_safety_resize_arr = Array();
226
+
227
+ function fv_flowplayer_safety_resize() {
228
+ var fv_flowplayer_safety_resize_init = false;
229
+
230
+ jQuery('.flowplayer').each( function() {
231
+ if( jQuery(this).width() < 30 || jQuery(this).height() < 20 ) {
232
+ fv_flowplayer_safety_resize_init = true
233
+ var el = jQuery(this);
234
+ while( jQuery(el).width() < 30 || jQuery(el).width() == jQuery(this).width() ) {
235
+ el = jQuery(el).parent();
236
+ }
237
+
238
+ jQuery(this).width( jQuery(el).width() );
239
+ jQuery(this).height( parseInt(jQuery(this).width() * jQuery(this).attr('data-ratio')) );
240
+ fv_flowplayer_safety_resize_arr[jQuery(this).attr('id')] = el;
241
+ }
242
+ } );
243
+
244
+ if( fv_flowplayer_safety_resize_init ) {
245
+ jQuery(window).resize(function() {
246
+ jQuery('.flowplayer').each( function() {
247
+ if( fv_flowplayer_safety_resize_arr[jQuery(this).attr('id')] ) {
248
+ jQuery(this).width( fv_flowplayer_safety_resize_arr[jQuery(this).attr('id')].width() );
249
+ jQuery(this).height( parseInt(jQuery(this).width() * jQuery(this).attr('data-ratio')) );
250
+ }
251
+ } );
252
+ } );
253
+ }
254
+ }
255
+
256
+ if( typeof(fv_flowplayer_safety_resize_do) != "undefined" && fv_flowplayer_safety_resize_do ) {
257
+ jQuery(document).ready(function() { fv_flowplayer_safety_resize(); } );
258
+ }
259
+
260
+ jQuery(document).ready( function() {
261
+ if( jQuery('.fp-playlist-external').length == 0 ) return;
262
+ jQuery('.fp-playlist-external' ).each( function(i,el) {
263
+ if( jQuery('a',el).length == 0 ) return;
264
+ jQuery('a',el).click( function(e) {
265
+ jQuery('a',el).removeClass('is-active');
266
+ jQuery( '#' + jQuery(this).parent().attr('rel') ).flowplayer().play( jQuery('a',el).index(this) );
267
+ jQuery(this).addClass('is-active');
268
+ } );
269
+ } );
270
+
271
+ jQuery('.flowplayer').bind('load', function(e,api,video) {
272
+ if( video.index > -1 ) {
273
+ var playlist_external = jQuery('[rel='+jQuery(this).attr('id')+'] a');
274
+ if( playlist_external.length > 0 ) {
275
+ jQuery(playlist_external).removeClass('is-active');
276
+ jQuery(playlist_external).eq(video.index).addClass('is-active');
277
+ }
278
+ }
279
+ } );
280
+ } );
281
+
282
+ jQuery( function() { if( typeof(flowplayer.conf.key) == "undefined" ) { jQuery('.flowplayer').unbind('contextmenu'); } } );
283
+
284
+ if( typeof(fv_flowplayer_conf) != "undefined" ) {
285
+ flowplayer.conf = fv_flowplayer_conf
286
+ }
287
+
288
+ if( typeof(fv_flowplayer_playlists) != "undefined" ) {
289
+ for( var i in fv_flowplayer_playlists ) {
290
+ jQuery('#'+i).flowplayer( { playlist: fv_flowplayer_playlists[i] })
291
+ }
292
+ }
293
+
294
+ var fv_fp_date = new Date();
295
+ var fv_fp_utime = fv_fp_date.getTime();
296
+
297
+ if( typeof(fv_flowplayer_autoplay_array) != "undefined" ) {
298
+ for( var i in fv_flowplayer_autoplay_array ) {
299
+ fv_flowplayer_autoplay( i );
300
+ }
301
+ }
302
+ if( typeof(fv_flowplayer_admin_test_media_array) != "undefined" ) {
303
+ for( var i in fv_flowplayer_admin_test_media_array ) {
304
+ fv_flowplayer_admin_test_media( i, fv_flowplayer_admin_test_media_array[i] );
305
+ }
306
+ }
307
+ if( typeof(fv_flowplayer_browser_ff_m4v_array) != "undefined" ) {
308
+ for( var i in fv_flowplayer_browser_ff_m4v_array ) {
309
+ fv_flowplayer_browser_ff_m4v( i );
310
+ }
311
+ }
312
+ if( typeof(fv_flowplayer_browser_chrome_fail_array) != "undefined" ) {
313
+ for( var i in fv_flowplayer_browser_chrome_fail_array ) {
314
+ fv_flowplayer_browser_chrome_fail( i, fv_flowplayer_browser_chrome_fail_array[i]['attrs'], fv_flowplayer_browser_chrome_fail_array[i]['mp4'], fv_flowplayer_browser_chrome_fail_array[i]['auto_buffer'] );
315
+ }
316
+ }
317
+ if( typeof(fv_flowplayer_browser_chrome_mp4_array) != "undefined" ) {
318
+ for( var i in fv_flowplayer_browser_chrome_mp4_array ) {
319
+ fv_flowplayer_browser_chrome_mp4( i );
320
+ }
321
+ }
322
+ if( typeof(fv_flowplayer_browser_ie_array) != "undefined" ) {
323
+ for( var i in fv_flowplayer_browser_ie_array ) {
324
+ fv_flowplayer_browser_ie( i );
325
+ }
326
+ }
327
+ if( typeof(fv_flowplayer_loop_array) != "undefined" ) {
328
+ for( var i in fv_flowplayer_loop_array ) {
329
+ fv_flowplayer_loop( i );
330
+ }
331
+ }
332
+ if( typeof(fv_flowplayer_mobile_switch_array) != "undefined" ) {
333
+ for( var i in fv_flowplayer_mobile_switch_array ) {
334
+ fv_flowplayer_mobile_switch( i );
335
+ }
336
+ }
337
+ if( typeof(fv_flowplayer_redirect_array) != "undefined" ) {
338
+ for( var i in fv_flowplayer_redirect_array ) {
339
+ fv_flowplayer_redirect( i, fv_flowplayer_redirect_array[i] );
340
+ }
341
+ }
flowplayer/style.css DELETED
@@ -1,41 +0,0 @@
1
-
2
- body {
3
- background-color:#fff;
4
- font-family:"Lucida Grande","bitstream vera sans","trebuchet ms",verdana,arial;
5
- text-align:center;
6
- }
7
-
8
- #page {
9
- background-color:#efefef;
10
- width:600px;
11
- margin:50px auto;
12
- padding:20px 150px 20px 50px;
13
- min-height:600px;
14
- border:2px solid #fff;
15
- outline:1px solid #ccc;
16
- text-align:left;
17
- }
18
-
19
- h1, h2 {
20
- letter-spacing:-1px;
21
- color:#2D5AC3;
22
- font-weight:normal;
23
- margin-bottom:-10px;
24
- }
25
-
26
- h1 {
27
- font-size:22px;
28
- }
29
-
30
- h2 {
31
- font-size:18px;
32
- }
33
-
34
- .less {
35
- color:#999;
36
- font-size:12px;
37
- }
38
-
39
- a {
40
- color:#295c72;
41
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
images/admin-bar-sprite.png ADDED
Binary file
images/button-bg.png DELETED
Binary file
images/fabric-plaid-bg.png ADDED
Binary file
images/finished_bg.png DELETED
Binary file
images/fv-wp-flowplayer-led-monitor.png ADDED
Binary file
images/icon.png.toobig DELETED
Binary file
images/icon.png.tootiny DELETED
Binary file
images/list-bullet.png ADDED
Binary file
images/play.png DELETED
Binary file
images/red-button-large.png ADDED
Binary file
images/red-button.png ADDED
Binary file
images/replay.png DELETED
Binary file
images/share.png DELETED
Binary file
images/wpspin.gif ADDED
Binary file
includes/extra-functions.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* FV Wordpress Flowplayer - HTML5 video player with Flash fallback
3
+ Copyright (C) 2013 Foliovision
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+
20
+ if( !function_exists('http_build_url') ) :
21
+ define('HTTP_URL_REPLACE', 1); // Replace every part of the first URL when there's one of the second URL
22
+ define('HTTP_URL_JOIN_PATH', 2); // Join relative paths
23
+ define('HTTP_URL_JOIN_QUERY', 4); // Join query strings
24
+ define('HTTP_URL_STRIP_USER', 8); // Strip any user authentication information
25
+ define('HTTP_URL_STRIP_PASS', 16); // Strip any password authentication information
26
+ define('HTTP_URL_STRIP_AUTH', 32); // Strip any authentication information
27
+ define('HTTP_URL_STRIP_PORT', 64); // Strip explicit port numbers
28
+ define('HTTP_URL_STRIP_PATH', 128); // Strip complete path
29
+ define('HTTP_URL_STRIP_QUERY', 256); // Strip query string
30
+ define('HTTP_URL_STRIP_FRAGMENT', 512); // Strip any fragments (#identifier)
31
+ define('HTTP_URL_STRIP_ALL', 1024); // Strip anything but scheme and host
32
+
33
+ // Build an URL
34
+ // The parts of the second URL will be merged into the first according to the flags argument.
35
+ //
36
+ // @param mixed (Part(s) of) an URL in form of a string or associative array like parse_url() returns
37
+ // @param mixed Same as the first argument
38
+ // @param int A bitmask of binary or'ed HTTP_URL constants (Optional)HTTP_URL_REPLACE is the default
39
+ // @param array If set, it will be filled with the parts of the composed url like parse_url() would return
40
+ function http_build_url($url, $parts=array(), $flags=HTTP_URL_REPLACE, &$new_url=false)
41
+ {
42
+ $keys = array('user','pass','port','path','query','fragment');
43
+
44
+ // HTTP_URL_STRIP_ALL becomes all the HTTP_URL_STRIP_Xs
45
+ if ($flags & HTTP_URL_STRIP_ALL)
46
+ {
47
+ $flags |= HTTP_URL_STRIP_USER;
48
+ $flags |= HTTP_URL_STRIP_PASS;
49
+ $flags |= HTTP_URL_STRIP_PORT;
50
+ $flags |= HTTP_URL_STRIP_PATH;
51
+ $flags |= HTTP_URL_STRIP_QUERY;
52
+ $flags |= HTTP_URL_STRIP_FRAGMENT;
53
+ }
54
+ // HTTP_URL_STRIP_AUTH becomes HTTP_URL_STRIP_USER and HTTP_URL_STRIP_PASS
55
+ else if ($flags & HTTP_URL_STRIP_AUTH)
56
+ {
57
+ $flags |= HTTP_URL_STRIP_USER;
58
+ $flags |= HTTP_URL_STRIP_PASS;
59
+ }
60
+
61
+ // Parse the original URL
62
+ $parse_url = parse_url($url);
63
+
64
+ // Scheme and Host are always replaced
65
+ if (isset($parts['scheme']))
66
+ $parse_url['scheme'] = $parts['scheme'];
67
+ if (isset($parts['host']))
68
+ $parse_url['host'] = $parts['host'];
69
+
70
+ // (If applicable) Replace the original URL with it's new parts
71
+ if ($flags & HTTP_URL_REPLACE)
72
+ {
73
+ foreach ($keys as $key)
74
+ {
75
+ if (isset($parts[$key]))
76
+ $parse_url[$key] = $parts[$key];
77
+ }
78
+ }
79
+ else
80
+ {
81
+ // Join the original URL path with the new path
82
+ if (isset($parts['path']) && ($flags & HTTP_URL_JOIN_PATH))
83
+ {
84
+ if (isset($parse_url['path']))
85
+ $parse_url['path'] = rtrim(str_replace(basename($parse_url['path']), '', $parse_url['path']), '/') . '/' . ltrim($parts['path'], '/');
86
+ else
87
+ $parse_url['path'] = $parts['path'];
88
+ }
89
+
90
+ // Join the original query string with the new query string
91
+ if (isset($parts['query']) && ($flags & HTTP_URL_JOIN_QUERY))
92
+ {
93
+ if (isset($parse_url['query']))
94
+ $parse_url['query'] .= '&' . $parts['query'];
95
+ else
96
+ $parse_url['query'] = $parts['query'];
97
+ }
98
+ }
99
+
100
+ // Strips all the applicable sections of the URL
101
+ // Note: Scheme and Host are never stripped
102
+ foreach ($keys as $key)
103
+ {
104
+ if ($flags & (int)constant('HTTP_URL_STRIP_' . strtoupper($key)))
105
+ unset($parse_url[$key]);
106
+ }
107
+
108
+
109
+ $new_url = $parse_url;
110
+
111
+ return
112
+ ((isset($parse_url['scheme'])) ? $parse_url['scheme'] . '://' : '')
113
+ .((isset($parse_url['user'])) ? $parse_url['user'] . ((isset($parse_url['pass'])) ? ':' . $parse_url['pass'] : '') .'@' : '')
114
+ .((isset($parse_url['host'])) ? $parse_url['host'] : '')
115
+ .((isset($parse_url['port'])) ? ':' . $parse_url['port'] : '')
116
+ .((isset($parse_url['path'])) ? $parse_url['path'] : '')
117
+ .((isset($parse_url['query'])) ? '?' . $parse_url['query'] : '')
118
+ .((isset($parse_url['fragment'])) ? '#' . $parse_url['fragment'] : '')
119
+ ;
120
+ }
121
+
122
+ endif;
123
+
124
+
125
+ if( !function_exists('is_utf8') && function_exists('mb_strlen') ) :
126
+
127
+ function is_utf8($str) {
128
+ return ( (mb_strlen($str) != strlen($str) ) ? true : false );
129
+ }
130
+
131
+ endif;
includes/fp-api.php ADDED
@@ -0,0 +1,376 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* FV Wordpress Flowplayer - HTML5 video player with Flash fallback
3
+ Copyright (C) 2013 Foliovision
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+
19
+ /**
20
+ * Foliopress base class
21
+ */
22
+
23
+ /**
24
+ * Class FV_Wordpress_Flowplayer_Plugin
25
+ */
26
+ class FV_Wordpress_Flowplayer_Plugin
27
+ {
28
+ /**
29
+ * Stores the path to readme.txt available on trac, needs to be set from plugin
30
+ * @var string
31
+ */
32
+ var $readme_URL;
33
+
34
+ /**
35
+ * Stores the special message for updates
36
+ * @var string
37
+ */
38
+ var $update_prefix;
39
+
40
+ function __construct(){
41
+ $this->class_name = sanitize_title( get_class($this) );
42
+ add_action( 'admin_enqueue_scripts', array( $this, 'pointers_enqueue' ) );
43
+ add_action( 'wp_ajax_fv_foliopress_ajax_pointers', array( $this, 'pointers_ajax' ), 999 );
44
+ }
45
+
46
+ function http_request($method, $url, $data = '', $auth = '', $check_status = true)
47
+ {
48
+ $status = 0;
49
+ $method = strtoupper($method);
50
+
51
+ if (function_exists('curl_init')) {
52
+ $ch = curl_init();
53
+
54
+ curl_setopt($ch, CURLOPT_URL, $url);
55
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
56
+ curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0)');
57
+ @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
58
+ curl_setopt($ch, CURLOPT_FORBID_REUSE, true);
59
+ curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
60
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
61
+ curl_setopt($ch, CURLOPT_TIMEOUT, 10);
62
+
63
+ switch ($method) {
64
+ case 'POST':
65
+ curl_setopt($ch, CURLOPT_POST, true);
66
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
67
+ break;
68
+
69
+ case 'PURGE':
70
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PURGE');
71
+ break;
72
+ }
73
+
74
+ if ($auth) {
75
+ curl_setopt($ch, CURLOPT_USERPWD, $auth);
76
+ }
77
+
78
+ $contents = curl_exec($ch);
79
+
80
+ $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
81
+
82
+ curl_close($ch);
83
+ } else {
84
+ $parse_url = @parse_url($url);
85
+
86
+ if ($parse_url && isset($parse_url['host'])) {
87
+ $host = $parse_url['host'];
88
+ $port = (isset($parse_url['port']) ? (int) $parse_url['port'] : 80);
89
+ $path = (!empty($parse_url['path']) ? $parse_url['path'] : '/');
90
+ $query = (isset($parse_url['query']) ? $parse_url['query'] : '');
91
+ $request_uri = $path . ($query != '' ? '?' . $query : '');
92
+
93
+ $request_headers_array = array(
94
+ sprintf('%s %s HTTP/1.1', $method, $request_uri),
95
+ sprintf('Host: %s', $host),
96
+ sprintf('User-Agent: %s', W3TC_POWERED_BY),
97
+ 'Connection: close'
98
+ );
99
+
100
+ if (!empty($data)) {
101
+ $request_headers_array[] = sprintf('Content-Length: %d', strlen($data));
102
+ }
103
+
104
+ if (!empty($auth)) {
105
+ $request_headers_array[] = sprintf('Authorization: Basic %s', base64_encode($auth));
106
+ }
107
+
108
+ $request_headers = implode("\r\n", $request_headers_array);
109
+ $request = $request_headers . "\r\n\r\n" . $data;
110
+ $errno = null;
111
+ $errstr = null;
112
+
113
+ $fp = @fsockopen($host, $port, $errno, $errstr, 10);
114
+
115
+ if (!$fp) {
116
+ return false;
117
+ }
118
+
119
+ $response = '';
120
+ @fputs($fp, $request);
121
+
122
+ while (!@feof($fp)) {
123
+ $response .= @fgets($fp, 4096);
124
+ }
125
+
126
+ @fclose($fp);
127
+
128
+ list($response_headers, $contents) = explode("\r\n\r\n", $response, 2);
129
+
130
+ $matches = null;
131
+
132
+ if (preg_match('~^HTTP/1.[01] (\d+)~', $response_headers, $matches)) {
133
+ $status = (int) $matches[1];
134
+ }
135
+ }
136
+ }
137
+
138
+ if (!$check_status || $status == 200) {
139
+ return $contents;
140
+ }
141
+
142
+ return false;
143
+ }
144
+
145
+ /**
146
+ * Download url via GET
147
+ *
148
+ * @param string $url
149
+ * @param string $auth
150
+ * $param boolean $check_status
151
+ * @return string
152
+ */
153
+ function http_get($url, $auth = '', $check_status = true)
154
+ {
155
+ return $this->http_request('GET', $url, null, $auth, $check_status);
156
+ }
157
+
158
+
159
+
160
+ function plugin_update_message()
161
+ {
162
+ if( $this->readme_URL ) {
163
+ $data = $this->http_get( $this->readme_URL );
164
+
165
+ if ($data) {
166
+ $matches = null; /// not sure if this works for more than one last changelog
167
+ //if (preg_match('~==\s*Changelog\s*==\s*=\s*[0-9.]+\s*=(.*)(=\s*[0-9.]+\s*=|$)~Uis', $data, $matches)) {
168
+ if (preg_match('~==\s*Upgrade Notice\s*==\s*=\s*[0-9.]+\s*=(.*)(=\s*[0-9.]+\s*=|$)~Uis', $data, $matches)) {
169
+ $changelog = (array) preg_split('~[\r\n]+~', trim($matches[1]));
170
+
171
+ echo '<div style="color: #b51212;"">';
172
+ $ul = false;
173
+
174
+ foreach ($changelog as $index => $line) {
175
+ if (preg_match('~^\s*\*\s*~', $line) && 1<0 ) {
176
+ if (!$ul) {
177
+ //echo '<ul style="list-style: disc; margin-left: 20px;">';
178
+ $ul = true;
179
+ }
180
+ $line = preg_replace('~^\s*\*\s*~', '', htmlspecialchars($line));
181
+ echo '<li style="width: 50%; margin: 0; float: left; ' . ($index % 2 == 0 ? 'clear: left;' : '') . '">' . $line . '</li>';
182
+ } else {
183
+ if ($ul) {
184
+ //echo '</ul><div style="clear: left;"></div>';
185
+ $ul = false;
186
+ }
187
+ $line = preg_replace('~^\s*\*\s*~', '', htmlspecialchars($line));
188
+ echo '<p style="margin: 5px 0;">' . htmlspecialchars($line) . '</p>';
189
+ }
190
+ }
191
+
192
+ if ($ul) {
193
+ //echo '</ul><div style="clear: left;"></div>';
194
+ }
195
+
196
+ echo '</div>';
197
+ }
198
+ }
199
+ }
200
+ }
201
+ /*function plugin_update_message()
202
+ {
203
+ if( $this->readme_URL ) {
204
+ $data = $this->http_get( $this->readme_URL );
205
+
206
+ if ($data) {
207
+ $matches = null; /// not sure if this works for more than one last changelog
208
+ if (preg_match('~==\s*Changelog\s*==\s*=\s*[0-9.]+\s*=(.*)(=\s*[0-9.]+\s*=|$)~Uis', $data, $matches)) {
209
+ $changelog = (array) preg_split('~[\r\n]+~', trim($matches[1]));
210
+
211
+ if( $this->update_prefix ) {
212
+ echo '<div style="color: #b51212;">'.$this->update_prefix.'</div>';
213
+ }
214
+ echo '<div>Last version improvements:</div><div style="font-weight: normal;">';
215
+ $ul = false;
216
+
217
+ foreach ($changelog as $index => $line) {
218
+ if (preg_match('~^\s*\*\s*~', $line)) {
219
+ if (!$ul) {
220
+ echo '<ul style="list-style: disc; margin-left: 20px;">';
221
+ $ul = true;
222
+ }
223
+ $line = preg_replace('~^\s*\*\s*~', '', htmlspecialchars($line));
224
+ echo '<li style="width: 50%; margin: 0; float: left; ' . ($index % 2 == 0 ? 'clear: left;' : '') . '">' . $line . '</li>';
225
+ } else {
226
+ if ($ul) {
227
+ echo '</ul><div style="clear: left;"></div>';
228
+ $ul = false;
229
+ }
230
+ echo '<p style="margin: 5px 0;">' . htmlspecialchars($line) . '</p>';
231
+ }
232
+ }
233
+
234
+ if ($ul) {
235
+ echo '</ul><div style="clear: left;"></div>';
236
+ }
237
+
238
+ echo '</div>';
239
+ }
240
+ }
241
+ }
242
+ }*/
243
+
244
+
245
+
246
+ function pointers_ajax() {
247
+ if( $this->pointer_boxes ) {
248
+ foreach( $this->pointer_boxes AS $sKey => $aPopup ) {
249
+ if( $_POST['key'] == $sKey ) {
250
+ check_ajax_referer($sKey);
251
+ }
252
+ }
253
+ }
254
+ }
255
+
256
+
257
+
258
+ function pointers_enqueue() {
259
+ global $wp_version;
260
+ if( ! current_user_can( 'manage_options' ) || ( isset($this->pointer_boxes) && count( $this->pointer_boxes ) == 0 ) || version_compare( $wp_version, '3.4', '<' ) ) {
261
+ return;
262
+ }
263
+
264
+ /*$options = get_option( 'wpseo' );
265
+ if ( ! isset( $options['yoast_tracking'] ) || ( ! isset( $options['ignore_tour'] ) || ! $options['ignore_tour'] ) ) {*/
266
+ wp_enqueue_style( 'wp-pointer' );
267
+ wp_enqueue_script( 'jquery-ui' );
268
+ wp_enqueue_script( 'wp-pointer' );
269
+ wp_enqueue_script( 'utils' );
270
+ /*}
271
+ if ( ! isset( $options['tracking_popup'] ) && ! isset( $_GET['allow_tracking'] ) ) {*/
272
+
273
+ /*}
274
+ else if ( ! isset( $options['ignore_tour'] ) || ! $options['ignore_tour'] ) {
275
+ add_action( 'admin_print_footer_scripts', array( $this, 'intro_tour' ) );
276
+ add_action( 'admin_head', array( $this, 'admin_head' ) );
277
+ } */
278
+
279
+ add_action( 'admin_print_footer_scripts', array( $this, 'pointers_init_scripts' ) );
280
+ }
281
+
282
+
283
+
284
+ function pointers_init_scripts() {
285
+ if( !isset($this->pointer_boxes) || !$this->pointer_boxes ) {
286
+ return;
287
+ }
288
+
289
+ foreach( $this->pointer_boxes AS $sKey => $aPopup ) {
290
+ $sNonce = wp_create_nonce( $sKey );
291
+
292
+ $content = '<h3>'.$aPopup['heading'].'</h3>';
293
+ if( stripos( $aPopup['content'], '</p>' ) !== false ) {
294
+ $content .= $aPopup['content'];
295
+ } else {
296
+ $content .= '<p>'.$aPopup['content'].'</p>';
297
+ }
298
+
299
+ $position = ( isset($aPopup['position']) ) ? $aPopup['position'] : array( 'edge' => 'top', 'align' => 'center' );
300
+
301
+ $opt_arr = array( 'content' => $content, 'position' => $position );
302
+
303
+ $function2 = $this->class_name.'_store_answer("'.$sKey.'", "false","' . $sNonce . '")';
304
+ $function1 = $this->class_name.'_store_answer("'.$sKey.'", "true","' . $sNonce . '")';
305
+
306
+ ?>
307
+ <script type="text/javascript">
308
+ //<![CDATA[
309
+ function <?php echo $this->class_name; ?>_store_answer(key, input, nonce) {
310
+ var post_data = {
311
+ action : 'fv_foliopress_ajax_pointers',
312
+ key : key,
313
+ value : input,
314
+ _ajax_nonce : nonce
315
+ }
316
+ jQuery.post(ajaxurl, post_data, function () {
317
+ jQuery('#wp-pointer-0').remove(); // todo: does this really work?
318
+ });
319
+ }
320
+ //]]>
321
+ </script>
322
+ <?php
323
+
324
+ $this->pointers_print_scripts( $sKey, $aPopup['id'], $opt_arr, $aPopup['button2'], $aPopup['button1'], $function2, $function1 );
325
+ }
326
+ }
327
+
328
+
329
+
330
+ function pointers_print_scripts( $id, $selector, $options, $button1, $button2 = false, $button2_function = '', $button1_function = '' ) {
331
+ ?>
332
+ <script type="text/javascript">
333
+ //<![CDATA[
334
+ (function ($) {
335
+ var <?php echo $id; ?>_pointer_options = <?php echo json_encode( $options ); ?>, <?php echo $id; ?>_setup;
336
+
337
+ <?php echo $id; ?>_pointer_options = $.extend(<?php echo $id; ?>_pointer_options, {
338
+ buttons: function (event, t) {
339
+ button = jQuery('<a id="pointer-close" style="margin-left:5px" class="button-secondary">' + '<?php echo addslashes($button1); ?>' + '</a>');
340
+ button.bind('click.pointer', function () {
341
+ t.element.pointer('close');
342
+ });
343
+ return button;
344
+ },
345
+ close : function () {
346
+ }
347
+ });
348
+
349
+ <?php echo $id; ?>_setup = function () {
350
+ $('<?php echo $selector; ?>').pointer(<?php echo $id; ?>_pointer_options).pointer('open');
351
+ <?php if ( $button2 ) { ?>
352
+ jQuery('#pointer-close').after('<a id="pointer-primary" class="button-primary">' + '<?php echo addslashes($button2); ?>' + '</a>');
353
+ jQuery('#pointer-primary').click(function () { <?php echo $button1_function; ?> });
354
+ jQuery('#pointer-close').click(function () { <?php echo $button2_function; ?> });
355
+ <?php } ?>
356
+ };
357
+
358
+ if(<?php echo $id; ?>_pointer_options.position && <?php echo $id; ?>_pointer_options.position.defer_loading)
359
+ $(window).bind('load.wp-pointers', <?php echo $id; ?>_setup);
360
+ else
361
+ $(document).ready(<?php echo $id; ?>_setup);
362
+ })(jQuery);
363
+ //]]>
364
+ </script>
365
+ <?php
366
+ }
367
+
368
+
369
+
370
+ function is_min_wp( $version ) {
371
+ return version_compare( $GLOBALS['wp_version'], $version. 'alpha', '>=' );
372
+ }
373
+
374
+ }
375
+
376
+ ?>
{view → includes}/getid3/extension.cache.dbm.php RENAMED
@@ -1,222 +1,208 @@
1
- <?php
2
- /////////////////////////////////////////////////////////////////
3
- /// getID3() by James Heinrich <info@getid3.org> //
4
- // available at http://getid3.sourceforge.net //
5
- // or http://www.getid3.org //
6
- /////////////////////////////////////////////////////////////////
7
- // //
8
- // extension.cache.dbm.php - part of getID3() //
9
- // Please see readme.txt for more information //
10
- // ///
11
- /////////////////////////////////////////////////////////////////
12
- // //
13
- // This extension written by Allan Hansen <ah�artemis*dk> //
14
- // ///
15
- /////////////////////////////////////////////////////////////////
16
-
17
-
18
- /**
19
- * This is a caching extension for getID3(). It works the exact same
20
- * way as the getID3 class, but return cached information very fast
21
- *
22
- * Example:
23
- *
24
- * Normal getID3 usage (example):
25
- *
26
- * require_once 'getid3/getid3.php';
27
- * $getID3 = new getID3;
28
- * $getID3->encoding = 'UTF-8';
29
- * $info1 = $getID3->analyze('file1.flac');
30
- * $info2 = $getID3->analyze('file2.wv');
31
- *
32
- * getID3_cached usage:
33
- *
34
- * require_once 'getid3/getid3.php';
35
- * require_once 'getid3/getid3/extension.cache.dbm.php';
36
- * $getID3 = new getID3_cached('db3', '/tmp/getid3_cache.dbm',
37
- * '/tmp/getid3_cache.lock');
38
- * $getID3->encoding = 'UTF-8';
39
- * $info1 = $getID3->analyze('file1.flac');
40
- * $info2 = $getID3->analyze('file2.wv');
41
- *
42
- *
43
- * Supported Cache Types
44
- *
45
- * SQL Databases: (use extension.cache.mysql)
46
- *
47
- * cache_type cache_options
48
- * -------------------------------------------------------------------
49
- * mysql host, database, username, password
50
- *
51
- *
52
- * DBM-Style Databases: (this extension)
53
- *
54
- * cache_type cache_options
55
- * -------------------------------------------------------------------
56
- * gdbm dbm_filename, lock_filename
57
- * ndbm dbm_filename, lock_filename
58
- * db2 dbm_filename, lock_filename
59
- * db3 dbm_filename, lock_filename
60
- * db4 dbm_filename, lock_filename (PHP5 required)
61
- *
62
- * PHP must have write access to both dbm_filename and lock_filename.
63
- *
64
- *
65
- * Recommended Cache Types
66
- *
67
- * Infrequent updates, many reads any DBM
68
- * Frequent updates mysql
69
- */
70
-
71
-
72
- class getID3_cached_dbm extends getID3
73
- {
74
-
75
- // public: constructor - see top of this file for cache type and cache_options
76
- function getID3_cached_dbm($cache_type, $dbm_filename, $lock_filename) {
77
-
78
- // Check for dba extension
79
- if (!extension_loaded('dba')) {
80
- die('PHP is not compiled with dba support, required to use DBM style cache.');
81
- }
82
-
83
- // Check for specific dba driver
84
- if (function_exists('dba_handlers')) { // PHP 4.3.0+
85
- if (!in_array('db3', dba_handlers())) {
86
- die('PHP is not compiled --with '.$cache_type.' support, required to use DBM style cache.');
87
- }
88
- }
89
- else { // PHP <= 4.2.3
90
- ob_start(); // nasty, buy the only way to check...
91
- phpinfo();
92
- $contents = ob_get_contents();
93
- ob_end_clean();
94
- if (!strstr($contents, $cache_type)) {
95
- die('PHP is not compiled --with '.$cache_type.' support, required to use DBM style cache.');
96
- }
97
- }
98
-
99
- // Create lock file if needed
100
- if (!file_exists($lock_filename)) {
101
- if (!touch($lock_filename)) {
102
- die('failed to create lock file: ' . $lock_filename);
103
- }
104
- }
105
-
106
- // Open lock file for writing
107
- if (!is_writeable($lock_filename)) {
108
- die('lock file: ' . $lock_filename . ' is not writable');
109
- }
110
- $this->lock = fopen($lock_filename, 'w');
111
-
112
- // Acquire exclusive write lock to lock file
113
- flock($this->lock, LOCK_EX);
114
-
115
- // Create dbm-file if needed
116
- if (!file_exists($dbm_filename)) {
117
- if (!touch($dbm_filename)) {
118
- die('failed to create dbm file: ' . $dbm_filename);
119
- }
120
- }
121
-
122
- // Try to open dbm file for writing
123
- $this->dba = @dba_open($dbm_filename, 'w', $cache_type);
124
- if (!$this->dba) {
125
-
126
- // Failed - create new dbm file
127
- $this->dba = dba_open($dbm_filename, 'n', $cache_type);
128
-
129
- if (!$this->dba) {
130
- die('failed to create dbm file: ' . $dbm_filename);
131
- }
132
-
133
- // Insert getID3 version number
134
- dba_insert(GETID3_VERSION, GETID3_VERSION, $this->dba);
135
- }
136
-
137
- // Init misc values
138
- $this->cache_type = $cache_type;
139
- $this->dbm_filename = $dbm_filename;
140
-
141
- // Register destructor
142
- register_shutdown_function(array($this, '__destruct'));
143
-
144
- // Check version number and clear cache if changed
145
- if (dba_fetch(GETID3_VERSION, $this->dba) != GETID3_VERSION) {
146
- $this->clear_cache();
147
- }
148
-
149
- parent::getID3();
150
- }
151
-
152
-
153
-
154
- // public: destuctor
155
- function __destruct() {
156
-
157
- // Close dbm file
158
- @dba_close($this->dba);
159
-
160
- // Release exclusive lock
161
- @flock($this->lock, LOCK_UN);
162
-
163
- // Close lock file
164
- @fclose($this->lock);
165
- }
166
-
167
-
168
-
169
- // public: clear cache
170
- function clear_cache() {
171
-
172
- // Close dbm file
173
- dba_close($this->dba);
174
-
175
- // Create new dbm file
176
- $this->dba = dba_open($this->dbm_filename, 'n', $this->cache_type);
177
-
178
- if (!$this->dba) {
179
- die('failed to clear cache/recreate dbm file: ' . $this->dbm_filename);
180
- }
181
-
182
- // Insert getID3 version number
183
- dba_insert(GETID3_VERSION, GETID3_VERSION, $this->dba);
184
-
185
- // Reregister shutdown function
186
- register_shutdown_function(array($this, '__destruct'));
187
- }
188
-
189
-
190
-
191
- // public: analyze file
192
- function analyze($filename) {
193
-
194
- if (file_exists($filename)) {
195
-
196
- // Calc key filename::mod_time::size - should be unique
197
- $key = $filename . '::' . filemtime($filename) . '::' . filesize($filename);
198
-
199
- // Loopup key
200
- $result = dba_fetch($key, $this->dba);
201
-
202
- // Hit
203
- if ($result !== false) {
204
- return unserialize($result);
205
- }
206
- }
207
-
208
- // Miss
209
- $result = parent::analyze($filename);
210
-
211
- // Save result
212
- if (file_exists($filename)) {
213
- dba_insert($key, serialize($result), $this->dba);
214
- }
215
-
216
- return $result;
217
- }
218
-
219
- }
220
-
221
-
222
- ?>
1
+ <?php
2
+ /////////////////////////////////////////////////////////////////
3
+ /// getID3() by James Heinrich <info@getid3.org> //
4
+ // available at http://getid3.sourceforge.net //
5
+ // or http://www.getid3.org //
6
+ /////////////////////////////////////////////////////////////////
7
+ // //
8
+ // extension.cache.dbm.php - part of getID3() //
9
+ // Please see readme.txt for more information //
10
+ // ///
11
+ /////////////////////////////////////////////////////////////////
12
+ // //
13
+ // This extension written by Allan Hansen <ah�artemis*dk> //
14
+ // ///
15
+ /////////////////////////////////////////////////////////////////
16
+
17
+
18
+ /**
19
+ * This is a caching extension for getID3(). It works the exact same
20
+ * way as the getID3 class, but return cached information very fast
21
+ *
22
+ * Example:
23
+ *
24
+ * Normal getID3 usage (example):
25
+ *
26
+ * require_once 'getid3/getid3.php';
27
+ * $getID3 = new getID3;
28
+ * $getID3->encoding = 'UTF-8';
29
+ * $info1 = $getID3->analyze('file1.flac');
30
+ * $info2 = $getID3->analyze('file2.wv');
31
+ *
32
+ * getID3_cached usage:
33
+ *
34
+ * require_once 'getid3/getid3.php';
35
+ * require_once 'getid3/getid3/extension.cache.dbm.php';
36
+ * $getID3 = new getID3_cached('db3', '/tmp/getid3_cache.dbm',
37
+ * '/tmp/getid3_cache.lock');
38
+ * $getID3->encoding = 'UTF-8';
39
+ * $info1 = $getID3->analyze('file1.flac');
40
+ * $info2 = $getID3->analyze('file2.wv');
41
+ *
42
+ *
43
+ * Supported Cache Types
44
+ *
45
+ * SQL Databases: (use extension.cache.mysql)
46
+ *
47
+ * cache_type cache_options
48
+ * -------------------------------------------------------------------
49
+ * mysql host, database, username, password
50
+ *
51
+ *
52
+ * DBM-Style Databases: (this extension)
53
+ *
54
+ * cache_type cache_options
55
+ * -------------------------------------------------------------------
56
+ * gdbm dbm_filename, lock_filename
57
+ * ndbm dbm_filename, lock_filename
58
+ * db2 dbm_filename, lock_filename
59
+ * db3 dbm_filename, lock_filename
60
+ * db4 dbm_filename, lock_filename (PHP5 required)
61
+ *
62
+ * PHP must have write access to both dbm_filename and lock_filename.
63
+ *
64
+ *
65
+ * Recommended Cache Types
66
+ *
67
+ * Infrequent updates, many reads any DBM
68
+ * Frequent updates mysql
69
+ */
70
+
71
+
72
+ class getID3_cached_dbm extends getID3
73
+ {
74
+
75
+ // public: constructor - see top of this file for cache type and cache_options
76
+ public function getID3_cached_dbm($cache_type, $dbm_filename, $lock_filename) {
77
+
78
+ // Check for dba extension
79
+ if (!extension_loaded('dba')) {
80
+ throw new Exception('PHP is not compiled with dba support, required to use DBM style cache.');
81
+ }
82
+
83
+ // Check for specific dba driver
84
+ if (!function_exists('dba_handlers') || !in_array($cache_type, dba_handlers())) {
85
+ throw new Exception('PHP is not compiled --with '.$cache_type.' support, required to use DBM style cache.');
86
+ }
87
+
88
+ // Create lock file if needed
89
+ if (!file_exists($lock_filename)) {
90
+ if (!touch($lock_filename)) {
91
+ throw new Exception('failed to create lock file: '.$lock_filename);
92
+ }
93
+ }
94
+
95
+ // Open lock file for writing
96
+ if (!is_writeable($lock_filename)) {
97
+ throw new Exception('lock file: '.$lock_filename.' is not writable');
98
+ }
99
+ $this->lock = fopen($lock_filename, 'w');
100
+
101
+ // Acquire exclusive write lock to lock file
102
+ flock($this->lock, LOCK_EX);
103
+
104
+ // Create dbm-file if needed
105
+ if (!file_exists($dbm_filename)) {
106
+ if (!touch($dbm_filename)) {
107
+ throw new Exception('failed to create dbm file: '.$dbm_filename);
108
+ }
109
+ }
110
+
111
+ // Try to open dbm file for writing
112
+ $this->dba = dba_open($dbm_filename, 'w', $cache_type);
113
+ if (!$this->dba) {
114
+
115
+ // Failed - create new dbm file
116
+ $this->dba = dba_open($dbm_filename, 'n', $cache_type);
117
+
118
+ if (!$this->dba) {
119
+ throw new Exception('failed to create dbm file: '.$dbm_filename);
120
+ }
121
+
122
+ // Insert getID3 version number
123
+ dba_insert(getID3::VERSION, getID3::VERSION, $this->dba);
124
+ }
125
+
126
+ // Init misc values
127
+ $this->cache_type = $cache_type;
128
+ $this->dbm_filename = $dbm_filename;
129
+
130
+ // Register destructor
131
+ register_shutdown_function(array($this, '__destruct'));
132
+
133
+ // Check version number and clear cache if changed
134
+ if (dba_fetch(getID3::VERSION, $this->dba) != getID3::VERSION) {
135
+ $this->clear_cache();
136
+ }
137
+
138
+ parent::getID3();
139
+ }
140
+
141
+
142
+
143
+ // public: destructor
144
+ public function __destruct() {
145
+
146
+ // Close dbm file
147
+ dba_close($this->dba);
148
+
149
+ // Release exclusive lock
150
+ flock($this->lock, LOCK_UN);
151
+
152
+ // Close lock file
153
+ fclose($this->lock);
154
+ }
155
+
156
+
157
+
158
+ // public: clear cache
159
+ public function clear_cache() {
160
+
161
+ // Close dbm file
162
+ dba_close($this->dba);
163
+
164
+ // Create new dbm file
165
+ $this->dba = dba_open($this->dbm_filename, 'n', $this->cache_type);
166
+
167
+ if (!$this->dba) {
168
+ throw new Exception('failed to clear cache/recreate dbm file: '.$this->dbm_filename);
169
+ }
170
+
171
+ // Insert getID3 version number
172
+ dba_insert(getID3::VERSION, getID3::VERSION, $this->dba);
173
+
174
+ // Re-register shutdown function
175
+ register_shutdown_function(array($this, '__destruct'));
176
+ }
177
+
178
+
179
+
180
+ // public: analyze file
181
+ public function analyze($filename) {
182
+
183
+ if (file_exists($filename)) {
184
+
185
+ // Calc key filename::mod_time::size - should be unique
186
+ $key = $filename.'::'.filemtime($filename).'::'.filesize($filename);
187
+
188
+ // Loopup key
189
+ $result = dba_fetch($key, $this->dba);
190
+
191
+ // Hit
192
+ if ($result !== false) {
193
+ return unserialize($result);
194
+ }
195
+ }
196
+
197
+ // Miss
198
+ $result = parent::analyze($filename);
199
+
200
+ // Save result
201
+ if (file_exists($filename)) {
202
+ dba_insert($key, serialize($result), $this->dba);
203
+ }
204
+
205
+ return $result;
206
+ }
207
+
208
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
{view → includes}/getid3/extension.cache.mysql.php RENAMED
@@ -1,171 +1,171 @@
1
- <?php
2
- /////////////////////////////////////////////////////////////////
3
- /// getID3() by James Heinrich <info@getid3.org> //
4
- // available at http://getid3.sourceforge.net //
5
- // or http://www.getid3.org //
6
- /////////////////////////////////////////////////////////////////
7
- // //
8
- // extension.cache.mysql.php - part of getID3() //
9
- // Please see readme.txt for more information //
10
- // ///
11
- /////////////////////////////////////////////////////////////////
12
- // //
13
- // This extension written by Allan Hansen <ah�artemis*dk> //
14
- // ///
15
- /////////////////////////////////////////////////////////////////
16
-
17
-
18
- /**
19
- * This is a caching extension for getID3(). It works the exact same
20
- * way as the getID3 class, but return cached information very fast
21
- *
22
- * Example: (see also demo.cache.mysql.php in /demo/)
23
- *
24
- * Normal getID3 usage (example):
25
- *
26
- * require_once 'getid3/getid3.php';
27
- * $getID3 = new getID3;
28
- * $getID3->encoding = 'UTF-8';
29
- * $info1 = $getID3->analyze('file1.flac');
30
- * $info2 = $getID3->analyze('file2.wv');
31
- *
32
- * getID3_cached usage:
33
- *
34
- * require_once 'getid3/getid3.php';
35
- * require_once 'getid3/getid3/extension.cache.mysql.php';
36
- * $getID3 = new getID3_cached_mysql('localhost', 'database',
37
- * 'username', 'password');
38
- * $getID3->encoding = 'UTF-8';
39
- * $info1 = $getID3->analyze('file1.flac');
40
- * $info2 = $getID3->analyze('file2.wv');
41
- *
42
- *
43
- * Supported Cache Types (this extension)
44
- *
45
- * SQL Databases:
46
- *
47
- * cache_type cache_options
48
- * -------------------------------------------------------------------
49
- * mysql host, database, username, password
50
- *
51
- *
52
- * DBM-Style Databases: (use extension.cache.dbm)
53
- *
54
- * cache_type cache_options
55
- * -------------------------------------------------------------------
56
- * gdbm dbm_filename, lock_filename
57
- * ndbm dbm_filename, lock_filename
58
- * db2 dbm_filename, lock_filename
59
- * db3 dbm_filename, lock_filename
60
- * db4 dbm_filename, lock_filename (PHP5 required)
61
- *
62
- * PHP must have write access to both dbm_filename and lock_filename.
63
- *
64
- *
65
- * Recommended Cache Types
66
- *
67
- * Infrequent updates, many reads any DBM
68
- * Frequent updates mysql
69
- */
70
-
71
-
72
- class getID3_cached_mysql extends getID3
73
- {
74
-
75
- // private vars
76
- var $cursor;
77
- var $connection;
78
-
79
-
80
- // public: constructor - see top of this file for cache type and cache_options
81
- function getID3_cached_mysql($host, $database, $username, $password) {
82
-
83
- // Check for mysql support
84
- if (!function_exists('mysql_pconnect')) {
85
- die('PHP not compiled with mysql support.');
86
- }
87
-
88
- // Connect to database
89
- $this->connection = mysql_pconnect($host, $username, $password);
90
- if (!$this->connection) {
91
- die('mysql_pconnect() failed - check permissions and spelling.');
92
- }
93
-
94
- // Select database
95
- if (!mysql_select_db($database, $this->connection)) {
96
- die('Cannot use database '.$database);
97
- }
98
-
99
- // Create cache table if not exists
100
- $this->create_table();
101
-
102
- // Check version number and clear cache if changed
103
- $this->cursor = mysql_query("SELECT `value` FROM `getid3_cache` WHERE (`filename` = '".GETID3_VERSION."') AND (`filesize` = '-1') AND (`filetime` = '-1') AND (`analyzetime` = '-1')", $this->connection);
104
- list($version) = @mysql_fetch_array($this->cursor);
105
- if ($version != GETID3_VERSION) {
106
- $this->clear_cache();
107
- }
108
-
109
- parent::getID3();
110
- }
111
-
112
-
113
-
114
- // public: clear cache
115
- function clear_cache() {
116
-
117
- $this->cursor = mysql_query("DELETE FROM `getid3_cache`", $this->connection);
118
- $this->cursor = mysql_query("INSERT INTO `getid3_cache` VALUES ('".GETID3_VERSION."', -1, -1, -1, '".GETID3_VERSION."')", $this->connection);
119
- }
120
-
121
-
122
-
123
- // public: analyze file
124
- function analyze($filename) {
125
-
126
- if (file_exists($filename)) {
127
-
128
- // Short-hands
129
- $filetime = filemtime($filename);
130
- $filesize = filesize($filename);
131
- $filenam2 = mysql_escape_string($filename);
132
-
133
- // Loopup file
134
- $this->cursor = mysql_query("SELECT `value` FROM `getid3_cache` WHERE (`filename`='".$filenam2."') AND (`filesize`='".$filesize."') AND (`filetime`='".$filetime."')", $this->connection);
135
- list($result) = @mysql_fetch_array($this->cursor);
136
-
137
- // Hit
138
- if ($result) {
139
- return unserialize($result);
140
- }
141
- }
142
-
143
- // Miss
144
- $result = parent::analyze($filename);
145
-
146
- // Save result
147
- if (file_exists($filename)) {
148
- $res2 = mysql_escape_string(serialize($result));
149
- $this->cursor = mysql_query("INSERT INTO `getid3_cache` (`filename`, `filesize`, `filetime`, `analyzetime`, `value`) VALUES ('".$filenam2."', '".$filesize."', '".$filetime."', '".time()."', '".$res2."')", $this->connection);
150
- }
151
- return $result;
152
- }
153
-
154
-
155
-
156
- // private: (re)create sql table
157
- function create_table($drop = false) {
158
-
159
- $this->cursor = mysql_query("CREATE TABLE IF NOT EXISTS `getid3_cache` (
160
- `filename` VARCHAR(255) NOT NULL DEFAULT '',
161
- `filesize` INT(11) NOT NULL DEFAULT '0',
162
- `filetime` INT(11) NOT NULL DEFAULT '0',
163
- `analyzetime` INT(11) NOT NULL DEFAULT '0',
164
- `value` TEXT NOT NULL,
165
- PRIMARY KEY (`filename`,`filesize`,`filetime`)) TYPE=MyISAM", $this->connection);
166
- echo mysql_error($this->connection);
167
- }
168
- }
169
-
170
-
171
- ?>
1
+ <?php
2
+ /////////////////////////////////////////////////////////////////
3
+ /// getID3() by James Heinrich <info@getid3.org> //
4
+ // available at http://getid3.sourceforge.net //
5
+ // or http://www.getid3.org //
6
+ /////////////////////////////////////////////////////////////////
7
+ // //
8
+ // extension.cache.mysql.php - part of getID3() //
9
+ // Please see readme.txt for more information //
10
+ // ///
11
+ /////////////////////////////////////////////////////////////////
12
+ // //
13
+ // This extension written by Allan Hansen <ah�artemis*dk> //
14
+ // Table name mod by Carlo Capocasa <calro�carlocapocasa*com> //
15
+ // ///
16
+ /////////////////////////////////////////////////////////////////
17
+
18
+
19
+ /**
20
+ * This is a caching extension for getID3(). It works the exact same
21
+ * way as the getID3 class, but return cached information very fast
22
+ *
23
+ * Example: (see also demo.cache.mysql.php in /demo/)
24
+ *
25
+ * Normal getID3 usage (example):
26
+ *
27
+ * require_once 'getid3/getid3.php';
28
+ * $getID3 = new getID3;
29
+ * $getID3->encoding = 'UTF-8';
30
+ * $info1 = $getID3->analyze('file1.flac');
31
+ * $info2 = $getID3->analyze('file2.wv');
32
+ *
33
+ * getID3_cached usage:
34
+ *
35
+ * require_once 'getid3/getid3.php';
36
+ * require_once 'getid3/getid3/extension.cache.mysql.php';
37
+ * // 5th parameter (tablename) is optional, default is 'getid3_cache'
38
+ * $getID3 = new getID3_cached_mysql('localhost', 'database', 'username', 'password', 'tablename');
39
+ * $getID3->encoding = 'UTF-8';
40
+ * $info1 = $getID3->analyze('file1.flac');
41
+ * $info2 = $getID3->analyze('file2.wv');
42
+ *
43
+ *
44
+ * Supported Cache Types (this extension)
45
+ *
46
+ * SQL Databases:
47
+ *
48
+ * cache_type cache_options
49
+ * -------------------------------------------------------------------
50
+ * mysql host, database, username, password
51
+ *
52
+ *
53
+ * DBM-Style Databases: (use extension.cache.dbm)
54
+ *
55
+ * cache_type cache_options
56
+ * -------------------------------------------------------------------
57
+ * gdbm dbm_filename, lock_filename
58
+ * ndbm dbm_filename, lock_filename
59
+ * db2 dbm_filename, lock_filename
60
+ * db3 dbm_filename, lock_filename
61
+ * db4 dbm_filename, lock_filename (PHP5 required)
62
+ *
63
+ * PHP must have write access to both dbm_filename and lock_filename.
64
+ *
65
+ *
66
+ * Recommended Cache Types
67
+ *
68
+ * Infrequent updates, many reads any DBM
69
+ * Frequent updates mysql
70
+ */
71
+
72
+
73
+ class getID3_cached_mysql extends getID3
74
+ {
75
+
76
+ // private vars
77
+ private $cursor;
78
+ private $connection;
79
+
80
+
81
+ // public: constructor - see top of this file for cache type and cache_options
82
+ public function getID3_cached_mysql($host, $database, $username, $password, $table='getid3_cache') {
83
+
84
+ // Check for mysql support
85
+ if (!function_exists('mysql_pconnect')) {
86
+ throw new Exception('PHP not compiled with mysql support.');
87
+ }
88
+
89
+ // Connect to database
90
+ $this->connection = mysql_pconnect($host, $username, $password);
91
+ if (!$this->connection) {
92
+ throw new Exception('mysql_pconnect() failed - check permissions and spelling.');
93
+ }
94
+
95
+ // Select database
96
+ if (!mysql_select_db($database, $this->connection)) {
97
+ throw new Exception('Cannot use database '.$database);
98
+ }
99
+
100
+ // Set table
101
+ $this->table = $table;
102
+
103
+ // Create cache table if not exists
104
+ $this->create_table();
105
+
106
+ // Check version number and clear cache if changed
107
+ $version = '';
108
+ if ($this->cursor = mysql_query("SELECT `value` FROM `".mysql_real_escape_string($this->table)."` WHERE (`filename` = '".mysql_real_escape_string(getID3::VERSION)."') AND (`filesize` = '-1') AND (`filetime` = '-1') AND (`analyzetime` = '-1')", $this->connection)) {
109
+ list($version) = mysql_fetch_array($this->cursor);
110
+ }
111
+ if ($version != getID3::VERSION) {
112
+ $this->clear_cache();
113
+ }
114
+
115
+ parent::getID3();
116
+ }
117
+
118
+
119
+
120
+ // public: clear cache
121
+ public function clear_cache() {
122
+
123
+ $this->cursor = mysql_query("DELETE FROM `".mysql_real_escape_string($this->table)."`", $this->connection);
124
+ $this->cursor = mysql_query("INSERT INTO `".mysql_real_escape_string($this->table)."` VALUES ('".getID3::VERSION."', -1, -1, -1, '".getID3::VERSION."')", $this->connection);
125
+ }
126
+
127
+
128
+
129
+ // public: analyze file
130
+ public function analyze($filename) {
131
+
132
+ if (file_exists($filename)) {
133
+
134
+ // Short-hands
135
+ $filetime = filemtime($filename);
136
+ $filesize = filesize($filename);
137
+
138
+ // Lookup file
139
+ $this->cursor = mysql_query("SELECT `value` FROM `".mysql_real_escape_string($this->table)."` WHERE (`filename` = '".mysql_real_escape_string($filename)."') AND (`filesize` = '".mysql_real_escape_string($filesize)."') AND (`filetime` = '".mysql_real_escape_string($filetime)."')", $this->connection);
140
+ if (mysql_num_rows($this->cursor) > 0) {
141
+ // Hit
142
+ list($result) = mysql_fetch_array($this->cursor);
143
+ return unserialize(base64_decode($result));
144
+ }
145
+ }
146
+
147
+ // Miss
148
+ $analysis = parent::analyze($filename);
149
+
150
+ // Save result
151
+ if (file_exists($filename)) {
152
+ $this->cursor = mysql_query("INSERT INTO `".mysql_real_escape_string($this->table)."` (`filename`, `filesize`, `filetime`, `analyzetime`, `value`) VALUES ('".mysql_real_escape_string($filename)."', '".mysql_real_escape_string($filesize)."', '".mysql_real_escape_string($filetime)."', '".mysql_real_escape_string(time())."', '".mysql_real_escape_string(base64_encode(serialize($analysis)))."')", $this->connection);
153
+ }
154
+ return $analysis;
155
+ }
156
+
157
+
158
+
159
+ // private: (re)create sql table
160
+ private function create_table($drop=false) {
161
+
162
+ $this->cursor = mysql_query("CREATE TABLE IF NOT EXISTS `".mysql_real_escape_string($this->table)."` (
163
+ `filename` VARCHAR(255) NOT NULL DEFAULT '',
164
+ `filesize` INT(11) NOT NULL DEFAULT '0',
165
+ `filetime` INT(11) NOT NULL DEFAULT '0',
166
+ `analyzetime` INT(11) NOT NULL DEFAULT '0',
167
+ `value` TEXT NOT NULL,
168
+ PRIMARY KEY (`filename`,`filesize`,`filetime`)) ENGINE=MyISAM", $this->connection);
169
+ echo mysql_error($this->connection);
170
+ }
171
+ }
includes/getid3/extension.cache.sqlite3.php ADDED
@@ -0,0 +1,264 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /////////////////////////////////////////////////////////////////////////////////
3
+ /// getID3() by James Heinrich <info@getid3.org> //
4
+ // available at http://getid3.sourceforge.net //
5
+ // or http://www.getid3.org ///
6
+ /////////////////////////////////////////////////////////////////////////////////
7
+ /// //
8
+ // extension.cache.sqlite3.php - part of getID3() //
9
+ // Please see readme.txt for more information //
10
+ // ///
11
+ /////////////////////////////////////////////////////////////////////////////////
12
+ /// //
13
+ // MySQL extension written by Allan Hansen <ah�artemis*dk> //
14
+ // Table name mod by Carlo Capocasa <calro�carlocapocasa*com> //
15
+ // MySQL extension was reworked for SQLite3 by Karl G. Holz <newaeon�mac*com> //
16
+ // ///
17
+ /////////////////////////////////////////////////////////////////////////////////
18
+ /**
19
+ * This is a caching extension for getID3(). It works the exact same
20
+ * way as the getID3 class, but return cached information much faster
21
+ *
22
+ * Normal getID3 usage (example):
23
+ *
24
+ * require_once 'getid3/getid3.php';
25
+ * $getID3 = new getID3;
26
+ * $getID3->encoding = 'UTF-8';
27
+ * $info1 = $getID3->analyze('file1.flac');
28
+ * $info2 = $getID3->analyze('file2.wv');
29
+ *
30
+ * getID3_cached usage:
31
+ *
32
+ * require_once 'getid3/getid3.php';
33
+ * require_once 'getid3/extension.cache.sqlite3.php';
34
+ * // all parameters are optional, defaults are:
35
+ * $getID3 = new getID3_cached_sqlite3($table='getid3_cache', $hide=FALSE);
36
+ * $getID3->encoding = 'UTF-8';
37
+ * $info1 = $getID3->analyze('file1.flac');
38
+ * $info2 = $getID3->analyze('file2.wv');
39
+ *
40
+ *
41
+ * Supported Cache Types (this extension)
42
+ *
43
+ * SQL Databases:
44
+ *
45
+ * cache_type cache_options
46
+ * -------------------------------------------------------------------
47
+ * mysql host, database, username, password
48
+ *
49
+ * sqlite3 table='getid3_cache', hide=false (PHP5)
50
+ *
51
+
52
+ *** database file will be stored in the same directory as this script,
53
+ *** webserver must have write access to that directory!
54
+ *** set $hide to TRUE to prefix db file with .ht to pervent access from web client
55
+ *** this is a default setting in the Apache configuration:
56
+
57
+ # The following lines prevent .htaccess and .htpasswd files from being viewed by Web clients.
58
+
59
+ <Files ~ "^\.ht">
60
+ Order allow,deny
61
+ Deny from all
62
+ Satisfy all
63
+ </Files>
64
+
65
+ ********************************************************************************
66
+ *
67
+ * -------------------------------------------------------------------
68
+ * DBM-Style Databases: (use extension.cache.dbm)
69
+ *
70
+ * cache_type cache_options
71
+ * -------------------------------------------------------------------
72
+ * gdbm dbm_filename, lock_filename
73
+ * ndbm dbm_filename, lock_filename
74
+ * db2 dbm_filename, lock_filename
75
+ * db3 dbm_filename, lock_filename
76
+ * db4 dbm_filename, lock_filename (PHP5 required)
77
+ *
78
+ * PHP must have write access to both dbm_filename and lock_filename.
79
+ *
80
+ * Recommended Cache Types
81
+ *
82
+ * Infrequent updates, many reads any DBM
83
+ * Frequent updates mysql
84
+ ********************************************************************************
85
+ *
86
+ * IMHO this is still a bit slow, I'm using this with MP4/MOV/ M4v files
87
+ * there is a plan to add directory scanning and analyzing to make things work much faster
88
+ *
89
+ *
90
+ */
91
+ class getID3_cached_sqlite3 extends getID3 {
92
+
93
+ /**
94
+ * __construct()
95
+ * @param string $table holds name of sqlite table
96
+ * @return type
97
+ */
98
+ public function __construct($table='getid3_cache', $hide=false) {
99
+ $this->table = $table; // Set table
100
+ $file = dirname(__FILE__).'/'.basename(__FILE__, 'php').'sqlite';
101
+ if ($hide) {
102
+ $file = dirname(__FILE__).'/.ht.'.basename(__FILE__, 'php').'sqlite';
103
+ }
104
+ $this->db = new SQLite3($file);
105
+ $db = $this->db;
106
+ $this->create_table(); // Create cache table if not exists
107
+ $version = '';
108
+ $sql = $this->version_check;
109
+ $stmt = $db->prepare($sql);
110
+ $stmt->bindValue(':filename', getID3::VERSION, SQLITE3_TEXT);
111
+ $result = $stmt->execute();
112
+ list($version) = $result->fetchArray();
113
+ if ($version != getID3::VERSION) { // Check version number and clear cache if changed
114
+ $this->clear_cache();
115
+ }
116
+ return parent::__construct();
117
+ }
118
+
119
+ /**
120
+ * close the database connection
121
+ */
122
+ public function __destruct() {
123
+ $db=$this->db;
124
+ $db->close();
125
+ }
126
+
127
+ /**
128
+ * hold the sqlite db
129
+ * @var SQLite Resource
130
+ */
131
+ private $db;
132
+
133
+ /**
134
+ * table to use for caching
135
+ * @var string $table
136
+ */
137
+ private $table;
138
+
139
+ /**
140
+ * clear the cache
141
+ * @access private
142
+ * @return type
143
+ */
144
+ private function clear_cache() {
145
+ $db = $this->db;
146
+ $sql = $this->delete_cache;
147
+ $db->exec($sql);
148
+ $sql = $this->set_version;
149
+ $stmt = $db->prepare($sql);
150
+ $stmt->bindValue(':filename', getID3::VERSION, SQLITE3_TEXT);
151
+ $stmt->bindValue(':dirname', getID3::VERSION, SQLITE3_TEXT);
152
+ $stmt->bindValue(':val', getID3::VERSION, SQLITE3_TEXT);
153
+ return $stmt->execute();
154
+ }
155
+
156
+ /**
157
+ * analyze file and cache them, if cached pull from the db
158
+ * @param type $filename
159
+ * @return boolean
160
+ */
161
+ public function analyze($filename) {
162
+ if (!file_exists($filename)) {
163
+ return false;
164
+ }
165
+ // items to track for caching
166
+ $filetime = filemtime($filename);
167
+ $filesize = filesize($filename);
168
+ // this will be saved for a quick directory lookup of analized files
169
+ // ... why do 50 seperate sql quries when you can do 1 for the same result
170
+ $dirname = dirname($filename);
171
+ // Lookup file
172
+ $db = $this->db;
173
+ $sql = $this->get_id3_data;
174
+ $stmt = $db->prepare($sql);
175
+ $stmt->bindValue(':filename', $filename, SQLITE3_TEXT);
176
+ $stmt->bindValue(':filesize', $filesize, SQLITE3_INTEGER);
177
+ $stmt->bindValue(':filetime', $filetime, SQLITE3_INTEGER);
178
+ $res = $stmt->execute();
179
+ list($result) = $res->fetchArray();
180
+ if (count($result) > 0 ) {
181
+ return unserialize(base64_decode($result));
182
+ }
183
+ // if it hasn't been analyzed before, then do it now
184
+ $analysis = parent::analyze($filename);
185
+ // Save result
186
+ $sql = $this->cache_file;
187
+ $stmt = $db->prepare($sql);
188
+ $stmt->bindValue(':filename', $filename, SQLITE3_TEXT);
189
+ $stmt->bindValue(':dirname', $dirname, SQLITE3_TEXT);
190
+ $stmt->bindValue(':filesize', $filesize, SQLITE3_INTEGER);
191
+ $stmt->bindValue(':filetime', $filetime, SQLITE3_INTEGER);
192
+ $stmt->bindValue(':atime', time(), SQLITE3_INTEGER);
193
+ $stmt->bindValue(':val', base64_encode(serialize($analysis)), SQLITE3_TEXT);
194
+ $res = $stmt->execute();
195
+ return $analysis;
196
+ }
197
+
198
+ /**
199
+ * create data base table
200
+ * this is almost the same as MySQL, with the exception of the dirname being added
201
+ * @return type
202
+ */
203
+ private function create_table() {
204
+ $db = $this->db;
205
+ $sql = $this->make_table;
206
+ return $db->exec($sql);
207
+ }
208
+
209
+ /**
210
+ * get cached directory
211
+ *
212
+ * This function is not in the MySQL extention, it's ment to speed up requesting multiple files
213
+ * which is ideal for podcasting, playlists, etc.
214
+ *
215
+ * @access public
216
+ * @param string $dir directory to search the cache database for
217
+ * @return array return an array of matching id3 data
218
+ */
219
+ public function get_cached_dir($dir) {
220
+ $db = $this->db;
221
+ $rows = array();
222
+ $sql = $this->get_cached_dir;
223
+ $stmt = $db->prepare($sql);
224
+ $stmt->bindValue(':dirname', $dir, SQLITE3_TEXT);
225
+ $res = $stmt->execute();
226
+ while ($row=$res->fetchArray()) {
227
+ $rows[] = unserialize(base64_decode($row));
228
+ }
229
+ return $rows;
230
+ }
231
+
232
+ /**
233
+ * use the magical __get() for sql queries
234
+ *
235
+ * access as easy as $this->{case name}, returns NULL if query is not found
236
+ */
237
+ public function __get($name) {
238
+ switch($name) {
239
+ case 'version_check':
240
+ return "SELECT val FROM $this->table WHERE filename = :filename AND filesize = '-1' AND filetime = '-1' AND analyzetime = '-1'";
241
+ break;
242
+ case 'delete_cache':
243
+ return "DELETE FROM $this->table";
244
+ break;
245
+ case 'set_version':
246
+ return "INSERT INTO $this->table (filename, dirname, filesize, filetime, analyzetime, val) VALUES (:filename, :dirname, -1, -1, -1, :val)";
247
+ break;
248
+ case 'get_id3_data':
249
+ return "SELECT val FROM $this->table WHERE filename = :filename AND filesize = :filesize AND filetime = :filetime";
250
+ break;
251
+ case 'cache_file':
252
+ return "INSERT INTO $this->table (filename, dirname, filesize, filetime, analyzetime, val) VALUES (:filename, :dirname, :filesize, :filetime, :atime, :val)";
253
+ break;
254
+ case 'make_table':
255
+ return "CREATE TABLE IF NOT EXISTS $this->table (filename VARCHAR(255) NOT NULL DEFAULT '', dirname VARCHAR(255) NOT NULL DEFAULT '', filesize INT(11) NOT NULL DEFAULT '0', filetime INT(11) NOT NULL DEFAULT '0', analyzetime INT(11) NOT NULL DEFAULT '0', val text not null, PRIMARY KEY (filename, filesize, filetime))";
256
+ break;
257
+ case 'get_cached_dir':
258
+ return "SELECT val FROM $this->table WHERE dirname = :dirname";
259
+ break;
260
+ }
261
+ return null;
262
+ }
263
+
264
+ }
{view → includes}/getid3/getid3.lib.php RENAMED
@@ -1,1309 +1,1342 @@
1
- <?php
2
- /////////////////////////////////////////////////////////////////
3
- /// getID3() by James Heinrich <info@getid3.org> //
4
- // available at http://getid3.sourceforge.net //
5
- // or http://www.getid3.org //
6
- /////////////////////////////////////////////////////////////////
7
- // //
8
- // getid3.lib.php - part of getID3() //
9
- // See readme.txt for more details //
10
- // ///
11
- /////////////////////////////////////////////////////////////////
12
-
13
-
14
- class getid3_lib
15
- {
16
-
17
- function PrintHexBytes($string, $hex=true, $spaces=true, $htmlsafe=true) {
18
- $returnstring = '';
19
- for ($i = 0; $i < strlen($string); $i++) {
20
- if ($hex) {
21
- $returnstring .= str_pad(dechex(ord($string{$i})), 2, '0', STR_PAD_LEFT);
22
- } else {
23
- $returnstring .= ' '.(ereg("[\x20-\x7E]", $string{$i}) ? $string{$i} : '�');
24
- }
25
- if ($spaces) {
26
- $returnstring .= ' ';
27
- }
28
- }
29
- if ($htmlsafe) {
30
- $returnstring = htmlentities($returnstring);
31
- }
32
- return $returnstring;
33
- }
34
-
35
- function SafeStripSlashes($text) {
36
- if (get_magic_quotes_gpc()) {
37
- return stripslashes($text);
38
- }
39
- return $text;
40
- }
41
-
42
-
43
- function trunc($floatnumber) {
44
- // truncates a floating-point number at the decimal point
45
- // returns int (if possible, otherwise float)
46
- if ($floatnumber >= 1) {
47
- $truncatednumber = floor($floatnumber);
48
- } elseif ($floatnumber <= -1) {
49
- $truncatednumber = ceil($floatnumber);
50
- } else {
51
- $truncatednumber = 0;
52
- }
53
- if ($truncatednumber <= 1073741824) { // 2^30
54
- $truncatednumber = (int) $truncatednumber;
55
- }
56
- return $truncatednumber;
57
- }
58
-
59
-
60
- function CastAsInt($floatnum) {
61
- // convert to float if not already
62
- $floatnum = (float) $floatnum;
63
-
64
- // convert a float to type int, only if possible
65
- if (getid3_lib::trunc($floatnum) == $floatnum) {
66
- // it's not floating point
67
- if ($floatnum <= 2147483647) { // 2^31
68
- // it's within int range
69
- $floatnum = (int) $floatnum;
70
- }
71
- }
72
- return $floatnum;
73
- }
74
-
75
-
76
- function DecimalBinary2Float($binarynumerator) {
77
- $numerator = getid3_lib::Bin2Dec($binarynumerator);
78
- $denominator = getid3_lib::Bin2Dec('1'.str_repeat('0', strlen($binarynumerator)));
79
- return ($numerator / $denominator);
80
- }
81
-
82
-
83
- function NormalizeBinaryPoint($binarypointnumber, $maxbits=52) {
84
- // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html
85
- if (strpos($binarypointnumber, '.') === false) {
86
- $binarypointnumber = '0.'.$binarypointnumber;
87
- } elseif ($binarypointnumber{0} == '.') {
88
- $binarypointnumber = '0'.$binarypointnumber;
89
- }
90
- $exponent = 0;
91
- while (($binarypointnumber{0} != '1') || (substr($binarypointnumber, 1, 1) != '.')) {
92
- if (substr($binarypointnumber, 1, 1) == '.') {
93
- $exponent--;
94
- $binarypointnumber = substr($binarypointnumber, 2, 1).'.'.substr($binarypointnumber, 3);
95
- } else {
96
- $pointpos = strpos($binarypointnumber, '.');
97
- $exponent += ($pointpos - 1);
98
- $binarypointnumber = str_replace('.', '', $binarypointnumber);
99
- $binarypointnumber = $binarypointnumber{0}.'.'.substr($binarypointnumber, 1);
100
- }
101
- }
102
- $binarypointnumber = str_pad(substr($binarypointnumber, 0, $maxbits + 2), $maxbits + 2, '0', STR_PAD_RIGHT);
103
- return array('normalized'=>$binarypointnumber, 'exponent'=>(int) $exponent);
104
- }
105
-
106
-
107
- function Float2BinaryDecimal($floatvalue) {
108
- // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html
109
- $maxbits = 128; // to how many bits of precision should the calculations be taken?
110
- $intpart = getid3_lib::trunc($floatvalue);
111
- $floatpart = abs($floatvalue - $intpart);
112
- $pointbitstring = '';
113
- while (($floatpart != 0) && (strlen($pointbitstring) < $maxbits)) {
114
- $floatpart *= 2;
115
- $pointbitstring .= (string) getid3_lib::trunc($floatpart);
116
- $floatpart -= getid3_lib::trunc($floatpart);
117
- }
118
- $binarypointnumber = decbin($intpart).'.'.$pointbitstring;
119
- return $binarypointnumber;
120
- }
121
-
122
-
123
- function Float2String($floatvalue, $bits) {
124
- // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee-expl.html
125
- switch ($bits) {
126
- case 32:
127
- $exponentbits = 8;
128
- $fractionbits = 23;
129
- break;
130
-
131
- case 64:
132
- $exponentbits = 11;
133
- $fractionbits = 52;
134
- break;
135
-
136
- default:
137
- return false;
138
- break;
139
- }
140
- if ($floatvalue >= 0) {
141
- $signbit = '0';
142
- } else {
143
- $signbit = '1';
144
- }
145
- $normalizedbinary = getid3_lib::NormalizeBinaryPoint(getid3_lib::Float2BinaryDecimal($floatvalue), $fractionbits);
146
- $biasedexponent = pow(2, $exponentbits - 1) - 1 + $normalizedbinary['exponent']; // (127 or 1023) +/- exponent
147
- $exponentbitstring = str_pad(decbin($biasedexponent), $exponentbits, '0', STR_PAD_LEFT);
148
- $fractionbitstring = str_pad(substr($normalizedbinary['normalized'], 2), $fractionbits, '0', STR_PAD_RIGHT);
149
-
150
- return getid3_lib::BigEndian2String(getid3_lib::Bin2Dec($signbit.$exponentbitstring.$fractionbitstring), $bits % 8, false);
151
- }
152
-
153
-
154
- function LittleEndian2Float($byteword) {
155
- return getid3_lib::BigEndian2Float(strrev($byteword));
156
- }
157
-
158
-
159
- function BigEndian2Float($byteword) {
160
- // ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic
161
- // http://www.psc.edu/general/software/packages/ieee/ieee.html
162
- // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html
163
-
164
- $bitword = getid3_lib::BigEndian2Bin($byteword);
165
- if (!$bitword) {
166
- return 0;
167
- }
168
- $signbit = $bitword{0};
169
-
170
- switch (strlen($byteword) * 8) {
171
- case 32:
172
- $exponentbits = 8;
173
- $fractionbits = 23;
174
- break;
175
-
176
- case 64:
177
- $exponentbits = 11;
178
- $fractionbits = 52;
179
- break;
180
-
181
- case 80:
182
- // 80-bit Apple SANE format
183
- // http://www.mactech.com/articles/mactech/Vol.06/06.01/SANENormalized/
184
- $exponentstring = substr($bitword, 1, 15);
185
- $isnormalized = intval($bitword{16});
186
- $fractionstring = substr($bitword, 17, 63);
187
- $exponent = pow(2, getid3_lib::Bin2Dec($exponentstring) - 16383);
188
- $fraction = $isnormalized + getid3_lib::DecimalBinary2Float($fractionstring);
189
- $floatvalue = $exponent * $fraction;
190
- if ($signbit == '1') {
191
- $floatvalue *= -1;
192
- }
193
- return $floatvalue;
194
- break;
195
-
196
- default:
197
- return false;
198
- break;
199
- }
200
- $exponentstring = substr($bitword, 1, $exponentbits);
201
- $fractionstring = substr($bitword, $exponentbits + 1, $fractionbits);
202
- $exponent = getid3_lib::Bin2Dec($exponentstring);
203
- $fraction = getid3_lib::Bin2Dec($fractionstring);
204
-
205
- if (($exponent == (pow(2, $exponentbits) - 1)) && ($fraction != 0)) {
206
- // Not a Number
207
- $floatvalue = false;
208
- } elseif (($exponent == (pow(2, $exponentbits) - 1)) && ($fraction == 0)) {
209
- if ($signbit == '1') {
210
- $floatvalue = '-infinity';
211
- } else {
212
- $floatvalue = '+infinity';
213
- }
214
- } elseif (($exponent == 0) && ($fraction == 0)) {
215
- if ($signbit == '1') {
216
- $floatvalue = -0;
217
- } else {
218
- $floatvalue = 0;
219
- }
220
- $floatvalue = ($signbit ? 0 : -0);
221
- } elseif (($exponent == 0) && ($fraction != 0)) {
222
- // These are 'unnormalized' values
223
- $floatvalue = pow(2, (-1 * (pow(2, $exponentbits - 1) - 2))) * getid3_lib::DecimalBinary2Float($fractionstring);
224
- if ($signbit == '1') {
225
- $floatvalue *= -1;
226
- }
227
- } elseif ($exponent != 0) {
228
- $floatvalue = pow(2, ($exponent - (pow(2, $exponentbits - 1) - 1))) * (1 + getid3_lib::DecimalBinary2Float($fractionstring));
229
- if ($signbit == '1') {
230
- $floatvalue *= -1;
231
- }
232
- }
233
- return (float) $floatvalue;
234
- }
235
-
236
-
237
- function BigEndian2Int($byteword, $synchsafe=false, $signed=false) {
238
- $intvalue = 0;
239
- $bytewordlen = strlen($byteword);
240
- for ($i = 0; $i < $bytewordlen; $i++) {
241
- if ($synchsafe) { // disregard MSB, effectively 7-bit bytes
242
- $intvalue = $intvalue | (ord($byteword{$i}) & 0x7F) << (($bytewordlen - 1 - $i) * 7);
243
- } else {
244
- $intvalue += ord($byteword{$i}) * pow(256, ($bytewordlen - 1 - $i));
245
- }
246
- }
247
- if ($signed && !$synchsafe) {
248
- // synchsafe ints are not allowed to be signed
249
- switch ($bytewordlen) {
250
- case 1:
251
- case 2:
252
- case 3:
253
- case 4:
254
- $signmaskbit = 0x80 << (8 * ($bytewordlen - 1));
255
- if ($intvalue & $signmaskbit) {
256
- $intvalue = 0 - ($intvalue & ($signmaskbit - 1));
257
- }
258
- break;
259
-
260
- default:
261
- die('ERROR: Cannot have signed integers larger than 32-bits in getid3_lib::BigEndian2Int()');
262
- break;
263
- }
264
- }
265
- return getid3_lib::CastAsInt($intvalue);
266
- }
267
-
268
-
269
- function LittleEndian2Int($byteword, $signed=false) {
270
- return getid3_lib::BigEndian2Int(strrev($byteword), false, $signed);
271
- }
272
-
273
-
274
- function BigEndian2Bin($byteword) {
275
- $binvalue = '';
276
- $bytewordlen = strlen($byteword);
277
- for ($i = 0; $i < $bytewordlen; $i++) {
278
- $binvalue .= str_pad(decbin(ord($byteword{$i})), 8, '0', STR_PAD_LEFT);
279
- }
280
- return $binvalue;
281
- }
282
-
283
-
284
- function BigEndian2String($number, $minbytes=1, $synchsafe=false, $signed=false) {
285
- if ($number < 0) {
286
- return false;
287
- }
288
- $maskbyte = (($synchsafe || $signed) ? 0x7F : 0xFF);
289
- $intstring = '';
290
- if ($signed) {
291
- if ($minbytes > 4) {
292
- die('ERROR: Cannot have signed integers larger than 32-bits in getid3_lib::BigEndian2String()');
293
- }
294
- $number = $number & (0x80 << (8 * ($minbytes - 1)));
295
- }
296
- while ($number != 0) {
297
- $quotient = ($number / ($maskbyte + 1));
298
- $intstring = chr(ceil(($quotient - floor($quotient)) * $maskbyte)).$intstring;
299
- $number = floor($quotient);
300
- }
301
- return str_pad($intstring, $minbytes, "\x00", STR_PAD_LEFT);
302
- }
303
-
304
-
305
- function Dec2Bin($number) {
306
- while ($number >= 256) {
307
- $bytes[] = (($number / 256) - (floor($number / 256))) * 256;
308
- $number = floor($number / 256);
309
- }
310
- $bytes[] = $number;
311
- $binstring = '';
312
- for ($i = 0; $i < count($bytes); $i++) {
313
- $binstring = (($i == count($bytes) - 1) ? decbin($bytes[$i]) : str_pad(decbin($bytes[$i]), 8, '0', STR_PAD_LEFT)).$binstring;
314
- }
315
- return $binstring;
316
- }
317
-
318
-
319
- function Bin2Dec($binstring, $signed=false) {
320
- $signmult = 1;
321
- if ($signed) {
322
- if ($binstring{0} == '1') {
323
- $signmult = -1;
324
- }
325
- $binstring = substr($binstring, 1);
326
- }
327
- $decvalue = 0;
328
- for ($i = 0; $i < strlen($binstring); $i++) {
329
- $decvalue += ((int) substr($binstring, strlen($binstring) - $i - 1, 1)) * pow(2, $i);
330
- }
331
- return getid3_lib::CastAsInt($decvalue * $signmult);
332
- }
333
-
334
-
335
- function Bin2String($binstring) {
336
- // return 'hi' for input of '0110100001101001'
337
- $string = '';
338
- $binstringreversed = strrev($binstring);
339
- for ($i = 0; $i < strlen($binstringreversed); $i += 8) {
340
- $string = chr(getid3_lib::Bin2Dec(strrev(substr($binstringreversed, $i, 8)))).$string;
341
- }
342
- return $string;
343
- }
344
-
345
-
346
- function LittleEndian2String($number, $minbytes=1, $synchsafe=false) {
347
- $intstring = '';
348
- while ($number > 0) {
349
- if ($synchsafe) {
350
- $intstring = $intstring.chr($number & 127);
351
- $number >>= 7;
352
- } else {
353
- $intstring = $intstring.chr($number & 255);
354
- $number >>= 8;
355
- }
356
- }
357
- return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT);
358
- }
359
-
360
-
361
- function array_merge_clobber($array1, $array2) {
362
- // written by kc�hireability*com
363
- // taken from http://www.php.net/manual/en/function.array-merge-recursive.php
364
- if (!is_array($array1) || !is_array($array2)) {
365
- return false;
366
- }
367
- $newarray = $array1;
368
- foreach ($array2 as $key => $val) {
369
- if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
370
- $newarray[$key] = getid3_lib::array_merge_clobber($newarray[$key], $val);
371
- } else {
372
- $newarray[$key] = $val;
373
- }
374
- }
375
- return $newarray;
376
- }
377
-
378
-
379
- function array_merge_noclobber($array1, $array2) {
380
- if (!is_array($array1) || !is_array($array2)) {
381
- return false;
382
- }
383
- $newarray = $array1;
384
- foreach ($array2 as $key => $val) {
385
- if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
386
- $newarray[$key] = getid3_lib::array_merge_noclobber($newarray[$key], $val);
387
- } elseif (!isset($newarray[$key])) {
388
- $newarray[$key] = $val;
389
- }
390
- }
391
- return $newarray;
392
- }
393
-
394
-
395
- function fileextension($filename, $numextensions=1) {
396
- if (strstr($filename, '.')) {
397
- $reversedfilename = strrev($filename);
398
- $offset = 0;
399
- for ($i = 0; $i < $numextensions; $i++) {
400
- $offset = strpos($reversedfilename, '.', $offset + 1);
401
- if ($offset === false) {
402
- return '';
403
- }
404
- }
405
- return strrev(substr($reversedfilename, 0, $offset));
406
- }
407
- return '';
408
- }
409
-
410
-
411
- function PlaytimeString($playtimeseconds) {
412
- $sign = (($playtimeseconds < 0) ? '-' : '');
413
- $playtimeseconds = abs($playtimeseconds);
414
- $contentseconds = round((($playtimeseconds / 60) - floor($playtimeseconds / 60)) * 60);
415
- $contentminutes = floor($playtimeseconds / 60);
416
- if ($contentseconds >= 60) {
417
- $contentseconds -= 60;
418
- $contentminutes++;
419
- }
420
- return $sign.intval($contentminutes).':'.str_pad($contentseconds, 2, 0, STR_PAD_LEFT);
421
- }
422
-
423
-
424
- function image_type_to_mime_type($imagetypeid) {
425
- // only available in PHP v4.3.0+
426
- static $image_type_to_mime_type = array();
427
- if (empty($image_type_to_mime_type)) {
428
- $image_type_to_mime_type[1] = 'image/gif'; // GIF
429
- $image_type_to_mime_type[2] = 'image/jpeg'; // JPEG
430
- $image_type_to_mime_type[3] = 'image/png'; // PNG
431
- $image_type_to_mime_type[4] = 'application/x-shockwave-flash'; // Flash
432
- $image_type_to_mime_type[5] = 'image/psd'; // PSD
433
- $image_type_to_mime_type[6] = 'image/bmp'; // BMP
434
- $image_type_to_mime_type[7] = 'image/tiff'; // TIFF: little-endian (Intel)
435
- $image_type_to_mime_type[8] = 'image/tiff'; // TIFF: big-endian (Motorola)
436
- //$image_type_to_mime_type[9] = 'image/jpc'; // JPC
437
- //$image_type_to_mime_type[10] = 'image/jp2'; // JPC
438
- //$image_type_to_mime_type[11] = 'image/jpx'; // JPC
439
- //$image_type_to_mime_type[12] = 'image/jb2'; // JPC
440
- $image_type_to_mime_type[13] = 'application/x-shockwave-flash'; // Shockwave
441
- $image_type_to_mime_type[14] = 'image/iff'; // IFF
442
- }
443
- return (isset($image_type_to_mime_type[$imagetypeid]) ? $image_type_to_mime_type[$imagetypeid] : 'application/octet-stream');
444
- }
445
-
446
-
447
- function DateMac2Unix($macdate) {
448
- // Macintosh timestamp: seconds since 00:00h January 1, 1904
449
- // UNIX timestamp: seconds since 00:00h January 1, 1970
450
- return getid3_lib::CastAsInt($macdate - 2082844800);
451
- }
452
-
453
-
454
- function FixedPoint8_8($rawdata) {
455
- return getid3_lib::BigEndian2Int(substr($rawdata, 0, 1)) + (float) (getid3_lib::BigEndian2Int(substr($rawdata, 1, 1)) / pow(2, 8));
456
- }
457
-
458
-
459
- function FixedPoint16_16($rawdata) {
460
- return getid3_lib::BigEndian2Int(substr($rawdata, 0, 2)) + (float) (getid3_lib::BigEndian2Int(substr($rawdata, 2, 2)) / pow(2, 16));
461
- }
462
-
463
-
464
- function FixedPoint2_30($rawdata) {
465
- $binarystring = getid3_lib::BigEndian2Bin($rawdata);
466
- return getid3_lib::Bin2Dec(substr($binarystring, 0, 2)) + (float) (getid3_lib::Bin2Dec(substr($binarystring, 2, 30)) / 1073741824);
467
- }
468
-
469
-
470
- function CreateDeepArray($ArrayPath, $Separator, $Value) {
471
- // assigns $Value to a nested array path:
472
- // $foo = getid3_lib::CreateDeepArray('/path/to/my', '/', 'file.txt')
473
- // is the same as:
474
- // $foo = array('path'=>array('to'=>'array('my'=>array('file.txt'))));
475
- // or
476
- // $foo['path']['to']['my'] = 'file.txt';
477
- while ($ArrayPath && ($ArrayPath{0} == $Separator)) {
478
- $ArrayPath = substr($ArrayPath, 1);
479
- }
480
- if (($pos = strpos($ArrayPath, $Separator)) !== false) {
481
- $ReturnedArray[substr($ArrayPath, 0, $pos)] = getid3_lib::CreateDeepArray(substr($ArrayPath, $pos + 1), $Separator, $Value);
482
- } else {
483
- $ReturnedArray[$ArrayPath] = $Value;
484
- }
485
- return $ReturnedArray;
486
- }
487
-
488
- function array_max($arraydata, $returnkey=false) {
489
- $maxvalue = false;
490
- $maxkey = false;
491
- foreach ($arraydata as $key => $value) {
492
- if (!is_array($value)) {
493
- if ($value > $maxvalue) {
494
- $maxvalue = $value;
495
- $maxkey = $key;
496
- }
497
- }
498
- }
499
- return ($returnkey ? $maxkey : $maxvalue);
500
- }
501
-
502
- function array_min($arraydata, $returnkey=false) {
503
- $minvalue = false;
504
- $minkey = false;
505
- foreach ($arraydata as $key => $value) {
506
- if (!is_array($value)) {
507
- if ($value > $minvalue) {
508
- $minvalue = $value;
509
- $minkey = $key;
510
- }
511
- }
512
- }
513
- return ($returnkey ? $minkey : $minvalue);
514
- }
515
-
516
-
517
- function md5_file($file) {
518
-
519
- // md5_file() exists in PHP 4.2.0+.
520
- if (function_exists('md5_file')) {
521
- return md5_file($file);
522
- }
523
-
524
- if (GETID3_OS_ISWINDOWS) {
525
-
526
- $RequiredFiles = array('cygwin1.dll', 'md5sum.exe');
527
- foreach ($RequiredFiles as $required_file) {
528
- if (!is_readable(GETID3_HELPERAPPSDIR.$required_file)) {
529
- die(implode(' and ', $RequiredFiles).' are required in '.GETID3_HELPERAPPSDIR.' for getid3_lib::md5_file() to function under Windows in PHP < v4.2.0');
530
- }
531
- }
532
- $commandline = GETID3_HELPERAPPSDIR.'md5sum.exe "'.str_replace('/', DIRECTORY_SEPARATOR, $file).'"';
533
- if (ereg("^[\\]?([0-9a-f]{32})", strtolower(`$commandline`), $r)) {
534
- return $r[1];
535
- }
536
-
537
- } else {
538
-
539
- // The following works under UNIX only
540
- $file = str_replace('`', '\\`', $file);
541
- if (ereg("^([0-9a-f]{32})[ \t\n\r]", `md5sum "$file"`, $r)) {
542
- return $r[1];
543
- }
544
-
545
- }
546
- return false;
547
- }
548
-
549
-
550
- function sha1_file($file) {
551
-
552
- // sha1_file() exists in PHP 4.3.0+.
553
- if (function_exists('sha1_file')) {
554
- return sha1_file($file);
555
- }
556
-
557
- $file = str_replace('`', '\\`', $file);
558
-
559
- if (GETID3_OS_ISWINDOWS) {
560
-
561
- $RequiredFiles = array('cygwin1.dll', 'sha1sum.exe');
562
- foreach ($RequiredFiles as $required_file) {
563
- if (!is_readable(GETID3_HELPERAPPSDIR.$required_file)) {
564
- die(implode(' and ', $RequiredFiles).' are required in '.GETID3_HELPERAPPSDIR.' for getid3_lib::sha1_file() to function under Windows in PHP < v4.3.0');
565
- }
566
- }
567
- $commandline = GETID3_HELPERAPPSDIR.'sha1sum.exe "'.str_replace('/', DIRECTORY_SEPARATOR, $file).'"';
568
- if (ereg("^sha1=([0-9a-f]{40})", strtolower(`$commandline`), $r)) {
569
- return $r[1];
570
- }
571
-
572
- } else {
573
-
574
- $commandline = 'sha1sum '.escapeshellarg($file).'';
575
- if (ereg("^([0-9a-f]{40})[ \t\n\r]", strtolower(`$commandline`), $r)) {
576
- return $r[1];
577
- }
578
-
579
- }
580
-
581
- return false;
582
- }
583
-
584
-
585
- // Allan Hansen <ah�artemis*dk>
586
- // getid3_lib::md5_data() - returns md5sum for a file from startuing position to absolute end position
587
- function hash_data($file, $offset, $end, $algorithm) {
588
- if ($end >= pow(2, 31)) {
589
- return false;
590
- }
591
-
592
- switch ($algorithm) {
593
- case 'md5':
594
- $hash_function = 'md5_file';
595
- $unix_call = 'md5sum';
596
- $windows_call = 'md5sum.exe';
597
- $hash_length = 32;
598
- break;
599
-
600
- case 'sha1':
601
- $hash_function = 'sha1_file';
602
- $unix_call = 'sha1sum';
603
- $windows_call = 'sha1sum.exe';
604
- $hash_length = 40;
605
- break;
606
-
607
- default:
608
- die('Invalid algorithm ('.$algorithm.') in getid3_lib::hash_data()');
609
- break;
610
- }
611
- $size = $end - $offset;
612
- while (true) {
613
- if (GETID3_OS_ISWINDOWS) {
614
-
615
- // It seems that sha1sum.exe for Windows only works on physical files, does not accept piped data
616
- // Fall back to create-temp-file method:
617
- if ($algorithm == 'sha1') {
618
- break;
619
- }
620
-
621
- $RequiredFiles = array('cygwin1.dll', 'head.exe', 'tail.exe', $windows_call);
622
- foreach ($RequiredFiles as $required_file) {
623
- if (!is_readable(GETID3_HELPERAPPSDIR.$required_file)) {
624
- // helper apps not available - fall back to old method
625
- break;
626
- }
627
- }
628
- $commandline = GETID3_HELPERAPPSDIR.'head.exe -c '.$end.' "'.escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $file)).'" | ';
629
- $commandline .= GETID3_HELPERAPPSDIR.'tail.exe -c '.$size.' | ';
630
- $commandline .= GETID3_HELPERAPPSDIR.$windows_call;
631
-
632
- } else {
633
-
634
- $commandline = 'head -c'.$end.' '.escapeshellarg($file).' | ';
635
- $commandline .= 'tail -c'.$size.' | ';
636
- $commandline .= $unix_call;
637
-
638
- }
639
- if ((bool) ini_get('safe_mode')) {
640
- $ThisFileInfo['warning'][] = 'PHP running in Safe Mode - backtick operator not available, using slower non-system-call '.$algorithm.' algorithm';
641
- break;
642
- }
643
- return substr(`$commandline`, 0, $hash_length);
644
- }
645
-
646
- // try to create a temporary file in the system temp directory - invalid dirname should force to system temp dir
647
- if (($data_filename = tempnam('*', 'getID3')) === false) {
648
- // can't find anywhere to create a temp file, just die
649
- return false;
650
- }
651
-
652
- // Init
653
- $result = false;
654
-
655
- // copy parts of file
656
- if ($fp = @fopen($file, 'rb')) {
657
-
658
- if ($fp_data = @fopen($data_filename, 'wb')) {
659
-
660
- fseek($fp, $offset, SEEK_SET);
661
- $byteslefttowrite = $end - $offset;
662
- while (($byteslefttowrite > 0) && ($buffer = fread($fp, GETID3_FREAD_BUFFER_SIZE))) {
663
- $byteswritten = fwrite($fp_data, $buffer, $byteslefttowrite);
664
- $byteslefttowrite -= $byteswritten;
665
- }
666
- fclose($fp_data);
667
- $result = getid3_lib::$hash_function($data_filename);
668
-
669
- }
670
- fclose($fp);
671
- }
672
- unlink($data_filename);
673
- return $result;
674
- }
675
-
676
-
677
- function iconv_fallback_int_utf8($charval) {
678
- if ($charval < 128) {
679
- // 0bbbbbbb
680
- $newcharstring = chr($charval);
681
- } elseif ($charval < 2048) {
682
- // 110bbbbb 10bbbbbb
683
- $newcharstring = chr(($charval >> 6) | 0xC0);
684
- $newcharstring .= chr(($charval & 0x3F) | 0x80);
685
- } elseif ($charval < 65536) {
686
- // 1110bbbb 10bbbbbb 10bbbbbb
687
- $newcharstring = chr(($charval >> 12) | 0xE0);
688
- $newcharstring .= chr(($charval >> 6) | 0xC0);
689
- $newcharstring .= chr(($charval & 0x3F) | 0x80);
690
- } else {
691
- // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
692
- $newcharstring = chr(($charval >> 18) | 0xF0);
693
- $newcharstring .= chr(($charval >> 12) | 0xC0);
694
- $newcharstring .= chr(($charval >> 6) | 0xC0);
695
- $newcharstring .= chr(($charval & 0x3F) | 0x80);
696
- }
697
- return $newcharstring;
698
- }
699
-
700
- // ISO-8859-1 => UTF-8
701
- function iconv_fallback_iso88591_utf8($string, $bom=false) {
702
- if (function_exists('utf8_encode')) {
703
- return utf8_encode($string);
704
- }
705
- // utf8_encode() unavailable, use getID3()'s iconv_fallback() conversions (possibly PHP is compiled without XML support)
706
- $newcharstring = '';
707
- if ($bom) {
708
- $newcharstring .= "\xEF\xBB\xBF";
709
- }
710
- for ($i = 0; $i < strlen($string); $i++) {
711
- $charval = ord($string{$i});
712
- $newcharstring .= getid3_lib::iconv_fallback_int_utf8($charval);
713
- }
714
- return $newcharstring;
715
- }
716
-
717
- // ISO-8859-1 => UTF-16BE
718
- function iconv_fallback_iso88591_utf16be($string, $bom=false) {
719
- $newcharstring = '';
720
- if ($bom) {
721
- $newcharstring .= "\xFE\xFF";
722
- }
723
- for ($i = 0; $i < strlen($string); $i++) {
724
- $newcharstring .= "\x00".$string{$i};
725
- }
726
- return $newcharstring;
727
- }
728
-
729
- // ISO-8859-1 => UTF-16LE
730
- function iconv_fallback_iso88591_utf16le($string, $bom=false) {
731
- $newcharstring = '';
732
- if ($bom) {
733
- $newcharstring .= "\xFF\xFE";
734
- }
735
- for ($i = 0; $i < strlen($string); $i++) {
736
- $newcharstring .= $string{$i}."\x00";
737
- }
738
- return $newcharstring;
739
- }
740
-
741
- // ISO-8859-1 => UTF-16LE (BOM)
742
- function iconv_fallback_iso88591_utf16($string) {
743
- return getid3_lib::iconv_fallback_iso88591_utf16le($string, true);
744
- }
745
-
746
- // UTF-8 => ISO-8859-1
747
- function iconv_fallback_utf8_iso88591($string) {
748
- if (function_exists('utf8_decode')) {
749
- return utf8_decode($string);
750
- }
751
- // utf8_decode() unavailable, use getID3()'s iconv_fallback() conversions (possibly PHP is compiled without XML support)
752
- $newcharstring = '';
753
- $offset = 0;
754
- $stringlength = strlen($string);
755
- while ($offset < $stringlength) {
756
- if ((ord($string{$offset}) | 0x07) == 0xF7) {
757
- // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
758
- $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
759
- ((ord($string{($offset + 1)}) & 0x3F) << 12) &
760
- ((ord($string{($offset + 2)}) & 0x3F) << 6) &
761
- (ord($string{($offset + 3)}) & 0x3F);
762
- $offset += 4;
763
- } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
764
- // 1110bbbb 10bbbbbb 10bbbbbb
765
- $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
766
- ((ord($string{($offset + 1)}) & 0x3F) << 6) &
767
- (ord($string{($offset + 2)}) & 0x3F);
768
- $offset += 3;
769
- } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
770
- // 110bbbbb 10bbbbbb
771
- $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
772
- (ord($string{($offset + 1)}) & 0x3F);
773
- $offset += 2;
774
- } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
775
- // 0bbbbbbb
776
- $charval = ord($string{$offset});
777
- $offset += 1;
778
- } else {
779
- // error? throw some kind of warning here?
780
- $charval = false;
781
- $offset += 1;
782
- }
783
- if ($charval !== false) {
784
- $newcharstring .= (($charval < 256) ? chr($charval) : '?');
785
- }
786
- }
787
- return $newcharstring;
788
- }
789
-
790
- // UTF-8 => UTF-16BE
791
- function iconv_fallback_utf8_utf16be($string, $bom=false) {
792
- $newcharstring = '';
793
- if ($bom) {
794
- $newcharstring .= "\xFE\xFF";
795
- }
796
- $offset = 0;
797
- $stringlength = strlen($string);
798
- while ($offset < $stringlength) {
799
- if ((ord($string{$offset}) | 0x07) == 0xF7) {
800
- // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
801
- $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
802
- ((ord($string{($offset + 1)}) & 0x3F) << 12) &
803
- ((ord($string{($offset + 2)}) & 0x3F) << 6) &
804
- (ord($string{($offset + 3)}) & 0x3F);
805
- $offset += 4;
806
- } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
807
- // 1110bbbb 10bbbbbb 10bbbbbb
808
- $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
809
- ((ord($string{($offset + 1)}) & 0x3F) << 6) &
810
- (ord($string{($offset + 2)}) & 0x3F);
811
- $offset += 3;
812
- } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
813
- // 110bbbbb 10bbbbbb
814
- $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
815
- (ord($string{($offset + 1)}) & 0x3F);
816
- $offset += 2;
817
- } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
818
- // 0bbbbbbb
819
- $charval = ord($string{$offset});
820
- $offset += 1;
821
- } else {
822
- // error? throw some kind of warning here?
823
- $charval = false;
824
- $offset += 1;
825
- }
826
- if ($charval !== false) {
827
- $newcharstring .= (($charval < 65536) ? getid3_lib::BigEndian2String($charval, 2) : "\x00".'?');
828
- }
829
- }
830
- return $newcharstring;
831
- }
832
-
833
- // UTF-8 => UTF-16LE
834
- function iconv_fallback_utf8_utf16le($string, $bom=false) {
835
- $newcharstring = '';
836
- if ($bom) {
837
- $newcharstring .= "\xFF\xFE";
838
- }
839
- $offset = 0;
840
- $stringlength = strlen($string);
841
- while ($offset < $stringlength) {
842
- if ((ord($string{$offset}) | 0x07) == 0xF7) {
843
- // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
844
- $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
845
- ((ord($string{($offset + 1)}) & 0x3F) << 12) &
846
- ((ord($string{($offset + 2)}) & 0x3F) << 6) &
847
- (ord($string{($offset + 3)}) & 0x3F);
848
- $offset += 4;
849
- } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
850
- // 1110bbbb 10bbbbbb 10bbbbbb
851
- $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
852
- ((ord($string{($offset + 1)}) & 0x3F) << 6) &
853
- (ord($string{($offset + 2)}) & 0x3F);
854
- $offset += 3;
855
- } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
856
- // 110bbbbb 10bbbbbb
857
- $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
858
- (ord($string{($offset + 1)}) & 0x3F);
859
- $offset += 2;
860
- } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
861
- // 0bbbbbbb
862
- $charval = ord($string{$offset});
863
- $offset += 1;
864
- } else {
865
- // error? maybe throw some warning here?
866
- $charval = false;
867
- $offset += 1;
868
- }
869
- if ($charval !== false) {
870
- $newcharstring .= (($charval < 65536) ? getid3_lib::LittleEndian2String($charval, 2) : '?'."\x00");
871
- }
872
- }
873
- return $newcharstring;
874
- }
875
-
876
- // UTF-8 => UTF-16LE (BOM)
877
- function iconv_fallback_utf8_utf16($string) {
878
- return getid3_lib::iconv_fallback_utf8_utf16le($string, true);
879
- }
880
-
881
- // UTF-16BE => UTF-8
882
- function iconv_fallback_utf16be_utf8($string) {
883
- if (substr($string, 0, 2) == "\xFE\xFF") {
884
- // strip BOM
885
- $string = substr($string, 2);
886
- }
887
- $newcharstring = '';
888
- for ($i = 0; $i < strlen($string); $i += 2) {
889
- $charval = getid3_lib::BigEndian2Int(substr($string, $i, 2));
890
- $newcharstring .= getid3_lib::iconv_fallback_int_utf8($charval);
891
- }
892
- return $newcharstring;
893
- }
894
-
895
- // UTF-16LE => UTF-8
896
- function iconv_fallback_utf16le_utf8($string) {
897
- if (substr($string, 0, 2) == "\xFF\xFE") {
898
- // strip BOM
899
- $string = substr($string, 2);
900
- }
901
- $newcharstring = '';
902
- for ($i = 0; $i < strlen($string); $i += 2) {
903
- $charval = getid3_lib::LittleEndian2Int(substr($string, $i, 2));
904
- $newcharstring .= getid3_lib::iconv_fallback_int_utf8($charval);
905
- }
906
- return $newcharstring;
907
- }
908
-
909
- // UTF-16BE => ISO-8859-1
910
- function iconv_fallback_utf16be_iso88591($string) {
911
- if (substr($string, 0, 2) == "\xFE\xFF") {
912
- // strip BOM
913
- $string = substr($string, 2);
914
- }
915
- $newcharstring = '';
916
- for ($i = 0; $i < strlen($string); $i += 2) {
917
- $charval = getid3_lib::BigEndian2Int(substr($string, $i, 2));
918
- $newcharstring .= (($charval < 256) ? chr($charval) : '?');
919
- }
920
- return $newcharstring;
921
- }
922
-
923
- // UTF-16LE => ISO-8859-1
924
- function iconv_fallback_utf16le_iso88591($string) {
925
- if (substr($string, 0, 2) == "\xFF\xFE") {
926
- // strip BOM
927
- $string = substr($string, 2);
928
- }
929
- $newcharstring = '';
930
- for ($i = 0; $i < strlen($string); $i += 2) {
931
- $charval = getid3_lib::LittleEndian2Int(substr($string, $i, 2));
932
- $newcharstring .= (($charval < 256) ? chr($charval) : '?');
933
- }
934
- return $newcharstring;
935
- }
936
-
937
- // UTF-16 (BOM) => ISO-8859-1
938
- function iconv_fallback_utf16_iso88591($string) {
939
- $bom = substr($string, 0, 2);
940
- if ($bom == "\xFE\xFF") {
941
- return getid3_lib::iconv_fallback_utf16be_iso88591(substr($string, 2));
942
- } elseif ($bom == "\xFF\xFE") {
943
- return getid3_lib::iconv_fallback_utf16le_iso88591(substr($string, 2));
944
- }
945
- return $string;
946
- }
947
-
948
- // UTF-16 (BOM) => UTF-8
949
- function iconv_fallback_utf16_utf8($string) {
950
- $bom = substr($string, 0, 2);
951
- if ($bom == "\xFE\xFF") {
952
- return getid3_lib::iconv_fallback_utf16be_utf8(substr($string, 2));
953
- } elseif ($bom == "\xFF\xFE") {
954
- return getid3_lib::iconv_fallback_utf16le_utf8(substr($string, 2));
955
- }
956
- return $string;
957
- }
958
-
959
- function iconv_fallback($in_charset, $out_charset, $string) {
960
-
961
- if ($in_charset == $out_charset) {
962
- return $string;
963
- }
964
-
965
- // iconv() availble
966
- if (function_exists('iconv')) {
967
-
968
- if ($converted_string = @iconv($in_charset, $out_charset.'//TRANSLIT', $string)) {
969
- switch ($out_charset) {
970
- case 'ISO-8859-1':
971
- $converted_string = rtrim($converted_string, "\x00");
972
- break;
973
- }
974
- return $converted_string;
975
- }
976
-
977
- // iconv() may sometimes fail with "illegal character in input string" error message
978
- // and return an empty string, but returning the unconverted string is more useful
979
- return $string;
980
- }
981
-
982
-
983
- // iconv() not available
984
- static $ConversionFunctionList = array();
985
- if (empty($ConversionFunctionList)) {
986
- $ConversionFunctionList['ISO-8859-1']['UTF-8'] = 'iconv_fallback_iso88591_utf8';
987
- $ConversionFunctionList['ISO-8859-1']['UTF-16'] = 'iconv_fallback_iso88591_utf16';
988
- $ConversionFunctionList['ISO-8859-1']['UTF-16BE'] = 'iconv_fallback_iso88591_utf16be';
989
- $ConversionFunctionList['ISO-8859-1']['UTF-16LE'] = 'iconv_fallback_iso88591_utf16le';
990
- $ConversionFunctionList['UTF-8']['ISO-8859-1'] = 'iconv_fallback_utf8_iso88591';
991
- $ConversionFunctionList['UTF-8']['UTF-16'] = 'iconv_fallback_utf8_utf16';
992
- $ConversionFunctionList['UTF-8']['UTF-16BE'] = 'iconv_fallback_utf8_utf16be';
993
- $ConversionFunctionList['UTF-8']['UTF-16LE'] = 'iconv_fallback_utf8_utf16le';
994
- $ConversionFunctionList['UTF-16']['ISO-8859-1'] = 'iconv_fallback_utf16_iso88591';
995
- $ConversionFunctionList['UTF-16']['UTF-8'] = 'iconv_fallback_utf16_utf8';
996
- $ConversionFunctionList['UTF-16LE']['ISO-8859-1'] = 'iconv_fallback_utf16le_iso88591';
997
- $ConversionFunctionList['UTF-16LE']['UTF-8'] = 'iconv_fallback_utf16le_utf8';
998
- $ConversionFunctionList['UTF-16BE']['ISO-8859-1'] = 'iconv_fallback_utf16be_iso88591';
999
- $ConversionFunctionList['UTF-16BE']['UTF-8'] = 'iconv_fallback_utf16be_utf8';
1000
- }
1001
- if (isset($ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)])) {
1002
- $ConversionFunction = $ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)];
1003
- return getid3_lib::$ConversionFunction($string);
1004
- }
1005
- die('PHP does not have iconv() support - cannot convert from '.$in_charset.' to '.$out_charset);
1006
- }
1007
-
1008
-
1009
- function MultiByteCharString2HTML($string, $charset='ISO-8859-1') {
1010
- $HTMLstring = '';
1011
-
1012
- switch ($charset) {
1013
- case 'ISO-8859-1':
1014
- case 'ISO8859-1':
1015
- case 'ISO-8859-15':
1016
- case 'ISO8859-15':
1017
- case 'cp866':
1018
- case 'ibm866':
1019
- case '866':
1020
- case 'cp1251':
1021
- case 'Windows-1251':
1022
- case 'win-1251':
1023
- case '1251':
1024
- case 'cp1252':
1025
- case 'Windows-1252':
1026
- case '1252':
1027
- case 'KOI8-R':
1028
- case 'koi8-ru':
1029
- case 'koi8r':
1030
- case 'BIG5':
1031
- case '950':
1032
- case 'GB2312':
1033
- case '936':
1034
- case 'BIG5-HKSCS':
1035
- case 'Shift_JIS':
1036
- case 'SJIS':
1037
- case '932':
1038
- case 'EUC-JP':
1039
- case 'EUCJP':
1040
- $HTMLstring = htmlentities($string, ENT_COMPAT, $charset);
1041
- break;
1042
-
1043
- case 'UTF-8':
1044
- $strlen = strlen($string);
1045
- for ($i = 0; $i < $strlen; $i++) {
1046
- $char_ord_val = ord($string{$i});
1047
- $charval = 0;
1048
- if ($char_ord_val < 0x80) {
1049
- $charval = $char_ord_val;
1050
- } elseif ((($char_ord_val & 0xF0) >> 4) == 0x0F && $i+3 < $strlen) {
1051
- $charval = (($char_ord_val & 0x07) << 18);
1052
- $charval += ((ord($string{++$i}) & 0x3F) << 12);
1053
- $charval += ((ord($string{++$i}) & 0x3F) << 6);
1054
- $charval += (ord($string{++$i}) & 0x3F);
1055
- } elseif ((($char_ord_val & 0xE0) >> 5) == 0x07 && $i+2 < $strlen) {
1056
- $charval = (($char_ord_val & 0x0F) << 12);
1057
- $charval += ((ord($string{++$i}) & 0x3F) << 6);
1058
- $charval += (ord($string{++$i}) & 0x3F);
1059
- } elseif ((($char_ord_val & 0xC0) >> 6) == 0x03 && $i+1 < $strlen) {
1060
- $charval = (($char_ord_val & 0x1F) << 6);
1061
- $charval += (ord($string{++$i}) & 0x3F);
1062
- }
1063
- if (($charval >= 32) && ($charval <= 127)) {
1064
- $HTMLstring .= htmlentities(chr($charval));
1065
- } else {
1066
- $HTMLstring .= '&#'.$charval.';';
1067
- }
1068
- }
1069
- break;
1070
-
1071
- case 'UTF-16LE':
1072
- for ($i = 0; $i < strlen($string); $i += 2) {
1073
- $charval = getid3_lib::LittleEndian2Int(substr($string, $i, 2));
1074
- if (($charval >= 32) && ($charval <= 127)) {
1075
- $HTMLstring .= chr($charval);
1076
- } else {
1077
- $HTMLstring .= '&#'.$charval.';';
1078
- }
1079
- }
1080
- break;
1081
-
1082
- case 'UTF-16BE':
1083
- for ($i = 0; $i < strlen($string); $i += 2) {
1084
- $charval = getid3_lib::BigEndian2Int(substr($string, $i, 2));
1085
- if (($charval >= 32) && ($charval <= 127)) {
1086
- $HTMLstring .= chr($charval);
1087
- } else {
1088
- $HTMLstring .= '&#'.$charval.';';
1089
- }
1090
- }
1091
- break;
1092
-
1093
- default:
1094
- $HTMLstring = 'ERROR: Character set "'.$charset.'" not supported in MultiByteCharString2HTML()';
1095
- break;
1096
- }
1097
- return $HTMLstring;
1098
- }
1099
-
1100
-
1101
-
1102
- function RGADnameLookup($namecode) {
1103
- static $RGADname = array();
1104
- if (empty($RGADname)) {
1105
- $RGADname[0] = 'not set';
1106
- $RGADname[1] = 'Track Gain Adjustment';
1107
- $RGADname[2] = 'Album Gain Adjustment';
1108
- }
1109
-
1110
- return (isset($RGADname[$namecode]) ? $RGADname[$namecode] : '');
1111
- }
1112
-
1113
-
1114
- function RGADoriginatorLookup($originatorcode) {
1115
- static $RGADoriginator = array();
1116
- if (empty($RGADoriginator)) {
1117
- $RGADoriginator[0] = 'unspecified';
1118
- $RGADoriginator[1] = 'pre-set by artist/producer/mastering engineer';
1119
- $RGADoriginator[2] = 'set by user';
1120
- $RGADoriginator[3] = 'determined automatically';
1121
- }
1122
-
1123
- return (isset($RGADoriginator[$originatorcode]) ? $RGADoriginator[$originatorcode] : '');
1124
- }
1125
-
1126
-
1127
- function RGADadjustmentLookup($rawadjustment, $signbit) {
1128
- $adjustment = $rawadjustment / 10;
1129
- if ($signbit == 1) {
1130
- $adjustment *= -1;
1131
- }
1132
- return (float) $adjustment;
1133
- }
1134
-
1135
-
1136
- function RGADgainString($namecode, $originatorcode, $replaygain) {
1137
- if ($replaygain < 0) {
1138
- $signbit = '1';
1139
- } else {
1140
- $signbit = '0';
1141
- }
1142
- $storedreplaygain = intval(round($replaygain * 10));
1143
- $gainstring = str_pad(decbin($namecode), 3, '0', STR_PAD_LEFT);
1144
- $gainstring .= str_pad(decbin($originatorcode), 3, '0', STR_PAD_LEFT);
1145
- $gainstring .= $signbit;
1146
- $gainstring .= str_pad(decbin($storedreplaygain), 9, '0', STR_PAD_LEFT);
1147
-
1148
- return $gainstring;
1149
- }
1150
-
1151
- function RGADamplitude2dB($amplitude) {
1152
- return 20 * log10($amplitude);
1153
- }
1154
-
1155
-
1156
- function GetDataImageSize($imgData, &$imageinfo) {
1157
- $GetDataImageSize = false;
1158
- if ($tempfilename = tempnam('*', 'getID3')) {
1159
- if ($tmp = @fopen($tempfilename, 'wb')) {
1160
- fwrite($tmp, $imgData);
1161
- fclose($tmp);
1162
- $GetDataImageSize = @GetImageSize($tempfilename, $imageinfo);
1163
- }
1164
- unlink($tempfilename);
1165
- }
1166
- return $GetDataImageSize;
1167
- }
1168
-
1169
- function ImageTypesLookup($imagetypeid) {
1170
- static $ImageTypesLookup = array();
1171
- if (empty($ImageTypesLookup)) {
1172
- $ImageTypesLookup[1] = 'gif';
1173
- $ImageTypesLookup[2] = 'jpeg';
1174
- $ImageTypesLookup[3] = 'png';
1175
- $ImageTypesLookup[4] = 'swf';
1176
- $ImageTypesLookup[5] = 'psd';
1177
- $ImageTypesLookup[6] = 'bmp';
1178
- $ImageTypesLookup[7] = 'tiff (little-endian)';
1179
- $ImageTypesLookup[8] = 'tiff (big-endian)';
1180
- $ImageTypesLookup[9] = 'jpc';
1181
- $ImageTypesLookup[10] = 'jp2';
1182
- $ImageTypesLookup[11] = 'jpx';
1183
- $ImageTypesLookup[12] = 'jb2';
1184
- $ImageTypesLookup[13] = 'swc';
1185
- $ImageTypesLookup[14] = 'iff';
1186
- }
1187
- return (isset($ImageTypesLookup[$imagetypeid]) ? $ImageTypesLookup[$imagetypeid] : '');
1188
- }
1189
-
1190
- function CopyTagsToComments(&$ThisFileInfo) {
1191
-
1192
- // Copy all entries from ['tags'] into common ['comments']
1193
- if (!empty($ThisFileInfo['tags'])) {
1194
- foreach ($ThisFileInfo['tags'] as $tagtype => $tagarray) {
1195
- foreach ($tagarray as $tagname => $tagdata) {
1196
- foreach ($tagdata as $key => $value) {
1197
- if (!empty($value)) {
1198
- if (empty($ThisFileInfo['comments'][$tagname])) {
1199
-
1200
- // fall through and append value
1201
-
1202
- } elseif ($tagtype == 'id3v1') {
1203
-
1204
- $newvaluelength = strlen(trim($value));
1205
- foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
1206
- $oldvaluelength = strlen(trim($existingvalue));
1207
- if (($newvaluelength <= $oldvaluelength) && (substr($existingvalue, 0, $newvaluelength) == trim($value))) {
1208
- // new value is identical but shorter-than (or equal-length to) one already in comments - skip
1209
- break 2;
1210
- }
1211
- }
1212
-
1213
- } else {
1214
-
1215
- $newvaluelength = strlen(trim($value));
1216
- foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
1217
- $oldvaluelength = strlen(trim($existingvalue));
1218
- if (($newvaluelength > $oldvaluelength) && (substr(trim($value), 0, strlen($existingvalue)) == $existingvalue)) {
1219
- $ThisFileInfo['comments'][$tagname][$existingkey] = trim($value);
1220
- break 2;
1221
- }
1222
- }
1223
-
1224
- }
1225
- if (empty($ThisFileInfo['comments'][$tagname]) || !in_array(trim($value), $ThisFileInfo['comments'][$tagname])) {
1226
- $ThisFileInfo['comments'][$tagname][] = trim($value);
1227
- }
1228
- }
1229
- }
1230
- }
1231
- }
1232
-
1233
- // Copy to ['comments_html']
1234
- foreach ($ThisFileInfo['comments'] as $field => $values) {
1235
- foreach ($values as $index => $value) {
1236
- $ThisFileInfo['comments_html'][$field][$index] = str_replace('&#0;', '', getid3_lib::MultiByteCharString2HTML($value, $ThisFileInfo['encoding']));
1237
- }
1238
- }
1239
- }
1240
- }
1241
-
1242
-
1243
- function EmbeddedLookup($key, $begin, $end, $file, $name) {
1244
-
1245
- // Cached
1246
- static $cache;
1247
- if (isset($cache[$file][$name])) {
1248
- return @$cache[$file][$name][$key];
1249
- }
1250
-
1251
- // Init
1252
- $keylength = strlen($key);
1253
- $line_count = $end - $begin - 7;
1254
-
1255
- // Open php file
1256
- $fp = fopen($file, 'r');
1257
-
1258
- // Discard $begin lines
1259
- for ($i = 0; $i < ($begin + 3); $i++) {
1260
- fgets($fp, 1024);
1261
- }
1262
-
1263
- // Loop thru line
1264
- while (0 < $line_count--) {
1265
-
1266
- // Read line
1267
- $line = ltrim(fgets($fp, 1024), "\t ");
1268
-
1269
- // METHOD A: only cache the matching key - less memory but slower on next lookup of not-previously-looked-up key
1270
- //$keycheck = substr($line, 0, $keylength);
1271
- //if ($key == $keycheck) {
1272
- // $cache[$file][$name][$keycheck] = substr($line, $keylength + 1);
1273
- // break;
1274
- //}
1275
-
1276
- // METHOD B: cache all keys in this lookup - more memory but faster on next lookup of not-previously-looked-up key
1277
- //$cache[$file][$name][substr($line, 0, $keylength)] = trim(substr($line, $keylength + 1));
1278
- @list($ThisKey, $ThisValue) = explode("\t", $line, 2);
1279
- $cache[$file][$name][$ThisKey] = trim($ThisValue);
1280
- }
1281
-
1282
- // Close and return
1283
- fclose($fp);
1284
- return @$cache[$file][$name][$key];
1285
- }
1286
-
1287
- function IncludeDependency($filename, $sourcefile, $DieOnFailure=false) {
1288
- global $GETID3_ERRORARRAY;
1289
-
1290
- if (file_exists($filename)) {
1291
- if (@include_once($filename)) {
1292
- return true;
1293
- } else {
1294
- $diemessage = basename($sourcefile).' depends on '.$filename.', which has errors';
1295
- }
1296
- } else {
1297
- $diemessage = basename($sourcefile).' depends on '.$filename.', which is missing';
1298
- }
1299
- if ($DieOnFailure) {
1300
- die($diemessage);
1301
- } else {
1302
- $GETID3_ERRORARRAY[] = $diemessage;
1303
- }
1304
- return false;
1305
- }
1306
-
1307
- }
1308
-
1309
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /////////////////////////////////////////////////////////////////
3
+ /// getID3() by James Heinrich <info@getid3.org> //
4
+ // available at http://getid3.sourceforge.net //
5
+ // or http://www.getid3.org //
6
+ /////////////////////////////////////////////////////////////////
7
+ // //
8
+ // getid3.lib.php - part of getID3() //
9
+ // See readme.txt for more details //
10
+ // ///
11
+ /////////////////////////////////////////////////////////////////
12
+
13
+
14
+ class getid3_lib
15
+ {
16
+
17
+ public static function PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8') {
18
+ $returnstring = '';
19
+ for ($i = 0; $i < strlen($string); $i++) {
20
+ if ($hex) {
21
+ $returnstring .= str_pad(dechex(ord($string{$i})), 2, '0', STR_PAD_LEFT);
22
+ } else {
23
+ $returnstring .= ' '.(preg_match("#[\x20-\x7E]#", $string{$i}) ? $string{$i} : '�');
24
+ }
25
+ if ($spaces) {
26
+ $returnstring .= ' ';
27
+ }
28
+ }
29
+ if (!empty($htmlencoding)) {
30
+ if ($htmlencoding === true) {
31
+ $htmlencoding = 'UTF-8'; // prior to getID3 v1.9.0 the function's 4th parameter was boolean
32
+ }
33
+ $returnstring = htmlentities($returnstring, ENT_QUOTES, $htmlencoding);
34
+ }
35
+ return $returnstring;
36
+ }
37
+
38
+ public static function trunc($floatnumber) {
39
+ // truncates a floating-point number at the decimal point
40
+ // returns int (if possible, otherwise float)
41
+ if ($floatnumber >= 1) {
42
+ $truncatednumber = floor($floatnumber);
43
+ } elseif ($floatnumber <= -1) {
44
+ $truncatednumber = ceil($floatnumber);
45
+ } else {
46
+ $truncatednumber = 0;
47
+ }
48
+ if (self::intValueSupported($truncatednumber)) {
49
+ $truncatednumber = (int) $truncatednumber;
50
+ }
51
+ return $truncatednumber;
52
+ }
53
+
54
+
55
+ public static function safe_inc(&$variable, $increment=1) {
56
+ if (isset($variable)) {
57
+ $variable += $increment;
58
+ } else {
59
+ $variable = $increment;
60
+ }
61
+ return true;
62
+ }
63
+
64
+ public static function CastAsInt($floatnum) {
65
+ // convert to float if not already
66
+ $floatnum = (float) $floatnum;
67
+
68
+ // convert a float to type int, only if possible
69
+ if (self::trunc($floatnum) == $floatnum) {
70
+ // it's not floating point
71
+ if (self::intValueSupported($floatnum)) {
72
+ // it's within int range
73
+ $floatnum = (int) $floatnum;
74
+ }
75
+ }
76
+ return $floatnum;
77
+ }
78
+
79
+ public static function intValueSupported($num) {
80
+ // check if integers are 64-bit
81
+ static $hasINT64 = null;
82
+ if ($hasINT64 === null) { // 10x faster than is_null()
83
+ $hasINT64 = is_int(pow(2, 31)); // 32-bit int are limited to (2^31)-1
84
+ if (!$hasINT64 && !defined('PHP_INT_MIN')) {
85
+ define('PHP_INT_MIN', ~PHP_INT_MAX);
86
+ }
87
+ }
88
+ // if integers are 64-bit - no other check required
89
+ if ($hasINT64 || (($num <= PHP_INT_MAX) && ($num >= PHP_INT_MIN))) {
90
+ return true;
91
+ }
92
+ return false;
93
+ }
94
+
95
+ public static function DecimalizeFraction($fraction) {
96
+ list($numerator, $denominator) = explode('/', $fraction);
97
+ return $numerator / ($denominator ? $denominator : 1);
98
+ }
99
+
100
+
101
+ public static function DecimalBinary2Float($binarynumerator) {
102
+ $numerator = self::Bin2Dec($binarynumerator);
103
+ $denominator = self::Bin2Dec('1'.str_repeat('0', strlen($binarynumerator)));
104
+ return ($numerator / $denominator);
105
+ }
106
+
107
+
108
+ public static function NormalizeBinaryPoint($binarypointnumber, $maxbits=52) {
109
+ // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html
110
+ if (strpos($binarypointnumber, '.') === false) {
111
+ $binarypointnumber = '0.'.$binarypointnumber;
112
+ } elseif ($binarypointnumber{0} == '.') {
113
+ $binarypointnumber = '0'.$binarypointnumber;
114
+ }
115
+ $exponent = 0;
116
+ while (($binarypointnumber{0} != '1') || (substr($binarypointnumber, 1, 1) != '.')) {
117
+ if (substr($binarypointnumber, 1, 1) == '.') {
118
+ $exponent--;
119
+ $binarypointnumber = substr($binarypointnumber, 2, 1).'.'.substr($binarypointnumber, 3);
120
+ } else {
121
+ $pointpos = strpos($binarypointnumber, '.');
122
+ $exponent += ($pointpos - 1);
123
+ $binarypointnumber = str_replace('.', '', $binarypointnumber);
124
+ $binarypointnumber = $binarypointnumber{0}.'.'.substr($binarypointnumber, 1);
125
+ }
126
+ }
127
+ $binarypointnumber = str_pad(substr($binarypointnumber, 0, $maxbits + 2), $maxbits + 2, '0', STR_PAD_RIGHT);
128
+ return array('normalized'=>$binarypointnumber, 'exponent'=>(int) $exponent);
129
+ }
130
+
131
+
132
+ public static function Float2BinaryDecimal($floatvalue) {
133
+ // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html
134
+ $maxbits = 128; // to how many bits of precision should the calculations be taken?
135
+ $intpart = self::trunc($floatvalue);
136
+ $floatpart = abs($floatvalue - $intpart);
137
+ $pointbitstring = '';
138
+ while (($floatpart != 0) && (strlen($pointbitstring) < $maxbits)) {
139
+ $floatpart *= 2;
140
+ $pointbitstring .= (string) self::trunc($floatpart);
141
+ $floatpart -= self::trunc($floatpart);
142
+ }
143
+ $binarypointnumber = decbin($intpart).'.'.$pointbitstring;
144
+ return $binarypointnumber;
145
+ }
146
+
147
+
148
+ public static function Float2String($floatvalue, $bits) {
149
+ // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee-expl.html
150
+ switch ($bits) {
151
+ case 32:
152
+ $exponentbits = 8;
153
+ $fractionbits = 23;
154
+ break;
155
+
156
+ case 64:
157
+ $exponentbits = 11;
158
+ $fractionbits = 52;
159
+ break;
160
+
161
+ default:
162
+ return false;
163
+ break;
164
+ }
165
+ if ($floatvalue >= 0) {
166
+ $signbit = '0';
167
+ } else {
168
+ $signbit = '1';
169
+ }
170
+ $normalizedbinary = self::NormalizeBinaryPoint(self::Float2BinaryDecimal($floatvalue), $fractionbits);
171
+ $biasedexponent = pow(2, $exponentbits - 1) - 1 + $normalizedbinary['exponent']; // (127 or 1023) +/- exponent
172
+ $exponentbitstring = str_pad(decbin($biasedexponent), $exponentbits, '0', STR_PAD_LEFT);
173
+ $fractionbitstring = str_pad(substr($normalizedbinary['normalized'], 2), $fractionbits, '0', STR_PAD_RIGHT);
174
+
175
+ return self::BigEndian2String(self::Bin2Dec($signbit.$exponentbitstring.$fractionbitstring), $bits % 8, false);
176
+ }
177
+
178
+
179
+ public static function LittleEndian2Float($byteword) {
180
+ return self::BigEndian2Float(strrev($byteword));
181
+ }
182
+
183
+
184
+ public static function BigEndian2Float($byteword) {
185
+ // ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic
186
+ // http://www.psc.edu/general/software/packages/ieee/ieee.html
187
+ // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html
188
+
189
+ $bitword = self::BigEndian2Bin($byteword);
190
+ if (!$bitword) {
191
+ return 0;
192
+ }
193
+ $signbit = $bitword{0};
194
+
195
+ switch (strlen($byteword) * 8) {
196
+ case 32:
197
+ $exponentbits = 8;
198
+ $fractionbits = 23;
199
+ break;
200
+
201
+ case 64:
202
+ $exponentbits = 11;
203
+ $fractionbits = 52;
204
+ break;
205
+
206
+ case 80:
207
+ // 80-bit Apple SANE format
208
+ // http://www.mactech.com/articles/mactech/Vol.06/06.01/SANENormalized/
209
+ $exponentstring = substr($bitword, 1, 15);
210
+ $isnormalized = intval($bitword{16});
211
+ $fractionstring = substr($bitword, 17, 63);
212
+ $exponent = pow(2, self::Bin2Dec($exponentstring) - 16383);
213
+ $fraction = $isnormalized + self::DecimalBinary2Float($fractionstring);
214
+ $floatvalue = $exponent * $fraction;
215
+ if ($signbit == '1') {
216
+ $floatvalue *= -1;
217
+ }
218
+ return $floatvalue;
219
+ break;
220
+
221
+ default:
222
+ return false;
223
+ break;
224
+ }
225
+ $exponentstring = substr($bitword, 1, $exponentbits);
226
+ $fractionstring = substr($bitword, $exponentbits + 1, $fractionbits);
227
+ $exponent = self::Bin2Dec($exponentstring);
228
+ $fraction = self::Bin2Dec($fractionstring);
229
+
230
+ if (($exponent == (pow(2, $exponentbits) - 1)) && ($fraction != 0)) {
231
+ // Not a Number
232
+ $floatvalue = false;
233
+ } elseif (($exponent == (pow(2, $exponentbits) - 1)) && ($fraction == 0)) {
234
+ if ($signbit == '1') {
235
+ $floatvalue = '-infinity';
236
+ } else {
237
+ $floatvalue = '+infinity';
238
+ }
239
+ } elseif (($exponent == 0) && ($fraction == 0)) {
240
+ if ($signbit == '1') {
241
+ $floatvalue = -0;
242
+ } else {
243
+ $floatvalue = 0;
244
+ }
245
+ $floatvalue = ($signbit ? 0 : -0);
246
+ } elseif (($exponent == 0) && ($fraction != 0)) {
247
+ // These are 'unnormalized' values
248
+ $floatvalue = pow(2, (-1 * (pow(2, $exponentbits - 1) - 2))) * self::DecimalBinary2Float($fractionstring);
249
+ if ($signbit == '1') {
250
+ $floatvalue *= -1;
251
+ }
252
+ } elseif ($exponent != 0) {
253
+ $floatvalue = pow(2, ($exponent - (pow(2, $exponentbits - 1) - 1))) * (1 + self::DecimalBinary2Float($fractionstring));
254
+ if ($signbit == '1') {
255
+ $floatvalue *= -1;
256
+ }
257
+ }
258
+ return (float) $floatvalue;
259
+ }
260
+
261
+
262
+ public static function BigEndian2Int($byteword, $synchsafe=false, $signed=false) {
263
+ $intvalue = 0;
264
+ $bytewordlen = strlen($byteword);
265
+ if ($bytewordlen == 0) {
266
+ return false;
267
+ }
268
+ for ($i = 0; $i < $bytewordlen; $i++) {
269
+ if ($synchsafe) { // disregard MSB, effectively 7-bit bytes
270
+ //$intvalue = $intvalue | (ord($byteword{$i}) & 0x7F) << (($bytewordlen - 1 - $i) * 7); // faster, but runs into problems past 2^31 on 32-bit systems
271
+ $intvalue += (ord($byteword{$i}) & 0x7F) * pow(2, ($bytewordlen - 1 - $i) * 7);
272
+ } else {
273
+ $intvalue += ord($byteword{$i}) * pow(256, ($bytewordlen - 1 - $i));
274
+ }
275
+ }
276
+ if ($signed && !$synchsafe) {
277
+ // synchsafe ints are not allowed to be signed
278
+ if ($bytewordlen <= PHP_INT_SIZE) {
279
+ $signMaskBit = 0x80 << (8 * ($bytewordlen - 1));
280
+ if ($intvalue & $signMaskBit) {
281
+ $intvalue = 0 - ($intvalue & ($signMaskBit - 1));
282
+ }
283
+ } else {
284
+ throw new Exception('ERROR: Cannot have signed integers larger than '.(8 * PHP_INT_SIZE).'-bits ('.strlen($byteword).') in self::BigEndian2Int()');
285
+ break;
286
+ }
287
+ }
288
+ return self::CastAsInt($intvalue);
289
+ }
290
+
291
+
292
+ public static function LittleEndian2Int($byteword, $signed=false) {
293
+ return self::BigEndian2Int(strrev($byteword), false, $signed);
294
+ }
295
+
296
+
297
+ public static function BigEndian2Bin($byteword) {
298
+ $binvalue = '';
299
+ $bytewordlen = strlen($byteword);
300
+ for ($i = 0; $i < $bytewordlen; $i++) {
301
+ $binvalue .= str_pad(decbin(ord($byteword{$i})), 8, '0', STR_PAD_LEFT);
302
+ }
303
+ return $binvalue;
304
+ }
305
+
306
+
307
+ public static function BigEndian2String($number, $minbytes=1, $synchsafe=false, $signed=false) {
308
+ if ($number < 0) {
309
+ throw new Exception('ERROR: self::BigEndian2String() does not support negative numbers');
310
+ }
311
+ $maskbyte = (($synchsafe || $signed) ? 0x7F : 0xFF);
312
+ $intstring = '';
313
+ if ($signed) {
314
+ if ($minbytes > PHP_INT_SIZE) {
315
+ throw new Exception('ERROR: Cannot have signed integers larger than '.(8 * PHP_INT_SIZE).'-bits in self::BigEndian2String()');
316
+ }
317
+ $number = $number & (0x80 << (8 * ($minbytes - 1)));
318
+ }
319
+ while ($number != 0) {
320
+ $quotient = ($number / ($maskbyte + 1));
321
+ $intstring = chr(ceil(($quotient - floor($quotient)) * $maskbyte)).$intstring;
322
+ $number = floor($quotient);
323
+ }
324
+ return str_pad($intstring, $minbytes, "\x00", STR_PAD_LEFT);
325
+ }
326
+
327
+
328
+ public static function Dec2Bin($number) {
329
+ while ($number >= 256) {
330
+ $bytes[] = (($number / 256) - (floor($number / 256))) * 256;
331
+ $number = floor($number / 256);
332
+ }
333
+ $bytes[] = $number;
334
+ $binstring = '';
335
+ for ($i = 0; $i < count($bytes); $i++) {
336
+ $binstring = (($i == count($bytes) - 1) ? decbin($bytes[$i]) : str_pad(decbin($bytes[$i]), 8, '0', STR_PAD_LEFT)).$binstring;
337
+ }
338
+ return $binstring;
339
+ }
340
+
341
+
342
+ public static function Bin2Dec($binstring, $signed=false) {
343
+ $signmult = 1;
344
+ if ($signed) {
345
+ if ($binstring{0} == '1') {
346
+ $signmult = -1;
347
+ }
348
+ $binstring = substr($binstring, 1);
349
+ }
350
+ $decvalue = 0;
351
+ for ($i = 0; $i < strlen($binstring); $i++) {
352
+ $decvalue += ((int) substr($binstring, strlen($binstring) - $i - 1, 1)) * pow(2, $i);
353
+ }
354
+ return self::CastAsInt($decvalue * $signmult);
355
+ }
356
+
357
+
358
+ public static function Bin2String($binstring) {
359
+ // return 'hi' for input of '0110100001101001'
360
+ $string = '';
361
+ $binstringreversed = strrev($binstring);
362
+ for ($i = 0; $i < strlen($binstringreversed); $i += 8) {
363
+ $string = chr(self::Bin2Dec(strrev(substr($binstringreversed, $i, 8)))).$string;
364
+ }
365
+ return $string;
366
+ }
367
+
368
+
369
+ public static function LittleEndian2String($number, $minbytes=1, $synchsafe=false) {
370
+ $intstring = '';
371
+ while ($number > 0) {
372
+ if ($synchsafe) {
373
+ $intstring = $intstring.chr($number & 127);
374
+ $number >>= 7;
375
+ } else {
376
+ $intstring = $intstring.chr($number & 255);
377
+ $number >>= 8;
378
+ }
379
+ }
380
+ return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT);
381
+ }
382
+
383
+
384
+ public static function array_merge_clobber($array1, $array2) {
385
+ // written by kc�hireability*com
386
+ // taken from http://www.php.net/manual/en/function.array-merge-recursive.php
387
+ if (!is_array($array1) || !is_array($array2)) {
388
+ return false;
389
+ }
390
+ $newarray = $array1;
391
+ foreach ($array2 as $key => $val) {
392
+ if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
393
+ $newarray[$key] = self::array_merge_clobber($newarray[$key], $val);
394
+ } else {
395
+ $newarray[$key] = $val;
396
+ }
397
+ }
398
+ return $newarray;
399
+ }
400
+
401
+
402
+ public static function array_merge_noclobber($array1, $array2) {
403
+ if (!is_array($array1) || !is_array($array2)) {
404
+ return false;
405
+ }
406
+ $newarray = $array1;
407
+ foreach ($array2 as $key => $val) {
408
+ if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
409
+ $newarray[$key] = self::array_merge_noclobber($newarray[$key], $val);
410
+ } elseif (!isset($newarray[$key])) {
411
+ $newarray[$key] = $val;
412
+ }
413
+ }
414
+ return $newarray;
415
+ }
416
+
417
+
418
+ public static function ksort_recursive(&$theArray) {
419
+ ksort($theArray);
420
+ foreach ($theArray as $key => $value) {
421
+ if (is_array($value)) {
422
+ self::ksort_recursive($theArray[$key]);
423
+ }
424
+ }
425
+ return true;
426
+ }
427
+
428
+ public static function fileextension($filename, $numextensions=1) {
429
+ if (strstr($filename, '.')) {
430
+ $reversedfilename = strrev($filename);
431
+ $offset = 0;
432
+ for ($i = 0; $i < $numextensions; $i++) {
433
+ $offset = strpos($reversedfilename, '.', $offset + 1);
434
+ if ($offset === false) {
435
+ return '';
436
+ }
437
+ }
438
+ return strrev(substr($reversedfilename, 0, $offset));
439
+ }
440
+ return '';
441
+ }
442
+
443
+
444
+ public static function PlaytimeString($seconds) {
445
+ $sign = (($seconds < 0) ? '-' : '');
446
+ $seconds = round(abs($seconds));
447
+ $H = (int) floor( $seconds / 3600);
448
+ $M = (int) floor(($seconds - (3600 * $H) ) / 60);
449
+ $S = (int) round( $seconds - (3600 * $H) - (60 * $M) );
450
+ return $sign.($H ? $H.':' : '').($H ? str_pad($M, 2, '0', STR_PAD_LEFT) : intval($M)).':'.str_pad($S, 2, 0, STR_PAD_LEFT);
451
+ }
452
+
453
+
454
+ public static function DateMac2Unix($macdate) {
455
+ // Macintosh timestamp: seconds since 00:00h January 1, 1904
456
+ // UNIX timestamp: seconds since 00:00h January 1, 1970
457
+ return self::CastAsInt($macdate - 2082844800);
458
+ }
459
+
460
+
461
+ public static function FixedPoint8_8($rawdata) {
462
+ return self::BigEndian2Int(substr($rawdata, 0, 1)) + (float) (self::BigEndian2Int(substr($rawdata, 1, 1)) / pow(2, 8));
463
+ }
464
+
465
+
466
+ public static function FixedPoint16_16($rawdata) {
467
+ return self::BigEndian2Int(substr($rawdata, 0, 2)) + (float) (self::BigEndian2Int(substr($rawdata, 2, 2)) / pow(2, 16));
468
+ }
469
+
470
+
471
+ public static function FixedPoint2_30($rawdata) {
472
+ $binarystring = self::BigEndian2Bin($rawdata);
473
+ return self::Bin2Dec(substr($binarystring, 0, 2)) + (float) (self::Bin2Dec(substr($binarystring, 2, 30)) / pow(2, 30));
474
+ }
475
+
476
+
477
+ public static function CreateDeepArray($ArrayPath, $Separator, $Value) {
478
+ // assigns $Value to a nested array path:
479
+ // $foo = self::CreateDeepArray('/path/to/my', '/', 'file.txt')
480
+ // is the same as:
481
+ // $foo = array('path'=>array('to'=>'array('my'=>array('file.txt'))));
482
+ // or
483
+ // $foo['path']['to']['my'] = 'file.txt';
484
+ $ArrayPath = ltrim($ArrayPath, $Separator);
485
+ if (($pos = strpos($ArrayPath, $Separator)) !== false) {
486
+ $ReturnedArray[substr($ArrayPath, 0, $pos)] = self::CreateDeepArray(substr($ArrayPath, $pos + 1), $Separator, $Value);
487
+ } else {
488
+ $ReturnedArray[$ArrayPath] = $Value;
489
+ }
490
+ return $ReturnedArray;
491
+ }
492
+
493
+ public static function array_max($arraydata, $returnkey=false) {
494
+ $maxvalue = false;
495
+ $maxkey = false;
496
+ foreach ($arraydata as $key => $value) {
497
+ if (!is_array($value)) {
498
+ if ($value > $maxvalue) {
499
+ $maxvalue = $value;
500
+ $maxkey = $key;
501
+ }
502
+ }
503
+ }
504
+ return ($returnkey ? $maxkey : $maxvalue);
505
+ }
506
+
507
+ public static function array_min($arraydata, $returnkey=false) {
508
+ $minvalue = false;
509
+ $minkey = false;
510
+ foreach ($arraydata as $key => $value) {
511
+ if (!is_array($value)) {
512
+ if ($value > $minvalue) {
513
+ $minvalue = $value;
514
+ $minkey = $key;
515
+ }
516
+ }
517
+ }
518
+ return ($returnkey ? $minkey : $minvalue);
519
+ }
520
+
521
+ public static function XML2array($XMLstring) {
522
+ if (function_exists('simplexml_load_string')) {
523
+ if (function_exists('get_object_vars')) {
524
+ $XMLobject = simplexml_load_string($XMLstring);
525
+ return self::SimpleXMLelement2array($XMLobject);
526
+ }
527
+ }
528
+ return false;
529
+ }
530
+
531
+ public static function SimpleXMLelement2array($XMLobject) {
532
+ if (!is_object($XMLobject) && !is_array($XMLobject)) {
533
+ return $XMLobject;
534
+ }
535
+ $XMLarray = (is_object($XMLobject) ? get_object_vars($XMLobject) : $XMLobject);
536
+ foreach ($XMLarray as $key => $value) {
537
+ $XMLarray[$key] = self::SimpleXMLelement2array($value);
538
+ }
539
+ return $XMLarray;
540
+ }
541
+
542
+
543
+ // Allan Hansen <ah�artemis*dk>
544
+ // self::md5_data() - returns md5sum for a file from startuing position to absolute end position
545
+ public static function hash_data($file, $offset, $end, $algorithm) {
546
+ static $tempdir = '';
547
+ if (!self::intValueSupported($end)) {
548
+ return false;
549
+ }
550
+ switch ($algorithm) {
551
+ case 'md5':
552
+ $hash_function = 'md5_file';
553
+ $unix_call = 'md5sum';
554
+ $windows_call = 'md5sum.exe';
555
+ $hash_length = 32;
556
+ break;
557
+
558
+ case 'sha1':
559
+ $hash_function = 'sha1_file';
560
+ $unix_call = 'sha1sum';
561
+ $windows_call = 'sha1sum.exe';
562
+ $hash_length = 40;
563
+ break;
564
+
565
+ default:
566
+ throw new Exception('Invalid algorithm ('.$algorithm.') in self::hash_data()');
567
+ break;
568
+ }
569
+ $size = $end - $offset;
570
+ while (true) {
571
+ if (GETID3_OS_ISWINDOWS) {
572
+
573
+ // It seems that sha1sum.exe for Windows only works on physical files, does not accept piped data
574
+ // Fall back to create-temp-file method:
575
+ if ($algorithm == 'sha1') {
576
+ break;
577
+ }
578
+
579
+ $RequiredFiles = array('cygwin1.dll', 'head.exe', 'tail.exe', $windows_call);
580
+ foreach ($RequiredFiles as $required_file) {
581
+ if (!is_readable(GETID3_HELPERAPPSDIR.$required_file)) {
582
+ // helper apps not available - fall back to old method
583
+ break 2;
584
+ }
585
+ }
586
+ $commandline = GETID3_HELPERAPPSDIR.'head.exe -c '.$end.' '.escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $file)).' | ';
587
+ $commandline .= GETID3_HELPERAPPSDIR.'tail.exe -c '.$size.' | ';
588
+ $commandline .= GETID3_HELPERAPPSDIR.$windows_call;
589
+
590
+ } else {
591
+
592
+ $commandline = 'head -c'.$end.' '.escapeshellarg($file).' | ';
593
+ $commandline .= 'tail -c'.$size.' | ';
594
+ $commandline .= $unix_call;
595
+
596
+ }
597
+ if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
598
+ //throw new Exception('PHP running in Safe Mode - backtick operator not available, using slower non-system-call '.$algorithm.' algorithm');
599
+ break;
600
+ }
601
+ return substr(`$commandline`, 0, $hash_length);
602
+ }
603
+
604
+ if (empty($tempdir)) {
605
+ // yes this is ugly, feel free to suggest a better way
606
+ require_once(dirname(__FILE__).'/getid3.php');
607
+ $getid3_temp = new getID3();
608
+ $tempdir = $getid3_temp->tempdir;
609
+ unset($getid3_temp);
610
+ }
611
+ // try to create a temporary file in the system temp directory - invalid dirname should force to system temp dir
612
+ if (($data_filename = tempnam($tempdir, 'gI3')) === false) {
613
+ // can't find anywhere to create a temp file, just fail
614
+ return false;
615
+ }
616
+
617
+ // Init
618
+ $result = false;
619
+
620
+ // copy parts of file
621
+ try {
622
+ self::CopyFileParts($file, $data_filename, $offset, $end - $offset);
623
+ $result = $hash_function($data_filename);
624
+ } catch (Exception $e) {
625
+ throw new Exception('self::CopyFileParts() failed in getid_lib::hash_data(): '.$e->getMessage());
626
+ }
627
+ unlink($data_filename);
628
+ return $result;
629
+ }
630
+
631
+ public static function CopyFileParts($filename_source, $filename_dest, $offset, $length) {
632
+ if (!self::intValueSupported($offset + $length)) {
633
+ throw new Exception('cannot copy file portion, it extends beyond the '.round(PHP_INT_MAX / 1073741824).'GB limit');
634
+ }
635
+ if (is_readable($filename_source) && is_file($filename_source) && ($fp_src = fopen($filename_source, 'rb'))) {
636
+ if (($fp_dest = fopen($filename_dest, 'wb'))) {
637
+ if (fseek($fp_src, $offset, SEEK_SET) == 0) {
638
+ $byteslefttowrite = $length;
639
+ while (($byteslefttowrite > 0) && ($buffer = fread($fp_src, min($byteslefttowrite, getID3::FREAD_BUFFER_SIZE)))) {
640
+ $byteswritten = fwrite($fp_dest, $buffer, $byteslefttowrite);
641
+ $byteslefttowrite -= $byteswritten;
642
+ }
643
+ return true;
644
+ } else {
645
+ throw new Exception('failed to seek to offset '.$offset.' in '.$filename_source);
646
+ }
647
+ fclose($fp_dest);
648
+ } else {
649
+ throw new Exception('failed to create file for writing '.$filename_dest);
650
+ }
651
+ fclose($fp_src);
652
+ } else {
653
+ throw new Exception('failed to open file for reading '.$filename_source);
654
+ }
655
+ return false;
656
+ }
657
+
658
+ public static function iconv_fallback_int_utf8($charval) {
659
+ if ($charval < 128) {
660
+ // 0bbbbbbb
661
+ $newcharstring = chr($charval);
662
+ } elseif ($charval < 2048) {
663
+ // 110bbbbb 10bbbbbb
664
+ $newcharstring = chr(($charval >> 6) | 0xC0);
665
+ $newcharstring .= chr(($charval & 0x3F) | 0x80);
666
+ } elseif ($charval < 65536) {
667
+ // 1110bbbb 10bbbbbb 10bbbbbb
668
+ $newcharstring = chr(($charval >> 12) | 0xE0);
669
+ $newcharstring .= chr(($charval >> 6) | 0xC0);
670
+ $newcharstring .= chr(($charval & 0x3F) | 0x80);
671
+ } else {
672
+ // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
673
+ $newcharstring = chr(($charval >> 18) | 0xF0);
674
+ $newcharstring .= chr(($charval >> 12) | 0xC0);
675
+ $newcharstring .= chr(($charval >> 6) | 0xC0);
676
+ $newcharstring .= chr(($charval & 0x3F) | 0x80);
677
+ }
678
+ return $newcharstring;
679
+ }
680
+
681
+ // ISO-8859-1 => UTF-8
682
+ public static function iconv_fallback_iso88591_utf8($string, $bom=false) {
683
+ if (function_exists('utf8_encode')) {
684
+ return utf8_encode($string);
685
+ }
686
+ // utf8_encode() unavailable, use getID3()'s iconv_fallback() conversions (possibly PHP is compiled without XML support)
687
+ $newcharstring = '';
688
+ if ($bom) {
689
+ $newcharstring .= "\xEF\xBB\xBF";
690
+ }
691
+ for ($i = 0; $i < strlen($string); $i++) {
692
+ $charval = ord($string{$i});
693
+ $newcharstring .= self::iconv_fallback_int_utf8($charval);
694
+ }
695
+ return $newcharstring;
696
+ }
697
+
698
+ // ISO-8859-1 => UTF-16BE
699
+ public static function iconv_fallback_iso88591_utf16be($string, $bom=false) {
700
+ $newcharstring = '';
701
+ if ($bom) {
702
+ $newcharstring .= "\xFE\xFF";
703
+ }
704
+ for ($i = 0; $i < strlen($string); $i++) {
705
+ $newcharstring .= "\x00".$string{$i};
706
+ }
707
+ return $newcharstring;
708
+ }
709
+
710
+ // ISO-8859-1 => UTF-16LE
711
+ public static function iconv_fallback_iso88591_utf16le($string, $bom=false) {
712
+ $newcharstring = '';
713
+ if ($bom) {
714
+ $newcharstring .= "\xFF\xFE";
715
+ }
716
+ for ($i = 0; $i < strlen($string); $i++) {
717
+ $newcharstring .= $string{$i}."\x00";
718
+ }
719
+ return $newcharstring;
720
+ }
721
+
722
+ // ISO-8859-1 => UTF-16LE (BOM)
723
+ public static function iconv_fallback_iso88591_utf16($string) {
724
+ return self::iconv_fallback_iso88591_utf16le($string, true);
725
+ }
726
+
727
+ // UTF-8 => ISO-8859-1
728
+ public static function iconv_fallback_utf8_iso88591($string) {
729
+ if (function_exists('utf8_decode')) {
730
+ return utf8_decode($string);
731
+ }
732
+ // utf8_decode() unavailable, use getID3()'s iconv_fallback() conversions (possibly PHP is compiled without XML support)
733
+ $newcharstring = '';
734
+ $offset = 0;
735
+ $stringlength = strlen($string);
736
+ while ($offset < $stringlength) {
737
+ if ((ord($string{$offset}) | 0x07) == 0xF7) {
738
+ // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
739
+ $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
740
+ ((ord($string{($offset + 1)}) & 0x3F) << 12) &
741
+ ((ord($string{($offset + 2)}) & 0x3F) << 6) &
742
+ (ord($string{($offset + 3)}) & 0x3F);
743
+ $offset += 4;
744
+ } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
745
+ // 1110bbbb 10bbbbbb 10bbbbbb
746
+ $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
747
+ ((ord($string{($offset + 1)}) & 0x3F) << 6) &
748
+ (ord($string{($offset + 2)}) & 0x3F);
749
+ $offset += 3;
750
+ } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
751
+ // 110bbbbb 10bbbbbb
752
+ $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
753
+ (ord($string{($offset + 1)}) & 0x3F);
754
+ $offset += 2;
755
+ } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
756
+ // 0bbbbbbb
757
+ $charval = ord($string{$offset});
758
+ $offset += 1;
759
+ } else {
760
+ // error? throw some kind of warning here?
761
+ $charval = false;
762
+ $offset += 1;
763
+ }
764
+ if ($charval !== false) {
765
+ $newcharstring .= (($charval < 256) ? chr($charval) : '?');
766
+ }
767
+ }
768
+ return $newcharstring;
769
+ }
770
+
771
+ // UTF-8 => UTF-16BE
772
+ public static function iconv_fallback_utf8_utf16be($string, $bom=false) {
773
+ $newcharstring = '';
774
+ if ($bom) {
775
+ $newcharstring .= "\xFE\xFF";
776
+ }
777
+ $offset = 0;
778
+ $stringlength = strlen($string);
779
+ while ($offset < $stringlength) {
780
+ if ((ord($string{$offset}) | 0x07) == 0xF7) {
781
+ // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
782
+ $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
783
+ ((ord($string{($offset + 1)}) & 0x3F) << 12) &
784
+ ((ord($string{($offset + 2)}) & 0x3F) << 6) &
785
+ (ord($string{($offset + 3)}) & 0x3F);
786
+ $offset += 4;
787
+ } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
788
+ // 1110bbbb 10bbbbbb 10bbbbbb
789
+ $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
790
+ ((ord($string{($offset + 1)}) & 0x3F) << 6) &
791
+ (ord($string{($offset + 2)}) & 0x3F);
792
+ $offset += 3;
793
+ } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
794
+ // 110bbbbb 10bbbbbb
795
+ $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
796
+ (ord($string{($offset + 1)}) & 0x3F);
797
+ $offset += 2;
798
+ } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
799
+ // 0bbbbbbb
800
+ $charval = ord($string{$offset});
801
+ $offset += 1;
802
+ } else {
803
+ // error? throw some kind of warning here?
804
+ $charval = false;
805
+ $offset += 1;
806
+ }
807
+ if ($charval !== false) {
808
+ $newcharstring .= (($charval < 65536) ? self::BigEndian2String($charval, 2) : "\x00".'?');
809
+ }
810
+ }
811
+ return $newcharstring;
812
+ }
813
+
814
+ // UTF-8 => UTF-16LE
815
+ public static function iconv_fallback_utf8_utf16le($string, $bom=false) {
816
+ $newcharstring = '';
817
+ if ($bom) {
818
+ $newcharstring .= "\xFF\xFE";
819
+ }
820
+ $offset = 0;
821
+ $stringlength = strlen($string);
822
+ while ($offset < $stringlength) {
823
+ if ((ord($string{$offset}) | 0x07) == 0xF7) {
824
+ // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
825
+ $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
826
+ ((ord($string{($offset + 1)}) & 0x3F) << 12) &
827
+ ((ord($string{($offset + 2)}) & 0x3F) << 6) &
828
+ (ord($string{($offset + 3)}) & 0x3F);
829
+ $offset += 4;
830
+ } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
831
+ // 1110bbbb 10bbbbbb 10bbbbbb
832
+ $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
833
+ ((ord($string{($offset + 1)}) & 0x3F) << 6) &
834
+ (ord($string{($offset + 2)}) & 0x3F);
835
+ $offset += 3;
836
+ } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
837
+ // 110bbbbb 10bbbbbb
838
+ $charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
839
+ (ord($string{($offset + 1)}) & 0x3F);
840
+ $offset += 2;
841
+ } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
842
+ // 0bbbbbbb
843
+ $charval = ord($string{$offset});
844
+ $offset += 1;
845
+ } else {
846
+ // error? maybe throw some warning here?
847
+ $charval = false;
848
+ $offset += 1;
849
+ }
850
+ if ($charval !== false) {
851
+ $newcharstring .= (($charval < 65536) ? self::LittleEndian2String($charval, 2) : '?'."\x00");
852
+ }
853
+ }
854
+ return $newcharstring;
855
+ }
856
+
857
+ // UTF-8 => UTF-16LE (BOM)
858
+ public static function iconv_fallback_utf8_utf16($string) {
859
+ return self::iconv_fallback_utf8_utf16le($string, true);
860
+ }
861
+
862
+ // UTF-16BE => UTF-8
863
+ public static function iconv_fallback_utf16be_utf8($string) {
864
+ if (substr($string, 0, 2) == "\xFE\xFF") {
865
+ // strip BOM
866
+ $string = substr($string, 2);
867
+ }
868
+ $newcharstring = '';
869
+ for ($i = 0; $i < strlen($string); $i += 2) {
870
+ $charval = self::BigEndian2Int(substr($string, $i, 2));
871
+ $newcharstring .= self::iconv_fallback_int_utf8($charval);
872
+ }
873
+ return $newcharstring;
874
+ }
875
+
876
+ // UTF-16LE => UTF-8
877
+ public static function iconv_fallback_utf16le_utf8($string) {
878
+ if (substr($string, 0, 2) == "\xFF\xFE") {
879
+ // strip BOM
880
+ $string = substr($string, 2);
881
+ }
882
+ $newcharstring = '';
883
+ for ($i = 0; $i < strlen($string); $i += 2) {
884
+ $charval = self::LittleEndian2Int(substr($string, $i, 2));
885
+ $newcharstring .= self::iconv_fallback_int_utf8($charval);
886
+ }
887
+ return $newcharstring;
888
+ }
889
+
890
+ // UTF-16BE => ISO-8859-1
891
+ public static function iconv_fallback_utf16be_iso88591($string) {
892
+ if (substr($string, 0, 2) == "\xFE\xFF") {
893
+ // strip BOM
894
+ $string = substr($string, 2);
895
+ }
896
+ $newcharstring = '';
897
+ for ($i = 0; $i < strlen($string); $i += 2) {
898
+ $charval = self::BigEndian2Int(substr($string, $i, 2));
899
+ $newcharstring .= (($charval < 256) ? chr($charval) : '?');
900
+ }
901
+ return $newcharstring;
902
+ }
903
+
904
+ // UTF-16LE => ISO-8859-1
905
+ public static function iconv_fallback_utf16le_iso88591($string) {
906
+ if (substr($string, 0, 2) == "\xFF\xFE") {
907
+ // strip BOM
908
+ $string = substr($string, 2);
909
+ }
910
+ $newcharstring = '';
911
+ for ($i = 0; $i < strlen($string); $i += 2) {
912
+ $charval = self::LittleEndian2Int(substr($string, $i, 2));
913
+ $newcharstring .= (($charval < 256) ? chr($charval) : '?');
914
+ }
915
+ return $newcharstring;
916
+ }
917
+
918
+ // UTF-16 (BOM) => ISO-8859-1
919
+ public static function iconv_fallback_utf16_iso88591($string) {
920
+ $bom = substr($string, 0, 2);
921
+ if ($bom == "\xFE\xFF") {
922
+ return self::iconv_fallback_utf16be_iso88591(substr($string, 2));
923
+ } elseif ($bom == "\xFF\xFE") {
924
+ return self::iconv_fallback_utf16le_iso88591(substr($string, 2));
925
+ }
926
+ return $string;
927
+ }
928
+
929
+ // UTF-16 (BOM) => UTF-8
930
+ public static function iconv_fallback_utf16_utf8($string) {
931
+ $bom = substr($string, 0, 2);
932
+ if ($bom == "\xFE\xFF") {
933
+ return self::iconv_fallback_utf16be_utf8(substr($string, 2));
934
+ } elseif ($bom == "\xFF\xFE") {
935
+ return self::iconv_fallback_utf16le_utf8(substr($string, 2));
936
+ }
937
+ return $string;
938
+ }
939
+
940
+ public static function iconv_fallback($in_charset, $out_charset, $string) {
941
+
942
+ if ($in_charset == $out_charset) {
943
+ return $string;
944
+ }
945
+
946
+ // iconv() availble
947
+ if (function_exists('iconv')) {
948
+ if ($converted_string = @iconv($in_charset, $out_charset.'//TRANSLIT', $string)) {
949
+ switch ($out_charset) {
950
+ case 'ISO-8859-1':
951
+ $converted_string = rtrim($converted_string, "\x00");
952
+ break;
953
+ }
954
+ return $converted_string;
955
+ }
956
+
957
+ // iconv() may sometimes fail with "illegal character in input string" error message
958
+ // and return an empty string, but returning the unconverted string is more useful
959
+ return $string;
960
+ }
961
+
962
+
963
+ // iconv() not available
964
+ static $ConversionFunctionList = array();
965
+ if (empty($ConversionFunctionList)) {
966
+ $ConversionFunctionList['ISO-8859-1']['UTF-8'] = 'iconv_fallback_iso88591_utf8';
967
+ $ConversionFunctionList['ISO-8859-1']['UTF-16'] = 'iconv_fallback_iso88591_utf16';
968
+ $ConversionFunctionList['ISO-8859-1']['UTF-16BE'] = 'iconv_fallback_iso88591_utf16be';
969
+ $ConversionFunctionList['ISO-8859-1']['UTF-16LE'] = 'iconv_fallback_iso88591_utf16le';
970
+ $ConversionFunctionList['UTF-8']['ISO-8859-1'] = 'iconv_fallback_utf8_iso88591';
971
+ $ConversionFunctionList['UTF-8']['UTF-16'] = 'iconv_fallback_utf8_utf16';
972
+ $ConversionFunctionList['UTF-8']['UTF-16BE'] = 'iconv_fallback_utf8_utf16be';
973
+ $ConversionFunctionList['UTF-8']['UTF-16LE'] = 'iconv_fallback_utf8_utf16le';
974
+ $ConversionFunctionList['UTF-16']['ISO-8859-1'] = 'iconv_fallback_utf16_iso88591';
975
+ $ConversionFunctionList['UTF-16']['UTF-8'] = 'iconv_fallback_utf16_utf8';
976
+ $ConversionFunctionList['UTF-16LE']['ISO-8859-1'] = 'iconv_fallback_utf16le_iso88591';
977
+ $ConversionFunctionList['UTF-16LE']['UTF-8'] = 'iconv_fallback_utf16le_utf8';
978
+ $ConversionFunctionList['UTF-16BE']['ISO-8859-1'] = 'iconv_fallback_utf16be_iso88591';
979
+ $ConversionFunctionList['UTF-16BE']['UTF-8'] = 'iconv_fallback_utf16be_utf8';
980
+ }
981
+ if (isset($ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)])) {
982
+ $ConversionFunction = $ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)];
983
+ return self::$ConversionFunction($string);
984
+ }
985
+ throw new Exception('PHP does not have iconv() support - cannot convert from '.$in_charset.' to '.$out_charset);
986
+ }
987
+
988
+
989
+ public static function MultiByteCharString2HTML($string, $charset='ISO-8859-1') {
990
+ $string = (string) $string; // in case trying to pass a numeric (float, int) string, would otherwise return an empty string
991
+ $HTMLstring = '';
992
+
993
+ switch ($charset) {
994
+ case '1251':
995
+ case '1252':
996
+ case '866':
997
+ case '932':
998
+ case '936':
999
+ case '950':
1000
+ case 'BIG5':
1001
+ case 'BIG5-HKSCS':
1002
+ case 'cp1251':
1003
+ case 'cp1252':
1004
+ case 'cp866':
1005
+ case 'EUC-JP':
1006
+ case 'EUCJP':
1007
+ case 'GB2312':
1008
+ case 'ibm866':
1009
+ case 'ISO-8859-1':
1010
+ case 'ISO-8859-15':
1011
+ case 'ISO8859-1':
1012
+ case 'ISO8859-15':
1013
+ case 'KOI8-R':
1014
+ case 'koi8-ru':
1015
+ case 'koi8r':
1016
+ case 'Shift_JIS':
1017
+ case 'SJIS':
1018
+ case 'win-1251':
1019
+ case 'Windows-1251':
1020
+ case 'Windows-1252':
1021
+ $HTMLstring = htmlentities($string, ENT_COMPAT, $charset);
1022
+ break;
1023
+
1024
+ case 'UTF-8':
1025
+ $strlen = strlen($string);
1026
+ for ($i = 0; $i < $strlen; $i++) {
1027
+ $char_ord_val = ord($string{$i});
1028
+ $charval = 0;
1029
+ if ($char_ord_val < 0x80) {
1030
+ $charval = $char_ord_val;
1031
+ } elseif ((($char_ord_val & 0xF0) >> 4) == 0x0F && $i+3 < $strlen) {
1032
+ $charval = (($char_ord_val & 0x07) << 18);
1033
+ $charval += ((ord($string{++$i}) & 0x3F) << 12);
1034
+ $charval += ((ord($string{++$i}) & 0x3F) << 6);
1035
+ $charval += (ord($string{++$i}) & 0x3F);
1036
+ } elseif ((($char_ord_val & 0xE0) >> 5) == 0x07 && $i+2 < $strlen) {
1037
+ $charval = (($char_ord_val & 0x0F) << 12);
1038
+ $charval += ((ord($string{++$i}) & 0x3F) << 6);
1039
+ $charval += (ord($string{++$i}) & 0x3F);
1040
+ } elseif ((($char_ord_val & 0xC0) >> 6) == 0x03 && $i+1 < $strlen) {
1041
+ $charval = (($char_ord_val & 0x1F) << 6);
1042
+ $charval += (ord($string{++$i}) & 0x3F);
1043
+ }
1044
+ if (($charval >= 32) && ($charval <= 127)) {
1045
+ $HTMLstring .= htmlentities(chr($charval));
1046
+ } else {
1047
+ $HTMLstring .= '&#'.$charval.';';
1048
+ }
1049
+ }
1050
+ break;
1051
+
1052
+ case 'UTF-16LE':
1053
+ for ($i = 0; $i < strlen($string); $i += 2) {
1054
+ $charval = self::LittleEndian2Int(substr($string, $i, 2));
1055
+ if (($charval >= 32) && ($charval <= 127)) {
1056
+ $HTMLstring .= chr($charval);
1057
+ } else {
1058
+ $HTMLstring .= '&#'.$charval.';';
1059
+ }
1060
+ }
1061
+ break;
1062
+
1063
+ case 'UTF-16BE':
1064
+ for ($i = 0; $i < strlen($string); $i += 2) {
1065
+ $charval = self::BigEndian2Int(substr($string, $i, 2));
1066
+ if (($charval >= 32) && ($charval <= 127)) {
1067
+ $HTMLstring .= chr($charval);
1068
+ } else {
1069
+ $HTMLstring .= '&#'.$charval.';';
1070
+ }
1071
+ }
1072
+ break;
1073
+
1074
+ default:
1075
+ $HTMLstring = 'ERROR: Character set "'.$charset.'" not supported in MultiByteCharString2HTML()';
1076
+ break;
1077
+ }
1078
+ return $HTMLstring;
1079
+ }
1080
+
1081
+
1082
+
1083
+ public static function RGADnameLookup($namecode) {
1084
+ static $RGADname = array();
1085
+ if (empty($RGADname)) {
1086
+ $RGADname[0] = 'not set';
1087
+ $RGADname[1] = 'Track Gain Adjustment';
1088
+ $RGADname[2] = 'Album Gain Adjustment';
1089
+ }
1090
+
1091
+ return (isset($RGADname[$namecode]) ? $RGADname[$namecode] : '');
1092
+ }
1093
+
1094
+
1095
+ public static function RGADoriginatorLookup($originatorcode) {
1096
+ static $RGADoriginator = array();
1097
+ if (empty($RGADoriginator)) {
1098
+ $RGADoriginator[0] = 'unspecified';
1099
+ $RGADoriginator[1] = 'pre-set by artist/producer/mastering engineer';
1100
+ $RGADoriginator[2] = 'set by user';
1101
+ $RGADoriginator[3] = 'determined automatically';
1102
+ }
1103
+
1104
+ return (isset($RGADoriginator[$originatorcode]) ? $RGADoriginator[$originatorcode] : '');
1105
+ }
1106
+
1107
+
1108
+ public static function RGADadjustmentLookup($rawadjustment, $signbit) {
1109
+ $adjustment = $rawadjustment / 10;
1110
+ if ($signbit == 1) {
1111
+ $adjustment *= -1;
1112
+ }
1113
+ return (float) $adjustment;
1114
+ }
1115
+
1116
+
1117
+ public static function RGADgainString($namecode, $originatorcode, $replaygain) {
1118
+ if ($replaygain < 0) {
1119
+ $signbit = '1';
1120
+ } else {
1121
+ $signbit = '0';
1122
+ }
1123
+ $storedreplaygain = intval(round($replaygain * 10));
1124
+ $gainstring = str_pad(decbin($namecode), 3, '0', STR_PAD_LEFT);
1125
+ $gainstring .= str_pad(decbin($originatorcode), 3, '0', STR_PAD_LEFT);
1126
+ $gainstring .= $signbit;
1127
+ $gainstring .= str_pad(decbin($storedreplaygain), 9, '0', STR_PAD_LEFT);
1128
+
1129
+ return $gainstring;
1130
+ }
1131
+
1132
+ public static function RGADamplitude2dB($amplitude) {
1133
+ return 20 * log10($amplitude);
1134
+ }
1135
+
1136
+
1137
+ public static function GetDataImageSize($imgData, &$imageinfo=array()) {
1138
+ static $tempdir = '';
1139
+ if (empty($tempdir)) {
1140
+ // yes this is ugly, feel free to suggest a better way
1141
+ require_once(dirname(__FILE__).'/getid3.php');
1142
+ $getid3_temp = new getID3();
1143
+ $tempdir = $getid3_temp->tempdir;
1144
+ unset($getid3_temp);
1145
+ }
1146
+ $GetDataImageSize = false;
1147
+ if ($tempfilename = tempnam($tempdir, 'gI3')) {
1148
+ if (is_writable($tempfilename) && is_file($tempfilename) && ($tmp = fopen($tempfilename, 'wb'))) {
1149
+ fwrite($tmp, $imgData);
1150
+ fclose($tmp);
1151
+ $GetDataImageSize = @getimagesize($tempfilename, $imageinfo);
1152
+ }
1153
+ unlink($tempfilename);
1154
+ }
1155
+ return $GetDataImageSize;
1156
+ }
1157
+
1158
+ public static function ImageExtFromMime($mime_type) {
1159
+ // temporary way, works OK for now, but should be reworked in the future
1160
+ return str_replace(array('image/', 'x-', 'jpeg'), array('', '', 'jpg'), $mime_type);
1161
+ }
1162
+
1163
+ public static function ImageTypesLookup($imagetypeid) {
1164
+ static $ImageTypesLookup = array();
1165
+ if (empty($ImageTypesLookup)) {
1166
+ $ImageTypesLookup[1] = 'gif';
1167
+ $ImageTypesLookup[2] = 'jpeg';
1168
+ $ImageTypesLookup[3] = 'png';
1169
+ $ImageTypesLookup[4] = 'swf';
1170
+ $ImageTypesLookup[5] = 'psd';
1171
+ $ImageTypesLookup[6] = 'bmp';
1172
+ $ImageTypesLookup[7] = 'tiff (little-endian)';
1173
+ $ImageTypesLookup[8] = 'tiff (big-endian)';
1174
+ $ImageTypesLookup[9] = 'jpc';
1175
+ $ImageTypesLookup[10] = 'jp2';
1176
+ $ImageTypesLookup[11] = 'jpx';
1177
+ $ImageTypesLookup[12] = 'jb2';
1178
+ $ImageTypesLookup[13] = 'swc';
1179
+ $ImageTypesLookup[14] = 'iff';
1180
+ }
1181
+ return (isset($ImageTypesLookup[$imagetypeid]) ? $ImageTypesLookup[$imagetypeid] : '');
1182
+ }
1183
+
1184
+ public static function CopyTagsToComments(&$ThisFileInfo) {
1185
+
1186
+ // Copy all entries from ['tags'] into common ['comments']
1187
+ if (!empty($ThisFileInfo['tags'])) {
1188
+ foreach ($ThisFileInfo['tags'] as $tagtype => $tagarray) {
1189
+ foreach ($tagarray as $tagname => $tagdata) {
1190
+ foreach ($tagdata as $key => $value) {
1191
+ if (!empty($value)) {
1192
+ if (empty($ThisFileInfo['comments'][$tagname])) {
1193
+
1194
+ // fall through and append value
1195
+
1196
+ } elseif ($tagtype == 'id3v1') {
1197
+
1198
+ $newvaluelength = strlen(trim($value));
1199
+ foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
1200
+ $oldvaluelength = strlen(trim($existingvalue));
1201
+ if (($newvaluelength <= $oldvaluelength) && (substr($existingvalue, 0, $newvaluelength) == trim($value))) {
1202
+ // new value is identical but shorter-than (or equal-length to) one already in comments - skip
1203
+ break 2;
1204
+ }
1205
+ }
1206
+
1207
+ } elseif (!is_array($value)) {
1208
+
1209
+ $newvaluelength = strlen(trim($value));
1210
+ foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
1211
+ $oldvaluelength = strlen(trim($existingvalue));
1212
+ if (($newvaluelength > $oldvaluelength) && (substr(trim($value), 0, strlen($existingvalue)) == $existingvalue)) {
1213
+ $ThisFileInfo['comments'][$tagname][$existingkey] = trim($value);
1214
+ break 2;
1215
+ }
1216
+ }
1217
+
1218
+ }
1219
+ if (is_array($value) || empty($ThisFileInfo['comments'][$tagname]) || !in_array(trim($value), $ThisFileInfo['comments'][$tagname])) {
1220
+ $value = (is_string($value) ? trim($value) : $value);
1221
+ $ThisFileInfo['comments'][$tagname][] = $value;
1222
+ }
1223
+ }
1224
+ }
1225
+ }
1226
+ }
1227
+
1228
+ // Copy to ['comments_html']
1229
+ foreach ($ThisFileInfo['comments'] as $field => $values) {
1230
+ if ($field == 'picture') {
1231
+ // pictures can take up a lot of space, and we don't need multiple copies of them
1232
+ // let there be a single copy in [comments][picture], and not elsewhere
1233
+ continue;
1234
+ }
1235
+ foreach ($values as $index => $value) {
1236
+ if (is_array($value)) {
1237
+ $ThisFileInfo['comments_html'][$field][$index] = $value;
1238
+ } else {
1239
+ $ThisFileInfo['comments_html'][$field][$index] = str_replace('&#0;', '', self::MultiByteCharString2HTML($value, $ThisFileInfo['encoding']));
1240
+ }
1241
+ }
1242
+ }
1243
+ }
1244
+ return true;
1245
+ }
1246
+
1247
+
1248
+ public static function EmbeddedLookup($key, $begin, $end, $file, $name) {
1249
+
1250
+ // Cached
1251
+ static $cache;
1252
+ if (isset($cache[$file][$name])) {
1253
+ return (isset($cache[$file][$name][$key]) ? $cache[$file][$name][$key] : '');
1254
+ }
1255
+
1256
+ // Init
1257
+ $keylength = strlen($key);
1258
+ $line_count = $end - $begin - 7;
1259
+
1260
+ // Open php file
1261
+ $fp = fopen($file, 'r');
1262
+
1263
+ // Discard $begin lines
1264
+ for ($i = 0; $i < ($begin + 3); $i++) {
1265
+ fgets($fp, 1024);
1266
+ }
1267
+
1268
+ // Loop thru line
1269
+ while (0 < $line_count--) {
1270
+
1271
+ // Read line
1272
+ $line = ltrim(fgets($fp, 1024), "\t ");
1273
+
1274
+ // METHOD A: only cache the matching key - less memory but slower on next lookup of not-previously-looked-up key
1275
+ //$keycheck = substr($line, 0, $keylength);
1276
+ //if ($key == $keycheck) {
1277
+ // $cache[$file][$name][$keycheck] = substr($line, $keylength + 1);
1278
+ // break;
1279
+ //}
1280
+
1281
+ // METHOD B: cache all keys in this lookup - more memory but faster on next lookup of not-previously-looked-up key
1282
+ //$cache[$file][$name][substr($line, 0, $keylength)] = trim(substr($line, $keylength + 1));
1283
+ $explodedLine = explode("\t", $line, 2);
1284
+ $ThisKey = (isset($explodedLine[0]) ? $explodedLine[0] : '');
1285
+ $ThisValue = (isset($explodedLine[1]) ? $explodedLine[1] : '');
1286
+ $cache[$file][$name][$ThisKey] = trim($ThisValue);
1287
+ }
1288
+
1289
+ // Close and return
1290
+ fclose($fp);
1291
+ return (isset($cache[$file][$name][$key]) ? $cache[$file][$name][$key] : '');
1292
+ }
1293
+
1294
+ public static function IncludeDependency($filename, $sourcefile, $DieOnFailure=false) {
1295
+ global $GETID3_ERRORARRAY;
1296
+
1297
+ if (file_exists($filename)) {
1298
+ if (include_once($filename)) {
1299
+ return true;
1300
+ } else {
1301
+ $diemessage = basename($sourcefile).' depends on '.$filename.', which has errors';
1302
+ }
1303
+ } else {
1304
+ $diemessage = basename($sourcefile).' depends on '.$filename.', which is missing';
1305
+ }
1306
+ if ($DieOnFailure) {
1307
+ throw new Exception($diemessage);
1308
+ } else {
1309
+ $GETID3_ERRORARRAY[] = $diemessage;
1310
+ }
1311
+ return false;
1312
+ }
1313
+
1314
+ public static function trimNullByte($string) {
1315
+ return trim($string, "\x00");
1316
+ }
1317
+
1318
+ public static function getFileSizeSyscall($path) {
1319
+ $filesize = false;
1320
+
1321
+ if (GETID3_OS_ISWINDOWS) {
1322
+ if (class_exists('COM')) { // From PHP 5.3.15 and 5.4.5, COM and DOTNET is no longer built into the php core.you have to add COM support in php.ini:
1323
+ $filesystem = new COM('Scripting.FileSystemObject');
1324
+ $file = $filesystem->GetFile($path);
1325
+ $filesize = $file->Size();
1326
+ unset($filesystem, $file);
1327
+ } else {
1328
+ $commandline = 'for %I in ('.escapeshellarg($path).') do @echo %~zI';
1329
+ }
1330
+ } else {
1331
+ $commandline = 'ls -l '.escapeshellarg($path).' | awk \'{print $5}\'';
1332
+ }
1333
+ if (isset($commandline)) {
1334
+ $output = trim(`$commandline`);
1335
+ if (ctype_digit($output)) {
1336
+ $filesize = (float) $output;
1337
+ }
1338
+ }
1339
+ return $filesize;
1340
+ }
1341
+
1342
+ }
{view → includes}/getid3/getid3.php RENAMED
@@ -1,1397 +1,1776 @@
1
- <?php
2
- /////////////////////////////////////////////////////////////////
3
- /// getID3() by James Heinrich <info@getid3.org> //
4
- // available at http://getid3.sourceforge.net //
5
- // or http://www.getid3.org //
6
- /////////////////////////////////////////////////////////////////
7
- // //
8
- // Please see readme.txt for more information //
9
- // ///
10
- /////////////////////////////////////////////////////////////////
11
-
12
- // Defines
13
- define('GETID3_VERSION', '1.7.9-20090308');
14
- define('GETID3_FREAD_BUFFER_SIZE', 16384); // read buffer size in bytes
15
-
16
-
17
-
18
- class getID3
19
- {
20
- // public: Settings
21
- var $encoding = 'ISO-8859-1'; // CASE SENSITIVE! - i.e. (must be supported by iconv())
22
- // Examples: ISO-8859-1 UTF-8 UTF-16 UTF-16BE
23
-
24
- var $encoding_id3v1 = 'ISO-8859-1'; // Should always be 'ISO-8859-1', but some tags may be written in other encodings such as 'EUC-CN'
25
-
26
- var $tempdir = '*'; // default '*' should use system temp dir
27
-
28
- // public: Optional tag checks - disable for speed.
29
- var $option_tag_id3v1 = true; // Read and process ID3v1 tags
30
- var $option_tag_id3v2 = true; // Read and process ID3v2 tags
31
- var $option_tag_lyrics3 = true; // Read and process Lyrics3 tags
32
- var $option_tag_apetag = true; // Read and process APE tags
33
- var $option_tags_process = true; // Copy tags to root key 'tags' and encode to $this->encoding
34
- var $option_tags_html = true; // Copy tags to root key 'tags_html' properly translated from various encodings to HTML entities
35
-
36
- // public: Optional tag/comment calucations
37
- var $option_extra_info = true; // Calculate additional info such as bitrate, channelmode etc
38
-
39
- // public: Optional calculations
40
- var $option_md5_data = false; // Get MD5 sum of data part - slow
41
- var $option_md5_data_source = false; // Use MD5 of source file if availble - only FLAC and OptimFROG
42
- var $option_sha1_data = false; // Get SHA1 sum of data part - slow
43
- var $option_max_2gb_check = true; // Check whether file is larger than 2 Gb and thus not supported by PHP
44
-
45
- // private
46
- var $filename;
47
-
48
-
49
- // public: constructor
50
- function getID3()
51
- {
52
-
53
- $this->startup_error = '';
54
- $this->startup_warning = '';
55
-
56
- // Check for PHP version >= 4.2.0
57
- if (phpversion() < '4.2.0') {
58
- $this->startup_error .= 'getID3() requires PHP v4.2.0 or higher - you are running v'.phpversion();
59
- }
60
-
61
- // Check memory
62
- $memory_limit = ini_get('memory_limit');
63
- if (eregi('([0-9]+)M', $memory_limit, $matches)) {
64
- // could be stored as "16M" rather than 16777216 for example
65
- $memory_limit = $matches[1] * 1048576;
66
- }
67
- if ($memory_limit <= 0) {
68
- // memory limits probably disabled
69
- } elseif ($memory_limit <= 3145728) {
70
- $this->startup_error .= 'PHP has less than 3MB available memory and will very likely run out. Increase memory_limit in php.ini';
71
- } elseif ($memory_limit <= 12582912) {
72
- $this->startup_warning .= 'PHP has less than 12MB available memory and might run out if all modules are loaded. Increase memory_limit in php.ini';
73
- }
74
-
75
- // Check safe_mode off
76
- if ((bool) ini_get('safe_mode')) {
77
- $this->warning('WARNING: Safe mode is on, shorten support disabled, md5data/sha1data for ogg vorbis disabled, ogg vorbos/flac tag writing disabled.');
78
- }
79
-
80
-
81
- // define a constant rather than looking up every time it is needed
82
- if (!defined('GETID3_OS_ISWINDOWS')) {
83
- if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
84
- define('GETID3_OS_ISWINDOWS', true);
85
- } else {
86
- define('GETID3_OS_ISWINDOWS', false);
87
- }
88
- }
89
-
90
- // Get base path of getID3() - ONCE
91
- if (!defined('GETID3_INCLUDEPATH')) {
92
- foreach (get_included_files() as $key => $val) {
93
- if (basename($val) == 'getid3.php') {
94
- define('GETID3_INCLUDEPATH', dirname($val).DIRECTORY_SEPARATOR);
95
- break;
96
- }
97
- }
98
- }
99
-
100
- // Load support library
101
- if (!include_once(GETID3_INCLUDEPATH.'getid3.lib.php')) {
102
- $this->startup_error .= 'getid3.lib.php is missing or corrupt';
103
- }
104
-
105
-
106
- // Needed for Windows only:
107
- // Define locations of helper applications for Shorten, VorbisComment, MetaFLAC
108
- // as well as other helper functions such as head, tail, md5sum, etc
109
- // IMPORTANT: This path cannot have spaces in it. If neccesary, use the 8dot3 equivalent
110
- // ie for "C:/Program Files/Apache/" put "C:/PROGRA~1/APACHE/"
111
- // IMPORTANT: This path must include the trailing slash
112
- if (GETID3_OS_ISWINDOWS && !defined('GETID3_HELPERAPPSDIR')) {
113
-
114
- $helperappsdir = GETID3_INCLUDEPATH.'..'.DIRECTORY_SEPARATOR.'helperapps'; // must not have any space in this path
115
-
116
- if (!is_dir($helperappsdir)) {
117
- $this->startup_error .= '"'.$helperappsdir.'" cannot be defined as GETID3_HELPERAPPSDIR because it does not exist';
118
- } elseif (strpos(realpath($helperappsdir), ' ') !== false) {
119
- $DirPieces = explode(DIRECTORY_SEPARATOR, realpath($helperappsdir));
120
- foreach ($DirPieces as $key => $value) {
121
- if ((strpos($value, '.') !== false) && (strpos($value, ' ') === false)) {
122
- if (strpos($value, '.') > 8) {
123
- $value = substr($value, 0, 6).'~1';
124
- }
125
- } elseif ((strpos($value, ' ') !== false) || strlen($value) > 8) {
126
- $value = substr($value, 0, 6).'~1';
127
- }
128
- $DirPieces[$key] = strtoupper($value);
129
- }
130
- $this->startup_error .= 'GETID3_HELPERAPPSDIR must not have any spaces in it - use 8dot3 naming convention if neccesary (on this server that would be something like "'.implode(DIRECTORY_SEPARATOR, $DirPieces).'" - NOTE: this may or may not be the actual 8.3 equivalent of "'.$helperappsdir.'", please double-check). You can run "dir /x" from the commandline to see the correct 8.3-style names.';
131
- }
132
- define('GETID3_HELPERAPPSDIR', realpath($helperappsdir).DIRECTORY_SEPARATOR);
133
- }
134
-
135
- }
136
-
137
-
138
- // public: setOption
139
- function setOption($optArray) {
140
- if (!is_array($optArray) || empty($optArray)) {
141
- return false;
142
- }
143
- foreach ($optArray as $opt => $val) {
144
- //if (isset($this, $opt) === false) {
145
- if (isset($this->$opt) === false) {
146
- continue;
147
- }
148
- $this->$opt = $val;
149
- }
150
- return true;
151
- }
152
-
153
-
154
- // public: analyze file - replaces GetAllFileInfo() and GetTagOnly()
155
- function analyze($filename) {
156
-
157
- if (!empty($this->startup_error)) {
158
- return $this->error($this->startup_error);
159
- }
160
- if (!empty($this->startup_warning)) {
161
- $this->warning($this->startup_warning);
162
- }
163
-
164
- // init result array and set parameters
165
- $this->info = array();
166
- $this->info['GETID3_VERSION'] = GETID3_VERSION;
167
-
168
- // Check encoding/iconv support
169
- if (!function_exists('iconv') && !in_array($this->encoding, array('ISO-8859-1', 'UTF-8', 'UTF-16LE', 'UTF-16BE', 'UTF-16'))) {
170
- $errormessage = 'iconv() support is needed for encodings other than ISO-8859-1, UTF-8, UTF-16LE, UTF16-BE, UTF-16. ';
171
- if (GETID3_OS_ISWINDOWS) {
172
- $errormessage .= 'PHP does not have iconv() support. Please enable php_iconv.dll in php.ini, and copy iconv.dll from c:/php/dlls to c:/windows/system32';
173
- } else {
174
- $errormessage .= 'PHP is not compiled with iconv() support. Please recompile with the --with-iconv switch';
175
- }
176
- return $this->error($errormessage);
177
- }
178
-
179
- // Disable magic_quotes_runtime, if neccesary
180
- $old_magic_quotes_runtime = get_magic_quotes_runtime(); // store current setting of magic_quotes_runtime
181
- if ($old_magic_quotes_runtime) {
182
- set_magic_quotes_runtime(0); // turn off magic_quotes_runtime
183
- if (get_magic_quotes_runtime()) {
184
- return $this->error('Could not disable magic_quotes_runtime - getID3() cannot work properly with this setting enabled');
185
- }
186
- }
187
-
188
- // remote files not supported
189
- if (preg_match('/^(ht|f)tp:\/\//', $filename)) {
190
- return $this->error('Remote files are not supported in this version of getID3() - please copy the file locally first');
191
- }
192
-
193
- $filename = str_replace('/', DIRECTORY_SEPARATOR, $filename);
194
- $filename = preg_replace('#'.preg_quote(DIRECTORY_SEPARATOR).'{2,}#', DIRECTORY_SEPARATOR, $filename);
195
-
196
- // open local file
197
- if (file_exists($filename) && ($fp = @fopen($filename, 'rb'))) {
198
- // great
199
- } else {
200
- return $this->error('Could not open file "'.$filename.'"');
201
- }
202
-
203
- // set parameters
204
- $this->info['filesize'] = filesize($filename);
205
-
206
- // option_max_2gb_check
207
- if ($this->option_max_2gb_check) {
208
- // PHP doesn't support integers larger than 31-bit (~2GB)
209
- // filesize() simply returns (filesize % (pow(2, 32)), no matter the actual filesize
210
- // ftell() returns 0 if seeking to the end is beyond the range of unsigned integer
211
- fseek($fp, 0, SEEK_END);
212
- if ((($this->info['filesize'] != 0) && (ftell($fp) == 0)) ||
213
- ($this->info['filesize'] < 0) ||
214
- (ftell($fp) < 0)) {
215
- $real_filesize = false;
216
- if (GETID3_OS_ISWINDOWS) {
217
- $commandline = 'dir /-C "'.str_replace('/', DIRECTORY_SEPARATOR, $filename).'"';
218
- $dir_output = `$commandline`;
219
- if (eregi('1 File\(s\)[ ]+([0-9]+) bytes', $dir_output, $matches)) {
220
- $real_filesize = (float) $matches[1];
221
- }
222
- } else {
223
- $commandline = 'ls -o -g -G --time-style=long-iso '.escapeshellarg($filename);
224
- $dir_output = `$commandline`;
225
- if (eregi('([0-9]+) ([0-9]{4}-[0-9]{2}\-[0-9]{2} [0-9]{2}:[0-9]{2}) '.preg_quote($filename).'$', $dir_output, $matches)) {
226
- $real_filesize = (float) $matches[1];
227
- }
228
- }
229
- if ($real_filesize === false) {
230
- unset($this->info['filesize']);
231
- fclose($fp);
232
- return $this->error('File is most likely larger than 2GB and is not supported by PHP');
233
- } elseif ($real_filesize < pow(2, 31)) {
234
- unset($this->info['filesize']);
235
- fclose($fp);
236
- return $this->error('PHP seems to think the file is larger than 2GB, but filesystem reports it as '.number_format($real_filesize, 3).'GB, please report to info@getid3.org');
237
- }
238
- $this->info['filesize'] = $real_filesize;
239
- $this->error('File is larger than 2GB (filesystem reports it as '.number_format($real_filesize, 3).'GB) and is not properly supported by PHP.');
240
- }
241
- }
242
-
243
- // set more parameters
244
- $this->info['avdataoffset'] = 0;
245
- $this->info['avdataend'] = $this->info['filesize'];
246
- $this->info['fileformat'] = ''; // filled in later
247
- $this->info['audio']['dataformat'] = ''; // filled in later, unset if not used
248
- $this->info['video']['dataformat'] = ''; // filled in later, unset if not used
249
- $this->info['tags'] = array(); // filled in later, unset if not used
250
- $this->info['error'] = array(); // filled in later, unset if not used
251
- $this->info['warning'] = array(); // filled in later, unset if not used
252
- $this->info['comments'] = array(); // filled in later, unset if not used
253
- $this->info['encoding'] = $this->encoding; // required by id3v2 and iso modules - can be unset at the end if desired
254
-
255
- // set redundant parameters - might be needed in some include file
256
- $this->info['filename'] = basename($filename);
257
- $this->info['filepath'] = str_replace('\\', '/', realpath(dirname($filename)));
258
- $this->info['filenamepath'] = $this->info['filepath'].'/'.$this->info['filename'];
259
-
260
-
261
- // handle ID3v2 tag - done first - already at beginning of file
262
- // ID3v2 detection (even if not parsing) is always done otherwise fileformat is much harder to detect
263
- if ($this->option_tag_id3v2) {
264
-
265
- $GETID3_ERRORARRAY = &$this->info['warning'];
266
- if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v2.php', __FILE__, false)) {
267
- $tag = new getid3_id3v2($fp, $this->info);
268
- unset($tag);
269
- }
270
-
271
- } else {
272
-
273
- fseek($fp, 0, SEEK_SET);
274
- $header = fread($fp, 10);
275
- if (substr($header, 0, 3) == 'ID3' && strlen($header) == 10) {
276
- $this->info['id3v2']['header'] = true;
277
- $this->info['id3v2']['majorversion'] = ord($header{3});
278
- $this->info['id3v2']['minorversion'] = ord($header{4});
279
- $this->info['id3v2']['headerlength'] = getid3_lib::BigEndian2Int(substr($header, 6, 4), 1) + 10; // length of ID3v2 tag in 10-byte header doesn't include 10-byte header length
280
-
281
- $this->info['id3v2']['tag_offset_start'] = 0;
282
- $this->info['id3v2']['tag_offset_end'] = $this->info['id3v2']['tag_offset_start'] + $this->info['id3v2']['headerlength'];
283
- $this->info['avdataoffset'] = $this->info['id3v2']['tag_offset_end'];
284
- }
285
-
286
- }
287
-
288
-
289
- // handle ID3v1 tag
290
- if ($this->option_tag_id3v1) {
291
- if (!@include_once(GETID3_INCLUDEPATH.'module.tag.id3v1.php')) {
292
- return $this->error('module.tag.id3v1.php is missing - you may disable option_tag_id3v1.');
293
- }
294
- $tag = new getid3_id3v1($fp, $this->info);
295
- unset($tag);
296
- }
297
-
298
- // handle APE tag
299
- if ($this->option_tag_apetag) {
300
- if (!@include_once(GETID3_INCLUDEPATH.'module.tag.apetag.php')) {
301
- return $this->error('module.tag.apetag.php is missing - you may disable option_tag_apetag.');
302
- }
303
- $tag = new getid3_apetag($fp, $this->info);
304
- unset($tag);
305
- }
306
-
307
- // handle lyrics3 tag
308
- if ($this->option_tag_lyrics3) {
309
- if (!@include_once(GETID3_INCLUDEPATH.'module.tag.lyrics3.php')) {
310
- return $this->error('module.tag.lyrics3.php is missing - you may disable option_tag_lyrics3.');
311
- }
312
- $tag = new getid3_lyrics3($fp, $this->info);
313
- unset($tag);
314
- }
315
-
316
- // read 32 kb file data
317
- fseek($fp, $this->info['avdataoffset'], SEEK_SET);
318
- $formattest = fread($fp, 32774);
319
-
320
- // determine format
321
- $determined_format = $this->GetFileFormat($formattest, $filename);
322
-
323
- // unable to determine file format
324
- if (!$determined_format) {
325
- fclose($fp);
326
- return $this->error('unable to determine file format');
327
- }
328
-
329
- // check for illegal ID3 tags
330
- if (isset($determined_format['fail_id3']) && (in_array('id3v1', $this->info['tags']) || in_array('id3v2', $this->info['tags']))) {
331
- if ($determined_format['fail_id3'] === 'ERROR') {
332
- fclose($fp);
333
- return $this->error('ID3 tags not allowed on this file type.');
334
- } elseif ($determined_format['fail_id3'] === 'WARNING') {
335
- $this->info['warning'][] = 'ID3 tags not allowed on this file type.';
336
- }
337
- }
338
-
339
- // check for illegal APE tags
340
- if (isset($determined_format['fail_ape']) && in_array('ape', $this->info['tags'])) {
341
- if ($determined_format['fail_ape'] === 'ERROR') {
342
- fclose($fp);
343
- return $this->error('APE tags not allowed on this file type.');
344
- } elseif ($determined_format['fail_ape'] === 'WARNING') {
345
- $this->info['warning'][] = 'APE tags not allowed on this file type.';
346
- }
347
- }
348
-
349
- // set mime type
350
- $this->info['mime_type'] = $determined_format['mime_type'];
351
-
352
- // supported format signature pattern detected, but module deleted
353
- if (!file_exists(GETID3_INCLUDEPATH.$determined_format['include'])) {
354
- fclose($fp);
355
- return $this->error('Format not supported, module "'.$determined_format['include'].'" was removed.');
356
- }
357
-
358
- // module requires iconv support
359
- if (!function_exists('iconv') && @$determined_format['iconv_req']) {
360
- return $this->error('iconv support is required for this module ('.$determined_format['include'].').');
361
- }
362
-
363
- // include module
364
- include_once(GETID3_INCLUDEPATH.$determined_format['include']);
365
-
366
- // instantiate module class
367
- $class_name = 'getid3_'.$determined_format['module'];
368
- if (!class_exists($class_name)) {
369
- return $this->error('Format not supported, module "'.$determined_format['include'].'" is corrupt.');
370
- }
371
- if (isset($determined_format['option'])) {
372
- $class = new $class_name($fp, $this->info, $determined_format['option']);
373
- } else {
374
- $class = new $class_name($fp, $this->info);
375
- }
376
- unset($class);
377
-
378
- // close file
379
- fclose($fp);
380
-
381
- // process all tags - copy to 'tags' and convert charsets
382
- if ($this->option_tags_process) {
383
- $this->HandleAllTags();
384
- }
385
-
386
- // perform more calculations
387
- if ($this->option_extra_info) {
388
- $this->ChannelsBitratePlaytimeCalculations();
389
- $this->CalculateCompressionRatioVideo();
390
- $this->CalculateCompressionRatioAudio();
391
- $this->CalculateReplayGain();
392
- $this->ProcessAudioStreams();
393
- }
394
-
395
- // get the MD5 sum of the audio/video portion of the file - without ID3/APE/Lyrics3/etc header/footer tags
396
- if ($this->option_md5_data) {
397
- // do not cald md5_data if md5_data_source is present - set by flac only - future MPC/SV8 too
398
- if (!$this->option_md5_data_source || empty($this->info['md5_data_source'])) {
399
- $this->getHashdata('md5');
400
- }
401
- }
402
-
403
- // get the SHA1 sum of the audio/video portion of the file - without ID3/APE/Lyrics3/etc header/footer tags
404
- if ($this->option_sha1_data) {
405
- $this->getHashdata('sha1');
406
- }
407
-
408
- // remove undesired keys
409
- $this->CleanUp();
410
-
411
- // restore magic_quotes_runtime setting
412
- set_magic_quotes_runtime($old_magic_quotes_runtime);
413
-
414
- // return info array
415
- return $this->info;
416
- }
417
-
418
-
419
- // private: error handling
420
- function error($message) {
421
-
422
- $this->CleanUp();
423
-
424
- $this->info['error'][] = $message;
425
- return $this->info;
426
- }
427
-
428
-
429
- // private: warning handling
430
- function warning($message) {
431
- $this->info['warning'][] = $message;
432
- return true;
433
- }
434
-
435
-
436
- // private: CleanUp
437
- function CleanUp() {
438
-
439
- // remove possible empty keys
440
- $AVpossibleEmptyKeys = array('dataformat', 'bits_per_sample', 'encoder_options', 'streams', 'bitrate');
441
- foreach ($AVpossibleEmptyKeys as $dummy => $key) {
442
- if (empty($this->info['audio'][$key]) && isset($this->info['audio'][$key])) {
443
- unset($this->info['audio'][$key]);
444
- }
445
- if (empty($this->info['video'][$key]) && isset($this->info['video'][$key])) {
446
- unset($this->info['video'][$key]);
447
- }
448
- }
449
-
450
- // remove empty root keys
451
- if (!empty($this->info)) {
452
- foreach ($this->info as $key => $value) {
453
- if (empty($this->info[$key]) && ($this->info[$key] !== 0) && ($this->info[$key] !== '0')) {
454
- unset($this->info[$key]);
455
- }
456
- }
457
- }
458
-
459
- // remove meaningless entries from unknown-format files
460
- if (empty($this->info['fileformat'])) {
461
- if (isset($this->info['avdataoffset'])) {
462
- unset($this->info['avdataoffset']);
463
- }
464
- if (isset($this->info['avdataend'])) {
465
- unset($this->info['avdataend']);
466
- }
467
- }
468
- }
469
-
470
-
471
- // return array containing information about all supported formats
472
- function GetFileFormatArray() {
473
- static $format_info = array();
474
- if (empty($format_info)) {
475
- $format_info = array(
476
-
477
- // Audio formats
478
-
479
- // AC-3 - audio - Dolby AC-3 / Dolby Digital
480
- 'ac3' => array(
481
- 'pattern' => '^\x0B\x77',
482
- 'group' => 'audio',
483
- 'module' => 'ac3',
484
- 'mime_type' => 'audio/ac3',
485
- ),
486
-
487
- // AAC - audio - Advanced Audio Coding (AAC) - ADIF format
488
- 'adif' => array(
489
- 'pattern' => '^ADIF',
490
- 'group' => 'audio',
491
- 'module' => 'aac',
492
- 'option' => 'adif',
493
- 'mime_type' => 'application/octet-stream',
494
- 'fail_ape' => 'WARNING',
495
- ),
496
-
497
-
498
- // AAC - audio - Advanced Audio Coding (AAC) - ADTS format (very similar to MP3)
499
- 'adts' => array(
500
- 'pattern' => '^\xFF[\xF0-\xF1\xF8-\xF9]',
501
- 'group' => 'audio',
502
- 'module' => 'aac',
503
- 'option' => 'adts',
504
- 'mime_type' => 'application/octet-stream',
505
- 'fail_ape' => 'WARNING',
506
- ),
507
-
508
-
509
- // AU - audio - NeXT/Sun AUdio (AU)
510
- 'au' => array(
511
- 'pattern' => '^\.snd',
512
- 'group' => 'audio',
513
- 'module' => 'au',
514
- 'mime_type' => 'audio/basic',
515
- ),
516
-
517
- // AVR - audio - Audio Visual Research
518
- 'avr' => array(
519
- 'pattern' => '^2BIT',
520
- 'group' => 'audio',
521
- 'module' => 'avr',
522
- 'mime_type' => 'application/octet-stream',
523
- ),
524
-
525
- // BONK - audio - Bonk v0.9+
526
- 'bonk' => array(
527
- 'pattern' => '^\x00(BONK|INFO|META| ID3)',
528
- 'group' => 'audio',
529
- 'module' => 'bonk',
530
- 'mime_type' => 'audio/xmms-bonk',
531
- ),
532
-
533
- // DSS - audio - Digital Speech Standard
534
- 'dss' => array(
535
- 'pattern' => '^[\x02]dss',
536
- 'group' => 'audio',
537
- 'module' => 'dss',
538
- 'mime_type' => 'application/octet-stream',
539
- ),
540
-
541
- // DTS - audio - Dolby Theatre System
542
- 'dts' => array(
543
- 'pattern' => '^\x7F\xFE\x80\x01',
544
- 'group' => 'audio',
545
- 'module' => 'dts',
546
- 'mime_type' => 'audio/dts',
547
- ),
548
-
549
- // FLAC - audio - Free Lossless Audio Codec
550
- 'flac' => array(
551
- 'pattern' => '^fLaC',
552
- 'group' => 'audio',
553
- 'module' => 'flac',
554
- 'mime_type' => 'audio/x-flac',
555
- ),
556
-
557
- // LA - audio - Lossless Audio (LA)
558
- 'la' => array(
559
- 'pattern' => '^LA0[2-4]',
560
- 'group' => 'audio',
561
- 'module' => 'la',
562
- 'mime_type' => 'application/octet-stream',
563
- ),
564
-
565
- // LPAC - audio - Lossless Predictive Audio Compression (LPAC)
566
- 'lpac' => array(
567
- 'pattern' => '^LPAC',
568
- 'group' => 'audio',
569
- 'module' => 'lpac',
570
- 'mime_type' => 'application/octet-stream',
571
- ),
572
-
573
- // MIDI - audio - MIDI (Musical Instrument Digital Interface)
574
- 'midi' => array(
575
- 'pattern' => '^MThd',
576
- 'group' => 'audio',
577
- 'module' => 'midi',
578
- 'mime_type' => 'audio/midi',
579
- ),
580
-
581
- // MAC - audio - Monkey's Audio Compressor
582
- 'mac' => array(
583
- 'pattern' => '^MAC ',
584
- 'group' => 'audio',
585
- 'module' => 'monkey',
586
- 'mime_type' => 'application/octet-stream',
587
- ),
588
-
589
- // has been known to produce false matches in random files (e.g. JPEGs), leave out until more precise matching available
590
- // // MOD - audio - MODule (assorted sub-formats)
591
- // 'mod' => array(
592
- // 'pattern' => '^.{1080}(M\\.K\\.|M!K!|FLT4|FLT8|[5-9]CHN|[1-3][0-9]CH)',
593
- // 'group' => 'audio',
594
- // 'module' => 'mod',
595
- // 'option' => 'mod',
596
- // 'mime_type' => 'audio/mod',
597
- // ),
598
-
599
- // MOD - audio - MODule (Impulse Tracker)
600
- 'it' => array(
601
- 'pattern' => '^IMPM',
602
- 'group' => 'audio',
603
- 'module' => 'mod',
604
- 'option' => 'it',
605
- 'mime_type' => 'audio/it',
606
- ),
607
-
608
- // MOD - audio - MODule (eXtended Module, various sub-formats)
609
- 'xm' => array(
610
- 'pattern' => '^Extended Module',
611
- 'group' => 'audio',
612
- 'module' => 'mod',
613
- 'option' => 'xm',
614
- 'mime_type' => 'audio/xm',
615
- ),
616
-
617
- // MOD - audio - MODule (ScreamTracker)
618
- 's3m' => array(
619
- 'pattern' => '^.{44}SCRM',
620
- 'group' => 'audio',
621
- 'module' => 'mod',
622
- 'option' => 's3m',
623
- 'mime_type' => 'audio/s3m',
624
- ),
625
-
626
- // MPC - audio - Musepack / MPEGplus
627
- 'mpc' => array(
628
- 'pattern' => '^(MPCK|MP\+|[\x00\x01\x10\x11\x40\x41\x50\x51\x80\x81\x90\x91\xC0\xC1\xD0\xD1][\x20-37][\x00\x20\x40\x60\x80\xA0\xC0\xE0])',
629
- 'group' => 'audio',
630
- 'module' => 'mpc',
631
- 'mime_type' => 'audio/x-musepack',
632
- ),
633
-
634
- // MP3 - audio - MPEG-audio Layer 3 (very similar to AAC-ADTS)
635
- 'mp3' => array(
636
- 'pattern' => '^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\xEB]',
637
- 'group' => 'audio',
638
- 'module' => 'mp3',
639
- 'mime_type' => 'audio/mpeg',
640
- ),
641
-
642
- // OFR - audio - OptimFROG
643
- 'ofr' => array(
644
- 'pattern' => '^(\*RIFF|OFR)',
645
- 'group' => 'audio',
646
- 'module' => 'optimfrog',
647
- 'mime_type' => 'application/octet-stream',
648
- ),
649
-
650
- // RKAU - audio - RKive AUdio compressor
651
- 'rkau' => array(
652
- 'pattern' => '^RKA',
653
- 'group' => 'audio',
654
- 'module' => 'rkau',
655
- 'mime_type' => 'application/octet-stream',
656
- ),
657
-
658
- // SHN - audio - Shorten
659
- 'shn' => array(
660
- 'pattern' => '^ajkg',
661
- 'group' => 'audio',
662
- 'module' => 'shorten',
663
- 'mime_type' => 'audio/xmms-shn',
664
- 'fail_id3' => 'ERROR',
665
- 'fail_ape' => 'ERROR',
666
- ),
667
-
668
- // TTA - audio - TTA Lossless Audio Compressor (http://tta.corecodec.org)
669
- 'tta' => array(
670
- 'pattern' => '^TTA', // could also be '^TTA(\x01|\x02|\x03|2|1)'
671
- 'group' => 'audio',
672
- 'module' => 'tta',
673
- 'mime_type' => 'application/octet-stream',
674
- ),
675
-
676
- // VOC - audio - Creative Voice (VOC)
677
- 'voc' => array(
678
- 'pattern' => '^Creative Voice File',
679
- 'group' => 'audio',
680
- 'module' => 'voc',
681
- 'mime_type' => 'audio/voc',
682
- ),
683
-
684
- // VQF - audio - transform-domain weighted interleave Vector Quantization Format (VQF)
685
- 'vqf' => array(
686
- 'pattern' => '^TWIN',
687
- 'group' => 'audio',
688
- 'module' => 'vqf',
689
- 'mime_type' => 'application/octet-stream',
690
- ),
691
-
692
- // WV - audio - WavPack (v4.0+)
693
- 'wv' => array(
694
- 'pattern' => '^wvpk',
695
- 'group' => 'audio',
696
- 'module' => 'wavpack',
697
- 'mime_type' => 'application/octet-stream',
698
- ),
699
-
700
-
701
- // Audio-Video formats
702
-
703
- // ASF - audio/video - Advanced Streaming Format, Windows Media Video, Windows Media Audio
704
- 'asf' => array(
705
- 'pattern' => '^\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C',
706
- 'group' => 'audio-video',
707
- 'module' => 'asf',
708
- 'mime_type' => 'video/x-ms-asf',
709
- 'iconv_req' => false,
710
- ),
711
-
712
- // BINK - audio/video - Bink / Smacker
713
- 'bink' => array(
714
- 'pattern' => '^(BIK|SMK)',
715
- 'group' => 'audio-video',
716
- 'module' => 'bink',
717
- 'mime_type' => 'application/octet-stream',
718
- ),
719
-
720
- // FLV - audio/video - FLash Video
721
- 'flv' => array(
722
- 'pattern' => '^FLV\x01',
723
- 'group' => 'audio-video',
724
- 'module' => 'flv',
725
- 'mime_type' => 'video/x-flv',
726
- ),
727
-
728
- // MKAV - audio/video - Mastroka
729
- 'matroska' => array(
730
- 'pattern' => '^\x1A\x45\xDF\xA3',
731
- 'group' => 'audio-video',
732
- 'module' => 'matroska',
733
- 'mime_type' => 'video/x-matroska', // may also be audio/x-matroska
734
- ),
735
-
736
- // MPEG - audio/video - MPEG (Moving Pictures Experts Group)
737
- 'mpeg' => array(
738
- 'pattern' => '^\x00\x00\x01(\xBA|\xB3)',
739
- 'group' => 'audio-video',
740
- 'module' => 'mpeg',
741
- 'mime_type' => 'video/mpeg',
742
- ),
743
-
744
- // NSV - audio/video - Nullsoft Streaming Video (NSV)
745
- 'nsv' => array(
746
- 'pattern' => '^NSV[sf]',
747
- 'group' => 'audio-video',
748
- 'module' => 'nsv',
749
- 'mime_type' => 'application/octet-stream',
750
- ),
751
-
752
- // Ogg - audio/video - Ogg (Ogg-Vorbis, Ogg-FLAC, Speex, Ogg-Theora(*), Ogg-Tarkin(*))
753
- 'ogg' => array(
754
- 'pattern' => '^OggS',
755
- 'group' => 'audio',
756
- 'module' => 'ogg',
757
- 'mime_type' => 'application/ogg',
758
- 'fail_id3' => 'WARNING',
759
- 'fail_ape' => 'WARNING',
760
- ),
761
-
762
- // QT - audio/video - Quicktime
763
- 'quicktime' => array(
764
- 'pattern' => '^.{4}(cmov|free|ftyp|mdat|moov|pnot|skip|wide)',
765
- 'group' => 'audio-video',
766
- 'module' => 'quicktime',
767
- 'mime_type' => 'video/quicktime',
768
- ),
769
-
770
- // RIFF - audio/video - Resource Interchange File Format (RIFF) / WAV / AVI / CD-audio / SDSS = renamed variant used by SmartSound QuickTracks (www.smartsound.com) / FORM = Audio Interchange File Format (AIFF)
771
- 'riff' => array(
772
- 'pattern' => '^(RIFF|SDSS|FORM)',
773
- 'group' => 'audio-video',
774
- 'module' => 'riff',
775
- 'mime_type' => 'audio/x-wave',
776
- 'fail_ape' => 'WARNING',
777
- ),
778
-
779
- // Real - audio/video - RealAudio, RealVideo
780
- 'real' => array(
781
- 'pattern' => '^(\\.RMF|\\.ra)',
782
- 'group' => 'audio-video',
783
- 'module' => 'real',
784
- 'mime_type' => 'audio/x-realaudio',
785
- ),
786
-
787
- // SWF - audio/video - ShockWave Flash
788
- 'swf' => array(
789
- 'pattern' => '^(F|C)WS',
790
- 'group' => 'audio-video',
791
- 'module' => 'swf',
792
- 'mime_type' => 'application/x-shockwave-flash',
793
- ),
794
-
795
-
796
- // Still-Image formats
797
-
798
- // BMP - still image - Bitmap (Windows, OS/2; uncompressed, RLE8, RLE4)
799
- 'bmp' => array(
800
- 'pattern' => '^BM',
801
- 'group' => 'graphic',
802
- 'module' => 'bmp',
803
- 'mime_type' => 'image/bmp',
804
- 'fail_id3' => 'ERROR',
805
- 'fail_ape' => 'ERROR',
806
- ),
807
-
808
- // GIF - still image - Graphics Interchange Format
809
- 'gif' => array(
810
- 'pattern' => '^GIF',
811
- 'group' => 'graphic',
812
- 'module' => 'gif',
813
- 'mime_type' => 'image/gif',
814
- 'fail_id3' => 'ERROR',
815
- 'fail_ape' => 'ERROR',
816
- ),
817
-
818
- // JPEG - still image - Joint Photographic Experts Group (JPEG)
819
- 'jpg' => array(
820
- 'pattern' => '^\xFF\xD8\xFF',
821
- 'group' => 'graphic',
822
- 'module' => 'jpg',
823
- 'mime_type' => 'image/jpeg',
824
- 'fail_id3' => 'ERROR',
825
- 'fail_ape' => 'ERROR',
826
- ),
827
-
828
- // PCD - still image - Kodak Photo CD
829
- 'pcd' => array(
830
- 'pattern' => '^.{2048}PCD_IPI\x00',
831
- 'group' => 'graphic',
832
- 'module' => 'pcd',
833
- 'mime_type' => 'image/x-photo-cd',
834
- 'fail_id3' => 'ERROR',
835
- 'fail_ape' => 'ERROR',
836
- ),
837
-
838
-
839
- // PNG - still image - Portable Network Graphics (PNG)
840
- 'png' => array(
841
- 'pattern' => '^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A',
842
- 'group' => 'graphic',
843
- 'module' => 'png',
844
- 'mime_type' => 'image/png',
845
- 'fail_id3' => 'ERROR',
846
- 'fail_ape' => 'ERROR',
847
- ),
848
-
849
-
850
- // SVG - still image - Scalable Vector Graphics (SVG)
851
- 'svg' => array(
852
- 'pattern' => '<!DOCTYPE svg PUBLIC ',
853
- 'group' => 'graphic',
854
- 'module' => 'svg',
855
- 'mime_type' => 'image/svg+xml',
856
- 'fail_id3' => 'ERROR',
857
- 'fail_ape' => 'ERROR',
858
- ),
859
-
860
-
861
- // TIFF - still image - Tagged Information File Format (TIFF)
862
- 'tiff' => array(
863
- 'pattern' => '^(II\x2A\x00|MM\x00\x2A)',
864
- 'group' => 'graphic',
865
- 'module' => 'tiff',
866
- 'mime_type' => 'image/tiff',
867
- 'fail_id3' => 'ERROR',
868
- 'fail_ape' => 'ERROR',
869
- ),
870
-
871
-
872
- // Data formats
873
-
874
- // ISO - data - International Standards Organization (ISO) CD-ROM Image
875
- 'iso' => array(
876
- 'pattern' => '^.{32769}CD001',
877
- 'group' => 'misc',
878
- 'module' => 'iso',
879
- 'mime_type' => 'application/octet-stream',
880
- 'fail_id3' => 'ERROR',
881
- 'fail_ape' => 'ERROR',
882
- 'iconv_req' => false,
883
- ),
884
-
885
- // RAR - data - RAR compressed data
886
- 'rar' => array(
887
- 'pattern' => '^Rar\!',
888
- 'group' => 'archive',
889
- 'module' => 'rar',
890
- 'mime_type' => 'application/octet-stream',
891
- 'fail_id3' => 'ERROR',
892
- 'fail_ape' => 'ERROR',
893
- ),
894
-
895
- // SZIP - audio/data - SZIP compressed data
896
- 'szip' => array(
897
- 'pattern' => '^SZ\x0A\x04',
898
- 'group' => 'archive',
899
- 'module' => 'szip',
900
- 'mime_type' => 'application/octet-stream',
901
- 'fail_id3' => 'ERROR',
902
- 'fail_ape' => 'ERROR',
903
- ),
904
-
905
- // TAR - data - TAR compressed data
906
- 'tar' => array(
907
- 'pattern' => '^.{100}[0-9\x20]{7}\x00[0-9\x20]{7}\x00[0-9\x20]{7}\x00[0-9\x20\x00]{12}[0-9\x20\x00]{12}',
908
- 'group' => 'archive',
909
- 'module' => 'tar',
910
- 'mime_type' => 'application/x-tar',
911
- 'fail_id3' => 'ERROR',
912
- 'fail_ape' => 'ERROR',
913
- ),
914
-
915
- // GZIP - data - GZIP compressed data
916
- 'gz' => array(
917
- 'pattern' => '^\x1F\x8B\x08',
918
- 'group' => 'archive',
919
- 'module' => 'gzip',
920
- 'mime_type' => 'application/x-gzip',
921
- 'fail_id3' => 'ERROR',
922
- 'fail_ape' => 'ERROR',
923
- ),
924
-
925
- // ZIP - data - ZIP compressed data
926
- 'zip' => array(
927
- 'pattern' => '^PK\x03\x04',
928
- 'group' => 'archive',
929
- 'module' => 'zip',
930
- 'mime_type' => 'application/zip',
931
- 'fail_id3' => 'ERROR',
932
- 'fail_ape' => 'ERROR',
933
- ),
934
-
935
-
936
- // Misc other formats
937
-
938
- // PAR2 - data - Parity Volume Set Specification 2.0
939
- 'par2' => array (
940
- 'pattern' => '^PAR2\x00PKT',
941
- 'group' => 'misc',
942
- 'module' => 'par2',
943
- 'mime_type' => 'application/octet-stream',
944
- 'fail_id3' => 'ERROR',
945
- 'fail_ape' => 'ERROR',
946
- ),
947
-
948
- // PDF - data - Portable Document Format
949
- 'pdf' => array(
950
- 'pattern' => '^\x25PDF',
951
- 'group' => 'misc',
952
- 'module' => 'pdf',
953
- 'mime_type' => 'application/pdf',
954
- 'fail_id3' => 'ERROR',
955
- 'fail_ape' => 'ERROR',
956
- ),
957
-
958
- // MSOFFICE - data - ZIP compressed data
959
- 'msoffice' => array(
960
- 'pattern' => '^\xD0\xCF\x11\xE0', // D0CF11E == DOCFILE == Microsoft Office Document
961
- 'group' => 'misc',
962
- 'module' => 'msoffice',
963
- 'mime_type' => 'application/octet-stream',
964
- 'fail_id3' => 'ERROR',
965
- 'fail_ape' => 'ERROR',
966
- ),
967
- );
968
- }
969
-
970
- return $format_info;
971
- }
972
-
973
-
974
-
975
- function GetFileFormat(&$filedata, $filename='') {
976
- // this function will determine the format of a file based on usually
977
- // the first 2-4 bytes of the file (8 bytes for PNG, 16 bytes for JPG,
978
- // and in the case of ISO CD image, 6 bytes offset 32kb from the start
979
- // of the file).
980
-
981
- // Identify file format - loop through $format_info and detect with reg expr
982
- foreach ($this->GetFileFormatArray() as $format_name => $info) {
983
- // Using preg_match() instead of ereg() - much faster
984
- // The /s switch on preg_match() forces preg_match() NOT to treat
985
- // newline (0x0A) characters as special chars but do a binary match
986
- if (preg_match('/'.$info['pattern'].'/s', $filedata)) {
987
- $info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
988
- return $info;
989
- }
990
- }
991
-
992
-
993
- if (preg_match('/\.mp[123a]$/i', $filename)) {
994
- // Too many mp3 encoders on the market put gabage in front of mpeg files
995
- // use assume format on these if format detection failed
996
- $GetFileFormatArray = $this->GetFileFormatArray();
997
- $info = $GetFileFormatArray['mp3'];
998
- $info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
999
- return $info;
1000
- }
1001
-
1002
- return false;
1003
- }
1004
-
1005
-
1006
- // converts array to $encoding charset from $this->encoding
1007
- function CharConvert(&$array, $encoding) {
1008
-
1009
- // identical encoding - end here
1010
- if ($encoding == $this->encoding) {
1011
- return;
1012
- }
1013
-
1014
- // loop thru array
1015
- foreach ($array as $key => $value) {
1016
-
1017
- // go recursive
1018
- if (is_array($value)) {
1019
- $this->CharConvert($array[$key], $encoding);
1020
- }
1021
-
1022
- // convert string
1023
- elseif (is_string($value)) {
1024
- $array[$key] = trim(getid3_lib::iconv_fallback($encoding, $this->encoding, $value));
1025
- }
1026
- }
1027
- }
1028
-
1029
-
1030
- function HandleAllTags() {
1031
-
1032
- // key name => array (tag name, character encoding)
1033
- static $tags;
1034
- if (empty($tags)) {
1035
- $tags = array(
1036
- 'asf' => array('asf' , 'UTF-16LE'),
1037
- 'midi' => array('midi' , 'ISO-8859-1'),
1038
- 'nsv' => array('nsv' , 'ISO-8859-1'),
1039
- 'ogg' => array('vorbiscomment' , 'UTF-8'),
1040
- 'png' => array('png' , 'UTF-8'),
1041
- 'tiff' => array('tiff' , 'ISO-8859-1'),
1042
- 'quicktime' => array('quicktime' , 'ISO-8859-1'),
1043
- 'real' => array('real' , 'ISO-8859-1'),
1044
- 'vqf' => array('vqf' , 'ISO-8859-1'),
1045
- 'zip' => array('zip' , 'ISO-8859-1'),
1046
- 'riff' => array('riff' , 'ISO-8859-1'),
1047
- 'lyrics3' => array('lyrics3' , 'ISO-8859-1'),
1048
- 'id3v1' => array('id3v1' , $this->encoding_id3v1),
1049
- 'id3v2' => array('id3v2' , 'UTF-8'), // not according to the specs (every frame can have a different encoding), but getID3() force-converts all encodings to UTF-8
1050
- 'ape' => array('ape' , 'UTF-8')
1051
- );
1052
- }
1053
-
1054
- // loop thru comments array
1055
- foreach ($tags as $comment_name => $tagname_encoding_array) {
1056
- list($tag_name, $encoding) = $tagname_encoding_array;
1057
-
1058
- // fill in default encoding type if not already present
1059
- if (isset($this->info[$comment_name]) && !isset($this->info[$comment_name]['encoding'])) {
1060
- $this->info[$comment_name]['encoding'] = $encoding;
1061
- }
1062
-
1063
- // copy comments if key name set
1064
- if (!empty($this->info[$comment_name]['comments'])) {
1065
-
1066
- foreach ($this->info[$comment_name]['comments'] as $tag_key => $valuearray) {
1067
- foreach ($valuearray as $key => $value) {
1068
- if (strlen(trim($value)) > 0) {
1069
- $this->info['tags'][trim($tag_name)][trim($tag_key)][] = $value; // do not trim!! Unicode characters will get mangled if trailing nulls are removed!
1070
- }
1071
- }
1072
- }
1073
-
1074
- if (!isset($this->info['tags'][$tag_name])) {
1075
- // comments are set but contain nothing but empty strings, so skip
1076
- continue;
1077
- }
1078
-
1079
- if ($this->option_tags_html) {
1080
- foreach ($this->info['tags'][$tag_name] as $tag_key => $valuearray) {
1081
- foreach ($valuearray as $key => $value) {
1082
- if (is_string($value)) {
1083
- //$this->info['tags_html'][$tag_name][$tag_key][$key] = getid3_lib::MultiByteCharString2HTML($value, $encoding);
1084
- $this->info['tags_html'][$tag_name][$tag_key][$key] = str_replace('&#0;', '', getid3_lib::MultiByteCharString2HTML($value, $encoding));
1085
- } else {
1086
- $this->info['tags_html'][$tag_name][$tag_key][$key] = $value;
1087
- }
1088
- }
1089
- }
1090
- }
1091
-
1092
- $this->CharConvert($this->info['tags'][$tag_name], $encoding); // only copy gets converted!
1093
- }
1094
-
1095
- }
1096
- return true;
1097
- }
1098
-
1099
-
1100
- function getHashdata($algorithm) {
1101
- switch ($algorithm) {
1102
- case 'md5':
1103
- case 'sha1':
1104
- break;
1105
-
1106
- default:
1107
- return $this->error('bad algorithm "'.$algorithm.'" in getHashdata()');
1108
- break;
1109
- }
1110
-
1111
- if ((@$this->info['fileformat'] == 'ogg') && (@$this->info['audio']['dataformat'] == 'vorbis')) {
1112
-
1113
- // We cannot get an identical md5_data value for Ogg files where the comments
1114
- // span more than 1 Ogg page (compared to the same audio data with smaller
1115
- // comments) using the normal getID3() method of MD5'ing the data between the
1116
- // end of the comments and the end of the file (minus any trailing tags),
1117
- // because the page sequence numbers of the pages that the audio data is on
1118
- // do not match. Under normal circumstances, where comments are smaller than
1119
- // the nominal 4-8kB page size, then this is not a problem, but if there are
1120
- // very large comments, the only way around it is to strip off the comment
1121
- // tags with vorbiscomment and MD5 that file.
1122
- // This procedure must be applied to ALL Ogg files, not just the ones with
1123
- // comments larger than 1 page, because the below method simply MD5's the
1124
- // whole file with the comments stripped, not just the portion after the
1125
- // comments block (which is the standard getID3() method.
1126
-
1127
- // The above-mentioned problem of comments spanning multiple pages and changing
1128
- // page sequence numbers likely happens for OggSpeex and OggFLAC as well, but
1129
- // currently vorbiscomment only works on OggVorbis files.
1130
-
1131
- if ((bool) ini_get('safe_mode')) {
1132
-
1133
- $this->info['warning'][] = 'Failed making system call to vorbiscomment.exe - '.$algorithm.'_data is incorrect - error returned: PHP running in Safe Mode (backtick operator not available)';
1134
- $this->info[$algorithm.'_data'] = false;
1135
-
1136
- } else {
1137
-
1138
- // Prevent user from aborting script
1139
- $old_abort = ignore_user_abort(true);
1140
-
1141
- // Create empty file
1142
- $empty = tempnam('*', 'getID3');
1143
- touch($empty);
1144
-
1145
-
1146
- // Use vorbiscomment to make temp file without comments
1147
- $temp = tempnam('*', 'getID3');
1148
- $file = $this->info['filenamepath'];
1149
-
1150
- if (GETID3_OS_ISWINDOWS) {
1151
-
1152
- if (file_exists(GETID3_HELPERAPPSDIR.'vorbiscomment.exe')) {
1153
-
1154
- $commandline = '"'.GETID3_HELPERAPPSDIR.'vorbiscomment.exe" -w -c "'.$empty.'" "'.$file.'" "'.$temp.'"';
1155
- $VorbisCommentError = `$commandline`;
1156
-
1157
- } else {
1158
-
1159
- $VorbisCommentError = 'vorbiscomment.exe not found in '.GETID3_HELPERAPPSDIR;
1160
-
1161
- }
1162
-
1163
- } else {
1164
-
1165
- $commandline = 'vorbiscomment -w -c "'.$empty.'" "'.$file.'" "'.$temp.'" 2>&1';
1166
- $commandline = 'vorbiscomment -w -c '.escapeshellarg($empty).' '.escapeshellarg($file).' '.escapeshellarg($temp).' 2>&1';
1167
- $VorbisCommentError = `$commandline`;
1168
-
1169
- }
1170
-
1171
- if (!empty($VorbisCommentError)) {
1172
-
1173
- $this->info['warning'][] = 'Failed making system call to vorbiscomment(.exe) - '.$algorithm.'_data will be incorrect. If vorbiscomment is unavailable, please download from http://www.vorbis.com/download.psp and put in the getID3() directory. Error returned: '.$VorbisCommentError;
1174
- $this->info[$algorithm.'_data'] = false;
1175
-
1176
- } else {
1177
-
1178
- // Get hash of newly created file
1179
- switch ($algorithm) {
1180
- case 'md5':
1181
- $this->info[$algorithm.'_data'] = getid3_lib::md5_file($temp);
1182
- break;
1183
-
1184
- case 'sha1':
1185
- $this->info[$algorithm.'_data'] = getid3_lib::sha1_file($temp);
1186
- break;
1187
- }
1188
- }
1189
-
1190
- // Clean up
1191
- unlink($empty);
1192
- unlink($temp);
1193
-
1194
- // Reset abort setting
1195
- ignore_user_abort($old_abort);
1196
-
1197
- }
1198
-
1199
- } else {
1200
-
1201
- if (!empty($this->info['avdataoffset']) || (isset($this->info['avdataend']) && ($this->info['avdataend'] < $this->info['filesize']))) {
1202
-
1203
- // get hash from part of file
1204
- $this->info[$algorithm.'_data'] = getid3_lib::hash_data($this->info['filenamepath'], $this->info['avdataoffset'], $this->info['avdataend'], $algorithm);
1205
-
1206
- } else {
1207
-
1208
- // get hash from whole file
1209
- switch ($algorithm) {
1210
- case 'md5':
1211
- $this->info[$algorithm.'_data'] = getid3_lib::md5_file($this->info['filenamepath']);
1212
- break;
1213
-
1214
- case 'sha1':
1215
- $this->info[$algorithm.'_data'] = getid3_lib::sha1_file($this->info['filenamepath']);
1216
- break;
1217
- }
1218
- }
1219
-
1220
- }
1221
- return true;
1222
- }
1223
-
1224
-
1225
- function ChannelsBitratePlaytimeCalculations() {
1226
-
1227
- // set channelmode on audio
1228
- if (@$this->info['audio']['channels'] == '1') {
1229
- $this->info['audio']['channelmode'] = 'mono';
1230
- } elseif (@$this->info['audio']['channels'] == '2') {
1231
- $this->info['audio']['channelmode'] = 'stereo';
1232
- }
1233
-
1234
- // Calculate combined bitrate - audio + video
1235
- $CombinedBitrate = 0;
1236
- $CombinedBitrate += (isset($this->info['audio']['bitrate']) ? $this->info['audio']['bitrate'] : 0);
1237
- $CombinedBitrate += (isset($this->info['video']['bitrate']) ? $this->info['video']['bitrate'] : 0);
1238
- if (($CombinedBitrate > 0) && empty($this->info['bitrate'])) {
1239
- $this->info['bitrate'] = $CombinedBitrate;
1240
- }
1241
- //if ((isset($this->info['video']) && !isset($this->info['video']['bitrate'])) || (isset($this->info['audio']) && !isset($this->info['audio']['bitrate']))) {
1242
- // // for example, VBR MPEG video files cannot determine video bitrate:
1243
- // // should not set overall bitrate and playtime from audio bitrate only
1244
- // unset($this->info['bitrate']);
1245
- //}
1246
-
1247
- // video bitrate undetermined, but calculable
1248
- if (isset($this->info['video']['dataformat']) && $this->info['video']['dataformat'] && (!isset($this->info['video']['bitrate']) || ($this->info['video']['bitrate'] == 0))) {
1249
- // if video bitrate not set
1250
- if (isset($this->info['audio']['bitrate']) && ($this->info['audio']['bitrate'] > 0) && ($this->info['audio']['bitrate'] == $this->info['bitrate'])) {
1251
- // AND if audio bitrate is set to same as overall bitrate
1252
- if (isset($this->info['playtime_seconds']) && ($this->info['playtime_seconds'] > 0)) {
1253
- // AND if playtime is set
1254
- if (isset($this->info['avdataend']) && isset($this->info['avdataoffset'])) {
1255
- // AND if AV data offset start/end is known
1256
- // THEN we can calculate the video bitrate
1257
- $this->info['bitrate'] = round((($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['playtime_seconds']);
1258
- $this->info['video']['bitrate'] = $this->info['bitrate'] - $this->info['audio']['bitrate'];
1259
- }
1260
- }
1261
- }
1262
- }
1263
-
1264
- if ((!isset($this->info['playtime_seconds']) || ($this->info['playtime_seconds'] <= 0)) && !empty($this->info['bitrate'])) {
1265
- $this->info['playtime_seconds'] = (($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['bitrate'];
1266
- }
1267
-
1268
- if (!isset($this->info['bitrate']) && !empty($this->info['playtime_seconds'])) {
1269
- $this->info['bitrate'] = (($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['playtime_seconds'];
1270
- }
1271
- //echo '<pre>';
1272
- //var_dump($this->info['bitrate']);
1273
- //var_dump($this->info['audio']['bitrate']);
1274
- //var_dump($this->info['video']['bitrate']);
1275
- //echo '</pre>';
1276
- if (isset($this->info['bitrate']) && empty($this->info['audio']['bitrate']) && empty($this->info['video']['bitrate'])) {
1277
- if (isset($this->info['audio']['dataformat']) && empty($this->info['video']['resolution_x'])) {
1278
- // audio only
1279
- $this->info['audio']['bitrate'] = $this->info['bitrate'];
1280
- } elseif (isset($this->info['video']['resolution_x']) && empty($this->info['audio']['dataformat'])) {
1281
- // video only
1282
- $this->info['video']['bitrate'] = $this->info['bitrate'];
1283
- }
1284
- }
1285
-
1286
- // Set playtime string
1287
- if (!empty($this->info['playtime_seconds']) && empty($this->info['playtime_string'])) {
1288
- $this->info['playtime_string'] = getid3_lib::PlaytimeString($this->info['playtime_seconds']);
1289
- }
1290
- }
1291
-
1292
-
1293
- function CalculateCompressionRatioVideo() {
1294
- if (empty($this->info['video'])) {
1295
- return false;
1296
- }
1297
- if (empty($this->info['video']['resolution_x']) || empty($this->info['video']['resolution_y'])) {
1298
- return false;
1299
- }
1300
- if (empty($this->info['video']['bits_per_sample'])) {
1301
- return false;
1302
- }
1303
-
1304
- switch ($this->info['video']['dataformat']) {
1305
- case 'bmp':
1306
- case 'gif':
1307
- case 'jpeg':
1308
- case 'jpg':
1309
- case 'png':
1310
- case 'tiff':
1311
- $FrameRate = 1;
1312
- $PlaytimeSeconds = 1;
1313
- $BitrateCompressed = $this->info['filesize'] * 8;
1314
- break;
1315
-
1316
- default:
1317
- if (!empty($this->info['video']['frame_rate'])) {
1318
- $FrameRate = $this->info['video']['frame_rate'];
1319
- } else {
1320
- return false;
1321
- }
1322
- if (!empty($this->info['playtime_seconds'])) {
1323
- $PlaytimeSeconds = $this->info['playtime_seconds'];
1324
- } else {
1325
- return false;
1326
- }
1327
- if (!empty($this->info['video']['bitrate'])) {
1328
- $BitrateCompressed = $this->info['video']['bitrate'];
1329
- } else {
1330
- return false;
1331
- }
1332
- break;
1333
- }
1334
- $BitrateUncompressed = $this->info['video']['resolution_x'] * $this->info['video']['resolution_y'] * $this->info['video']['bits_per_sample'] * $FrameRate;
1335
-
1336
- $this->info['video']['compression_ratio'] = $BitrateCompressed / $BitrateUncompressed;
1337
- return true;
1338
- }
1339
-
1340
-
1341
- function CalculateCompressionRatioAudio() {
1342
- if (empty($this->info['audio']['bitrate']) || empty($this->info['audio']['channels']) || empty($this->info['audio']['sample_rate'])) {
1343
- return false;
1344
- }
1345
- $this->info['audio']['compression_ratio'] = $this->info['audio']['bitrate'] / ($this->info['audio']['channels'] * $this->info['audio']['sample_rate'] * (!empty($this->info['audio']['bits_per_sample']) ? $this->info['audio']['bits_per_sample'] : 16));
1346
-
1347
- if (!empty($this->info['audio']['streams'])) {
1348
- foreach ($this->info['audio']['streams'] as $streamnumber => $streamdata) {
1349
- if (!empty($streamdata['bitrate']) && !empty($streamdata['channels']) && !empty($streamdata['sample_rate'])) {
1350
- $this->info['audio']['streams'][$streamnumber]['compression_ratio'] = $streamdata['bitrate'] / ($streamdata['channels'] * $streamdata['sample_rate'] * (!empty($streamdata['bits_per_sample']) ? $streamdata['bits_per_sample'] : 16));
1351
- }
1352
- }
1353
- }
1354
- return true;
1355
- }
1356
-
1357
-
1358
- function CalculateReplayGain() {
1359
- if (isset($this->info['replay_gain'])) {
1360
- $this->info['replay_gain']['reference_volume'] = 89;
1361
- if (isset($this->info['replay_gain']['track']['adjustment'])) {
1362
- $this->info['replay_gain']['track']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['track']['adjustment'];
1363
- }
1364
- if (isset($this->info['replay_gain']['album']['adjustment'])) {
1365
- $this->info['replay_gain']['album']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['album']['adjustment'];
1366
- }
1367
-
1368
- if (isset($this->info['replay_gain']['track']['peak'])) {
1369
- $this->info['replay_gain']['track']['max_noclip_gain'] = 0 - getid3_lib::RGADamplitude2dB($this->info['replay_gain']['track']['peak']);
1370
- }
1371
- if (isset($this->info['replay_gain']['album']['peak'])) {
1372
- $this->info['replay_gain']['album']['max_noclip_gain'] = 0 - getid3_lib::RGADamplitude2dB($this->info['replay_gain']['album']['peak']);
1373
- }
1374
- }
1375
- return true;
1376
- }
1377
-
1378
- function ProcessAudioStreams() {
1379
- if (!empty($this->info['audio']['bitrate']) || !empty($this->info['audio']['channels']) || !empty($this->info['audio']['sample_rate'])) {
1380
- if (!isset($this->info['audio']['streams'])) {
1381
- foreach ($this->info['audio'] as $key => $value) {
1382
- if ($key != 'streams') {
1383
- $this->info['audio']['streams'][0][$key] = $value;
1384
- }
1385
- }
1386
- }
1387
- }
1388
- return true;
1389
- }
1390
-
1391
- function getid3_tempnam() {
1392
- return tempnam($this->tempdir, 'gI3');
1393
- }
1394
-
1395
- }
1396
-
1397
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /////////////////////////////////////////////////////////////////
3
+ /// getID3() by James Heinrich <info@getid3.org> //
4
+ // available at http://getid3.sourceforge.net //
5
+ // or http://www.getid3.org //
6
+ /////////////////////////////////////////////////////////////////
7
+ // //
8
+ // Please see readme.txt for more information //
9
+ // ///
10
+ /////////////////////////////////////////////////////////////////
11
+
12
+ // define a constant rather than looking up every time it is needed
13
+ if (!defined('GETID3_OS_ISWINDOWS')) {
14
+ define('GETID3_OS_ISWINDOWS', (stripos(PHP_OS, 'WIN') === 0));
15
+ }
16
+ // Get base path of getID3() - ONCE
17
+ if (!defined('GETID3_INCLUDEPATH')) {
18
+ define('GETID3_INCLUDEPATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
19
+ }
20
+
21
+ // attempt to define temp dir as something flexible but reliable
22
+ $temp_dir = ini_get('upload_tmp_dir');
23
+ if ($temp_dir && (!is_dir($temp_dir) || !is_readable($temp_dir))) {
24
+ $temp_dir = '';
25
+ }
26
+ if (!$temp_dir && function_exists('sys_get_temp_dir')) {
27
+ // PHP v5.2.1+
28
+ // sys_get_temp_dir() may give inaccessible temp dir, e.g. with open_basedir on virtual hosts
29
+ $temp_dir = sys_get_temp_dir();
30
+ }
31
+ $temp_dir = realpath($temp_dir);
32
+ $open_basedir = ini_get('open_basedir');
33
+ if ($open_basedir) {
34
+ // e.g. "/var/www/vhosts/getid3.org/httpdocs/:/tmp/"
35
+ $temp_dir = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $temp_dir);
36
+ $open_basedir = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $open_basedir);
37
+ if (substr($temp_dir, -1, 1) != DIRECTORY_SEPARATOR) {
38
+ $temp_dir .= DIRECTORY_SEPARATOR;
39
+ }
40
+ $found_valid_tempdir = false;
41
+ $open_basedirs = explode(PATH_SEPARATOR, $open_basedir);
42
+ foreach ($open_basedirs as $basedir) {
43
+ if (substr($basedir, -1, 1) != DIRECTORY_SEPARATOR) {
44
+ $basedir .= DIRECTORY_SEPARATOR;
45
+ }
46
+ if (preg_match('#^'.preg_quote($basedir).'#', $temp_dir)) {
47
+ $found_valid_tempdir = true;
48
+ break;
49
+ }
50
+ }
51
+ if (!$found_valid_tempdir) {
52
+ $temp_dir = '';
53
+ }
54
+ unset($open_basedirs, $found_valid_tempdir, $basedir);
55
+ }
56
+ if (!$temp_dir) {
57
+ $temp_dir = '*'; // invalid directory name should force tempnam() to use system default temp dir
58
+ }
59
+ // $temp_dir = '/something/else/'; // feel free to override temp dir here if it works better for your system
60
+ define('GETID3_TEMP_DIR', $temp_dir);
61
+ unset($open_basedir, $temp_dir);
62
+
63
+ // End: Defines
64
+
65
+
66
+ class getID3
67
+ {
68
+ // public: Settings
69
+ public $encoding = 'UTF-8'; // CASE SENSITIVE! - i.e. (must be supported by iconv()). Examples: ISO-8859-1 UTF-8 UTF-16 UTF-16BE
70
+ public $encoding_id3v1 = 'ISO-8859-1'; // Should always be 'ISO-8859-1', but some tags may be written in other encodings such as 'EUC-CN' or 'CP1252'
71
+
72
+ // public: Optional tag checks - disable for speed.
73
+ public $option_tag_id3v1 = true; // Read and process ID3v1 tags
74
+ public $option_tag_id3v2 = true; // Read and process ID3v2 tags
75
+ public $option_tag_lyrics3 = true; // Read and process Lyrics3 tags
76
+ public $option_tag_apetag = true; // Read and process APE tags
77
+ public $option_tags_process = true; // Copy tags to root key 'tags' and encode to $this->encoding
78
+ public $option_tags_html = true; // Copy tags to root key 'tags_html' properly translated from various encodings to HTML entities
79
+
80
+ // public: Optional tag/comment calucations
81
+ public $option_extra_info = true; // Calculate additional info such as bitrate, channelmode etc
82
+
83
+ // public: Optional handling of embedded attachments (e.g. images)
84
+ public $option_save_attachments = true; // defaults to true (ATTACHMENTS_INLINE) for backward compatibility
85
+
86
+ // public: Optional calculations
87
+ public $option_md5_data = false; // Get MD5 sum of data part - slow
88
+ public $option_md5_data_source = false; // Use MD5 of source file if availble - only FLAC and OptimFROG
89
+ public $option_sha1_data = false; // Get SHA1 sum of data part - slow
90
+ public $option_max_2gb_check = null; // Check whether file is larger than 2GB and thus not supported by 32-bit PHP (null: auto-detect based on PHP_INT_MAX)
91
+
92
+ // public: Read buffer size in bytes
93
+ public $option_fread_buffer_size = 32768;
94
+
95
+ // Public variables
96
+ public $filename; // Filename of file being analysed.
97
+ public $fp; // Filepointer to file being analysed.
98
+ public $info; // Result array.
99
+ public $tempdir = GETID3_TEMP_DIR;
100
+
101
+ // Protected variables
102
+ protected $startup_error = '';
103
+ protected $startup_warning = '';
104
+ protected $memory_limit = 0;
105
+
106
+ const VERSION = '1.9.5-20130220';
107
+ const FREAD_BUFFER_SIZE = 32768;
108
+
109
+ const ATTACHMENTS_NONE = false;
110
+ const ATTACHMENTS_INLINE = true;
111
+
112
+ // public: constructor
113
+ public function __construct() {
114
+
115
+ // Check for PHP version
116
+ $required_php_version = '5.0.5';
117
+ if (version_compare(PHP_VERSION, $required_php_version, '<')) {
118
+ $this->startup_error .= 'getID3() requires PHP v'.$required_php_version.' or higher - you are running v'.PHP_VERSION;
119
+ return false;
120
+ }
121
+
122
+ // Check memory
123
+ $this->memory_limit = ini_get('memory_limit');
124
+ if (preg_match('#([0-9]+)M#i', $this->memory_limit, $matches)) {
125
+ // could be stored as "16M" rather than 16777216 for example
126
+ $this->memory_limit = $matches[1] * 1048576;
127
+ } elseif (preg_match('#([0-9]+)G#i', $this->memory_limit, $matches)) { // The 'G' modifier is available since PHP 5.1.0
128
+ // could be stored as "2G" rather than 2147483648 for example
129
+ $this->memory_limit = $matches[1] * 1073741824;
130
+ }
131
+ if ($this->memory_limit <= 0) {
132
+ // memory limits probably disabled
133
+ } elseif ($this->memory_limit <= 4194304) {
134
+ $this->startup_error .= 'PHP has less than 4MB available memory and will very likely run out. Increase memory_limit in php.ini';
135
+ } elseif ($this->memory_limit <= 12582912) {
136
+ $this->startup_warning .= 'PHP has less than 12MB available memory and might run out if all modules are loaded. Increase memory_limit in php.ini';
137
+ }
138
+
139
+ // Check safe_mode off
140
+ if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
141
+ $this->warning('WARNING: Safe mode is on, shorten support disabled, md5data/sha1data for ogg vorbis disabled, ogg vorbos/flac tag writing disabled.');
142
+ }
143
+
144
+ if (intval(ini_get('mbstring.func_overload')) > 0) {
145
+ $this->warning('WARNING: php.ini contains "mbstring.func_overload = '.ini_get('mbstring.func_overload').'", this may break things.');
146
+ }
147
+
148
+ // Check for magic_quotes_runtime
149
+ if (function_exists('get_magic_quotes_runtime')) {
150
+ if (get_magic_quotes_runtime()) {
151
+ return $this->startup_error('magic_quotes_runtime must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_runtime(0) and set_magic_quotes_runtime(1).');
152
+ }
153
+ }
154
+
155
+ // Check for magic_quotes_gpc
156
+ if (function_exists('magic_quotes_gpc')) {
157
+ if (get_magic_quotes_gpc()) {
158
+ return $this->startup_error('magic_quotes_gpc must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_gpc(0) and set_magic_quotes_gpc(1).');
159
+ }
160
+ }
161
+
162
+ // Load support library
163
+ if (!include_once(GETID3_INCLUDEPATH.'getid3.lib.php')) {
164
+ $this->startup_error .= 'getid3.lib.php is missing or corrupt';
165
+ }
166
+
167
+ if ($this->option_max_2gb_check === null) {
168
+ $this->option_max_2gb_check = (PHP_INT_MAX <= 2147483647);
169
+ }
170
+
171
+
172
+ // Needed for Windows only:
173
+ // Define locations of helper applications for Shorten, VorbisComment, MetaFLAC
174
+ // as well as other helper functions such as head, tail, md5sum, etc
175
+ // This path cannot contain spaces, but the below code will attempt to get the
176
+ // 8.3-equivalent path automatically
177
+ // IMPORTANT: This path must include the trailing slash
178
+ if (GETID3_OS_ISWINDOWS && !defined('GETID3_HELPERAPPSDIR')) {
179
+
180
+ $helperappsdir = GETID3_INCLUDEPATH.'..'.DIRECTORY_SEPARATOR.'helperapps'; // must not have any space in this path
181
+
182
+ if (!is_dir($helperappsdir)) {
183
+ $this->startup_warning .= '"'.$helperappsdir.'" cannot be defined as GETID3_HELPERAPPSDIR because it does not exist';
184
+ } elseif (strpos(realpath($helperappsdir), ' ') !== false) {
185
+ $DirPieces = explode(DIRECTORY_SEPARATOR, realpath($helperappsdir));
186
+ $path_so_far = array();
187
+ foreach ($DirPieces as $key => $value) {
188
+ if (strpos($value, ' ') !== false) {
189
+ if (!empty($path_so_far)) {
190
+ $commandline = 'dir /x '.escapeshellarg(implode(DIRECTORY_SEPARATOR, $path_so_far));
191
+ $dir_listing = `$commandline`;
192
+ $lines = explode("\n", $dir_listing);
193
+ foreach ($lines as $line) {
194
+ $line = trim($line);
195
+ if (preg_match('#^([0-9/]{10}) +([0-9:]{4,5}( [AP]M)?) +(<DIR>|[0-9,]+) +([^ ]{0,11}) +(.+)$#', $line, $matches)) {
196
+ list($dummy, $date, $time, $ampm, $filesize, $shortname, $filename) = $matches;
197
+ if ((strtoupper($filesize) == '<DIR>') && (strtolower($filename) == strtolower($value))) {
198
+ $value = $shortname;
199
+ }
200
+ }
201
+ }
202
+ } else {
203
+ $this->startup_warning .= 'GETID3_HELPERAPPSDIR must not have any spaces in it - use 8dot3 naming convention if neccesary. You can run "dir /x" from the commandline to see the correct 8.3-style names.';
204
+ }
205
+ }
206
+ $path_so_far[] = $value;
207
+ }
208
+ $helperappsdir = implode(DIRECTORY_SEPARATOR, $path_so_far);
209
+ }
210
+ define('GETID3_HELPERAPPSDIR', $helperappsdir.DIRECTORY_SEPARATOR);
211
+ }
212
+
213
+ return true;
214
+ }
215
+
216
+ public function version() {
217
+ return self::VERSION;
218
+ }
219
+
220
+ public function fread_buffer_size() {
221
+ return $this->option_fread_buffer_size;
222
+ }
223
+
224
+
225
+ // public: setOption
226
+ public function setOption($optArray) {
227
+ if (!is_array($optArray) || empty($optArray)) {
228
+ return false;
229
+ }
230
+ foreach ($optArray as $opt => $val) {
231
+ if (isset($this->$opt) === false) {
232
+ continue;
233
+ }
234
+ $this->$opt = $val;
235
+ }
236
+ return true;
237
+ }
238
+
239
+
240
+ public function openfile($filename) {
241
+ try {
242
+ if (!empty($this->startup_error)) {
243
+ throw new getid3_exception($this->startup_error);
244
+ }
245
+ if (!empty($this->startup_warning)) {
246
+ $this->warning($this->startup_warning);
247
+ }
248
+
249
+ // init result array and set parameters
250
+ $this->filename = $filename;
251
+ $this->info = array();
252
+ $this->info['GETID3_VERSION'] = $this->version();
253
+ $this->info['php_memory_limit'] = $this->memory_limit;
254
+
255
+ // remote files not supported
256
+ if (preg_match('/^(ht|f)tp:\/\//', $filename)) {
257
+ throw new getid3_exception('Remote files are not supported - please copy the file locally first');
258
+ }
259
+
260
+ $filename = str_replace('/', DIRECTORY_SEPARATOR, $filename);
261
+ $filename = preg_replace('#(.+)'.preg_quote(DIRECTORY_SEPARATOR).'{2,}#U', '\1'.DIRECTORY_SEPARATOR, $filename);
262
+
263
+ // open local file
264
+ if (is_readable($filename) && is_file($filename) && ($this->fp = fopen($filename, 'rb'))) {
265
+ // great
266
+ } else {
267
+ throw new getid3_exception('Could not open "'.$filename.'" (does not exist, or is not a file)');
268
+ }
269
+
270
+ $this->info['filesize'] = filesize($filename);
271
+ // set redundant parameters - might be needed in some include file
272
+ $this->info['filename'] = basename($filename);
273
+ $this->info['filepath'] = str_replace('\\', '/', realpath(dirname($filename)));
274
+ $this->info['filenamepath'] = $this->info['filepath'].'/'.$this->info['filename'];
275
+
276
+
277
+ // option_max_2gb_check
278
+ if ($this->option_max_2gb_check) {
279
+ // PHP (32-bit all, and 64-bit Windows) doesn't support integers larger than 2^31 (~2GB)
280
+ // filesize() simply returns (filesize % (pow(2, 32)), no matter the actual filesize
281
+ // ftell() returns 0 if seeking to the end is beyond the range of unsigned integer
282
+ $fseek = fseek($this->fp, 0, SEEK_END);
283
+ if (($fseek < 0) || (($this->info['filesize'] != 0) && (ftell($this->fp) == 0)) ||
284
+ ($this->info['filesize'] < 0) ||
285
+ (ftell($this->fp) < 0)) {
286
+ $real_filesize = getid3_lib::getFileSizeSyscall($this->info['filenamepath']);
287
+
288
+ if ($real_filesize === false) {
289
+ unset($this->info['filesize']);
290
+ fclose($this->fp);
291
+ throw new getid3_exception('Unable to determine actual filesize. File is most likely larger than '.round(PHP_INT_MAX / 1073741824).'GB and is not supported by PHP.');
292
+ } elseif (getid3_lib::intValueSupported($real_filesize)) {
293
+ unset($this->info['filesize']);
294
+ fclose($this->fp);
295
+ throw new getid3_exception('PHP seems to think the file is larger than '.round(PHP_INT_MAX / 1073741824).'GB, but filesystem reports it as '.number_format($real_filesize, 3).'GB, please report to info@getid3.org');
296
+ }
297
+ $this->info['filesize'] = $real_filesize;
298
+ $this->error('File is larger than '.round(PHP_INT_MAX / 1073741824).'GB (filesystem reports it as '.number_format($real_filesize, 3).'GB) and is not properly supported by PHP.');
299
+ }
300
+ }
301
+
302
+ // set more parameters
303
+ $this->info['avdataoffset'] = 0;
304
+ $this->info['avdataend'] = $this->info['filesize'];
305
+ $this->info['fileformat'] = ''; // filled in later
306
+ $this->info['audio']['dataformat'] = ''; // filled in later, unset if not used
307
+ $this->info['video']['dataformat'] = ''; // filled in later, unset if not used
308
+ $this->info['tags'] = array(); // filled in later, unset if not used
309
+ $this->info['error'] = array(); // filled in later, unset if not used
310
+ $this->info['warning'] = array(); // filled in later, unset if not used
311
+ $this->info['comments'] = array(); // filled in later, unset if not used
312
+ $this->info['encoding'] = $this->encoding; // required by id3v2 and iso modules - can be unset at the end if desired
313
+
314
+ return true;
315
+
316
+ } catch (Exception $e) {
317
+ $this->error($e->getMessage());
318
+ }
319
+ return false;
320
+ }
321
+
322
+ // public: analyze file
323
+ public function analyze($filename) {
324
+ try {
325
+ if (!$this->openfile($filename)) {
326
+ return $this->info;
327
+ }
328
+
329
+ // Handle tags
330
+ foreach (array('id3v2'=>'id3v2', 'id3v1'=>'id3v1', 'apetag'=>'ape', 'lyrics3'=>'lyrics3') as $tag_name => $tag_key) {
331
+ $option_tag = 'option_tag_'.$tag_name;
332
+ if ($this->$option_tag) {
333
+ $this->include_module('tag.'.$tag_name);
334
+ try {
335
+ $tag_class = 'getid3_'.$tag_name;
336
+ $tag = new $tag_class($this);
337
+ $tag->Analyze();
338
+ }
339
+ catch (getid3_exception $e) {
340
+ throw $e;
341
+ }
342
+ }
343
+ }
344
+ if (isset($this->info['id3v2']['tag_offset_start'])) {
345
+ $this->info['avdataoffset'] = max($this->info['avdataoffset'], $this->info['id3v2']['tag_offset_end']);
346
+ }
347
+ foreach (array('id3v1'=>'id3v1', 'apetag'=>'ape', 'lyrics3'=>'lyrics3') as $tag_name => $tag_key) {
348
+ if (isset($this->info[$tag_key]['tag_offset_start'])) {
349
+ $this->info['avdataend'] = min($this->info['avdataend'], $this->info[$tag_key]['tag_offset_start']);
350
+ }
351
+ }
352
+
353
+ // ID3v2 detection (NOT parsing), even if ($this->option_tag_id3v2 == false) done to make fileformat easier
354
+ if (!$this->option_tag_id3v2) {
355
+ fseek($this->fp, 0, SEEK_SET);
356
+ $header = fread($this->fp, 10);
357
+ if ((substr($header, 0, 3) == 'ID3') && (strlen($header) == 10)) {
358
+ $this->info['id3v2']['header'] = true;
359
+ $this->info['id3v2']['majorversion'] = ord($header{3});
360
+ $this->info['id3v2']['minorversion'] = ord($header{4});
361
+ $this->info['avdataoffset'] += getid3_lib::BigEndian2Int(substr($header, 6, 4), 1) + 10; // length of ID3v2 tag in 10-byte header doesn't include 10-byte header length
362
+ }
363
+ }
364
+
365
+ // read 32 kb file data
366
+ fseek($this->fp, $this->info['avdataoffset'], SEEK_SET);
367
+ $formattest = fread($this->fp, 32774);
368
+
369
+ // determine format
370
+ $determined_format = $this->GetFileFormat($formattest, $filename);
371
+
372
+ // unable to determine file format
373
+ if (!$determined_format) {
374
+ fclose($this->fp);
375
+ return $this->error('unable to determine file format');
376
+ }
377
+
378
+ // check for illegal ID3 tags
379
+ if (isset($determined_format['fail_id3']) && (in_array('id3v1', $this->info['tags']) || in_array('id3v2', $this->info['tags']))) {
380
+ if ($determined_format['fail_id3'] === 'ERROR') {
381
+ fclose($this->fp);
382
+ return $this->error('ID3 tags not allowed on this file type.');
383
+ } elseif ($determined_format['fail_id3'] === 'WARNING') {
384
+ $this->warning('ID3 tags not allowed on this file type.');
385
+ }
386
+ }
387
+
388
+ // check for illegal APE tags
389
+ if (isset($determined_format['fail_ape']) && in_array('ape', $this->info['tags'])) {
390
+ if ($determined_format['fail_ape'] === 'ERROR') {
391
+ fclose($this->fp);
392
+ return $this->error('APE tags not allowed on this file type.');
393
+ } elseif ($determined_format['fail_ape'] === 'WARNING') {
394
+ $this->warning('APE tags not allowed on this file type.');
395
+ }
396
+ }
397
+
398
+ // set mime type
399
+ $this->info['mime_type'] = $determined_format['mime_type'];
400
+
401
+ // supported format signature pattern detected, but module deleted
402
+ if (!file_exists(GETID3_INCLUDEPATH.$determined_format['include'])) {
403
+ fclose($this->fp);
404
+ return $this->error('Format not supported, module "'.$determined_format['include'].'" was removed.');
405
+ }
406
+
407
+ // module requires iconv support
408
+ // Check encoding/iconv support
409
+ if (!empty($determined_format['iconv_req']) && !function_exists('iconv') && !in_array($this->encoding, array('ISO-8859-1', 'UTF-8', 'UTF-16LE', 'UTF-16BE', 'UTF-16'))) {
410
+ $errormessage = 'iconv() support is required for this module ('.$determined_format['include'].') for encodings other than ISO-8859-1, UTF-8, UTF-16LE, UTF16-BE, UTF-16. ';
411
+ if (GETID3_OS_ISWINDOWS) {
412
+ $errormessage .= 'PHP does not have iconv() support. Please enable php_iconv.dll in php.ini, and copy iconv.dll from c:/php/dlls to c:/windows/system32';
413
+ } else {
414
+ $errormessage .= 'PHP is not compiled with iconv() support. Please recompile with the --with-iconv switch';
415
+ }
416
+ return $this->error($errormessage);
417
+ }
418
+
419
+ // include module
420
+ include_once(GETID3_INCLUDEPATH.$determined_format['include']);
421
+
422
+ // instantiate module class
423
+ $class_name = 'getid3_'.$determined_format['module'];
424
+ if (!class_exists($class_name)) {
425
+ return $this->error('Format not supported, module "'.$determined_format['include'].'" is corrupt.');
426
+ }
427
+ $class = new $class_name($this);
428
+ $class->Analyze();
429
+ unset($class);
430
+
431
+ // close file
432
+ fclose($this->fp);
433
+
434
+ // process all tags - copy to 'tags' and convert charsets
435
+ if ($this->option_tags_process) {
436
+ $this->HandleAllTags();
437
+ }
438
+
439
+ // perform more calculations
440
+ if ($this->option_extra_info) {
441
+ $this->ChannelsBitratePlaytimeCalculations();
442
+ $this->CalculateCompressionRatioVideo();
443
+ $this->CalculateCompressionRatioAudio();
444
+ $this->CalculateReplayGain();
445
+ $this->ProcessAudioStreams();
446
+ }
447
+
448
+ // get the MD5 sum of the audio/video portion of the file - without ID3/APE/Lyrics3/etc header/footer tags
449
+ if ($this->option_md5_data) {
450
+ // do not calc md5_data if md5_data_source is present - set by flac only - future MPC/SV8 too
451
+ if (!$this->option_md5_data_source || empty($this->info['md5_data_source'])) {
452
+ $this->getHashdata('md5');
453
+ }
454
+ }
455
+
456
+ // get the SHA1 sum of the audio/video portion of the file - without ID3/APE/Lyrics3/etc header/footer tags
457
+ if ($this->option_sha1_data) {
458
+ $this->getHashdata('sha1');
459
+ }
460
+
461
+ // remove undesired keys
462
+ $this->CleanUp();
463
+
464
+ } catch (Exception $e) {
465
+ $this->error('Caught exception: '.$e->getMessage());
466
+ }
467
+
468
+ // return info array
469
+ return $this->info;
470
+ }
471
+
472
+
473
+ // private: error handling
474
+ public function error($message) {
475
+ $this->CleanUp();
476
+ if (!isset($this->info['error'])) {
477
+ $this->info['error'] = array();
478
+ }
479
+ $this->info['error'][] = $message;
480
+ return $this->info;
481
+ }
482
+
483
+
484
+ // private: warning handling
485
+ public function warning($message) {
486
+ $this->info['warning'][] = $message;
487
+ return true;
488
+ }
489
+
490
+
491
+ // private: CleanUp
492
+ private function CleanUp() {
493
+
494
+ // remove possible empty keys
495
+ $AVpossibleEmptyKeys = array('dataformat', 'bits_per_sample', 'encoder_options', 'streams', 'bitrate');
496
+ foreach ($AVpossibleEmptyKeys as $dummy => $key) {
497
+ if (empty($this->info['audio'][$key]) && isset($this->info['audio'][$key])) {
498
+ unset($this->info['audio'][$key]);
499
+ }
500
+ if (empty($this->info['video'][$key]) && isset($this->info['video'][$key])) {
501
+ unset($this->info['video'][$key]);
502
+ }
503
+ }
504
+
505
+ // remove empty root keys
506
+ if (!empty($this->info)) {
507
+ foreach ($this->info as $key => $value) {
508
+ if (empty($this->info[$key]) && ($this->info[$key] !== 0) && ($this->info[$key] !== '0')) {
509
+ unset($this->info[$key]);
510
+ }
511
+ }
512
+ }
513
+
514
+ // remove meaningless entries from unknown-format files
515
+ if (empty($this->info['fileformat'])) {
516
+ if (isset($this->info['avdataoffset'])) {
517
+ unset($this->info['avdataoffset']);
518
+ }
519
+ if (isset($this->info['avdataend'])) {
520
+ unset($this->info['avdataend']);
521
+ }
522
+ }
523
+
524
+ // remove possible duplicated identical entries
525
+ if (!empty($this->info['error'])) {
526
+ $this->info['error'] = array_values(array_unique($this->info['error']));
527
+ }
528
+ if (!empty($this->info['warning'])) {
529
+ $this->info['warning'] = array_values(array_unique($this->info['warning']));
530
+ }
531
+
532
+ // remove "global variable" type keys
533
+ unset($this->info['php_memory_limit']);
534
+
535
+ return true;
536
+ }
537
+
538
+
539
+ // return array containing information about all supported formats
540
+ public function GetFileFormatArray() {
541
+ static $format_info = array();
542
+ if (empty($format_info)) {
543
+ $format_info = array(
544
+
545
+ // Audio formats
546
+
547
+ // AC-3 - audio - Dolby AC-3 / Dolby Digital
548
+ 'ac3' => array(
549
+ 'pattern' => '^\x0B\x77',
550
+ 'group' => 'audio',
551
+ 'module' => 'ac3',
552
+ 'mime_type' => 'audio/ac3',
553
+ ),
554
+
555
+ // AAC - audio - Advanced Audio Coding (AAC) - ADIF format
556
+ 'adif' => array(
557
+ 'pattern' => '^ADIF',
558
+ 'group' => 'audio',
559
+ 'module' => 'aac',
560
+ 'mime_type' => 'application/octet-stream',
561
+ 'fail_ape' => 'WARNING',
562
+ ),
563
+
564
+ /*
565
+ // AA - audio - Audible Audiobook
566
+ 'aa' => array(
567
+ 'pattern' => '^.{4}\x57\x90\x75\x36',
568
+ 'group' => 'audio',
569
+ 'module' => 'aa',
570
+ 'mime_type' => 'audio/audible',
571
+ ),
572
+ */
573
+ // AAC - audio - Advanced Audio Coding (AAC) - ADTS format (very similar to MP3)
574
+ 'adts' => array(
575
+ 'pattern' => '^\xFF[\xF0-\xF1\xF8-\xF9]',
576
+ 'group' => 'audio',
577
+ 'module' => 'aac',
578
+ 'mime_type' => 'application/octet-stream',
579
+ 'fail_ape' => 'WARNING',
580
+ ),
581
+
582
+
583
+ // AU - audio - NeXT/Sun AUdio (AU)
584
+ 'au' => array(
585
+ 'pattern' => '^\.snd',
586
+ 'group' => 'audio',
587
+ 'module' => 'au',
588
+ 'mime_type' => 'audio/basic',
589
+ ),
590
+
591
+ // AVR - audio - Audio Visual Research
592
+ 'avr' => array(
593
+ 'pattern' => '^2BIT',
594
+ 'group' => 'audio',
595
+ 'module' => 'avr',
596
+ 'mime_type' => 'application/octet-stream',
597
+ ),
598
+
599
+ // BONK - audio - Bonk v0.9+
600
+ 'bonk' => array(
601
+ 'pattern' => '^\x00(BONK|INFO|META| ID3)',
602
+ 'group' => 'audio',
603
+ 'module' => 'bonk',
604
+ 'mime_type' => 'audio/xmms-bonk',
605
+ ),
606
+
607
+ // DSS - audio - Digital Speech Standard
608
+ 'dss' => array(
609
+ 'pattern' => '^[\x02-\x03]ds[s2]',
610
+ 'group' => 'audio',
611
+ 'module' => 'dss',
612
+ 'mime_type' => 'application/octet-stream',
613
+ ),
614
+
615
+ // DTS - audio - Dolby Theatre System
616
+ 'dts' => array(
617
+ 'pattern' => '^\x7F\xFE\x80\x01',
618
+ 'group' => 'audio',
619
+ 'module' => 'dts',
620
+ 'mime_type' => 'audio/dts',
621
+ ),
622
+
623
+ // FLAC - audio - Free Lossless Audio Codec
624
+ 'flac' => array(
625
+ 'pattern' => '^fLaC',
626
+ 'group' => 'audio',
627
+ 'module' => 'flac',
628
+ 'mime_type' => 'audio/x-flac',
629
+ ),
630
+
631
+ // LA - audio - Lossless Audio (LA)
632
+ 'la' => array(
633
+ 'pattern' => '^LA0[2-4]',
634
+ 'group' => 'audio',
635
+ 'module' => 'la',
636
+ 'mime_type' => 'application/octet-stream',
637
+ ),
638
+
639
+ // LPAC - audio - Lossless Predictive Audio Compression (LPAC)
640
+ 'lpac' => array(
641
+ 'pattern' => '^LPAC',
642
+ 'group' => 'audio',
643
+ 'module' => 'lpac',
644
+ 'mime_type' => 'application/octet-stream',
645
+ ),
646
+
647
+ // MIDI - audio - MIDI (Musical Instrument Digital Interface)
648
+ 'midi' => array(
649
+ 'pattern' => '^MThd',
650
+ 'group' => 'audio',
651
+ 'module' => 'midi',
652
+ 'mime_type' => 'audio/midi',
653
+ ),
654
+
655
+ // MAC - audio - Monkey's Audio Compressor
656
+ 'mac' => array(
657
+ 'pattern' => '^MAC ',
658
+ 'group' => 'audio',
659
+ 'module' => 'monkey',
660
+ 'mime_type' => 'application/octet-stream',
661
+ ),
662
+
663
+ // has been known to produce false matches in random files (e.g. JPEGs), leave out until more precise matching available
664
+ // // MOD - audio - MODule (assorted sub-formats)
665
+ // 'mod' => array(
666
+ // 'pattern' => '^.{1080}(M\\.K\\.|M!K!|FLT4|FLT8|[5-9]CHN|[1-3][0-9]CH)',
667
+ // 'group' => 'audio',
668
+ // 'module' => 'mod',
669
+ // 'option' => 'mod',
670
+ // 'mime_type' => 'audio/mod',
671
+ // ),
672
+
673
+ // MOD - audio - MODule (Impulse Tracker)
674
+ 'it' => array(
675
+ 'pattern' => '^IMPM',
676
+ 'group' => 'audio',
677
+ 'module' => 'mod',
678
+ //'option' => 'it',
679
+ 'mime_type' => 'audio/it',
680
+ ),
681
+
682
+ // MOD - audio - MODule (eXtended Module, various sub-formats)
683
+ 'xm' => array(
684
+ 'pattern' => '^Extended Module',
685
+ 'group' => 'audio',
686
+ 'module' => 'mod',
687
+ //'option' => 'xm',
688
+ 'mime_type' => 'audio/xm',
689
+ ),
690
+
691
+ // MOD - audio - MODule (ScreamTracker)
692
+ 's3m' => array(
693
+ 'pattern' => '^.{44}SCRM',
694
+ 'group' => 'audio',
695
+ 'module' => 'mod',
696
+ //'option' => 's3m',
697
+ 'mime_type' => 'audio/s3m',
698
+ ),
699
+
700
+ // MPC - audio - Musepack / MPEGplus
701
+ 'mpc' => array(
702
+ 'pattern' => '^(MPCK|MP\+|[\x00\x01\x10\x11\x40\x41\x50\x51\x80\x81\x90\x91\xC0\xC1\xD0\xD1][\x20-37][\x00\x20\x40\x60\x80\xA0\xC0\xE0])',
703
+ 'group' => 'audio',
704
+ 'module' => 'mpc',
705
+ 'mime_type' => 'audio/x-musepack',
706
+ ),
707
+
708
+ // MP3 - audio - MPEG-audio Layer 3 (very similar to AAC-ADTS)
709
+ 'mp3' => array(
710
+ 'pattern' => '^\xFF[\xE2-\xE7\xF2-\xF7\xFA-\xFF][\x00-\x0B\x10-\x1B\x20-\x2B\x30-\x3B\x40-\x4B\x50-\x5B\x60-\x6B\x70-\x7B\x80-\x8B\x90-\x9B\xA0-\xAB\xB0-\xBB\xC0-\xCB\xD0-\xDB\xE0-\xEB\xF0-\xFB]',
711
+ 'group' => 'audio',
712
+ 'module' => 'mp3',
713
+ 'mime_type' => 'audio/mpeg',
714
+ ),
715
+
716
+ // OFR - audio - OptimFROG
717
+ 'ofr' => array(
718
+ 'pattern' => '^(\*RIFF|OFR)',
719
+ 'group' => 'audio',
720
+ 'module' => 'optimfrog',
721
+ 'mime_type' => 'application/octet-stream',
722
+ ),
723
+
724
+ // RKAU - audio - RKive AUdio compressor
725
+ 'rkau' => array(
726
+ 'pattern' => '^RKA',
727
+ 'group' => 'audio',
728
+ 'module' => 'rkau',
729
+ 'mime_type' => 'application/octet-stream',
730
+ ),
731
+
732
+ // SHN - audio - Shorten
733
+ 'shn' => array(
734
+ 'pattern' => '^ajkg',
735
+ 'group' => 'audio',
736
+ 'module' => 'shorten',
737
+ 'mime_type' => 'audio/xmms-shn',
738
+ 'fail_id3' => 'ERROR',
739
+ 'fail_ape' => 'ERROR',
740
+ ),
741
+
742
+ // TTA - audio - TTA Lossless Audio Compressor (http://tta.corecodec.org)
743
+ 'tta' => array(
744
+ 'pattern' => '^TTA', // could also be '^TTA(\x01|\x02|\x03|2|1)'
745
+ 'group' => 'audio',
746
+ 'module' => 'tta',
747
+ 'mime_type' => 'application/octet-stream',
748
+ ),
749
+
750
+ // VOC - audio - Creative Voice (VOC)
751
+ 'voc' => array(
752
+ 'pattern' => '^Creative Voice File',
753
+ 'group' => 'audio',
754
+ 'module' => 'voc',
755
+ 'mime_type' => 'audio/voc',
756
+ ),
757
+
758
+ // VQF - audio - transform-domain weighted interleave Vector Quantization Format (VQF)
759
+ 'vqf' => array(
760
+ 'pattern' => '^TWIN',
761
+ 'group' => 'audio',
762
+ 'module' => 'vqf',
763
+ 'mime_type' => 'application/octet-stream',
764
+ ),
765
+
766
+ // WV - audio - WavPack (v4.0+)
767
+ 'wv' => array(
768
+ 'pattern' => '^wvpk',
769
+ 'group' => 'audio',
770
+ 'module' => 'wavpack',
771
+ 'mime_type' => 'application/octet-stream',
772
+ ),
773
+
774
+
775
+ // Audio-Video formats
776
+
777
+ // ASF - audio/video - Advanced Streaming Format, Windows Media Video, Windows Media Audio
778
+ 'asf' => array(
779
+ 'pattern' => '^\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C',
780
+ 'group' => 'audio-video',
781
+ 'module' => 'asf',
782
+ 'mime_type' => 'video/x-ms-asf',
783
+ 'iconv_req' => false,
784
+ ),
785
+
786
+ // BINK - audio/video - Bink / Smacker
787
+ 'bink' => array(
788
+ 'pattern' => '^(BIK|SMK)',
789
+ 'group' => 'audio-video',
790
+ 'module' => 'bink',
791
+ 'mime_type' => 'application/octet-stream',
792
+ ),
793
+
794
+ // FLV - audio/video - FLash Video
795
+ 'flv' => array(
796
+ 'pattern' => '^FLV\x01',
797
+ 'group' => 'audio-video',
798
+ 'module' => 'flv',
799
+ 'mime_type' => 'video/x-flv',
800
+ ),
801
+
802
+ // MKAV - audio/video - Mastroka
803
+ 'matroska' => array(
804
+ 'pattern' => '^\x1A\x45\xDF\xA3',
805
+ 'group' => 'audio-video',
806
+ 'module' => 'matroska',
807
+ 'mime_type' => 'video/x-matroska', // may also be audio/x-matroska
808
+ ),
809
+
810
+ // MPEG - audio/video - MPEG (Moving Pictures Experts Group)
811
+ 'mpeg' => array(
812
+ 'pattern' => '^\x00\x00\x01(\xBA|\xB3)',
813
+ 'group' => 'audio-video',
814
+ 'module' => 'mpeg',
815
+ 'mime_type' => 'video/mpeg',
816
+ ),
817
+
818
+ // NSV - audio/video - Nullsoft Streaming Video (NSV)
819
+ 'nsv' => array(
820
+ 'pattern' => '^NSV[sf]',
821
+ 'group' => 'audio-video',
822
+ 'module' => 'nsv',
823
+ 'mime_type' => 'application/octet-stream',
824
+ ),
825
+
826
+ // Ogg - audio/video - Ogg (Ogg-Vorbis, Ogg-FLAC, Speex, Ogg-Theora(*), Ogg-Tarkin(*))
827
+ 'ogg' => array(
828
+ 'pattern' => '^OggS',
829
+ 'group' => 'audio',
830
+ 'module' => 'ogg',
831
+ 'mime_type' => 'application/ogg',
832
+ 'fail_id3' => 'WARNING',
833
+ 'fail_ape' => 'WARNING',
834
+ ),
835
+
836
+ // QT - audio/video - Quicktime
837
+ 'quicktime' => array(
838
+ 'pattern' => '^.{4}(cmov|free|ftyp|mdat|moov|pnot|skip|wide)',
839
+ 'group' => 'audio-video',
840
+ 'module' => 'quicktime',
841
+ 'mime_type' => 'video/quicktime',
842
+ ),
843
+
844
+ // RIFF - audio/video - Resource Interchange File Format (RIFF) / WAV / AVI / CD-audio / SDSS = renamed variant used by SmartSound QuickTracks (www.smartsound.com) / FORM = Audio Interchange File Format (AIFF)
845
+ 'riff' => array(
846
+ 'pattern' => '^(RIFF|SDSS|FORM)',
847
+ 'group' => 'audio-video',
848
+ 'module' => 'riff',
849
+ 'mime_type' => 'audio/x-wave',
850
+ 'fail_ape' => 'WARNING',
851
+ ),
852
+
853
+ // Real - audio/video - RealAudio, RealVideo
854
+ 'real' => array(
855
+ 'pattern' => '^(\\.RMF|\\.ra)',
856
+ 'group' => 'audio-video',
857
+ 'module' => 'real',
858
+ 'mime_type' => 'audio/x-realaudio',
859
+ ),
860
+
861
+ // SWF - audio/video - ShockWave Flash
862
+ 'swf' => array(
863
+ 'pattern' => '^(F|C)WS',
864
+ 'group' => 'audio-video',
865
+ 'module' => 'swf',
866
+ 'mime_type' => 'application/x-shockwave-flash',
867
+ ),
868
+
869
+ // TS - audio/video - MPEG-2 Transport Stream
870
+ 'ts' => array(
871
+ 'pattern' => '^(\x47.{187}){10,}', // packets are 188 bytes long and start with 0x47 "G". Check for at least 10 packets matching this pattern
872
+ 'group' => 'audio-video',
873
+ 'module' => 'ts',
874
+ 'mime_type' => 'video/MP2T',
875
+ ),
876
+
877
+
878
+ // Still-Image formats
879
+
880
+ // BMP - still image - Bitmap (Windows, OS/2; uncompressed, RLE8, RLE4)
881
+ 'bmp' => array(
882
+ 'pattern' => '^BM',
883
+ 'group' => 'graphic',
884
+ 'module' => 'bmp',
885
+ 'mime_type' => 'image/bmp',
886
+ 'fail_id3' => 'ERROR',
887
+ 'fail_ape' => 'ERROR',
888
+ ),
889
+
890
+ // GIF - still image - Graphics Interchange Format
891
+ 'gif' => array(
892
+ 'pattern' => '^GIF',
893
+ 'group' => 'graphic',
894
+ 'module' => 'gif',
895
+ 'mime_type' => 'image/gif',
896
+ 'fail_id3' => 'ERROR',
897
+ 'fail_ape' => 'ERROR',
898
+ ),
899
+
900
+ // JPEG - still image - Joint Photographic Experts Group (JPEG)
901
+ 'jpg' => array(
902
+ 'pattern' => '^\xFF\xD8\xFF',
903
+ 'group' => 'graphic',
904
+ 'module' => 'jpg',
905
+ 'mime_type' => 'image/jpeg',
906
+ 'fail_id3' => 'ERROR',
907
+ 'fail_ape' => 'ERROR',
908
+ ),
909
+
910
+ // PCD - still image - Kodak Photo CD
911
+ 'pcd' => array(
912
+ 'pattern' => '^.{2048}PCD_IPI\x00',
913
+ 'group' => 'graphic',
914
+ 'module' => 'pcd',
915
+ 'mime_type' => 'image/x-photo-cd',
916
+ 'fail_id3' => 'ERROR',
917
+ 'fail_ape' => 'ERROR',
918
+ ),
919
+
920
+
921
+ // PNG - still image - Portable Network Graphics (PNG)
922
+ 'png' => array(
923
+ 'pattern' => '^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A',
924
+ 'group' => 'graphic',
925
+ 'module' => 'png',
926
+ 'mime_type' => 'image/png',
927
+ 'fail_id3' => 'ERROR',
928
+ 'fail_ape' => 'ERROR',
929
+ ),
930
+
931
+
932
+ // SVG - still image - Scalable Vector Graphics (SVG)
933
+ 'svg' => array(
934
+ 'pattern' => '(<!DOCTYPE svg PUBLIC |xmlns="http:\/\/www\.w3\.org\/2000\/svg")',
935
+ 'group' => 'graphic',
936
+ 'module' => 'svg',
937
+ 'mime_type' => 'image/svg+xml',
938
+ 'fail_id3' => 'ERROR',
939
+ 'fail_ape' => 'ERROR',
940
+ ),
941
+
942
+
943
+ // TIFF - still image - Tagged Information File Format (TIFF)
944
+ 'tiff' => array(
945
+ 'pattern' => '^(II\x2A\x00|MM\x00\x2A)',
946
+ 'group' => 'graphic',
947
+ 'module' => 'tiff',
948
+ 'mime_type' => 'image/tiff',
949
+ 'fail_id3' => 'ERROR',
950
+ 'fail_ape' => 'ERROR',
951
+ ),
952
+
953
+
954
+ // EFAX - still image - eFax (TIFF derivative)
955
+ 'efax' => array(
956
+ 'pattern' => '^\xDC\xFE',
957
+ 'group' => 'graphic',
958
+ 'module' => 'efax',
959
+ 'mime_type' => 'image/efax',
960
+ 'fail_id3' => 'ERROR',
961
+ 'fail_ape' => 'ERROR',
962
+ ),
963
+
964
+
965
+ // Data formats
966
+
967
+ // ISO - data - International Standards Organization (ISO) CD-ROM Image
968
+ 'iso' => array(
969
+ 'pattern' => '^.{32769}CD001',
970
+ 'group' => 'misc',
971
+ 'module' => 'iso',
972
+ 'mime_type' => 'application/octet-stream',
973
+ 'fail_id3' => 'ERROR',
974
+ 'fail_ape' => 'ERROR',
975
+ 'iconv_req' => false,
976
+ ),
977
+
978
+ // RAR - data - RAR compressed data
979
+ 'rar' => array(
980
+ 'pattern' => '^Rar\!',
981
+ 'group' => 'archive',
982
+ 'module' => 'rar',
983
+ 'mime_type' => 'application/octet-stream',
984
+ 'fail_id3' => 'ERROR',
985
+ 'fail_ape' => 'ERROR',
986
+ ),
987
+
988
+ // SZIP - audio/data - SZIP compressed data
989
+ 'szip' => array(
990
+ 'pattern' => '^SZ\x0A\x04',
991
+ 'group' => 'archive',
992
+ 'module' => 'szip',
993
+ 'mime_type' => 'application/octet-stream',
994
+ 'fail_id3' => 'ERROR',
995
+ 'fail_ape' => 'ERROR',
996
+ ),
997
+
998
+ // TAR - data - TAR compressed data
999
+ 'tar' => array(
1000
+ 'pattern' => '^.{100}[0-9\x20]{7}\x00[0-9\x20]{7}\x00[0-9\x20]{7}\x00[0-9\x20\x00]{12}[0-9\x20\x00]{12}',
1001
+ 'group' => 'archive',
1002
+ 'module' => 'tar',
1003
+ 'mime_type' => 'application/x-tar',
1004
+ 'fail_id3' => 'ERROR',
1005
+ 'fail_ape' => 'ERROR',
1006
+ ),
1007
+
1008
+ // GZIP - data - GZIP compressed data
1009
+ 'gz' => array(
1010
+ 'pattern' => '^\x1F\x8B\x08',
1011
+ 'group' => 'archive',
1012
+ 'module' => 'gzip',
1013
+ 'mime_type' => 'application/x-gzip',
1014
+ 'fail_id3' => 'ERROR',
1015
+ 'fail_ape' => 'ERROR',
1016
+ ),
1017
+
1018
+ // ZIP - data - ZIP compressed data
1019
+ 'zip' => array(
1020
+ 'pattern' => '^PK\x03\x04',
1021
+ 'group' => 'archive',
1022
+ 'module' => 'zip',
1023
+ 'mime_type' => 'application/zip',
1024
+ 'fail_id3' => 'ERROR',
1025
+ 'fail_ape' => 'ERROR',
1026
+ ),
1027
+
1028
+
1029
+ // Misc other formats
1030
+
1031
+ // PAR2 - data - Parity Volume Set Specification 2.0
1032
+ 'par2' => array (
1033
+ 'pattern' => '^PAR2\x00PKT',
1034
+ 'group' => 'misc',
1035
+ 'module' => 'par2',
1036
+ 'mime_type' => 'application/octet-stream',
1037
+ 'fail_id3' => 'ERROR',
1038
+ 'fail_ape' => 'ERROR',
1039
+ ),
1040
+
1041
+ // PDF - data - Portable Document Format
1042
+ 'pdf' => array(
1043
+ 'pattern' => '^\x25PDF',
1044
+ 'group' => 'misc',
1045
+ 'module' => 'pdf',
1046
+ 'mime_type' => 'application/pdf',
1047
+ 'fail_id3' => 'ERROR',
1048
+ 'fail_ape' => 'ERROR',
1049
+ ),
1050
+
1051
+ // MSOFFICE - data - ZIP compressed data
1052
+ 'msoffice' => array(
1053
+ 'pattern' => '^\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1', // D0CF11E == DOCFILE == Microsoft Office Document
1054
+ 'group' => 'misc',
1055
+ 'module' => 'msoffice',
1056
+ 'mime_type' => 'application/octet-stream',
1057
+ 'fail_id3' => 'ERROR',
1058
+ 'fail_ape' => 'ERROR',
1059
+ ),
1060
+
1061
+ // CUE - data - CUEsheet (index to single-file disc images)
1062
+ 'cue' => array(
1063
+ 'pattern' => '', // empty pattern means cannot be automatically detected, will fall through all other formats and match based on filename and very basic file contents
1064
+ 'group' => 'misc',
1065
+ 'module' => 'cue',
1066
+ 'mime_type' => 'application/octet-stream',
1067
+ ),
1068
+
1069
+ );
1070
+ }
1071
+
1072
+ return $format_info;
1073
+ }
1074
+
1075
+
1076
+
1077
+ public function GetFileFormat(&$filedata, $filename='') {
1078
+ // this function will determine the format of a file based on usually
1079
+ // the first 2-4 bytes of the file (8 bytes for PNG, 16 bytes for JPG,
1080
+ // and in the case of ISO CD image, 6 bytes offset 32kb from the start
1081
+ // of the file).
1082
+
1083
+ // Identify file format - loop through $format_info and detect with reg expr
1084
+ foreach ($this->GetFileFormatArray() as $format_name => $info) {
1085
+ // The /s switch on preg_match() forces preg_match() NOT to treat
1086
+ // newline (0x0A) characters as special chars but do a binary match
1087
+ if (!empty($info['pattern']) && preg_match('#'.$info['pattern'].'#s', $filedata)) {
1088
+ $info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
1089
+ return $info;
1090
+ }
1091
+ }
1092
+
1093
+
1094
+ if (preg_match('#\.mp[123a]$#i', $filename)) {
1095
+ // Too many mp3 encoders on the market put gabage in front of mpeg files
1096
+ // use assume format on these if format detection failed
1097
+ $GetFileFormatArray = $this->GetFileFormatArray();
1098
+ $info = $GetFileFormatArray['mp3'];
1099
+ $info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
1100
+ return $info;
1101
+ } elseif (preg_match('/\.cue$/i', $filename) && preg_match('#FILE "[^"]+" (BINARY|MOTOROLA|AIFF|WAVE|MP3)#', $filedata)) {
1102
+ // there's not really a useful consistent "magic" at the beginning of .cue files to identify them
1103
+ // so until I think of something better, just go by filename if all other format checks fail
1104
+ // and verify there's at least one instance of "TRACK xx AUDIO" in the file
1105
+ $GetFileFormatArray = $this->GetFileFormatArray();
1106
+ $info = $GetFileFormatArray['cue'];
1107
+ $info['include'] = 'module.'.$info['group'].'.'.$info['module'].'.php';
1108
+ return $info;
1109
+ }
1110
+
1111
+ return false;
1112
+ }
1113
+
1114
+
1115
+ // converts array to $encoding charset from $this->encoding
1116
+ public function CharConvert(&$array, $encoding) {
1117
+
1118
+ // identical encoding - end here
1119
+ if ($encoding == $this->encoding) {
1120
+ return;
1121
+ }
1122
+
1123
+ // loop thru array
1124
+ foreach ($array as $key => $value) {
1125
+
1126
+ // go recursive
1127
+ if (is_array($value)) {
1128
+ $this->CharConvert($array[$key], $encoding);
1129
+ }
1130
+
1131
+ // convert string
1132
+ elseif (is_string($value)) {
1133
+ $array[$key] = trim(getid3_lib::iconv_fallback($encoding, $this->encoding, $value));
1134
+ }
1135
+ }
1136
+ }
1137
+
1138
+
1139
+ public function HandleAllTags() {
1140
+
1141
+ // key name => array (tag name, character encoding)
1142
+ static $tags;
1143
+ if (empty($tags)) {
1144
+ $tags = array(
1145
+ 'asf' => array('asf' , 'UTF-16LE'),
1146
+ 'midi' => array('midi' , 'ISO-8859-1'),
1147
+ 'nsv' => array('nsv' , 'ISO-8859-1'),
1148
+ 'ogg' => array('vorbiscomment' , 'UTF-8'),
1149
+ 'png' => array('png' , 'UTF-8'),
1150
+ 'tiff' => array('tiff' , 'ISO-8859-1'),
1151
+ 'quicktime' => array('quicktime' , 'UTF-8'),
1152
+ 'real' => array('real' , 'ISO-8859-1'),
1153
+ 'vqf' => array('vqf' , 'ISO-8859-1'),
1154
+ 'zip' => array('zip' , 'ISO-8859-1'),
1155
+ 'riff' => array('riff' , 'ISO-8859-1'),
1156
+ 'lyrics3' => array('lyrics3' , 'ISO-8859-1'),
1157
+ 'id3v1' => array('id3v1' , $this->encoding_id3v1),
1158
+ 'id3v2' => array('id3v2' , 'UTF-8'), // not according to the specs (every frame can have a different encoding), but getID3() force-converts all encodings to UTF-8
1159
+ 'ape' => array('ape' , 'UTF-8'),
1160
+ 'cue' => array('cue' , 'ISO-8859-1'),
1161
+ 'matroska' => array('matroska' , 'UTF-8'),
1162
+ 'flac' => array('vorbiscomment' , 'UTF-8'),
1163
+ 'divxtag' => array('divx' , 'ISO-8859-1'),
1164
+ );
1165
+ }
1166
+
1167
+ // loop through comments array
1168
+ foreach ($tags as $comment_name => $tagname_encoding_array) {
1169
+ list($tag_name, $encoding) = $tagname_encoding_array;
1170
+
1171
+ // fill in default encoding type if not already present
1172
+ if (isset($this->info[$comment_name]) && !isset($this->info[$comment_name]['encoding'])) {
1173
+ $this->info[$comment_name]['encoding'] = $encoding;
1174
+ }
1175
+
1176
+ // copy comments if key name set
1177
+ if (!empty($this->info[$comment_name]['comments'])) {
1178
+ foreach ($this->info[$comment_name]['comments'] as $tag_key => $valuearray) {
1179
+ foreach ($valuearray as $key => $value) {
1180
+ if (is_string($value)) {
1181
+ $value = trim($value, " \r\n\t"); // do not trim nulls from $value!! Unicode characters will get mangled if trailing nulls are removed!
1182
+ }
1183
+ if ($value) {
1184
+ $this->info['tags'][trim($tag_name)][trim($tag_key)][] = $value;
1185
+ }
1186
+ }
1187
+ if ($tag_key == 'picture') {
1188
+ unset($this->info[$comment_name]['comments'][$tag_key]);
1189
+ }
1190
+ }
1191
+
1192
+ if (!isset($this->info['tags'][$tag_name])) {
1193
+ // comments are set but contain nothing but empty strings, so skip
1194
+ continue;
1195
+ }
1196
+
1197
+ if ($this->option_tags_html) {
1198
+ foreach ($this->info['tags'][$tag_name] as $tag_key => $valuearray) {
1199
+ foreach ($valuearray as $key => $value) {
1200
+ if (is_string($value)) {
1201
+ //$this->info['tags_html'][$tag_name][$tag_key][$key] = getid3_lib::MultiByteCharString2HTML($value, $encoding);
1202
+ $this->info['tags_html'][$tag_name][$tag_key][$key] = str_replace('&#0;', '', trim(getid3_lib::MultiByteCharString2HTML($value, $encoding)));
1203
+ } else {
1204
+ $this->info['tags_html'][$tag_name][$tag_key][$key] = $value;
1205
+ }
1206
+ }
1207
+ }
1208
+ }
1209
+
1210
+ $this->CharConvert($this->info['tags'][$tag_name], $encoding); // only copy gets converted!
1211
+ }
1212
+
1213
+ }
1214
+
1215
+ // pictures can take up a lot of space, and we don't need multiple copies of them
1216
+ // let there be a single copy in [comments][picture], and not elsewhere
1217
+ if (!empty($this->info['tags'])) {
1218
+ $unset_keys = array('tags', 'tags_html');
1219
+ foreach ($this->info['tags'] as $tagtype => $tagarray) {
1220
+ foreach ($tagarray as $tagname => $tagdata) {
1221
+ if ($tagname == 'picture') {
1222
+ foreach ($tagdata as $key => $tagarray) {
1223
+ $this->info['comments']['picture'][] = $tagarray;
1224
+ if (isset($tagarray['data']) && isset($tagarray['image_mime'])) {
1225
+ if (isset($this->info['tags'][$tagtype][$tagname][$key])) {
1226
+ unset($this->info['tags'][$tagtype][$tagname][$key]);
1227
+ }
1228
+ if (isset($this->info['tags_html'][$tagtype][$tagname][$key])) {
1229
+ unset($this->info['tags_html'][$tagtype][$tagname][$key]);
1230
+ }
1231
+ }
1232
+ }
1233
+ }
1234
+ }
1235
+ foreach ($unset_keys as $unset_key) {
1236
+ // remove possible empty keys from (e.g. [tags][id3v2][picture])
1237
+ if (empty($this->info[$unset_key][$tagtype]['picture'])) {
1238
+ unset($this->info[$unset_key][$tagtype]['picture']);
1239
+ }
1240
+ if (empty($this->info[$unset_key][$tagtype])) {
1241
+ unset($this->info[$unset_key][$tagtype]);
1242
+ }
1243
+ if (empty($this->info[$unset_key])) {
1244
+ unset($this->info[$unset_key]);
1245
+ }
1246
+ }
1247
+ // remove duplicate copy of picture data from (e.g. [id3v2][comments][picture])
1248
+ if (isset($this->info[$tagtype]['comments']['picture'])) {
1249
+ unset($this->info[$tagtype]['comments']['picture']);
1250
+ }
1251
+ if (empty($this->info[$tagtype]['comments'])) {
1252
+ unset($this->info[$tagtype]['comments']);
1253
+ }
1254
+ if (empty($this->info[$tagtype])) {
1255
+ unset($this->info[$tagtype]);
1256
+ }
1257
+ }
1258
+ }
1259
+ return true;
1260
+ }
1261
+
1262
+
1263
+ public function getHashdata($algorithm) {
1264
+ switch ($algorithm) {
1265
+ case 'md5':
1266
+ case 'sha1':
1267
+ break;
1268
+
1269
+ default:
1270
+ return $this->error('bad algorithm "'.$algorithm.'" in getHashdata()');
1271
+ break;
1272
+ }
1273
+
1274
+ if (!empty($this->info['fileformat']) && !empty($this->info['dataformat']) && ($this->info['fileformat'] == 'ogg') && ($this->info['audio']['dataformat'] == 'vorbis')) {
1275
+
1276
+ // We cannot get an identical md5_data value for Ogg files where the comments
1277
+ // span more than 1 Ogg page (compared to the same audio data with smaller
1278
+ // comments) using the normal getID3() method of MD5'ing the data between the
1279
+ // end of the comments and the end of the file (minus any trailing tags),
1280
+ // because the page sequence numbers of the pages that the audio data is on
1281
+ // do not match. Under normal circumstances, where comments are smaller than
1282
+ // the nominal 4-8kB page size, then this is not a problem, but if there are
1283
+ // very large comments, the only way around it is to strip off the comment
1284
+ // tags with vorbiscomment and MD5 that file.
1285
+ // This procedure must be applied to ALL Ogg files, not just the ones with
1286
+ // comments larger than 1 page, because the below method simply MD5's the
1287
+ // whole file with the comments stripped, not just the portion after the
1288
+ // comments block (which is the standard getID3() method.
1289
+
1290
+ // The above-mentioned problem of comments spanning multiple pages and changing
1291
+ // page sequence numbers likely happens for OggSpeex and OggFLAC as well, but
1292
+ // currently vorbiscomment only works on OggVorbis files.
1293
+
1294
+ if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
1295
+
1296
+ $this->warning('Failed making system call to vorbiscomment.exe - '.$algorithm.'_data is incorrect - error returned: PHP running in Safe Mode (backtick operator not available)');
1297
+ $this->info[$algorithm.'_data'] = false;
1298
+
1299
+ } else {
1300
+
1301
+ // Prevent user from aborting script
1302
+ $old_abort = ignore_user_abort(true);
1303
+
1304
+ // Create empty file
1305
+ $empty = tempnam(GETID3_TEMP_DIR, 'getID3');
1306
+ touch($empty);
1307
+
1308
+ // Use vorbiscomment to make temp file without comments
1309
+ $temp = tempnam(GETID3_TEMP_DIR, 'getID3');
1310
+ $file = $this->info['filenamepath'];
1311
+
1312
+ if (GETID3_OS_ISWINDOWS) {
1313
+
1314
+ if (file_exists(GETID3_HELPERAPPSDIR.'vorbiscomment.exe')) {
1315
+
1316
+ $commandline = '"'.GETID3_HELPERAPPSDIR.'vorbiscomment.exe" -w -c "'.$empty.'" "'.$file.'" "'.$temp.'"';
1317
+ $VorbisCommentError = `$commandline`;
1318
+
1319
+ } else {
1320
+
1321
+ $VorbisCommentError = 'vorbiscomment.exe not found in '.GETID3_HELPERAPPSDIR;
1322
+
1323
+ }
1324
+
1325
+ } else {
1326
+
1327
+ $commandline = 'vorbiscomment -w -c "'.$empty.'" "'.$file.'" "'.$temp.'" 2>&1';
1328
+ $commandline = 'vorbiscomment -w -c '.escapeshellarg($empty).' '.escapeshellarg($file).' '.escapeshellarg($temp).' 2>&1';
1329
+ $VorbisCommentError = `$commandline`;
1330
+
1331
+ }
1332
+
1333
+ if (!empty($VorbisCommentError)) {
1334
+
1335
+ $this->info['warning'][] = 'Failed making system call to vorbiscomment(.exe) - '.$algorithm.'_data will be incorrect. If vorbiscomment is unavailable, please download from http://www.vorbis.com/download.psp and put in the getID3() directory. Error returned: '.$VorbisCommentError;
1336
+ $this->info[$algorithm.'_data'] = false;
1337
+
1338
+ } else {
1339
+
1340
+ // Get hash of newly created file
1341
+ switch ($algorithm) {
1342
+ case 'md5':
1343
+ $this->info[$algorithm.'_data'] = md5_file($temp);
1344
+ break;
1345
+
1346
+ case 'sha1':
1347
+ $this->info[$algorithm.'_data'] = sha1_file($temp);
1348
+ break;
1349
+ }
1350
+ }
1351
+
1352
+ // Clean up
1353
+ unlink($empty);
1354
+ unlink($temp);
1355
+
1356
+ // Reset abort setting
1357
+ ignore_user_abort($old_abort);
1358
+
1359
+ }
1360
+
1361
+ } else {
1362
+
1363
+ if (!empty($this->info['avdataoffset']) || (isset($this->info['avdataend']) && ($this->info['avdataend'] < $this->info['filesize']))) {
1364
+
1365
+ // get hash from part of file
1366
+ $this->info[$algorithm.'_data'] = getid3_lib::hash_data($this->info['filenamepath'], $this->info['avdataoffset'], $this->info['avdataend'], $algorithm);
1367
+
1368
+ } else {
1369
+
1370
+ // get hash from whole file
1371
+ switch ($algorithm) {
1372
+ case 'md5':
1373
+ $this->info[$algorithm.'_data'] = md5_file($this->info['filenamepath']);
1374
+ break;
1375
+
1376
+ case 'sha1':
1377
+ $this->info[$algorithm.'_data'] = sha1_file($this->info['filenamepath']);
1378
+ break;
1379
+ }
1380
+ }
1381
+
1382
+ }
1383
+ return true;
1384
+ }
1385
+
1386
+
1387
+ public function ChannelsBitratePlaytimeCalculations() {
1388
+
1389
+ // set channelmode on audio
1390
+ if (!empty($this->info['audio']['channelmode']) || !isset($this->info['audio']['channels'])) {
1391
+ // ignore
1392
+ } elseif ($this->info['audio']['channels'] == 1) {
1393
+ $this->info['audio']['channelmode'] = 'mono';
1394
+ } elseif ($this->info['audio']['channels'] == 2) {
1395
+ $this->info['audio']['channelmode'] = 'stereo';
1396
+ }
1397
+
1398
+ // Calculate combined bitrate - audio + video
1399
+ $CombinedBitrate = 0;
1400
+ $CombinedBitrate += (isset($this->info['audio']['bitrate']) ? $this->info['audio']['bitrate'] : 0);
1401
+ $CombinedBitrate += (isset($this->info['video']['bitrate']) ? $this->info['video']['bitrate'] : 0);
1402
+ if (($CombinedBitrate > 0) && empty($this->info['bitrate'])) {
1403
+ $this->info['bitrate'] = $CombinedBitrate;
1404
+ }
1405
+ //if ((isset($this->info['video']) && !isset($this->info['video']['bitrate'])) || (isset($this->info['audio']) && !isset($this->info['audio']['bitrate']))) {
1406
+ // // for example, VBR MPEG video files cannot determine video bitrate:
1407
+ // // should not set overall bitrate and playtime from audio bitrate only
1408
+ // unset($this->info['bitrate']);
1409
+ //}
1410
+
1411
+ // video bitrate undetermined, but calculable
1412
+ if (isset($this->info['video']['dataformat']) && $this->info['video']['dataformat'] && (!isset($this->info['video']['bitrate']) || ($this->info['video']['bitrate'] == 0))) {
1413
+ // if video bitrate not set
1414
+ if (isset($this->info['audio']['bitrate']) && ($this->info['audio']['bitrate'] > 0) && ($this->info['audio']['bitrate'] == $this->info['bitrate'])) {
1415
+ // AND if audio bitrate is set to same as overall bitrate
1416
+ if (isset($this->info['playtime_seconds']) && ($this->info['playtime_seconds'] > 0)) {
1417
+ // AND if playtime is set
1418
+ if (isset($this->info['avdataend']) && isset($this->info['avdataoffset'])) {
1419
+ // AND if AV data offset start/end is known
1420
+ // THEN we can calculate the video bitrate
1421
+ $this->info['bitrate'] = round((($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['playtime_seconds']);
1422
+ $this->info['video']['bitrate'] = $this->info['bitrate'] - $this->info['audio']['bitrate'];
1423
+ }
1424
+ }
1425
+ }
1426
+ }
1427
+
1428
+ if ((!isset($this->info['playtime_seconds']) || ($this->info['playtime_seconds'] <= 0)) && !empty($this->info['bitrate'])) {
1429
+ $this->info['playtime_seconds'] = (($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['bitrate'];
1430
+ }
1431
+
1432
+ if (!isset($this->info['bitrate']) && !empty($this->info['playtime_seconds'])) {
1433
+ $this->info['bitrate'] = (($this->info['avdataend'] - $this->info['avdataoffset']) * 8) / $this->info['playtime_seconds'];
1434
+ }
1435
+ if (isset($this->info['bitrate']) && empty($this->info['audio']['bitrate']) && empty($this->info['video']['bitrate'])) {
1436
+ if (isset($this->info['audio']['dataformat']) && empty($this->info['video']['resolution_x'])) {
1437
+ // audio only
1438
+ $this->info['audio']['bitrate'] = $this->info['bitrate'];
1439
+ } elseif (isset($this->info['video']['resolution_x']) && empty($this->info['audio']['dataformat'])) {
1440
+ // video only
1441
+ $this->info['video']['bitrate'] = $this->info['bitrate'];
1442
+ }
1443
+ }
1444
+
1445
+ // Set playtime string
1446
+ if (!empty($this->info['playtime_seconds']) && empty($this->info['playtime_string'])) {
1447
+ $this->info['playtime_string'] = getid3_lib::PlaytimeString($this->info['playtime_seconds']);
1448
+ }
1449
+ }
1450
+
1451
+
1452
+ public function CalculateCompressionRatioVideo() {
1453
+ if (empty($this->info['video'])) {
1454
+ return false;
1455
+ }
1456
+ if (empty($this->info['video']['resolution_x']) || empty($this->info['video']['resolution_y'])) {
1457
+ return false;
1458
+ }
1459
+ if (empty($this->info['video']['bits_per_sample'])) {
1460
+ return false;
1461
+ }
1462
+
1463
+ switch ($this->info['video']['dataformat']) {
1464
+ case 'bmp':
1465
+ case 'gif':
1466
+ case 'jpeg':
1467
+ case 'jpg':
1468
+ case 'png':
1469
+ case 'tiff':
1470
+ $FrameRate = 1;
1471
+ $PlaytimeSeconds = 1;
1472
+ $BitrateCompressed = $this->info['filesize'] * 8;
1473
+ break;
1474
+
1475
+ default:
1476
+ if (!empty($this->info['video']['frame_rate'])) {
1477
+ $FrameRate = $this->info['video']['frame_rate'];
1478
+ } else {
1479
+ return false;
1480
+ }
1481
+ if (!empty($this->info['playtime_seconds'])) {
1482
+ $PlaytimeSeconds = $this->info['playtime_seconds'];
1483
+ } else {
1484
+ return false;
1485
+ }
1486
+ if (!empty($this->info['video']['bitrate'])) {
1487
+ $BitrateCompressed = $this->info['video']['bitrate'];
1488
+ } else {
1489
+ return false;
1490
+ }
1491
+ break;
1492
+ }
1493
+ $BitrateUncompressed = $this->info['video']['resolution_x'] * $this->info['video']['resolution_y'] * $this->info['video']['bits_per_sample'] * $FrameRate;
1494
+
1495
+ $this->info['video']['compression_ratio'] = $BitrateCompressed / $BitrateUncompressed;
1496
+ return true;
1497
+ }
1498
+
1499
+
1500
+ public function CalculateCompressionRatioAudio() {
1501
+ if (empty($this->info['audio']['bitrate']) || empty($this->info['audio']['channels']) || empty($this->info['audio']['sample_rate']) || !is_numeric($this->info['audio']['sample_rate'])) {
1502
+ return false;
1503
+ }
1504
+ $this->info['audio']['compression_ratio'] = $this->info['audio']['bitrate'] / ($this->info['audio']['channels'] * $this->info['audio']['sample_rate'] * (!empty($this->info['audio']['bits_per_sample']) ? $this->info['audio']['bits_per_sample'] : 16));
1505
+
1506
+ if (!empty($this->info['audio']['streams'])) {
1507
+ foreach ($this->info['audio']['streams'] as $streamnumber => $streamdata) {
1508
+ if (!empty($streamdata['bitrate']) && !empty($streamdata['channels']) && !empty($streamdata['sample_rate'])) {
1509
+ $this->info['audio']['streams'][$streamnumber]['compression_ratio'] = $streamdata['bitrate'] / ($streamdata['channels'] * $streamdata['sample_rate'] * (!empty($streamdata['bits_per_sample']) ? $streamdata['bits_per_sample'] : 16));
1510
+ }
1511
+ }
1512
+ }
1513
+ return true;
1514
+ }
1515
+
1516
+
1517
+ public function CalculateReplayGain() {
1518
+ if (isset($this->info['replay_gain'])) {
1519
+ if (!isset($this->info['replay_gain']['reference_volume'])) {
1520
+ $this->info['replay_gain']['reference_volume'] = (double) 89.0;
1521
+ }
1522
+ if (isset($this->info['replay_gain']['track']['adjustment'])) {
1523
+ $this->info['replay_gain']['track']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['track']['adjustment'];
1524
+ }
1525
+ if (isset($this->info['replay_gain']['album']['adjustment'])) {
1526
+ $this->info['replay_gain']['album']['volume'] = $this->info['replay_gain']['reference_volume'] - $this->info['replay_gain']['album']['adjustment'];
1527
+ }
1528
+
1529
+ if (isset($this->info['replay_gain']['track']['peak'])) {
1530
+ $this->info['replay_gain']['track']['max_noclip_gain'] = 0 - getid3_lib::RGADamplitude2dB($this->info['replay_gain']['track']['peak']);
1531
+ }
1532
+ if (isset($this->info['replay_gain']['album']['peak'])) {
1533
+ $this->info['replay_gain']['album']['max_noclip_gain'] = 0 - getid3_lib::RGADamplitude2dB($this->info['replay_gain']['album']['peak']);
1534
+ }
1535
+ }
1536
+ return true;
1537
+ }
1538
+
1539
+ public function ProcessAudioStreams() {
1540
+ if (!empty($this->info['audio']['bitrate']) || !empty($this->info['audio']['channels']) || !empty($this->info['audio']['sample_rate'])) {
1541
+ if (!isset($this->info['audio']['streams'])) {
1542
+ foreach ($this->info['audio'] as $key => $value) {
1543
+ if ($key != 'streams') {
1544
+ $this->info['audio']['streams'][0][$key] = $value;
1545
+ }
1546
+ }
1547
+ }
1548
+ }
1549
+ return true;
1550
+ }
1551
+
1552
+ public function getid3_tempnam() {
1553
+ return tempnam($this->tempdir, 'gI3');
1554
+ }
1555
+
1556
+ public function include_module($name) {
1557
+ //if (!file_exists($this->include_path.'module.'.$name.'.php')) {
1558
+ if (!file_exists(GETID3_INCLUDEPATH.'module.'.$name.'.php')) {
1559
+ throw new getid3_exception('Required module.'.$name.'.php is missing.');
1560
+ }
1561
+ include_once(GETID3_INCLUDEPATH.'module.'.$name.'.php');
1562
+ return true;
1563
+ }
1564
+
1565
+ }
1566
+
1567
+
1568
+ abstract class getid3_handler
1569
+ {
1570
+ protected $getid3; // pointer
1571
+
1572
+ protected $data_string_flag = false; // analyzing filepointer or string
1573
+ protected $data_string = ''; // string to analyze
1574
+ protected $data_string_position = 0; // seek position in string
1575
+ protected $data_string_length = 0; // string length
1576
+
1577
+ private $dependency_to = null;
1578
+
1579
+
1580
+ public function __construct(getID3 $getid3, $call_module=null) {
1581
+ $this->getid3 = $getid3;
1582
+
1583
+ if ($call_module) {
1584
+ $this->dependency_to = str_replace('getid3_', '', $call_module);
1585
+ }
1586
+ }
1587
+
1588
+
1589
+ // Analyze from file pointer
1590
+ abstract public function Analyze();
1591
+
1592
+
1593
+ // Analyze from string instead
1594
+ public function AnalyzeString($string) {
1595
+ // Enter string mode
1596
+ $this->setStringMode($string);
1597
+
1598
+ // Save info
1599
+ $saved_avdataoffset = $this->getid3->info['avdataoffset'];
1600
+ $saved_avdataend = $this->getid3->info['avdataend'];
1601
+ $saved_filesize = (isset($this->getid3->info['filesize']) ? $this->getid3->info['filesize'] : null); // may be not set if called as dependency without openfile() call
1602
+
1603
+ // Reset some info
1604
+ $this->getid3->info['avdataoffset'] = 0;
1605
+ $this->getid3->info['avdataend'] = $this->getid3->info['filesize'] = $this->data_string_length;
1606
+
1607
+ // Analyze
1608
+ $this->Analyze();
1609
+
1610
+ // Restore some info
1611
+ $this->getid3->info['avdataoffset'] = $saved_avdataoffset;
1612
+ $this->getid3->info['avdataend'] = $saved_avdataend;
1613
+ $this->getid3->info['filesize'] = $saved_filesize;
1614
+
1615
+ // Exit string mode
1616
+ $this->data_string_flag = false;
1617
+ }
1618
+
1619
+ public function setStringMode($string) {
1620
+ $this->data_string_flag = true;
1621
+ $this->data_string = $string;
1622
+ $this->data_string_length = strlen($string);
1623
+ }
1624
+
1625
+ protected function ftell() {
1626
+ if ($this->data_string_flag) {
1627
+ return $this->data_string_position;
1628
+ }
1629
+ return ftell($this->getid3->fp);
1630
+ }
1631
+
1632
+ protected function fread($bytes) {
1633
+ if ($this->data_string_flag) {
1634
+ $this->data_string_position += $bytes;
1635
+ return substr($this->data_string, $this->data_string_position - $bytes, $bytes);
1636
+ }
1637
+ $pos = $this->ftell() + $bytes;
1638
+ if (!getid3_lib::intValueSupported($pos)) {
1639
+ throw new getid3_exception('cannot fread('.$bytes.' from '.$this->ftell().') because beyond PHP filesystem limit', 10);
1640
+ }
1641
+ return fread($this->getid3->fp, $bytes);
1642
+ }
1643
+
1644
+ protected function fseek($bytes, $whence=SEEK_SET) {
1645
+ if ($this->data_string_flag) {
1646
+ switch ($whence) {
1647
+ case SEEK_SET:
1648
+ $this->data_string_position = $bytes;
1649
+ break;
1650
+
1651
+ case SEEK_CUR:
1652
+ $this->data_string_position += $bytes;
1653
+ break;
1654
+
1655
+ case SEEK_END:
1656
+ $this->data_string_position = $this->data_string_length + $bytes;
1657
+ break;
1658
+ }
1659
+ return 0;
1660
+ } else {
1661
+ $pos = $bytes;
1662
+ if ($whence == SEEK_CUR) {
1663
+ $pos = $this->ftell() + $bytes;
1664
+ } elseif ($whence == SEEK_END) {
1665
+ $pos = $this->info['filesize'] + $bytes;
1666
+ }
1667
+ if (!getid3_lib::intValueSupported($pos)) {
1668
+ throw new getid3_exception('cannot fseek('.$pos.') because beyond PHP filesystem limit', 10);
1669
+ }
1670
+ }
1671
+ return fseek($this->getid3->fp, $bytes, $whence);
1672
+ }
1673
+
1674
+ protected function feof() {
1675
+ if ($this->data_string_flag) {
1676
+ return $this->data_string_position >= $this->data_string_length;
1677
+ }
1678
+ return feof($this->getid3->fp);
1679
+ }
1680
+
1681
+ final protected function isDependencyFor($module) {
1682
+ return $this->dependency_to == $module;
1683
+ }
1684
+
1685
+ protected function error($text)
1686
+ {
1687
+ $this->getid3->info['error'][] = $text;
1688
+
1689
+ return false;
1690
+ }
1691
+
1692
+ protected function warning($text)
1693
+ {
1694
+ return $this->getid3->warning($text);
1695
+ }
1696
+
1697
+ protected function notice($text)
1698
+ {
1699
+ // does nothing for now
1700
+ }
1701
+
1702
+ public function saveAttachment($name, $offset, $length, $image_mime=null) {
1703
+ try {
1704
+
1705
+ // do not extract at all
1706
+ if ($this->getid3->option_save_attachments === getID3::ATTACHMENTS_NONE) {
1707
+
1708
+ $attachment = null; // do not set any
1709
+
1710
+ // extract to return array
1711
+ } elseif ($this->getid3->option_save_attachments === getID3::ATTACHMENTS_INLINE) {
1712
+
1713
+ $this->fseek($offset);
1714
+ $attachment = $this->fread($length); // get whole data in one pass, till it is anyway stored in memory
1715
+ if ($attachment === false || strlen($attachment) != $length) {
1716
+ throw new Exception('failed to read attachment data');
1717
+ }
1718
+
1719
+ // assume directory path is given
1720
+ } else {
1721
+
1722
+ // set up destination path
1723
+ $dir = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->getid3->option_save_attachments), DIRECTORY_SEPARATOR);
1724
+ if (!is_dir($dir) || !is_writable($dir)) { // check supplied directory
1725
+ throw new Exception('supplied path ('.$dir.') does not exist, or is not writable');
1726
+ }
1727
+ $dest = $dir.DIRECTORY_SEPARATOR.$name.($image_mime ? '.'.getid3_lib::ImageExtFromMime($image_mime) : '');
1728
+
1729
+ // create dest file
1730
+ if (($fp_dest = fopen($dest, 'wb')) == false) {
1731
+ throw new Exception('failed to create file '.$dest);
1732
+ }
1733
+
1734
+ // copy data
1735
+ $this->fseek($offset);
1736
+ $buffersize = ($this->data_string_flag ? $length : $this->getid3->fread_buffer_size());
1737
+ $bytesleft = $length;
1738
+ while ($bytesleft > 0) {
1739
+ if (($buffer = $this->fread(min($buffersize, $bytesleft))) === false || ($byteswritten = fwrite($fp_dest, $buffer)) === false || ($byteswritten === 0)) {
1740
+ throw new Exception($buffer === false ? 'not enough data to read' : 'failed to write to destination file, may be not enough disk space');
1741
+ }
1742
+ $bytesleft -= $byteswritten;
1743
+ }
1744
+
1745
+ fclose($fp_dest);
1746
+ $attachment = $dest;
1747
+
1748
+ }
1749
+
1750
+ } catch (Exception $e) {
1751
+
1752
+ // close and remove dest file if created
1753
+ if (isset($fp_dest) && is_resource($fp_dest)) {
1754
+ fclose($fp_dest);
1755
+ unlink($dest);
1756
+ }
1757
+
1758
+ // do not set any is case of error
1759
+ $attachment = null;
1760
+ $this->warning('Failed to extract attachment '.$name.': '.$e->getMessage());
1761
+
1762
+ }
1763
+
1764
+ // seek to the end of attachment
1765
+ $this->fseek($offset + $length);
1766
+
1767
+ return $attachment;
1768
+ }
1769
+
1770
+ }
1771
+
1772
+
1773
+ class getid3_exception extends Exception
1774
+ {
1775
+ public $message;
1776
+ }
includes/getid3/module.audio-video.flv.php ADDED
@@ -0,0 +1,729 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /////////////////////////////////////////////////////////////////
3
+ /// getID3() by James Heinrich <info@getid3.org> //
4
+ // available at http://getid3.sourceforge.net //
5
+ // or http://www.getid3.org //
6
+ // //
7
+ // FLV module by Seth Kaufman <seth�whirl-i-gig*com> //
8
+ // //
9
+ // * version 0.1 (26 June 2005) //
10
+ // //
11
+ // //
12
+ // * version 0.1.1 (15 July 2005) //
13
+ // minor modifications by James Heinrich <info@getid3.org> //
14
+ // //
15
+ // * version 0.2 (22 February 2006) //
16
+ // Support for On2 VP6 codec and meta information //
17
+ // by Steve Webster <steve.webster�featurecreep*com> //
18
+ // //
19
+ // * version 0.3 (15 June 2006) //
20
+ // Modified to not read entire file into memory //
21
+ // by James Heinrich <info@getid3.org> //
22
+ // //
23
+ // * version 0.4 (07 December 2007) //
24
+ // Bugfixes for incorrectly parsed FLV dimensions //
25
+ // and incorrect parsing of onMetaTag //
26
+ // by Evgeny Moysevich <moysevich�gmail*com> //
27
+ // //
28
+ // * version 0.5 (21 May 2009) //
29
+ // Fixed parsing of audio tags and added additional codec //
30
+ // details. The duration is now read from onMetaTag (if //
31
+ // exists), rather than parsing whole file //
32
+ // by Nigel Barnes <ngbarnes�hotmail*com> //
33
+ // //
34
+ // * version 0.6 (24 May 2009) //
35
+ // Better parsing of files with h264 video //
36
+ // by Evgeny Moysevich <moysevich�gmail*com> //
37
+ // //
38
+ // * version 0.6.1 (30 May 2011) //
39
+ // prevent infinite loops in expGolombUe() //
40
+ // //
41
+ /////////////////////////////////////////////////////////////////
42
+ // //
43
+ // module.audio-video.flv.php //
44
+ // module for analyzing Shockwave Flash Video files //
45
+ // dependencies: NONE //
46
+ // ///
47
+ /////////////////////////////////////////////////////////////////
48
+
49
+ define('GETID3_FLV_TAG_AUDIO', 8);
50
+ define('GETID3_FLV_TAG_VIDEO', 9);
51
+ define('GETID3_FLV_TAG_META', 18);
52
+
53
+ define('GETID3_FLV_VIDEO_H263', 2);
54
+ define('GETID3_FLV_VIDEO_SCREEN', 3);
55
+ define('GETID3_FLV_VIDEO_VP6FLV', 4);
56
+ define('GETID3_FLV_VIDEO_VP6FLV_ALPHA', 5);
57
+ define('GETID3_FLV_VIDEO_SCREENV2', 6);
58
+ define('GETID3_FLV_VIDEO_H264', 7);
59
+
60
+ define('H264_AVC_SEQUENCE_HEADER', 0);
61
+ define('H264_PROFILE_BASELINE', 66);
62
+ define('H264_PROFILE_MAIN', 77);
63
+ define('H264_PROFILE_EXTENDED', 88);
64
+ define('H264_PROFILE_HIGH', 100);
65
+ define('H264_PROFILE_HIGH10', 110);
66
+ define('H264_PROFILE_HIGH422', 122);
67
+ define('H264_PROFILE_HIGH444', 144);
68
+ define('H264_PROFILE_HIGH444_PREDICTIVE', 244);
69
+
70
+ class getid3_flv extends getid3_handler
71
+ {
72
+ public $max_frames = 100000; // break out of the loop if too many frames have been scanned; only scan this many if meta frame does not contain useful duration
73
+
74
+ public function Analyze() {
75
+ $info = &$this->getid3->info;
76
+
77
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
78
+
79
+ $FLVdataLength = $info['avdataend'] - $info['avdataoffset'];
80
+ $FLVheader = fread($this->getid3->fp, 5);
81
+
82
+ $info['fileformat'] = 'flv';
83
+ $info['flv']['header']['signature'] = substr($FLVheader, 0, 3);
84
+ $info['flv']['header']['version'] = getid3_lib::BigEndian2Int(substr($FLVheader, 3, 1));
85
+ $TypeFlags = getid3_lib::BigEndian2Int(substr($FLVheader, 4, 1));
86
+
87
+ $magic = 'FLV';
88
+ if ($info['flv']['header']['signature'] != $magic) {
89
+ $info['error'][] = 'Expecting "'.getid3_lib::PrintHexBytes($magic).'" at offset '.$info['avdataoffset'].', found "'.getid3_lib::PrintHexBytes($info['flv']['header']['signature']).'"';
90
+ unset($info['flv']);
91
+ unset($info['fileformat']);
92
+ return false;
93
+ }
94
+
95
+ $info['flv']['header']['hasAudio'] = (bool) ($TypeFlags & 0x04);
96
+ $info['flv']['header']['hasVideo'] = (bool) ($TypeFlags & 0x01);
97
+
98
+ $FrameSizeDataLength = getid3_lib::BigEndian2Int(fread($this->getid3->fp, 4));
99
+ $FLVheaderFrameLength = 9;
100
+ if ($FrameSizeDataLength > $FLVheaderFrameLength) {
101
+ fseek($this->getid3->fp, $FrameSizeDataLength - $FLVheaderFrameLength, SEEK_CUR);
102
+ }
103
+ $Duration = 0;
104
+ $found_video = false;
105
+ $found_audio = false;
106
+ $found_meta = false;
107
+ $found_valid_meta_playtime = false;
108
+ $tagParseCount = 0;
109
+ $info['flv']['framecount'] = array('total'=>0, 'audio'=>0, 'video'=>0);
110
+ $flv_framecount = &$info['flv']['framecount'];
111
+ while (((ftell($this->getid3->fp) + 16) < $info['avdataend']) && (($tagParseCount++ <= $this->max_frames) || !$found_valid_meta_playtime)) {
112
+ $ThisTagHeader = fread($this->getid3->fp, 16);
113
+
114
+ $PreviousTagLength = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 0, 4));
115
+ $TagType = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 4, 1));
116
+ $DataLength = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 5, 3));
117
+ $Timestamp = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 8, 3));
118
+ $LastHeaderByte = getid3_lib::BigEndian2Int(substr($ThisTagHeader, 15, 1));
119
+ $NextOffset = ftell($this->getid3->fp) - 1 + $DataLength;
120
+ if ($Timestamp > $Duration) {
121
+ $Duration = $Timestamp;
122
+ }
123
+
124
+ $flv_framecount['total']++;
125
+ switch ($TagType) {
126
+ case GETID3_FLV_TAG_AUDIO:
127
+ $flv_framecount['audio']++;
128
+ if (!$found_audio) {
129
+ $found_audio = true;
130
+ $info['flv']['audio']['audioFormat'] = ($LastHeaderByte >> 4) & 0x0F;
131
+ $info['flv']['audio']['audioRate'] = ($LastHeaderByte >> 2) & 0x03;
132
+ $info['flv']['audio']['audioSampleSize'] = ($LastHeaderByte >> 1) & 0x01;
133
+ $info['flv']['audio']['audioType'] = $LastHeaderByte & 0x01;
134
+ }
135
+ break;
136
+
137
+ case GETID3_FLV_TAG_VIDEO:
138
+ $flv_framecount['video']++;
139
+ if (!$found_video) {
140
+ $found_video = true;
141
+ $info['flv']['video']['videoCodec'] = $LastHeaderByte & 0x07;
142
+
143
+ $FLVvideoHeader = fread($this->getid3->fp, 11);
144
+
145
+ if ($info['flv']['video']['videoCodec'] == GETID3_FLV_VIDEO_H264) {
146
+ // this code block contributed by: moysevich�gmail*com
147
+
148
+ $AVCPacketType = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 0, 1));
149
+ if ($AVCPacketType == H264_AVC_SEQUENCE_HEADER) {
150
+ // read AVCDecoderConfigurationRecord
151
+ $configurationVersion = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 4, 1));
152
+ $AVCProfileIndication = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 1));
153
+ $profile_compatibility = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 1));
154
+ $lengthSizeMinusOne = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 7, 1));
155
+ $numOfSequenceParameterSets = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 8, 1));
156
+
157
+ if (($numOfSequenceParameterSets & 0x1F) != 0) {
158
+ // there is at least one SequenceParameterSet
159
+ // read size of the first SequenceParameterSet
160
+ //$spsSize = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 9, 2));
161
+ $spsSize = getid3_lib::LittleEndian2Int(substr($FLVvideoHeader, 9, 2));
162
+ // read the first SequenceParameterSet
163
+ $sps = fread($this->getid3->fp, $spsSize);
164
+ if (strlen($sps) == $spsSize) { // make sure that whole SequenceParameterSet was red
165
+ $spsReader = new AVCSequenceParameterSetReader($sps);
166
+ $spsReader->readData();
167
+ $info['video']['resolution_x'] = $spsReader->getWidth();
168
+ $info['video']['resolution_y'] = $spsReader->getHeight();
169
+ }
170
+ }
171
+ }
172
+ // end: moysevich�gmail*com
173
+
174
+ } elseif ($info['flv']['video']['videoCodec'] == GETID3_FLV_VIDEO_H263) {
175
+
176
+ $PictureSizeType = (getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 3, 2))) >> 7;
177
+ $PictureSizeType = $PictureSizeType & 0x0007;
178
+ $info['flv']['header']['videoSizeType'] = $PictureSizeType;
179
+ switch ($PictureSizeType) {
180
+ case 0:
181
+ //$PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 2));
182
+ //$PictureSizeEnc <<= 1;
183
+ //$info['video']['resolution_x'] = ($PictureSizeEnc & 0xFF00) >> 8;
184
+ //$PictureSizeEnc = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 2));
185
+ //$PictureSizeEnc <<= 1;
186
+ //$info['video']['resolution_y'] = ($PictureSizeEnc & 0xFF00) >> 8;
187
+
188
+ $PictureSizeEnc['x'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 4, 2));
189
+ $PictureSizeEnc['y'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 5, 2));
190
+ $PictureSizeEnc['x'] >>= 7;
191
+ $PictureSizeEnc['y'] >>= 7;
192
+ $info['video']['resolution_x'] = $PictureSizeEnc['x'] & 0xFF;
193
+ $info['video']['resolution_y'] = $PictureSizeEnc['y'] & 0xFF;
194
+ break;
195
+
196
+ case 1:
197
+ $PictureSizeEnc['x'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 4, 3));
198
+ $PictureSizeEnc['y'] = getid3_lib::BigEndian2Int(substr($FLVvideoHeader, 6, 3));
199
+ $PictureSizeEnc['x'] >>= 7;
200
+ $PictureSizeEnc['y'] >>= 7;
201
+ $info['video']['resolution_x'] = $PictureSizeEnc['x'] & 0xFFFF;
202
+ $info['video']['resolution_y'] = $PictureSizeEnc['y'] & 0xFFFF;
203
+ break;
204
+
205
+ case 2:
206
+ $info['video']['resolution_x'] = 352;
207
+ $info['video']['resolution_y'] = 288;
208
+ break;
209
+
210
+ case 3:
211
+ $info['video']['resolution_x'] = 176;
212
+ $info['video']['resolution_y'] = 144;
213
+ break;
214
+
215
+ case 4:
216
+ $info['video']['resolution_x'] = 128;
217
+ $info['video']['resolution_y'] = 96;
218
+ break;
219
+
220
+ case 5:
221
+ $info['video']['resolution_x'] = 320;
222
+ $info['video']['resolution_y'] = 240;
223
+ break;
224
+
225
+ case 6:
226
+ $info['video']['resolution_x'] = 160;
227
+ $info['video']['resolution_y'] = 120;
228
+ break;
229
+
230
+ default:
231
+ $info['video']['resolution_x'] = 0;
232
+ $info['video']['resolution_y'] = 0;
233
+ break;
234
+
235
+ }
236
+ }
237
+ $info['video']['pixel_aspect_ratio'] = $info['video']['resolution_x'] / $info['video']['resolution_y'];
238
+ }
239
+ break;
240
+
241
+ // Meta tag
242
+ case GETID3_FLV_TAG_META:
243
+ if (!$found_meta) {
244
+ $found_meta = true;
245
+ fseek($this->getid3->fp, -1, SEEK_CUR);
246
+ $datachunk = fread($this->getid3->fp, $DataLength);
247
+ $AMFstream = new AMFStream($datachunk);
248
+ $reader = new AMFReader($AMFstream);
249
+ $eventName = $reader->readData();
250
+ $info['flv']['meta'][$eventName] = $reader->readData();
251
+ unset($reader);
252
+
253
+ $copykeys = array('framerate'=>'frame_rate', 'width'=>'resolution_x', 'height'=>'resolution_y', 'audiodatarate'=>'bitrate', 'videodatarate'=>'bitrate');
254
+ foreach ($copykeys as $sourcekey => $destkey) {
255
+ if (isset($info['flv']['meta']['onMetaData'][$sourcekey])) {
256
+ switch ($sourcekey) {
257
+ case 'width':
258
+ case 'height':
259
+ $info['video'][$destkey] = intval(round($info['flv']['meta']['onMetaData'][$sourcekey]));
260
+ break;
261
+ case 'audiodatarate':
262
+ $info['audio'][$destkey] = getid3_lib::CastAsInt(round($info['flv']['meta']['onMetaData'][$sourcekey] * 1000));
263
+ break;
264
+ case 'videodatarate':
265
+ case 'frame_rate':
266
+ default:
267
+ $info['video'][$destkey] = $info['flv']['meta']['onMetaData'][$sourcekey];
268
+ break;
269
+ }
270
+ }
271
+ }
272
+ if (!empty($info['flv']['meta']['onMetaData']['duration'])) {
273
+ $found_valid_meta_playtime = true;
274
+ }
275
+ }
276
+ break;
277
+
278
+ default:
279
+ // noop
280
+ break;
281
+ }
282
+ fseek($this->getid3->fp, $NextOffset, SEEK_SET);
283
+ }
284
+
285
+ $info['playtime_seconds'] = $Duration / 1000;
286
+ if ($info['playtime_seconds'] > 0) {
287
+ $info['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
288
+ }
289
+
290
+ if ($info['flv']['header']['hasAudio']) {
291
+ $info['audio']['codec'] = $this->FLVaudioFormat($info['flv']['audio']['audioFormat']);
292
+ $info['audio']['sample_rate'] = $this->FLVaudioRate($info['flv']['audio']['audioRate']);
293
+ $info['audio']['bits_per_sample'] = $this->FLVaudioBitDepth($info['flv']['audio']['audioSampleSize']);
294
+
295
+ $info['audio']['channels'] = $info['flv']['audio']['audioType'] + 1; // 0=mono,1=stereo
296
+ $info['audio']['lossless'] = ($info['flv']['audio']['audioFormat'] ? false : true); // 0=uncompressed
297
+ $info['audio']['dataformat'] = 'flv';
298
+ }
299
+ if (!empty($info['flv']['header']['hasVideo'])) {
300
+ $info['video']['codec'] = $this->FLVvideoCodec($info['flv']['video']['videoCodec']);
301
+ $info['video']['dataformat'] = 'flv';
302
+ $info['video']['lossless'] = false;
303
+ }
304
+
305
+ // Set information from meta
306
+ if (!empty($info['flv']['meta']['onMetaData']['duration'])) {
307
+ $info['playtime_seconds'] = $info['flv']['meta']['onMetaData']['duration'];
308
+ $info['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
309
+ }
310
+ if (isset($info['flv']['meta']['onMetaData']['audiocodecid'])) {
311
+ $info['audio']['codec'] = $this->FLVaudioFormat($info['flv']['meta']['onMetaData']['audiocodecid']);
312
+ }
313
+ if (isset($info['flv']['meta']['onMetaData']['videocodecid'])) {
314
+ $info['video']['codec'] = $this->FLVvideoCodec($info['flv']['meta']['onMetaData']['videocodecid']);
315
+ }
316
+ return true;
317
+ }
318
+
319
+
320
+ public function FLVaudioFormat($id) {
321
+ $FLVaudioFormat = array(
322
+ 0 => 'Linear PCM, platform endian',
323
+ 1 => 'ADPCM',
324
+ 2 => 'mp3',
325
+ 3 => 'Linear PCM, little endian',
326
+ 4 => 'Nellymoser 16kHz mono',
327
+ 5 => 'Nellymoser 8kHz mono',
328
+ 6 => 'Nellymoser',
329
+ 7 => 'G.711A-law logarithmic PCM',
330
+ 8 => 'G.711 mu-law logarithmic PCM',
331
+ 9 => 'reserved',
332
+ 10 => 'AAC',
333
+ 11 => false, // unknown?
334
+ 12 => false, // unknown?
335
+ 13 => false, // unknown?
336
+ 14 => 'mp3 8kHz',
337
+ 15 => 'Device-specific sound',
338
+ );
339
+ return (isset($FLVaudioFormat[$id]) ? $FLVaudioFormat[$id] : false);
340
+ }
341
+
342
+ public function FLVaudioRate($id) {
343
+ $FLVaudioRate = array(
344
+ 0 => 5500,
345
+ 1 => 11025,
346
+ 2 => 22050,
347
+ 3 => 44100,
348
+ );
349
+ return (isset($FLVaudioRate[$id]) ? $FLVaudioRate[$id] : false);
350
+ }
351
+
352
+ public function FLVaudioBitDepth($id) {
353
+ $FLVaudioBitDepth = array(
354
+ 0 => 8,
355
+ 1 => 16,
356
+ );
357
+ return (isset($FLVaudioBitDepth[$id]) ? $FLVaudioBitDepth[$id] : false);
358
+ }
359
+
360
+ public function FLVvideoCodec($id) {
361
+ $FLVvideoCodec = array(
362
+ GETID3_FLV_VIDEO_H263 => 'Sorenson H.263',
363
+ GETID3_FLV_VIDEO_SCREEN => 'Screen video',
364
+ GETID3_FLV_VIDEO_VP6FLV => 'On2 VP6',
365
+ GETID3_FLV_VIDEO_VP6FLV_ALPHA => 'On2 VP6 with alpha channel',
366
+ GETID3_FLV_VIDEO_SCREENV2 => 'Screen video v2',
367
+ GETID3_FLV_VIDEO_H264 => 'Sorenson H.264',
368
+ );
369
+ return (isset($FLVvideoCodec[$id]) ? $FLVvideoCodec[$id] : false);
370
+ }
371
+ }
372
+
373
+ class AMFStream {
374
+ public $bytes;
375
+ public $pos;
376
+
377
+ public function AMFStream(&$bytes) {
378
+ $this->bytes =& $bytes;
379
+ $this->pos = 0;
380
+ }
381
+
382
+ public function readByte() {
383
+ return getid3_lib::BigEndian2Int(substr($this->bytes, $this->pos++, 1));
384
+ }
385
+
386
+ public function readInt() {
387
+ return ($this->readByte() << 8) + $this->readByte();
388
+ }
389
+
390
+ public function readLong() {
391
+ return ($this->readByte() << 24) + ($this->readByte() << 16) + ($this->readByte() << 8) + $this->readByte();
392
+ }
393
+
394
+ public function readDouble() {
395
+ return getid3_lib::BigEndian2Float($this->read(8));
396
+ }
397
+
398
+ public function readUTF() {
399
+ $length = $this->readInt();
400
+ return $this->read($length);
401
+ }
402
+
403
+ public function readLongUTF() {
404
+ $length = $this->readLong();
405
+ return $this->read($length);
406
+ }
407
+
408
+ public function read($length) {
409
+ $val = substr($this->bytes, $this->pos, $length);
410
+ $this->pos += $length;
411
+ return $val;
412
+ }
413
+
414
+ public function peekByte() {
415
+ $pos = $this->pos;
416
+ $val = $this->readByte();
417
+ $this->pos = $pos;
418
+ return $val;
419
+ }
420
+
421
+ public function peekInt() {
422
+ $pos = $this->pos;
423
+ $val = $this->readInt();
424
+ $this->pos = $pos;
425
+ return $val;
426
+ }
427
+
428
+ public function peekLong() {
429
+ $pos = $this->pos;
430
+ $val = $this->readLong();
431
+ $this->pos = $pos;
432
+ return $val;
433
+ }
434
+
435
+ public function peekDouble() {
436
+ $pos = $this->pos;
437
+ $val = $this->readDouble();
438
+ $this->pos = $pos;
439
+ return $val;
440
+ }
441
+
442
+ public function peekUTF() {
443
+ $pos = $this->pos;
444
+ $val = $this->readUTF();
445
+ $this->pos = $pos;
446
+ return $val;
447
+ }
448
+
449
+ public function peekLongUTF() {
450
+ $pos = $this->pos;
451
+ $val = $this->readLongUTF();
452
+ $this->pos = $pos;
453
+ return $val;
454
+ }
455
+ }
456
+
457
+ class AMFReader {
458
+ public $stream;
459
+
460
+ public function AMFReader(&$stream) {
461
+ $this->stream =& $stream;
462
+ }
463
+
464
+ public function readData() {
465
+ $value = null;
466
+
467
+ $type = $this->stream->readByte();
468
+ switch ($type) {
469
+
470
+ // Double
471
+ case 0:
472
+ $value = $this->readDouble();
473
+ break;
474
+
475
+ // Boolean
476
+ case 1:
477
+ $value = $this->readBoolean();
478
+ break;
479
+
480
+ // String
481
+ case 2:
482
+ $value = $this->readString();
483
+ break;
484
+
485
+ // Object
486
+ case 3:
487
+ $value = $this->readObject();
488
+ break;
489
+
490
+ // null
491
+ case 6:
492
+ return null;
493
+ break;
494
+
495
+ // Mixed array
496
+ case 8:
497
+ $value = $this->readMixedArray();
498
+ break;
499
+
500
+ // Array
501
+ case 10:
502
+ $value = $this->readArray();
503
+ break;
504
+
505
+ // Date
506
+ case 11:
507
+ $value = $this->readDate();
508
+ break;
509
+
510
+ // Long string
511
+ case 13:
512
+ $value = $this->readLongString();
513
+ break;
514
+
515
+ // XML (handled as string)
516
+ case 15:
517
+ $value = $this->readXML();
518
+ break;
519
+
520
+ // Typed object (handled as object)
521
+ case 16:
522
+ $value = $this->readTypedObject();
523
+ break;
524
+
525
+ // Long string
526
+ default:
527
+ $value = '(unknown or unsupported data type)';
528
+ break;
529
+ }
530
+
531
+ return $value;
532
+ }
533
+
534
+ public function readDouble() {
535
+ return $this->stream->readDouble();
536
+ }
537
+
538
+ public function readBoolean() {
539
+ return $this->stream->readByte() == 1;
540
+ }
541
+
542
+ public function readString() {
543
+ return $this->stream->readUTF();
544
+ }
545
+
546
+ public function readObject() {
547
+ // Get highest numerical index - ignored
548
+ // $highestIndex = $this->stream->readLong();
549
+
550
+ $data = array();
551
+
552
+ while ($key = $this->stream->readUTF()) {
553
+ $data[$key] = $this->readData();
554
+ }
555
+ // Mixed array record ends with empty string (0x00 0x00) and 0x09
556
+ if (($key == '') && ($this->stream->peekByte() == 0x09)) {
557
+ // Consume byte
558
+ $this->stream->readByte();
559
+ }
560
+ return $data;
561
+ }
562
+
563
+ public function readMixedArray() {
564
+ // Get highest numerical index - ignored
565
+ $highestIndex = $this->stream->readLong();
566
+
567
+ $data = array();
568
+
569
+ while ($key = $this->stream->readUTF()) {
570
+ if (is_numeric($key)) {
571
+ $key = (float) $key;
572
+ }
573
+ $data[$key] = $this->readData();
574
+ }
575
+ // Mixed array record ends with empty string (0x00 0x00) and 0x09
576
+ if (($key == '') && ($this->stream->peekByte() == 0x09)) {
577
+ // Consume byte
578
+ $this->stream->readByte();
579
+ }
580
+
581
+ return $data;
582
+ }
583
+
584
+ public function readArray() {
585
+ $length = $this->stream->readLong();
586
+ $data = array();
587
+
588
+ for ($i = 0; $i < $length; $i++) {
589
+ $data[] = $this->readData();
590
+ }
591
+ return $data;
592
+ }
593
+
594
+ public function readDate() {
595
+ $timestamp = $this->stream->readDouble();
596
+ $timezone = $this->stream->readInt();
597
+ return $timestamp;
598
+ }
599
+
600
+ public function readLongString() {
601
+ return $this->stream->readLongUTF();
602
+ }
603
+
604
+ public function readXML() {
605
+ return $this->stream->readLongUTF();
606
+ }
607
+
608
+ public function readTypedObject() {
609
+ $className = $this->stream->readUTF();
610
+ return $this->readObject();
611
+ }
612
+ }
613
+
614
+ class AVCSequenceParameterSetReader {
615
+ public $sps;
616
+ public $start = 0;
617
+ public $currentBytes = 0;
618
+ public $currentBits = 0;
619
+ public $width;
620
+ public $height;
621
+
622
+ public function AVCSequenceParameterSetReader($sps) {
623
+ $this->sps = $sps;
624
+ }
625
+
626
+ public function readData() {
627
+ $this->skipBits(8);
628
+ $this->skipBits(8);
629
+ $profile = $this->getBits(8); // read profile
630
+ $this->skipBits(16);
631
+ $this->expGolombUe(); // read sps id
632
+ if (in_array($profile, array(H264_PROFILE_HIGH, H264_PROFILE_HIGH10, H264_PROFILE_HIGH422, H264_PROFILE_HIGH444, H264_PROFILE_HIGH444_PREDICTIVE))) {
633
+ if ($this->expGolombUe() == 3) {
634
+ $this->skipBits(1);
635
+ }
636
+ $this->expGolombUe();
637
+ $this->expGolombUe();
638
+ $this->skipBits(1);
639
+ if ($this->getBit()) {
640
+ for ($i = 0; $i < 8; $i++) {
641
+ if ($this->getBit()) {
642
+ $size = $i < 6 ? 16 : 64;
643
+ $lastScale = 8;
644
+ $nextScale = 8;
645
+ for ($j = 0; $j < $size; $j++) {
646
+ if ($nextScale != 0) {
647
+ $deltaScale = $this->expGolombUe();
648
+ $nextScale = ($lastScale + $deltaScale + 256) % 256;
649
+ }
650
+ if ($nextScale != 0) {
651
+ $lastScale = $nextScale;
652
+ }
653
+ }
654
+ }
655
+ }
656
+ }
657
+ }
658
+ $this->expGolombUe();
659
+ $pocType = $this->expGolombUe();
660
+ if ($pocType == 0) {
661
+ $this->expGolombUe();
662
+ } elseif ($pocType == 1) {
663
+ $this->skipBits(1);
664
+ $this->expGolombSe();
665
+ $this->expGolombSe();
666
+ $pocCycleLength = $this->expGolombUe();
667
+ for ($i = 0; $i < $pocCycleLength; $i++) {
668
+ $this->expGolombSe();
669
+ }
670
+ }
671
+ $this->expGolombUe();
672
+ $this->skipBits(1);
673
+ $this->width = ($this->expGolombUe() + 1) * 16;
674
+ $heightMap = $this->expGolombUe() + 1;
675
+ $this->height = (2 - $this->getBit()) * $heightMap * 16;
676
+ }
677
+
678
+ public function skipBits($bits) {
679
+ $newBits = $this->currentBits + $bits;
680
+ $this->currentBytes += (int)floor($newBits / 8);
681
+ $this->currentBits = $newBits % 8;
682
+ }
683
+
684
+ public function getBit() {
685
+ $result = (getid3_lib::BigEndian2Int(substr($this->sps, $this->currentBytes, 1)) >> (7 - $this->currentBits)) & 0x01;
686
+ $this->skipBits(1);
687
+ return $result;
688
+ }
689
+
690
+ public function getBits($bits) {
691
+ $result = 0;
692
+ for ($i = 0; $i < $bits; $i++) {
693
+ $result = ($result << 1) + $this->getBit();
694
+ }
695
+ return $result;
696
+ }
697
+
698
+ public function expGolombUe() {
699
+ $significantBits = 0;
700
+ $bit = $this->getBit();
701
+ while ($bit == 0) {
702
+ $significantBits++;
703
+ $bit = $this->getBit();
704
+
705
+ if ($significantBits > 31) {
706
+ // something is broken, this is an emergency escape to prevent infinite loops
707
+ return 0;
708
+ }
709
+ }
710
+ return (1 << $significantBits) + $this->getBits($significantBits) - 1;
711
+ }
712
+
713
+ public function expGolombSe() {
714
+ $result = $this->expGolombUe();
715
+ if (($result & 0x01) == 0) {
716
+ return -($result >> 1);
717
+ } else {
718
+ return ($result + 1) >> 1;
719
+ }
720
+ }
721
+
722
+ public function getWidth() {
723
+ return $this->width;
724
+ }
725
+
726
+ public function getHeight() {
727
+ return $this->height;
728
+ }
729
+ }
{view → includes}/getid3/module.audio-video.matroska.php RENAMED
@@ -1,1712 +1,1771 @@
1
- <?php
2
- /////////////////////////////////////////////////////////////////
3
- /// getID3() by James Heinrich <info@getid3.org> //
4
- // available at http://getid3.sourceforge.net //
5
- // or http://www.getid3.org //
6
- /////////////////////////////////////////////////////////////////
7
- // See readme.txt for more details //
8
- /////////////////////////////////////////////////////////////////
9
- // //
10
- // module.audio-video.matriska.php //
11
- // module for analyzing Matroska containers //
12
- // dependencies: NONE //
13
- // ///
14
- /////////////////////////////////////////////////////////////////
15
-
16
-
17
- define('EBML_ID_CHAPTERS', 0x0043A770); // [10][43][A7][70] -- A system to define basic menus and partition data. For more detailed information, look at the Chapters Explanation.
18
- define('EBML_ID_SEEKHEAD', 0x014D9B74); // [11][4D][9B][74] -- Contains the position of other level 1 elements.
19
- define('EBML_ID_TAGS', 0x0254C367); // [12][54][C3][67] -- Element containing elements specific to Tracks/Chapters. A list of valid tags can be found here.
20
- define('EBML_ID_INFO', 0x0549A966); // [15][49][A9][66] -- Contains miscellaneous general information and statistics on the file.
21
- define('EBML_ID_TRACKS', 0x0654AE6B); // [16][54][AE][6B] -- A top-level block of information with many tracks described.
22
- define('EBML_ID_SEGMENT', 0x08538067); // [18][53][80][67] -- This element contains all other top-level (level 1) elements. Typically a Matroska file is composed of 1 segment.
23
- define('EBML_ID_ATTACHMENTS', 0x0941A469); // [19][41][A4][69] -- Contain attached files.
24
- define('EBML_ID_EBML', 0x0A45DFA3); // [1A][45][DF][A3] -- Set the EBML characteristics of the data to follow. Each EBML document has to start with this.
25
- define('EBML_ID_CUES', 0x0C53BB6B); // [1C][53][BB][6B] -- A top-level element to speed seeking access. All entries are local to the segment.
26
- define('EBML_ID_CLUSTER', 0x0F43B675); // [1F][43][B6][75] -- The lower level element containing the (monolithic) Block structure.
27
- define('EBML_ID_LANGUAGE', 0x02B59C); // [22][B5][9C] -- Specifies the language of the track in the Matroska languages form.
28
- define('EBML_ID_TRACKTIMECODESCALE', 0x03314F); // [23][31][4F] -- The scale to apply on this track to work at normal speed in relation with other tracks (mostly used to adjust video speed when the audio length differs).
29
- define('EBML_ID_DEFAULTDURATION', 0x03E383); // [23][E3][83] -- Number of nanoseconds (i.e. not scaled) per frame.
30
- define('EBML_ID_CODECNAME', 0x058688); // [25][86][88] -- A human-readable string specifying the codec.
31
- define('EBML_ID_CODECDOWNLOADURL', 0x06B240); // [26][B2][40] -- A URL to download about the codec used.
32
- define('EBML_ID_TIMECODESCALE', 0x0AD7B1); // [2A][D7][B1] -- Timecode scale in nanoseconds (1.000.000 means all timecodes in the segment are expressed in milliseconds).
33
- define('EBML_ID_COLOURSPACE', 0x0EB524); // [2E][B5][24] -- Same value as in AVI (32 bits).
34
- define('EBML_ID_GAMMAVALUE', 0x0FB523); // [2F][B5][23] -- Gamma Value.
35
- define('EBML_ID_CODECSETTINGS', 0x1A9697); // [3A][96][97] -- A string describing the encoding setting used.
36
- define('EBML_ID_CODECINFOURL', 0x1B4040); // [3B][40][40] -- A URL to find information about the codec used.
37
- define('EBML_ID_PREVFILENAME', 0x1C83AB); // [3C][83][AB] -- An escaped filename corresponding to the previous segment.
38
- define('EBML_ID_PREVUID', 0x1CB923); // [3C][B9][23] -- A unique ID to identify the previous chained segment (128 bits).
39
- define('EBML_ID_NEXTFILENAME', 0x1E83BB); // [3E][83][BB] -- An escaped filename corresponding to the next segment.
40
- define('EBML_ID_NEXTUID', 0x1EB923); // [3E][B9][23] -- A unique ID to identify the next chained segment (128 bits).
41
- define('EBML_ID_CONTENTCOMPALGO', 0x0254); // [42][54] -- The compression algorithm used. Algorithms that have been specified so far are:
42
- define('EBML_ID_CONTENTCOMPSETTINGS', 0x0255); // [42][55] -- Settings that might be needed by the decompressor. For Header Stripping (ContentCompAlgo=3), the bytes that were removed from the beggining of each frames of the track.
43
- define('EBML_ID_DOCTYPE', 0x0282); // [42][82] -- A string that describes the type of document that follows this EBML header ('matroska' in our case).
44
- define('EBML_ID_DOCTYPEREADVERSION', 0x0285); // [42][85] -- The minimum DocType version an interpreter has to support to read this file.
45
- define('EBML_ID_EBMLVERSION', 0x0286); // [42][86] -- The version of EBML parser used to create the file.
46
- define('EBML_ID_DOCTYPEVERSION', 0x0287); // [42][87] -- The version of DocType interpreter used to create the file.
47
- define('EBML_ID_EBMLMAXIDLENGTH', 0x02F2); // [42][F2] -- The maximum length of the IDs you'll find in this file (4 or less in Matroska).
48
- define('EBML_ID_EBMLMAXSIZELENGTH', 0x02F3); // [42][F3] -- The maximum length of the sizes you'll find in this file (8 or less in Matroska). This does not override the element size indicated at the beginning of an element. Elements that have an indicated size which is larger than what is allowed by EBMLMaxSizeLength shall be considered invalid.
49
- define('EBML_ID_EBMLREADVERSION', 0x02F7); // [42][F7] -- The minimum EBML version a parser has to support to read this file.
50
- define('EBML_ID_CHAPLANGUAGE', 0x037C); // [43][7C] -- The languages corresponding to the string, in the bibliographic ISO-639-2 form.
51
- define('EBML_ID_CHAPCOUNTRY', 0x037E); // [43][7E] -- The countries corresponding to the string, same 2 octets as in Internet domains.
52
- define('EBML_ID_SEGMENTFAMILY', 0x0444); // [44][44] -- A randomly generated unique ID that all segments related to each other must use (128 bits).
53
- define('EBML_ID_DATEUTC', 0x0461); // [44][61] -- Date of the origin of timecode (value 0), i.e. production date.
54
- define('EBML_ID_TAGLANGUAGE', 0x047A); // [44][7A] -- Specifies the language of the tag specified, in the Matroska languages form.
55
- define('EBML_ID_TAGDEFAULT', 0x0484); // [44][84] -- Indication to know if this is the default/original language to use for the given tag.
56
- define('EBML_ID_TAGBINARY', 0x0485); // [44][85] -- The values of the Tag if it is binary. Note that this cannot be used in the same SimpleTag as TagString.
57
- define('EBML_ID_TAGSTRING', 0x0487); // [44][87] -- The value of the Tag.
58
- define('EBML_ID_DURATION', 0x0489); // [44][89] -- Duration of the segment (based on TimecodeScale).
59
- define('EBML_ID_CHAPPROCESSPRIVATE', 0x050D); // [45][0D] -- Some optional data attached to the ChapProcessCodecID information. For ChapProcessCodecID = 1, it is the "DVD level" equivalent.
60
- define('EBML_ID_CHAPTERFLAGENABLED', 0x0598); // [45][98] -- Specify wether the chapter is enabled. It can be enabled/disabled by a Control Track. When disabled, the movie should skip all the content between the TimeStart and TimeEnd of this chapter.
61
- define('EBML_ID_TAGNAME', 0x05A3); // [45][A3] -- The name of the Tag that is going to be stored.
62
- define('EBML_ID_EDITIONENTRY', 0x05B9); // [45][B9] -- Contains all information about a segment edition.
63
- define('EBML_ID_EDITIONUID', 0x05BC); // [45][BC] -- A unique ID to identify the edition. It's useful for tagging an edition.
64
- define('EBML_ID_EDITIONFLAGHIDDEN', 0x05BD); // [45][BD] -- If an edition is hidden (1), it should not be available to the user interface (but still to Control Tracks).
65
- define('EBML_ID_EDITIONFLAGDEFAULT', 0x05DB); // [45][DB] -- If a flag is set (1) the edition should be used as the default one.
66
- define('EBML_ID_EDITIONFLAGORDERED', 0x05DD); // [45][DD] -- Specify if the chapters can be defined multiple times and the order to play them is enforced.
67
- define('EBML_ID_FILEDATA', 0x065C); // [46][5C] -- The data of the file.
68
- define('EBML_ID_FILEMIMETYPE', 0x0660); // [46][60] -- MIME type of the file.
69
- define('EBML_ID_FILENAME', 0x066E); // [46][6E] -- Filename of the attached file.
70
- define('EBML_ID_FILEREFERRAL', 0x0675); // [46][75] -- A binary value that a track/codec can refer to when the attachment is needed.
71
- define('EBML_ID_FILEDESCRIPTION', 0x067E); // [46][7E] -- A human-friendly name for the attached file.
72
- define('EBML_ID_FILEUID', 0x06AE); // [46][AE] -- Unique ID representing the file, as random as possible.
73
- define('EBML_ID_CONTENTENCALGO', 0x07E1); // [47][E1] -- The encryption algorithm used. The value '0' means that the contents have not been encrypted but only signed. Predefined values:
74
- define('EBML_ID_CONTENTENCKEYID', 0x07E2); // [47][E2] -- For public key algorithms this is the ID of the public key the the data was encrypted with.
75
- define('EBML_ID_CONTENTSIGNATURE', 0x07E3); // [47][E3] -- A cryptographic signature of the contents.
76
- define('EBML_ID_CONTENTSIGKEYID', 0x07E4); // [47][E4] -- This is the ID of the private key the data was signed with.
77
- define('EBML_ID_CONTENTSIGALGO', 0x07E5); // [47][E5] -- The algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values:
78
- define('EBML_ID_CONTENTSIGHASHALGO', 0x07E6); // [47][E6] -- The hash algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values:
79
- define('EBML_ID_MUXINGAPP', 0x0D80); // [4D][80] -- Muxing application or library ("libmatroska-0.4.3").
80
- define('EBML_ID_SEEK', 0x0DBB); // [4D][BB] -- Contains a single seek entry to an EBML element.
81
- define('EBML_ID_CONTENTENCODINGORDER', 0x1031); // [50][31] -- Tells when this modification was used during encoding/muxing starting with 0 and counting upwards. The decoder/demuxer has to start with the highest order number it finds and work its way down. This value has to be unique over all ContentEncodingOrder elements in the segment.
82
- define('EBML_ID_CONTENTENCODINGSCOPE', 0x1032); // [50][32] -- A bit field that describes which elements have been modified in this way. Values (big endian) can be OR'ed. Possible values:
83
- define('EBML_ID_CONTENTENCODINGTYPE', 0x1033); // [50][33] -- A value describing what kind of transformation has been done. Possible values:
84
- define('EBML_ID_CONTENTCOMPRESSION', 0x1034); // [50][34] -- Settings describing the compression used. Must be present if the value of ContentEncodingType is 0 and absent otherwise. Each block must be decompressable even if no previous block is available in order not to prevent seeking.
85
- define('EBML_ID_CONTENTENCRYPTION', 0x1035); // [50][35] -- Settings describing the encryption used. Must be present if the value of ContentEncodingType is 1 and absent otherwise.
86
- define('EBML_ID_CUEREFNUMBER', 0x135F); // [53][5F] -- Number of the referenced Block of Track X in the specified Cluster.
87
- define('EBML_ID_NAME', 0x136E); // [53][6E] -- A human-readable track name.
88
- define('EBML_ID_CUEBLOCKNUMBER', 0x1378); // [53][78] -- Number of the Block in the specified Cluster.
89
- define('EBML_ID_TRACKOFFSET', 0x137F); // [53][7F] -- A value to add to the Block's Timecode. This can be used to adjust the playback offset of a track.
90
- define('EBML_ID_SEEKID', 0x13AB); // [53][AB] -- The binary ID corresponding to the element name.
91
- define('EBML_ID_SEEKPOSITION', 0x13AC); // [53][AC] -- The position of the element in the segment in octets (0 = first level 1 element).
92
- define('EBML_ID_STEREOMODE', 0x13B8); // [53][B8] -- Stereo-3D video mode on 2 bits (0: mono, 1: right eye, 2: left eye, 3: both eyes).
93
- define('EBML_ID_PIXELCROPBOTTOM', 0x14AA); // [54][AA] -- The number of video pixels to remove at the bottom of the image (for HDTV content).
94
- define('EBML_ID_DISPLAYWIDTH', 0x14B0); // [54][B0] -- Width of the video frames to display.
95
- define('EBML_ID_DISPLAYUNIT', 0x14B2); // [54][B2] -- Type of the unit for DisplayWidth/Height (0: pixels, 1: centimeters, 2: inches).
96
- define('EBML_ID_ASPECTRATIOTYPE', 0x14B3); // [54][B3] -- Specify the possible modifications to the aspect ratio (0: free resizing, 1: keep aspect ratio, 2: fixed).
97
- define('EBML_ID_DISPLAYHEIGHT', 0x14BA); // [54][BA] -- Height of the video frames to display.
98
- define('EBML_ID_PIXELCROPTOP', 0x14BB); // [54][BB] -- The number of video pixels to remove at the top of the image.
99
- define('EBML_ID_PIXELCROPLEFT', 0x14CC); // [54][CC] -- The number of video pixels to remove on the left of the image.
100
- define('EBML_ID_PIXELCROPRIGHT', 0x14DD); // [54][DD] -- The number of video pixels to remove on the right of the image.
101
- define('EBML_ID_FLAGFORCED', 0x15AA); // [55][AA] -- Set if that track MUST be used during playback. There can be many forced track for a kind (audio, video or subs), the player should select the one which language matches the user preference or the default + forced track. Overlay MAY happen between a forced and non-forced track of the same kind.
102
- define('EBML_ID_MAXBLOCKADDITIONID', 0x15EE); // [55][EE] -- The maximum value of BlockAddID. A value 0 means there is no BlockAdditions for this track.
103
- define('EBML_ID_WRITINGAPP', 0x1741); // [57][41] -- Writing application ("mkvmerge-0.3.3").
104
- define('EBML_ID_CLUSTERSILENTTRACKS', 0x1854); // [58][54] -- The list of tracks that are not used in that part of the stream. It is useful when using overlay tracks on seeking. Then you should decide what track to use.
105
- define('EBML_ID_CLUSTERSILENTTRACKNUMBER', 0x18D7); // [58][D7] -- One of the track number that are not used from now on in the stream. It could change later if not specified as silent in a further Cluster.
106
- define('EBML_ID_ATTACHEDFILE', 0x21A7); // [61][A7] -- An attached file.
107
- define('EBML_ID_CONTENTENCODING', 0x2240); // [62][40] -- Settings for one content encoding like compression or encryption.
108
- define('EBML_ID_BITDEPTH', 0x2264); // [62][64] -- Bits per sample, mostly used for PCM.
109
- define('EBML_ID_CODECPRIVATE', 0x23A2); // [63][A2] -- Private data only known to the codec.
110
- define('EBML_ID_TARGETS', 0x23C0); // [63][C0] -- Contain all UIDs where the specified meta data apply. It is void to describe everything in the segment.
111
- define('EBML_ID_CHAPTERPHYSICALEQUIV', 0x23C3); // [63][C3] -- Specify the physical equivalent of this ChapterAtom like "DVD" (60) or "SIDE" (50), see complete list of values.
112
- define('EBML_ID_TAGCHAPTERUID', 0x23C4); // [63][C4] -- A unique ID to identify the Chapter(s) the tags belong to. If the value is 0 at this level, the tags apply to all chapters in the Segment.
113
- define('EBML_ID_TAGTRACKUID', 0x23C5); // [63][C5] -- A unique ID to identify the Track(s) the tags belong to. If the value is 0 at this level, the tags apply to all tracks in the Segment.
114
- define('EBML_ID_ATTACHMENTUID', 0x23C6); // [63][C6] -- A unique ID to identify the Attachment(s) the tags belong to. If the value is 0 at this level, the tags apply to all the attachments in the Segment.
115
- define('EBML_ID_TAGEDITIONUID', 0x23C9); // [63][C9] -- A unique ID to identify the EditionEntry(s) the tags belong to. If the value is 0 at this level, the tags apply to all editions in the Segment.
116
- define('EBML_ID_TARGETTYPE', 0x23CA); // [63][CA] -- An informational string that can be used to display the logical level of the target like "ALBUM", "TRACK", "MOVIE", "CHAPTER", etc (see TargetType).
117
- define('EBML_ID_TRACKTRANSLATE', 0x2624); // [66][24] -- The track identification for the given Chapter Codec.
118
- define('EBML_ID_TRACKTRANSLATETRACKID', 0x26A5); // [66][A5] -- The binary value used to represent this track in the chapter codec data. The format depends on the ChapProcessCodecID used.
119
- define('EBML_ID_TRACKTRANSLATECODEC', 0x26BF); // [66][BF] -- The chapter codec using this ID (0: Matroska Script, 1: DVD-menu).
120
- define('EBML_ID_TRACKTRANSLATEEDITIONUID', 0x26FC); // [66][FC] -- Specify an edition UID on which this translation applies. When not specified, it means for all editions found in the segment.
121
- define('EBML_ID_SIMPLETAG', 0x27C8); // [67][C8] -- Contains general information about the target.
122
- define('EBML_ID_TARGETTYPEVALUE', 0x28CA); // [68][CA] -- A number to indicate the logical level of the target (see TargetType).
123
- define('EBML_ID_CHAPPROCESSCOMMAND', 0x2911); // [69][11] -- Contains all the commands associated to the Atom.
124
- define('EBML_ID_CHAPPROCESSTIME', 0x2922); // [69][22] -- Defines when the process command should be handled (0: during the whole chapter, 1: before starting playback, 2: after playback of the chapter).
125
- define('EBML_ID_CHAPTERTRANSLATE', 0x2924); // [69][24] -- A tuple of corresponding ID used by chapter codecs to represent this segment.
126
- define('EBML_ID_CHAPPROCESSDATA', 0x2933); // [69][33] -- Contains the command information. The data should be interpreted depending on the ChapProcessCodecID value. For ChapProcessCodecID = 1, the data correspond to the binary DVD cell pre/post commands.
127
- define('EBML_ID_CHAPPROCESS', 0x2944); // [69][44] -- Contains all the commands associated to the Atom.
128
- define('EBML_ID_CHAPPROCESSCODECID', 0x2955); // [69][55] -- Contains the type of the codec used for the processing. A value of 0 means native Matroska processing (to be defined), a value of 1 means the DVD command set is used. More codec IDs can be added later.
129
- define('EBML_ID_CHAPTERTRANSLATEID', 0x29A5); // [69][A5] -- The binary value used to represent this segment in the chapter codec data. The format depends on the ChapProcessCodecID used.
130
- define('EBML_ID_CHAPTERTRANSLATECODEC', 0x29BF); // [69][BF] -- The chapter codec using this ID (0: Matroska Script, 1: DVD-menu).
131
- define('EBML_ID_CHAPTERTRANSLATEEDITIONUID', 0x29FC); // [69][FC] -- Specify an edition UID on which this correspondance applies. When not specified, it means for all editions found in the segment.
132
- define('EBML_ID_CONTENTENCODINGS', 0x2D80); // [6D][80] -- Settings for several content encoding mechanisms like compression or encryption.
133
- define('EBML_ID_MINCACHE', 0x2DE7); // [6D][E7] -- The minimum number of frames a player should be able to cache during playback. If set to 0, the reference pseudo-cache system is not used.
134
- define('EBML_ID_MAXCACHE', 0x2DF8); // [6D][F8] -- The maximum cache size required to store referenced frames in and the current frame. 0 means no cache is needed.
135
- define('EBML_ID_CHAPTERSEGMENTUID', 0x2E67); // [6E][67] -- A segment to play in place of this chapter. Edition ChapterSegmentEditionUID should be used for this segment, otherwise no edition is used.
136
- define('EBML_ID_CHAPTERSEGMENTEDITIONUID', 0x2EBC); // [6E][BC] -- The edition to play from the segment linked in ChapterSegmentUID.
137
- define('EBML_ID_TRACKOVERLAY', 0x2FAB); // [6F][AB] -- Specify that this track is an overlay track for the Track specified (in the u-integer). That means when this track has a gap (see SilentTracks) the overlay track should be used instead. The order of multiple TrackOverlay matters, the first one is the one that should be used. If not found it should be the second, etc.
138
- define('EBML_ID_TAG', 0x3373); // [73][73] -- Element containing elements specific to Tracks/Chapters.
139
- define('EBML_ID_SEGMENTFILENAME', 0x3384); // [73][84] -- A filename corresponding to this segment.
140
- define('EBML_ID_SEGMENTUID', 0x33A4); // [73][A4] -- A randomly generated unique ID to identify the current segment between many others (128 bits).
141
- define('EBML_ID_CHAPTERUID', 0x33C4); // [73][C4] -- A unique ID to identify the Chapter.
142
- define('EBML_ID_TRACKUID', 0x33C5); // [73][C5] -- A unique ID to identify the Track. This should be kept the same when making a direct stream copy of the Track to another file.
143
- define('EBML_ID_ATTACHMENTLINK', 0x3446); // [74][46] -- The UID of an attachment that is used by this codec.
144
- define('EBML_ID_CLUSTERBLOCKADDITIONS', 0x35A1); // [75][A1] -- Contain additional blocks to complete the main one. An EBML parser that has no knowledge of the Block structure could still see and use/skip these data.
145
- define('EBML_ID_CHANNELPOSITIONS', 0x347B); // [7D][7B] -- Table of horizontal angles for each successive channel, see appendix.
146
- define('EBML_ID_OUTPUTSAMPLINGFREQUENCY', 0x38B5); // [78][B5] -- Real output sampling frequency in Hz (used for SBR techniques).
147
- define('EBML_ID_TITLE', 0x3BA9); // [7B][A9] -- General name of the segment.
148
- define('EBML_ID_CHAPTERDISPLAY', 0x00); // [80] -- Contains all possible strings to use for the chapter display.
149
- define('EBML_ID_TRACKTYPE', 0x03); // [83] -- A set of track types coded on 8 bits (1: video, 2: audio, 3: complex, 0x10: logo, 0x11: subtitle, 0x12: buttons, 0x20: control).
150
- define('EBML_ID_CHAPSTRING', 0x05); // [85] -- Contains the string to use as the chapter atom.
151
- define('EBML_ID_CODECID', 0x06); // [86] -- An ID corresponding to the codec, see the codec page for more info.
152
- define('EBML_ID_FLAGDEFAULT', 0x08); // [88] -- Set if that track (audio, video or subs) SHOULD be used if no language found matches the user preference.
153
- define('EBML_ID_CHAPTERTRACKNUMBER', 0x09); // [89] -- UID of the Track to apply this chapter too. In the absense of a control track, choosing this chapter will select the listed Tracks and deselect unlisted tracks. Absense of this element indicates that the Chapter should be applied to any currently used Tracks.
154
- define('EBML_ID_CLUSTERSLICES', 0x0E); // [8E] -- Contains slices description.
155
- define('EBML_ID_CHAPTERTRACK', 0x0F); // [8F] -- List of tracks on which the chapter applies. If this element is not present, all tracks apply
156
- define('EBML_ID_CHAPTERTIMESTART', 0x11); // [91] -- Timecode of the start of Chapter (not scaled).
157
- define('EBML_ID_CHAPTERTIMEEND', 0x12); // [92] -- Timecode of the end of Chapter (timecode excluded, not scaled).
158
- define('EBML_ID_CUEREFTIME', 0x16); // [96] -- Timecode of the referenced Block.
159
- define('EBML_ID_CUEREFCLUSTER', 0x17); // [97] -- Position of the Cluster containing the referenced Block.
160
- define('EBML_ID_CHAPTERFLAGHIDDEN', 0x18); // [98] -- If a chapter is hidden (1), it should not be available to the user interface (but still to Control Tracks).
161
- define('EBML_ID_FLAGINTERLACED', 0x1A); // [9A] -- Set if the video is interlaced.
162
- define('EBML_ID_CLUSTERBLOCKDURATION', 0x1B); // [9B] -- The duration of the Block (based on TimecodeScale). This element is mandatory when DefaultDuration is set for the track. When not written and with no DefaultDuration, the value is assumed to be the difference between the timecode of this Block and the timecode of the next Block in "display" order (not coding order). This element can be useful at the end of a Track (as there is not other Block available), or when there is a break in a track like for subtitle tracks.
163
- define('EBML_ID_FLAGLACING', 0x1C); // [9C] -- Set if the track may contain blocks using lacing.
164
- define('EBML_ID_CHANNELS', 0x1F); // [9F] -- Numbers of channels in the track.
165
- define('EBML_ID_CLUSTERBLOCKGROUP', 0x20); // [A0] -- Basic container of information containing a single Block or BlockVirtual, and information specific to that Block/VirtualBlock.
166
- define('EBML_ID_CLUSTERBLOCK', 0x21); // [A1] -- Block containing the actual data to be rendered and a timecode relative to the Cluster Timecode.
167
- define('EBML_ID_CLUSTERBLOCKVIRTUAL', 0x22); // [A2] -- A Block with no data. It must be stored in the stream at the place the real Block should be in display order.
168
- define('EBML_ID_CLUSTERSIMPLEBLOCK', 0x23); // [A3] -- Similar to Block but without all the extra information, mostly used to reduced overhead when no extra feature is needed.
169
- define('EBML_ID_CLUSTERCODECSTATE', 0x24); // [A4] -- The new codec state to use. Data interpretation is private to the codec. This information should always be referenced by a seek entry.
170
- define('EBML_ID_CLUSTERBLOCKADDITIONAL', 0x25); // [A5] -- Interpreted by the codec as it wishes (using the BlockAddID).
171
- define('EBML_ID_CLUSTERBLOCKMORE', 0x26); // [A6] -- Contain the BlockAdditional and some parameters.
172
- define('EBML_ID_CLUSTERPOSITION', 0x27); // [A7] -- Position of the Cluster in the segment (0 in live broadcast streams). It might help to resynchronise offset on damaged streams.
173
- define('EBML_ID_CODECDECODEALL', 0x2A); // [AA] -- The codec can decode potentially damaged data.
174
- define('EBML_ID_CLUSTERPREVSIZE', 0x2B); // [AB] -- Size of the previous Cluster, in octets. Can be useful for backward playing.
175
- define('EBML_ID_TRACKENTRY', 0x2E); // [AE] -- Describes a track with all elements.
176
- define('EBML_ID_CLUSTERENCRYPTEDBLOCK', 0x2F); // [AF] -- Similar to SimpleBlock but the data inside the Block are Transformed (encrypt and/or signed).
177
- define('EBML_ID_PIXELWIDTH', 0x30); // [B0] -- Width of the encoded video frames in pixels.
178
- define('EBML_ID_CUETIME', 0x33); // [B3] -- Absolute timecode according to the segment time base.
179
- define('EBML_ID_SAMPLINGFREQUENCY', 0x35); // [B5] -- Sampling frequency in Hz.
180
- define('EBML_ID_CHAPTERATOM', 0x36); // [B6] -- Contains the atom information to use as the chapter atom (apply to all tracks).
181
- define('EBML_ID_CUETRACKPOSITIONS', 0x37); // [B7] -- Contain positions for different tracks corresponding to the timecode.
182
- define('EBML_ID_FLAGENABLED', 0x39); // [B9] -- Set if the track is used.
183
- define('EBML_ID_PIXELHEIGHT', 0x3A); // [BA] -- Height of the encoded video frames in pixels.
184
- define('EBML_ID_CUEPOINT', 0x3B); // [BB] -- Contains all information relative to a seek point in the segment.
185
- define('EBML_ID_CRC32', 0x3F); // [BF] -- The CRC is computed on all the data of the Master element it's in, regardless of its position. It's recommended to put the CRC value at the beggining of the Master element for easier reading. All level 1 elements should include a CRC-32.
186
- define('EBML_ID_CLUSTERBLOCKADDITIONID', 0x4B); // [CB] -- The ID of the BlockAdditional element (0 is the main Block).
187
- define('EBML_ID_CLUSTERLACENUMBER', 0x4C); // [CC] -- The reverse number of the frame in the lace (0 is the last frame, 1 is the next to last, etc). While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback.
188
- define('EBML_ID_CLUSTERFRAMENUMBER', 0x4D); // [CD] -- The number of the frame to generate from this lace with this delay (allow you to generate many frames from the same Block/Frame).
189
- define('EBML_ID_CLUSTERDELAY', 0x4E); // [CE] -- The (scaled) delay to apply to the element.
190
- define('EBML_ID_CLUSTERDURATION', 0x4F); // [CF] -- The (scaled) duration to apply to the element.
191
- define('EBML_ID_TRACKNUMBER', 0x57); // [D7] -- The track number as used in the Block Header (using more than 127 tracks is not encouraged, though the design allows an unlimited number).
192
- define('EBML_ID_CUEREFERENCE', 0x5B); // [DB] -- The Clusters containing the required referenced Blocks.
193
- define('EBML_ID_VIDEO', 0x60); // [E0] -- Video settings.
194
- define('EBML_ID_AUDIO', 0x61); // [E1] -- Audio settings.
195
- define('EBML_ID_CLUSTERTIMESLICE', 0x68); // [E8] -- Contains extra time information about the data contained in the Block. While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback.
196
- define('EBML_ID_CUECODECSTATE', 0x6A); // [EA] -- The position of the Codec State corresponding to this Cue element. 0 means that the data is taken from the initial Track Entry.
197
- define('EBML_ID_CUEREFCODECSTATE', 0x6B); // [EB] -- The position of the Codec State corresponding to this referenced element. 0 means that the data is taken from the initial Track Entry.
198
- define('EBML_ID_VOID', 0x6C); // [EC] -- Used to void damaged data, to avoid unexpected behaviors when using damaged data. The content is discarded. Also used to reserve space in a sub-element for later use.
199
- define('EBML_ID_CLUSTERTIMECODE', 0x67); // [E7] -- Absolute timecode of the cluster (based on TimecodeScale).
200
- define('EBML_ID_CLUSTERBLOCKADDID', 0x6E); // [EE] -- An ID to identify the BlockAdditional level.
201
- define('EBML_ID_CUECLUSTERPOSITION', 0x71); // [F1] -- The position of the Cluster containing the required Block.
202
- define('EBML_ID_CUETRACK', 0x77); // [F7] -- The track for which a position is given.
203
- define('EBML_ID_CLUSTERREFERENCEPRIORITY', 0x7A); // [FA] -- This frame is referenced and has the specified cache priority. In cache only a frame of the same or higher priority can replace this frame. A value of 0 means the frame is not referenced.
204
- define('EBML_ID_CLUSTERREFERENCEBLOCK', 0x7B); // [FB] -- Timecode of another frame used as a reference (ie: B or P frame). The timecode is relative to the block it's attached to.
205
- define('EBML_ID_CLUSTERREFERENCEVIRTUAL', 0x7D); // [FD] -- Relative position of the data that should be in position of the virtual block.
206
-
207
-
208
- class getid3_matroska
209
- {
210
- var $read_buffer_size = 32768; // size of read buffer, 32kB is default
211
- var $hide_clusters = true; // if true, do not return information about CLUSTER chunks, since there's a lot of them and they're not usually useful
212
- var $warnings = array();
213
-
214
- function getid3_matroska(&$fd, &$ThisFileInfo) {
215
-
216
- // http://www.matroska.org/technical/specs/index.html#EBMLBasics
217
- $offset = $ThisFileInfo['avdataoffset'];
218
- $EBMLdata = '';
219
- $EBMLdata_offset = $offset;
220
-
221
- if ($ThisFileInfo['avdataend'] > 2147483648) {
222
- $this->warnings[] = 'This version of getID3() may or may not correctly handle Matroska files larger than 2GB';
223
- }
224
-
225
- while ($offset < $ThisFileInfo['avdataend']) {
226
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
227
-
228
- $top_element_offset = $offset;
229
- $top_element_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
230
- $top_element_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
231
- if ($top_element_length === false) {
232
- $this->warnings[] = 'invalid chunk length at '.$top_element_offset;
233
- $offset = pow(2, 63);
234
- break;
235
- }
236
- $top_element_endoffset = $offset + $top_element_length;
237
- switch ($top_element_id) {
238
- case EBML_ID_EBML:
239
- $ThisFileInfo['fileformat'] = 'matroska';
240
- $ThisFileInfo['matroska']['header']['offset'] = $top_element_offset;
241
- $ThisFileInfo['matroska']['header']['length'] = $top_element_length;
242
-
243
- while ($offset < $top_element_endoffset) {
244
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
245
- $element_data = array();
246
- $element_data_offset = $offset;
247
- $element_data['id'] = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
248
- $element_data['id_name'] = $this->EBMLidName($element_data['id']);
249
- $element_data['length'] = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
250
- $end_offset = $offset + $element_data['length'];
251
-
252
- switch ($element_data['id']) {
253
- case EBML_ID_EBMLVERSION:
254
- case EBML_ID_EBMLREADVERSION:
255
- case EBML_ID_EBMLMAXIDLENGTH:
256
- case EBML_ID_EBMLMAXSIZELENGTH:
257
- case EBML_ID_DOCTYPEVERSION:
258
- case EBML_ID_DOCTYPEREADVERSION:
259
- $element_data['data'] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $element_data['length']));
260
- break;
261
- case EBML_ID_DOCTYPE:
262
- $element_data['data'] = trim(substr($EBMLdata, $offset - $EBMLdata_offset, $element_data['length']), "\x00");
263
- break;
264
- default:
265
- $this->warnings[] = 'Unhandled track.video element['.__LINE__.'] ('.$element_data['id'].'::'.$element_data['id_name'].') at '.$element_data_offset;
266
- break;
267
- }
268
- $offset = $end_offset;
269
- $ThisFileInfo['matroska']['header']['elements'][] = $element_data;
270
- }
271
- break;
272
-
273
-
274
- case EBML_ID_SEGMENT:
275
- $ThisFileInfo['matroska']['segment'][0]['offset'] = $top_element_offset;
276
- $ThisFileInfo['matroska']['segment'][0]['length'] = $top_element_length;
277
-
278
- $segment_key = -1;
279
- while ($offset < $ThisFileInfo['avdataend']) {
280
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
281
-
282
- $element_data = array();
283
- $element_data['offset'] = $offset;
284
- $element_data['id'] = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
285
- $element_data['id_name'] = $this->EBMLidName($element_data['id']);
286
- $element_data['length'] = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
287
- if ($element_data['length'] === false) {
288
- $this->warnings[] = 'invalid chunk length at '.$element_data['offset'];
289
- //$offset = pow(2, 63);
290
- $offset = $ThisFileInfo['avdataend'];
291
- break;
292
- }
293
- $element_end = $offset + $element_data['length'];
294
- switch ($element_data['id']) {
295
- //case EBML_ID_CLUSTER:
296
- // // too many cluster entries, probably not useful
297
- // break;
298
- case false:
299
- $this->warnings[] = 'invalid ID at '.$element_data['offset'];
300
- $offset = $element_end;
301
- continue 3;
302
- default:
303
- $ThisFileInfo['matroska']['segments'][] = $element_data;
304
- break;
305
- }
306
- $segment_key++;
307
-
308
- switch ($element_data['id']) {
309
- case EBML_ID_SEEKHEAD: // Contains the position of other level 1 elements
310
- while ($offset < $element_end) {
311
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
312
- $seek_entry = array();
313
- $seek_entry['offset'] = $offset;
314
- $seek_entry['id'] = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
315
- $seek_entry['id_name'] = $this->EBMLidName($seek_entry['id']);
316
- $seek_entry['length'] = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
317
- $seek_end_offset = $offset + $seek_entry['length'];
318
- switch ($seek_entry['id']) {
319
- case EBML_ID_SEEK: // Contains a single seek entry to an EBML element
320
- while ($offset < $seek_end_offset) {
321
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
322
- $id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
323
- $length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
324
- $value = substr($EBMLdata, $offset - $EBMLdata_offset, $length);
325
- $offset += $length;
326
- switch ($id) {
327
- case EBML_ID_SEEKID:
328
- $dummy = 0;
329
- $seek_entry['target_id'] = $this->readEBMLint($value, $dummy);
330
- $seek_entry['target_name'] = $this->EBMLidName($seek_entry['target_id']);
331
- break;
332
- case EBML_ID_SEEKPOSITION:
333
- $seek_entry['target_offset'] = $element_data['offset'] + getid3_lib::BigEndian2Int($value);
334
- break;
335
- default:
336
- $ThisFileInfo['error'][] = 'Unhandled segment['.__LINE__.'] ('.$id.') at '.$offset;
337
- break;
338
- }
339
- }
340
- $ThisFileInfo['matroska']['seek'][] = $seek_entry;
341
- //switch ($seek_entry['target_id']) {
342
- // case EBML_ID_CLUSTER:
343
- // // too many cluster seek points, probably not useful
344
- // break;
345
- // default:
346
- // $ThisFileInfo['matroska']['seek'][] = $seek_entry;
347
- // break;
348
- //}
349
- break;
350
- default:
351
- $this->warnings[] = 'Unhandled seekhead element['.__LINE__.'] ('.$seek_entry['id'].') at '.$offset;
352
- break;
353
- }
354
- $offset = $seek_end_offset;
355
- }
356
- break;
357
-
358
- case EBML_ID_TRACKS: // information about all tracks in segment
359
- $ThisFileInfo['matroska']['tracks'] = $element_data;
360
- while ($offset < $element_end) {
361
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
362
- $track_entry = array();
363
- $track_entry['offset'] = $offset;
364
- $track_entry['id'] = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
365
- $track_entry['id_name'] = $this->EBMLidName($track_entry['id']);
366
- $track_entry['length'] = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
367
- $track_entry_endoffset = $offset + $track_entry['length'];
368
- switch ($track_entry['id']) {
369
- case EBML_ID_TRACKENTRY: //subelements: Describes a track with all elements.
370
- while ($offset < $track_entry_endoffset) {
371
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
372
- $subelement_offset = $offset;
373
- $subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
374
- $subelement_idname = $this->EBMLidName($subelement_id);
375
- $subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
376
- $subelement_end = $offset + $subelement_length;
377
- switch ($subelement_id) {
378
- case EBML_ID_TRACKNUMBER:
379
- case EBML_ID_TRACKUID:
380
- case EBML_ID_TRACKTYPE:
381
- case EBML_ID_MINCACHE:
382
- case EBML_ID_MAXCACHE:
383
- case EBML_ID_MAXBLOCKADDITIONID:
384
- case EBML_ID_DEFAULTDURATION: // nanoseconds per frame
385
- $track_entry[$subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $subelement_length));
386
- break;
387
- case EBML_ID_TRACKTIMECODESCALE:
388
- $track_entry[$subelement_idname] = getid3_lib::BigEndian2Float(substr($EBMLdata, $offset - $EBMLdata_offset, $subelement_length));
389
- break;
390
- case EBML_ID_CODECID:
391
- case EBML_ID_LANGUAGE:
392
- case EBML_ID_NAME:
393
- case EBML_ID_CODECPRIVATE:
394
- $track_entry[$subelement_idname] = trim(substr($EBMLdata, $offset - $EBMLdata_offset, $subelement_length), "\x00");
395
- break;
396
- case EBML_ID_FLAGENABLED:
397
- case EBML_ID_FLAGDEFAULT:
398
- case EBML_ID_FLAGFORCED:
399
- case EBML_ID_FLAGLACING:
400
- case EBML_ID_CODECDECODEALL:
401
- $track_entry[$subelement_idname] = (bool) getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $subelement_length));
402
- break;
403
- case EBML_ID_VIDEO:
404
- while ($offset < $subelement_end) {
405
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
406
- $sub_subelement_offset = $offset;
407
- $sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
408
- $sub_subelement_idname = $this->EBMLidName($sub_subelement_id);
409
- $sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
410
- $sub_subelement_end = $offset + $sub_subelement_length;
411
- switch ($sub_subelement_id) {
412
- case EBML_ID_PIXELWIDTH:
413
- case EBML_ID_PIXELHEIGHT:
414
- case EBML_ID_STEREOMODE:
415
- case EBML_ID_PIXELCROPBOTTOM:
416
- case EBML_ID_PIXELCROPTOP:
417
- case EBML_ID_PIXELCROPLEFT:
418
- case EBML_ID_PIXELCROPRIGHT:
419
- case EBML_ID_DISPLAYWIDTH:
420
- case EBML_ID_DISPLAYHEIGHT:
421
- case EBML_ID_DISPLAYUNIT:
422
- case EBML_ID_ASPECTRATIOTYPE:
423
- $track_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
424
- break;
425
- case EBML_ID_FLAGINTERLACED:
426
- $track_entry[$sub_subelement_idname] = (bool) getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
427
- break;
428
- case EBML_ID_GAMMAVALUE:
429
- $track_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Float(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
430
- break;
431
- case EBML_ID_COLOURSPACE:
432
- $track_entry[$sub_subelement_idname] = trim(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length), "\x00");
433
- break;
434
- default:
435
- $this->warnings[] = 'Unhandled track.video element['.__LINE__.'] ('.$sub_subelement_id.'::'.$sub_subelement_idname.') at '.$sub_subelement_offset;
436
- break;
437
- }
438
- $offset = $sub_subelement_end;
439
- }
440
-
441
- if ((@$track_entry[$this->EBMLidName(EBML_ID_CODECID)] == 'V_MS/VFW/FOURCC') && isset($track_entry[$this->EBMLidName(EBML_ID_CODECPRIVATE)])) {
442
- if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, false)) {
443
- $track_entry['codec_private_parsed'] = getid3_riff::ParseBITMAPINFOHEADER($track_entry[$this->EBMLidName(EBML_ID_CODECPRIVATE)]);
444
- } else {
445
- $this->warnings[] = 'Unable to parse codec private data['.__LINE__.'] because cannot include "module.audio-video.riff.php"';
446
- }
447
- }
448
- break;
449
- case EBML_ID_AUDIO:
450
- while ($offset < $subelement_end) {
451
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
452
- $sub_subelement_offset = $offset;
453
- $sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
454
- $sub_subelement_idname = $this->EBMLidName($sub_subelement_id);
455
- $sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
456
- $sub_subelement_end = $offset + $sub_subelement_length;
457
- switch ($sub_subelement_id) {
458
- case EBML_ID_CHANNELS:
459
- case EBML_ID_BITDEPTH:
460
- $track_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
461
- break;
462
- case EBML_ID_SAMPLINGFREQUENCY:
463
- case EBML_ID_OUTPUTSAMPLINGFREQUENCY:
464
- $track_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Float(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
465
- break;
466
- case EBML_ID_CHANNELPOSITIONS:
467
- $track_entry[$sub_subelement_idname] = trim(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length), "\x00");
468
- break;
469
- default:
470
- $this->warnings[] = 'Unhandled track.video element['.__LINE__.'] ('.$sub_subelement_id.'::'.$sub_subelement_idname.') at '.$sub_subelement_offset;
471
- break;
472
- }
473
- $offset = $sub_subelement_end;
474
- }
475
- break;
476
-
477
- case EBML_ID_CONTENTENCODINGS:
478
- while ($offset < $subelement_end) {
479
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
480
- $sub_subelement_offset = $offset;
481
- $sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
482
- $sub_subelement_idname = $this->EBMLidName($sub_subelement_id);
483
- $sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
484
- $sub_subelement_end = $offset + $sub_subelement_length;
485
- switch ($sub_subelement_id) {
486
- case EBML_ID_CONTENTENCODING:
487
- while ($offset < $sub_subelement_end) {
488
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
489
- $sub_sub_subelement_offset = $offset;
490
- $sub_sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
491
- $sub_sub_subelement_idname = $this->EBMLidName($sub_sub_subelement_id);
492
- $sub_sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
493
- $sub_sub_subelement_end = $offset + $sub_sub_subelement_length;
494
- switch ($sub_sub_subelement_id) {
495
- case EBML_ID_CONTENTENCODINGORDER:
496
- case EBML_ID_CONTENTENCODINGSCOPE:
497
- case EBML_ID_CONTENTENCODINGTYPE:
498
- $track_entry[$sub_subelement_idname][$sub_sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_subelement_length));
499
- break;
500
- case EBML_ID_CONTENTCOMPRESSION:
501
- while ($offset < $sub_sub_subelement_end) {
502
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
503
- $sub_sub_sub_subelement_offset = $offset;
504
- $sub_sub_sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
505
- $sub_sub_sub_subelement_idname = $this->EBMLidName($sub_sub_subelement_id);
506
- $sub_sub_sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
507
- $sub_sub_sub_subelement_end = $offset + $sub_sub_sub_subelement_length;
508
- switch ($sub_sub_sub_subelement_id) {
509
- case EBML_ID_CONTENTCOMPALGO:
510
- $track_entry[$sub_subelement_idname][$sub_sub_subelement_idname][$sub_sub_sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_sub_subelement_length));
511
- break;
512
- case EBML_ID_CONTENTCOMPSETTINGS:
513
- $track_entry[$sub_subelement_idname][$sub_sub_subelement_idname][$sub_sub_sub_subelement_idname] = substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_sub_subelement_length);
514
- break;
515
- default:
516
- $this->warnings[] = 'Unhandled track.contentencodings.contentencoding.contentcompression element['.__LINE__.'] ('.$subelement_id.'::'.$subelement_idname.' ['.$subelement_length.' bytes]) at '.$subelement_offset;
517
- break;
518
- }
519
- $offset = $sub_sub_sub_subelement_end;
520
- }
521
- break;
522
-
523
- case EBML_ID_CONTENTENCRYPTION:
524
- while ($offset < $sub_sub_subelement_end) {
525
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
526
- $sub_sub_sub_subelement_offset = $offset;
527
- $sub_sub_sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
528
- $sub_sub_sub_subelement_idname = $this->EBMLidName($sub_sub_subelement_id);
529
- $sub_sub_sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
530
- $sub_sub_sub_subelement_end = $offset + $sub_sub_sub_subelement_length;
531
- switch ($sub_sub_sub_subelement_id) {
532
- case EBML_ID_CONTENTENCALGO:
533
- case EBML_ID_CONTENTSIGALGO:
534
- case EBML_ID_CONTENTSIGHASHALGO:
535
- $track_entry[$sub_subelement_idname][$sub_sub_subelement_idname][$sub_sub_sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_sub_subelement_length));
536
- break;
537
- case EBML_ID_CONTENTENCKEYID:
538
- case EBML_ID_CONTENTSIGNATURE:
539
- case EBML_ID_CONTENTSIGKEYID:
540
- $track_entry[$sub_subelement_idname][$sub_sub_subelement_idname][$sub_sub_sub_subelement_idname] = substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_sub_subelement_length);
541
- break;
542
- default:
543
- $this->warnings[] = 'Unhandled track.contentencodings.contentencoding.contentcompression element['.__LINE__.'] ('.$subelement_id.'::'.$subelement_idname.' ['.$subelement_length.' bytes]) at '.$subelement_offset;
544
- break;
545
- }
546
- $offset = $sub_sub_sub_subelement_end;
547
- }
548
- break;
549
-
550
- default:
551
- $this->warnings[] = 'Unhandled track.contentencodings.contentencoding element['.__LINE__.'] ('.$subelement_id.'::'.$subelement_idname.' ['.$subelement_length.' bytes]) at '.$subelement_offset;
552
- break;
553
- }
554
- $offset = $sub_sub_subelement_end;
555
- }
556
- break;
557
- default:
558
- $this->warnings[] = 'Unhandled track.contentencodings element['.__LINE__.'] ('.$subelement_id.'::'.$subelement_idname.' ['.$subelement_length.' bytes]) at '.$subelement_offset;
559
- break;
560
- }
561
- $offset = $sub_subelement_end;
562
- }
563
- break;
564
-
565
- default:
566
- $this->warnings[] = 'Unhandled track element['.__LINE__.'] ('.$subelement_id.'::'.$subelement_idname.' ['.$subelement_length.' bytes]) at '.$subelement_offset;
567
- break;
568
- }
569
- $offset = $subelement_end;
570
- }
571
- break;
572
- default:
573
- $this->warnings[] = 'Unhandled track element['.__LINE__.'] ('.$track_entry['id'].'::'.$track_entry['id_name'].') at '.$track_entry['offset'];
574
- $offset = $track_entry_endoffset;
575
- break;
576
- }
577
- $ThisFileInfo['matroska']['tracks']['tracks'][] = $track_entry;
578
- }
579
- break;
580
-
581
- case EBML_ID_INFO: // Contains the position of other level 1 elements
582
- $info_entry = array();
583
- while ($offset < $element_end) {
584
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
585
- $subelement_offset = $offset;
586
- $subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
587
- $subelement_idname = $this->EBMLidName($subelement_id);
588
- $subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
589
- $subelement_end = $offset + $subelement_length;
590
- switch ($subelement_id) {
591
- case EBML_ID_CHAPTERTRANSLATEEDITIONUID:
592
- case EBML_ID_CHAPTERTRANSLATECODEC:
593
- case EBML_ID_TIMECODESCALE:
594
- $info_entry[$subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $subelement_length));
595
- break;
596
- case EBML_ID_DURATION:
597
- $info_entry[$subelement_idname] = getid3_lib::BigEndian2Float(substr($EBMLdata, $offset - $EBMLdata_offset, $subelement_length));
598
- break;
599
- case EBML_ID_DATEUTC:
600
- $info_entry[$subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $subelement_length));
601
- $info_entry[$subelement_idname.'_unix'] = $this->EBMLdate2unix($info_entry[$subelement_idname]);
602
- break;
603
- case EBML_ID_SEGMENTUID:
604
- case EBML_ID_PREVUID:
605
- case EBML_ID_NEXTUID:
606
- case EBML_ID_SEGMENTFAMILY:
607
- case EBML_ID_CHAPTERTRANSLATEID:
608
- $info_entry[$subelement_idname] = trim(substr($EBMLdata, $offset - $EBMLdata_offset, $subelement_length), "\x00");
609
- break;
610
- case EBML_ID_SEGMENTFILENAME:
611
- case EBML_ID_PREVFILENAME:
612
- case EBML_ID_NEXTFILENAME:
613
- case EBML_ID_TITLE:
614
- case EBML_ID_MUXINGAPP:
615
- case EBML_ID_WRITINGAPP:
616
- $info_entry[$subelement_idname] = trim(substr($EBMLdata, $offset - $EBMLdata_offset, $subelement_length), "\x00");
617
- break;
618
- default:
619
- $this->warnings[] = 'Unhandled info element['.__LINE__.'] ('.$subelement_id.'::'.$subelement_idname.' ['.$subelement_length.' bytes]) at '.$subelement_offset;
620
- break;
621
- }
622
- $offset = $subelement_end;
623
- }
624
- $ThisFileInfo['matroska']['info'][] = $info_entry;
625
- break;
626
-
627
- case EBML_ID_CUES:
628
- $cues_entry = array();
629
- while ($offset < $element_end) {
630
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
631
- $subelement_offset = $offset;
632
- $subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
633
- $subelement_idname = $this->EBMLidName($subelement_id);
634
- $subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
635
- $subelement_end = $offset + $subelement_length;
636
- switch ($subelement_id) {
637
- case EBML_ID_CUEPOINT:
638
- $cuepoint_entry = array();
639
- while ($offset < $subelement_end) {
640
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
641
- $sub_subelement_offset = $offset;
642
- $sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
643
- $sub_subelement_idname = $this->EBMLidName($sub_subelement_id);
644
- $sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
645
- $sub_subelement_end = $offset + $sub_subelement_length;
646
- switch ($sub_subelement_id) {
647
- case EBML_ID_CUETRACKPOSITIONS:
648
- while ($offset < $sub_subelement_end) {
649
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
650
- $sub_sub_subelement_offset = $offset;
651
- $sub_sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
652
- $sub_sub_subelement_idname = $this->EBMLidName($sub_sub_subelement_id);
653
- $sub_sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
654
- $sub_sub_subelement_end = $offset + $sub_sub_subelement_length;
655
- switch ($sub_sub_subelement_id) {
656
- case EBML_ID_CUETRACK:
657
- $cuepoint_entry[$sub_sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_subelement_length));
658
- break;
659
- default:
660
- $this->warnings[] = 'Unhandled cues.cuepoint.cuetrackpositions element['.__LINE__.'] ('.$sub_sub_subelement_id.'::'.$sub_sub_subelement_idname.') at '.$sub_sub_subelement_offset;
661
- break;
662
- }
663
- $offset = $sub_subelement_end;
664
- }
665
- break;
666
- case EBML_ID_CUETIME:
667
- $cuepoint_entry[$subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
668
- break;
669
- default:
670
- $this->warnings[] = 'Unhandled cues.cuepoint element['.__LINE__.'] ('.$sub_subelement_id.'::'.$sub_subelement_idname.') at '.$sub_subelement_offset;
671
- break;
672
- }
673
- $offset = $sub_subelement_end;
674
- }
675
- $cues_entry[] = $cuepoint_entry;
676
- $offset = $sub_subelement_end;
677
- break;
678
- default:
679
- $this->warnings[] = 'Unhandled cues element['.__LINE__.'] ('.$subelement_id.'::'.$subelement_idname.' ['.$subelement_length.' bytes]) at '.$subelement_offset;
680
- break;
681
- }
682
- $offset = $subelement_end;
683
- }
684
- $ThisFileInfo['matroska']['cues'] = $cues_entry;
685
- break;
686
-
687
- case EBML_ID_TAGS:
688
- $tags_entry = array();
689
- while ($offset < $element_end) {
690
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
691
- $subelement_offset = $offset;
692
- $subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
693
- $subelement_idname = $this->EBMLidName($subelement_id);
694
- $subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
695
- $subelement_end = $offset + $subelement_length;
696
- switch ($subelement_id) {
697
- case EBML_ID_WRITINGAPP:
698
- $tags_entry[$subelement_idname] = substr($EBMLdata, $offset - $EBMLdata_offset, $subelement_length);
699
- break;
700
- case EBML_ID_TAG:
701
- $tag_entry = array();
702
- while ($offset < $subelement_end) {
703
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
704
- $sub_subelement_offset = $offset;
705
- $sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
706
- $sub_subelement_idname = $this->EBMLidName($sub_subelement_id);
707
- $sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
708
- $sub_subelement_end = $offset + $sub_subelement_length;
709
- switch ($sub_subelement_id) {
710
- case EBML_ID_TARGETS:
711
- $targets_entry = array();
712
- while ($offset < $sub_subelement_end) {
713
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
714
- $sub_sub_subelement_offset = $offset;
715
- $sub_sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
716
- $sub_sub_subelement_idname = $this->EBMLidName($sub_sub_subelement_id);
717
- $sub_sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
718
- $sub_sub_subelement_end = $offset + $sub_sub_subelement_length;
719
- switch ($sub_sub_subelement_id) {
720
- case EBML_ID_TARGETTYPEVALUE:
721
- case EBML_ID_EDITIONUID:
722
- case EBML_ID_CHAPTERUID:
723
- case EBML_ID_ATTACHMENTUID:
724
- case EBML_ID_TAGTRACKUID:
725
- case EBML_ID_TAGCHAPTERUID:
726
- $targets_entry[$sub_sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_subelement_length));
727
- break;
728
- default:
729
- $this->warnings[] = 'Unhandled tag.targets element['.__LINE__.'] ('.$sub_sub_subelement_id.'::'.$sub_sub_subelement_idname.') at '.$sub_sub_subelement_offset;
730
- break;
731
- }
732
- $offset = $sub_sub_subelement_end;
733
- }
734
- $tag_entry[$sub_subelement_idname][] = $targets_entry;
735
- break;
736
- case EBML_ID_SIMPLETAG:
737
- $simpletag_entry = array();
738
- while ($offset < $sub_subelement_end) {
739
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
740
- $sub_sub_subelement_offset = $offset;
741
- $sub_sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
742
- $sub_sub_subelement_idname = $this->EBMLidName($sub_sub_subelement_id);
743
- $sub_sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
744
- $sub_sub_subelement_end = $offset + $sub_sub_subelement_length;
745
- switch ($sub_sub_subelement_id) {
746
- case EBML_ID_TAGNAME:
747
- case EBML_ID_TAGLANGUAGE:
748
- case EBML_ID_TAGSTRING:
749
- case EBML_ID_TAGBINARY:
750
- $simpletag_entry[$sub_sub_subelement_idname] = substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_subelement_length);
751
- break;
752
- case EBML_ID_TAGDEFAULT:
753
- $simpletag_entry[$sub_sub_subelement_idname] = (bool) getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_subelement_length));
754
- break;
755
- default:
756
- $this->warnings[] = 'Unhandled tag.simpletag element['.__LINE__.'] ('.$sub_sub_subelement_id.'::'.$sub_sub_subelement_idname.') at '.$sub_sub_subelement_offset;
757
- break;
758
- }
759
- $offset = $sub_sub_subelement_end;
760
- }
761
- $tag_entry[$sub_subelement_idname][] = $simpletag_entry;
762
- break;
763
- case EBML_ID_TARGETTYPE:
764
- $tag_entry[$sub_subelement_idname] = substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length);
765
- break;
766
- case EBML_ID_TRACKUID:
767
- $tag_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
768
- break;
769
- default:
770
- $this->warnings[] = 'Unhandled tags.tag element['.__LINE__.'] ('.$sub_subelement_id.'::'.$sub_subelement_idname.') at '.$sub_subelement_offset;
771
- break;
772
- }
773
- $offset = $sub_subelement_end;
774
- }
775
- $tags_entry['tags'][] = $tag_entry;
776
- $offset = $sub_subelement_end;
777
- break;
778
- default:
779
- $this->warnings[] = 'Unhandled tags element['.__LINE__.'] ('.$subelement_id.'::'.$subelement_idname.' ['.$subelement_length.' bytes]) at '.$subelement_offset;
780
- break;
781
- }
782
- $offset = $subelement_end;
783
- }
784
- $ThisFileInfo['matroska']['tags'] = $tags_entry;
785
- break;
786
-
787
-
788
- case EBML_ID_ATTACHMENTS:
789
- while ($offset < $element_end) {
790
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
791
- $subelement_offset = $offset;
792
- $subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
793
- $subelement_idname = $this->EBMLidName($subelement_id);
794
- $subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
795
- $subelement_end = $offset + $subelement_length;
796
- switch ($subelement_id) {
797
- case EBML_ID_ATTACHEDFILE:
798
- $attachedfile_entry = array();
799
- while ($offset < $subelement_end) {
800
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
801
- $sub_subelement_offset = $offset;
802
- $sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
803
- $sub_subelement_idname = $this->EBMLidName($sub_subelement_id);
804
- $sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
805
- $sub_subelement_end = $offset + $sub_subelement_length;
806
- switch ($sub_subelement_id) {
807
- case EBML_ID_FILEDESCRIPTION:
808
- case EBML_ID_FILENAME:
809
- case EBML_ID_FILEMIMETYPE:
810
- $attachedfile_entry[$sub_subelement_idname] = substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length);
811
- break;
812
-
813
- case EBML_ID_FILEDATA:
814
- $attachedfile_entry['data_offset'] = $offset;
815
- $attachedfile_entry['data_length'] = $sub_subelement_length;
816
- if ($sub_subelement_length < 1024) {
817
- $attachedfile_entry[$sub_subelement_idname] = substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length);
818
- }
819
- break;
820
-
821
- case EBML_ID_FILEUID:
822
- $attachedfile_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
823
- break;
824
-
825
- default:
826
- $this->warnings[] = 'Unhandled attachment.attachedfile element['.__LINE__.'] ('.$sub_subelement_id.'::'.$sub_subelement_idname.') at '.$sub_subelement_offset;
827
- break;
828
- }
829
- $offset = $sub_subelement_end;
830
- }
831
- $ThisFileInfo['matroska']['attachments'][] = $attachedfile_entry;
832
- $offset = $sub_subelement_end;
833
- break;
834
- default:
835
- $this->warnings[] = 'Unhandled tags element['.__LINE__.'] ('.$subelement_id.'::'.$subelement_idname.' ['.$subelement_length.' bytes]) at '.$subelement_offset;
836
- break;
837
- }
838
- $offset = $subelement_end;
839
- }
840
- break;
841
-
842
-
843
- case EBML_ID_CHAPTERS: // not important to us, contains mostly actual audio/video data, ignore
844
- while ($offset < $element_end) {
845
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
846
- $subelement_offset = $offset;
847
- $subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
848
- $subelement_idname = $this->EBMLidName($subelement_id);
849
- $subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
850
- $subelement_end = $offset + $subelement_length;
851
- switch ($subelement_id) {
852
- case EBML_ID_EDITIONENTRY:
853
- $editionentry_entry = array();
854
- while ($offset < $subelement_end) {
855
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
856
- $sub_subelement_offset = $offset;
857
- $sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
858
- $sub_subelement_idname = $this->EBMLidName($sub_subelement_id);
859
- $sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
860
- $sub_subelement_end = $offset + $sub_subelement_length;
861
- switch ($sub_subelement_id) {
862
- case EBML_ID_EDITIONUID:
863
- $editionentry_entry[$sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
864
- break;
865
- case EBML_ID_EDITIONFLAGHIDDEN:
866
- case EBML_ID_EDITIONFLAGDEFAULT:
867
- case EBML_ID_EDITIONFLAGORDERED:
868
- $editionentry_entry[$sub_subelement_idname] = (bool) getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
869
- break;
870
- case EBML_ID_CHAPTERATOM:
871
- $chapteratom_entry = array();
872
- while ($offset < $sub_subelement_end) {
873
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
874
- $sub_sub_subelement_offset = $offset;
875
- $sub_sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
876
- $sub_sub_subelement_idname = $this->EBMLidName($sub_sub_subelement_id);
877
- $sub_sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
878
- $sub_sub_subelement_end = $offset + $sub_sub_subelement_length;
879
- switch ($sub_sub_subelement_id) {
880
- case EBML_ID_CHAPTERSEGMENTUID:
881
- case EBML_ID_CHAPTERSEGMENTEDITIONUID:
882
- $chapteratom_entry[$sub_sub_subelement_idname] = substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_subelement_length);
883
- break;
884
- case EBML_ID_CHAPTERFLAGENABLED:
885
- case EBML_ID_CHAPTERFLAGHIDDEN:
886
- $chapteratom_entry[$sub_sub_subelement_idname] = (bool) getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_subelement_length));
887
- break;
888
- case EBML_ID_CHAPTERUID:
889
- case EBML_ID_CHAPTERTIMESTART:
890
- case EBML_ID_CHAPTERTIMEEND:
891
- $chapteratom_entry[$sub_sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_subelement_length));
892
- break;
893
- case EBML_ID_CHAPTERTRACK:
894
- $chaptertrack_entry = array();
895
- while ($offset < $sub_sub_subelement_end) {
896
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
897
- $sub_sub_sub_subelement_offset = $offset;
898
- $sub_sub_sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
899
- $sub_sub_sub_subelement_idname = $this->EBMLidName($sub_sub_subelement_id);
900
- $sub_sub_sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
901
- $sub_sub_sub_subelement_end = $offset + $sub_sub_sub_subelement_length;
902
- switch ($sub_sub_sub_subelement_id) {
903
- case EBML_ID_CHAPTERTRACKNUMBER:
904
- $chaptertrack_entry[$sub_sub_sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_sub_subelement_length));
905
- break;
906
- default:
907
- $this->warnings[] = 'Unhandled chapters.editionentry.chapteratom.chaptertrack element['.__LINE__.'] ('.$sub_sub_sub_subelement_id.'::'.$sub_sub_sub_subelement_idname.') at '.$sub_sub_sub_subelement_offset;
908
- break;
909
- }
910
- $offset = $sub_sub_sub_subelement_end;
911
- }
912
- $chapteratom_entry[$sub_sub_subelement_idname][] = $chaptertrack_entry;
913
- break;
914
- case EBML_ID_CHAPTERDISPLAY:
915
- $chapterdisplay_entry = array();
916
- while ($offset < $sub_sub_subelement_end) {
917
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
918
- $sub_sub_sub_subelement_offset = $offset;
919
- $sub_sub_sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
920
- $sub_sub_sub_subelement_idname = $this->EBMLidName($sub_sub_sub_subelement_id);
921
- $sub_sub_sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
922
- $sub_sub_sub_subelement_end = $offset + $sub_sub_sub_subelement_length;
923
- switch ($sub_sub_sub_subelement_id) {
924
- case EBML_ID_CHAPSTRING:
925
- case EBML_ID_CHAPLANGUAGE:
926
- case EBML_ID_CHAPCOUNTRY:
927
- $chapterdisplay_entry[$sub_sub_sub_subelement_idname] = substr($EBMLdata, $offset - $EBMLdata_offset, $sub_sub_sub_subelement_length);
928
- break;
929
- default:
930
- $this->warnings[] = 'Unhandled chapters.editionentry.chapteratom.chapterdisplay element['.__LINE__.'] ('.$sub_sub_sub_subelement_id.'::'.$sub_sub_sub_subelement_idname.') at '.$sub_sub_sub_subelement_offset;
931
- break;
932
- }
933
- $offset = $sub_sub_sub_subelement_end;
934
- }
935
- $chapteratom_entry[$sub_sub_subelement_idname][] = $chapterdisplay_entry;
936
- break;
937
- default:
938
- $this->warnings[] = 'Unhandled chapters.editionentry.chapteratom element['.__LINE__.'] ('.$sub_sub_subelement_id.'::'.$sub_sub_subelement_idname.') at '.$sub_sub_subelement_offset;
939
- break;
940
- }
941
- $offset = $sub_sub_subelement_end;
942
- }
943
- $editionentry_entry[$sub_subelement_idname][] = $chapteratom_entry;
944
- break;
945
- default:
946
- $this->warnings[] = 'Unhandled chapters.editionentry element['.__LINE__.'] ('.$sub_subelement_id.'::'.$sub_subelement_idname.') at '.$sub_subelement_offset;
947
- break;
948
- }
949
- $offset = $sub_subelement_end;
950
- }
951
- $ThisFileInfo['matroska']['chapters'][] = $editionentry_entry;
952
- $offset = $sub_subelement_end;
953
- break;
954
- default:
955
- $this->warnings[] = 'Unhandled chapters element['.__LINE__.'] ('.$subelement_id.'::'.$subelement_idname.' ['.$subelement_length.' bytes]) at '.$subelement_offset;
956
- break;
957
- }
958
- $offset = $subelement_end;
959
- }
960
- break;
961
-
962
-
963
- case EBML_ID_VOID: // padding, ignore
964
- $void_entry = array();
965
- $void_entry['offset'] = $offset;
966
- $ThisFileInfo['matroska']['void'][] = $void_entry;
967
- break;
968
-
969
- case EBML_ID_CLUSTER: // not important to us, contains mostly actual audio/video data, ignore
970
- $cluster_entry = array();
971
- while ($offset < $element_end) {
972
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
973
- $subelement_offset = $offset;
974
- //var_dump($offset);
975
- $subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
976
- //var_dump($subelement_id);
977
- //echo '<br>';
978
- $subelement_idname = $this->EBMLidName($subelement_id);
979
- $subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
980
- //var_dump($subelement_length);
981
- $subelement_end = $offset + $subelement_length;
982
- //exit;
983
- switch ($subelement_id) {
984
- case EBML_ID_CLUSTERTIMECODE:
985
- case EBML_ID_CLUSTERPOSITION:
986
- case EBML_ID_CLUSTERPREVSIZE:
987
- $cluster_entry[$subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $subelement_length));
988
- break;
989
-
990
- case EBML_ID_CLUSTERSILENTTRACKS:
991
- $cluster_silent_tracks = array();
992
- while ($offset < $subelement_end) {
993
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
994
- $sub_subelement_offset = $offset;
995
- $sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
996
- $sub_subelement_idname = $this->EBMLidName($sub_subelement_id);
997
- $sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
998
- $sub_subelement_end = $offset + $sub_subelement_length;
999
- switch ($sub_subelement_id) {
1000
- case EBML_ID_CLUSTERSILENTTRACKNUMBER:
1001
- $cluster_silent_tracks[] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
1002
- break;
1003
- default:
1004
- $this->warnings[] = 'Unhandled clusters.silenttracks element['.__LINE__.'] ('.$sub_subelement_id.'::'.$sub_subelement_idname.') at '.$sub_subelement_offset;
1005
- break;
1006
- }
1007
- $offset = $sub_subelement_end;
1008
- }
1009
- $cluster_entry[$subelement_idname][] = $cluster_silent_tracks;
1010
- $offset = $sub_subelement_end;
1011
- break;
1012
-
1013
- case EBML_ID_CLUSTERBLOCKGROUP:
1014
- $cluster_block_group = array('offset'=>$offset);
1015
- while ($offset < $subelement_end) {
1016
- $this->EnsureBufferHasEnoughData($fd, $EBMLdata, $offset, $EBMLdata_offset);
1017
- $sub_subelement_offset = $offset;
1018
- $sub_subelement_id = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
1019
- $sub_subelement_idname = $this->EBMLidName($sub_subelement_id);
1020
- $sub_subelement_length = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
1021
- $sub_subelement_end = $offset + $sub_subelement_length;
1022
- switch ($sub_subelement_id) {
1023
- case EBML_ID_CLUSTERBLOCK:
1024
- $cluster_block_data = array();
1025
- $cluster_block_data['tracknumber'] = $this->readEBMLint($EBMLdata, $offset, $EBMLdata_offset);
1026
- $cluster_block_data['timecode'] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset, 2));
1027
- $offset += 2;
1028
- // unsure whether this is 1 octect or 2 octets? (http://matroska.org/technical/specs/index.html#block_structure)
1029
- $cluster_block_data['flags_raw'] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset, 1));
1030
- $offset += 1;
1031
- //$cluster_block_data['flags']['reserved1'] = (($cluster_block_data['flags_raw'] & 0xF0) >> 4);
1032
- $cluster_block_data['flags']['invisible'] = (bool) (($cluster_block_data['flags_raw'] & 0x08) >> 3);
1033
- $cluster_block_data['flags']['lacing'] = (($cluster_block_data['flags_raw'] & 0x06) >> 1);
1034
- //$cluster_block_data['flags']['reserved2'] = (($cluster_block_data['flags_raw'] & 0x01) >> 0);
1035
- $cluster_block_data['flags']['lacing_type'] = $this->MatroskaBlockLacingType($cluster_block_data['flags']['lacing']);
1036
- if ($cluster_block_data['flags']['lacing'] != 0) {
1037
- $cluster_block_data['lace_frames'] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset, 1)); // Number of frames in the lace-1 (uint8)
1038
- $offset += 1;
1039
- if ($cluster_block_data['flags']['lacing'] != 2) {
1040
- $cluster_block_data['lace_frames'] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset, 1)); // Lace-coded size of each frame of the lace, except for the last one (multiple uint8). *This is not used with Fixed-size lacing as it is calculated automatically from (total size of lace) / (number of frames in lace).
1041
- $offset += 1;
1042
- }
1043
- }
1044
- if (!isset($ThisFileInfo['matroska']['track_data_offsets'][$cluster_block_data['tracknumber']])) {
1045
- $ThisFileInfo['matroska']['track_data_offsets'][$cluster_block_data['tracknumber']] = $offset;
1046
- }
1047
- $cluster_block_group[$sub_subelement_idname] = $cluster_block_data;
1048
- break;
1049
-
1050
- case EBML_ID_CLUSTERREFERENCEPRIORITY: // unsigned-int
1051
- case EBML_ID_CLUSTERBLOCKDURATION: // unsigned-int
1052
- $cluster_block_group[$sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length));
1053
- break;
1054
-
1055
- case EBML_ID_CLUSTERREFERENCEBLOCK: // signed-int
1056
- $cluster_block_group[$sub_subelement_idname] = getid3_lib::BigEndian2Int(substr($EBMLdata, $offset - $EBMLdata_offset, $sub_subelement_length), false, true);
1057
- break;
1058
-
1059
- default:
1060
- $this->warnings[] = 'Unhandled clusters.blockgroup element['.__LINE__.'] ('.$sub_subelement_id.'::'.$sub_subelement_idname.') at '.$sub_subelement_offset;
1061
- break;
1062
- }
1063
- $offset = $sub_subelement_end;
1064
- }
1065
- $cluster_entry[$subelement_idname][] = $cluster_block_group;
1066
- $offset = $sub_subelement_end;
1067
- break;
1068
-
1069
- default:
1070
- $this->warnings[] = 'Unhandled cluster element['.__LINE__.'] ('.$subelement_id.'::'.$subelement_idname.' ['.$subelement_length.' bytes]) at '.$subelement_offset;
1071
- break;
1072
- }
1073
- $offset = $subelement_end;
1074
- }
1075
- $ThisFileInfo['matroska']['cluster'][] = $cluster_entry;
1076
-
1077
- // check to see if all the data we need exists already, if so, break out of the loop
1078
- if (isset($ThisFileInfo['matroska']['info']) && is_array($ThisFileInfo['matroska']['info'])) {
1079
- if (isset($ThisFileInfo['matroska']['tracks']['tracks']) && is_array($ThisFileInfo['matroska']['tracks']['tracks'])) {
1080
- break 2;
1081
- }
1082
- }
1083
- break;
1084
-
1085
- default:
1086
- if ($element_data['id_name'] == dechex($element_data['id'])) {
1087
- $ThisFileInfo['error'][] = 'Unhandled segment['.__LINE__.'] ('.$element_data['id'].') at '.$element_data_offset;
1088
- } else {
1089
- $this->warnings[] = 'Unhandled segment['.__LINE__.'] ('.$element_data['id'].'::'.$element_data['id_name'].') at '.$element_data['offset'];
1090
- }
1091
- break;
1092
- }
1093
- $offset = $element_end;
1094
- }
1095
- break;
1096
-
1097
-
1098
- default:
1099
- $ThisFileInfo['error'][] = 'Unhandled chunk['.__LINE__.'] ('.$top_element_id.') at '.$offset;
1100
- break;
1101
- }
1102
- $offset = $top_element_endoffset;
1103
- }
1104
-
1105
-
1106
-
1107
- if (isset($ThisFileInfo['matroska']['info']) && is_array($ThisFileInfo['matroska']['info'])) {
1108
- foreach ($ThisFileInfo['matroska']['info'] as $key => $infoarray) {
1109
- if (isset($infoarray['Duration'])) {
1110
- // TimecodeScale is how many nanoseconds each Duration unit is
1111
- $ThisFileInfo['playtime_seconds'] = $infoarray['Duration'] * ((isset($infoarray['TimecodeScale']) ? $infoarray['TimecodeScale'] : 1000000) / 1000000000);
1112
- break;
1113
- }
1114
- }
1115
- }
1116
- if (isset($ThisFileInfo['matroska']['tracks']['tracks']) && is_array($ThisFileInfo['matroska']['tracks']['tracks'])) {
1117
- foreach ($ThisFileInfo['matroska']['tracks']['tracks'] as $key => $trackarray) {
1118
- $track_info = array();
1119
- switch (@$trackarray['TrackType']) {
1120
- case 1: // Video
1121
- if (@$trackarray['PixelWidth']) { $track_info['resolution_x'] = $trackarray['PixelWidth']; }
1122
- if (@$trackarray['PixelHeight']) { $track_info['resolution_y'] = $trackarray['PixelHeight']; }
1123
- if (@$trackarray['DisplayWidth']) { $track_info['display_x'] = $trackarray['DisplayWidth']; }
1124
- if (@$trackarray['DisplayHeight']) { $track_info['display_y'] = $trackarray['DisplayHeight']; }
1125
- if (@$trackarray['DefaultDuration']) { $track_info['frame_rate'] = round(1000000000 / $trackarray['DefaultDuration'], 3); }
1126
- if (@$trackarray['CodecID']) { $track_info['dataformat'] = $this->MatroskaCodecIDtoCommonName($trackarray['CodecID']); }
1127
- if (!empty($trackarray['codec_private_parsed']['fourcc'])) {
1128
- $track_info['fourcc'] = $trackarray['codec_private_parsed']['fourcc'];
1129
- }
1130
- $ThisFileInfo['video']['streams'][] = $track_info;
1131
- if (isset($track_info['resolution_x']) && empty($ThisFileInfo['video']['resolution_x'])) {
1132
- foreach ($track_info as $key => $value) {
1133
- $ThisFileInfo['video'][$key] = $value;
1134
- }
1135
- }
1136
- break;
1137
- case 2: // Audio
1138
- if (@$trackarray['CodecID']) { $track_info['dataformat'] = $this->MatroskaCodecIDtoCommonName($trackarray['CodecID']); }
1139
- if (@$trackarray['SamplingFrequency']) { $track_info['sample_rate'] = $trackarray['SamplingFrequency']; }
1140
- if (@$trackarray['Channels']) { $track_info['channels'] = $trackarray['Channels']; }
1141
- if (@$trackarray['BitDepth']) { $track_info['bits_per_sample'] = $trackarray['BitDepth']; }
1142
- switch (@$trackarray[$this->EBMLidName(EBML_ID_CODECID)]) {
1143
- case 'A_PCM/INT/LIT':
1144
- case 'A_PCM/INT/BIG':
1145
- $track_info['bitrate'] = $trackarray['SamplingFrequency'] * $trackarray['Channels'] * $trackarray['BitDepth'];
1146
- break;
1147
-
1148
- case 'A_AC3':
1149
- if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ac3.php', __FILE__, false)) {
1150
- $ac3_thisfileinfo = array('avdataoffset'=>$ThisFileInfo['matroska']['track_data_offsets'][$trackarray['TrackNumber']]);
1151
- $getid3_ac3 = new getid3_ac3($fd, $ac3_thisfileinfo);
1152
- $ThisFileInfo['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $ac3_thisfileinfo;
1153
- if (!empty($ac3_thisfileinfo['error'])) {
1154
- foreach ($ac3_thisfileinfo['error'] as $newerror) {
1155
- $this->warnings[] = 'getid3_ac3() says: ['.$newerror.']';
1156
- }
1157
- }
1158
- if (!empty($ac3_thisfileinfo['warning'])) {
1159
- foreach ($ac3_thisfileinfo['warning'] as $newerror) {
1160
- $this->warnings[] = 'getid3_ac3() says: ['.$newerror.']';
1161
- }
1162
- }
1163
- if (isset($ac3_thisfileinfo['audio']) && is_array($ac3_thisfileinfo['audio'])) {
1164
- foreach ($ac3_thisfileinfo['audio'] as $key => $value) {
1165
- $track_info[$key] = $value;
1166
- }
1167
- }
1168
- unset($ac3_thisfileinfo);
1169
- unset($getid3_ac3);
1170
- } else {
1171
- $this->warnings[] = 'Unable to parse audio data['.__LINE__.'] because cannot include "module.audio.ac3.php"';
1172
- }
1173
- break;
1174
-
1175
- case 'A_DTS':
1176
- $dts_offset = $ThisFileInfo['matroska']['track_data_offsets'][$trackarray['TrackNumber']];
1177
- // this is a NASTY hack, but sometimes audio data is off by a byte or two and not sure why, email info@getid3.org if you can explain better
1178
- fseek($fd, $dts_offset, SEEK_SET);
1179
- $magic_test = fread($fd, 8);
1180
- for ($i = 0; $i < 4; $i++) {
1181
- // look to see if DTS "magic" is here, if so adjust offset by that many bytes
1182
- if (substr($magic_test, $i, 4) == "\x7F\xFE\x80\x01") {
1183
- $dts_offset += $i;
1184
- break;
1185
- }
1186
- }
1187
- if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.dts.php', __FILE__, false)) {
1188
- $dts_thisfileinfo = array('avdataoffset'=>$dts_offset);
1189
- $getid3_dts = new getid3_dts($fd, $dts_thisfileinfo);
1190
- $ThisFileInfo['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $dts_thisfileinfo;
1191
- if (!empty($dts_thisfileinfo['error'])) {
1192
- foreach ($dts_thisfileinfo['error'] as $newerror) {
1193
- $this->warnings[] = 'getid3_dts() says: ['.$newerror.']';
1194
- }
1195
- }
1196
- if (!empty($dts_thisfileinfo['warning'])) {
1197
- foreach ($dts_thisfileinfo['warning'] as $newerror) {
1198
- $this->warnings[] = 'getid3_dts() says: ['.$newerror.']';
1199
- }
1200
- }
1201
- if (isset($dts_thisfileinfo['audio']) && is_array($dts_thisfileinfo['audio'])) {
1202
- foreach ($dts_thisfileinfo['audio'] as $key => $value) {
1203
- $track_info[$key] = $value;
1204
- }
1205
- }
1206
- unset($dts_thisfileinfo);
1207
- unset($getid3_dts);
1208
- } else {
1209
- $this->warnings[] = 'Unable to parse audio data['.__LINE__.'] because cannot include "module.audio.dts.php"';
1210
- }
1211
- break;
1212
-
1213
- //case 'A_AAC':
1214
- // if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.aac.php', __FILE__, false)) {
1215
- // $aac_thisfileinfo = array('avdataoffset'=>$ThisFileInfo['matroska']['track_data_offsets'][$trackarray['TrackNumber']]);
1216
- // $getid3_aac = new getid3_aac($fd, $aac_thisfileinfo);
1217
- // $ThisFileInfo['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $aac_thisfileinfo;
1218
- // if (isset($aac_thisfileinfo['audio']) && is_array($aac_thisfileinfo['audio'])) {
1219
- // foreach ($aac_thisfileinfo['audio'] as $key => $value) {
1220
- // $track_info[$key] = $value;
1221
- // }
1222
- // }
1223
- // unset($aac_thisfileinfo);
1224
- // unset($getid3_aac);
1225
- // } else {
1226
- // $this->warnings[] = 'Unable to parse audio data['.__LINE__.'] because cannot include "module.audio.aac.php"';
1227
- // }
1228
- // break;
1229
-
1230
- case 'A_MPEG/L3':
1231
- if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, false)) {
1232
- $mp3_thisfileinfo = array(
1233
- 'avdataoffset' => $ThisFileInfo['matroska']['track_data_offsets'][$trackarray['TrackNumber']],
1234
- 'avdataend' => $ThisFileInfo['matroska']['track_data_offsets'][$trackarray['TrackNumber']] + 1024,
1235
- );
1236
- $getid3_mp3 = new getid3_mp3($fd, $mp3_thisfileinfo);
1237
- $getid3_mp3->allow_bruteforce = true;
1238
- //getid3_mp3::getOnlyMPEGaudioInfo($fd, $mp3_thisfileinfo, $offset, false);
1239
- $ThisFileInfo['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $mp3_thisfileinfo;
1240
- if (!empty($mp3_thisfileinfo['error'])) {
1241
- foreach ($mp3_thisfileinfo['error'] as $newerror) {
1242
- $this->warnings[] = 'getid3_mp3() says: ['.$newerror.']';
1243
- }
1244
- }
1245
- if (!empty($mp3_thisfileinfo['warning'])) {
1246
- foreach ($mp3_thisfileinfo['warning'] as $newerror) {
1247
- $this->warnings[] = 'getid3_mp3() says: ['.$newerror.']';
1248
- }
1249
- }
1250
- if (isset($mp3_thisfileinfo['audio']) && is_array($mp3_thisfileinfo['audio'])) {
1251
- foreach ($mp3_thisfileinfo['audio'] as $key => $value) {
1252
- $track_info[$key] = $value;
1253
- }
1254
- }
1255
- unset($mp3_thisfileinfo);
1256
- unset($getid3_mp3);
1257
- } else {
1258
- $this->warnings[] = 'Unable to parse audio data['.__LINE__.'] because cannot include "module.audio.mp3.php"';
1259
- }
1260
- break;
1261
-
1262
- case 'A_VORBIS':
1263
- if (isset($trackarray['CodecPrivate'])) {
1264
- // this is a NASTY hack, email info@getid3.org if you have a better idea how to get this info out
1265
- $found_vorbis = false;
1266
- for ($vorbis_offset = 1; $vorbis_offset < 16; $vorbis_offset++) {
1267
- if (substr($trackarray['CodecPrivate'], $vorbis_offset, 6) == 'vorbis') {
1268
- $vorbis_offset--;
1269
- $found_vorbis = true;
1270
- break;
1271
- }
1272
- }
1273
- if ($found_vorbis) {
1274
- if (getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ogg.php', __FILE__, false)) {
1275
- $vorbis_fileinfo = array();
1276
- $oggpageinfo['page_seqno'] = 0;
1277
- getid3_ogg::ParseVorbisPageHeader($trackarray['CodecPrivate'], $vorbis_offset, $vorbis_fileinfo, $oggpageinfo);
1278
- $ThisFileInfo['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $vorbis_fileinfo;
1279
- if (!empty($vorbis_fileinfo['error'])) {
1280
- foreach ($vorbis_fileinfo['error'] as $newerror) {
1281
- $this->warnings[] = 'getid3_ogg() says: ['.$newerror.']';
1282
- }
1283
- }
1284
- if (!empty($vorbis_fileinfo['warning'])) {
1285
- foreach ($vorbis_fileinfo['warning'] as $newerror) {
1286
- $this->warnings[] = 'getid3_ogg() says: ['.$newerror.']';
1287
- }
1288
- }
1289
- if (isset($vorbis_fileinfo['audio']) && is_array($vorbis_fileinfo['audio'])) {
1290
- foreach ($vorbis_fileinfo['audio'] as $key => $value) {
1291
- $track_info[$key] = $value;
1292
- }
1293
- }
1294
- if (@$vorbis_fileinfo['ogg']['bitrate_average']) {
1295
- $track_info['bitrate'] = $vorbis_fileinfo['ogg']['bitrate_average'];
1296
- } elseif (@$vorbis_fileinfo['ogg']['bitrate_nominal']) {
1297
- $track_info['bitrate'] = $vorbis_fileinfo['ogg']['bitrate_nominal'];
1298
- }
1299
- unset($vorbis_fileinfo);
1300
- unset($oggpageinfo);
1301
- } else {
1302
- $this->warnings[] = 'Unable to parse audio data['.__LINE__.'] because cannot include "module.audio.ogg.php"';
1303
- }
1304
- } else {
1305
- }
1306
- } else {
1307
- }
1308
- break;
1309
-
1310
- default:
1311
- $this->warnings[] = 'Unhandled audio type "'.@$trackarray[$this->EBMLidName(EBML_ID_CODECID)].'"';
1312
- break;
1313
- }
1314
-
1315
-
1316
- $ThisFileInfo['audio']['streams'][] = $track_info;
1317
- if (isset($track_info['dataformat']) && empty($ThisFileInfo['audio']['dataformat'])) {
1318
- foreach ($track_info as $key => $value) {
1319
- $ThisFileInfo['audio'][$key] = $value;
1320
- }
1321
- }
1322
- break;
1323
- default:
1324
- // ignore, do nothing
1325
- break;
1326
- }
1327
- }
1328
- }
1329
-
1330
- if ($this->hide_clusters) {
1331
- // too much data returned that is usually not useful
1332
- if (isset($ThisFileInfo['matroska']['segments']) && is_array($ThisFileInfo['matroska']['segments'])) {
1333
- foreach ($ThisFileInfo['matroska']['segments'] as $key => $segmentsarray) {
1334
- if ($segmentsarray['id'] == EBML_ID_CLUSTER) {
1335
- unset($ThisFileInfo['matroska']['segments'][$key]);
1336
- }
1337
- }
1338
- }
1339
- if (isset($ThisFileInfo['matroska']['seek']) && is_array($ThisFileInfo['matroska']['seek'])) {
1340
- foreach ($ThisFileInfo['matroska']['seek'] as $key => $seekarray) {
1341
- if ($seekarray['target_id'] == EBML_ID_CLUSTER) {
1342
- unset($ThisFileInfo['matroska']['seek'][$key]);
1343
- }
1344
- }
1345
- }
1346
- //unset($ThisFileInfo['matroska']['cluster']);
1347
- //unset($ThisFileInfo['matroska']['track_data_offsets']);
1348
- }
1349
-
1350
- if (!empty($ThisFileInfo['video']['streams'])) {
1351
- $ThisFileInfo['mime_type'] = 'video/x-matroska';
1352
- } elseif (!empty($ThisFileInfo['video']['streams'])) {
1353
- $ThisFileInfo['mime_type'] = 'audio/x-matroska';
1354
- } elseif (isset($ThisFileInfo['mime_type'])) {
1355
- unset($ThisFileInfo['mime_type']);
1356
- }
1357
-
1358
- foreach ($this->warnings as $key => $value) {
1359
- $ThisFileInfo['warning'][] = $value;
1360
- }
1361
-
1362
- return true;
1363
- }
1364
-
1365
-
1366
- ///////////////////////////////////////
1367
-
1368
-
1369
- function EnsureBufferHasEnoughData(&$fd, &$EBMLdata, &$offset, &$EBMLdata_offset) {
1370
- $min_data = 1024;
1371
- if ($offset > 2147450880) { // 2^31 - 2^15 (2G-32k)
1372
- $offset = pow(2,63);
1373
- return false;
1374
- } elseif (($offset - $EBMLdata_offset) >= (strlen($EBMLdata) - $min_data)) {
1375
- fseek($fd, $offset, SEEK_SET);
1376
- $EBMLdata_offset = ftell($fd);
1377
- $EBMLdata = fread($fd, $this->read_buffer_size);
1378
- }
1379
- return true;
1380
- }
1381
-
1382
- function readEBMLint(&$string, &$offset, $dataoffset=0) {
1383
- $actual_offset = $offset - $dataoffset;
1384
- if ($offset > 2147450880) { // 2^31 - 2^15 (2G-32k)
1385
- $this->warnings[] = 'aborting readEBMLint() because $offset larger than 2GB';
1386
- return false;
1387
- } elseif ($actual_offset >= strlen($string)) {
1388
- $this->warnings[] = '$actual_offset > $string in readEBMLint($string['.strlen($string).'], '.$offset.', '.$dataoffset.')';
1389
- return false;
1390
- } elseif ($actual_offset < 0) {
1391
- $this->warnings[] = '$actual_offset < 0 in readEBMLint($string['.strlen($string).'], '.$offset.', '.$dataoffset.')';
1392
- return false;
1393
- }
1394
- $first_byte_int = ord($string{$actual_offset});
1395
- if (0x80 & $first_byte_int) {
1396
- $length = 1;
1397
- } elseif (0x40 & $first_byte_int) {
1398
- $length = 2;
1399
- } elseif (0x20 & $first_byte_int) {
1400
- $length = 3;
1401
- } elseif (0x10 & $first_byte_int) {
1402
- $length = 4;
1403
- } elseif (0x08 & $first_byte_int) {
1404
- $length = 5;
1405
- } elseif (0x04 & $first_byte_int) {
1406
- $length = 6;
1407
- } elseif (0x02 & $first_byte_int) {
1408
- $length = 7;
1409
- } elseif (0x01 & $first_byte_int) {
1410
- $length = 8;
1411
- } else {
1412
- $offset = pow(2,63); // abort processing, skip to end of file
1413
- $this->warnings[] = 'invalid EBML integer (leading 0x00) at '.$offset;
1414
- return false;
1415
- }
1416
- $int_value = $this->EBML2Int(substr($string, $actual_offset, $length));
1417
- $offset += $length;
1418
- return $int_value;
1419
- }
1420
-
1421
- function EBML2Int($EBMLstring) {
1422
- // http://matroska.org/specs/
1423
-
1424
- // Element ID coded with an UTF-8 like system:
1425
- // 1xxx xxxx - Class A IDs (2^7 -2 possible values) (base 0x8X)
1426
- // 01xx xxxx xxxx xxxx - Class B IDs (2^14-2 possible values) (base 0x4X 0xXX)
1427
- // 001x xxxx xxxx xxxx xxxx xxxx - Class C IDs (2^21-2 possible values) (base 0x2X 0xXX 0xXX)
1428
- // 0001 xxxx xxxx xxxx xxxx xxxx xxxx xxxx - Class D IDs (2^28-2 possible values) (base 0x1X 0xXX 0xXX 0xXX)
1429
- // Values with all x at 0 and 1 are reserved (hence the -2).
1430
-
1431
- // Data size, in octets, is also coded with an UTF-8 like system :
1432
- // 1xxx xxxx - value 0 to 2^7-2
1433
- // 01xx xxxx xxxx xxxx - value 0 to 2^14-2
1434
- // 001x xxxx xxxx xxxx xxxx xxxx - value 0 to 2^21-2
1435
- // 0001 xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^28-2
1436
- // 0000 1xxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^35-2
1437
- // 0000 01xx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^42-2
1438
- // 0000 001x xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^49-2
1439
- // 0000 0001 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^56-2
1440
-
1441
- $first_byte_int = ord($EBMLstring{0});
1442
- if (0x80 & $first_byte_int) {
1443
- $EBMLstring{0} = chr($first_byte_int & 0x7F);
1444
- } elseif (0x40 & $first_byte_int) {
1445
- $EBMLstring{0} = chr($first_byte_int & 0x3F);
1446
- } elseif (0x20 & $first_byte_int) {
1447
- $EBMLstring{0} = chr($first_byte_int & 0x1F);
1448
- } elseif (0x10 & $first_byte_int) {
1449
- $EBMLstring{0} = chr($first_byte_int & 0x0F);
1450
- } elseif (0x08 & $first_byte_int) {
1451
- $EBMLstring{0} = chr($first_byte_int & 0x07);
1452
- } elseif (0x04 & $first_byte_int) {
1453
- $EBMLstring{0} = chr($first_byte_int & 0x03);
1454
- } elseif (0x02 & $first_byte_int) {
1455
- $EBMLstring{0} = chr($first_byte_int & 0x01);
1456
- } elseif (0x01 & $first_byte_int) {
1457
- $EBMLstring{0} = chr($first_byte_int & 0x00);
1458
- } else {
1459
- return false;
1460
- }
1461
- return getid3_lib::BigEndian2Int($EBMLstring);
1462
- }
1463
-
1464
-
1465
- function EBMLdate2unix($EBMLdatestamp) {
1466
- // Date - signed 8 octets integer in nanoseconds with 0 indicating the precise beginning of the millennium (at 2001-01-01T00:00:00,000000000 UTC)
1467
- // 978307200 == mktime(0, 0, 0, 1, 1, 2001) == January 1, 2001 12:00:00am UTC
1468
- return round(($EBMLdatestamp / 1000000000) + 978307200);
1469
- }
1470
-
1471
-
1472
- function MatroskaBlockLacingType($lacingtype) {
1473
- // http://matroska.org/technical/specs/index.html#block_structure
1474
- static $MatroskaBlockLacingType = array();
1475
- if (empty($MatroskaBlockLacingType)) {
1476
- $MatroskaBlockLacingType[0x00] = 'no lacing';
1477
- $MatroskaBlockLacingType[0x01] = 'Xiph lacing';
1478
- $MatroskaBlockLacingType[0x02] = 'fixed-size lacing';
1479
- $MatroskaBlockLacingType[0x03] = 'EBML lacing';
1480
- }
1481
- return (isset($MatroskaBlockLacingType[$lacingtype]) ? $MatroskaBlockLacingType[$lacingtype] : $lacingtype);
1482
- }
1483
-
1484
- function MatroskaCodecIDtoCommonName($codecid) {
1485
- // http://www.matroska.org/technical/specs/codecid/index.html
1486
- static $MatroskaCodecIDlist = array();
1487
- if (empty($MatroskaCodecIDlist)) {
1488
- $MatroskaCodecIDlist['A_AAC'] = 'aac';
1489
- $MatroskaCodecIDlist['A_AAC/MPEG2/LC'] = 'aac';
1490
- $MatroskaCodecIDlist['A_AC3'] = 'ac3';
1491
- $MatroskaCodecIDlist['A_DTS'] = 'dts';
1492
- $MatroskaCodecIDlist['A_FLAC'] = 'flac';
1493
- $MatroskaCodecIDlist['A_MPEG/L1'] = 'mp1';
1494
- $MatroskaCodecIDlist['A_MPEG/L2'] = 'mp2';
1495
- $MatroskaCodecIDlist['A_MPEG/L3'] = 'mp3';
1496
- $MatroskaCodecIDlist['A_PCM/INT/LIT'] = 'pcm'; // PCM Integer Little Endian
1497
- $MatroskaCodecIDlist['A_PCM/INT/BIG'] = 'pcm'; // PCM Integer Big Endian
1498
- $MatroskaCodecIDlist['A_QUICKTIME/QDMC'] = 'quicktime'; // Quicktime: QDesign Music
1499
- $MatroskaCodecIDlist['A_QUICKTIME/QDM2'] = 'quicktime'; // Quicktime: QDesign Music v2
1500
- $MatroskaCodecIDlist['A_VORBIS'] = 'vorbis';
1501
- $MatroskaCodecIDlist['V_MPEG1'] = 'mpeg';
1502
- $MatroskaCodecIDlist['V_THEORA'] = 'theora';
1503
- $MatroskaCodecIDlist['V_REAL/RV40'] = 'real';
1504
- $MatroskaCodecIDlist['V_REAL/RV10'] = 'real';
1505
- $MatroskaCodecIDlist['V_REAL/RV20'] = 'real';
1506
- $MatroskaCodecIDlist['V_REAL/RV30'] = 'real';
1507
- $MatroskaCodecIDlist['V_QUICKTIME'] = 'quicktime'; // Quicktime
1508
- $MatroskaCodecIDlist['V_MPEG4/ISO/AP'] = 'mpeg4';
1509
- $MatroskaCodecIDlist['V_MPEG4/ISO/ASP'] = 'mpeg4';
1510
- $MatroskaCodecIDlist['V_MPEG4/ISO/AVC'] = 'h264';
1511
- $MatroskaCodecIDlist['V_MPEG4/ISO/SP'] = 'mpeg4';
1512
- }
1513
- return (isset($MatroskaCodecIDlist[$codecid]) ? $MatroskaCodecIDlist[$codecid] : $codecid);
1514
- }
1515
-
1516
- function EBMLidName($value) {
1517
- static $EBMLidList = array();
1518
- if (empty($EBMLidList)) {
1519
- $EBMLidList[EBML_ID_ASPECTRATIOTYPE] = 'AspectRatioType';
1520
- $EBMLidList[EBML_ID_ATTACHEDFILE] = 'AttachedFile';
1521
- $EBMLidList[EBML_ID_ATTACHMENTLINK] = 'AttachmentLink';
1522
- $EBMLidList[EBML_ID_ATTACHMENTS] = 'Attachments';
1523
- $EBMLidList[EBML_ID_ATTACHMENTUID] = 'AttachmentUID';
1524
- $EBMLidList[EBML_ID_AUDIO] = 'Audio';
1525
- $EBMLidList[EBML_ID_BITDEPTH] = 'BitDepth';
1526
- $EBMLidList[EBML_ID_CHANNELPOSITIONS] = 'ChannelPositions';
1527
- $EBMLidList[EBML_ID_CHANNELS] = 'Channels';
1528
- $EBMLidList[EBML_ID_CHAPCOUNTRY] = 'ChapCountry';
1529
- $EBMLidList[EBML_ID_CHAPLANGUAGE] = 'ChapLanguage';
1530
- $EBMLidList[EBML_ID_CHAPPROCESS] = 'ChapProcess';
1531
- $EBMLidList[EBML_ID_CHAPPROCESSCODECID] = 'ChapProcessCodecID';
1532
- $EBMLidList[EBML_ID_CHAPPROCESSCOMMAND] = 'ChapProcessCommand';
1533
- $EBMLidList[EBML_ID_CHAPPROCESSDATA] = 'ChapProcessData';
1534
- $EBMLidList[EBML_ID_CHAPPROCESSPRIVATE] = 'ChapProcessPrivate';
1535
- $EBMLidList[EBML_ID_CHAPPROCESSTIME] = 'ChapProcessTime';
1536
- $EBMLidList[EBML_ID_CHAPSTRING] = 'ChapString';
1537
- $EBMLidList[EBML_ID_CHAPTERATOM] = 'ChapterAtom';
1538
- $EBMLidList[EBML_ID_CHAPTERDISPLAY] = 'ChapterDisplay';
1539
- $EBMLidList[EBML_ID_CHAPTERFLAGENABLED] = 'ChapterFlagEnabled';
1540
- $EBMLidList[EBML_ID_CHAPTERFLAGHIDDEN] = 'ChapterFlagHidden';
1541
- $EBMLidList[EBML_ID_CHAPTERPHYSICALEQUIV] = 'ChapterPhysicalEquiv';
1542
- $EBMLidList[EBML_ID_CHAPTERS] = 'Chapters';
1543
- $EBMLidList[EBML_ID_CHAPTERSEGMENTEDITIONUID] = 'ChapterSegmentEditionUID';
1544
- $EBMLidList[EBML_ID_CHAPTERSEGMENTUID] = 'ChapterSegmentUID';
1545
- $EBMLidList[EBML_ID_CHAPTERTIMEEND] = 'ChapterTimeEnd';
1546
- $EBMLidList[EBML_ID_CHAPTERTIMESTART] = 'ChapterTimeStart';
1547
- $EBMLidList[EBML_ID_CHAPTERTRACK] = 'ChapterTrack';
1548
- $EBMLidList[EBML_ID_CHAPTERTRACKNUMBER] = 'ChapterTrackNumber';
1549
- $EBMLidList[EBML_ID_CHAPTERTRANSLATE] = 'ChapterTranslate';
1550
- $EBMLidList[EBML_ID_CHAPTERTRANSLATECODEC] = 'ChapterTranslateCodec';
1551
- $EBMLidList[EBML_ID_CHAPTERTRANSLATEEDITIONUID] = 'ChapterTranslateEditionUID';
1552
- $EBMLidList[EBML_ID_CHAPTERTRANSLATEID] = 'ChapterTranslateID';
1553
- $EBMLidList[EBML_ID_CHAPTERUID] = 'ChapterUID';
1554
- $EBMLidList[EBML_ID_CLUSTER] = 'Cluster';
1555
- $EBMLidList[EBML_ID_CLUSTERBLOCK] = 'ClusterBlock';
1556
- $EBMLidList[EBML_ID_CLUSTERBLOCKADDID] = 'ClusterBlockAddID';
1557
- $EBMLidList[EBML_ID_CLUSTERBLOCKADDITIONAL] = 'ClusterBlockAdditional';
1558
- $EBMLidList[EBML_ID_CLUSTERBLOCKADDITIONID] = 'ClusterBlockAdditionID';
1559
- $EBMLidList[EBML_ID_CLUSTERBLOCKADDITIONS] = 'ClusterBlockAdditions';
1560
- $EBMLidList[EBML_ID_CLUSTERBLOCKDURATION] = 'ClusterBlockDuration';
1561
- $EBMLidList[EBML_ID_CLUSTERBLOCKGROUP] = 'ClusterBlockGroup';
1562
- $EBMLidList[EBML_ID_CLUSTERBLOCKMORE] = 'ClusterBlockMore';
1563
- $EBMLidList[EBML_ID_CLUSTERBLOCKVIRTUAL] = 'ClusterBlockVirtual';
1564
- $EBMLidList[EBML_ID_CLUSTERCODECSTATE] = 'ClusterCodecState';
1565
- $EBMLidList[EBML_ID_CLUSTERDELAY] = 'ClusterDelay';
1566
- $EBMLidList[EBML_ID_CLUSTERDURATION] = 'ClusterDuration';
1567
- $EBMLidList[EBML_ID_CLUSTERENCRYPTEDBLOCK] = 'ClusterEncryptedBlock';
1568
- $EBMLidList[EBML_ID_CLUSTERFRAMENUMBER] = 'ClusterFrameNumber';
1569
- $EBMLidList[EBML_ID_CLUSTERLACENUMBER] = 'ClusterLaceNumber';
1570
- $EBMLidList[EBML_ID_CLUSTERPOSITION] = 'ClusterPosition';
1571
- $EBMLidList[EBML_ID_CLUSTERPREVSIZE] = 'ClusterPrevSize';
1572
- $EBMLidList[EBML_ID_CLUSTERREFERENCEBLOCK] = 'ClusterReferenceBlock';
1573
- $EBMLidList[EBML_ID_CLUSTERREFERENCEPRIORITY] = 'ClusterReferencePriority';
1574
- $EBMLidList[EBML_ID_CLUSTERREFERENCEVIRTUAL] = 'ClusterReferenceVirtual';
1575
- $EBMLidList[EBML_ID_CLUSTERSILENTTRACKNUMBER] = 'ClusterSilentTrackNumber';
1576
- $EBMLidList[EBML_ID_CLUSTERSILENTTRACKS] = 'ClusterSilentTracks';
1577
- $EBMLidList[EBML_ID_CLUSTERSIMPLEBLOCK] = 'ClusterSimpleBlock';
1578
- $EBMLidList[EBML_ID_CLUSTERTIMECODE] = 'ClusterTimecode';
1579
- $EBMLidList[EBML_ID_CLUSTERTIMESLICE] = 'ClusterTimeSlice';
1580
- $EBMLidList[EBML_ID_CODECDECODEALL] = 'CodecDecodeAll';
1581
- $EBMLidList[EBML_ID_CODECDOWNLOADURL] = 'CodecDownloadURL';
1582
- $EBMLidList[EBML_ID_CODECID] = 'CodecID';
1583
- $EBMLidList[EBML_ID_CODECINFOURL] = 'CodecInfoURL';
1584
- $EBMLidList[EBML_ID_CODECNAME] = 'CodecName';
1585
- $EBMLidList[EBML_ID_CODECPRIVATE] = 'CodecPrivate';
1586
- $EBMLidList[EBML_ID_CODECSETTINGS] = 'CodecSettings';
1587
- $EBMLidList[EBML_ID_COLOURSPACE] = 'ColourSpace';
1588
- $EBMLidList[EBML_ID_CONTENTCOMPALGO] = 'ContentCompAlgo';
1589
- $EBMLidList[EBML_ID_CONTENTCOMPRESSION] = 'ContentCompression';
1590
- $EBMLidList[EBML_ID_CONTENTCOMPSETTINGS] = 'ContentCompSettings';
1591
- $EBMLidList[EBML_ID_CONTENTENCALGO] = 'ContentEncAlgo';
1592
- $EBMLidList[EBML_ID_CONTENTENCKEYID] = 'ContentEncKeyID';
1593
- $EBMLidList[EBML_ID_CONTENTENCODING] = 'ContentEncoding';
1594
- $EBMLidList[EBML_ID_CONTENTENCODINGORDER] = 'ContentEncodingOrder';
1595
- $EBMLidList[EBML_ID_CONTENTENCODINGS] = 'ContentEncodings';
1596
- $EBMLidList[EBML_ID_CONTENTENCODINGSCOPE] = 'ContentEncodingScope';
1597
- $EBMLidList[EBML_ID_CONTENTENCODINGTYPE] = 'ContentEncodingType';
1598
- $EBMLidList[EBML_ID_CONTENTENCRYPTION] = 'ContentEncryption';
1599
- $EBMLidList[EBML_ID_CONTENTSIGALGO] = 'ContentSigAlgo';
1600
- $EBMLidList[EBML_ID_CONTENTSIGHASHALGO] = 'ContentSigHashAlgo';
1601
- $EBMLidList[EBML_ID_CONTENTSIGKEYID] = 'ContentSigKeyID';
1602
- $EBMLidList[EBML_ID_CONTENTSIGNATURE] = 'ContentSignature';
1603
- $EBMLidList[EBML_ID_CRC32] = 'CRC32';
1604
- $EBMLidList[EBML_ID_CUEBLOCKNUMBER] = 'CueBlockNumber';
1605
- $EBMLidList[EBML_ID_CUECLUSTERPOSITION] = 'CueClusterPosition';
1606
- $EBMLidList[EBML_ID_CUECODECSTATE] = 'CueCodecState';
1607
- $EBMLidList[EBML_ID_CUEPOINT] = 'CuePoint';
1608
- $EBMLidList[EBML_ID_CUEREFCLUSTER] = 'CueRefCluster';
1609
- $EBMLidList[EBML_ID_CUEREFCODECSTATE] = 'CueRefCodecState';
1610
- $EBMLidList[EBML_ID_CUEREFERENCE] = 'CueReference';
1611
- $EBMLidList[EBML_ID_CUEREFNUMBER] = 'CueRefNumber';
1612
- $EBMLidList[EBML_ID_CUEREFTIME] = 'CueRefTime';
1613
- $EBMLidList[EBML_ID_CUES] = 'Cues';
1614
- $EBMLidList[EBML_ID_CUETIME] = 'CueTime';
1615
- $EBMLidList[EBML_ID_CUETRACK] = 'CueTrack';
1616
- $EBMLidList[EBML_ID_CUETRACKPOSITIONS] = 'CueTrackPositions';
1617
- $EBMLidList[EBML_ID_DATEUTC] = 'DateUTC';
1618
- $EBMLidList[EBML_ID_DEFAULTDURATION] = 'DefaultDuration';
1619
- $EBMLidList[EBML_ID_DISPLAYHEIGHT] = 'DisplayHeight';
1620
- $EBMLidList[EBML_ID_DISPLAYUNIT] = 'DisplayUnit';
1621
- $EBMLidList[EBML_ID_DISPLAYWIDTH] = 'DisplayWidth';
1622
- $EBMLidList[EBML_ID_DOCTYPE] = 'DocType';
1623
- $EBMLidList[EBML_ID_DOCTYPEREADVERSION] = 'DocTypeReadVersion';
1624
- $EBMLidList[EBML_ID_DOCTYPEVERSION] = 'DocTypeVersion';
1625
- $EBMLidList[EBML_ID_DURATION] = 'Duration';
1626
- $EBMLidList[EBML_ID_EBMLMAXIDLENGTH] = 'EBMLMaxIDLength';
1627
- $EBMLidList[EBML_ID_EBMLMAXSIZELENGTH] = 'EBMLMaxSizeLength';
1628
- $EBMLidList[EBML_ID_EBMLREADVERSION] = 'EBMLReadVersion';
1629
- $EBMLidList[EBML_ID_EBMLVERSION] = 'EBMLVersion';
1630
- $EBMLidList[EBML_ID_EDITIONENTRY] = 'EditionEntry';
1631
- $EBMLidList[EBML_ID_EDITIONFLAGDEFAULT] = 'EditionFlagDefault';
1632
- $EBMLidList[EBML_ID_EDITIONFLAGHIDDEN] = 'EditionFlagHidden';
1633
- $EBMLidList[EBML_ID_EDITIONFLAGORDERED] = 'EditionFlagOrdered';
1634
- $EBMLidList[EBML_ID_EDITIONUID] = 'EditionUID';
1635
- $EBMLidList[EBML_ID_FILEDATA] = 'FileData';
1636
- $EBMLidList[EBML_ID_FILEDESCRIPTION] = 'FileDescription';
1637
- $EBMLidList[EBML_ID_FILEMIMETYPE] = 'FileMimeType';
1638
- $EBMLidList[EBML_ID_FILENAME] = 'FileName';
1639
- $EBMLidList[EBML_ID_FILEREFERRAL] = 'FileReferral';
1640
- $EBMLidList[EBML_ID_FILEUID] = 'FileUID';
1641
- $EBMLidList[EBML_ID_FLAGDEFAULT] = 'FlagDefault';
1642
- $EBMLidList[EBML_ID_FLAGENABLED] = 'FlagEnabled';
1643
- $EBMLidList[EBML_ID_FLAGFORCED] = 'FlagForced';
1644
- $EBMLidList[EBML_ID_FLAGINTERLACED] = 'FlagInterlaced';
1645
- $EBMLidList[EBML_ID_FLAGLACING] = 'FlagLacing';
1646
- $EBMLidList[EBML_ID_GAMMAVALUE] = 'GammaValue';
1647
- $EBMLidList[EBML_ID_INFO] = 'Info';
1648
- $EBMLidList[EBML_ID_LANGUAGE] = 'Language';
1649
- $EBMLidList[EBML_ID_MAXBLOCKADDITIONID] = 'MaxBlockAdditionID';
1650
- $EBMLidList[EBML_ID_MAXCACHE] = 'MaxCache';
1651
- $EBMLidList[EBML_ID_MINCACHE] = 'MinCache';
1652
- $EBMLidList[EBML_ID_MUXINGAPP] = 'MuxingApp';
1653
- $EBMLidList[EBML_ID_NAME] = 'Name';
1654
- $EBMLidList[EBML_ID_NEXTFILENAME] = 'NextFilename';
1655
- $EBMLidList[EBML_ID_NEXTUID] = 'NextUID';
1656
- $EBMLidList[EBML_ID_OUTPUTSAMPLINGFREQUENCY] = 'OutputSamplingFrequency';
1657
- $EBMLidList[EBML_ID_PIXELCROPBOTTOM] = 'PixelCropBottom';
1658
- $EBMLidList[EBML_ID_PIXELCROPLEFT] = 'PixelCropLeft';
1659
- $EBMLidList[EBML_ID_PIXELCROPRIGHT] = 'PixelCropRight';
1660
- $EBMLidList[EBML_ID_PIXELCROPTOP] = 'PixelCropTop';
1661
- $EBMLidList[EBML_ID_PIXELHEIGHT] = 'PixelHeight';
1662
- $EBMLidList[EBML_ID_PIXELWIDTH] = 'PixelWidth';
1663
- $EBMLidList[EBML_ID_PREVFILENAME] = 'PrevFilename';
1664
- $EBMLidList[EBML_ID_PREVUID] = 'PrevUID';
1665
- $EBMLidList[EBML_ID_SAMPLINGFREQUENCY] = 'SamplingFrequency';
1666
- $EBMLidList[EBML_ID_SEEK] = 'Seek';
1667
- $EBMLidList[EBML_ID_SEEKHEAD] = 'SeekHead';
1668
- $EBMLidList[EBML_ID_SEEKID] = 'SeekID';
1669
- $EBMLidList[EBML_ID_SEEKPOSITION] = 'SeekPosition';
1670
- $EBMLidList[EBML_ID_SEGMENTFAMILY] = 'SegmentFamily';
1671
- $EBMLidList[EBML_ID_SEGMENTFILENAME] = 'SegmentFilename';
1672
- $EBMLidList[EBML_ID_SEGMENTUID] = 'SegmentUID';
1673
- $EBMLidList[EBML_ID_SIMPLETAG] = 'SimpleTag';
1674
- $EBMLidList[EBML_ID_CLUSTERSLICES] = 'ClusterSlices';
1675
- $EBMLidList[EBML_ID_STEREOMODE] = 'StereoMode';
1676
- $EBMLidList[EBML_ID_TAG] = 'Tag';
1677
- $EBMLidList[EBML_ID_TAGBINARY] = 'TagBinary';
1678
- $EBMLidList[EBML_ID_TAGCHAPTERUID] = 'TagChapterUID';
1679
- $EBMLidList[EBML_ID_TAGDEFAULT] = 'TagDefault';
1680
- $EBMLidList[EBML_ID_TAGEDITIONUID] = 'TagEditionUID';
1681
- $EBMLidList[EBML_ID_TAGLANGUAGE] = 'TagLanguage';
1682
- $EBMLidList[EBML_ID_TAGNAME] = 'TagName';
1683
- $EBMLidList[EBML_ID_TAGTRACKUID] = 'TagTrackUID';
1684
- $EBMLidList[EBML_ID_TAGS] = 'Tags';
1685
- $EBMLidList[EBML_ID_TAGSTRING] = 'TagString';
1686
- $EBMLidList[EBML_ID_TARGETS] = 'Targets';
1687
- $EBMLidList[EBML_ID_TARGETTYPE] = 'TargetType';
1688
- $EBMLidList[EBML_ID_TARGETTYPEVALUE] = 'TargetTypeValue';
1689
- $EBMLidList[EBML_ID_TIMECODESCALE] = 'TimecodeScale';
1690
- $EBMLidList[EBML_ID_TITLE] = 'Title';
1691
- $EBMLidList[EBML_ID_TRACKENTRY] = 'TrackEntry';
1692
- $EBMLidList[EBML_ID_TRACKNUMBER] = 'TrackNumber';
1693
- $EBMLidList[EBML_ID_TRACKOFFSET] = 'TrackOffset';
1694
- $EBMLidList[EBML_ID_TRACKOVERLAY] = 'TrackOverlay';
1695
- $EBMLidList[EBML_ID_TRACKS] = 'Tracks';
1696
- $EBMLidList[EBML_ID_TRACKTIMECODESCALE] = 'TrackTimecodeScale';
1697
- $EBMLidList[EBML_ID_TRACKTRANSLATE] = 'TrackTranslate';
1698
- $EBMLidList[EBML_ID_TRACKTRANSLATECODEC] = 'TrackTranslateCodec';
1699
- $EBMLidList[EBML_ID_TRACKTRANSLATEEDITIONUID] = 'TrackTranslateEditionUID';
1700
- $EBMLidList[EBML_ID_TRACKTRANSLATETRACKID] = 'TrackTranslateTrackID';
1701
- $EBMLidList[EBML_ID_TRACKTYPE] = 'TrackType';
1702
- $EBMLidList[EBML_ID_TRACKUID] = 'TrackUID';
1703
- $EBMLidList[EBML_ID_VIDEO] = 'Video';
1704
- $EBMLidList[EBML_ID_VOID] = 'Void';
1705
- $EBMLidList[EBML_ID_WRITINGAPP] = 'WritingApp';
1706
- }
1707
- return (isset($EBMLidList[$value]) ? $EBMLidList[$value] : dechex($value));
1708
- }
1709
-
1710
- }
1711
-
1712
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /////////////////////////////////////////////////////////////////
3
+ /// getID3() by James Heinrich <info@getid3.org> //
4
+ // available at http://getid3.sourceforge.net //
5
+ // or http://www.getid3.org //
6
+ /////////////////////////////////////////////////////////////////
7
+ // See readme.txt for more details //
8
+ /////////////////////////////////////////////////////////////////
9
+ // //
10
+ // module.audio-video.matriska.php //
11
+ // module for analyzing Matroska containers //
12
+ // dependencies: NONE //
13
+ // ///
14
+ /////////////////////////////////////////////////////////////////
15
+
16
+
17
+ define('EBML_ID_CHAPTERS', 0x0043A770); // [10][43][A7][70] -- A system to define basic menus and partition data. For more detailed information, look at the Chapters Explanation.
18
+ define('EBML_ID_SEEKHEAD', 0x014D9B74); // [11][4D][9B][74] -- Contains the position of other level 1 elements.
19
+ define('EBML_ID_TAGS', 0x0254C367); // [12][54][C3][67] -- Element containing elements specific to Tracks/Chapters. A list of valid tags can be found <http://www.matroska.org/technical/specs/tagging/index.html>.
20
+ define('EBML_ID_INFO', 0x0549A966); // [15][49][A9][66] -- Contains miscellaneous general information and statistics on the file.
21
+ define('EBML_ID_TRACKS', 0x0654AE6B); // [16][54][AE][6B] -- A top-level block of information with many tracks described.
22
+ define('EBML_ID_SEGMENT', 0x08538067); // [18][53][80][67] -- This element contains all other top-level (level 1) elements. Typically a Matroska file is composed of 1 segment.
23
+ define('EBML_ID_ATTACHMENTS', 0x0941A469); // [19][41][A4][69] -- Contain attached files.
24
+ define('EBML_ID_EBML', 0x0A45DFA3); // [1A][45][DF][A3] -- Set the EBML characteristics of the data to follow. Each EBML document has to start with this.
25
+ define('EBML_ID_CUES', 0x0C53BB6B); // [1C][53][BB][6B] -- A top-level element to speed seeking access. All entries are local to the segment.
26
+ define('EBML_ID_CLUSTER', 0x0F43B675); // [1F][43][B6][75] -- The lower level element containing the (monolithic) Block structure.
27
+ define('EBML_ID_LANGUAGE', 0x02B59C); // [22][B5][9C] -- Specifies the language of the track in the Matroska languages form.
28
+ define('EBML_ID_TRACKTIMECODESCALE', 0x03314F); // [23][31][4F] -- The scale to apply on this track to work at normal speed in relation with other tracks (mostly used to adjust video speed when the audio length differs).
29
+ define('EBML_ID_DEFAULTDURATION', 0x03E383); // [23][E3][83] -- Number of nanoseconds (i.e. not scaled) per frame.
30
+ define('EBML_ID_CODECNAME', 0x058688); // [25][86][88] -- A human-readable string specifying the codec.
31
+ define('EBML_ID_CODECDOWNLOADURL', 0x06B240); // [26][B2][40] -- A URL to download about the codec used.
32
+ define('EBML_ID_TIMECODESCALE', 0x0AD7B1); // [2A][D7][B1] -- Timecode scale in nanoseconds (1.000.000 means all timecodes in the segment are expressed in milliseconds).
33
+ define('EBML_ID_COLOURSPACE', 0x0EB524); // [2E][B5][24] -- Same value as in AVI (32 bits).
34
+ define('EBML_ID_GAMMAVALUE', 0x0FB523); // [2F][B5][23] -- Gamma Value.
35
+ define('EBML_ID_CODECSETTINGS', 0x1A9697); // [3A][96][97] -- A string describing the encoding setting used.
36
+ define('EBML_ID_CODECINFOURL', 0x1B4040); // [3B][40][40] -- A URL to find information about the codec used.
37
+ define('EBML_ID_PREVFILENAME', 0x1C83AB); // [3C][83][AB] -- An escaped filename corresponding to the previous segment.
38
+ define('EBML_ID_PREVUID', 0x1CB923); // [3C][B9][23] -- A unique ID to identify the previous chained segment (128 bits).
39
+ define('EBML_ID_NEXTFILENAME', 0x1E83BB); // [3E][83][BB] -- An escaped filename corresponding to the next segment.
40
+ define('EBML_ID_NEXTUID', 0x1EB923); // [3E][B9][23] -- A unique ID to identify the next chained segment (128 bits).
41
+ define('EBML_ID_CONTENTCOMPALGO', 0x0254); // [42][54] -- The compression algorithm used. Algorithms that have been specified so far are:
42
+ define('EBML_ID_CONTENTCOMPSETTINGS', 0x0255); // [42][55] -- Settings that might be needed by the decompressor. For Header Stripping (ContentCompAlgo=3), the bytes that were removed from the beggining of each frames of the track.
43
+ define('EBML_ID_DOCTYPE', 0x0282); // [42][82] -- A string that describes the type of document that follows this EBML header ('matroska' in our case).
44
+ define('EBML_ID_DOCTYPEREADVERSION', 0x0285); // [42][85] -- The minimum DocType version an interpreter has to support to read this file.
45
+ define('EBML_ID_EBMLVERSION', 0x0286); // [42][86] -- The version of EBML parser used to create the file.
46
+ define('EBML_ID_DOCTYPEVERSION', 0x0287); // [42][87] -- The version of DocType interpreter used to create the file.
47
+ define('EBML_ID_EBMLMAXIDLENGTH', 0x02F2); // [42][F2] -- The maximum length of the IDs you'll find in this file (4 or less in Matroska).
48
+ define('EBML_ID_EBMLMAXSIZELENGTH', 0x02F3); // [42][F3] -- The maximum length of the sizes you'll find in this file (8 or less in Matroska). This does not override the element size indicated at the beginning of an element. Elements that have an indicated size which is larger than what is allowed by EBMLMaxSizeLength shall be considered invalid.
49
+ define('EBML_ID_EBMLREADVERSION', 0x02F7); // [42][F7] -- The minimum EBML version a parser has to support to read this file.
50
+ define('EBML_ID_CHAPLANGUAGE', 0x037C); // [43][7C] -- The languages corresponding to the string, in the bibliographic ISO-639-2 form.
51
+ define('EBML_ID_CHAPCOUNTRY', 0x037E); // [43][7E] -- The countries corresponding to the string, same 2 octets as in Internet domains.
52
+ define('EBML_ID_SEGMENTFAMILY', 0x0444); // [44][44] -- A randomly generated unique ID that all segments related to each other must use (128 bits).
53
+ define('EBML_ID_DATEUTC', 0x0461); // [44][61] -- Date of the origin of timecode (value 0), i.e. production date.
54
+ define('EBML_ID_TAGLANGUAGE', 0x047A); // [44][7A] -- Specifies the language of the tag specified, in the Matroska languages form.
55
+ define('EBML_ID_TAGDEFAULT', 0x0484); // [44][84] -- Indication to know if this is the default/original language to use for the given tag.
56
+ define('EBML_ID_TAGBINARY', 0x0485); // [44][85] -- The values of the Tag if it is binary. Note that this cannot be used in the same SimpleTag as TagString.
57
+ define('EBML_ID_TAGSTRING', 0x0487); // [44][87] -- The value of the Tag.
58
+ define('EBML_ID_DURATION', 0x0489); // [44][89] -- Duration of the segment (based on TimecodeScale).
59
+ define('EBML_ID_CHAPPROCESSPRIVATE', 0x050D); // [45][0D] -- Some optional data attached to the ChapProcessCodecID information. For ChapProcessCodecID = 1, it is the "DVD level" equivalent.
60
+ define('EBML_ID_CHAPTERFLAGENABLED', 0x0598); // [45][98] -- Specify wether the chapter is enabled. It can be enabled/disabled by a Control Track. When disabled, the movie should skip all the content between the TimeStart and TimeEnd of this chapter.
61
+ define('EBML_ID_TAGNAME', 0x05A3); // [45][A3] -- The name of the Tag that is going to be stored.
62
+ define('EBML_ID_EDITIONENTRY', 0x05B9); // [45][B9] -- Contains all information about a segment edition.
63
+ define('EBML_ID_EDITIONUID', 0x05BC); // [45][BC] -- A unique ID to identify the edition. It's useful for tagging an edition.
64
+ define('EBML_ID_EDITIONFLAGHIDDEN', 0x05BD); // [45][BD] -- If an edition is hidden (1), it should not be available to the user interface (but still to Control Tracks).
65
+ define('EBML_ID_EDITIONFLAGDEFAULT', 0x05DB); // [45][DB] -- If a flag is set (1) the edition should be used as the default one.
66
+ define('EBML_ID_EDITIONFLAGORDERED', 0x05DD); // [45][DD] -- Specify if the chapters can be defined multiple times and the order to play them is enforced.
67
+ define('EBML_ID_FILEDATA', 0x065C); // [46][5C] -- The data of the file.
68
+ define('EBML_ID_FILEMIMETYPE', 0x0660); // [46][60] -- MIME type of the file.
69
+ define('EBML_ID_FILENAME', 0x066E); // [46][6E] -- Filename of the attached file.
70
+ define('EBML_ID_FILEREFERRAL', 0x0675); // [46][75] -- A binary value that a track/codec can refer to when the attachment is needed.
71
+ define('EBML_ID_FILEDESCRIPTION', 0x067E); // [46][7E] -- A human-friendly name for the attached file.
72
+ define('EBML_ID_FILEUID', 0x06AE); // [46][AE] -- Unique ID representing the file, as random as possible.
73
+ define('EBML_ID_CONTENTENCALGO', 0x07E1); // [47][E1] -- The encryption algorithm used. The value '0' means that the contents have not been encrypted but only signed. Predefined values:
74
+ define('EBML_ID_CONTENTENCKEYID', 0x07E2); // [47][E2] -- For public key algorithms this is the ID of the public key the the data was encrypted with.
75
+ define('EBML_ID_CONTENTSIGNATURE', 0x07E3); // [47][E3] -- A cryptographic signature of the contents.
76
+ define('EBML_ID_CONTENTSIGKEYID', 0x07E4); // [47][E4] -- This is the ID of the private key the data was signed with.
77
+ define('EBML_ID_CONTENTSIGALGO', 0x07E5); // [47][E5] -- The algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values:
78
+ define('EBML_ID_CONTENTSIGHASHALGO', 0x07E6); // [47][E6] -- The hash algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values:
79
+ define('EBML_ID_MUXINGAPP', 0x0D80); // [4D][80] -- Muxing application or library ("libmatroska-0.4.3").
80
+ define('EBML_ID_SEEK', 0x0DBB); // [4D][BB] -- Contains a single seek entry to an EBML element.
81
+ define('EBML_ID_CONTENTENCODINGORDER', 0x1031); // [50][31] -- Tells when this modification was used during encoding/muxing starting with 0 and counting upwards. The decoder/demuxer has to start with the highest order number it finds and work its way down. This value has to be unique over all ContentEncodingOrder elements in the segment.
82
+ define('EBML_ID_CONTENTENCODINGSCOPE', 0x1032); // [50][32] -- A bit field that describes which elements have been modified in this way. Values (big endian) can be OR'ed. Possible values:
83
+ define('EBML_ID_CONTENTENCODINGTYPE', 0x1033); // [50][33] -- A value describing what kind of transformation has been done. Possible values:
84
+ define('EBML_ID_CONTENTCOMPRESSION', 0x1034); // [50][34] -- Settings describing the compression used. Must be present if the value of ContentEncodingType is 0 and absent otherwise. Each block must be decompressable even if no previous block is available in order not to prevent seeking.
85
+ define('EBML_ID_CONTENTENCRYPTION', 0x1035); // [50][35] -- Settings describing the encryption used. Must be present if the value of ContentEncodingType is 1 and absent otherwise.
86
+ define('EBML_ID_CUEREFNUMBER', 0x135F); // [53][5F] -- Number of the referenced Block of Track X in the specified Cluster.
87
+ define('EBML_ID_NAME', 0x136E); // [53][6E] -- A human-readable track name.
88
+ define('EBML_ID_CUEBLOCKNUMBER', 0x1378); // [53][78] -- Number of the Block in the specified Cluster.
89
+ define('EBML_ID_TRACKOFFSET', 0x137F); // [53][7F] -- A value to add to the Block's Timecode. This can be used to adjust the playback offset of a track.
90
+ define('EBML_ID_SEEKID', 0x13AB); // [53][AB] -- The binary ID corresponding to the element name.
91
+ define('EBML_ID_SEEKPOSITION', 0x13AC); // [53][AC] -- The position of the element in the segment in octets (0 = first level 1 element).
92
+ define('EBML_ID_STEREOMODE', 0x13B8); // [53][B8] -- Stereo-3D video mode.
93
+ define('EBML_ID_OLDSTEREOMODE', 0x13B9); // [53][B9] -- Bogus StereoMode value used in old versions of libmatroska. DO NOT USE. (0: mono, 1: right eye, 2: left eye, 3: both eyes).
94
+ define('EBML_ID_PIXELCROPBOTTOM', 0x14AA); // [54][AA] -- The number of video pixels to remove at the bottom of the image (for HDTV content).
95
+ define('EBML_ID_DISPLAYWIDTH', 0x14B0); // [54][B0] -- Width of the video frames to display.
96
+ define('EBML_ID_DISPLAYUNIT', 0x14B2); // [54][B2] -- Type of the unit for DisplayWidth/Height (0: pixels, 1: centimeters, 2: inches).
97
+ define('EBML_ID_ASPECTRATIOTYPE', 0x14B3); // [54][B3] -- Specify the possible modifications to the aspect ratio (0: free resizing, 1: keep aspect ratio, 2: fixed).
98
+ define('EBML_ID_DISPLAYHEIGHT', 0x14BA); // [54][BA] -- Height of the video frames to display.
99
+ define('EBML_ID_PIXELCROPTOP', 0x14BB); // [54][BB] -- The number of video pixels to remove at the top of the image.
100
+ define('EBML_ID_PIXELCROPLEFT', 0x14CC); // [54][CC] -- The number of video pixels to remove on the left of the image.
101
+ define('EBML_ID_PIXELCROPRIGHT', 0x14DD); // [54][DD] -- The number of video pixels to remove on the right of the image.
102
+ define('EBML_ID_FLAGFORCED', 0x15AA); // [55][AA] -- Set if that track MUST be used during playback. There can be many forced track for a kind (audio, video or subs), the player should select the one which language matches the user preference or the default + forced track. Overlay MAY happen between a forced and non-forced track of the same kind.
103
+ define('EBML_ID_MAXBLOCKADDITIONID', 0x15EE); // [55][EE] -- The maximum value of BlockAddID. A value 0 means there is no BlockAdditions for this track.
104
+ define('EBML_ID_WRITINGAPP', 0x1741); // [57][41] -- Writing application ("mkvmerge-0.3.3").
105
+ define('EBML_ID_CLUSTERSILENTTRACKS', 0x1854); // [58][54] -- The list of tracks that are not used in that part of the stream. It is useful when using overlay tracks on seeking. Then you should decide what track to use.
106
+ define('EBML_ID_CLUSTERSILENTTRACKNUMBER', 0x18D7); // [58][D7] -- One of the track number that are not used from now on in the stream. It could change later if not specified as silent in a further Cluster.
107
+ define('EBML_ID_ATTACHEDFILE', 0x21A7); // [61][A7] -- An attached file.
108
+ define('EBML_ID_CONTENTENCODING', 0x2240); // [62][40] -- Settings for one content encoding like compression or encryption.
109
+ define('EBML_ID_BITDEPTH', 0x2264); // [62][64] -- Bits per sample, mostly used for PCM.
110
+ define('EBML_ID_CODECPRIVATE', 0x23A2); // [63][A2] -- Private data only known to the codec.
111
+ define('EBML_ID_TARGETS', 0x23C0); // [63][C0] -- Contain all UIDs where the specified meta data apply. It is void to describe everything in the segment.
112
+ define('EBML_ID_CHAPTERPHYSICALEQUIV', 0x23C3); // [63][C3] -- Specify the physical equivalent of this ChapterAtom like "DVD" (60) or "SIDE" (50), see complete list of values.
113
+ define('EBML_ID_TAGCHAPTERUID', 0x23C4); // [63][C4] -- A unique ID to identify the Chapter(s) the tags belong to. If the value is 0 at this level, the tags apply to all chapters in the Segment.
114
+ define('EBML_ID_TAGTRACKUID', 0x23C5); // [63][C5] -- A unique ID to identify the Track(s) the tags belong to. If the value is 0 at this level, the tags apply to all tracks in the Segment.
115
+ define('EBML_ID_TAGATTACHMENTUID', 0x23C6); // [63][C6] -- A unique ID to identify the Attachment(s) the tags belong to. If the value is 0 at this level, the tags apply to all the attachments in the Segment.
116
+ define('EBML_ID_TAGEDITIONUID', 0x23C9); // [63][C9] -- A unique ID to identify the EditionEntry(s) the tags belong to. If the value is 0 at this level, the tags apply to all editions in the Segment.
117
+ define('EBML_ID_TARGETTYPE', 0x23CA); // [63][CA] -- An informational string that can be used to display the logical level of the target like "ALBUM", "TRACK", "MOVIE", "CHAPTER", etc (see TargetType).
118
+ define('EBML_ID_TRACKTRANSLATE', 0x2624); // [66][24] -- The track identification for the given Chapter Codec.
119
+ define('EBML_ID_TRACKTRANSLATETRACKID', 0x26A5); // [66][A5] -- The binary value used to represent this track in the chapter codec data. The format depends on the ChapProcessCodecID used.
120
+ define('EBML_ID_TRACKTRANSLATECODEC', 0x26BF); // [66][BF] -- The chapter codec using this ID (0: Matroska Script, 1: DVD-menu).
121
+ define('EBML_ID_TRACKTRANSLATEEDITIONUID', 0x26FC); // [66][FC] -- Specify an edition UID on which this translation applies. When not specified, it means for all editions found in the segment.
122
+ define('EBML_ID_SIMPLETAG', 0x27C8); // [67][C8] -- Contains general information about the target.
123
+ define('EBML_ID_TARGETTYPEVALUE', 0x28CA); // [68][CA] -- A number to indicate the logical level of the target (see TargetType).
124
+ define('EBML_ID_CHAPPROCESSCOMMAND', 0x2911); // [69][11] -- Contains all the commands associated to the Atom.
125
+ define('EBML_ID_CHAPPROCESSTIME', 0x2922); // [69][22] -- Defines when the process command should be handled (0: during the whole chapter, 1: before starting playback, 2: after playback of the chapter).
126
+ define('EBML_ID_CHAPTERTRANSLATE', 0x2924); // [69][24] -- A tuple of corresponding ID used by chapter codecs to represent this segment.
127
+ define('EBML_ID_CHAPPROCESSDATA', 0x2933); // [69][33] -- Contains the command information. The data should be interpreted depending on the ChapProcessCodecID value. For ChapProcessCodecID = 1, the data correspond to the binary DVD cell pre/post commands.
128
+ define('EBML_ID_CHAPPROCESS', 0x2944); // [69][44] -- Contains all the commands associated to the Atom.
129
+ define('EBML_ID_CHAPPROCESSCODECID', 0x2955); // [69][55] -- Contains the type of the codec used for the processing. A value of 0 means native Matroska processing (to be defined), a value of 1 means the DVD command set is used. More codec IDs can be added later.
130
+ define('EBML_ID_CHAPTERTRANSLATEID', 0x29A5); // [69][A5] -- The binary value used to represent this segment in the chapter codec data. The format depends on the ChapProcessCodecID used.
131
+ define('EBML_ID_CHAPTERTRANSLATECODEC', 0x29BF); // [69][BF] -- The chapter codec using this ID (0: Matroska Script, 1: DVD-menu).
132
+ define('EBML_ID_CHAPTERTRANSLATEEDITIONUID', 0x29FC); // [69][FC] -- Specify an edition UID on which this correspondance applies. When not specified, it means for all editions found in the segment.
133
+ define('EBML_ID_CONTENTENCODINGS', 0x2D80); // [6D][80] -- Settings for several content encoding mechanisms like compression or encryption.
134
+ define('EBML_ID_MINCACHE', 0x2DE7); // [6D][E7] -- The minimum number of frames a player should be able to cache during playback. If set to 0, the reference pseudo-cache system is not used.
135
+ define('EBML_ID_MAXCACHE', 0x2DF8); // [6D][F8] -- The maximum cache size required to store referenced frames in and the current frame. 0 means no cache is needed.
136
+ define('EBML_ID_CHAPTERSEGMENTUID', 0x2E67); // [6E][67] -- A segment to play in place of this chapter. Edition ChapterSegmentEditionUID should be used for this segment, otherwise no edition is used.
137
+ define('EBML_ID_CHAPTERSEGMENTEDITIONUID', 0x2EBC); // [6E][BC] -- The edition to play from the segment linked in ChapterSegmentUID.
138
+ define('EBML_ID_TRACKOVERLAY', 0x2FAB); // [6F][AB] -- Specify that this track is an overlay track for the Track specified (in the u-integer). That means when this track has a gap (see SilentTracks) the overlay track should be used instead. The order of multiple TrackOverlay matters, the first one is the one that should be used. If not found it should be the second, etc.
139
+ define('EBML_ID_TAG', 0x3373); // [73][73] -- Element containing elements specific to Tracks/Chapters.
140
+ define('EBML_ID_SEGMENTFILENAME', 0x3384); // [73][84] -- A filename corresponding to this segment.
141
+ define('EBML_ID_SEGMENTUID', 0x33A4); // [73][A4] -- A randomly generated unique ID to identify the current segment between many others (128 bits).
142
+ define('EBML_ID_CHAPTERUID', 0x33C4); // [73][C4] -- A unique ID to identify the Chapter.
143
+ define('EBML_ID_TRACKUID', 0x33C5); // [73][C5] -- A unique ID to identify the Track. This should be kept the same when making a direct stream copy of the Track to another file.
144
+ define('EBML_ID_ATTACHMENTLINK', 0x3446); // [74][46] -- The UID of an attachment that is used by this codec.
145
+ define('EBML_ID_CLUSTERBLOCKADDITIONS', 0x35A1); // [75][A1] -- Contain additional blocks to complete the main one. An EBML parser that has no knowledge of the Block structure could still see and use/skip these data.
146
+ define('EBML_ID_CHANNELPOSITIONS', 0x347B); // [7D][7B] -- Table of horizontal angles for each successive channel, see appendix.
147
+ define('EBML_ID_OUTPUTSAMPLINGFREQUENCY', 0x38B5); // [78][B5] -- Real output sampling frequency in Hz (used for SBR techniques).
148
+ define('EBML_ID_TITLE', 0x3BA9); // [7B][A9] -- General name of the segment.
149
+ define('EBML_ID_CHAPTERDISPLAY', 0x00); // [80] -- Contains all possible strings to use for the chapter display.
150
+ define('EBML_ID_TRACKTYPE', 0x03); // [83] -- A set of track types coded on 8 bits (1: video, 2: audio, 3: complex, 0x10: logo, 0x11: subtitle, 0x12: buttons, 0x20: control).
151
+ define('EBML_ID_CHAPSTRING', 0x05); // [85] -- Contains the string to use as the chapter atom.
152
+ define('EBML_ID_CODECID', 0x06); // [86] -- An ID corresponding to the codec, see the codec page for more info.
153
+ define('EBML_ID_FLAGDEFAULT', 0x08); // [88] -- Set if that track (audio, video or subs) SHOULD be used if no language found matches the user preference.
154
+ define('EBML_ID_CHAPTERTRACKNUMBER', 0x09); // [89] -- UID of the Track to apply this chapter too. In the absense of a control track, choosing this chapter will select the listed Tracks and deselect unlisted tracks. Absense of this element indicates that the Chapter should be applied to any currently used Tracks.
155
+ define('EBML_ID_CLUSTERSLICES', 0x0E); // [8E] -- Contains slices description.
156
+ define('EBML_ID_CHAPTERTRACK', 0x0F); // [8F] -- List of tracks on which the chapter applies. If this element is not present, all tracks apply
157
+ define('EBML_ID_CHAPTERTIMESTART', 0x11); // [91] -- Timecode of the start of Chapter (not scaled).
158
+ define('EBML_ID_CHAPTERTIMEEND', 0x12); // [92] -- Timecode of the end of Chapter (timecode excluded, not scaled).
159
+ define('EBML_ID_CUEREFTIME', 0x16); // [96] -- Timecode of the referenced Block.
160
+ define('EBML_ID_CUEREFCLUSTER', 0x17); // [97] -- Position of the Cluster containing the referenced Block.
161
+ define('EBML_ID_CHAPTERFLAGHIDDEN', 0x18); // [98] -- If a chapter is hidden (1), it should not be available to the user interface (but still to Control Tracks).
162
+ define('EBML_ID_FLAGINTERLACED', 0x1A); // [9A] -- Set if the video is interlaced.
163
+ define('EBML_ID_CLUSTERBLOCKDURATION', 0x1B); // [9B] -- The duration of the Block (based on TimecodeScale). This element is mandatory when DefaultDuration is set for the track. When not written and with no DefaultDuration, the value is assumed to be the difference between the timecode of this Block and the timecode of the next Block in "display" order (not coding order). This element can be useful at the end of a Track (as there is not other Block available), or when there is a break in a track like for subtitle tracks.
164
+ define('EBML_ID_FLAGLACING', 0x1C); // [9C] -- Set if the track may contain blocks using lacing.
165
+ define('EBML_ID_CHANNELS', 0x1F); // [9F] -- Numbers of channels in the track.
166
+ define('EBML_ID_CLUSTERBLOCKGROUP', 0x20); // [A0] -- Basic container of information containing a single Block or BlockVirtual, and information specific to that Block/VirtualBlock.
167
+ define('EBML_ID_CLUSTERBLOCK', 0x21); // [A1] -- Block containing the actual data to be rendered and a timecode relative to the Cluster Timecode.
168
+ define('EBML_ID_CLUSTERBLOCKVIRTUAL', 0x22); // [A2] -- A Block with no data. It must be stored in the stream at the place the real Block should be in display order.
169
+ define('EBML_ID_CLUSTERSIMPLEBLOCK', 0x23); // [A3] -- Similar to Block but without all the extra information, mostly used to reduced overhead when no extra feature is needed.
170
+ define('EBML_ID_CLUSTERCODECSTATE', 0x24); // [A4] -- The new codec state to use. Data interpretation is private to the codec. This information should always be referenced by a seek entry.
171
+ define('EBML_ID_CLUSTERBLOCKADDITIONAL', 0x25); // [A5] -- Interpreted by the codec as it wishes (using the BlockAddID).
172
+ define('EBML_ID_CLUSTERBLOCKMORE', 0x26); // [A6] -- Contain the BlockAdditional and some parameters.
173
+ define('EBML_ID_CLUSTERPOSITION', 0x27); // [A7] -- Position of the Cluster in the segment (0 in live broadcast streams). It might help to resynchronise offset on damaged streams.
174
+ define('EBML_ID_CODECDECODEALL', 0x2A); // [AA] -- The codec can decode potentially damaged data.
175
+ define('EBML_ID_CLUSTERPREVSIZE', 0x2B); // [AB] -- Size of the previous Cluster, in octets. Can be useful for backward playing.
176
+ define('EBML_ID_TRACKENTRY', 0x2E); // [AE] -- Describes a track with all elements.
177
+ define('EBML_ID_CLUSTERENCRYPTEDBLOCK', 0x2F); // [AF] -- Similar to SimpleBlock but the data inside the Block are Transformed (encrypt and/or signed).
178
+ define('EBML_ID_PIXELWIDTH', 0x30); // [B0] -- Width of the encoded video frames in pixels.
179
+ define('EBML_ID_CUETIME', 0x33); // [B3] -- Absolute timecode according to the segment time base.
180
+ define('EBML_ID_SAMPLINGFREQUENCY', 0x35); // [B5] -- Sampling frequency in Hz.
181
+ define('EBML_ID_CHAPTERATOM', 0x36); // [B6] -- Contains the atom information to use as the chapter atom (apply to all tracks).
182
+ define('EBML_ID_CUETRACKPOSITIONS', 0x37); // [B7] -- Contain positions for different tracks corresponding to the timecode.
183
+ define('EBML_ID_FLAGENABLED', 0x39); // [B9] -- Set if the track is used.
184
+ define('EBML_ID_PIXELHEIGHT', 0x3A); // [BA] -- Height of the encoded video frames in pixels.
185
+ define('EBML_ID_CUEPOINT', 0x3B); // [BB] -- Contains all information relative to a seek point in the segment.
186
+ define('EBML_ID_CRC32', 0x3F); // [BF] -- The CRC is computed on all the data of the Master element it's in, regardless of its position. It's recommended to put the CRC value at the beggining of the Master element for easier reading. All level 1 elements should include a CRC-32.
187
+ define('EBML_ID_CLUSTERBLOCKADDITIONID', 0x4B); // [CB] -- The ID of the BlockAdditional element (0 is the main Block).
188
+ define('EBML_ID_CLUSTERLACENUMBER', 0x4C); // [CC] -- The reverse number of the frame in the lace (0 is the last frame, 1 is the next to last, etc). While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback.
189
+ define('EBML_ID_CLUSTERFRAMENUMBER', 0x4D); // [CD] -- The number of the frame to generate from this lace with this delay (allow you to generate many frames from the same Block/Frame).
190
+ define('EBML_ID_CLUSTERDELAY', 0x4E); // [CE] -- The (scaled) delay to apply to the element.
191
+ define('EBML_ID_CLUSTERDURATION', 0x4F); // [CF] -- The (scaled) duration to apply to the element.
192
+ define('EBML_ID_TRACKNUMBER', 0x57); // [D7] -- The track number as used in the Block Header (using more than 127 tracks is not encouraged, though the design allows an unlimited number).
193
+ define('EBML_ID_CUEREFERENCE', 0x5B); // [DB] -- The Clusters containing the required referenced Blocks.
194
+ define('EBML_ID_VIDEO', 0x60); // [E0] -- Video settings.
195
+ define('EBML_ID_AUDIO', 0x61); // [E1] -- Audio settings.
196
+ define('EBML_ID_CLUSTERTIMESLICE', 0x68); // [E8] -- Contains extra time information about the data contained in the Block. While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback.
197
+ define('EBML_ID_CUECODECSTATE', 0x6A); // [EA] -- The position of the Codec State corresponding to this Cue element. 0 means that the data is taken from the initial Track Entry.
198
+ define('EBML_ID_CUEREFCODECSTATE', 0x6B); // [EB] -- The position of the Codec State corresponding to this referenced element. 0 means that the data is taken from the initial Track Entry.
199
+ define('EBML_ID_VOID', 0x6C); // [EC] -- Used to void damaged data, to avoid unexpected behaviors when using damaged data. The content is discarded. Also used to reserve space in a sub-element for later use.
200
+ define('EBML_ID_CLUSTERTIMECODE', 0x67); // [E7] -- Absolute timecode of the cluster (based on TimecodeScale).
201
+ define('EBML_ID_CLUSTERBLOCKADDID', 0x6E); // [EE] -- An ID to identify the BlockAdditional level.
202
+ define('EBML_ID_CUECLUSTERPOSITION', 0x71); // [F1] -- The position of the Cluster containing the required Block.
203
+ define('EBML_ID_CUETRACK', 0x77); // [F7] -- The track for which a position is given.
204
+ define('EBML_ID_CLUSTERREFERENCEPRIORITY', 0x7A); // [FA] -- This frame is referenced and has the specified cache priority. In cache only a frame of the same or higher priority can replace this frame. A value of 0 means the frame is not referenced.
205
+ define('EBML_ID_CLUSTERREFERENCEBLOCK', 0x7B); // [FB] -- Timecode of another frame used as a reference (ie: B or P frame). The timecode is relative to the block it's attached to.
206
+ define('EBML_ID_CLUSTERREFERENCEVIRTUAL', 0x7D); // [FD] -- Relative position of the data that should be in position of the virtual block.
207
+
208
+
209
+ /**
210
+ * @tutorial http://www.matroska.org/technical/specs/index.html
211
+ *
212
+ * @todo Rewrite EBML parser to reduce it's size and honor default element values
213
+ * @todo After rewrite implement stream size calculation, that will provide additional useful info and enable AAC/FLAC audio bitrate detection
214
+ */
215
+ class getid3_matroska extends getid3_handler
216
+ {
217
+ // public options
218
+ public static $hide_clusters = true; // if true, do not return information about CLUSTER chunks, since there's a lot of them and they're not usually useful [default: TRUE]
219
+ public static $parse_whole_file = false; // true to parse the whole file, not only header [default: FALSE]
220
+
221
+ // private parser settings/placeholders
222
+ private $EBMLbuffer = '';
223
+ private $EBMLbuffer_offset = 0;
224
+ private $EBMLbuffer_length = 0;
225
+ private $current_offset = 0;
226
+ private $unuseful_elements = array(EBML_ID_CRC32, EBML_ID_VOID);
227
+
228
+ public function Analyze()
229
+ {
230
+ $info = &$this->getid3->info;
231
+
232
+ // parse container
233
+ try {
234
+ $this->parseEBML($info);
235
+ } catch (Exception $e) {
236
+ $info['error'][] = 'EBML parser: '.$e->getMessage();
237
+ }
238
+
239
+ // calculate playtime
240
+ if (isset($info['matroska']['info']) && is_array($info['matroska']['info'])) {
241
+ foreach ($info['matroska']['info'] as $key => $infoarray) {
242
+ if (isset($infoarray['Duration'])) {
243
+ // TimecodeScale is how many nanoseconds each Duration unit is
244
+ $info['playtime_seconds'] = $infoarray['Duration'] * ((isset($infoarray['TimecodeScale']) ? $infoarray['TimecodeScale'] : 1000000) / 1000000000);
245
+ break;
246
+ }
247
+ }
248
+ }
249
+
250
+ // extract tags
251
+ if (isset($info['matroska']['tags']) && is_array($info['matroska']['tags'])) {
252
+ foreach ($info['matroska']['tags'] as $key => $infoarray) {
253
+ $this->ExtractCommentsSimpleTag($infoarray);
254
+ }
255
+ }
256
+
257
+ // process tracks
258
+ if (isset($info['matroska']['tracks']['tracks']) && is_array($info['matroska']['tracks']['tracks'])) {
259
+ foreach ($info['matroska']['tracks']['tracks'] as $key => $trackarray) {
260
+
261
+ $track_info = array();
262
+ $track_info['dataformat'] = self::CodecIDtoCommonName($trackarray['CodecID']);
263
+ $track_info['default'] = (isset($trackarray['FlagDefault']) ? $trackarray['FlagDefault'] : true);
264
+ if (isset($trackarray['Name'])) { $track_info['name'] = $trackarray['Name']; }
265
+
266
+ switch ($trackarray['TrackType']) {
267
+
268
+ case 1: // Video
269
+ $track_info['resolution_x'] = $trackarray['PixelWidth'];
270
+ $track_info['resolution_y'] = $trackarray['PixelHeight'];
271
+ $track_info['display_unit'] = self::displayUnit(isset($trackarray['DisplayUnit']) ? $trackarray['DisplayUnit'] : 0);
272
+ $track_info['display_x'] = (isset($trackarray['DisplayWidth']) ? $trackarray['DisplayWidth'] : $trackarray['PixelWidth']);
273
+ $track_info['display_y'] = (isset($trackarray['DisplayHeight']) ? $trackarray['DisplayHeight'] : $trackarray['PixelHeight']);
274
+
275
+ if (isset($trackarray['PixelCropBottom'])) { $track_info['crop_bottom'] = $trackarray['PixelCropBottom']; }
276
+ if (isset($trackarray['PixelCropTop'])) { $track_info['crop_top'] = $trackarray['PixelCropTop']; }
277
+ if (isset($trackarray['PixelCropLeft'])) { $track_info['crop_left'] = $trackarray['PixelCropLeft']; }
278
+ if (isset($trackarray['PixelCropRight'])) { $track_info['crop_right'] = $trackarray['PixelCropRight']; }
279
+ if (isset($trackarray['DefaultDuration'])) { $track_info['frame_rate'] = round(1000000000 / $trackarray['DefaultDuration'], 3); }
280
+ if (isset($trackarray['CodecName'])) { $track_info['codec'] = $trackarray['CodecName']; }
281
+
282
+ switch ($trackarray['CodecID']) {
283
+ case 'V_MS/VFW/FOURCC':
284
+ if (!getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, false)) {
285
+ $this->warning('Unable to parse codec private data ['.basename(__FILE__).':'.__LINE__.'] because cannot include "module.audio-video.riff.php"');
286
+ break;
287
+ }
288
+ $parsed = getid3_riff::ParseBITMAPINFOHEADER($trackarray['CodecPrivate']);
289
+ $track_info['codec'] = getid3_riff::fourccLookup($parsed['fourcc']);
290
+ $info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $parsed;
291
+ break;
292
+
293
+ /*case 'V_MPEG4/ISO/AVC':
294
+ $h264['profile'] = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], 1, 1));
295
+ $h264['level'] = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], 3, 1));
296
+ $rn = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], 4, 1));
297
+ $h264['NALUlength'] = ($rn & 3) + 1;
298
+ $rn = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], 5, 1));
299
+ $nsps = ($rn & 31);
300
+ $offset = 6;
301
+ for ($i = 0; $i < $nsps; $i ++) {
302
+ $length = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], $offset, 2));
303
+ $h264['SPS'][] = substr($trackarray['CodecPrivate'], $offset + 2, $length);
304
+ $offset += 2 + $length;
305
+ }
306
+ $npps = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], $offset, 1));
307
+ $offset += 1;
308
+ for ($i = 0; $i < $npps; $i ++) {
309
+ $length = getid3_lib::BigEndian2Int(substr($trackarray['CodecPrivate'], $offset, 2));
310
+ $h264['PPS'][] = substr($trackarray['CodecPrivate'], $offset + 2, $length);
311
+ $offset += 2 + $length;
312
+ }
313
+ $info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $h264;
314
+ break;*/
315
+ }
316
+
317
+ $info['video']['streams'][] = $track_info;
318
+ break;
319
+
320
+ case 2: // Audio
321
+ $track_info['sample_rate'] = (isset($trackarray['SamplingFrequency']) ? $trackarray['SamplingFrequency'] : 8000.0);
322
+ $track_info['channels'] = (isset($trackarray['Channels']) ? $trackarray['Channels'] : 1);
323
+ $track_info['language'] = (isset($trackarray['Language']) ? $trackarray['Language'] : 'eng');
324
+ if (isset($trackarray['BitDepth'])) { $track_info['bits_per_sample'] = $trackarray['BitDepth']; }
325
+ if (isset($trackarray['CodecName'])) { $track_info['codec'] = $trackarray['CodecName']; }
326
+
327
+ switch ($trackarray['CodecID']) {
328
+ case 'A_PCM/INT/LIT':
329
+ case 'A_PCM/INT/BIG':
330
+ $track_info['bitrate'] = $trackarray['SamplingFrequency'] * $trackarray['Channels'] * $trackarray['BitDepth'];
331
+ break;
332
+
333
+ case 'A_AC3':
334
+ case 'A_DTS':
335
+ case 'A_MPEG/L3':
336
+ case 'A_MPEG/L2':
337
+ case 'A_FLAC':
338
+ if (!getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.'.($track_info['dataformat'] == 'mp2' ? 'mp3' : $track_info['dataformat']).'.php', __FILE__, false)) {
339
+ $this->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because cannot include "module.audio.'.$track_info['dataformat'].'.php"');
340
+ break;
341
+ }
342
+
343
+ if (!isset($info['matroska']['track_data_offsets'][$trackarray['TrackNumber']])) {
344
+ $this->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because $info[matroska][track_data_offsets]['.$trackarray['TrackNumber'].'] not set');
345
+ break;
346
+ }
347
+
348
+ // create temp instance
349
+ $getid3_temp = new getID3();
350
+ if ($track_info['dataformat'] != 'flac') {
351
+ $getid3_temp->openfile($this->getid3->filename);
352
+ }
353
+ $getid3_temp->info['avdataoffset'] = $info['matroska']['track_data_offsets'][$trackarray['TrackNumber']]['offset'];
354
+ if ($track_info['dataformat'][0] == 'm' || $track_info['dataformat'] == 'flac') {
355
+ $getid3_temp->info['avdataend'] = $info['matroska']['track_data_offsets'][$trackarray['TrackNumber']]['offset'] + $info['matroska']['track_data_offsets'][$trackarray['TrackNumber']]['length'];
356
+ }
357
+
358
+ // analyze
359
+ $class = 'getid3_'.($track_info['dataformat'] == 'mp2' ? 'mp3' : $track_info['dataformat']);
360
+ $header_data_key = $track_info['dataformat'][0] == 'm' ? 'mpeg' : $track_info['dataformat'];
361
+ $getid3_audio = new $class($getid3_temp, __CLASS__);
362
+ if ($track_info['dataformat'] == 'flac') {
363
+ $getid3_audio->AnalyzeString($trackarray['CodecPrivate']);
364
+ }
365
+ else {
366
+ $getid3_audio->Analyze();
367
+ }
368
+ if (!empty($getid3_temp->info[$header_data_key])) {
369
+ $info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $getid3_temp->info[$header_data_key];
370
+ if (isset($getid3_temp->info['audio']) && is_array($getid3_temp->info['audio'])) {
371
+ foreach ($getid3_temp->info['audio'] as $key => $value) {
372
+ $track_info[$key] = $value;
373
+ }
374
+ }
375
+ }
376
+ else {
377
+ $this->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because '.$class.'::Analyze() failed at offset '.$getid3_temp->info['avdataoffset']);
378
+ }
379
+
380
+ // copy errors and warnings
381
+ if (!empty($getid3_temp->info['error'])) {
382
+ foreach ($getid3_temp->info['error'] as $newerror) {
383
+ $this->warning($class.'() says: ['.$newerror.']');
384
+ }
385
+ }
386
+ if (!empty($getid3_temp->info['warning'])) {
387
+ foreach ($getid3_temp->info['warning'] as $newerror) {
388
+ if ($track_info['dataformat'] == 'mp3' && preg_match('/^Probable truncated file: expecting \d+ bytes of audio data, only found \d+ \(short by \d+ bytes\)$/', $newerror)) {
389
+ // LAME/Xing header is probably set, but audio data is chunked into Matroska file and near-impossible to verify if audio stream is complete, so ignore useless warning
390
+ continue;
391
+ }
392
+ $this->warning($class.'() says: ['.$newerror.']');
393
+ }
394
+ }
395
+ unset($getid3_temp, $getid3_audio);
396
+ break;
397
+
398
+ case 'A_AAC':
399
+ case 'A_AAC/MPEG2/LC':
400
+ case 'A_AAC/MPEG2/LC/SBR':
401
+ case 'A_AAC/MPEG4/LC':
402
+ case 'A_AAC/MPEG4/LC/SBR':
403
+ $this->warning($trackarray['CodecID'].' audio data contains no header, audio/video bitrates can\'t be calculated');
404
+ break;
405
+
406
+ case 'A_VORBIS':
407
+ if (!isset($trackarray['CodecPrivate'])) {
408
+ $this->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because CodecPrivate data not set');
409
+ break;
410
+ }
411
+ $vorbis_offset = strpos($trackarray['CodecPrivate'], 'vorbis', 1);
412
+ if ($vorbis_offset === false) {
413
+ $this->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because CodecPrivate data does not contain "vorbis" keyword');
414
+ break;
415
+ }
416
+ $vorbis_offset -= 1;
417
+
418
+ if (!getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ogg.php', __FILE__, false)) {
419
+ $this->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because cannot include "module.audio.ogg.php"');
420
+ break;
421
+ }
422
+
423
+ // create temp instance
424
+ $getid3_temp = new getID3();
425
+
426
+ // analyze
427
+ $getid3_ogg = new getid3_ogg($getid3_temp);
428
+ $oggpageinfo['page_seqno'] = 0;
429
+ $getid3_ogg->ParseVorbisPageHeader($trackarray['CodecPrivate'], $vorbis_offset, $oggpageinfo);
430
+ if (!empty($getid3_temp->info['ogg'])) {
431
+ $info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $getid3_temp->info['ogg'];
432
+ if (isset($getid3_temp->info['audio']) && is_array($getid3_temp->info['audio'])) {
433
+ foreach ($getid3_temp->info['audio'] as $key => $value) {
434
+ $track_info[$key] = $value;
435
+ }
436
+ }
437
+ }
438
+
439
+ // copy errors and warnings
440
+ if (!empty($getid3_temp->info['error'])) {
441
+ foreach ($getid3_temp->info['error'] as $newerror) {
442
+ $this->warning('getid3_ogg() says: ['.$newerror.']');
443
+ }
444
+ }
445
+ if (!empty($getid3_temp->info['warning'])) {
446
+ foreach ($getid3_temp->info['warning'] as $newerror) {
447
+ $this->warning('getid3_ogg() says: ['.$newerror.']');
448
+ }
449
+ }
450
+
451
+ if (!empty($getid3_temp->info['ogg']['bitrate_nominal'])) {
452
+ $track_info['bitrate'] = $getid3_temp->info['ogg']['bitrate_nominal'];
453
+ }
454
+ unset($getid3_temp, $getid3_ogg, $oggpageinfo, $vorbis_offset);
455
+ break;
456
+
457
+ case 'A_MS/ACM':
458
+ if (!getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, false)) {
459
+ $this->warning('Unable to parse audio data ['.basename(__FILE__).':'.__LINE__.'] because cannot include "module.audio-video.riff.php"');
460
+ break;
461
+ }
462
+
463
+ $parsed = getid3_riff::parseWAVEFORMATex($trackarray['CodecPrivate']);
464
+ foreach ($parsed as $key => $value) {
465
+ if ($key != 'raw') {
466
+ $track_info[$key] = $value;
467
+ }
468
+ }
469
+ $info['matroska']['track_codec_parsed'][$trackarray['TrackNumber']] = $parsed;
470
+ break;
471
+
472
+ default:
473
+ $this->warning('Unhandled audio type "'.(isset($trackarray['CodecID']) ? $trackarray['CodecID'] : '').'"');
474
+ }
475
+
476
+ $info['audio']['streams'][] = $track_info;
477
+ break;
478
+ }
479
+ }
480
+
481
+ if (!empty($info['video']['streams'])) {
482
+ $info['video'] = self::getDefaultStreamInfo($info['video']['streams']);
483
+ }
484
+ if (!empty($info['audio']['streams'])) {
485
+ $info['audio'] = self::getDefaultStreamInfo($info['audio']['streams']);
486
+ }
487
+ }
488
+
489
+ // process attachments
490
+ if (isset($info['matroska']['attachments']) && $this->getid3->option_save_attachments !== getID3::ATTACHMENTS_NONE) {
491
+ foreach ($info['matroska']['attachments'] as $i => $entry) {
492
+ if (strpos($entry['FileMimeType'], 'image/') === 0 && !empty($entry['FileData'])) {
493
+ $info['matroska']['comments']['picture'][] = array('data' => $entry['FileData'], 'image_mime' => $entry['FileMimeType'], 'filename' => $entry['FileName']);
494
+ }
495
+ }
496
+ }
497
+
498
+ // determine mime type
499
+ if (!empty($info['video']['streams'])) {
500
+ $info['mime_type'] = ($info['matroska']['doctype'] == 'webm' ? 'video/webm' : 'video/x-matroska');
501
+ } elseif (!empty($info['audio']['streams'])) {
502
+ $info['mime_type'] = ($info['matroska']['doctype'] == 'webm' ? 'audio/webm' : 'audio/x-matroska');
503
+ } elseif (isset($info['mime_type'])) {
504
+ unset($info['mime_type']);
505
+ }
506
+
507
+ return true;
508
+ }
509
+
510
+ private function parseEBML(&$info) {
511
+ // http://www.matroska.org/technical/specs/index.html#EBMLBasics
512
+ $this->current_offset = $info['avdataoffset'];
513
+
514
+ while ($this->getEBMLelement($top_element, $info['avdataend'])) {
515
+ switch ($top_element['id']) {
516
+
517
+ case EBML_ID_EBML:
518
+ $info['fileformat'] = 'matroska';
519
+ $info['matroska']['header']['offset'] = $top_element['offset'];
520
+ $info['matroska']['header']['length'] = $top_element['length'];
521
+
522
+ while ($this->getEBMLelement($element_data, $top_element['end'], true)) {
523
+ switch ($element_data['id']) {
524
+
525
+ case EBML_ID_EBMLVERSION:
526
+ case EBML_ID_EBMLREADVERSION:
527
+ case EBML_ID_EBMLMAXIDLENGTH:
528
+ case EBML_ID_EBMLMAXSIZELENGTH:
529
+ case EBML_ID_DOCTYPEVERSION:
530
+ case EBML_ID_DOCTYPEREADVERSION:
531
+ $element_data['data'] = getid3_lib::BigEndian2Int($element_data['data']);
532
+ break;
533
+
534
+ case EBML_ID_DOCTYPE:
535
+ $element_data['data'] = getid3_lib::trimNullByte($element_data['data']);
536
+ $info['matroska']['doctype'] = $element_data['data'];
537
+ break;
538
+
539
+ case EBML_ID_CRC32: // not useful, ignore
540
+ $this->current_offset = $element_data['end'];
541
+ unset($element_data);
542
+ break;
543
+
544
+ default:
545
+ $this->unhandledElement('header', __LINE__, $element_data);
546
+ }
547
+ if (!empty($element_data)) {
548
+ unset($element_data['offset'], $element_data['end']);
549
+ $info['matroska']['header']['elements'][] = $element_data;
550
+ }
551
+ }
552
+ break;
553
+
554
+ case EBML_ID_SEGMENT:
555
+ $info['matroska']['segment'][0]['offset'] = $top_element['offset'];
556
+ $info['matroska']['segment'][0]['length'] = $top_element['length'];
557
+
558
+ while ($this->getEBMLelement($element_data, $top_element['end'])) {
559
+ if ($element_data['id'] != EBML_ID_CLUSTER || !self::$hide_clusters) { // collect clusters only if required
560
+ $info['matroska']['segments'][] = $element_data;
561
+ }
562
+ switch ($element_data['id']) {
563
+
564
+ case EBML_ID_SEEKHEAD: // Contains the position of other level 1 elements.
565
+
566
+ while ($this->getEBMLelement($seek_entry, $element_data['end'])) {
567
+ switch ($seek_entry['id']) {
568
+
569
+ case EBML_ID_SEEK: // Contains a single seek entry to an EBML element
570
+ while ($this->getEBMLelement($sub_seek_entry, $seek_entry['end'], true)) {
571
+
572
+ switch ($sub_seek_entry['id']) {
573
+
574
+ case EBML_ID_SEEKID:
575
+ $seek_entry['target_id'] = self::EBML2Int($sub_seek_entry['data']);
576
+ $seek_entry['target_name'] = self::EBMLidName($seek_entry['target_id']);
577
+ break;
578
+
579
+ case EBML_ID_SEEKPOSITION:
580
+ $seek_entry['target_offset'] = $element_data['offset'] + getid3_lib::BigEndian2Int($sub_seek_entry['data']);
581
+ break;
582
+
583
+ default:
584
+ $this->unhandledElement('seekhead.seek', __LINE__, $sub_seek_entry); }
585
+ }
586
+
587
+ if ($seek_entry['target_id'] != EBML_ID_CLUSTER || !self::$hide_clusters) { // collect clusters only if required
588
+ $info['matroska']['seek'][] = $seek_entry;
589
+ }
590
+ break;
591
+
592
+ default:
593
+ $this->unhandledElement('seekhead', __LINE__, $seek_entry);
594
+ }
595
+ }
596
+ break;
597
+
598
+ case EBML_ID_TRACKS: // A top-level block of information with many tracks described.
599
+ $info['matroska']['tracks'] = $element_data;
600
+
601
+ while ($this->getEBMLelement($track_entry, $element_data['end'])) {
602
+ switch ($track_entry['id']) {
603
+
604
+ case EBML_ID_TRACKENTRY: //subelements: Describes a track with all elements.
605
+
606
+ while ($this->getEBMLelement($subelement, $track_entry['end'], array(EBML_ID_VIDEO, EBML_ID_AUDIO, EBML_ID_CONTENTENCODINGS, EBML_ID_CODECPRIVATE))) {
607
+ switch ($subelement['id']) {
608
+
609
+ case EBML_ID_TRACKNUMBER:
610
+ case EBML_ID_TRACKUID:
611
+ case EBML_ID_TRACKTYPE:
612
+ case EBML_ID_MINCACHE:
613
+ case EBML_ID_MAXCACHE:
614
+ case EBML_ID_MAXBLOCKADDITIONID:
615
+ case EBML_ID_DEFAULTDURATION: // nanoseconds per frame
616
+ $track_entry[$subelement['id_name']] = getid3_lib::BigEndian2Int($subelement['data']);
617
+ break;
618
+
619
+ case EBML_ID_TRACKTIMECODESCALE:
620
+ $track_entry[$subelement['id_name']] = getid3_lib::BigEndian2Float($subelement['data']);
621
+ break;
622
+
623
+ case EBML_ID_CODECID:
624
+ case EBML_ID_LANGUAGE:
625
+ case EBML_ID_NAME:
626
+ case EBML_ID_CODECNAME:
627
+ $track_entry[$subelement['id_name']] = getid3_lib::trimNullByte($subelement['data']);
628
+ break;
629
+
630
+ case EBML_ID_CODECPRIVATE:
631
+ $track_entry[$subelement['id_name']] = $this->readEBMLelementData($subelement['length'], true);
632
+ break;
633
+
634
+ case EBML_ID_FLAGENABLED:
635
+ case EBML_ID_FLAGDEFAULT:
636
+ case EBML_ID_FLAGFORCED:
637
+ case EBML_ID_FLAGLACING:
638
+ case EBML_ID_CODECDECODEALL:
639
+ $track_entry[$subelement['id_name']] = (bool) getid3_lib::BigEndian2Int($subelement['data']);
640
+ break;
641
+
642
+ case EBML_ID_VIDEO:
643
+
644
+ while ($this->getEBMLelement($sub_subelement, $subelement['end'], true)) {
645
+ switch ($sub_subelement['id']) {
646
+
647
+ case EBML_ID_PIXELWIDTH:
648
+ case EBML_ID_PIXELHEIGHT:
649
+ case EBML_ID_PIXELCROPBOTTOM:
650
+ case EBML_ID_PIXELCROPTOP:
651
+ case EBML_ID_PIXELCROPLEFT:
652
+ case EBML_ID_PIXELCROPRIGHT:
653
+ case EBML_ID_DISPLAYWIDTH:
654
+ case EBML_ID_DISPLAYHEIGHT:
655
+ case EBML_ID_DISPLAYUNIT:
656
+ case EBML_ID_ASPECTRATIOTYPE:
657
+ case EBML_ID_STEREOMODE:
658
+ case EBML_ID_OLDSTEREOMODE:
659
+ $track_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']);
660
+ break;
661
+
662
+ case EBML_ID_FLAGINTERLACED:
663
+ $track_entry[$sub_subelement['id_name']] = (bool)getid3_lib::BigEndian2Int($sub_subelement['data']);
664
+ break;
665
+
666
+ case EBML_ID_GAMMAVALUE:
667
+ $track_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Float($sub_subelement['data']);
668
+ break;
669
+
670
+ case EBML_ID_COLOURSPACE:
671
+ $track_entry[$sub_subelement['id_name']] = getid3_lib::trimNullByte($sub_subelement['data']);
672
+ break;
673
+
674
+ default:
675
+ $this->unhandledElement('track.video', __LINE__, $sub_subelement);
676
+ }
677
+ }
678
+ break;
679
+
680
+ case EBML_ID_AUDIO:
681
+
682
+ while ($this->getEBMLelement($sub_subelement, $subelement['end'], true)) {
683
+ switch ($sub_subelement['id']) {
684
+
685
+ case EBML_ID_CHANNELS:
686
+ case EBML_ID_BITDEPTH:
687
+ $track_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']);
688
+ break;
689
+
690
+ case EBML_ID_SAMPLINGFREQUENCY:
691
+ case EBML_ID_OUTPUTSAMPLINGFREQUENCY:
692
+ $track_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Float($sub_subelement['data']);
693
+ break;
694
+
695
+ case EBML_ID_CHANNELPOSITIONS:
696
+ $track_entry[$sub_subelement['id_name']] = getid3_lib::trimNullByte($sub_subelement['data']);
697
+ break;
698
+
699
+ default:
700
+ $this->unhandledElement('track.audio', __LINE__, $sub_subelement);
701
+ }
702
+ }
703
+ break;
704
+
705
+ case EBML_ID_CONTENTENCODINGS:
706
+
707
+ while ($this->getEBMLelement($sub_subelement, $subelement['end'])) {
708
+ switch ($sub_subelement['id']) {
709
+
710
+ case EBML_ID_CONTENTENCODING:
711
+
712
+ while ($this->getEBMLelement($sub_sub_subelement, $sub_subelement['end'], array(EBML_ID_CONTENTCOMPRESSION, EBML_ID_CONTENTENCRYPTION))) {
713
+ switch ($sub_sub_subelement['id']) {
714
+
715
+ case EBML_ID_CONTENTENCODINGORDER:
716
+ case EBML_ID_CONTENTENCODINGSCOPE:
717
+ case EBML_ID_CONTENTENCODINGTYPE:
718
+ $track_entry[$sub_subelement['id_name']][$sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_subelement['data']);
719
+ break;
720
+
721
+ case EBML_ID_CONTENTCOMPRESSION:
722
+
723
+ while ($this->getEBMLelement($sub_sub_sub_subelement, $sub_sub_subelement['end'], true)) {
724
+ switch ($sub_sub_sub_subelement['id']) {
725
+
726
+ case EBML_ID_CONTENTCOMPALGO:
727
+ $track_entry[$sub_subelement['id_name']][$sub_sub_subelement['id_name']][$sub_sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_sub_subelement['data']);
728
+ break;
729
+
730
+ case EBML_ID_CONTENTCOMPSETTINGS:
731
+ $track_entry[$sub_subelement['id_name']][$sub_sub_subelement['id_name']][$sub_sub_sub_subelement['id_name']] = $sub_sub_sub_subelement['data'];
732
+ break;
733
+
734
+ default:
735
+ $this->unhandledElement('track.contentencodings.contentencoding.contentcompression', __LINE__, $sub_sub_sub_subelement);
736
+ }
737
+ }
738
+ break;
739
+
740
+ case EBML_ID_CONTENTENCRYPTION:
741
+
742
+ while ($this->getEBMLelement($sub_sub_sub_subelement, $sub_sub_subelement['end'], true)) {
743
+ switch ($sub_sub_sub_subelement['id']) {
744
+
745
+ case EBML_ID_CONTENTENCALGO:
746
+ case EBML_ID_CONTENTSIGALGO:
747
+ case EBML_ID_CONTENTSIGHASHALGO:
748
+ $track_entry[$sub_subelement['id_name']][$sub_sub_subelement['id_name']][$sub_sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_sub_subelement['data']);
749
+ break;
750
+
751
+ case EBML_ID_CONTENTENCKEYID:
752
+ case EBML_ID_CONTENTSIGNATURE:
753
+ case EBML_ID_CONTENTSIGKEYID:
754
+ $track_entry[$sub_subelement['id_name']][$sub_sub_subelement['id_name']][$sub_sub_sub_subelement['id_name']] = $sub_sub_sub_subelement['data'];
755
+ break;
756
+
757
+ default:
758
+ $this->unhandledElement('track.contentencodings.contentencoding.contentcompression', __LINE__, $sub_sub_sub_subelement);
759
+ }
760
+ }
761
+ break;
762
+
763
+ default:
764
+ $this->unhandledElement('track.contentencodings.contentencoding', __LINE__, $sub_sub_subelement);
765
+ }
766
+ }
767
+ break;
768
+
769
+ default:
770
+ $this->unhandledElement('track.contentencodings', __LINE__, $sub_subelement);
771
+ }
772
+ }
773
+ break;
774
+
775
+ default:
776
+ $this->unhandledElement('track', __LINE__, $subelement);
777
+ }
778
+ }
779
+
780
+ $info['matroska']['tracks']['tracks'][] = $track_entry;
781
+ break;
782
+
783
+ default:
784
+ $this->unhandledElement('tracks', __LINE__, $track_entry);
785
+ }
786
+ }
787
+ break;
788
+
789
+ case EBML_ID_INFO: // Contains miscellaneous general information and statistics on the file.
790
+ $info_entry = array();
791
+
792
+ while ($this->getEBMLelement($subelement, $element_data['end'], true)) {
793
+ switch ($subelement['id']) {
794
+
795
+ case EBML_ID_TIMECODESCALE:
796
+ $info_entry[$subelement['id_name']] = getid3_lib::BigEndian2Int($subelement['data']);
797
+ break;
798
+
799
+ case EBML_ID_DURATION:
800
+ $info_entry[$subelement['id_name']] = getid3_lib::BigEndian2Float($subelement['data']);
801
+ break;
802
+
803
+ case EBML_ID_DATEUTC:
804
+ $info_entry[$subelement['id_name']] = getid3_lib::BigEndian2Int($subelement['data']);
805
+ $info_entry[$subelement['id_name'].'_unix'] = self::EBMLdate2unix($info_entry[$subelement['id_name']]);
806
+ break;
807
+
808
+ case EBML_ID_SEGMENTUID:
809
+ case EBML_ID_PREVUID:
810
+ case EBML_ID_NEXTUID:
811
+ $info_entry[$subelement['id_name']] = getid3_lib::trimNullByte($subelement['data']);
812
+ break;
813
+
814
+ case EBML_ID_SEGMENTFAMILY:
815
+ $info_entry[$subelement['id_name']][] = getid3_lib::trimNullByte($subelement['data']);
816
+ break;
817
+
818
+ case EBML_ID_SEGMENTFILENAME:
819
+ case EBML_ID_PREVFILENAME:
820
+ case EBML_ID_NEXTFILENAME:
821
+ case EBML_ID_TITLE:
822
+ case EBML_ID_MUXINGAPP:
823
+ case EBML_ID_WRITINGAPP:
824
+ $info_entry[$subelement['id_name']] = getid3_lib::trimNullByte($subelement['data']);
825
+ $info['matroska']['comments'][strtolower($subelement['id_name'])][] = $info_entry[$subelement['id_name']];
826
+ break;
827
+
828
+ case EBML_ID_CHAPTERTRANSLATE:
829
+ $chaptertranslate_entry = array();
830
+
831
+ while ($this->getEBMLelement($sub_subelement, $subelement['end'], true)) {
832
+ switch ($sub_subelement['id']) {
833
+
834
+ case EBML_ID_CHAPTERTRANSLATEEDITIONUID:
835
+ $chaptertranslate_entry[$sub_subelement['id_name']][] = getid3_lib::BigEndian2Int($sub_subelement['data']);
836
+ break;
837
+
838
+ case EBML_ID_CHAPTERTRANSLATECODEC:
839
+ $chaptertranslate_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']);
840
+ break;
841
+
842
+ case EBML_ID_CHAPTERTRANSLATEID:
843
+ $chaptertranslate_entry[$sub_subelement['id_name']] = getid3_lib::trimNullByte($sub_subelement['data']);
844
+ break;
845
+
846
+ default:
847
+ $this->unhandledElement('info.chaptertranslate', __LINE__, $sub_subelement);
848
+ }
849
+ }
850
+ $info_entry[$subelement['id_name']] = $chaptertranslate_entry;
851
+ break;
852
+
853
+ default:
854
+ $this->unhandledElement('info', __LINE__, $subelement);
855
+ }
856
+ }
857
+ $info['matroska']['info'][] = $info_entry;
858
+ break;
859
+
860
+ case EBML_ID_CUES: // A top-level element to speed seeking access. All entries are local to the segment. Should be mandatory for non "live" streams.
861
+ if (self::$hide_clusters) { // do not parse cues if hide clusters is "ON" till they point to clusters anyway
862
+ $this->current_offset = $element_data['end'];
863
+ break;
864
+ }
865
+ $cues_entry = array();
866
+
867
+ while ($this->getEBMLelement($subelement, $element_data['end'])) {
868
+ switch ($subelement['id']) {
869
+
870
+ case EBML_ID_CUEPOINT:
871
+ $cuepoint_entry = array();
872
+
873
+ while ($this->getEBMLelement($sub_subelement, $subelement['end'], array(EBML_ID_CUETRACKPOSITIONS))) {
874
+ switch ($sub_subelement['id']) {
875
+
876
+ case EBML_ID_CUETRACKPOSITIONS:
877
+ $cuetrackpositions_entry = array();
878
+
879
+ while ($this->getEBMLelement($sub_sub_subelement, $sub_subelement['end'], true)) {
880
+ switch ($sub_sub_subelement['id']) {
881
+
882
+ case EBML_ID_CUETRACK:
883
+ case EBML_ID_CUECLUSTERPOSITION:
884
+ case EBML_ID_CUEBLOCKNUMBER:
885
+ case EBML_ID_CUECODECSTATE:
886
+ $cuetrackpositions_entry[$sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_subelement['data']);
887
+ break;
888
+
889
+ default:
890
+ $this->unhandledElement('cues.cuepoint.cuetrackpositions', __LINE__, $sub_sub_subelement);
891
+ }
892
+ }
893
+ $cuepoint_entry[$sub_subelement['id_name']][] = $cuetrackpositions_entry;
894
+ break;
895
+
896
+ case EBML_ID_CUETIME:
897
+ $cuepoint_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']);
898
+ break;
899
+
900
+ default:
901
+ $this->unhandledElement('cues.cuepoint', __LINE__, $sub_subelement);
902
+ }
903
+ }
904
+ $cues_entry[] = $cuepoint_entry;
905
+ break;
906
+
907
+ default:
908
+ $this->unhandledElement('cues', __LINE__, $subelement);
909
+ }
910
+ }
911
+ $info['matroska']['cues'] = $cues_entry;
912
+ break;
913
+
914
+ case EBML_ID_TAGS: // Element containing elements specific to Tracks/Chapters.
915
+ $tags_entry = array();
916
+
917
+ while ($this->getEBMLelement($subelement, $element_data['end'], false)) {
918
+ switch ($subelement['id']) {
919
+
920
+ case EBML_ID_TAG:
921
+ $tag_entry = array();
922
+
923
+ while ($this->getEBMLelement($sub_subelement, $subelement['end'], false)) {
924
+ switch ($sub_subelement['id']) {
925
+
926
+ case EBML_ID_TARGETS:
927
+ $targets_entry = array();
928
+
929
+ while ($this->getEBMLelement($sub_sub_subelement, $sub_subelement['end'], true)) {
930
+ switch ($sub_sub_subelement['id']) {
931
+
932
+ case EBML_ID_TARGETTYPEVALUE:
933
+ $targets_entry[$sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_subelement['data']);
934
+ $targets_entry[strtolower($sub_sub_subelement['id_name']).'_long'] = self::TargetTypeValue($targets_entry[$sub_sub_subelement['id_name']]);
935
+ break;
936
+
937
+ case EBML_ID_TARGETTYPE:
938
+ $targets_entry[$sub_sub_subelement['id_name']] = $sub_sub_subelement['data'];
939
+ break;
940
+
941
+ case EBML_ID_TAGTRACKUID:
942
+ case EBML_ID_TAGEDITIONUID:
943
+ case EBML_ID_TAGCHAPTERUID:
944
+ case EBML_ID_TAGATTACHMENTUID:
945
+ $targets_entry[$sub_sub_subelement['id_name']][] = getid3_lib::BigEndian2Int($sub_sub_subelement['data']);
946
+ break;
947
+
948
+ default:
949
+ $this->unhandledElement('tags.tag.targets', __LINE__, $sub_sub_subelement);
950
+ }
951
+ }
952
+ $tag_entry[$sub_subelement['id_name']] = $targets_entry;
953
+ break;
954
+
955
+ case EBML_ID_SIMPLETAG:
956
+ $tag_entry[$sub_subelement['id_name']][] = $this->HandleEMBLSimpleTag($sub_subelement['end']);
957
+ break;
958
+
959
+ default:
960
+ $this->unhandledElement('tags.tag', __LINE__, $sub_subelement);
961
+ }
962
+ }
963
+ $tags_entry[] = $tag_entry;
964
+ break;
965
+
966
+ default:
967
+ $this->unhandledElement('tags', __LINE__, $subelement);
968
+ }
969
+ }
970
+ $info['matroska']['tags'] = $tags_entry;
971
+ break;
972
+
973
+ case EBML_ID_ATTACHMENTS: // Contain attached files.
974
+
975
+ while ($this->getEBMLelement($subelement, $element_data['end'])) {
976
+ switch ($subelement['id']) {
977
+
978
+ case EBML_ID_ATTACHEDFILE:
979
+ $attachedfile_entry = array();
980
+
981
+ while ($this->getEBMLelement($sub_subelement, $subelement['end'], array(EBML_ID_FILEDATA))) {
982
+ switch ($sub_subelement['id']) {
983
+
984
+ case EBML_ID_FILEDESCRIPTION:
985
+ case EBML_ID_FILENAME:
986
+ case EBML_ID_FILEMIMETYPE:
987
+ $attachedfile_entry[$sub_subelement['id_name']] = $sub_subelement['data'];
988
+ break;
989
+
990
+ case EBML_ID_FILEDATA:
991
+ $attachedfile_entry['data_offset'] = $this->current_offset;
992
+ $attachedfile_entry['data_length'] = $sub_subelement['length'];
993
+
994
+ $attachedfile_entry[$sub_subelement['id_name']] = $this->saveAttachment(
995
+ $attachedfile_entry['FileName'],
996
+ $attachedfile_entry['data_offset'],
997
+ $attachedfile_entry['data_length']);
998
+
999
+ $this->current_offset = $sub_subelement['end'];
1000
+ break;
1001
+
1002
+ case EBML_ID_FILEUID:
1003
+ $attachedfile_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']);
1004
+ break;
1005
+
1006
+ default:
1007
+ $this->unhandledElement('attachments.attachedfile', __LINE__, $sub_subelement);
1008
+ }
1009
+ }
1010
+ $info['matroska']['attachments'][] = $attachedfile_entry;
1011
+ break;
1012
+
1013
+ default:
1014
+ $this->unhandledElement('attachments', __LINE__, $subelement);
1015
+ }
1016
+ }
1017
+ break;
1018
+
1019
+ case EBML_ID_CHAPTERS:
1020
+
1021
+ while ($this->getEBMLelement($subelement, $element_data['end'])) {
1022
+ switch ($subelement['id']) {
1023
+
1024
+ case EBML_ID_EDITIONENTRY:
1025
+ $editionentry_entry = array();
1026
+
1027
+ while ($this->getEBMLelement($sub_subelement, $subelement['end'], array(EBML_ID_CHAPTERATOM))) {
1028
+ switch ($sub_subelement['id']) {
1029
+
1030
+ case EBML_ID_EDITIONUID:
1031
+ $editionentry_entry[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']);
1032
+ break;
1033
+
1034
+ case EBML_ID_EDITIONFLAGHIDDEN:
1035
+ case EBML_ID_EDITIONFLAGDEFAULT:
1036
+ case EBML_ID_EDITIONFLAGORDERED:
1037
+ $editionentry_entry[$sub_subelement['id_name']] = (bool)getid3_lib::BigEndian2Int($sub_subelement['data']);
1038
+ break;
1039
+
1040
+ case EBML_ID_CHAPTERATOM:
1041
+ $chapteratom_entry = array();
1042
+
1043
+ while ($this->getEBMLelement($sub_sub_subelement, $sub_subelement['end'], array(EBML_ID_CHAPTERTRACK, EBML_ID_CHAPTERDISPLAY))) {
1044
+ switch ($sub_sub_subelement['id']) {
1045
+
1046
+ case EBML_ID_CHAPTERSEGMENTUID:
1047
+ case EBML_ID_CHAPTERSEGMENTEDITIONUID:
1048
+ $chapteratom_entry[$sub_sub_subelement['id_name']] = $sub_sub_subelement['data'];
1049
+ break;
1050
+
1051
+ case EBML_ID_CHAPTERFLAGENABLED:
1052
+ case EBML_ID_CHAPTERFLAGHIDDEN:
1053
+ $chapteratom_entry[$sub_sub_subelement['id_name']] = (bool)getid3_lib::BigEndian2Int($sub_sub_subelement['data']);
1054
+ break;
1055
+
1056
+ case EBML_ID_CHAPTERUID:
1057
+ case EBML_ID_CHAPTERTIMESTART:
1058
+ case EBML_ID_CHAPTERTIMEEND:
1059
+ $chapteratom_entry[$sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_subelement['data']);
1060
+ break;
1061
+
1062
+ case EBML_ID_CHAPTERTRACK:
1063
+ $chaptertrack_entry = array();
1064
+
1065
+ while ($this->getEBMLelement($sub_sub_sub_subelement, $sub_sub_subelement['end'], true)) {
1066
+ switch ($sub_sub_sub_subelement['id']) {
1067
+
1068
+ case EBML_ID_CHAPTERTRACKNUMBER:
1069
+ $chaptertrack_entry[$sub_sub_sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_sub_sub_subelement['data']);
1070
+ break;
1071
+
1072
+ default:
1073
+ $this->unhandledElement('chapters.editionentry.chapteratom.chaptertrack', __LINE__, $sub_sub_sub_subelement);
1074
+ }
1075
+ }
1076
+ $chapteratom_entry[$sub_sub_subelement['id_name']][] = $chaptertrack_entry;
1077
+ break;
1078
+
1079
+ case EBML_ID_CHAPTERDISPLAY:
1080
+ $chapterdisplay_entry = array();
1081
+
1082
+ while ($this->getEBMLelement($sub_sub_sub_subelement, $sub_sub_subelement['end'], true)) {
1083
+ switch ($sub_sub_sub_subelement['id']) {
1084
+
1085
+ case EBML_ID_CHAPSTRING:
1086
+ case EBML_ID_CHAPLANGUAGE:
1087
+ case EBML_ID_CHAPCOUNTRY:
1088
+ $chapterdisplay_entry[$sub_sub_sub_subelement['id_name']] = $sub_sub_sub_subelement['data'];
1089
+ break;
1090
+
1091
+ default:
1092
+ $this->unhandledElement('chapters.editionentry.chapteratom.chapterdisplay', __LINE__, $sub_sub_sub_subelement);
1093
+ }
1094
+ }
1095
+ $chapteratom_entry[$sub_sub_subelement['id_name']][] = $chapterdisplay_entry;
1096
+ break;
1097
+
1098
+ default:
1099
+ $this->unhandledElement('chapters.editionentry.chapteratom', __LINE__, $sub_sub_subelement);
1100
+ }
1101
+ }
1102
+ $editionentry_entry[$sub_subelement['id_name']][] = $chapteratom_entry;
1103
+ break;
1104
+
1105
+ default:
1106
+ $this->unhandledElement('chapters.editionentry', __LINE__, $sub_subelement);
1107
+ }
1108
+ }
1109
+ $info['matroska']['chapters'][] = $editionentry_entry;
1110
+ break;
1111
+
1112
+ default:
1113
+ $this->unhandledElement('chapters', __LINE__, $subelement);
1114
+ }
1115
+ }
1116
+ break;
1117
+
1118
+ case EBML_ID_CLUSTER: // The lower level element containing the (monolithic) Block structure.
1119
+ $cluster_entry = array();
1120
+
1121
+ while ($this->getEBMLelement($subelement, $element_data['end'], array(EBML_ID_CLUSTERSILENTTRACKS, EBML_ID_CLUSTERBLOCKGROUP, EBML_ID_CLUSTERSIMPLEBLOCK))) {
1122
+ switch ($subelement['id']) {
1123
+
1124
+ case EBML_ID_CLUSTERTIMECODE:
1125
+ case EBML_ID_CLUSTERPOSITION:
1126
+ case EBML_ID_CLUSTERPREVSIZE:
1127
+ $cluster_entry[$subelement['id_name']] = getid3_lib::BigEndian2Int($subelement['data']);
1128
+ break;
1129
+
1130
+ case EBML_ID_CLUSTERSILENTTRACKS:
1131
+ $cluster_silent_tracks = array();
1132
+
1133
+ while ($this->getEBMLelement($sub_subelement, $subelement['end'], true)) {
1134
+ switch ($sub_subelement['id']) {
1135
+
1136
+ case EBML_ID_CLUSTERSILENTTRACKNUMBER:
1137
+ $cluster_silent_tracks[] = getid3_lib::BigEndian2Int($sub_subelement['data']);
1138
+ break;
1139
+
1140
+ default:
1141
+ $this->unhandledElement('cluster.silenttracks', __LINE__, $sub_subelement);
1142
+ }
1143
+ }
1144
+ $cluster_entry[$subelement['id_name']][] = $cluster_silent_tracks;
1145
+ break;
1146
+
1147
+ case EBML_ID_CLUSTERBLOCKGROUP:
1148
+ $cluster_block_group = array('offset' => $this->current_offset);
1149
+
1150
+ while ($this->getEBMLelement($sub_subelement, $subelement['end'], array(EBML_ID_CLUSTERBLOCK))) {
1151
+ switch ($sub_subelement['id']) {
1152
+
1153
+ case EBML_ID_CLUSTERBLOCK:
1154
+ $cluster_block_group[$sub_subelement['id_name']] = $this->HandleEMBLClusterBlock($sub_subelement, EBML_ID_CLUSTERBLOCK, $info);
1155
+ break;
1156
+
1157
+ case EBML_ID_CLUSTERREFERENCEPRIORITY: // unsigned-int
1158
+ case EBML_ID_CLUSTERBLOCKDURATION: // unsigned-int
1159
+ $cluster_block_group[$sub_subelement['id_name']] = getid3_lib::BigEndian2Int($sub_subelement['data']);
1160
+ break;
1161
+
1162
+ case EBML_ID_CLUSTERREFERENCEBLOCK: // signed-int
1163
+ $cluster_block_group[$sub_subelement['id_name']][] = getid3_lib::BigEndian2Int($sub_subelement['data'], false, true);
1164
+ break;
1165
+
1166
+ case EBML_ID_CLUSTERCODECSTATE:
1167
+ $cluster_block_group[$sub_subelement['id_name']] = getid3_lib::trimNullByte($sub_subelement['data']);
1168
+ break;
1169
+
1170
+ default:
1171
+ $this->unhandledElement('clusters.blockgroup', __LINE__, $sub_subelement);
1172
+ }
1173
+ }
1174
+ $cluster_entry[$subelement['id_name']][] = $cluster_block_group;
1175
+ break;
1176
+
1177
+ case EBML_ID_CLUSTERSIMPLEBLOCK:
1178
+ $cluster_entry[$subelement['id_name']][] = $this->HandleEMBLClusterBlock($subelement, EBML_ID_CLUSTERSIMPLEBLOCK, $info);
1179
+ break;
1180
+
1181
+ default:
1182
+ $this->unhandledElement('cluster', __LINE__, $subelement);
1183
+ }
1184
+ $this->current_offset = $subelement['end'];
1185
+ }
1186
+ if (!self::$hide_clusters) {
1187
+ $info['matroska']['cluster'][] = $cluster_entry;
1188
+ }
1189
+
1190
+ // check to see if all the data we need exists already, if so, break out of the loop
1191
+ if (!self::$parse_whole_file) {
1192
+ if (isset($info['matroska']['info']) && is_array($info['matroska']['info'])) {
1193
+ if (isset($info['matroska']['tracks']['tracks']) && is_array($info['matroska']['tracks']['tracks'])) {
1194
+ if (count($info['matroska']['track_data_offsets']) == count($info['matroska']['tracks']['tracks'])) {
1195
+ return;
1196
+ }
1197
+ }
1198
+ }
1199
+ }
1200
+ break;
1201
+
1202
+ default:
1203
+ $this->unhandledElement('segment', __LINE__, $element_data);
1204
+ }
1205
+ }
1206
+ break;
1207
+
1208
+ default:
1209
+ $this->unhandledElement('root', __LINE__, $top_element);
1210
+ }
1211
+ }
1212
+ }
1213
+
1214
+ private function EnsureBufferHasEnoughData($min_data=1024) {
1215
+ if (($this->current_offset - $this->EBMLbuffer_offset) >= ($this->EBMLbuffer_length - $min_data)) {
1216
+ $read_bytes = max($min_data, $this->getid3->fread_buffer_size());
1217
+
1218
+ try {
1219
+ $this->fseek($this->current_offset);
1220
+ $this->EBMLbuffer_offset = $this->current_offset;
1221
+ $this->EBMLbuffer = $this->fread($read_bytes);
1222
+ $this->EBMLbuffer_length = strlen($this->EBMLbuffer);
1223
+ } catch (getid3_exception $e) {
1224
+ $this->warning('EBML parser: '.$e->getMessage());
1225
+ return false;
1226
+ }
1227
+
1228
+ if ($this->EBMLbuffer_length == 0 && $this->feof()) {
1229
+ return $this->error('EBML parser: ran out of file at offset '.$this->current_offset);
1230
+ }
1231
+ }
1232
+ return true;
1233
+ }
1234
+
1235
+ private function readEBMLint() {
1236
+ $actual_offset = $this->current_offset - $this->EBMLbuffer_offset;
1237
+
1238
+ // get length of integer
1239
+ $first_byte_int = ord($this->EBMLbuffer[$actual_offset]);
1240
+ if (0x80 & $first_byte_int) {
1241
+ $length = 1;
1242
+ } elseif (0x40 & $first_byte_int) {
1243
+ $length = 2;
1244
+ } elseif (0x20 & $first_byte_int) {
1245
+ $length = 3;
1246
+ } elseif (0x10 & $first_byte_int) {
1247
+ $length = 4;
1248
+ } elseif (0x08 & $first_byte_int) {
1249
+ $length = 5;
1250
+ } elseif (0x04 & $first_byte_int) {
1251
+ $length = 6;
1252
+ } elseif (0x02 & $first_byte_int) {
1253
+ $length = 7;
1254
+ } elseif (0x01 & $first_byte_int) {
1255
+ $length = 8;
1256
+ } else {
1257
+ throw new Exception('invalid EBML integer (leading 0x00) at '.$this->current_offset);
1258
+ }
1259
+
1260
+ // read
1261
+ $int_value = self::EBML2Int(substr($this->EBMLbuffer, $actual_offset, $length));
1262
+ $this->current_offset += $length;
1263
+
1264
+ return $int_value;
1265
+ }
1266
+
1267
+ private function readEBMLelementData($length, $check_buffer=false) {
1268
+ if ($check_buffer && !$this->EnsureBufferHasEnoughData($length)) {
1269
+ return false;
1270
+ }
1271
+ $data = substr($this->EBMLbuffer, $this->current_offset - $this->EBMLbuffer_offset, $length);
1272
+ $this->current_offset += $length;
1273
+ return $data;
1274
+ }
1275
+
1276
+ private function getEBMLelement(&$element, $parent_end, $get_data=false) {
1277
+ if ($this->current_offset >= $parent_end) {
1278
+ return false;
1279
+ }
1280
+
1281
+ if (!$this->EnsureBufferHasEnoughData()) {
1282
+ $this->current_offset = PHP_INT_MAX; // do not exit parser right now, allow to finish current loop to gather maximum information
1283
+ return false;
1284
+ }
1285
+
1286
+ $element = array();
1287
+
1288
+ // set offset
1289
+ $element['offset'] = $this->current_offset;
1290
+
1291
+ // get ID
1292
+ $element['id'] = $this->readEBMLint();
1293
+
1294
+ // get name
1295
+ $element['id_name'] = self::EBMLidName($element['id']);
1296
+
1297
+ // get length
1298
+ $element['length'] = $this->readEBMLint();
1299
+
1300
+ // get end offset
1301
+ $element['end'] = $this->current_offset + $element['length'];
1302
+
1303
+ // get raw data
1304
+ $dont_parse = (in_array($element['id'], $this->unuseful_elements) || $element['id_name'] == dechex($element['id']));
1305
+ if (($get_data === true || (is_array($get_data) && !in_array($element['id'], $get_data))) && !$dont_parse) {
1306
+ $element['data'] = $this->readEBMLelementData($element['length'], $element);
1307
+ }
1308
+
1309
+ return true;
1310
+ }
1311
+
1312
+ private function unhandledElement($type, $line, $element) {
1313
+ // warn only about unknown and missed elements, not about unuseful
1314
+ if (!in_array($element['id'], $this->unuseful_elements)) {
1315
+ $this->warning('Unhandled '.$type.' element ['.basename(__FILE__).':'.$line.'] ('.$element['id'].'::'.$element['id_name'].' ['.$element['length'].' bytes]) at '.$element['offset']);
1316
+ }
1317
+
1318
+ // increase offset for unparsed elements
1319
+ if (!isset($element['data'])) {
1320
+ $this->current_offset = $element['end'];
1321
+ }
1322
+ }
1323
+
1324
+ private function ExtractCommentsSimpleTag($SimpleTagArray) {
1325
+ if (!empty($SimpleTagArray['SimpleTag'])) {
1326
+ foreach ($SimpleTagArray['SimpleTag'] as $SimpleTagKey => $SimpleTagData) {
1327
+ if (!empty($SimpleTagData['TagName']) && !empty($SimpleTagData['TagString'])) {
1328
+ $this->getid3->info['matroska']['comments'][strtolower($SimpleTagData['TagName'])][] = $SimpleTagData['TagString'];
1329
+ }
1330
+ if (!empty($SimpleTagData['SimpleTag'])) {
1331
+ $this->ExtractCommentsSimpleTag($SimpleTagData);
1332
+ }
1333
+ }
1334
+ }
1335
+
1336
+ return true;
1337
+ }
1338
+
1339
+ private function HandleEMBLSimpleTag($parent_end) {
1340
+ $simpletag_entry = array();
1341
+
1342
+ while ($this->getEBMLelement($element, $parent_end, array(EBML_ID_SIMPLETAG))) {
1343
+ switch ($element['id']) {
1344
+
1345
+ case EBML_ID_TAGNAME:
1346
+ case EBML_ID_TAGLANGUAGE:
1347
+ case EBML_ID_TAGSTRING:
1348
+ case EBML_ID_TAGBINARY:
1349
+ $simpletag_entry[$element['id_name']] = $element['data'];
1350
+ break;
1351
+
1352
+ case EBML_ID_SIMPLETAG:
1353
+ $simpletag_entry[$element['id_name']][] = $this->HandleEMBLSimpleTag($element['end']);
1354
+ break;
1355
+
1356
+ case EBML_ID_TAGDEFAULT:
1357
+ $simpletag_entry[$element['id_name']] = (bool)getid3_lib::BigEndian2Int($element['data']);
1358
+ break;
1359
+
1360
+ default:
1361
+ $this->unhandledElement('tag.simpletag', __LINE__, $element);
1362
+ }
1363
+ }
1364
+
1365
+ return $simpletag_entry;
1366
+ }
1367
+
1368
+ private function HandleEMBLClusterBlock($element, $block_type, &$info) {
1369
+ // http://www.matroska.org/technical/specs/index.html#block_structure
1370
+ // http://www.matroska.org/technical/specs/index.html#simpleblock_structure
1371
+
1372
+ $block_data = array();
1373
+ $block_data['tracknumber'] = $this->readEBMLint();
1374
+ $block_data['timecode'] = getid3_lib::BigEndian2Int($this->readEBMLelementData(2), false, true);
1375
+ $block_data['flags_raw'] = getid3_lib::BigEndian2Int($this->readEBMLelementData(1));
1376
+
1377
+ if ($block_type == EBML_ID_CLUSTERSIMPLEBLOCK) {
1378
+ $block_data['flags']['keyframe'] = (($block_data['flags_raw'] & 0x80) >> 7);
1379
+ //$block_data['flags']['reserved1'] = (($block_data['flags_raw'] & 0x70) >> 4);
1380
+ }
1381
+ else {
1382
+ //$block_data['flags']['reserved1'] = (($block_data['flags_raw'] & 0xF0) >> 4);
1383
+ }
1384
+ $block_data['flags']['invisible'] = (bool)(($block_data['flags_raw'] & 0x08) >> 3);
1385
+ $block_data['flags']['lacing'] = (($block_data['flags_raw'] & 0x06) >> 1); // 00=no lacing; 01=Xiph lacing; 11=EBML lacing; 10=fixed-size lacing
1386
+ if ($block_type == EBML_ID_CLUSTERSIMPLEBLOCK) {
1387
+ $block_data['flags']['discardable'] = (($block_data['flags_raw'] & 0x01));
1388
+ }
1389
+ else {
1390
+ //$block_data['flags']['reserved2'] = (($block_data['flags_raw'] & 0x01) >> 0);
1391
+ }
1392
+ $block_data['flags']['lacing_type'] = self::BlockLacingType($block_data['flags']['lacing']);
1393
+
1394
+ // Lace (when lacing bit is set)
1395
+ if ($block_data['flags']['lacing'] > 0) {
1396
+ $block_data['lace_frames'] = getid3_lib::BigEndian2Int($this->readEBMLelementData(1)) + 1; // Number of frames in the lace-1 (uint8)
1397
+ if ($block_data['flags']['lacing'] != 0x02) {
1398
+ for ($i = 1; $i < $block_data['lace_frames']; $i ++) { // Lace-coded size of each frame of the lace, except for the last one (multiple uint8). *This is not used with Fixed-size lacing as it is calculated automatically from (total size of lace) / (number of frames in lace).
1399
+ if ($block_data['flags']['lacing'] == 0x03) { // EBML lacing
1400
+ $block_data['lace_frames_size'][$i] = $this->readEBMLint(); // TODO: read size correctly, calc size for the last frame. For now offsets are deteminded OK with readEBMLint() and that's the most important thing.
1401
+ }
1402
+ else { // Xiph lacing
1403
+ $block_data['lace_frames_size'][$i] = 0;
1404
+ do {
1405
+ $size = getid3_lib::BigEndian2Int($this->readEBMLelementData(1));
1406
+ $block_data['lace_frames_size'][$i] += $size;
1407
+ }
1408
+ while ($size == 255);
1409
+ }
1410
+ }
1411
+ if ($block_data['flags']['lacing'] == 0x01) { // calc size of the last frame only for Xiph lacing, till EBML sizes are now anyway determined incorrectly
1412
+ $block_data['lace_frames_size'][] = $element['end'] - $this->current_offset - array_sum($block_data['lace_frames_size']);
1413
+ }
1414
+ }
1415
+ }
1416
+
1417
+ if (!isset($info['matroska']['track_data_offsets'][$block_data['tracknumber']])) {
1418
+ $info['matroska']['track_data_offsets'][$block_data['tracknumber']]['offset'] = $this->current_offset;
1419
+ $info['matroska']['track_data_offsets'][$block_data['tracknumber']]['length'] = $element['end'] - $this->current_offset;
1420
+ //$info['matroska']['track_data_offsets'][$block_data['tracknumber']]['total_length'] = 0;
1421
+ }
1422
+ //$info['matroska']['track_data_offsets'][$block_data['tracknumber']]['total_length'] += $info['matroska']['track_data_offsets'][$block_data['tracknumber']]['length'];
1423
+ //$info['matroska']['track_data_offsets'][$block_data['tracknumber']]['duration'] = $block_data['timecode'] * ((isset($info['matroska']['info'][0]['TimecodeScale']) ? $info['matroska']['info'][0]['TimecodeScale'] : 1000000) / 1000000000);
1424
+
1425
+ // set offset manually
1426
+ $this->current_offset = $element['end'];
1427
+
1428
+ return $block_data;
1429
+ }
1430
+
1431
+ private static function EBML2Int($EBMLstring) {
1432
+ // http://matroska.org/specs/
1433
+
1434
+ // Element ID coded with an UTF-8 like system:
1435
+ // 1xxx xxxx - Class A IDs (2^7 -2 possible values) (base 0x8X)
1436
+ // 01xx xxxx xxxx xxxx - Class B IDs (2^14-2 possible values) (base 0x4X 0xXX)
1437
+ // 001x xxxx xxxx xxxx xxxx xxxx - Class C IDs (2^21-2 possible values) (base 0x2X 0xXX 0xXX)
1438
+ // 0001 xxxx xxxx xxxx xxxx xxxx xxxx xxxx - Class D IDs (2^28-2 possible values) (base 0x1X 0xXX 0xXX 0xXX)
1439
+ // Values with all x at 0 and 1 are reserved (hence the -2).
1440
+
1441
+ // Data size, in octets, is also coded with an UTF-8 like system :
1442
+ // 1xxx xxxx - value 0 to 2^7-2
1443
+ // 01xx xxxx xxxx xxxx - value 0 to 2^14-2
1444
+ // 001x xxxx xxxx xxxx xxxx xxxx - value 0 to 2^21-2
1445
+ // 0001 xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^28-2
1446
+ // 0000 1xxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^35-2
1447
+ // 0000 01xx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^42-2
1448
+ // 0000 001x xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^49-2
1449
+ // 0000 0001 xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx - value 0 to 2^56-2
1450
+
1451
+ $first_byte_int = ord($EBMLstring[0]);
1452
+ if (0x80 & $first_byte_int) {
1453
+ $EBMLstring[0] = chr($first_byte_int & 0x7F);
1454
+ } elseif (0x40 & $first_byte_int) {
1455
+ $EBMLstring[0] = chr($first_byte_int & 0x3F);
1456
+ } elseif (0x20 & $first_byte_int) {
1457
+ $EBMLstring[0] = chr($first_byte_int & 0x1F);
1458
+ } elseif (0x10 & $first_byte_int) {
1459
+ $EBMLstring[0] = chr($first_byte_int & 0x0F);
1460
+ } elseif (0x08 & $first_byte_int) {
1461
+ $EBMLstring[0] = chr($first_byte_int & 0x07);
1462
+ } elseif (0x04 & $first_byte_int) {
1463
+ $EBMLstring[0] = chr($first_byte_int & 0x03);
1464
+ } elseif (0x02 & $first_byte_int) {
1465
+ $EBMLstring[0] = chr($first_byte_int & 0x01);
1466
+ } elseif (0x01 & $first_byte_int) {
1467
+ $EBMLstring[0] = chr($first_byte_int & 0x00);
1468
+ }
1469
+
1470
+ return getid3_lib::BigEndian2Int($EBMLstring);
1471
+ }
1472
+
1473
+ private static function EBMLdate2unix($EBMLdatestamp) {
1474
+ // Date - signed 8 octets integer in nanoseconds with 0 indicating the precise beginning of the millennium (at 2001-01-01T00:00:00,000000000 UTC)
1475
+ // 978307200 == mktime(0, 0, 0, 1, 1, 2001) == January 1, 2001 12:00:00am UTC
1476
+ return round(($EBMLdatestamp / 1000000000) + 978307200);
1477
+ }
1478
+
1479
+ public static function TargetTypeValue($target_type) {
1480
+ // http://www.matroska.org/technical/specs/tagging/index.html
1481
+ static $TargetTypeValue = array();
1482
+ if (empty($TargetTypeValue)) {
1483
+ $TargetTypeValue[10] = 'A: ~ V:shot'; // the lowest hierarchy found in music or movies
1484
+ $TargetTypeValue[20] = 'A:subtrack/part/movement ~ V:scene'; // corresponds to parts of a track for audio (like a movement)
1485
+ $TargetTypeValue[30] = 'A:track/song ~ V:chapter'; // the common parts of an album or a movie
1486
+ $TargetTypeValue[40] = 'A:part/session ~ V:part/session'; // when an album or episode has different logical parts
1487
+ $TargetTypeValue[50] = 'A:album/opera/concert ~ V:movie/episode/concert'; // the most common grouping level of music and video (equals to an episode for TV series)
1488
+ $TargetTypeValue[60] = 'A:edition/issue/volume/opus ~ V:season/sequel/volume'; // a list of lower levels grouped together
1489
+ $TargetTypeValue[70] = 'A:collection ~ V:collection'; // the high hierarchy consisting of many different lower items
1490
+ }
1491
+ return (isset($TargetTypeValue[$target_type]) ? $TargetTypeValue[$target_type] : $target_type);
1492
+ }
1493
+
1494
+ public static function BlockLacingType($lacingtype) {
1495
+ // http://matroska.org/technical/specs/index.html#block_structure
1496
+ static $BlockLacingType = array();
1497
+ if (empty($BlockLacingType)) {
1498
+ $BlockLacingType[0x00] = 'no lacing';
1499
+ $BlockLacingType[0x01] = 'Xiph lacing';
1500
+ $BlockLacingType[0x02] = 'fixed-size lacing';
1501
+ $BlockLacingType[0x03] = 'EBML lacing';
1502
+ }
1503
+ return (isset($BlockLacingType[$lacingtype]) ? $BlockLacingType[$lacingtype] : $lacingtype);
1504
+ }
1505
+
1506
+ public static function CodecIDtoCommonName($codecid) {
1507
+ // http://www.matroska.org/technical/specs/codecid/index.html
1508
+ static $CodecIDlist = array();
1509
+ if (empty($CodecIDlist)) {
1510
+ $CodecIDlist['A_AAC'] = 'aac';
1511
+ $CodecIDlist['A_AAC/MPEG2/LC'] = 'aac';
1512
+ $CodecIDlist['A_AC3'] = 'ac3';
1513
+ $CodecIDlist['A_DTS'] = 'dts';
1514
+ $CodecIDlist['A_FLAC'] = 'flac';
1515
+ $CodecIDlist['A_MPEG/L1'] = 'mp1';
1516
+ $CodecIDlist['A_MPEG/L2'] = 'mp2';
1517
+ $CodecIDlist['A_MPEG/L3'] = 'mp3';
1518
+ $CodecIDlist['A_PCM/INT/LIT'] = 'pcm'; // PCM Integer Little Endian
1519
+ $CodecIDlist['A_PCM/INT/BIG'] = 'pcm'; // PCM Integer Big Endian
1520
+ $CodecIDlist['A_QUICKTIME/QDMC'] = 'quicktime'; // Quicktime: QDesign Music
1521
+ $CodecIDlist['A_QUICKTIME/QDM2'] = 'quicktime'; // Quicktime: QDesign Music v2
1522
+ $CodecIDlist['A_VORBIS'] = 'vorbis';
1523
+ $CodecIDlist['V_MPEG1'] = 'mpeg';
1524
+ $CodecIDlist['V_THEORA'] = 'theora';
1525
+ $CodecIDlist['V_REAL/RV40'] = 'real';
1526
+ $CodecIDlist['V_REAL/RV10'] = 'real';
1527
+ $CodecIDlist['V_REAL/RV20'] = 'real';
1528
+ $CodecIDlist['V_REAL/RV30'] = 'real';
1529
+ $CodecIDlist['V_QUICKTIME'] = 'quicktime'; // Quicktime
1530
+ $CodecIDlist['V_MPEG4/ISO/AP'] = 'mpeg4';
1531
+ $CodecIDlist['V_MPEG4/ISO/ASP'] = 'mpeg4';
1532
+ $CodecIDlist['V_MPEG4/ISO/AVC'] = 'h264';
1533
+ $CodecIDlist['V_MPEG4/ISO/SP'] = 'mpeg4';
1534
+ $CodecIDlist['V_VP8'] = 'vp8';
1535
+ $CodecIDlist['V_MS/VFW/FOURCC'] = 'riff';
1536
+ $CodecIDlist['A_MS/ACM'] = 'riff';
1537
+ }
1538
+ return (isset($CodecIDlist[$codecid]) ? $CodecIDlist[$codecid] : $codecid);
1539
+ }
1540
+
1541
+ private static function EBMLidName($value) {
1542
+ static $EBMLidList = array();
1543
+ if (empty($EBMLidList)) {
1544
+ $EBMLidList[EBML_ID_ASPECTRATIOTYPE] = 'AspectRatioType';
1545
+ $EBMLidList[EBML_ID_ATTACHEDFILE] = 'AttachedFile';
1546
+ $EBMLidList[EBML_ID_ATTACHMENTLINK] = 'AttachmentLink';
1547
+ $EBMLidList[EBML_ID_ATTACHMENTS] = 'Attachments';
1548
+ $EBMLidList[EBML_ID_AUDIO] = 'Audio';
1549
+ $EBMLidList[EBML_ID_BITDEPTH] = 'BitDepth';
1550
+ $EBMLidList[EBML_ID_CHANNELPOSITIONS] = 'ChannelPositions';
1551
+ $EBMLidList[EBML_ID_CHANNELS] = 'Channels';
1552
+ $EBMLidList[EBML_ID_CHAPCOUNTRY] = 'ChapCountry';
1553
+ $EBMLidList[EBML_ID_CHAPLANGUAGE] = 'ChapLanguage';
1554
+ $EBMLidList[EBML_ID_CHAPPROCESS] = 'ChapProcess';
1555
+ $EBMLidList[EBML_ID_CHAPPROCESSCODECID] = 'ChapProcessCodecID';
1556
+ $EBMLidList[EBML_ID_CHAPPROCESSCOMMAND] = 'ChapProcessCommand';
1557
+ $EBMLidList[EBML_ID_CHAPPROCESSDATA] = 'ChapProcessData';
1558
+ $EBMLidList[EBML_ID_CHAPPROCESSPRIVATE] = 'ChapProcessPrivate';
1559
+ $EBMLidList[EBML_ID_CHAPPROCESSTIME] = 'ChapProcessTime';
1560
+ $EBMLidList[EBML_ID_CHAPSTRING] = 'ChapString';
1561
+ $EBMLidList[EBML_ID_CHAPTERATOM] = 'ChapterAtom';
1562
+ $EBMLidList[EBML_ID_CHAPTERDISPLAY] = 'ChapterDisplay';
1563
+ $EBMLidList[EBML_ID_CHAPTERFLAGENABLED] = 'ChapterFlagEnabled';
1564
+ $EBMLidList[EBML_ID_CHAPTERFLAGHIDDEN] = 'ChapterFlagHidden';
1565
+ $EBMLidList[EBML_ID_CHAPTERPHYSICALEQUIV] = 'ChapterPhysicalEquiv';
1566
+ $EBMLidList[EBML_ID_CHAPTERS] = 'Chapters';
1567
+ $EBMLidList[EBML_ID_CHAPTERSEGMENTEDITIONUID] = 'ChapterSegmentEditionUID';
1568
+ $EBMLidList[EBML_ID_CHAPTERSEGMENTUID] = 'ChapterSegmentUID';
1569
+ $EBMLidList[EBML_ID_CHAPTERTIMEEND] = 'ChapterTimeEnd';
1570
+ $EBMLidList[EBML_ID_CHAPTERTIMESTART] = 'ChapterTimeStart';
1571
+ $EBMLidList[EBML_ID_CHAPTERTRACK] = 'ChapterTrack';
1572
+ $EBMLidList[EBML_ID_CHAPTERTRACKNUMBER] = 'ChapterTrackNumber';
1573
+ $EBMLidList[EBML_ID_CHAPTERTRANSLATE] = 'ChapterTranslate';
1574
+ $EBMLidList[EBML_ID_CHAPTERTRANSLATECODEC] = 'ChapterTranslateCodec';
1575
+ $EBMLidList[EBML_ID_CHAPTERTRANSLATEEDITIONUID] = 'ChapterTranslateEditionUID';
1576
+ $EBMLidList[EBML_ID_CHAPTERTRANSLATEID] = 'ChapterTranslateID';
1577
+ $EBMLidList[EBML_ID_CHAPTERUID] = 'ChapterUID';
1578
+ $EBMLidList[EBML_ID_CLUSTER] = 'Cluster';
1579
+ $EBMLidList[EBML_ID_CLUSTERBLOCK] = 'ClusterBlock';
1580
+ $EBMLidList[EBML_ID_CLUSTERBLOCKADDID] = 'ClusterBlockAddID';
1581
+ $EBMLidList[EBML_ID_CLUSTERBLOCKADDITIONAL] = 'ClusterBlockAdditional';
1582
+ $EBMLidList[EBML_ID_CLUSTERBLOCKADDITIONID] = 'ClusterBlockAdditionID';
1583
+ $EBMLidList[EBML_ID_CLUSTERBLOCKADDITIONS] = 'ClusterBlockAdditions';
1584
+ $EBMLidList[EBML_ID_CLUSTERBLOCKDURATION] = 'ClusterBlockDuration';
1585
+ $EBMLidList[EBML_ID_CLUSTERBLOCKGROUP] = 'ClusterBlockGroup';
1586
+ $EBMLidList[EBML_ID_CLUSTERBLOCKMORE] = 'ClusterBlockMore';
1587
+ $EBMLidList[EBML_ID_CLUSTERBLOCKVIRTUAL] = 'ClusterBlockVirtual';
1588
+ $EBMLidList[EBML_ID_CLUSTERCODECSTATE] = 'ClusterCodecState';
1589
+ $EBMLidList[EBML_ID_CLUSTERDELAY] = 'ClusterDelay';
1590
+ $EBMLidList[EBML_ID_CLUSTERDURATION] = 'ClusterDuration';
1591
+ $EBMLidList[EBML_ID_CLUSTERENCRYPTEDBLOCK] = 'ClusterEncryptedBlock';
1592
+ $EBMLidList[EBML_ID_CLUSTERFRAMENUMBER] = 'ClusterFrameNumber';
1593
+ $EBMLidList[EBML_ID_CLUSTERLACENUMBER] = 'ClusterLaceNumber';
1594
+ $EBMLidList[EBML_ID_CLUSTERPOSITION] = 'ClusterPosition';
1595
+ $EBMLidList[EBML_ID_CLUSTERPREVSIZE] = 'ClusterPrevSize';
1596
+ $EBMLidList[EBML_ID_CLUSTERREFERENCEBLOCK] = 'ClusterReferenceBlock';
1597
+ $EBMLidList[EBML_ID_CLUSTERREFERENCEPRIORITY] = 'ClusterReferencePriority';
1598
+ $EBMLidList[EBML_ID_CLUSTERREFERENCEVIRTUAL] = 'ClusterReferenceVirtual';
1599
+ $EBMLidList[EBML_ID_CLUSTERSILENTTRACKNUMBER] = 'ClusterSilentTrackNumber';
1600
+ $EBMLidList[EBML_ID_CLUSTERSILENTTRACKS] = 'ClusterSilentTracks';
1601
+ $EBMLidList[EBML_ID_CLUSTERSIMPLEBLOCK] = 'ClusterSimpleBlock';
1602
+ $EBMLidList[EBML_ID_CLUSTERTIMECODE] = 'ClusterTimecode';
1603
+ $EBMLidList[EBML_ID_CLUSTERTIMESLICE] = 'ClusterTimeSlice';
1604
+ $EBMLidList[EBML_ID_CODECDECODEALL] = 'CodecDecodeAll';
1605
+ $EBMLidList[EBML_ID_CODECDOWNLOADURL] = 'CodecDownloadURL';
1606
+ $EBMLidList[EBML_ID_CODECID] = 'CodecID';
1607
+ $EBMLidList[EBML_ID_CODECINFOURL] = 'CodecInfoURL';
1608
+ $EBMLidList[EBML_ID_CODECNAME] = 'CodecName';
1609
+ $EBMLidList[EBML_ID_CODECPRIVATE] = 'CodecPrivate';
1610
+ $EBMLidList[EBML_ID_CODECSETTINGS] = 'CodecSettings';
1611
+ $EBMLidList[EBML_ID_COLOURSPACE] = 'ColourSpace';
1612
+ $EBMLidList[EBML_ID_CONTENTCOMPALGO] = 'ContentCompAlgo';
1613
+ $EBMLidList[EBML_ID_CONTENTCOMPRESSION] = 'ContentCompression';
1614
+ $EBMLidList[EBML_ID_CONTENTCOMPSETTINGS] = 'ContentCompSettings';
1615
+ $EBMLidList[EBML_ID_CONTENTENCALGO] = 'ContentEncAlgo';
1616
+ $EBMLidList[EBML_ID_CONTENTENCKEYID] = 'ContentEncKeyID';
1617
+ $EBMLidList[EBML_ID_CONTENTENCODING] = 'ContentEncoding';
1618
+ $EBMLidList[EBML_ID_CONTENTENCODINGORDER] = 'ContentEncodingOrder';
1619
+ $EBMLidList[EBML_ID_CONTENTENCODINGS] = 'ContentEncodings';
1620
+ $EBMLidList[EBML_ID_CONTENTENCODINGSCOPE] = 'ContentEncodingScope';
1621
+ $EBMLidList[EBML_ID_CONTENTENCODINGTYPE] = 'ContentEncodingType';
1622
+ $EBMLidList[EBML_ID_CONTENTENCRYPTION] = 'ContentEncryption';
1623
+ $EBMLidList[EBML_ID_CONTENTSIGALGO] = 'ContentSigAlgo';
1624
+ $EBMLidList[EBML_ID_CONTENTSIGHASHALGO] = 'ContentSigHashAlgo';
1625
+ $EBMLidList[EBML_ID_CONTENTSIGKEYID] = 'ContentSigKeyID';
1626
+ $EBMLidList[EBML_ID_CONTENTSIGNATURE] = 'ContentSignature';
1627
+ $EBMLidList[EBML_ID_CRC32] = 'CRC32';
1628
+ $EBMLidList[EBML_ID_CUEBLOCKNUMBER] = 'CueBlockNumber';
1629
+ $EBMLidList[EBML_ID_CUECLUSTERPOSITION] = 'CueClusterPosition';
1630
+ $EBMLidList[EBML_ID_CUECODECSTATE] = 'CueCodecState';
1631
+ $EBMLidList[EBML_ID_CUEPOINT] = 'CuePoint';
1632
+ $EBMLidList[EBML_ID_CUEREFCLUSTER] = 'CueRefCluster';
1633
+ $EBMLidList[EBML_ID_CUEREFCODECSTATE] = 'CueRefCodecState';
1634
+ $EBMLidList[EBML_ID_CUEREFERENCE] = 'CueReference';
1635
+ $EBMLidList[EBML_ID_CUEREFNUMBER] = 'CueRefNumber';
1636
+ $EBMLidList[EBML_ID_CUEREFTIME] = 'CueRefTime';
1637
+ $EBMLidList[EBML_ID_CUES] = 'Cues';
1638
+ $EBMLidList[EBML_ID_CUETIME] = 'CueTime';
1639
+ $EBMLidList[EBML_ID_CUETRACK] = 'CueTrack';
1640
+ $EBMLidList[EBML_ID_CUETRACKPOSITIONS] = 'CueTrackPositions';
1641
+ $EBMLidList[EBML_ID_DATEUTC] = 'DateUTC';
1642
+ $EBMLidList[EBML_ID_DEFAULTDURATION] = 'DefaultDuration';
1643
+ $EBMLidList[EBML_ID_DISPLAYHEIGHT] = 'DisplayHeight';
1644
+ $EBMLidList[EBML_ID_DISPLAYUNIT] = 'DisplayUnit';
1645
+ $EBMLidList[EBML_ID_DISPLAYWIDTH] = 'DisplayWidth';
1646
+ $EBMLidList[EBML_ID_DOCTYPE] = 'DocType';
1647
+ $EBMLidList[EBML_ID_DOCTYPEREADVERSION] = 'DocTypeReadVersion';
1648
+ $EBMLidList[EBML_ID_DOCTYPEVERSION] = 'DocTypeVersion';
1649
+ $EBMLidList[EBML_ID_DURATION] = 'Duration';
1650
+ $EBMLidList[EBML_ID_EBML] = 'EBML';
1651
+ $EBMLidList[EBML_ID_EBMLMAXIDLENGTH] = 'EBMLMaxIDLength';
1652
+ $EBMLidList[EBML_ID_EBMLMAXSIZELENGTH] = 'EBMLMaxSizeLength';
1653
+ $EBMLidList[EBML_ID_EBMLREADVERSION] = 'EBMLReadVersion';
1654
+ $EBMLidList[EBML_ID_EBMLVERSION] = 'EBMLVersion';
1655
+ $EBMLidList[EBML_ID_EDITIONENTRY] = 'EditionEntry';
1656
+ $EBMLidList[EBML_ID_EDITIONFLAGDEFAULT] = 'EditionFlagDefault';
1657
+ $EBMLidList[EBML_ID_EDITIONFLAGHIDDEN] = 'EditionFlagHidden';
1658
+ $EBMLidList[EBML_ID_EDITIONFLAGORDERED] = 'EditionFlagOrdered';
1659
+ $EBMLidList[EBML_ID_EDITIONUID] = 'EditionUID';
1660
+ $EBMLidList[EBML_ID_FILEDATA] = 'FileData';
1661
+ $EBMLidList[EBML_ID_FILEDESCRIPTION] = 'FileDescription';
1662
+ $EBMLidList[EBML_ID_FILEMIMETYPE] = 'FileMimeType';
1663
+ $EBMLidList[EBML_ID_FILENAME] = 'FileName';
1664
+ $EBMLidList[EBML_ID_FILEREFERRAL] = 'FileReferral';
1665
+ $EBMLidList[EBML_ID_FILEUID] = 'FileUID';
1666
+ $EBMLidList[EBML_ID_FLAGDEFAULT] = 'FlagDefault';
1667
+ $EBMLidList[EBML_ID_FLAGENABLED] = 'FlagEnabled';
1668
+ $EBMLidList[EBML_ID_FLAGFORCED] = 'FlagForced';
1669
+ $EBMLidList[EBML_ID_FLAGINTERLACED] = 'FlagInterlaced';
1670
+ $EBMLidList[EBML_ID_FLAGLACING] = 'FlagLacing';
1671
+ $EBMLidList[EBML_ID_GAMMAVALUE] = 'GammaValue';
1672
+ $EBMLidList[EBML_ID_INFO] = 'Info';
1673
+ $EBMLidList[EBML_ID_LANGUAGE] = 'Language';
1674
+ $EBMLidList[EBML_ID_MAXBLOCKADDITIONID] = 'MaxBlockAdditionID';
1675
+ $EBMLidList[EBML_ID_MAXCACHE] = 'MaxCache';
1676
+ $EBMLidList[EBML_ID_MINCACHE] = 'MinCache';
1677
+ $EBMLidList[EBML_ID_MUXINGAPP] = 'MuxingApp';
1678
+ $EBMLidList[EBML_ID_NAME] = 'Name';
1679
+ $EBMLidList[EBML_ID_NEXTFILENAME] = 'NextFilename';
1680
+ $EBMLidList[EBML_ID_NEXTUID] = 'NextUID';
1681
+ $EBMLidList[EBML_ID_OUTPUTSAMPLINGFREQUENCY] = 'OutputSamplingFrequency';
1682
+ $EBMLidList[EBML_ID_PIXELCROPBOTTOM] = 'PixelCropBottom';
1683
+ $EBMLidList[EBML_ID_PIXELCROPLEFT] = 'PixelCropLeft';
1684
+ $EBMLidList[EBML_ID_PIXELCROPRIGHT] = 'PixelCropRight';
1685
+ $EBMLidList[EBML_ID_PIXELCROPTOP] = 'PixelCropTop';
1686
+ $EBMLidList[EBML_ID_PIXELHEIGHT] = 'PixelHeight';
1687
+ $EBMLidList[EBML_ID_PIXELWIDTH] = 'PixelWidth';
1688
+ $EBMLidList[EBML_ID_PREVFILENAME] = 'PrevFilename';
1689
+ $EBMLidList[EBML_ID_PREVUID] = 'PrevUID';
1690
+ $EBMLidList[EBML_ID_SAMPLINGFREQUENCY] = 'SamplingFrequency';
1691
+ $EBMLidList[EBML_ID_SEEK] = 'Seek';
1692
+ $EBMLidList[EBML_ID_SEEKHEAD] = 'SeekHead';
1693
+ $EBMLidList[EBML_ID_SEEKID] = 'SeekID';
1694
+ $EBMLidList[EBML_ID_SEEKPOSITION] = 'SeekPosition';
1695
+ $EBMLidList[EBML_ID_SEGMENT] = 'Segment';
1696
+ $EBMLidList[EBML_ID_SEGMENTFAMILY] = 'SegmentFamily';
1697
+ $EBMLidList[EBML_ID_SEGMENTFILENAME] = 'SegmentFilename';
1698
+ $EBMLidList[EBML_ID_SEGMENTUID] = 'SegmentUID';
1699
+ $EBMLidList[EBML_ID_SIMPLETAG] = 'SimpleTag';
1700
+ $EBMLidList[EBML_ID_CLUSTERSLICES] = 'ClusterSlices';
1701
+ $EBMLidList[EBML_ID_STEREOMODE] = 'StereoMode';
1702
+ $EBMLidList[EBML_ID_OLDSTEREOMODE] = 'OldStereoMode';
1703
+ $EBMLidList[EBML_ID_TAG] = 'Tag';
1704
+ $EBMLidList[EBML_ID_TAGATTACHMENTUID] = 'TagAttachmentUID';
1705
+ $EBMLidList[EBML_ID_TAGBINARY] = 'TagBinary';
1706
+ $EBMLidList[EBML_ID_TAGCHAPTERUID] = 'TagChapterUID';
1707
+ $EBMLidList[EBML_ID_TAGDEFAULT] = 'TagDefault';
1708
+ $EBMLidList[EBML_ID_TAGEDITIONUID] = 'TagEditionUID';
1709
+ $EBMLidList[EBML_ID_TAGLANGUAGE] = 'TagLanguage';
1710
+ $EBMLidList[EBML_ID_TAGNAME] = 'TagName';
1711
+ $EBMLidList[EBML_ID_TAGTRACKUID] = 'TagTrackUID';
1712
+ $EBMLidList[EBML_ID_TAGS] = 'Tags';
1713
+ $EBMLidList[EBML_ID_TAGSTRING] = 'TagString';
1714
+ $EBMLidList[EBML_ID_TARGETS] = 'Targets';
1715
+ $EBMLidList[EBML_ID_TARGETTYPE] = 'TargetType';
1716
+ $EBMLidList[EBML_ID_TARGETTYPEVALUE] = 'TargetTypeValue';
1717
+ $EBMLidList[EBML_ID_TIMECODESCALE] = 'TimecodeScale';
1718
+ $EBMLidList[EBML_ID_TITLE] = 'Title';
1719
+ $EBMLidList[EBML_ID_TRACKENTRY] = 'TrackEntry';
1720
+ $EBMLidList[EBML_ID_TRACKNUMBER] = 'TrackNumber';
1721
+ $EBMLidList[EBML_ID_TRACKOFFSET] = 'TrackOffset';
1722
+ $EBMLidList[EBML_ID_TRACKOVERLAY] = 'TrackOverlay';
1723
+ $EBMLidList[EBML_ID_TRACKS] = 'Tracks';
1724
+ $EBMLidList[EBML_ID_TRACKTIMECODESCALE] = 'TrackTimecodeScale';
1725
+ $EBMLidList[EBML_ID_TRACKTRANSLATE] = 'TrackTranslate';
1726
+ $EBMLidList[EBML_ID_TRACKTRANSLATECODEC] = 'TrackTranslateCodec';
1727
+ $EBMLidList[EBML_ID_TRACKTRANSLATEEDITIONUID] = 'TrackTranslateEditionUID';
1728
+ $EBMLidList[EBML_ID_TRACKTRANSLATETRACKID] = 'TrackTranslateTrackID';
1729
+ $EBMLidList[EBML_ID_TRACKTYPE] = 'TrackType';
1730
+ $EBMLidList[EBML_ID_TRACKUID] = 'TrackUID';
1731
+ $EBMLidList[EBML_ID_VIDEO] = 'Video';
1732
+ $EBMLidList[EBML_ID_VOID] = 'Void';
1733
+ $EBMLidList[EBML_ID_WRITINGAPP] = 'WritingApp';
1734
+ }
1735
+
1736
+ return (isset($EBMLidList[$value]) ? $EBMLidList[$value] : dechex($value));
1737
+ }
1738
+
1739
+ public static function displayUnit($value) {
1740
+ // http://www.matroska.org/technical/specs/index.html#DisplayUnit
1741
+ static $units = array(
1742
+ 0 => 'pixels',
1743
+ 1 => 'centimeters',
1744
+ 2 => 'inches',
1745
+ 3 => 'Display Aspect Ratio');
1746
+
1747
+ return (isset($units[$value]) ? $units[$value] : 'unknown');
1748
+ }
1749
+
1750
+ private static function getDefaultStreamInfo($streams)
1751
+ {
1752
+ foreach (array_reverse($streams) as $stream) {
1753
+ if ($stream['default']) {
1754
+ break;
1755
+ }
1756
+ }
1757
+
1758
+ $unset = array('default', 'name');
1759
+ foreach ($unset as $u) {
1760
+ if (isset($stream[$u])) {
1761
+ unset($stream[$u]);
1762
+ }
1763
+ }
1764
+
1765
+ $info = $stream;
1766
+ $info['streams'] = $streams;
1767
+
1768
+ return $info;
1769
+ }
1770
+
1771
+ }
{view → includes}/getid3/module.audio-video.mpeg.php RENAMED
@@ -1,292 +1,296 @@
1
- <?php
2
- /////////////////////////////////////////////////////////////////
3
- /// getID3() by James Heinrich <info@getid3.org> //
4
- // available at http://getid3.sourceforge.net //
5
- // or http://www.getid3.org //
6
- /////////////////////////////////////////////////////////////////
7
- // See readme.txt for more details //
8
- /////////////////////////////////////////////////////////////////
9
- // //
10
- // module.audio-video.mpeg.php //
11
- // module for analyzing MPEG files //
12
- // dependencies: module.audio.mp3.php //
13
- // ///
14
- /////////////////////////////////////////////////////////////////
15
-
16
- getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, true);
17
-
18
- define('GETID3_MPEG_VIDEO_PICTURE_START', "\x00\x00\x01\x00");
19
- define('GETID3_MPEG_VIDEO_USER_DATA_START', "\x00\x00\x01\xB2");
20
- define('GETID3_MPEG_VIDEO_SEQUENCE_HEADER', "\x00\x00\x01\xB3");
21
- define('GETID3_MPEG_VIDEO_SEQUENCE_ERROR', "\x00\x00\x01\xB4");
22
- define('GETID3_MPEG_VIDEO_EXTENSION_START', "\x00\x00\x01\xB5");
23
- define('GETID3_MPEG_VIDEO_SEQUENCE_END', "\x00\x00\x01\xB7");
24
- define('GETID3_MPEG_VIDEO_GROUP_START', "\x00\x00\x01\xB8");
25
- define('GETID3_MPEG_AUDIO_START', "\x00\x00\x01\xC0");
26
-
27
-
28
- class getid3_mpeg
29
- {
30
-
31
- function getid3_mpeg(&$fd, &$ThisFileInfo) {
32
- if ($ThisFileInfo['avdataend'] <= $ThisFileInfo['avdataoffset']) {
33
- $ThisFileInfo['error'][] = '"avdataend" ('.$ThisFileInfo['avdataend'].') is unexpectedly less-than-or-equal-to "avdataoffset" ('.$ThisFileInfo['avdataoffset'].')';
34
- return false;
35
- }
36
- $ThisFileInfo['fileformat'] = 'mpeg';
37
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
38
- $MPEGstreamData = fread($fd, min(100000, $ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']));
39
- $MPEGstreamDataLength = strlen($MPEGstreamData);
40
-
41
- $foundVideo = true;
42
- $VideoChunkOffset = 0;
43
- while (substr($MPEGstreamData, $VideoChunkOffset++, 4) !== GETID3_MPEG_VIDEO_SEQUENCE_HEADER) {
44
- if ($VideoChunkOffset >= $MPEGstreamDataLength) {
45
- $foundVideo = false;
46
- break;
47
- }
48
- }
49
- if ($foundVideo) {
50
-
51
- // Start code 32 bits
52
- // horizontal frame size 12 bits
53
- // vertical frame size 12 bits
54
- // pixel aspect ratio 4 bits
55
- // frame rate 4 bits
56
- // bitrate 18 bits
57
- // marker bit 1 bit
58
- // VBV buffer size 10 bits
59
- // constrained parameter flag 1 bit
60
- // intra quant. matrix flag 1 bit
61
- // intra quant. matrix values 512 bits (present if matrix flag == 1)
62
- // non-intra quant. matrix flag 1 bit
63
- // non-intra quant. matrix values 512 bits (present if matrix flag == 1)
64
-
65
- $ThisFileInfo['video']['dataformat'] = 'mpeg';
66
-
67
- $VideoChunkOffset += (strlen(GETID3_MPEG_VIDEO_SEQUENCE_HEADER) - 1);
68
-
69
- $FrameSizeDWORD = getid3_lib::BigEndian2Int(substr($MPEGstreamData, $VideoChunkOffset, 3));
70
- $VideoChunkOffset += 3;
71
-
72
- $AspectRatioFrameRateDWORD = getid3_lib::BigEndian2Int(substr($MPEGstreamData, $VideoChunkOffset, 1));
73
- $VideoChunkOffset += 1;
74
-
75
- $assortedinformation = getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $VideoChunkOffset, 4));
76
- $VideoChunkOffset += 4;
77
-
78
- $ThisFileInfo['mpeg']['video']['raw']['framesize_horizontal'] = ($FrameSizeDWORD & 0xFFF000) >> 12; // 12 bits for horizontal frame size
79
- $ThisFileInfo['mpeg']['video']['raw']['framesize_vertical'] = ($FrameSizeDWORD & 0x000FFF); // 12 bits for vertical frame size
80
- $ThisFileInfo['mpeg']['video']['raw']['pixel_aspect_ratio'] = ($AspectRatioFrameRateDWORD & 0xF0) >> 4;
81
- $ThisFileInfo['mpeg']['video']['raw']['frame_rate'] = ($AspectRatioFrameRateDWORD & 0x0F);
82
-
83
- $ThisFileInfo['mpeg']['video']['framesize_horizontal'] = $ThisFileInfo['mpeg']['video']['raw']['framesize_horizontal'];
84
- $ThisFileInfo['mpeg']['video']['framesize_vertical'] = $ThisFileInfo['mpeg']['video']['raw']['framesize_vertical'];
85
-
86
- $ThisFileInfo['mpeg']['video']['pixel_aspect_ratio'] = $this->MPEGvideoAspectRatioLookup($ThisFileInfo['mpeg']['video']['raw']['pixel_aspect_ratio']);
87
- $ThisFileInfo['mpeg']['video']['pixel_aspect_ratio_text'] = $this->MPEGvideoAspectRatioTextLookup($ThisFileInfo['mpeg']['video']['raw']['pixel_aspect_ratio']);
88
- $ThisFileInfo['mpeg']['video']['frame_rate'] = $this->MPEGvideoFramerateLookup($ThisFileInfo['mpeg']['video']['raw']['frame_rate']);
89
-
90
- $ThisFileInfo['mpeg']['video']['raw']['bitrate'] = getid3_lib::Bin2Dec(substr($assortedinformation, 0, 18));
91
- $ThisFileInfo['mpeg']['video']['raw']['marker_bit'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 18, 1));
92
- $ThisFileInfo['mpeg']['video']['raw']['vbv_buffer_size'] = getid3_lib::Bin2Dec(substr($assortedinformation, 19, 10));
93
- $ThisFileInfo['mpeg']['video']['raw']['constrained_param_flag'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 29, 1));
94
- $ThisFileInfo['mpeg']['video']['raw']['intra_quant_flag'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 30, 1));
95
- if ($ThisFileInfo['mpeg']['video']['raw']['intra_quant_flag']) {
96
-
97
- // read 512 bits
98
- $ThisFileInfo['mpeg']['video']['raw']['intra_quant'] = getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $VideoChunkOffset, 64));
99
- $VideoChunkOffset += 64;
100
-
101
- $ThisFileInfo['mpeg']['video']['raw']['non_intra_quant_flag'] = (bool) getid3_lib::Bin2Dec(substr($ThisFileInfo['mpeg']['video']['raw']['intra_quant'], 511, 1));
102
- $ThisFileInfo['mpeg']['video']['raw']['intra_quant'] = getid3_lib::Bin2Dec(substr($assortedinformation, 31, 1)).substr(getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $VideoChunkOffset, 64)), 0, 511);
103
-
104
- if ($ThisFileInfo['mpeg']['video']['raw']['non_intra_quant_flag']) {
105
- $ThisFileInfo['mpeg']['video']['raw']['non_intra_quant'] = substr($MPEGstreamData, $VideoChunkOffset, 64);
106
- $VideoChunkOffset += 64;
107
- }
108
-
109
- } else {
110
-
111
- $ThisFileInfo['mpeg']['video']['raw']['non_intra_quant_flag'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 31, 1));
112
- if ($ThisFileInfo['mpeg']['video']['raw']['non_intra_quant_flag']) {
113
- $ThisFileInfo['mpeg']['video']['raw']['non_intra_quant'] = substr($MPEGstreamData, $VideoChunkOffset, 64);
114
- $VideoChunkOffset += 64;
115
- }
116
-
117
- }
118
-
119
- if ($ThisFileInfo['mpeg']['video']['raw']['bitrate'] == 0x3FFFF) { // 18 set bits
120
-
121
- $ThisFileInfo['warning'][] = 'This version of getID3() ['.GETID3_VERSION.'] cannot determine average bitrate of VBR MPEG video files';
122
- $ThisFileInfo['mpeg']['video']['bitrate_mode'] = 'vbr';
123
-
124
- } else {
125
-
126
- $ThisFileInfo['mpeg']['video']['bitrate'] = $ThisFileInfo['mpeg']['video']['raw']['bitrate'] * 400;
127
- $ThisFileInfo['mpeg']['video']['bitrate_mode'] = 'cbr';
128
- $ThisFileInfo['video']['bitrate'] = $ThisFileInfo['mpeg']['video']['bitrate'];
129
-
130
- }
131
-
132
- $ThisFileInfo['video']['resolution_x'] = $ThisFileInfo['mpeg']['video']['framesize_horizontal'];
133
- $ThisFileInfo['video']['resolution_y'] = $ThisFileInfo['mpeg']['video']['framesize_vertical'];
134
- $ThisFileInfo['video']['frame_rate'] = $ThisFileInfo['mpeg']['video']['frame_rate'];
135
- $ThisFileInfo['video']['bitrate_mode'] = $ThisFileInfo['mpeg']['video']['bitrate_mode'];
136
- $ThisFileInfo['video']['pixel_aspect_ratio'] = $ThisFileInfo['mpeg']['video']['pixel_aspect_ratio'];
137
- $ThisFileInfo['video']['lossless'] = false;
138
- $ThisFileInfo['video']['bits_per_sample'] = 24;
139
-
140
- } else {
141
-
142
- $ThisFileInfo['error'][] = 'Could not find start of video block in the first 100,000 bytes (or before end of file) - this might not be an MPEG-video file?';
143
-
144
- }
145
-
146
- //0x000001B3 begins the sequence_header of every MPEG video stream.
147
- //But in MPEG-2, this header must immediately be followed by an
148
- //extension_start_code (0x000001B5) with a sequence_extension ID (1).
149
- //(This extension contains all the additional MPEG-2 stuff.)
150
- //MPEG-1 doesn't have this extension, so that's a sure way to tell the
151
- //difference between MPEG-1 and MPEG-2 video streams.
152
-
153
- if (substr($MPEGstreamData, $VideoChunkOffset, 4) == GETID3_MPEG_VIDEO_EXTENSION_START) {
154
- $ThisFileInfo['video']['codec'] = 'MPEG-2';
155
- } else {
156
- $ThisFileInfo['video']['codec'] = 'MPEG-1';
157
- }
158
-
159
-
160
- $AudioChunkOffset = 0;
161
- while (true) {
162
- while (substr($MPEGstreamData, $AudioChunkOffset++, 4) !== GETID3_MPEG_AUDIO_START) {
163
- if ($AudioChunkOffset >= $MPEGstreamDataLength) {
164
- break 2;
165
- }
166
- }
167
-
168
- for ($i = 0; $i <= 7; $i++) {
169
- // some files have the MPEG-audio header 8 bytes after the end of the $00 $00 $01 $C0 signature, some have it up to 13 bytes (or more?) after
170
- // I have no idea why or what the difference is, so this is a stupid hack.
171
- // If anybody has any better idea of what's going on, please let me know - info@getid3.org
172
-
173
- $dummy = $ThisFileInfo;
174
- if (getid3_mp3::decodeMPEGaudioHeader($fd, ($AudioChunkOffset + 3) + 8 + $i, $dummy, false)) {
175
- $ThisFileInfo = $dummy;
176
- $ThisFileInfo['audio']['bitrate_mode'] = 'cbr';
177
- $ThisFileInfo['audio']['lossless'] = false;
178
- break 2;
179
-
180
- }
181
- }
182
- }
183
-
184
- // Temporary hack to account for interleaving overhead:
185
- if (!empty($ThisFileInfo['video']['bitrate']) && !empty($ThisFileInfo['audio']['bitrate'])) {
186
- $ThisFileInfo['playtime_seconds'] = (($ThisFileInfo['avdataend'] - $ThisFileInfo['avdataoffset']) * 8) / ($ThisFileInfo['video']['bitrate'] + $ThisFileInfo['audio']['bitrate']);
187
-
188
- // Interleaved MPEG audio/video files have a certain amount of overhead that varies
189
- // by both video and audio bitrates, and not in any sensible, linear/logarithmic patter
190
- // Use interpolated lookup tables to approximately guess how much is overhead, because
191
- // playtime is calculated as filesize / total-bitrate
192
- $ThisFileInfo['playtime_seconds'] *= $this->MPEGsystemNonOverheadPercentage($ThisFileInfo['video']['bitrate'], $ThisFileInfo['audio']['bitrate']);
193
-
194
- //switch ($ThisFileInfo['video']['bitrate']) {
195
- // case('5000000'):
196
- // $multiplier = 0.93292642112380355828048824319889;
197
- // break;
198
- // case('5500000'):
199
- // $multiplier = 0.93582895375200989965359777343219;
200
- // break;
201
- // case('6000000'):
202
- // $multiplier = 0.93796247714820932532911373859139;
203
- // break;
204
- // case('7000000'):
205
- // $multiplier = 0.9413264083635103463010117778776;
206
- // break;
207
- // default:
208
- // $multiplier = 1;
209
- // break;
210
- //}
211
- //$ThisFileInfo['playtime_seconds'] *= $multiplier;
212
- //$ThisFileInfo['warning'][] = 'Interleaved MPEG audio/video playtime may be inaccurate. With current hack should be within a few seconds of accurate. Report to info@getid3.org if off by more than 10 seconds.';
213
- if ($ThisFileInfo['video']['bitrate'] < 50000) {
214
- $ThisFileInfo['warning'][] = 'Interleaved MPEG audio/video playtime may be slightly inaccurate for video bitrates below 100kbps. Except in extreme low-bitrate situations, error should be less than 1%. Report to info@getid3.org if greater than this.';
215
- }
216
- }
217
-
218
- return true;
219
- }
220
-
221
-
222
- function MPEGsystemNonOverheadPercentage($VideoBitrate, $AudioBitrate) {
223
- $OverheadPercentage = 0;
224
-
225
- $AudioBitrate = max(min($AudioBitrate / 1000, 384), 32); // limit to range of 32kbps - 384kbps (should be only legal bitrates, but maybe VBR?)
226
- $VideoBitrate = max(min($VideoBitrate / 1000, 10000), 10); // limit to range of 10kbps - 10Mbps (beyond that curves flatten anyways, no big loss)
227
-
228
-
229
- //OMBB[audiobitrate] = array(video-10kbps, video-100kbps, video-1000kbps, video-10000kbps)
230
- $OverheadMultiplierByBitrate[32] = array(0, 0.9676287944368530, 0.9802276264360310, 0.9844916183244460, 0.9852821845179940);
231
- $OverheadMultiplierByBitrate[48] = array(0, 0.9779100089209830, 0.9787770035359320, 0.9846738664076130, 0.9852683013799960);
232
- $OverheadMultiplierByBitrate[56] = array(0, 0.9731249855367600, 0.9776624308938040, 0.9832606361852130, 0.9843922606633340);
233
- $OverheadMultiplierByBitrate[64] = array(0, 0.9755642683275760, 0.9795256705493390, 0.9836573009193170, 0.9851122539404470);
234
- $OverheadMultiplierByBitrate[96] = array(0, 0.9788025247497290, 0.9798553314148700, 0.9822956869792560, 0.9834815119124690);
235
- $OverheadMultiplierByBitrate[128] = array(0, 0.9816940050925480, 0.9821675936072120, 0.9829756927470870, 0.9839763420152050);
236
- $OverheadMultiplierByBitrate[160] = array(0, 0.9825894094561180, 0.9820913399073960, 0.9823907143253970, 0.9832821783651570);
237
- $OverheadMultiplierByBitrate[192] = array(0, 0.9832038474336260, 0.9825731694317960, 0.9821028622712400, 0.9828262076447620);
238
- $OverheadMultiplierByBitrate[224] = array(0, 0.9836516298538770, 0.9824718601823890, 0.9818302180625380, 0.9823735101626480);
239
- $OverheadMultiplierByBitrate[256] = array(0, 0.9845863022094920, 0.9837229411967540, 0.9824521662210830, 0.9828645172100790);
240
- $OverheadMultiplierByBitrate[320] = array(0, 0.9849565280263180, 0.9837683142805110, 0.9822885275960400, 0.9824424382727190);
241
- $OverheadMultiplierByBitrate[384] = array(0, 0.9856094774357600, 0.9844573394432720, 0.9825970399837330, 0.9824673808303890);
242
-
243
- $BitrateToUseMin = 32;
244
- $BitrateToUseMax = 32;
245
- $previousBitrate = 32;
246
- foreach ($OverheadMultiplierByBitrate as $key => $value) {
247
- if ($AudioBitrate >= $previousBitrate) {
248
- $BitrateToUseMin = $previousBitrate;
249
- }
250
- if ($AudioBitrate < $key) {
251
- $BitrateToUseMax = $key;
252
- break;
253
- }
254
- $previousBitrate = $key;
255
- }
256
- $FactorA = ($BitrateToUseMax - $AudioBitrate) / ($BitrateToUseMax - $BitrateToUseMin);
257
-
258
- $VideoBitrateLog10 = log10($VideoBitrate);
259
- $VideoFactorMin1 = $OverheadMultiplierByBitrate[$BitrateToUseMin][floor($VideoBitrateLog10)];
260
- $VideoFactorMin2 = $OverheadMultiplierByBitrate[$BitrateToUseMax][floor($VideoBitrateLog10)];
261
- $VideoFactorMax1 = $OverheadMultiplierByBitrate[$BitrateToUseMin][ceil($VideoBitrateLog10)];
262
- $VideoFactorMax2 = $OverheadMultiplierByBitrate[$BitrateToUseMax][ceil($VideoBitrateLog10)];
263
- $FactorV = $VideoBitrateLog10 - floor($VideoBitrateLog10);
264
-
265
- $OverheadPercentage = $VideoFactorMin1 * $FactorA * $FactorV;
266
- $OverheadPercentage += $VideoFactorMin2 * (1 - $FactorA) * $FactorV;
267
- $OverheadPercentage += $VideoFactorMax1 * $FactorA * (1 - $FactorV);
268
- $OverheadPercentage += $VideoFactorMax2 * (1 - $FactorA) * (1 - $FactorV);
269
-
270
- return $OverheadPercentage;
271
- }
272
-
273
-
274
- function MPEGvideoFramerateLookup($rawframerate) {
275
- $MPEGvideoFramerateLookup = array(0, 23.976, 24, 25, 29.97, 30, 50, 59.94, 60);
276
- return (isset($MPEGvideoFramerateLookup[$rawframerate]) ? (float) $MPEGvideoFramerateLookup[$rawframerate] : (float) 0);
277
- }
278
-
279
- function MPEGvideoAspectRatioLookup($rawaspectratio) {
280
- $MPEGvideoAspectRatioLookup = array(0, 1, 0.6735, 0.7031, 0.7615, 0.8055, 0.8437, 0.8935, 0.9157, 0.9815, 1.0255, 1.0695, 1.0950, 1.1575, 1.2015, 0);
281
- return (isset($MPEGvideoAspectRatioLookup[$rawaspectratio]) ? (float) $MPEGvideoAspectRatioLookup[$rawaspectratio] : (float) 0);
282
- }
283
-
284
- function MPEGvideoAspectRatioTextLookup($rawaspectratio) {
285
- $MPEGvideoAspectRatioTextLookup = array('forbidden', 'square pixels', '0.6735', '16:9, 625 line, PAL', '0.7615', '0.8055', '16:9, 525 line, NTSC', '0.8935', '4:3, 625 line, PAL, CCIR601', '0.9815', '1.0255', '1.0695', '4:3, 525 line, NTSC, CCIR601', '1.1575', '1.2015', 'reserved');
286
- return (isset($MPEGvideoAspectRatioTextLookup[$rawaspectratio]) ? $MPEGvideoAspectRatioTextLookup[$rawaspectratio] : '');
287
- }
288
-
289
- }
290
-
291
-
292
- ?>
 
 
 
 
1
+ <?php
2
+ /////////////////////////////////////////////////////////////////
3
+ /// getID3() by James Heinrich <info@getid3.org> //
4
+ // available at http://getid3.sourceforge.net //
5
+ // or http://www.getid3.org //
6
+ /////////////////////////////////////////////////////////////////
7
+ // See readme.txt for more details //
8
+ /////////////////////////////////////////////////////////////////
9
+ // //
10
+ // module.audio-video.mpeg.php //
11
+ // module for analyzing MPEG files //
12
+ // dependencies: module.audio.mp3.php //
13
+ // ///
14
+ /////////////////////////////////////////////////////////////////
15
+
16
+ getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, true);
17
+
18
+ define('GETID3_MPEG_VIDEO_PICTURE_START', "\x00\x00\x01\x00");
19
+ define('GETID3_MPEG_VIDEO_USER_DATA_START', "\x00\x00\x01\xB2");
20
+ define('GETID3_MPEG_VIDEO_SEQUENCE_HEADER', "\x00\x00\x01\xB3");
21
+ define('GETID3_MPEG_VIDEO_SEQUENCE_ERROR', "\x00\x00\x01\xB4");
22
+ define('GETID3_MPEG_VIDEO_EXTENSION_START', "\x00\x00\x01\xB5");
23
+ define('GETID3_MPEG_VIDEO_SEQUENCE_END', "\x00\x00\x01\xB7");
24
+ define('GETID3_MPEG_VIDEO_GROUP_START', "\x00\x00\x01\xB8");
25
+ define('GETID3_MPEG_AUDIO_START', "\x00\x00\x01\xC0");
26
+
27
+
28
+ class getid3_mpeg extends getid3_handler
29
+ {
30
+
31
+ public function Analyze() {
32
+ $info = &$this->getid3->info;
33
+
34
+ if ($info['avdataend'] <= $info['avdataoffset']) {
35
+ $info['error'][] = '"avdataend" ('.$info['avdataend'].') is unexpectedly less-than-or-equal-to "avdataoffset" ('.$info['avdataoffset'].')';
36
+ return false;
37
+ }
38
+ $info['fileformat'] = 'mpeg';
39
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
40
+ $MPEGstreamData = fread($this->getid3->fp, min(100000, $info['avdataend'] - $info['avdataoffset']));
41
+ $MPEGstreamDataLength = strlen($MPEGstreamData);
42
+
43
+ $foundVideo = true;
44
+ $VideoChunkOffset = 0;
45
+ while (substr($MPEGstreamData, $VideoChunkOffset++, 4) !== GETID3_MPEG_VIDEO_SEQUENCE_HEADER) {
46
+ if ($VideoChunkOffset >= $MPEGstreamDataLength) {
47
+ $foundVideo = false;
48
+ break;
49
+ }
50
+ }
51
+ if ($foundVideo) {
52
+
53
+ // Start code 32 bits
54
+ // horizontal frame size 12 bits
55
+ // vertical frame size 12 bits
56
+ // pixel aspect ratio 4 bits
57
+ // frame rate 4 bits
58
+ // bitrate 18 bits
59
+ // marker bit 1 bit
60
+ // VBV buffer size 10 bits
61
+ // constrained parameter flag 1 bit
62
+ // intra quant. matrix flag 1 bit
63
+ // intra quant. matrix values 512 bits (present if matrix flag == 1)
64
+ // non-intra quant. matrix flag 1 bit
65
+ // non-intra quant. matrix values 512 bits (present if matrix flag == 1)
66
+
67
+ $info['video']['dataformat'] = 'mpeg';
68
+
69
+ $VideoChunkOffset += (strlen(GETID3_MPEG_VIDEO_SEQUENCE_HEADER) - 1);
70
+
71
+ $FrameSizeDWORD = getid3_lib::BigEndian2Int(substr($MPEGstreamData, $VideoChunkOffset, 3));
72
+ $VideoChunkOffset += 3;
73
+
74
+ $AspectRatioFrameRateDWORD = getid3_lib::BigEndian2Int(substr($MPEGstreamData, $VideoChunkOffset, 1));
75
+ $VideoChunkOffset += 1;
76
+
77
+ $assortedinformation = getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $VideoChunkOffset, 4));
78
+ $VideoChunkOffset += 4;
79
+
80
+ $info['mpeg']['video']['raw']['framesize_horizontal'] = ($FrameSizeDWORD & 0xFFF000) >> 12; // 12 bits for horizontal frame size
81
+ $info['mpeg']['video']['raw']['framesize_vertical'] = ($FrameSizeDWORD & 0x000FFF); // 12 bits for vertical frame size
82
+ $info['mpeg']['video']['raw']['pixel_aspect_ratio'] = ($AspectRatioFrameRateDWORD & 0xF0) >> 4;
83
+ $info['mpeg']['video']['raw']['frame_rate'] = ($AspectRatioFrameRateDWORD & 0x0F);
84
+
85
+ $info['mpeg']['video']['framesize_horizontal'] = $info['mpeg']['video']['raw']['framesize_horizontal'];
86
+ $info['mpeg']['video']['framesize_vertical'] = $info['mpeg']['video']['raw']['framesize_vertical'];
87
+
88
+ $info['mpeg']['video']['pixel_aspect_ratio'] = $this->MPEGvideoAspectRatioLookup($info['mpeg']['video']['raw']['pixel_aspect_ratio']);
89
+ $info['mpeg']['video']['pixel_aspect_ratio_text'] = $this->MPEGvideoAspectRatioTextLookup($info['mpeg']['video']['raw']['pixel_aspect_ratio']);
90
+ $info['mpeg']['video']['frame_rate'] = $this->MPEGvideoFramerateLookup($info['mpeg']['video']['raw']['frame_rate']);
91
+
92
+ $info['mpeg']['video']['raw']['bitrate'] = getid3_lib::Bin2Dec(substr($assortedinformation, 0, 18));
93
+ $info['mpeg']['video']['raw']['marker_bit'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 18, 1));
94
+ $info['mpeg']['video']['raw']['vbv_buffer_size'] = getid3_lib::Bin2Dec(substr($assortedinformation, 19, 10));
95
+ $info['mpeg']['video']['raw']['constrained_param_flag'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 29, 1));
96
+ $info['mpeg']['video']['raw']['intra_quant_flag'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 30, 1));
97
+ if ($info['mpeg']['video']['raw']['intra_quant_flag']) {
98
+
99
+ // read 512 bits
100
+ $info['mpeg']['video']['raw']['intra_quant'] = getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $VideoChunkOffset, 64));
101
+ $VideoChunkOffset += 64;
102
+
103
+ $info['mpeg']['video']['raw']['non_intra_quant_flag'] = (bool) getid3_lib::Bin2Dec(substr($info['mpeg']['video']['raw']['intra_quant'], 511, 1));
104
+ $info['mpeg']['video']['raw']['intra_quant'] = getid3_lib::Bin2Dec(substr($assortedinformation, 31, 1)).substr(getid3_lib::BigEndian2Bin(substr($MPEGstreamData, $VideoChunkOffset, 64)), 0, 511);
105
+
106
+ if ($info['mpeg']['video']['raw']['non_intra_quant_flag']) {
107
+ $info['mpeg']['video']['raw']['non_intra_quant'] = substr($MPEGstreamData, $VideoChunkOffset, 64);
108
+ $VideoChunkOffset += 64;
109
+ }
110
+
111
+ } else {
112
+
113
+ $info['mpeg']['video']['raw']['non_intra_quant_flag'] = (bool) getid3_lib::Bin2Dec(substr($assortedinformation, 31, 1));
114
+ if ($info['mpeg']['video']['raw']['non_intra_quant_flag']) {
115
+ $info['mpeg']['video']['raw']['non_intra_quant'] = substr($MPEGstreamData, $VideoChunkOffset, 64);
116
+ $VideoChunkOffset += 64;
117
+ }
118
+
119
+ }
120
+
121
+ if ($info['mpeg']['video']['raw']['bitrate'] == 0x3FFFF) { // 18 set bits
122
+
123
+ $info['warning'][] = 'This version of getID3() ['.$this->getid3->version().'] cannot determine average bitrate of VBR MPEG video files';
124
+ $info['mpeg']['video']['bitrate_mode'] = 'vbr';
125
+
126
+ } else {
127
+
128
+ $info['mpeg']['video']['bitrate'] = $info['mpeg']['video']['raw']['bitrate'] * 400;
129
+ $info['mpeg']['video']['bitrate_mode'] = 'cbr';
130
+ $info['video']['bitrate'] = $info['mpeg']['video']['bitrate'];
131
+
132
+ }
133
+
134
+ $info['video']['resolution_x'] = $info['mpeg']['video']['framesize_horizontal'];
135
+ $info['video']['resolution_y'] = $info['mpeg']['video']['framesize_vertical'];
136
+ $info['video']['frame_rate'] = $info['mpeg']['video']['frame_rate'];
137
+ $info['video']['bitrate_mode'] = $info['mpeg']['video']['bitrate_mode'];
138
+ $info['video']['pixel_aspect_ratio'] = $info['mpeg']['video']['pixel_aspect_ratio'];
139
+ $info['video']['lossless'] = false;
140
+ $info['video']['bits_per_sample'] = 24;
141
+
142
+ } else {
143
+
144
+ $info['error'][] = 'Could not find start of video block in the first 100,000 bytes (or before end of file) - this might not be an MPEG-video file?';
145
+
146
+ }
147
+
148
+ //0x000001B3 begins the sequence_header of every MPEG video stream.
149
+ //But in MPEG-2, this header must immediately be followed by an
150
+ //extension_start_code (0x000001B5) with a sequence_extension ID (1).
151
+ //(This extension contains all the additional MPEG-2 stuff.)
152
+ //MPEG-1 doesn't have this extension, so that's a sure way to tell the
153
+ //difference between MPEG-1 and MPEG-2 video streams.
154
+
155
+ if (substr($MPEGstreamData, $VideoChunkOffset, 4) == GETID3_MPEG_VIDEO_EXTENSION_START) {
156
+ $info['video']['codec'] = 'MPEG-2';
157
+ } else {
158
+ $info['video']['codec'] = 'MPEG-1';
159
+ }
160
+
161
+
162
+ $AudioChunkOffset = 0;
163
+ while (true) {
164
+ while (substr($MPEGstreamData, $AudioChunkOffset++, 4) !== GETID3_MPEG_AUDIO_START) {
165
+ if ($AudioChunkOffset >= $MPEGstreamDataLength) {
166
+ break 2;
167
+ }
168
+ }
169
+
170
+ $getid3_temp = new getID3();
171
+ $getid3_temp->openfile($this->getid3->filename);
172
+ $getid3_temp->info = $info;
173
+ $getid3_mp3 = new getid3_mp3($getid3_temp);
174
+ for ($i = 0; $i <= 7; $i++) {
175
+ // some files have the MPEG-audio header 8 bytes after the end of the $00 $00 $01 $C0 signature, some have it up to 13 bytes (or more?) after
176
+ // I have no idea why or what the difference is, so this is a stupid hack.
177
+ // If anybody has any better idea of what's going on, please let me know - info@getid3.org
178
+ fseek($getid3_temp->fp, ftell($this->getid3->fp), SEEK_SET);
179
+ $getid3_temp->info = $info; // only overwrite real data if valid header found
180
+ if ($getid3_mp3->decodeMPEGaudioHeader(($AudioChunkOffset + 3) + 8 + $i, $getid3_temp->info, false)) {
181
+ $info = $getid3_temp->info;
182
+ $info['audio']['bitrate_mode'] = 'cbr';
183
+ $info['audio']['lossless'] = false;
184
+ unset($getid3_temp, $getid3_mp3);
185
+ break 2;
186
+ }
187
+ }
188
+ unset($getid3_temp, $getid3_mp3);
189
+ }
190
+
191
+ // Temporary hack to account for interleaving overhead:
192
+ if (!empty($info['video']['bitrate']) && !empty($info['audio']['bitrate'])) {
193
+ $info['playtime_seconds'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / ($info['video']['bitrate'] + $info['audio']['bitrate']);
194
+
195
+ // Interleaved MPEG audio/video files have a certain amount of overhead that varies
196
+ // by both video and audio bitrates, and not in any sensible, linear/logarithmic patter
197
+ // Use interpolated lookup tables to approximately guess how much is overhead, because
198
+ // playtime is calculated as filesize / total-bitrate
199
+ $info['playtime_seconds'] *= $this->MPEGsystemNonOverheadPercentage($info['video']['bitrate'], $info['audio']['bitrate']);
200
+
201
+ //switch ($info['video']['bitrate']) {
202
+ // case('5000000'):
203
+ // $multiplier = 0.93292642112380355828048824319889;
204
+ // break;
205
+ // case('5500000'):
206
+ // $multiplier = 0.93582895375200989965359777343219;
207
+ // break;
208
+ // case('6000000'):
209
+ // $multiplier = 0.93796247714820932532911373859139;
210
+ // break;
211
+ // case('7000000'):
212
+ // $multiplier = 0.9413264083635103463010117778776;
213
+ // break;
214
+ // default:
215
+ // $multiplier = 1;
216
+ // break;
217
+ //}
218
+ //$info['playtime_seconds'] *= $multiplier;
219
+ //$info['warning'][] = 'Interleaved MPEG audio/video playtime may be inaccurate. With current hack should be within a few seconds of accurate. Report to info@getid3.org if off by more than 10 seconds.';
220
+ if ($info['video']['bitrate'] < 50000) {
221
+ $info['warning'][] = 'Interleaved MPEG audio/video playtime may be slightly inaccurate for video bitrates below 100kbps. Except in extreme low-bitrate situations, error should be less than 1%. Report to info@getid3.org if greater than this.';
222
+ }
223
+ }
224
+
225
+ return true;
226
+ }
227
+
228
+
229
+ public function MPEGsystemNonOverheadPercentage($VideoBitrate, $AudioBitrate) {
230
+ $OverheadPercentage = 0;
231
+
232
+ $AudioBitrate = max(min($AudioBitrate / 1000, 384), 32); // limit to range of 32kbps - 384kbps (should be only legal bitrates, but maybe VBR?)
233
+ $VideoBitrate = max(min($VideoBitrate / 1000, 10000), 10); // limit to range of 10kbps - 10Mbps (beyond that curves flatten anyways, no big loss)
234
+
235
+
236
+ //OMBB[audiobitrate] = array(video-10kbps, video-100kbps, video-1000kbps, video-10000kbps)
237
+ $OverheadMultiplierByBitrate[32] = array(0, 0.9676287944368530, 0.9802276264360310, 0.9844916183244460, 0.9852821845179940);
238
+ $OverheadMultiplierByBitrate[48] = array(0, 0.9779100089209830, 0.9787770035359320, 0.9846738664076130, 0.9852683013799960);
239
+ $OverheadMultiplierByBitrate[56] = array(0, 0.9731249855367600, 0.9776624308938040, 0.9832606361852130, 0.9843922606633340);
240
+ $OverheadMultiplierByBitrate[64] = array(0, 0.9755642683275760, 0.9795256705493390, 0.9836573009193170, 0.9851122539404470);
241
+ $OverheadMultiplierByBitrate[96] = array(0, 0.9788025247497290, 0.9798553314148700, 0.9822956869792560, 0.9834815119124690);
242
+ $OverheadMultiplierByBitrate[128] = array(0, 0.9816940050925480, 0.9821675936072120, 0.9829756927470870, 0.9839763420152050);
243
+ $OverheadMultiplierByBitrate[160] = array(0, 0.9825894094561180, 0.9820913399073960, 0.9823907143253970, 0.9832821783651570);
244
+ $OverheadMultiplierByBitrate[192] = array(0, 0.9832038474336260, 0.9825731694317960, 0.9821028622712400, 0.9828262076447620);
245
+ $OverheadMultiplierByBitrate[224] = array(0, 0.9836516298538770, 0.9824718601823890, 0.9818302180625380, 0.9823735101626480);
246
+ $OverheadMultiplierByBitrate[256] = array(0, 0.9845863022094920, 0.9837229411967540, 0.9824521662210830, 0.9828645172100790);
247
+ $OverheadMultiplierByBitrate[320] = array(0, 0.9849565280263180, 0.9837683142805110, 0.9822885275960400, 0.9824424382727190);
248
+ $OverheadMultiplierByBitrate[384] = array(0, 0.9856094774357600, 0.9844573394432720, 0.9825970399837330, 0.9824673808303890);
249
+
250
+ $BitrateToUseMin = 32;
251
+ $BitrateToUseMax = 32;
252
+ $previousBitrate = 32;
253
+ foreach ($OverheadMultiplierByBitrate as $key => $value) {
254
+ if ($AudioBitrate >= $previousBitrate) {
255
+ $BitrateToUseMin = $previousBitrate;
256
+ }
257
+ if ($AudioBitrate < $key) {
258
+ $BitrateToUseMax = $key;
259
+ break;
260
+ }
261
+ $previousBitrate = $key;
262
+ }
263
+ $FactorA = ($BitrateToUseMax - $AudioBitrate) / ($BitrateToUseMax - $BitrateToUseMin);
264
+
265
+ $VideoBitrateLog10 = log10($VideoBitrate);
266
+ $VideoFactorMin1 = $OverheadMultiplierByBitrate[$BitrateToUseMin][floor($VideoBitrateLog10)];
267
+ $VideoFactorMin2 = $OverheadMultiplierByBitrate[$BitrateToUseMax][floor($VideoBitrateLog10)];
268
+ $VideoFactorMax1 = $OverheadMultiplierByBitrate[$BitrateToUseMin][ceil($VideoBitrateLog10)];
269
+ $VideoFactorMax2 = $OverheadMultiplierByBitrate[$BitrateToUseMax][ceil($VideoBitrateLog10)];
270
+ $FactorV = $VideoBitrateLog10 - floor($VideoBitrateLog10);
271
+
272
+ $OverheadPercentage = $VideoFactorMin1 * $FactorA * $FactorV;
273
+ $OverheadPercentage += $VideoFactorMin2 * (1 - $FactorA) * $FactorV;
274
+ $OverheadPercentage += $VideoFactorMax1 * $FactorA * (1 - $FactorV);
275
+ $OverheadPercentage += $VideoFactorMax2 * (1 - $FactorA) * (1 - $FactorV);
276
+
277
+ return $OverheadPercentage;
278
+ }
279
+
280
+
281
+ public function MPEGvideoFramerateLookup($rawframerate) {
282
+ $MPEGvideoFramerateLookup = array(0, 23.976, 24, 25, 29.97, 30, 50, 59.94, 60);
283
+ return (isset($MPEGvideoFramerateLookup[$rawframerate]) ? (float) $MPEGvideoFramerateLookup[$rawframerate] : (float) 0);
284
+ }
285
+
286
+ public function MPEGvideoAspectRatioLookup($rawaspectratio) {
287
+ $MPEGvideoAspectRatioLookup = array(0, 1, 0.6735, 0.7031, 0.7615, 0.8055, 0.8437, 0.8935, 0.9157, 0.9815, 1.0255, 1.0695, 1.0950, 1.1575, 1.2015, 0);
288
+ return (isset($MPEGvideoAspectRatioLookup[$rawaspectratio]) ? (float) $MPEGvideoAspectRatioLookup[$rawaspectratio] : (float) 0);
289
+ }
290
+
291
+ public function MPEGvideoAspectRatioTextLookup($rawaspectratio) {
292
+ $MPEGvideoAspectRatioTextLookup = array('forbidden', 'square pixels', '0.6735', '16:9, 625 line, PAL', '0.7615', '0.8055', '16:9, 525 line, NTSC', '0.8935', '4:3, 625 line, PAL, CCIR601', '0.9815', '1.0255', '1.0695', '4:3, 525 line, NTSC, CCIR601', '1.1575', '1.2015', 'reserved');
293
+ return (isset($MPEGvideoAspectRatioTextLookup[$rawaspectratio]) ? $MPEGvideoAspectRatioTextLookup[$rawaspectratio] : '');
294
+ }
295
+
296
+ }
includes/getid3/module.audio-video.quicktime.php ADDED
@@ -0,0 +1,2145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /////////////////////////////////////////////////////////////////
3
+ /// getID3() by James Heinrich <info@getid3.org> //
4
+ // available at http://getid3.sourceforge.net //
5
+ // or http://www.getid3.org //
6
+ /////////////////////////////////////////////////////////////////
7
+ // See readme.txt for more details //
8
+ /////////////////////////////////////////////////////////////////
9
+ // //
10
+ // module.audio-video.quicktime.php //
11
+ // module for analyzing Quicktime and MP3-in-MP4 files //
12
+ // dependencies: module.audio.mp3.php //
13
+ // ///
14
+ /////////////////////////////////////////////////////////////////
15
+
16
+ getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, true);
17
+
18
+ class getid3_quicktime extends getid3_handler
19
+ {
20
+
21
+ public $ReturnAtomData = true;
22
+ public $ParseAllPossibleAtoms = false;
23
+
24
+ public function Analyze() {
25
+ $info = &$this->getid3->info;
26
+
27
+ $info['fileformat'] = 'quicktime';
28
+ $info['quicktime']['hinting'] = false;
29
+ $info['quicktime']['controller'] = 'standard'; // may be overridden if 'ctyp' atom is present
30
+
31
+ fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);
32
+
33
+ $offset = 0;
34
+ $atomcounter = 0;
35
+
36
+ while ($offset < $info['avdataend']) {
37
+ if (!getid3_lib::intValueSupported($offset)) {
38
+ $info['error'][] = 'Unable to parse atom at offset '.$offset.' because beyond '.round(PHP_INT_MAX / 1073741824).'GB limit of PHP filesystem functions';
39
+ break;
40
+ }
41
+ fseek($this->getid3->fp, $offset, SEEK_SET);
42
+ $AtomHeader = fread($this->getid3->fp, 8);
43
+
44
+ $atomsize = getid3_lib::BigEndian2Int(substr($AtomHeader, 0, 4));
45
+ $atomname = substr($AtomHeader, 4, 4);
46
+
47
+ // 64-bit MOV patch by jlegate�ktnc*com
48
+ if ($atomsize == 1) {
49
+ $atomsize = getid3_lib::BigEndian2Int(fread($this->getid3->fp, 8));
50
+ }
51
+
52
+ $info['quicktime'][$atomname]['name'] = $atomname;
53
+ $info['quicktime'][$atomname]['size'] = $atomsize;
54
+ $info['quicktime'][$atomname]['offset'] = $offset;
55
+
56
+ if (($offset + $atomsize) > $info['avdataend']) {
57
+ $info['error'][] = 'Atom at offset '.$offset.' claims to go beyond end-of-file (length: '.$atomsize.' bytes)';
58
+ return false;
59
+ }
60
+
61
+ if ($atomsize == 0) {
62
+ // Furthermore, for historical reasons the list of atoms is optionally
63
+ // terminated by a 32-bit integer set to 0. If you are writing a program
64
+ // to read user data atoms, you should allow for the terminating 0.
65
+ break;
66
+ }
67
+ switch ($atomname) {
68
+ case 'mdat': // Media DATa atom
69
+ // 'mdat' contains the actual data for the audio/video
70
+ if (($atomsize > 8) && (!isset($info['avdataend_tmp']) || ($info['quicktime'][$atomname]['size'] > ($info['avdataend_tmp'] - $info['avdataoffset'])))) {
71
+
72
+ $info['avdataoffset'] = $info['quicktime'][$atomname]['offset'] + 8;
73
+ $OldAVDataEnd = $info['avdataend'];
74
+ $info['avdataend'] = $info['quicktime'][$atomname]['offset'] + $info['quicktime'][$atomname]['size'];
75
+
76
+ $getid3_temp = new getID3();
77
+ $getid3_temp->openfile($this->getid3->filename);
78
+ $getid3_temp->info['avdataoffset'] = $info['avdataoffset'];
79
+ $getid3_temp->info['avdataend'] = $info['avdataend'];
80
+ $getid3_mp3 = new getid3_mp3($getid3_temp);
81
+ if ($getid3_mp3->MPEGaudioHeaderValid($getid3_mp3->MPEGaudioHeaderDecode(fread($this->getid3->fp, 4)))) {
82
+ $getid3_mp3->getOnlyMPEGaudioInfo($getid3_temp->info['avdataoffset'], false);
83
+ if (!empty($getid3_temp->info['warning'])) {
84
+ foreach ($getid3_temp->info['warning'] as $value) {
85
+ $info['warning'][] = $value;
86
+ }
87
+ }
88
+ if (!empty($getid3_temp->info['mpeg'])) {
89
+ $info['mpeg'] = $getid3_temp->info['mpeg'];
90
+ if (isset($info['mpeg']['audio'])) {
91
+ $info['audio']['dataformat'] = 'mp3';
92
+ $info['audio']['codec'] = (!empty($info['mpeg']['audio']['encoder']) ? $info['mpeg']['audio']['encoder'] : (!empty($info['mpeg']['audio']['codec']) ? $info['mpeg']['audio']['codec'] : (!empty($info['mpeg']['audio']['LAME']) ? 'LAME' :'mp3')));
93
+ $info['audio']['sample_rate'] = $info['mpeg']['audio']['sample_rate'];
94
+ $info['audio']['channels'] = $info['mpeg']['audio']['channels'];
95
+ $info['audio']['bitrate'] = $info['mpeg']['audio']['bitrate'];
96
+ $info['audio']['bitrate_mode'] = strtolower($info['mpeg']['audio']['bitrate_mode']);
97
+ $info['bitrate'] = $info['audio']['bitrate'];
98
+ }
99
+ }
100
+ }
101
+ unset($getid3_mp3, $getid3_temp);
102
+ $info['avdataend'] = $OldAVDataEnd;
103
+ unset($OldAVDataEnd);
104
+
105
+ }
106
+ break;
107
+
108
+ case 'free': // FREE space atom
109
+ case 'skip': // SKIP atom
110
+ case 'wide': // 64-bit expansion placeholder atom
111
+ // 'free', 'skip' and 'wide' are just padding, contains no useful data at all
112
+ break;
113
+
114
+ default:
115
+ $atomHierarchy = array();
116
+ $info['quicktime'][$atomname] = $this->QuicktimeParseAtom($atomname, $atomsize, fread($this->getid3->fp, $atomsize), $offset, $atomHierarchy, $this->ParseAllPossibleAtoms);
117
+ break;
118
+ }
119
+
120
+ $offset += $atomsize;
121
+ $atomcounter++;
122
+ }
123
+
124
+ if (!empty($info['avdataend_tmp'])) {
125
+ // this value is assigned to a temp value and then erased because
126
+ // otherwise any atoms beyond the 'mdat' atom would not get parsed
127
+ $info['avdataend'] = $info['avdataend_tmp'];
128
+ unset($info['avdataend_tmp']);
129
+ }
130
+
131
+ if (!isset($info['bitrate']) && isset($info['playtime_seconds'])) {
132
+ $info['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];
133
+ }
134
+ if (isset($info['bitrate']) && !isset($info['audio']['bitrate']) && !isset($info['quicktime']['video'])) {
135
+ $info['audio']['bitrate'] = $info['bitrate'];
136
+ }
137
+ if (!empty($info['playtime_seconds']) && !isset($info['video']['frame_rate']) && !empty($info['quicktime']['stts_framecount'])) {
138
+ foreach ($info['quicktime']['stts_framecount'] as $key => $samples_count) {
139
+ $samples_per_second = $samples_count / $info['playtime_seconds'];
140
+ if ($samples_per_second > 240) {
141
+ // has to be audio samples
142
+ } else {
143
+ $info['video']['frame_rate'] = $samples_per_second;
144
+ break;
145
+ }
146
+ }
147
+ }
148
+ if (($info['audio']['dataformat'] == 'mp4') && empty($info['video']['resolution_x'])) {
149
+ $info['fileformat'] = 'mp4';
150
+ $info['mime_type'] = 'audio/mp4';
151
+ unset($info['video']['dataformat']);
152
+ }
153
+
154
+ if (!$this->ReturnAtomData) {
155
+ unset($info['quicktime']['moov']);
156
+ }
157
+
158
+ if (empty($info['audio']['dataformat']) && !empty($info['quicktime']['audio'])) {
159
+ $info['audio']['dataformat'] = 'quicktime';
160
+ }
161
+ if (empty($info['video']['dataformat']) && !empty($info['quicktime']['video'])) {
162
+ $info['video']['dataformat'] = 'quicktime';
163
+ }
164
+
165
+ return true;
166
+ }
167
+
168
+ public function QuicktimeParseAtom($atomname, $atomsize, $atom_data, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms) {
169
+ // http://developer.apple.com/techpubs/quicktime/qtdevdocs/APIREF/INDEX/atomalphaindex.htm
170
+
171
+ $info = &$this->getid3->info;
172
+
173
+ $atom_parent = array_pop($atomHierarchy);
174
+ array_push($atomHierarchy, $atomname);
175
+ $atom_structure['hierarchy'] = implode(' ', $atomHierarchy);
176
+ $atom_structure['name'] = $atomname;
177
+ $atom_structure['size'] = $atomsize;
178
+ $atom_structure['offset'] = $baseoffset;
179
+ //echo getid3_lib::PrintHexBytes(substr($atom_data, 0, 8)).'<br>';
180
+ //echo getid3_lib::PrintHexBytes(substr($atom_data, 0, 8), false).'<br><br>';
181
+ switch ($atomname) {
182
+ case 'moov': // MOVie container atom
183
+ case 'trak': // TRAcK container atom
184
+ case 'clip': // CLIPping container atom
185
+ case 'matt': // track MATTe container atom
186
+ case 'edts': // EDiTS container atom
187
+ case 'tref': // Track REFerence container atom
188
+ case 'mdia': // MeDIA container atom
189
+ case 'minf': // Media INFormation container atom
190
+ case 'dinf': // Data INFormation container atom
191
+ case 'udta': // User DaTA container atom
192
+ case 'cmov': // Compressed MOVie container atom
193
+ case 'rmra': // Reference Movie Record Atom
194
+ case 'rmda': // Reference Movie Descriptor Atom
195
+ case 'gmhd': // Generic Media info HeaDer atom (seen on QTVR)
196
+ $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
197
+ break;
198
+
199
+ case 'ilst': // Item LiST container atom
200
+ $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
201
+
202
+ // some "ilst" atoms contain data atoms that have a numeric name, and the data is far more accessible if the returned array is compacted
203
+ $allnumericnames = true;
204
+ foreach ($atom_structure['subatoms'] as $subatomarray) {
205
+ if (!is_integer($subatomarray['name']) || (count($subatomarray['subatoms']) != 1)) {
206
+ $allnumericnames = false;
207
+ break;
208
+ }
209
+ }
210
+ if ($allnumericnames) {
211
+ $newData = array();
212
+ foreach ($atom_structure['subatoms'] as $subatomarray) {
213
+ foreach ($subatomarray['subatoms'] as $newData_subatomarray) {
214
+ unset($newData_subatomarray['hierarchy'], $newData_subatomarray['name']);
215
+ $newData[$subatomarray['name']] = $newData_subatomarray;
216
+ break;
217
+ }
218
+ }
219
+ $atom_structure['data'] = $newData;
220
+ unset($atom_structure['subatoms']);
221
+ }
222
+ break;
223
+
224
+ case "\x00\x00\x00\x01":
225
+ case "\x00\x00\x00\x02":
226
+ case "\x00\x00\x00\x03":
227
+ case "\x00\x00\x00\x04":
228
+ case "\x00\x00\x00\x05":
229
+ $atomname = getid3_lib::BigEndian2Int($atomname);
230
+ $atom_structure['name'] = $atomname;
231
+ $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
232
+ break;
233
+
234
+ case 'stbl': // Sample TaBLe container atom
235
+ $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
236
+ $isVideo = false;
237
+ $framerate = 0;
238
+ $framecount = 0;
239
+ foreach ($atom_structure['subatoms'] as $key => $value_array) {
240
+ if (isset($value_array['sample_description_table'])) {
241
+ foreach ($value_array['sample_description_table'] as $key2 => $value_array2) {
242
+ if (isset($value_array2['data_format'])) {
243
+ switch ($value_array2['data_format']) {
244
+ case 'avc1':
245
+ case 'mp4v':
246
+ // video data
247
+ $isVideo = true;
248
+ break;
249
+ case 'mp4a':
250
+ // audio data
251
+ break;
252
+ }
253
+ }
254
+ }
255
+ } elseif (isset($value_array['time_to_sample_table'])) {
256
+ foreach ($value_array['time_to_sample_table'] as $key2 => $value_array2) {
257
+ if (isset($value_array2['sample_count']) && isset($value_array2['sample_duration']) && ($value_array2['sample_duration'] > 0)) {
258
+ $framerate = round($info['quicktime']['time_scale'] / $value_array2['sample_duration'], 3);
259
+ $framecount = $value_array2['sample_count'];
260
+ }
261
+ }
262
+ }
263
+ }
264
+ if ($isVideo && $framerate) {
265
+ $info['quicktime']['video']['frame_rate'] = $framerate;
266
+ $info['video']['frame_rate'] = $info['quicktime']['video']['frame_rate'];
267
+ }
268
+ if ($isVideo && $framecount) {
269
+ $info['quicktime']['video']['frame_count'] = $framecount;
270
+ }
271
+ break;
272
+
273
+
274
+ case 'aART': // Album ARTist
275
+ case 'catg': // CaTeGory
276
+ case 'covr': // COVeR artwork
277
+ case 'cpil': // ComPILation
278
+ case 'cprt': // CoPyRighT
279
+ case 'desc': // DESCription
280
+ case 'disk': // DISK number
281
+ case 'egid': // Episode Global ID
282
+ case 'gnre': // GeNRE
283
+ case 'keyw': // KEYWord
284
+ case 'ldes':
285
+ case 'pcst': // PodCaST
286
+ case 'pgap': // GAPless Playback
287
+ case 'purd': // PURchase Date
288
+ case 'purl': // Podcast URL
289
+ case 'rati':
290
+ case 'rndu':
291
+ case 'rpdu':
292
+ case 'rtng': // RaTiNG
293
+ case 'stik':
294
+ case 'tmpo': // TeMPO (BPM)
295
+ case 'trkn': // TRacK Number
296
+ case 'tves': // TV EpiSode
297
+ case 'tvnn': // TV Network Name
298
+ case 'tvsh': // TV SHow Name
299
+ case 'tvsn': // TV SeasoN
300
+ case 'akID': // iTunes store account type
301
+ case 'apID':
302
+ case 'atID':
303
+ case 'cmID':
304
+ case 'cnID':
305
+ case 'geID':
306
+ case 'plID':
307
+ case 'sfID': // iTunes store country
308
+ case '�alb': // ALBum
309
+ case '�art': // ARTist
310
+ case '�ART':
311
+ case '�aut':
312
+ case '�cmt': // CoMmenT
313
+ case '�com': // COMposer
314
+ case '�cpy':
315
+ case '�day': // content created year
316
+ case '�dir':
317
+ case '�ed1':
318
+ case '�ed2':
319
+ case '�ed3':
320
+ case '�ed4':
321
+ case '�ed5':
322
+ case '�ed6':
323
+ case '�ed7':
324
+ case '�ed8':
325
+ case '�ed9':
326
+ case '�enc':
327
+ case '�fmt':
328
+ case '�gen': // GENre
329
+ case '�grp': // GRouPing
330
+ case '�hst':
331
+ case '�inf':
332
+ case '�lyr': // LYRics
333
+ case '�mak':
334
+ case '�mod':
335
+ case '�nam': // full NAMe
336
+ case '�ope':
337
+ case '�PRD':
338
+ case '�prd':
339
+ case '�prf':
340
+ case '�req':
341
+ case '�src':
342
+ case '�swr':
343
+ case '�too': // encoder
344
+ case '�trk': // TRacK
345
+ case '�url':
346
+ case '�wrn':
347
+ case '�wrt': // WRiTer
348
+ case '----': // itunes specific
349
+ if ($atom_parent == 'udta') {
350
+ // User data atom handler
351
+ $atom_structure['data_length'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2));
352
+ $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2));
353
+ $atom_structure['data'] = substr($atom_data, 4);
354
+
355
+ $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']);
356
+ if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) {
357
+ $info['comments']['language'][] = $atom_structure['language'];
358
+ }
359
+ } else {
360
+ // Apple item list box atom handler
361
+ $atomoffset = 0;
362
+ if (substr($atom_data, 2, 2) == "\x10\xB5") {
363
+ // not sure what it means, but observed on iPhone4 data.
364
+ // Each $atom_data has 2 bytes of datasize, plus 0x10B5, then data
365
+ while ($atomoffset < strlen($atom_data)) {
366
+ $boxsmallsize = getid3_lib::BigEndian2Int(substr($atom_data, $atomoffset, 2));
367
+ $boxsmalltype = substr($atom_data, $atomoffset + 2, 2);
368
+ $boxsmalldata = substr($atom_data, $atomoffset + 4, $boxsmallsize);
369
+ switch ($boxsmalltype) {
370
+ case "\x10\xB5":
371
+ $atom_structure['data'] = $boxsmalldata;
372
+ break;
373
+ default:
374
+ $info['warning'][] = 'Unknown QuickTime smallbox type: "'.getid3_lib::PrintHexBytes($boxsmalltype).'" at offset '.$baseoffset;
375
+ $atom_structure['data'] = $atom_data;
376
+ break;
377
+ }
378
+ $atomoffset += (4 + $boxsmallsize);
379
+ }
380
+ } else {
381
+ while ($atomoffset < strlen($atom_data)) {
382
+ $boxsize = getid3_lib::BigEndian2Int(substr($atom_data, $atomoffset, 4));
383
+ $boxtype = substr($atom_data, $atomoffset + 4, 4);
384
+ $boxdata = substr($atom_data, $atomoffset + 8, $boxsize - 8);
385
+ if ($boxsize <= 1) {
386
+ $info['warning'][] = 'Invalid QuickTime atom box size "'.$boxsize.'" in atom "'.$atomname.'" at offset: '.($atom_structure['offset'] + $atomoffset);
387
+ $atom_structure['data'] = null;
388
+ $atomoffset = strlen($atom_data);
389
+ break;
390
+ }
391
+ $atomoffset += $boxsize;
392
+
393
+ switch ($boxtype) {
394
+ case 'mean':
395
+ case 'name':
396
+ $atom_structure[$boxtype] = substr($boxdata, 4);
397
+ break;
398
+
399
+ case 'data':
400
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($boxdata, 0, 1));
401
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($boxdata, 1, 3));
402
+ switch ($atom_structure['flags_raw']) {
403
+ case 0: // data flag
404
+ case 21: // tmpo/cpil flag
405
+ switch ($atomname) {
406
+ case 'cpil':
407
+ case 'pcst':
408
+ case 'pgap':
409
+ $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));
410
+ break;
411
+
412
+ case 'tmpo':
413
+ $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 2));
414
+ break;
415
+
416
+ case 'disk':
417
+ case 'trkn':
418
+ $num = getid3_lib::BigEndian2Int(substr($boxdata, 10, 2));
419
+ $num_total = getid3_lib::BigEndian2Int(substr($boxdata, 12, 2));
420
+ $atom_structure['data'] = empty($num) ? '' : $num;
421
+ $atom_structure['data'] .= empty($num_total) ? '' : '/'.$num_total;
422
+ break;
423
+
424
+ case 'gnre':
425
+ $GenreID = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
426
+ $atom_structure['data'] = getid3_id3v1::LookupGenreName($GenreID - 1);
427
+ break;
428
+
429
+ case 'rtng':
430
+ $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));
431
+ $atom_structure['data'] = $this->QuicktimeContentRatingLookup($atom_structure[$atomname]);
432
+ break;
433
+
434
+ case 'stik':
435
+ $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 1));
436
+ $atom_structure['data'] = $this->QuicktimeSTIKLookup($atom_structure[$atomname]);
437
+ break;
438
+
439
+ case 'sfID':
440
+ $atom_structure[$atomname] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
441
+ $atom_structure['data'] = $this->QuicktimeStoreFrontCodeLookup($atom_structure[$atomname]);
442
+ break;
443
+
444
+ case 'egid':
445
+ case 'purl':
446
+ $atom_structure['data'] = substr($boxdata, 8);
447
+ break;
448
+
449
+ default:
450
+ $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($boxdata, 8, 4));
451
+ }
452
+ break;
453
+
454
+ case 1: // text flag
455
+ case 13: // image flag
456
+ default:
457
+ $atom_structure['data'] = substr($boxdata, 8);
458
+ break;
459
+
460
+ }
461
+ break;
462
+
463
+ default:
464
+ $info['warning'][] = 'Unknown QuickTime box type: "'.getid3_lib::PrintHexBytes($boxtype).'" at offset '.$baseoffset;
465
+ $atom_structure['data'] = $atom_data;
466
+
467
+ }
468
+ }
469
+ }
470
+ }
471
+ $this->CopyToAppropriateCommentsSection($atomname, $atom_structure['data'], $atom_structure['name']);
472
+ break;
473
+
474
+
475
+ case 'play': // auto-PLAY atom
476
+ $atom_structure['autoplay'] = (bool) getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
477
+
478
+ $info['quicktime']['autoplay'] = $atom_structure['autoplay'];
479
+ break;
480
+
481
+
482
+ case 'WLOC': // Window LOCation atom
483
+ $atom_structure['location_x'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2));
484
+ $atom_structure['location_y'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2));
485
+ break;
486
+
487
+
488
+ case 'LOOP': // LOOPing atom
489
+ case 'SelO': // play SELection Only atom
490
+ case 'AllF': // play ALL Frames atom
491
+ $atom_structure['data'] = getid3_lib::BigEndian2Int($atom_data);
492
+ break;
493
+
494
+
495
+ case 'name': //
496
+ case 'MCPS': // Media Cleaner PRo
497
+ case '@PRM': // adobe PReMiere version
498
+ case '@PRQ': // adobe PRemiere Quicktime version
499
+ $atom_structure['data'] = $atom_data;
500
+ break;
501
+
502
+
503
+ case 'cmvd': // Compressed MooV Data atom
504
+ // Code by ubergeek�ubergeek*tv based on information from
505
+ // http://developer.apple.com/quicktime/icefloe/dispatch012.html
506
+ $atom_structure['unCompressedSize'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
507
+
508
+ $CompressedFileData = substr($atom_data, 4);
509
+ if ($UncompressedHeader = @gzuncompress($CompressedFileData)) {
510
+ $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($UncompressedHeader, 0, $atomHierarchy, $ParseAllPossibleAtoms);
511
+ } else {
512
+ $info['warning'][] = 'Error decompressing compressed MOV atom at offset '.$atom_structure['offset'];
513
+ }
514
+ break;
515
+
516
+
517
+ case 'dcom': // Data COMpression atom
518
+ $atom_structure['compression_id'] = $atom_data;
519
+ $atom_structure['compression_text'] = $this->QuicktimeDCOMLookup($atom_data);
520
+ break;
521
+
522
+
523
+ case 'rdrf': // Reference movie Data ReFerence atom
524
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
525
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
526
+ $atom_structure['flags']['internal_data'] = (bool) ($atom_structure['flags_raw'] & 0x000001);
527
+
528
+ $atom_structure['reference_type_name'] = substr($atom_data, 4, 4);
529
+ $atom_structure['reference_length'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
530
+ switch ($atom_structure['reference_type_name']) {
531
+ case 'url ':
532
+ $atom_structure['url'] = $this->NoNullString(substr($atom_data, 12));
533
+ break;
534
+
535
+ case 'alis':
536
+ $atom_structure['file_alias'] = substr($atom_data, 12);
537
+ break;
538
+
539
+ case 'rsrc':
540
+ $atom_structure['resource_alias'] = substr($atom_data, 12);
541
+ break;
542
+
543
+ default:
544
+ $atom_structure['data'] = substr($atom_data, 12);
545
+ break;
546
+ }
547
+ break;
548
+
549
+
550
+ case 'rmqu': // Reference Movie QUality atom
551
+ $atom_structure['movie_quality'] = getid3_lib::BigEndian2Int($atom_data);
552
+ break;
553
+
554
+
555
+ case 'rmcs': // Reference Movie Cpu Speed atom
556
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
557
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
558
+ $atom_structure['cpu_speed_rating'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
559
+ break;
560
+
561
+
562
+ case 'rmvc': // Reference Movie Version Check atom
563
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
564
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
565
+ $atom_structure['gestalt_selector'] = substr($atom_data, 4, 4);
566
+ $atom_structure['gestalt_value_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
567
+ $atom_structure['gestalt_value'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
568
+ $atom_structure['gestalt_check_type'] = getid3_lib::BigEndian2Int(substr($atom_data, 14, 2));
569
+ break;
570
+
571
+
572
+ case 'rmcd': // Reference Movie Component check atom
573
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
574
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
575
+ $atom_structure['component_type'] = substr($atom_data, 4, 4);
576
+ $atom_structure['component_subtype'] = substr($atom_data, 8, 4);
577
+ $atom_structure['component_manufacturer'] = substr($atom_data, 12, 4);
578
+ $atom_structure['component_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
579
+ $atom_structure['component_flags_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4));
580
+ $atom_structure['component_min_version'] = getid3_lib::BigEndian2Int(substr($atom_data, 24, 4));
581
+ break;
582
+
583
+
584
+ case 'rmdr': // Reference Movie Data Rate atom
585
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
586
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
587
+ $atom_structure['data_rate'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
588
+
589
+ $atom_structure['data_rate_bps'] = $atom_structure['data_rate'] * 10;
590
+ break;
591
+
592
+
593
+ case 'rmla': // Reference Movie Language Atom
594
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
595
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
596
+ $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
597
+
598
+ $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']);
599
+ if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) {
600
+ $info['comments']['language'][] = $atom_structure['language'];
601
+ }
602
+ break;
603
+
604
+
605
+ case 'rmla': // Reference Movie Language Atom
606
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
607
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
608
+ $atom_structure['track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
609
+ break;
610
+
611
+
612
+ case 'ptv ': // Print To Video - defines a movie's full screen mode
613
+ // http://developer.apple.com/documentation/QuickTime/APIREF/SOURCESIV/at_ptv-_pg.htm
614
+ $atom_structure['display_size_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2));
615
+ $atom_structure['reserved_1'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 2)); // hardcoded: 0x0000
616
+ $atom_structure['reserved_2'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x0000
617
+ $atom_structure['slide_show_flag'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 1));
618
+ $atom_structure['play_on_open_flag'] = getid3_lib::BigEndian2Int(substr($atom_data, 7, 1));
619
+
620
+ $atom_structure['flags']['play_on_open'] = (bool) $atom_structure['play_on_open_flag'];
621
+ $atom_structure['flags']['slide_show'] = (bool) $atom_structure['slide_show_flag'];
622
+
623
+ $ptv_lookup[0] = 'normal';
624
+ $ptv_lookup[1] = 'double';
625
+ $ptv_lookup[2] = 'half';
626
+ $ptv_lookup[3] = 'full';
627
+ $ptv_lookup[4] = 'current';
628
+ if (isset($ptv_lookup[$atom_structure['display_size_raw']])) {
629
+ $atom_structure['display_size'] = $ptv_lookup[$atom_structure['display_size_raw']];
630
+ } else {
631
+ $info['warning'][] = 'unknown "ptv " display constant ('.$atom_structure['display_size_raw'].')';
632
+ }
633
+ break;
634
+
635
+
636
+ case 'stsd': // Sample Table Sample Description atom
637
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
638
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
639
+ $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
640
+ $stsdEntriesDataOffset = 8;
641
+ for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
642
+ $atom_structure['sample_description_table'][$i]['size'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 4));
643
+ $stsdEntriesDataOffset += 4;
644
+ $atom_structure['sample_description_table'][$i]['data_format'] = substr($atom_data, $stsdEntriesDataOffset, 4);
645
+ $stsdEntriesDataOffset += 4;
646
+ $atom_structure['sample_description_table'][$i]['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 6));
647
+ $stsdEntriesDataOffset += 6;
648
+ $atom_structure['sample_description_table'][$i]['reference_index'] = getid3_lib::BigEndian2Int(substr($atom_data, $stsdEntriesDataOffset, 2));
649
+ $stsdEntriesDataOffset += 2;
650
+ $atom_structure['sample_description_table'][$i]['data'] = substr($atom_data, $stsdEntriesDataOffset, ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2));
651
+ $stsdEntriesDataOffset += ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2);
652
+
653
+ $atom_structure['sample_description_table'][$i]['encoder_version'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 0, 2));
654
+ $atom_structure['sample_description_table'][$i]['encoder_revision'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 2, 2));
655
+ $atom_structure['sample_description_table'][$i]['encoder_vendor'] = substr($atom_structure['sample_description_table'][$i]['data'], 4, 4);
656
+
657
+ switch ($atom_structure['sample_description_table'][$i]['encoder_vendor']) {
658
+
659
+ case "\x00\x00\x00\x00":
660
+ // audio atom
661
+ $atom_structure['sample_description_table'][$i]['audio_channels'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 8, 2));
662
+ $atom_structure['sample_description_table'][$i]['audio_bit_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 10, 2));
663
+ $atom_structure['sample_description_table'][$i]['audio_compression_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12, 2));
664
+ $atom_structure['sample_description_table'][$i]['audio_packet_size'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 14, 2));
665
+ $atom_structure['sample_description_table'][$i]['audio_sample_rate'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 16, 4));
666
+
667
+ switch ($atom_structure['sample_description_table'][$i]['data_format']) {
668
+ case 'avc1':
669
+ case 'mp4v':
670
+ $info['fileformat'] = 'mp4';
671
+ $info['video']['fourcc'] = $atom_structure['sample_description_table'][$i]['data_format'];
672
+ //$info['warning'][] = 'This version of getID3() ['.$this->getid3->version().'] does not fully support MPEG-4 audio/video streams'; // 2011-02-18: why am I warning about this again? What's not supported?
673
+ break;
674
+
675
+ case 'qtvr':
676
+ $info['video']['dataformat'] = 'quicktimevr';
677
+ break;
678
+
679
+ case 'mp4a':
680
+ default:
681
+ $info['quicktime']['audio']['codec'] = $this->QuicktimeAudioCodecLookup($atom_structure['sample_description_table'][$i]['data_format']);
682
+ $info['quicktime']['audio']['sample_rate'] = $atom_structure['sample_description_table'][$i]['audio_sample_rate'];
683
+ $info['quicktime']['audio']['channels'] = $atom_structure['sample_description_table'][$i]['audio_channels'];
684
+ $info['quicktime']['audio']['bit_depth'] = $atom_structure['sample_description_table'][$i]['audio_bit_depth'];
685
+ $info['audio']['codec'] = $info['quicktime']['audio']['codec'];
686
+ $info['audio']['sample_rate'] = $info['quicktime']['audio']['sample_rate'];
687
+ $info['audio']['channels'] = $info['quicktime']['audio']['channels'];
688
+ $info['audio']['bits_per_sample'] = $info['quicktime']['audio']['bit_depth'];
689
+ switch ($atom_structure['sample_description_table'][$i]['data_format']) {
690
+ case 'raw ': // PCM
691
+ case 'alac': // Apple Lossless Audio Codec
692
+ $info['audio']['lossless'] = true;
693
+ break;
694
+ default:
695
+ $info['audio']['lossless'] = false;
696
+ break;
697
+ }
698
+ break;
699
+ }
700
+ break;
701
+
702
+ default:
703
+ switch ($atom_structure['sample_description_table'][$i]['data_format']) {
704
+ case 'mp4s':
705
+ $info['fileformat'] = 'mp4';
706
+ break;
707
+
708
+ default:
709
+ // video atom
710
+ $atom_structure['sample_description_table'][$i]['video_temporal_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 8, 4));
711
+ $atom_structure['sample_description_table'][$i]['video_spatial_quality'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 12, 4));
712
+ $atom_structure['sample_description_table'][$i]['video_frame_width'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 16, 2));
713
+ $atom_structure['sample_description_table'][$i]['video_frame_height'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 18, 2));
714
+ $atom_structure['sample_description_table'][$i]['video_resolution_x'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 20, 4));
715
+ $atom_structure['sample_description_table'][$i]['video_resolution_y'] = getid3_lib::FixedPoint16_16(substr($atom_structure['sample_description_table'][$i]['data'], 24, 4));
716
+ $atom_structure['sample_description_table'][$i]['video_data_size'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 28, 4));
717
+ $atom_structure['sample_description_table'][$i]['video_frame_count'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 32, 2));
718
+ $atom_structure['sample_description_table'][$i]['video_encoder_name_len'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 34, 1));
719
+ $atom_structure['sample_description_table'][$i]['video_encoder_name'] = substr($atom_structure['sample_description_table'][$i]['data'], 35, $atom_structure['sample_description_table'][$i]['video_encoder_name_len']);
720
+ $atom_structure['sample_description_table'][$i]['video_pixel_color_depth'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 66, 2));
721
+ $atom_structure['sample_description_table'][$i]['video_color_table_id'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 68, 2));
722
+
723
+ $atom_structure['sample_description_table'][$i]['video_pixel_color_type'] = (($atom_structure['sample_description_table'][$i]['video_pixel_color_depth'] > 32) ? 'grayscale' : 'color');
724
+ $atom_structure['sample_description_table'][$i]['video_pixel_color_name'] = $this->QuicktimeColorNameLookup($atom_structure['sample_description_table'][$i]['video_pixel_color_depth']);
725
+
726
+ if ($atom_structure['sample_description_table'][$i]['video_pixel_color_name'] != 'invalid') {
727
+ $info['quicktime']['video']['codec_fourcc'] = $atom_structure['sample_description_table'][$i]['data_format'];
728
+ $info['quicktime']['video']['codec_fourcc_lookup'] = $this->QuicktimeVideoCodecLookup($atom_structure['sample_description_table'][$i]['data_format']);
729
+ $info['quicktime']['video']['codec'] = (($atom_structure['sample_description_table'][$i]['video_encoder_name_len'] > 0) ? $atom_structure['sample_description_table'][$i]['video_encoder_name'] : $atom_structure['sample_description_table'][$i]['data_format']);
730
+ $info['quicktime']['video']['color_depth'] = $atom_structure['sample_description_table'][$i]['video_pixel_color_depth'];
731
+ $info['quicktime']['video']['color_depth_name'] = $atom_structure['sample_description_table'][$i]['video_pixel_color_name'];
732
+
733
+ $info['video']['codec'] = $info['quicktime']['video']['codec'];
734
+ $info['video']['bits_per_sample'] = $info['quicktime']['video']['color_depth'];
735
+ }
736
+ $info['video']['lossless'] = false;
737
+ $info['video']['pixel_aspect_ratio'] = (float) 1;
738
+ break;
739
+ }
740
+ break;
741
+ }
742
+ switch (strtolower($atom_structure['sample_description_table'][$i]['data_format'])) {
743
+ case 'mp4a':
744
+ $info['audio']['dataformat'] = 'mp4';
745
+ $info['quicktime']['audio']['codec'] = 'mp4';
746
+ break;
747
+
748
+ case '3ivx':
749
+ case '3iv1':
750
+ case '3iv2':
751
+ $info['video']['dataformat'] = '3ivx';
752
+ break;
753
+
754
+ case 'xvid':
755
+ $info['video']['dataformat'] = 'xvid';
756
+ break;
757
+
758
+ case 'mp4v':
759
+ $info['video']['dataformat'] = 'mpeg4';
760
+ break;
761
+
762
+ case 'divx':
763
+ case 'div1':
764
+ case 'div2':
765
+ case 'div3':
766
+ case 'div4':
767
+ case 'div5':
768
+ case 'div6':
769
+ $info['video']['dataformat'] = 'divx';
770
+ break;
771
+
772
+ default:
773
+ // do nothing
774
+ break;
775
+ }
776
+ unset($atom_structure['sample_description_table'][$i]['data']);
777
+ }
778
+ break;
779
+
780
+
781
+ case 'stts': // Sample Table Time-to-Sample atom
782
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
783
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
784
+ $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
785
+ $sttsEntriesDataOffset = 8;
786
+ //$FrameRateCalculatorArray = array();
787
+ $frames_count = 0;
788
+ for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
789
+ $atom_structure['time_to_sample_table'][$i]['sample_count'] = getid3_lib::BigEndian2Int(substr($atom_data, $sttsEntriesDataOffset, 4));
790
+ $sttsEntriesDataOffset += 4;
791
+ $atom_structure['time_to_sample_table'][$i]['sample_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, $sttsEntriesDataOffset, 4));
792
+ $sttsEntriesDataOffset += 4;
793
+
794
+ $frames_count += $atom_structure['time_to_sample_table'][$i]['sample_count'];
795
+
796
+ // THIS SECTION REPLACED WITH CODE IN "stbl" ATOM
797
+ //if (!empty($info['quicktime']['time_scale']) && ($atom_structure['time_to_sample_table'][$i]['sample_duration'] > 0)) {
798
+ // $stts_new_framerate = $info['quicktime']['time_scale'] / $atom_structure['time_to_sample_table'][$i]['sample_duration'];
799
+ // if ($stts_new_framerate <= 60) {
800
+ // // some atoms have durations of "1" giving a very large framerate, which probably is not right
801
+ // $info['video']['frame_rate'] = max($info['video']['frame_rate'], $stts_new_framerate);
802
+ // }
803
+ //}
804
+ //
805
+ //$FrameRateCalculatorArray[($info['quicktime']['time_scale'] / $atom_structure['time_to_sample_table'][$i]['sample_duration'])] += $atom_structure['time_to_sample_table'][$i]['sample_count'];
806
+ }
807
+ $info['quicktime']['stts_framecount'][] = $frames_count;
808
+ //$sttsFramesTotal = 0;
809
+ //$sttsSecondsTotal = 0;
810
+ //foreach ($FrameRateCalculatorArray as $frames_per_second => $frame_count) {
811
+ // if (($frames_per_second > 60) || ($frames_per_second < 1)) {
812
+ // // not video FPS information, probably audio information
813
+ // $sttsFramesTotal = 0;
814
+ // $sttsSecondsTotal = 0;
815
+ // break;
816
+ // }
817
+ // $sttsFramesTotal += $frame_count;
818
+ // $sttsSecondsTotal += $frame_count / $frames_per_second;
819
+ //}
820
+ //if (($sttsFramesTotal > 0) && ($sttsSecondsTotal > 0)) {
821
+ // if (($sttsFramesTotal / $sttsSecondsTotal) > $info['video']['frame_rate']) {
822
+ // $info['video']['frame_rate'] = $sttsFramesTotal / $sttsSecondsTotal;
823
+ // }
824
+ //}
825
+ break;
826
+
827
+
828
+ case 'stss': // Sample Table Sync Sample (key frames) atom
829
+ if ($ParseAllPossibleAtoms) {
830
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
831
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
832
+ $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
833
+ $stssEntriesDataOffset = 8;
834
+ for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
835
+ $atom_structure['time_to_sample_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stssEntriesDataOffset, 4));
836
+ $stssEntriesDataOffset += 4;
837
+ }
838
+ }
839
+ break;
840
+
841
+
842
+ case 'stsc': // Sample Table Sample-to-Chunk atom
843
+ if ($ParseAllPossibleAtoms) {
844
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
845
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
846
+ $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
847
+ $stscEntriesDataOffset = 8;
848
+ for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
849
+ $atom_structure['sample_to_chunk_table'][$i]['first_chunk'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4));
850
+ $stscEntriesDataOffset += 4;
851
+ $atom_structure['sample_to_chunk_table'][$i]['samples_per_chunk'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4));
852
+ $stscEntriesDataOffset += 4;
853
+ $atom_structure['sample_to_chunk_table'][$i]['sample_description'] = getid3_lib::BigEndian2Int(substr($atom_data, $stscEntriesDataOffset, 4));
854
+ $stscEntriesDataOffset += 4;
855
+ }
856
+ }
857
+ break;
858
+
859
+
860
+ case 'stsz': // Sample Table SiZe atom
861
+ if ($ParseAllPossibleAtoms) {
862
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
863
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
864
+ $atom_structure['sample_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
865
+ $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
866
+ $stszEntriesDataOffset = 12;
867
+ if ($atom_structure['sample_size'] == 0) {
868
+ for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
869
+ $atom_structure['sample_size_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stszEntriesDataOffset, 4));
870
+ $stszEntriesDataOffset += 4;
871
+ }
872
+ }
873
+ }
874
+ break;
875
+
876
+
877
+ case 'stco': // Sample Table Chunk Offset atom
878
+ if ($ParseAllPossibleAtoms) {
879
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
880
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
881
+ $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
882
+ $stcoEntriesDataOffset = 8;
883
+ for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
884
+ $atom_structure['chunk_offset_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stcoEntriesDataOffset, 4));
885
+ $stcoEntriesDataOffset += 4;
886
+ }
887
+ }
888
+ break;
889
+
890
+
891
+ case 'co64': // Chunk Offset 64-bit (version of "stco" that supports > 2GB files)
892
+ if ($ParseAllPossibleAtoms) {
893
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
894
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
895
+ $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
896
+ $stcoEntriesDataOffset = 8;
897
+ for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
898
+ $atom_structure['chunk_offset_table'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $stcoEntriesDataOffset, 8));
899
+ $stcoEntriesDataOffset += 8;
900
+ }
901
+ }
902
+ break;
903
+
904
+
905
+ case 'dref': // Data REFerence atom
906
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
907
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
908
+ $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
909
+ $drefDataOffset = 8;
910
+ for ($i = 0; $i < $atom_structure['number_entries']; $i++) {
911
+ $atom_structure['data_references'][$i]['size'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 4));
912
+ $drefDataOffset += 4;
913
+ $atom_structure['data_references'][$i]['type'] = substr($atom_data, $drefDataOffset, 4);
914
+ $drefDataOffset += 4;
915
+ $atom_structure['data_references'][$i]['version'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 1));
916
+ $drefDataOffset += 1;
917
+ $atom_structure['data_references'][$i]['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, $drefDataOffset, 3)); // hardcoded: 0x0000
918
+ $drefDataOffset += 3;
919
+ $atom_structure['data_references'][$i]['data'] = substr($atom_data, $drefDataOffset, ($atom_structure['data_references'][$i]['size'] - 4 - 4 - 1 - 3));
920
+ $drefDataOffset += ($atom_structure['data_references'][$i]['size'] - 4 - 4 - 1 - 3);
921
+
922
+ $atom_structure['data_references'][$i]['flags']['self_reference'] = (bool) ($atom_structure['data_references'][$i]['flags_raw'] & 0x001);
923
+ }
924
+ break;
925
+
926
+
927
+ case 'gmin': // base Media INformation atom
928
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
929
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
930
+ $atom_structure['graphics_mode'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
931
+ $atom_structure['opcolor_red'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2));
932
+ $atom_structure['opcolor_green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 2));
933
+ $atom_structure['opcolor_blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2));
934
+ $atom_structure['balance'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 2));
935
+ $atom_structure['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, 14, 2));
936
+ break;
937
+
938
+
939
+ case 'smhd': // Sound Media information HeaDer atom
940
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
941
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
942
+ $atom_structure['balance'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
943
+ $atom_structure['reserved'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2));
944
+ break;
945
+
946
+
947
+ case 'vmhd': // Video Media information HeaDer atom
948
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
949
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
950
+ $atom_structure['graphics_mode'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2));
951
+ $atom_structure['opcolor_red'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2));
952
+ $atom_structure['opcolor_green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 2));
953
+ $atom_structure['opcolor_blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2));
954
+
955
+ $atom_structure['flags']['no_lean_ahead'] = (bool) ($atom_structure['flags_raw'] & 0x001);
956
+ break;
957
+
958
+
959
+ case 'hdlr': // HanDLeR reference atom
960
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
961
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
962
+ $atom_structure['component_type'] = substr($atom_data, 4, 4);
963
+ $atom_structure['component_subtype'] = substr($atom_data, 8, 4);
964
+ $atom_structure['component_manufacturer'] = substr($atom_data, 12, 4);
965
+ $atom_structure['component_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
966
+ $atom_structure['component_flags_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4));
967
+ $atom_structure['component_name'] = $this->Pascal2String(substr($atom_data, 24));
968
+
969
+ if (($atom_structure['component_subtype'] == 'STpn') && ($atom_structure['component_manufacturer'] == 'zzzz')) {
970
+ $info['video']['dataformat'] = 'quicktimevr';
971
+ }
972
+ break;
973
+
974
+
975
+ case 'mdhd': // MeDia HeaDer atom
976
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
977
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
978
+ $atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
979
+ $atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
980
+ $atom_structure['time_scale'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
981
+ $atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
982
+ $atom_structure['language_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 2));
983
+ $atom_structure['quality'] = getid3_lib::BigEndian2Int(substr($atom_data, 22, 2));
984
+
985
+ if ($atom_structure['time_scale'] == 0) {
986
+ $info['error'][] = 'Corrupt Quicktime file: mdhd.time_scale == zero';
987
+ return false;
988
+ }
989
+ $info['quicktime']['time_scale'] = (isset($info['quicktime']['time_scale']) ? max($info['quicktime']['time_scale'], $atom_structure['time_scale']) : $atom_structure['time_scale']);
990
+
991
+ $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']);
992
+ $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']);
993
+ $atom_structure['playtime_seconds'] = $atom_structure['duration'] / $atom_structure['time_scale'];
994
+ $atom_structure['language'] = $this->QuicktimeLanguageLookup($atom_structure['language_id']);
995
+ if (empty($info['comments']['language']) || (!in_array($atom_structure['language'], $info['comments']['language']))) {
996
+ $info['comments']['language'][] = $atom_structure['language'];
997
+ }
998
+ break;
999
+
1000
+
1001
+ case 'pnot': // Preview atom
1002
+ $atom_structure['modification_date'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); // "standard Macintosh format"
1003
+ $atom_structure['version_number'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x00
1004
+ $atom_structure['atom_type'] = substr($atom_data, 6, 4); // usually: 'PICT'
1005
+ $atom_structure['atom_index'] = getid3_lib::BigEndian2Int(substr($atom_data, 10, 2)); // usually: 0x01
1006
+
1007
+ $atom_structure['modification_date_unix'] = getid3_lib::DateMac2Unix($atom_structure['modification_date']);
1008
+ break;
1009
+
1010
+
1011
+ case 'crgn': // Clipping ReGioN atom
1012
+ $atom_structure['region_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 2)); // The Region size, Region boundary box,
1013
+ $atom_structure['boundary_box'] = getid3_lib::BigEndian2Int(substr($atom_data, 2, 8)); // and Clipping region data fields
1014
+ $atom_structure['clipping_data'] = substr($atom_data, 10); // constitute a QuickDraw region.
1015
+ break;
1016
+
1017
+
1018
+ case 'load': // track LOAD settings atom
1019
+ $atom_structure['preload_start_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
1020
+ $atom_structure['preload_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
1021
+ $atom_structure['preload_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
1022
+ $atom_structure['default_hints_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
1023
+
1024
+ $atom_structure['default_hints']['double_buffer'] = (bool) ($atom_structure['default_hints_raw'] & 0x0020);
1025
+ $atom_structure['default_hints']['high_quality'] = (bool) ($atom_structure['default_hints_raw'] & 0x0100);
1026
+ break;
1027
+
1028
+
1029
+ case 'tmcd': // TiMe CoDe atom
1030
+ case 'chap': // CHAPter list atom
1031
+ case 'sync': // SYNChronization atom
1032
+ case 'scpt': // tranSCriPT atom
1033
+ case 'ssrc': // non-primary SouRCe atom
1034
+ for ($i = 0; $i < (strlen($atom_data) % 4); $i++) {
1035
+ $atom_structure['track_id'][$i] = getid3_lib::BigEndian2Int(substr($atom_data, $i * 4, 4));
1036
+ }
1037
+ break;
1038
+
1039
+
1040
+ case 'elst': // Edit LiST atom
1041
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
1042
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
1043
+ $atom_structure['number_entries'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
1044
+ for ($i = 0; $i < $atom_structure['number_entries']; $i++ ) {
1045
+ $atom_structure['edit_list'][$i]['track_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($i * 12) + 0, 4));
1046
+ $atom_structure['edit_list'][$i]['media_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($i * 12) + 4, 4));
1047
+ $atom_structure['edit_list'][$i]['media_rate'] = getid3_lib::FixedPoint16_16(substr($atom_data, 8 + ($i * 12) + 8, 4));
1048
+ }
1049
+ break;
1050
+
1051
+
1052
+ case 'kmat': // compressed MATte atom
1053
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
1054
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3)); // hardcoded: 0x0000
1055
+ $atom_structure['matte_data_raw'] = substr($atom_data, 4);
1056
+ break;
1057
+
1058
+
1059
+ case 'ctab': // Color TABle atom
1060
+ $atom_structure['color_table_seed'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4)); // hardcoded: 0x00000000
1061
+ $atom_structure['color_table_flags'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 2)); // hardcoded: 0x8000
1062
+ $atom_structure['color_table_size'] = getid3_lib::BigEndian2Int(substr($atom_data, 6, 2)) + 1;
1063
+ for ($colortableentry = 0; $colortableentry < $atom_structure['color_table_size']; $colortableentry++) {
1064
+ $atom_structure['color_table'][$colortableentry]['alpha'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 0, 2));
1065
+ $atom_structure['color_table'][$colortableentry]['red'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 2, 2));
1066
+ $atom_structure['color_table'][$colortableentry]['green'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 4, 2));
1067
+ $atom_structure['color_table'][$colortableentry]['blue'] = getid3_lib::BigEndian2Int(substr($atom_data, 8 + ($colortableentry * 8) + 6, 2));
1068
+ }
1069
+ break;
1070
+
1071
+
1072
+ case 'mvhd': // MoVie HeaDer atom
1073
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
1074
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
1075
+ $atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
1076
+ $atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
1077
+ $atom_structure['time_scale'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
1078
+ $atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
1079
+ $atom_structure['preferred_rate'] = getid3_lib::FixedPoint16_16(substr($atom_data, 20, 4));
1080
+ $atom_structure['preferred_volume'] = getid3_lib::FixedPoint8_8(substr($atom_data, 24, 2));
1081
+ $atom_structure['reserved'] = substr($atom_data, 26, 10);
1082
+ $atom_structure['matrix_a'] = getid3_lib::FixedPoint16_16(substr($atom_data, 36, 4));
1083
+ $atom_structure['matrix_b'] = getid3_lib::FixedPoint16_16(substr($atom_data, 40, 4));
1084
+ $atom_structure['matrix_u'] = getid3_lib::FixedPoint2_30(substr($atom_data, 44, 4));
1085
+ $atom_structure['matrix_c'] = getid3_lib::FixedPoint16_16(substr($atom_data, 48, 4));
1086
+ $atom_structure['matrix_d'] = getid3_lib::FixedPoint16_16(substr($atom_data, 52, 4));
1087
+ $atom_structure['matrix_v'] = getid3_lib::FixedPoint2_30(substr($atom_data, 56, 4));
1088
+ $atom_structure['matrix_x'] = getid3_lib::FixedPoint16_16(substr($atom_data, 60, 4));
1089
+ $atom_structure['matrix_y'] = getid3_lib::FixedPoint16_16(substr($atom_data, 64, 4));
1090
+ $atom_structure['matrix_w'] = getid3_lib::FixedPoint2_30(substr($atom_data, 68, 4));
1091
+ $atom_structure['preview_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 72, 4));
1092
+ $atom_structure['preview_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 76, 4));
1093
+ $atom_structure['poster_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 80, 4));
1094
+ $atom_structure['selection_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 84, 4));
1095
+ $atom_structure['selection_duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 88, 4));
1096
+ $atom_structure['current_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 92, 4));
1097
+ $atom_structure['next_track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, 96, 4));
1098
+
1099
+ if ($atom_structure['time_scale'] == 0) {
1100
+ $info['error'][] = 'Corrupt Quicktime file: mvhd.time_scale == zero';
1101
+ return false;
1102
+ }
1103
+ $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']);
1104
+ $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']);
1105
+ $info['quicktime']['time_scale'] = (isset($info['quicktime']['time_scale']) ? max($info['quicktime']['time_scale'], $atom_structure['time_scale']) : $atom_structure['time_scale']);
1106
+ $info['quicktime']['display_scale'] = $atom_structure['matrix_a'];
1107
+ $info['playtime_seconds'] = $atom_structure['duration'] / $atom_structure['time_scale'];
1108
+ break;
1109
+
1110
+
1111
+ case 'tkhd': // TracK HeaDer atom
1112
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
1113
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
1114
+ $atom_structure['creation_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
1115
+ $atom_structure['modify_time'] = getid3_lib::BigEndian2Int(substr($atom_data, 8, 4));
1116
+ $atom_structure['trackid'] = getid3_lib::BigEndian2Int(substr($atom_data, 12, 4));
1117
+ $atom_structure['reserved1'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4));
1118
+ $atom_structure['duration'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4));
1119
+ $atom_structure['reserved2'] = getid3_lib::BigEndian2Int(substr($atom_data, 24, 8));
1120
+ $atom_structure['layer'] = getid3_lib::BigEndian2Int(substr($atom_data, 32, 2));
1121
+ $atom_structure['alternate_group'] = getid3_lib::BigEndian2Int(substr($atom_data, 34, 2));
1122
+ $atom_structure['volume'] = getid3_lib::FixedPoint8_8(substr($atom_data, 36, 2));
1123
+ $atom_structure['reserved3'] = getid3_lib::BigEndian2Int(substr($atom_data, 38, 2));
1124
+ $atom_structure['matrix_a'] = getid3_lib::FixedPoint16_16(substr($atom_data, 40, 4));
1125
+ $atom_structure['matrix_b'] = getid3_lib::FixedPoint16_16(substr($atom_data, 44, 4));
1126
+ $atom_structure['matrix_u'] = getid3_lib::FixedPoint16_16(substr($atom_data, 48, 4));
1127
+ $atom_structure['matrix_c'] = getid3_lib::FixedPoint16_16(substr($atom_data, 52, 4));
1128
+ $atom_structure['matrix_d'] = getid3_lib::FixedPoint16_16(substr($atom_data, 56, 4));
1129
+ $atom_structure['matrix_v'] = getid3_lib::FixedPoint16_16(substr($atom_data, 60, 4));
1130
+ $atom_structure['matrix_x'] = getid3_lib::FixedPoint2_30(substr($atom_data, 64, 4));
1131
+ $atom_structure['matrix_y'] = getid3_lib::FixedPoint2_30(substr($atom_data, 68, 4));
1132
+ $atom_structure['matrix_w'] = getid3_lib::FixedPoint2_30(substr($atom_data, 72, 4));
1133
+ $atom_structure['width'] = getid3_lib::FixedPoint16_16(substr($atom_data, 76, 4));
1134
+ $atom_structure['height'] = getid3_lib::FixedPoint16_16(substr($atom_data, 80, 4));
1135
+
1136
+ $atom_structure['flags']['enabled'] = (bool) ($atom_structure['flags_raw'] & 0x0001);
1137
+ $atom_structure['flags']['in_movie'] = (bool) ($atom_structure['flags_raw'] & 0x0002);
1138
+ $atom_structure['flags']['in_preview'] = (bool) ($atom_structure['flags_raw'] & 0x0004);
1139
+ $atom_structure['flags']['in_poster'] = (bool) ($atom_structure['flags_raw'] & 0x0008);
1140
+ $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']);
1141
+ $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']);
1142
+
1143
+ if ($atom_structure['flags']['enabled'] == 1) {
1144
+ if (!isset($info['video']['resolution_x']) || !isset($info['video']['resolution_y'])) {
1145
+ $info['video']['resolution_x'] = $atom_structure['width'];
1146
+ $info['video']['resolution_y'] = $atom_structure['height'];
1147
+ }
1148
+ $info['video']['resolution_x'] = max($info['video']['resolution_x'], $atom_structure['width']);
1149
+ $info['video']['resolution_y'] = max($info['video']['resolution_y'], $atom_structure['height']);
1150
+ $info['quicktime']['video']['resolution_x'] = $info['video']['resolution_x'];
1151
+ $info['quicktime']['video']['resolution_y'] = $info['video']['resolution_y'];
1152
+ } else {
1153
+ // see: http://www.getid3.org/phpBB3/viewtopic.php?t=1295
1154
+ //if (isset($info['video']['resolution_x'])) { unset($info['video']['resolution_x']); }
1155
+ //if (isset($info['video']['resolution_y'])) { unset($info['video']['resolution_y']); }
1156
+ //if (isset($info['quicktime']['video'])) { unset($info['quicktime']['video']); }
1157
+ }
1158
+ break;
1159
+
1160
+
1161
+ case 'iods': // Initial Object DeScriptor atom
1162
+ // http://www.koders.com/c/fid1FAB3E762903DC482D8A246D4A4BF9F28E049594.aspx?s=windows.h
1163
+ // http://libquicktime.sourcearchive.com/documentation/1.0.2plus-pdebian/iods_8c-source.html
1164
+ $offset = 0;
1165
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
1166
+ $offset += 1;
1167
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 3));
1168
+ $offset += 3;
1169
+ $atom_structure['mp4_iod_tag'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
1170
+ $offset += 1;
1171
+ $atom_structure['length'] = $this->quicktime_read_mp4_descr_length($atom_data, $offset);
1172
+ //$offset already adjusted by quicktime_read_mp4_descr_length()
1173
+ $atom_structure['object_descriptor_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 2));
1174
+ $offset += 2;
1175
+ $atom_structure['od_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
1176
+ $offset += 1;
1177
+ $atom_structure['scene_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
1178
+ $offset += 1;
1179
+ $atom_structure['audio_profile_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
1180
+ $offset += 1;
1181
+ $atom_structure['video_profile_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
1182
+ $offset += 1;
1183
+ $atom_structure['graphics_profile_level'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
1184
+ $offset += 1;
1185
+
1186
+ $atom_structure['num_iods_tracks'] = ($atom_structure['length'] - 7) / 6; // 6 bytes would only be right if all tracks use 1-byte length fields
1187
+ for ($i = 0; $i < $atom_structure['num_iods_tracks']; $i++) {
1188
+ $atom_structure['track'][$i]['ES_ID_IncTag'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 1));
1189
+ $offset += 1;
1190
+ $atom_structure['track'][$i]['length'] = $this->quicktime_read_mp4_descr_length($atom_data, $offset);
1191
+ //$offset already adjusted by quicktime_read_mp4_descr_length()
1192
+ $atom_structure['track'][$i]['track_id'] = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 4));
1193
+ $offset += 4;
1194
+ }
1195
+
1196
+ $atom_structure['audio_profile_name'] = $this->QuicktimeIODSaudioProfileName($atom_structure['audio_profile_id']);
1197
+ $atom_structure['video_profile_name'] = $this->QuicktimeIODSvideoProfileName($atom_structure['video_profile_id']);
1198
+ break;
1199
+
1200
+ case 'ftyp': // FileTYPe (?) atom (for MP4 it seems)
1201
+ $atom_structure['signature'] = substr($atom_data, 0, 4);
1202
+ $atom_structure['unknown_1'] = getid3_lib::BigEndian2Int(substr($atom_data, 4, 4));
1203
+ $atom_structure['fourcc'] = substr($atom_data, 8, 4);
1204
+ break;
1205
+
1206
+ case 'mdat': // Media DATa atom
1207
+ case 'free': // FREE space atom
1208
+ case 'skip': // SKIP atom
1209
+ case 'wide': // 64-bit expansion placeholder atom
1210
+ // 'mdat' data is too big to deal with, contains no useful metadata
1211
+ // 'free', 'skip' and 'wide' are just padding, contains no useful data at all
1212
+
1213
+ // When writing QuickTime files, it is sometimes necessary to update an atom's size.
1214
+ // It is impossible to update a 32-bit atom to a 64-bit atom since the 32-bit atom
1215
+ // is only 8 bytes in size, and the 64-bit atom requires 16 bytes. Therefore, QuickTime
1216
+ // puts an 8-byte placeholder atom before any atoms it may have to update the size of.
1217
+ // In this way, if the atom needs to be converted from a 32-bit to a 64-bit atom, the
1218
+ // placeholder atom can be overwritten to obtain the necessary 8 extra bytes.
1219
+ // The placeholder atom has a type of kWideAtomPlaceholderType ( 'wide' ).
1220
+ break;
1221
+
1222
+
1223
+ case 'nsav': // NoSAVe atom
1224
+ // http://developer.apple.com/technotes/tn/tn2038.html
1225
+ $atom_structure['data'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
1226
+ break;
1227
+
1228
+ case 'ctyp': // Controller TYPe atom (seen on QTVR)
1229
+ // http://homepages.slingshot.co.nz/~helmboy/quicktime/formats/qtm-layout.txt
1230
+ // some controller names are:
1231
+ // 0x00 + 'std' for linear movie
1232
+ // 'none' for no controls
1233
+ $atom_structure['ctyp'] = substr($atom_data, 0, 4);
1234
+ $info['quicktime']['controller'] = $atom_structure['ctyp'];
1235
+ switch ($atom_structure['ctyp']) {
1236
+ case 'qtvr':
1237
+ $info['video']['dataformat'] = 'quicktimevr';
1238
+ break;
1239
+ }
1240
+ break;
1241
+
1242
+ case 'pano': // PANOrama track (seen on QTVR)
1243
+ $atom_structure['pano'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 4));
1244
+ break;
1245
+
1246
+ case 'hint': // HINT track
1247
+ case 'hinf': //
1248
+ case 'hinv': //
1249
+ case 'hnti': //
1250
+ $info['quicktime']['hinting'] = true;
1251
+ break;
1252
+
1253
+ case 'imgt': // IMaGe Track reference (kQTVRImageTrackRefType) (seen on QTVR)
1254
+ for ($i = 0; $i < ($atom_structure['size'] - 8); $i += 4) {
1255
+ $atom_structure['imgt'][] = getid3_lib::BigEndian2Int(substr($atom_data, $i, 4));
1256
+ }
1257
+ break;
1258
+
1259
+
1260
+ // Observed-but-not-handled atom types are just listed here to prevent warnings being generated
1261
+ case 'FXTC': // Something to do with Adobe After Effects (?)
1262
+ case 'PrmA':
1263
+ case 'code':
1264
+ case 'FIEL': // this is NOT "fiel" (Field Ordering) as describe here: http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap3/chapter_4_section_2.html
1265
+ case 'tapt': // TrackApertureModeDimensionsAID - http://developer.apple.com/documentation/QuickTime/Reference/QT7-1_Update_Reference/Constants/Constants.html
1266
+ // tapt seems to be used to compute the video size [http://www.getid3.org/phpBB3/viewtopic.php?t=838]
1267
+ // * http://lists.apple.com/archives/quicktime-api/2006/Aug/msg00014.html
1268
+ // * http://handbrake.fr/irclogs/handbrake-dev/handbrake-dev20080128_pg2.html
1269
+ case 'ctts':// STCompositionOffsetAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html
1270
+ case 'cslg':// STCompositionShiftLeastGreatestAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html
1271
+ case 'sdtp':// STSampleDependencyAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html
1272
+ case 'stps':// STPartialSyncSampleAID - http://developer.apple.com/documentation/QuickTime/Reference/QTRef_Constants/Reference/reference.html
1273
+ //$atom_structure['data'] = $atom_data;
1274
+ break;
1275
+
1276
+ case '�xyz': // GPS latitude+longitude+altitude
1277
+ $atom_structure['data'] = $atom_data;
1278
+ if (preg_match('#([\\+\\-][0-9\\.]+)([\\+\\-][0-9\\.]+)([\\+\\-][0-9\\.]+)?/$#i', $atom_data, $matches)) {
1279
+ @list($all, $latitude, $longitude, $altitude) = $matches;
1280
+ $info['quicktime']['comments']['gps_latitude'][] = floatval($latitude);
1281
+ $info['quicktime']['comments']['gps_longitude'][] = floatval($longitude);
1282
+ if (!empty($altitude)) {
1283
+ $info['quicktime']['comments']['gps_altitude'][] = floatval($altitude);
1284
+ }
1285
+ } else {
1286
+ $info['warning'][] = 'QuickTime atom "�xyz" data does not match expected data pattern at offset '.$baseoffset.'. Please report as getID3() bug.';
1287
+ }
1288
+ break;
1289
+
1290
+ case 'NCDT':
1291
+ // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html
1292
+ // Nikon-specific QuickTime tags found in the NCDT atom of MOV videos from some Nikon cameras such as the Coolpix S8000 and D5100
1293
+ $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 4, $atomHierarchy, $ParseAllPossibleAtoms);
1294
+ break;
1295
+ case 'NCTH': // Nikon Camera THumbnail image
1296
+ case 'NCVW': // Nikon Camera preVieW image
1297
+ // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html
1298
+ if (preg_match('/^\xFF\xD8\xFF/', $atom_data)) {
1299
+ $atom_structure['data'] = $atom_data;
1300
+ $atom_structure['image_mime'] = 'image/jpeg';
1301
+ $atom_structure['description'] = (($atomname == 'NCTH') ? 'Nikon Camera Thumbnail Image' : (($atomname == 'NCVW') ? 'Nikon Camera Preview Image' : 'Nikon preview image'));
1302
+ $info['quicktime']['comments']['picture'][] = array('image_mime'=>$atom_structure['image_mime'], 'data'=>$atom_data, 'description'=>$atom_structure['description']);
1303
+ }
1304
+ break;
1305
+ case 'NCHD': // MakerNoteVersion
1306
+ // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html
1307
+ $atom_structure['data'] = $atom_data;
1308
+ break;
1309
+ case 'NCTG': // NikonTags
1310
+ // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#NCTG
1311
+ $atom_structure['data'] = $this->QuicktimeParseNikonNCTG($atom_data);
1312
+ break;
1313
+ case 'NCDB': // NikonTags
1314
+ // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html
1315
+ $atom_structure['data'] = $atom_data;
1316
+ break;
1317
+
1318
+ case "\x00\x00\x00\x00":
1319
+ case 'meta': // METAdata atom
1320
+ // some kind of metacontainer, may contain a big data dump such as:
1321
+ // mdta keys mdtacom.apple.quicktime.make (mdtacom.apple.quicktime.creationdate ,mdtacom.apple.quicktime.location.ISO6709 $mdtacom.apple.quicktime.software !mdtacom.apple.quicktime.model ilst data DEApple 0 (data DE2011-05-11T17:54:04+0200 2 *data DE+52.4936+013.3897+040.247/ data DE4.3.1 data DEiPhone 4
1322
+ // http://www.geocities.com/xhelmboyx/quicktime/formats/qti-layout.txt
1323
+
1324
+ $atom_structure['version'] = getid3_lib::BigEndian2Int(substr($atom_data, 0, 1));
1325
+ $atom_structure['flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 1, 3));
1326
+ $atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom(substr($atom_data, 4), $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
1327
+ //$atom_structure['subatoms'] = $this->QuicktimeParseContainerAtom($atom_data, $baseoffset + 8, $atomHierarchy, $ParseAllPossibleAtoms);
1328
+ break;
1329
+
1330
+ case 'data': // metaDATA atom
1331
+ // seems to be 2 bytes language code (ASCII), 2 bytes unknown (set to 0x10B5 in sample I have), remainder is useful data
1332
+ $atom_structure['language'] = substr($atom_data, 4 + 0, 2);
1333
+ $atom_structure['unknown'] = getid3_lib::BigEndian2Int(substr($atom_data, 4 + 2, 2));
1334
+ $atom_structure['data'] = substr($atom_data, 4 + 4);
1335
+ break;
1336
+
1337
+ default:
1338
+ $info['warning'][] = 'Unknown QuickTime atom type: "'.$atomname.'" ('.trim(getid3_lib::PrintHexBytes($atomname)).') at offset '.$baseoffset;
1339
+ $atom_structure['data'] = $atom_data;
1340
+ break;
1341
+ }
1342
+ array_pop($atomHierarchy);
1343
+ return $atom_structure;
1344
+ }
1345
+
1346
+ public function QuicktimeParseContainerAtom($atom_data, $baseoffset, &$atomHierarchy, $ParseAllPossibleAtoms) {
1347
+ //echo 'QuicktimeParseContainerAtom('.substr($atom_data, 4, 4).') @ '.$baseoffset.'<br><br>';
1348
+ $atom_structure = false;
1349
+ $subatomoffset = 0;
1350
+ $subatomcounter = 0;
1351
+ if ((strlen($atom_data) == 4) && (getid3_lib::BigEndian2Int($atom_data) == 0x00000000)) {
1352
+ return false;
1353
+ }
1354
+ while ($subatomoffset < strlen($atom_data)) {
1355
+ $subatomsize = getid3_lib::BigEndian2Int(substr($atom_data, $subatomoffset + 0, 4));
1356
+ $subatomname = substr($atom_data, $subatomoffset + 4, 4);
1357
+ $subatomdata = substr($atom_data, $subatomoffset + 8, $subatomsize - 8);
1358
+ if ($subatomsize == 0) {
1359
+ // Furthermore, for historical reasons the list of atoms is optionally
1360
+ // terminated by a 32-bit integer set to 0. If you are writing a program
1361
+ // to read user data atoms, you should allow for the terminating 0.
1362
+ return $atom_structure;
1363
+ }
1364
+
1365
+ $atom_structure[$subatomcounter] = $this->QuicktimeParseAtom($subatomname, $subatomsize, $subatomdata, $baseoffset + $subatomoffset, $atomHierarchy, $ParseAllPossibleAtoms);
1366
+
1367
+ $subatomoffset += $subatomsize;
1368
+ $subatomcounter++;
1369
+ }
1370
+ return $atom_structure;
1371
+ }
1372
+
1373
+
1374
+ public function quicktime_read_mp4_descr_length($data, &$offset) {
1375
+ // http://libquicktime.sourcearchive.com/documentation/2:1.0.2plus-pdebian-2build1/esds_8c-source.html
1376
+ $num_bytes = 0;
1377
+ $length = 0;
1378
+ do {
1379
+ $b = ord(substr($data, $offset++, 1));
1380
+ $length = ($length << 7) | ($b & 0x7F);
1381
+ } while (($b & 0x80) && ($num_bytes++ < 4));
1382
+ return $length;
1383
+ }
1384
+
1385
+
1386
+ public function QuicktimeLanguageLookup($languageid) {
1387
+ static $QuicktimeLanguageLookup = array();
1388
+ if (empty($QuicktimeLanguageLookup)) {
1389
+ $QuicktimeLanguageLookup[0] = 'English';
1390
+ $QuicktimeLanguageLookup[1] = 'French';
1391
+ $QuicktimeLanguageLookup[2] = 'German';
1392
+ $QuicktimeLanguageLookup[3] = 'Italian';
1393
+ $QuicktimeLanguageLookup[4] = 'Dutch';
1394
+ $QuicktimeLanguageLookup[5] = 'Swedish';
1395
+ $QuicktimeLanguageLookup[6] = 'Spanish';
1396
+ $QuicktimeLanguageLookup[7] = 'Danish';
1397
+ $QuicktimeLanguageLookup[8] = 'Portuguese';
1398
+ $QuicktimeLanguageLookup[9] = 'Norwegian';
1399
+ $QuicktimeLanguageLookup[10] = 'Hebrew';
1400
+ $QuicktimeLanguageLookup[11] = 'Japanese';
1401
+ $QuicktimeLanguageLookup[12] = 'Arabic';
1402
+ $QuicktimeLanguageLookup[13] = 'Finnish';
1403
+ $QuicktimeLanguageLookup[14] = 'Greek';
1404
+ $QuicktimeLanguageLookup[15] = 'Icelandic';
1405
+ $QuicktimeLanguageLookup[16] = 'Maltese';
1406
+ $QuicktimeLanguageLookup[17] = 'Turkish';
1407
+ $QuicktimeLanguageLookup[18] = 'Croatian';
1408
+ $QuicktimeLanguageLookup[19] = 'Chinese (Traditional)';
1409
+ $QuicktimeLanguageLookup[20] = 'Urdu';
1410
+ $QuicktimeLanguageLookup[21] = 'Hindi';
1411
+ $QuicktimeLanguageLookup[22] = 'Thai';
1412
+ $QuicktimeLanguageLookup[23] = 'Korean';
1413
+ $QuicktimeLanguageLookup[24] = 'Lithuanian';
1414
+ $QuicktimeLanguageLookup[25] = 'Polish';
1415
+ $QuicktimeLanguageLookup[26] = 'Hungarian';
1416
+ $QuicktimeLanguageLookup[27] = 'Estonian';
1417
+ $QuicktimeLanguageLookup[28] = 'Lettish';
1418
+ $QuicktimeLanguageLookup[28] = 'Latvian';
1419
+ $QuicktimeLanguageLookup[29] = 'Saamisk';
1420
+ $QuicktimeLanguageLookup[29] = 'Lappish';
1421
+ $QuicktimeLanguageLookup[30] = 'Faeroese';
1422
+ $QuicktimeLanguageLookup[31] = 'Farsi';
1423
+ $QuicktimeLanguageLookup[31] = 'Persian';
1424
+ $QuicktimeLanguageLookup[32] = 'Russian';
1425
+ $QuicktimeLanguageLookup[33] = 'Chinese (Simplified)';
1426
+ $QuicktimeLanguageLookup[34] = 'Flemish';
1427
+ $QuicktimeLanguageLookup[35] = 'Irish';
1428
+ $QuicktimeLanguageLookup[36] = 'Albanian';
1429
+ $QuicktimeLanguageLookup[37] = 'Romanian';
1430
+ $QuicktimeLanguageLookup[38] = 'Czech';
1431
+ $QuicktimeLanguageLookup[39] = 'Slovak';
1432
+ $QuicktimeLanguageLookup[40] = 'Slovenian';
1433
+ $QuicktimeLanguageLookup[41] = 'Yiddish';
1434
+ $QuicktimeLanguageLookup[42] = 'Serbian';
1435
+ $QuicktimeLanguageLookup[43] = 'Macedonian';
1436
+ $QuicktimeLanguageLookup[44] = 'Bulgarian';
1437
+ $QuicktimeLanguageLookup[45] = 'Ukrainian';
1438
+ $QuicktimeLanguageLookup[46] = 'Byelorussian';
1439
+ $QuicktimeLanguageLookup[47] = 'Uzbek';
1440
+ $QuicktimeLanguageLookup[48] = 'Kazakh';
1441
+ $QuicktimeLanguageLookup[49] = 'Azerbaijani';
1442
+ $QuicktimeLanguageLookup[50] = 'AzerbaijanAr';
1443
+ $QuicktimeLanguageLookup[51] = 'Armenian';
1444
+ $QuicktimeLanguageLookup[52] = 'Georgian';
1445
+ $QuicktimeLanguageLookup[53] = 'Moldavian';
1446
+ $QuicktimeLanguageLookup[54] = 'Kirghiz';
1447
+ $QuicktimeLanguageLookup[55] = 'Tajiki';
1448
+ $QuicktimeLanguageLookup[56] = 'Turkmen';
1449
+ $QuicktimeLanguageLookup[57] = 'Mongolian';
1450
+ $QuicktimeLanguageLookup[58] = 'MongolianCyr';
1451
+ $QuicktimeLanguageLookup[59] = 'Pashto';
1452
+ $QuicktimeLanguageLookup[60] = 'Kurdish';
1453
+ $QuicktimeLanguageLookup[61] = 'Kashmiri';
1454
+ $QuicktimeLanguageLookup[62] = 'Sindhi';
1455
+ $QuicktimeLanguageLookup[63] = 'Tibetan';
1456
+ $QuicktimeLanguageLookup[64] = 'Nepali';
1457
+ $QuicktimeLanguageLookup[65] = 'Sanskrit';
1458
+ $QuicktimeLanguageLookup[66] = 'Marathi';
1459
+ $QuicktimeLanguageLookup[67] = 'Bengali';
1460
+ $QuicktimeLanguageLookup[68] = 'Assamese';
1461
+ $QuicktimeLanguageLookup[69] = 'Gujarati';
1462
+ $QuicktimeLanguageLookup[70] = 'Punjabi';
1463
+ $QuicktimeLanguageLookup[71] = 'Oriya';
1464
+ $QuicktimeLanguageLookup[72] = 'Malayalam';
1465
+ $QuicktimeLanguageLookup[73] = 'Kannada';
1466
+ $QuicktimeLanguageLookup[74] = 'Tamil';
1467
+ $QuicktimeLanguageLookup[75] = 'Telugu';
1468
+ $QuicktimeLanguageLookup[76] = 'Sinhalese';
1469
+ $QuicktimeLanguageLookup[77] = 'Burmese';
1470
+ $QuicktimeLanguageLookup[78] = 'Khmer';
1471
+ $QuicktimeLanguageLookup[79] = 'Lao';
1472
+ $QuicktimeLanguageLookup[80] = 'Vietnamese';
1473
+ $QuicktimeLanguageLookup[81] = 'Indonesian';
1474
+ $QuicktimeLanguageLookup[82] = 'Tagalog';
1475
+ $QuicktimeLanguageLookup[83] = 'MalayRoman';
1476
+ $QuicktimeLanguageLookup[84] = 'MalayArabic';
1477
+ $QuicktimeLanguageLookup[85] = 'Amharic';
1478
+ $QuicktimeLanguageLookup[86] = 'Tigrinya';
1479
+ $QuicktimeLanguageLookup[87] = 'Galla';
1480
+ $QuicktimeLanguageLookup[87] = 'Oromo';
1481
+ $QuicktimeLanguageLookup[88] = 'Somali';
1482
+ $QuicktimeLanguageLookup[89] = 'Swahili';
1483
+ $QuicktimeLanguageLookup[90] = 'Ruanda';
1484
+ $QuicktimeLanguageLookup[91] = 'Rundi';
1485
+ $QuicktimeLanguageLookup[92] = 'Chewa';
1486
+ $QuicktimeLanguageLookup[93] = 'Malagasy';
1487
+ $QuicktimeLanguageLookup[94] = 'Esperanto';
1488
+ $QuicktimeLanguageLookup[128] = 'Welsh';
1489
+ $QuicktimeLanguageLookup[129] = 'Basque';
1490
+ $QuicktimeLanguageLookup[130] = 'Catalan';
1491
+ $QuicktimeLanguageLookup[131] = 'Latin';
1492
+ $QuicktimeLanguageLookup[132] = 'Quechua';
1493
+ $QuicktimeLanguageLookup[133] = 'Guarani';
1494
+ $QuicktimeLanguageLookup[134] = 'Aymara';
1495
+ $QuicktimeLanguageLookup[135] = 'Tatar';
1496
+ $QuicktimeLanguageLookup[136] = 'Uighur';
1497
+ $QuicktimeLanguageLookup[137] = 'Dzongkha';
1498
+ $QuicktimeLanguageLookup[138] = 'JavaneseRom';
1499
+ }
1500
+ return (isset($QuicktimeLanguageLookup[$languageid]) ? $QuicktimeLanguageLookup[$languageid] : 'invalid');
1501
+ }
1502
+
1503
+ public function QuicktimeVideoCodecLookup($codecid) {
1504
+ static $QuicktimeVideoCodecLookup = array();
1505
+ if (empty($QuicktimeVideoCodecLookup)) {
1506
+ $QuicktimeVideoCodecLookup['.SGI'] = 'SGI';
1507
+ $QuicktimeVideoCodecLookup['3IV1'] = '3ivx MPEG-4 v1';
1508
+ $QuicktimeVideoCodecLookup['3IV2'] = '3ivx MPEG-4 v2';
1509
+ $QuicktimeVideoCodecLookup['3IVX'] = '3ivx MPEG-4';
1510
+ $QuicktimeVideoCodecLookup['8BPS'] = 'Planar RGB';
1511
+ $QuicktimeVideoCodecLookup['avc1'] = 'H.264/MPEG-4 AVC';
1512
+ $QuicktimeVideoCodecLookup['avr '] = 'AVR-JPEG';
1513
+ $QuicktimeVideoCodecLookup['b16g'] = '16Gray';
1514
+ $QuicktimeVideoCodecLookup['b32a'] = '32AlphaGray';
1515
+ $QuicktimeVideoCodecLookup['b48r'] = '48RGB';
1516
+ $QuicktimeVideoCodecLookup['b64a'] = '64ARGB';
1517
+ $QuicktimeVideoCodecLookup['base'] = 'Base';
1518
+ $QuicktimeVideoCodecLookup['clou'] = 'Cloud';
1519
+ $QuicktimeVideoCodecLookup['cmyk'] = 'CMYK';
1520
+ $QuicktimeVideoCodecLookup['cvid'] = 'Cinepak';
1521
+ $QuicktimeVideoCodecLookup['dmb1'] = 'OpenDML JPEG';
1522
+ $QuicktimeVideoCodecLookup['dvc '] = 'DVC-NTSC';
1523
+ $QuicktimeVideoCodecLookup['dvcp'] = 'DVC-PAL';
1524
+ $QuicktimeVideoCodecLookup['dvpn'] = 'DVCPro-NTSC';
1525
+ $QuicktimeVideoCodecLookup['dvpp'] = 'DVCPro-PAL';
1526
+ $QuicktimeVideoCodecLookup['fire'] = 'Fire';
1527
+ $QuicktimeVideoCodecLookup['flic'] = 'FLC';
1528
+ $QuicktimeVideoCodecLookup['gif '] = 'GIF';
1529
+ $QuicktimeVideoCodecLookup['h261'] = 'H261';
1530
+ $QuicktimeVideoCodecLookup['h263'] = 'H263';
1531
+ $QuicktimeVideoCodecLookup['IV41'] = 'Indeo4';
1532
+ $QuicktimeVideoCodecLookup['jpeg'] = 'JPEG';
1533
+ $QuicktimeVideoCodecLookup['kpcd'] = 'PhotoCD';
1534
+ $QuicktimeVideoCodecLookup['mjpa'] = 'Motion JPEG-A';
1535
+ $QuicktimeVideoCodecLookup['mjpb'] = 'Motion JPEG-B';
1536
+ $QuicktimeVideoCodecLookup['msvc'] = 'Microsoft Video1';
1537
+ $QuicktimeVideoCodecLookup['myuv'] = 'MPEG YUV420';
1538
+ $QuicktimeVideoCodecLookup['path'] = 'Vector';
1539
+ $QuicktimeVideoCodecLookup['png '] = 'PNG';
1540
+ $QuicktimeVideoCodecLookup['PNTG'] = 'MacPaint';
1541
+ $QuicktimeVideoCodecLookup['qdgx'] = 'QuickDrawGX';
1542
+ $QuicktimeVideoCodecLookup['qdrw'] = 'QuickDraw';
1543
+ $QuicktimeVideoCodecLookup['raw '] = 'RAW';
1544
+ $QuicktimeVideoCodecLookup['ripl'] = 'WaterRipple';
1545
+ $QuicktimeVideoCodecLookup['rpza'] = 'Video';
1546
+ $QuicktimeVideoCodecLookup['smc '] = 'Graphics';
1547
+ $QuicktimeVideoCodecLookup['SVQ1'] = 'Sorenson Video 1';
1548
+ $QuicktimeVideoCodecLookup['SVQ1'] = 'Sorenson Video 3';
1549
+ $QuicktimeVideoCodecLookup['syv9'] = 'Sorenson YUV9';
1550
+ $QuicktimeVideoCodecLookup['tga '] = 'Targa';
1551
+ $QuicktimeVideoCodecLookup['tiff'] = 'TIFF';
1552
+ $QuicktimeVideoCodecLookup['WRAW'] = 'Windows RAW';
1553
+ $QuicktimeVideoCodecLookup['WRLE'] = 'BMP';
1554
+ $QuicktimeVideoCodecLookup['y420'] = 'YUV420';
1555
+ $QuicktimeVideoCodecLookup['yuv2'] = 'ComponentVideo';
1556
+ $QuicktimeVideoCodecLookup['yuvs'] = 'ComponentVideoUnsigned';
1557
+ $QuicktimeVideoCodecLookup['yuvu'] = 'ComponentVideoSigned';
1558
+ }
1559
+ return (isset($QuicktimeVideoCodecLookup[$codecid]) ? $QuicktimeVideoCodecLookup[$codecid] : '');
1560
+ }
1561
+
1562
+ public function QuicktimeAudioCodecLookup($codecid) {
1563
+ static $QuicktimeAudioCodecLookup = array();
1564
+ if (empty($QuicktimeAudioCodecLookup)) {
1565
+ $QuicktimeAudioCodecLookup['.mp3'] = 'Fraunhofer MPEG Layer-III alias';
1566
+ $QuicktimeAudioCodecLookup['aac '] = 'ISO/IEC 14496-3 AAC';
1567
+ $QuicktimeAudioCodecLookup['agsm'] = 'Apple GSM 10:1';
1568
+ $QuicktimeAudioCodecLookup['alac'] = 'Apple Lossless Audio Codec';
1569
+ $QuicktimeAudioCodecLookup['alaw'] = 'A-law 2:1';
1570
+ $QuicktimeAudioCodecLookup['conv'] = 'Sample Format';
1571
+ $QuicktimeAudioCodecLookup['dvca'] = 'DV';
1572
+ $QuicktimeAudioCodecLookup['dvi '] = 'DV 4:1';
1573
+ $QuicktimeAudioCodecLookup['eqal'] = 'Frequency Equalizer';
1574
+ $QuicktimeAudioCodecLookup['fl32'] = '32-bit Floating Point';
1575
+ $QuicktimeAudioCodecLookup['fl64'] = '64-bit Floating Point';
1576
+ $QuicktimeAudioCodecLookup['ima4'] = 'Interactive Multimedia Association 4:1';
1577
+ $QuicktimeAudioCodecLookup['in24'] = '24-bit Integer';
1578
+ $QuicktimeAudioCodecLookup['in32'] = '32-bit Integer';
1579
+ $QuicktimeAudioCodecLookup['lpc '] = 'LPC 23:1';
1580
+ $QuicktimeAudioCodecLookup['MAC3'] = 'Macintosh Audio Compression/Expansion (MACE) 3:1';
1581
+ $QuicktimeAudioCodecLookup['MAC6'] = 'Macintosh Audio Compression/Expansion (MACE) 6:1';
1582
+ $QuicktimeAudioCodecLookup['mixb'] = '8-bit Mixer';
1583
+ $QuicktimeAudioCodecLookup['mixw'] = '16-bit Mixer';
1584
+ $QuicktimeAudioCodecLookup['mp4a'] = 'ISO/IEC 14496-3 AAC';
1585
+ $QuicktimeAudioCodecLookup['MS'."\x00\x02"] = 'Microsoft ADPCM';
1586
+ $QuicktimeAudioCodecLookup['MS'."\x00\x11"] = 'DV IMA';
1587
+ $QuicktimeAudioCodecLookup['MS'."\x00\x55"] = 'Fraunhofer MPEG Layer III';
1588
+ $QuicktimeAudioCodecLookup['NONE'] = 'No Encoding';
1589
+ $QuicktimeAudioCodecLookup['Qclp'] = 'Qualcomm PureVoice';
1590
+ $QuicktimeAudioCodecLookup['QDM2'] = 'QDesign Music 2';
1591
+ $QuicktimeAudioCodecLookup['QDMC'] = 'QDesign Music 1';
1592
+ $QuicktimeAudioCodecLookup['ratb'] = '8-bit Rate';
1593
+ $QuicktimeAudioCodecLookup['ratw'] = '16-bit Rate';
1594
+ $QuicktimeAudioCodecLookup['raw '] = 'raw PCM';
1595
+ $QuicktimeAudioCodecLookup['sour'] = 'Sound Source';
1596
+ $QuicktimeAudioCodecLookup['sowt'] = 'signed/two\'s complement (Little Endian)';
1597
+ $QuicktimeAudioCodecLookup['str1'] = 'Iomega MPEG layer II';
1598
+ $QuicktimeAudioCodecLookup['str2'] = 'Iomega MPEG *layer II';
1599
+ $QuicktimeAudioCodecLookup['str3'] = 'Iomega MPEG **layer II';
1600
+ $QuicktimeAudioCodecLookup['str4'] = 'Iomega MPEG ***layer II';
1601
+ $QuicktimeAudioCodecLookup['twos'] = 'signed/two\'s complement (Big Endian)';
1602
+ $QuicktimeAudioCodecLookup['ulaw'] = 'mu-law 2:1';
1603
+ }
1604
+ return (isset($QuicktimeAudioCodecLookup[$codecid]) ? $QuicktimeAudioCodecLookup[$codecid] : '');
1605
+ }
1606
+
1607
+ public function QuicktimeDCOMLookup($compressionid) {
1608
+ static $QuicktimeDCOMLookup = array();
1609
+ if (empty($QuicktimeDCOMLookup)) {
1610
+ $QuicktimeDCOMLookup['zlib'] = 'ZLib Deflate';
1611
+ $QuicktimeDCOMLookup['adec'] = 'Apple Compression';
1612
+ }
1613
+ return (isset($QuicktimeDCOMLookup[$compressionid]) ? $QuicktimeDCOMLookup[$compressionid] : '');
1614
+ }
1615
+
1616
+ public function QuicktimeColorNameLookup($colordepthid) {
1617
+ static $QuicktimeColorNameLookup = array();
1618
+ if (empty($QuicktimeColorNameLookup)) {
1619
+ $QuicktimeColorNameLookup[1] = '2-color (monochrome)';
1620
+ $QuicktimeColorNameLookup[2] = '4-color';
1621
+ $QuicktimeColorNameLookup[4] = '16-color';
1622
+ $QuicktimeColorNameLookup[8] = '256-color';
1623
+ $QuicktimeColorNameLookup[16] = 'thousands (16-bit color)';
1624
+ $QuicktimeColorNameLookup[24] = 'millions (24-bit color)';
1625
+ $QuicktimeColorNameLookup[32] = 'millions+ (32-bit color)';
1626
+ $QuicktimeColorNameLookup[33] = 'black & white';
1627
+ $QuicktimeColorNameLookup[34] = '4-gray';
1628
+ $QuicktimeColorNameLookup[36] = '16-gray';
1629
+ $QuicktimeColorNameLookup[40] = '256-gray';
1630
+ }
1631
+ return (isset($QuicktimeColorNameLookup[$colordepthid]) ? $QuicktimeColorNameLookup[$colordepthid] : 'invalid');
1632
+ }
1633
+
1634
+ public function QuicktimeSTIKLookup($stik) {
1635
+ static $QuicktimeSTIKLookup = array();
1636
+ if (empty($QuicktimeSTIKLookup)) {
1637
+ $QuicktimeSTIKLookup[0] = 'Movie';
1638
+ $QuicktimeSTIKLookup[1] = 'Normal';
1639
+ $QuicktimeSTIKLookup[2] = 'Audiobook';
1640
+ $QuicktimeSTIKLookup[5] = 'Whacked Bookmark';
1641
+ $QuicktimeSTIKLookup[6] = 'Music Video';
1642
+ $QuicktimeSTIKLookup[9] = 'Short Film';
1643
+ $QuicktimeSTIKLookup[10] = 'TV Show';
1644
+ $QuicktimeSTIKLookup[11] = 'Booklet';
1645
+ $QuicktimeSTIKLookup[14] = 'Ringtone';
1646
+ $QuicktimeSTIKLookup[21] = 'Podcast';
1647
+ }
1648
+ return (isset($QuicktimeSTIKLookup[$stik]) ? $QuicktimeSTIKLookup[$stik] : 'invalid');
1649
+ }
1650
+
1651
+ public function QuicktimeIODSaudioProfileName($audio_profile_id) {
1652
+ static $QuicktimeIODSaudioProfileNameLookup = array();
1653
+ if (empty($QuicktimeIODSaudioProfileNameLookup)) {
1654
+ $QuicktimeIODSaudioProfileNameLookup = array(
1655
+ 0x00 => 'ISO Reserved (0x00)',
1656
+ 0x01 => 'Main Audio Profile @ Level 1',
1657
+ 0x02 => 'Main Audio Profile @ Level 2',
1658
+ 0x03 => 'Main Audio Profile @ Level 3',
1659
+ 0x04 => 'Main Audio Profile @ Level 4',
1660
+ 0x05 => 'Scalable Audio Profile @ Level 1',
1661
+ 0x06 => 'Scalable Audio Profile @ Level 2',
1662
+ 0x07 => 'Scalable Audio Profile @ Level 3',
1663
+ 0x08 => 'Scalable Audio Profile @ Level 4',
1664
+ 0x09 => 'Speech Audio Profile @ Level 1',
1665
+ 0x0A => 'Speech Audio Profile @ Level 2',
1666
+ 0x0B => 'Synthetic Audio Profile @ Level 1',
1667
+ 0x0C => 'Synthetic Audio Profile @ Level 2',
1668
+ 0x0D => 'Synthetic Audio Profile @ Level 3',
1669
+ 0x0E => 'High Quality Audio Profile @ Level 1',
1670
+ 0x0F => 'High Quality Audio Profile @ Level 2',
1671
+ 0x10 => 'High Quality Audio Profile @ Level 3',
1672
+ 0x11 => 'High Quality Audio Profile @ Level 4',
1673
+ 0x12 => 'High Quality Audio Profile @ Level 5',
1674
+ 0x13 => 'High Quality Audio Profile @ Level 6',
1675
+ 0x14 => 'High Quality Audio Profile @ Level 7',
1676
+ 0x15 => 'High Quality Audio Profile @ Level 8',
1677
+ 0x16 => 'Low Delay Audio Profile @ Level 1',
1678
+ 0x17 => 'Low Delay Audio Profile @ Level 2',
1679
+ 0x18 => 'Low Delay Audio Profile @ Level 3',
1680
+ 0x19 => 'Low Delay Audio Profile @ Level 4',
1681
+ 0x1A => 'Low Delay Audio Profile @ Level 5',
1682
+ 0x1B => 'Low Delay Audio Profile @ Level 6',
1683
+ 0x1C => 'Low Delay Audio Profile @ Level 7',
1684
+ 0x1D => 'Low Delay Audio Profile @ Level 8',
1685
+ 0x1E => 'Natural Audio Profile @ Level 1',
1686
+ 0x1F => 'Natural Audio Profile @ Level 2',
1687
+ 0x20 => 'Natural Audio Profile @ Level 3',
1688
+ 0x21 => 'Natural Audio Profile @ Level 4',
1689
+ 0x22 => 'Mobile Audio Internetworking Profile @ Level 1',
1690
+ 0x23 => 'Mobile Audio Internetworking Profile @ Level 2',
1691
+ 0x24 => 'Mobile Audio Internetworking Profile @ Level 3',
1692
+ 0x25 => 'Mobile Audio Internetworking Profile @ Level 4',
1693
+ 0x26 => 'Mobile Audio Internetworking Profile @ Level 5',
1694
+ 0x27 => 'Mobile Audio Internetworking Profile @ Level 6',
1695
+ 0x28 => 'AAC Profile @ Level 1',
1696
+ 0x29 => 'AAC Profile @ Level 2',
1697
+ 0x2A => 'AAC Profile @ Level 4',
1698
+ 0x2B => 'AAC Profile @ Level 5',
1699
+ 0x2C => 'High Efficiency AAC Profile @ Level 2',
1700
+ 0x2D => 'High Efficiency AAC Profile @ Level 3',
1701
+ 0x2E => 'High Efficiency AAC Profile @ Level 4',
1702
+ 0x2F => 'High Efficiency AAC Profile @ Level 5',
1703
+ 0xFE => 'Not part of MPEG-4 audio profiles',
1704
+ 0xFF => 'No audio capability required',
1705
+ );
1706
+ }
1707
+ return (isset($QuicktimeIODSaudioProfileNameLookup[$audio_profile_id]) ? $QuicktimeIODSaudioProfileNameLookup[$audio_profile_id] : 'ISO Reserved / User Private');
1708
+ }
1709
+
1710
+
1711
+ public function QuicktimeIODSvideoProfileName($video_profile_id) {
1712
+ static $QuicktimeIODSvideoProfileNameLookup = array();
1713
+ if (empty($QuicktimeIODSvideoProfileNameLookup)) {
1714
+ $QuicktimeIODSvideoProfileNameLookup = array(
1715
+ 0x00 => 'Reserved (0x00) Profile',
1716
+ 0x01 => 'Simple Profile @ Level 1',
1717
+ 0x02 => 'Simple Profile @ Level 2',
1718
+ 0x03 => 'Simple Profile @ Level 3',
1719
+ 0x08 => 'Simple Profile @ Level 0',
1720
+ 0x10 => 'Simple Scalable Profile @ Level 0',
1721
+ 0x11 => 'Simple Scalable Profile @ Level 1',
1722
+ 0x12 => 'Simple Scalable Profile @ Level 2',
1723
+ 0x15 => 'AVC/H264 Profile',
1724
+ 0x21 => 'Core Profile @ Level 1',
1725
+ 0x22 => 'Core Profile @ Level 2',
1726
+ 0x32 => 'Main Profile @ Level 2',
1727
+ 0x33 => 'Main Profile @ Level 3',
1728
+ 0x34 => 'Main Profile @ Level 4',
1729
+ 0x42 => 'N-bit Profile @ Level 2',
1730
+ 0x51 => 'Scalable Texture Profile @ Level 1',
1731
+ 0x61 => 'Simple Face Animation Profile @ Level 1',
1732
+ 0x62 => 'Simple Face Animation Profile @ Level 2',
1733
+ 0x63 => 'Simple FBA Profile @ Level 1',
1734
+ 0x64 => 'Simple FBA Profile @ Level 2',
1735
+ 0x71 => 'Basic Animated Texture Profile @ Level 1',
1736
+ 0x72 => 'Basic Animated Texture Profile @ Level 2',
1737
+ 0x81 => 'Hybrid Profile @ Level 1',
1738
+ 0x82 => 'Hybrid Profile @ Level 2',
1739
+ 0x91 => 'Advanced Real Time Simple Profile @ Level 1',
1740
+ 0x92 => 'Advanced Real Time Simple Profile @ Level 2',
1741
+ 0x93 => 'Advanced Real Time Simple Profile @ Level 3',
1742
+ 0x94 => 'Advanced Real Time Simple Profile @ Level 4',
1743
+ 0xA1 => 'Core Scalable Profile @ Level1',
1744
+ 0xA2 => 'Core Scalable Profile @ Level2',
1745
+ 0xA3 => 'Core Scalable Profile @ Level3',
1746
+ 0xB1 => 'Advanced Coding Efficiency Profile @ Level 1',
1747
+ 0xB2 => 'Advanced Coding Efficiency Profile @ Level 2',
1748
+ 0xB3 => 'Advanced Coding Efficiency Profile @ Level 3',
1749
+ 0xB4 => 'Advanced Coding Efficiency Profile @ Level 4',
1750
+ 0xC1 => 'Advanced Core Profile @ Level 1',
1751
+ 0xC2 => 'Advanced Core Profile @ Level 2',
1752
+ 0xD1 => 'Advanced Scalable Texture @ Level1',
1753
+ 0xD2 => 'Advanced Scalable Texture @ Level2',
1754
+ 0xE1 => 'Simple Studio Profile @ Level 1',
1755
+ 0xE2 => 'Simple Studio Profile @ Level 2',
1756
+ 0xE3 => 'Simple Studio Profile @ Level 3',
1757
+ 0xE4 => 'Simple Studio Profile @ Level 4',
1758
+ 0xE5 => 'Core Studio Profile @ Level 1',
1759
+ 0xE6 => 'Core Studio Profile @ Level 2',
1760
+ 0xE7 => 'Core Studio Profile @ Level 3',
1761
+ 0xE8 => 'Core Studio Profile @ Level 4',
1762
+ 0xF0 => 'Advanced Simple Profile @ Level 0',
1763
+ 0xF1 => 'Advanced Simple Profile @ Level 1',
1764
+ 0xF2 => 'Advanced Simple Profile @ Level 2',
1765
+ 0xF3 => 'Advanced Simple Profile @ Level 3',
1766
+ 0xF4 => 'Advanced Simple Profile @ Level 4',
1767
+ 0xF5 => 'Advanced Simple Profile @ Level 5',
1768
+ 0xF7 => 'Advanced Simple Profile @ Level 3b',
1769
+ 0xF8 => 'Fine Granularity Scalable Profile @ Level 0',
1770
+ 0xF9 => 'Fine Granularity Scalable Profile @ Level 1',
1771
+ 0xFA => 'Fine Granularity Scalable Profile @ Level 2',
1772
+ 0xFB => 'Fine Granularity Scalable Profile @ Level 3',
1773
+ 0xFC => 'Fine Granularity Scalable Profile @ Level 4',
1774
+ 0xFD => 'Fine Granularity Scalable Profile @ Level 5',
1775
+ 0xFE => 'Not part of MPEG-4 Visual profiles',
1776
+ 0xFF => 'No visual capability required',
1777
+ );
1778
+ }
1779
+ return (isset($QuicktimeIODSvideoProfileNameLookup[$video_profile_id]) ? $QuicktimeIODSvideoProfileNameLookup[$video_profile_id] : 'ISO Reserved Profile');
1780
+ }
1781
+
1782
+
1783
+ public function QuicktimeContentRatingLookup($rtng) {
1784
+ static $QuicktimeContentRatingLookup = array();
1785
+ if (empty($QuicktimeContentRatingLookup)) {
1786
+ $QuicktimeContentRatingLookup[0] = 'None';
1787
+ $QuicktimeContentRatingLookup[2] = 'Clean';
1788
+ $QuicktimeContentRatingLookup[4] = 'Explicit';
1789
+ }
1790
+ return (isset($QuicktimeContentRatingLookup[$rtng]) ? $QuicktimeContentRatingLookup[$rtng] : 'invalid');
1791
+ }
1792
+
1793
+ public function QuicktimeStoreAccountTypeLookup($akid) {
1794
+ static $QuicktimeStoreAccountTypeLookup = array();
1795
+ if (empty($QuicktimeStoreAccountTypeLookup)) {
1796
+ $QuicktimeStoreAccountTypeLookup[0] = 'iTunes';
1797
+ $QuicktimeStoreAccountTypeLookup[1] = 'AOL';
1798
+ }
1799
+ return (isset($QuicktimeStoreAccountTypeLookup[$akid]) ? $QuicktimeStoreAccountTypeLookup[$akid] : 'invalid');
1800
+ }
1801
+
1802
+ public function QuicktimeStoreFrontCodeLookup($sfid) {
1803
+ static $QuicktimeStoreFrontCodeLookup = array();
1804
+ if (empty($QuicktimeStoreFrontCodeLookup)) {
1805
+ $QuicktimeStoreFrontCodeLookup[143460] = 'Australia';
1806
+ $QuicktimeStoreFrontCodeLookup[143445] = 'Austria';
1807
+ $QuicktimeStoreFrontCodeLookup[143446] = 'Belgium';
1808
+ $QuicktimeStoreFrontCodeLookup[143455] = 'Canada';
1809
+ $QuicktimeStoreFrontCodeLookup[143458] = 'Denmark';
1810
+ $QuicktimeStoreFrontCodeLookup[143447] = 'Finland';
1811
+ $QuicktimeStoreFrontCodeLookup[143442] = 'France';
1812
+ $QuicktimeStoreFrontCodeLookup[143443] = 'Germany';
1813
+ $QuicktimeStoreFrontCodeLookup[143448] = 'Greece';
1814
+ $QuicktimeStoreFrontCodeLookup[143449] = 'Ireland';
1815
+ $QuicktimeStoreFrontCodeLookup[143450] = 'Italy';
1816
+ $QuicktimeStoreFrontCodeLookup[143462] = 'Japan';
1817
+ $QuicktimeStoreFrontCodeLookup[143451] = 'Luxembourg';
1818
+ $QuicktimeStoreFrontCodeLookup[143452] = 'Netherlands';
1819
+ $QuicktimeStoreFrontCodeLookup[143461] = 'New Zealand';
1820
+ $QuicktimeStoreFrontCodeLookup[143457] = 'Norway';
1821
+ $QuicktimeStoreFrontCodeLookup[143453] = 'Portugal';
1822
+ $QuicktimeStoreFrontCodeLookup[143454] = 'Spain';
1823
+ $QuicktimeStoreFrontCodeLookup[143456] = 'Sweden';
1824
+ $QuicktimeStoreFrontCodeLookup[143459] = 'Switzerland';
1825
+ $QuicktimeStoreFrontCodeLookup[143444] = 'United Kingdom';
1826
+ $QuicktimeStoreFrontCodeLookup[143441] = 'United States';
1827
+ }
1828
+ return (isset($QuicktimeStoreFrontCodeLookup[$sfid]) ? $QuicktimeStoreFrontCodeLookup[$sfid] : 'invalid');
1829
+ }
1830
+
1831
+ public function QuicktimeParseNikonNCTG($atom_data) {
1832
+ // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#NCTG
1833
+ // Nikon-specific QuickTime tags found in the NCDT atom of MOV videos from some Nikon cameras such as the Coolpix S8000 and D5100
1834
+ // Data is stored as records of:
1835
+ // * 4 bytes record type
1836
+ // * 2 bytes size of data field type:
1837
+ // 0x0001 = flag (size field *= 1-byte)
1838
+ // 0x0002 = char (size field *= 1-byte)
1839
+ // 0x0003 = DWORD+ (size field *= 2-byte), values are stored CDAB
1840
+ // 0x0004 = QWORD+ (size field *= 4-byte), values are stored EFGHABCD
1841
+ // 0x0005 = float (size field *= 8-byte), values are stored aaaabbbb where value is aaaa/bbbb; possibly multiple sets of values appended together
1842
+ // 0x0007 = bytes (size field *= 1-byte), values are stored as ??????
1843
+ // 0x0008 = ????? (size field *= 2-byte), values are stored as ??????
1844
+ // * 2 bytes data size field
1845
+ // * ? bytes data (string data may be null-padded; datestamp fields are in the format "2011:05:25 20:24:15")
1846
+ // all integers are stored BigEndian
1847
+
1848
+ $NCTGtagName = array(
1849
+ 0x00000001 => 'Make',
1850
+ 0x00000002 => 'Model',
1851
+ 0x00000003 => 'Software',
1852
+ 0x00000011 => 'CreateDate',
1853
+ 0x00000012 => 'DateTimeOriginal',
1854
+ 0x00000013 => 'FrameCount',
1855
+ 0x00000016 => 'FrameRate',
1856
+ 0x00000022 => 'FrameWidth',
1857
+ 0x00000023 => 'FrameHeight',
1858
+ 0x00000032 => 'AudioChannels',
1859
+ 0x00000033 => 'AudioBitsPerSample',
1860
+ 0x00000034 => 'AudioSampleRate',
1861
+ 0x02000001 => 'MakerNoteVersion',
1862
+ 0x02000005 => 'WhiteBalance',
1863
+ 0x0200000b => 'WhiteBalanceFineTune',
1864
+ 0x0200001e => 'ColorSpace',
1865
+ 0x02000023 => 'PictureControlData',
1866
+ 0x02000024 => 'WorldTime',
1867
+ 0x02000032 => 'UnknownInfo',
1868
+ 0x02000083 => 'LensType',
1869
+ 0x02000084 => 'Lens',
1870
+ );
1871
+
1872
+ $offset = 0;
1873
+ $datalength = strlen($atom_data);
1874
+ $parsed = array();
1875
+ while ($offset < $datalength) {
1876
+ //echo getid3_lib::PrintHexBytes(substr($atom_data, $offset, 4)).'<br>';
1877
+ $record_type = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 4)); $offset += 4;
1878
+ $data_size_type = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 2)); $offset += 2;
1879
+ $data_size = getid3_lib::BigEndian2Int(substr($atom_data, $offset, 2)); $offset += 2;
1880
+ switch ($data_size_type) {
1881
+ case 0x0001: // 0x0001 = flag (size field *= 1-byte)
1882
+ $data = getid3_lib::BigEndian2Int(substr($atom_data, $offset, $data_size * 1));
1883
+ $offset += ($data_size * 1);
1884
+ break;
1885
+ case 0x0002: // 0x0002 = char (size field *= 1-byte)
1886
+ $data = substr($atom_data, $offset, $data_size * 1);
1887
+ $offset += ($data_size * 1);
1888
+ $data = rtrim($data, "\x00");
1889
+ break;
1890
+ case 0x0003: // 0x0003 = DWORD+ (size field *= 2-byte), values are stored CDAB
1891
+ $data = '';
1892
+ for ($i = $data_size - 1; $i >= 0; $i--) {
1893
+ $data .= substr($atom_data, $offset + ($i * 2), 2);
1894
+ }
1895
+ $data = getid3_lib::BigEndian2Int($data);
1896
+ $offset += ($data_size * 2);
1897
+ break;
1898
+ case 0x0004: // 0x0004 = QWORD+ (size field *= 4-byte), values are stored EFGHABCD
1899
+ $data = '';
1900
+ for ($i = $data_size - 1; $i >= 0; $i--) {
1901
+ $data .= substr($atom_data, $offset + ($i * 4), 4);
1902
+ }
1903
+ $data = getid3_lib::BigEndian2Int($data);
1904
+ $offset += ($data_size * 4);
1905
+ break;
1906
+ case 0x0005: // 0x0005 = float (size field *= 8-byte), values are stored aaaabbbb where value is aaaa/bbbb; possibly multiple sets of values appended together
1907
+ $data = array();
1908
+ for ($i = 0; $i < $data_size; $i++) {
1909
+ $numerator = getid3_lib::BigEndian2Int(substr($atom_data, $offset + ($i * 8) + 0, 4));
1910
+ $denomninator = getid3_lib::BigEndian2Int(substr($atom_data, $offset + ($i * 8) + 4, 4));
1911
+ if ($denomninator == 0) {
1912
+ $data[$i] = false;
1913
+ } else {
1914
+ $data[$i] = (double) $numerator / $denomninator;
1915
+ }
1916
+ }
1917
+ $offset += (8 * $data_size);
1918
+ if (count($data) == 1) {
1919
+ $data = $data[0];
1920
+ }
1921
+ break;
1922
+ case 0x0007: // 0x0007 = bytes (size field *= 1-byte), values are stored as ??????
1923
+ $data = substr($atom_data, $offset, $data_size * 1);
1924
+ $offset += ($data_size * 1);
1925
+ break;
1926
+ case 0x0008: // 0x0008 = ????? (size field *= 2-byte), values are stored as ??????
1927
+ $data = substr($atom_data, $offset, $data_size * 2);
1928
+ $offset += ($data_size * 2);
1929
+ break;
1930
+ default:
1931
+ echo 'QuicktimeParseNikonNCTG()::unknown $data_size_type: '.$data_size_type.'<br>';
1932
+ break 2;
1933
+ }
1934
+
1935
+ switch ($record_type) {
1936
+ case 0x00000011: // CreateDate
1937
+ case 0x00000012: // DateTimeOriginal
1938
+ $data = strtotime($data);
1939
+ break;
1940
+ case 0x0200001e: // ColorSpace
1941
+ switch ($data) {
1942
+ case 1:
1943
+ $data = 'sRGB';
1944
+ break;
1945
+ case 2:
1946
+ $data = 'Adobe RGB';
1947
+ break;
1948
+ }
1949
+ break;
1950
+ case 0x02000023: // PictureControlData
1951
+ $PictureControlAdjust = array(0=>'default', 1=>'quick', 2=>'full');
1952
+ $FilterEffect = array(0x80=>'off', 0x81=>'yellow', 0x82=>'orange', 0x83=>'red', 0x84=>'green', 0xff=>'n/a');
1953
+ $ToningEffect = array(0x80=>'b&w', 0x81=>'sepia', 0x82=>'cyanotype', 0x83=>'red', 0x84=>'yellow', 0x85=>'green', 0x86=>'blue-green', 0x87=>'blue', 0x88=>'purple-blue', 0x89=>'red-purple', 0xff=>'n/a');
1954
+ $data = array(
1955
+ 'PictureControlVersion' => substr($data, 0, 4),
1956
+ 'PictureControlName' => rtrim(substr($data, 4, 20), "\x00"),
1957
+ 'PictureControlBase' => rtrim(substr($data, 24, 20), "\x00"),
1958
+ //'?' => substr($data, 44, 4),
1959
+ 'PictureControlAdjust' => $PictureControlAdjust[ord(substr($data, 48, 1))],
1960
+ 'PictureControlQuickAdjust' => ord(substr($data, 49, 1)),
1961
+ 'Sharpness' => ord(substr($data, 50, 1)),
1962
+ 'Contrast' => ord(substr($data, 51, 1)),
1963
+ 'Brightness' => ord(substr($data, 52, 1)),
1964
+ 'Saturation' => ord(substr($data, 53, 1)),
1965
+ 'HueAdjustment' => ord(substr($data, 54, 1)),
1966
+ 'FilterEffect' => $FilterEffect[ord(substr($data, 55, 1))],
1967
+ 'ToningEffect' => $ToningEffect[ord(substr($data, 56, 1))],
1968
+ 'ToningSaturation' => ord(substr($data, 57, 1)),
1969
+ );
1970
+ break;
1971
+ case 0x02000024: // WorldTime
1972
+ // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Nikon.html#WorldTime
1973
+ // timezone is stored as offset from GMT in minutes
1974
+ $timezone = getid3_lib::BigEndian2Int(substr($data, 0, 2));
1975
+ if ($timezone & 0x8000) {
1976
+ $timezone = 0 - (0x10000 - $timezone);
1977
+ }
1978
+ $timezone /= 60;
1979
+
1980
+ $dst = (bool) getid3_lib::BigEndian2Int(substr($data, 2, 1));
1981
+ switch (getid3_lib::BigEndian2Int(substr($data, 3, 1))) {
1982
+ case 2:
1983
+ $datedisplayformat = 'D/M/Y'; break;
1984
+ case 1:
1985
+ $datedisplayformat = 'M/D/Y'; break;
1986
+ case 0:
1987
+ default:
1988
+ $datedisplayformat = 'Y/M/D'; break;
1989
+ }
1990
+
1991
+ $data = array('timezone'=>floatval($timezone), 'dst'=>$dst, 'display'=>$datedisplayformat);
1992
+ break;
1993
+ case 0x02000083: // LensType
1994
+ $data = array(
1995
+ //'_' => $data,
1996
+ 'mf' => (bool) ($data & 0x01),
1997
+ 'd' => (bool) ($data & 0x02),
1998
+ 'g' => (bool) ($data & 0x04),
1999
+ 'vr' => (bool) ($data & 0x08),
2000
+ );
2001
+ break;
2002
+ }
2003
+ $tag_name = (isset($NCTGtagName[$record_type]) ? $NCTGtagName[$record_type] : '0x'.str_pad(dechex($record_type), 8, '0', STR_PAD_LEFT));
2004
+ $parsed[$tag_name] = $data;
2005
+ }
2006
+ return $parsed;
2007
+ }
2008
+
2009
+
2010
+ public function CopyToAppropriateCommentsSection($keyname, $data, $boxname='') {
2011
+ static $handyatomtranslatorarray = array();
2012
+ if (empty($handyatomtranslatorarray)) {
2013
+ $handyatomtranslatorarray['�cpy'] = 'copyright';
2014
+ $handyatomtranslatorarray['�day'] = 'creation_date'; // iTunes 4.0
2015
+ $handyatomtranslatorarray['�dir'] = 'director';
2016
+ $handyatomtranslatorarray['�ed1'] = 'edit1';
2017
+ $handyatomtranslatorarray['�ed2'] = 'edit2';
2018
+ $handyatomtranslatorarray['�ed3'] = 'edit3';
2019
+ $handyatomtranslatorarray['�ed4'] = 'edit4';
2020
+ $handyatomtranslatorarray['�ed5'] = 'edit5';
2021
+ $handyatomtranslatorarray['�ed6'] = 'edit6';
2022
+ $handyatomtranslatorarray['�ed7'] = 'edit7';
2023
+ $handyatomtranslatorarray['�ed8'] = 'edit8';
2024
+ $handyatomtranslatorarray['�ed9'] = 'edit9';
2025
+ $handyatomtranslatorarray['�fmt'] = 'format';
2026
+ $handyatomtranslatorarray['�inf'] = 'information';
2027
+ $handyatomtranslatorarray['�prd'] = 'producer';
2028
+ $handyatomtranslatorarray['�prf'] = 'performers';
2029
+ $handyatomtranslatorarray['�req'] = 'system_requirements';
2030
+ $handyatomtranslatorarray['�src'] = 'source_credit';
2031
+ $handyatomtranslatorarray['�wrt'] = 'writer';
2032
+
2033
+ // http://www.geocities.com/xhelmboyx/quicktime/formats/qtm-layout.txt
2034
+ $handyatomtranslatorarray['�nam'] = 'title'; // iTunes 4.0
2035
+ $handyatomtranslatorarray['�cmt'] = 'comment'; // iTunes 4.0
2036
+ $handyatomtranslatorarray['�wrn'] = 'warning';
2037
+ $handyatomtranslatorarray['�hst'] = 'host_computer';
2038
+ $handyatomtranslatorarray['�mak'] = 'make';
2039
+ $handyatomtranslatorarray['�mod'] = 'model';
2040
+ $handyatomtranslatorarray['�PRD'] = 'product';
2041
+ $handyatomtranslatorarray['�swr'] = 'software';
2042
+ $handyatomtranslatorarray['�aut'] = 'author';
2043
+ $handyatomtranslatorarray['�ART'] = 'artist';
2044
+ $handyatomtranslatorarray['�trk'] = 'track';
2045
+ $handyatomtranslatorarray['�alb'] = 'album'; // iTunes 4.0
2046
+ $handyatomtranslatorarray['�com'] = 'comment';
2047
+ $handyatomtranslatorarray['�gen'] = 'genre'; // iTunes 4.0
2048
+ $handyatomtranslatorarray['�ope'] = 'composer';
2049
+ $handyatomtranslatorarray['�url'] = 'url';
2050
+ $handyatomtranslatorarray['�enc'] = 'encoder';
2051
+
2052
+ // http://atomicparsley.sourceforge.net/mpeg-4files.html
2053
+ $handyatomtranslatorarray['�art'] = 'artist'; // iTunes 4.0
2054
+ $handyatomtranslatorarray['aART'] = 'album_artist';
2055
+ $handyatomtranslatorarray['trkn'] = 'track_number'; // iTunes 4.0
2056
+ $handyatomtranslatorarray['disk'] = 'disc_number'; // iTunes 4.0
2057
+ $handyatomtranslatorarray['gnre'] = 'genre'; // iTunes 4.0
2058
+ $handyatomtranslatorarray['�too'] = 'encoder'; // iTunes 4.0
2059
+ $handyatomtranslatorarray['tmpo'] = 'bpm'; // iTunes 4.0
2060
+ $handyatomtranslatorarray['cprt'] = 'copyright'; // iTunes 4.0?
2061
+ $handyatomtranslatorarray['cpil'] = 'compilation'; // iTunes 4.0
2062
+ $handyatomtranslatorarray['covr'] = 'picture'; // iTunes 4.0
2063
+ $handyatomtranslatorarray['rtng'] = 'rating'; // iTunes 4.0
2064
+ $handyatomtranslatorarray['�grp'] = 'grouping'; // iTunes 4.2
2065
+ $handyatomtranslatorarray['stik'] = 'stik'; // iTunes 4.9
2066
+ $handyatomtranslatorarray['pcst'] = 'podcast'; // iTunes 4.9
2067
+ $handyatomtranslatorarray['catg'] = 'category'; // iTunes 4.9
2068
+ $handyatomtranslatorarray['keyw'] = 'keyword'; // iTunes 4.9
2069
+ $handyatomtranslatorarray['purl'] = 'podcast_url'; // iTunes 4.9
2070
+ $handyatomtranslatorarray['egid'] = 'episode_guid'; // iTunes 4.9
2071
+ $handyatomtranslatorarray['desc'] = 'description'; // iTunes 5.0
2072
+ $handyatomtranslatorarray['�lyr'] = 'lyrics'; // iTunes 5.0
2073
+ $handyatomtranslatorarray['tvnn'] = 'tv_network_name'; // iTunes 6.0
2074
+ $handyatomtranslatorarray['tvsh'] = 'tv_show_name'; // iTunes 6.0
2075
+ $handyatomtranslatorarray['tvsn'] = 'tv_season'; // iTunes 6.0
2076
+ $handyatomtranslatorarray['tves'] = 'tv_episode'; // iTunes 6.0
2077
+ $handyatomtranslatorarray['purd'] = 'purchase_date'; // iTunes 6.0.2
2078
+ $handyatomtranslatorarray['pgap'] = 'gapless_playback'; // iTunes 7.0
2079
+
2080
+ // http://www.geocities.com/xhelmboyx/quicktime/formats/mp4-layout.txt
2081
+
2082
+
2083
+
2084
+ // boxnames:
2085
+ /*
2086
+ $handyatomtranslatorarray['iTunSMPB'] = 'iTunSMPB';
2087
+ $handyatomtranslatorarray['iTunNORM'] = 'iTunNORM';
2088
+ $handyatomtranslatorarray['Encoding Params'] = 'Encoding Params';
2089
+ $handyatomtranslatorarray['replaygain_track_gain'] = 'replaygain_track_gain';
2090
+ $handyatomtranslatorarray['replaygain_track_peak'] = 'replaygain_track_peak';
2091
+ $handyatomtranslatorarray['replaygain_track_minmax'] = 'replaygain_track_minmax';
2092
+ $handyatomtranslatorarray['MusicIP PUID'] = 'MusicIP PUID';
2093
+ $handyatomtranslatorarray['MusicBrainz Artist Id'] = 'MusicBrainz Artist Id';
2094
+ $handyatomtranslatorarray['MusicBrainz Album Id'] = 'MusicBrainz Album Id';
2095
+ $handyatomtranslatorarray['MusicBrainz Album Artist Id'] = 'MusicBrainz Album Artist Id';
2096
+ $handyatomtranslatorarray['MusicBrainz Track Id'] = 'MusicBrainz Track Id';
2097
+ $handyatomtranslatorarray['MusicBrainz Disc Id'] = 'MusicBrainz Disc Id';
2098
+
2099
+ // http://age.hobba.nl/audio/tag_frame_reference.html
2100
+ $handyatomtranslatorarray['PLAY_COUNTER'] = 'play_counter'; // Foobar2000 - http://www.getid3.org/phpBB3/viewtopic.php?t=1355
2101
+ $handyatomtranslatorarray['MEDIATYPE'] = 'mediatype'; // Foobar2000 - http://www.getid3.org/phpBB3/viewtopic.php?t=1355
2102
+ */
2103
+ }
2104
+ $info = &$this->getid3->info;
2105
+ $comment_key = '';
2106
+ if ($boxname && ($boxname != $keyname)) {
2107
+ $comment_key = (isset($handyatomtranslatorarray[$boxname]) ? $handyatomtranslatorarray[$boxname] : $boxname);
2108
+ } elseif (isset($handyatomtranslatorarray[$keyname])) {
2109
+ $comment_key = $handyatomtranslatorarray[$keyname];
2110
+ }
2111
+ if ($comment_key) {
2112
+ if ($comment_key == 'picture') {
2113
+ if (!is_array($data)) {
2114
+ $image_mime = '';
2115
+ if (preg_match('#^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A#', $data)) {
2116
+ $image_mime = 'image/png';
2117
+ } elseif (preg_match('#^\xFF\xD8\xFF#', $data)) {
2118
+ $image_mime = 'image/jpeg';
2119
+ } elseif (preg_match('#^GIF#', $data)) {
2120
+ $image_mime = 'image/gif';
2121
+ } elseif (preg_match('#^BM#', $data)) {
2122
+ $image_mime = 'image/bmp';
2123
+ }
2124
+ $data = array('data'=>$data, 'image_mime'=>$image_mime);
2125
+ }
2126
+ }
2127
+ $info['quicktime']['comments'][$comment_key][] = $data;
2128
+ }
2129
+ return true;
2130
+ }
2131
+
2132
+ public function NoNullString($nullterminatedstring) {
2133
+ // remove the single null terminator on null terminated strings
2134
+ if (substr($nullterminatedstring, strlen($nullterminatedstring) - 1, 1) === "\x00") {
2135
+ return substr($nullterminatedstring, 0, strlen($nullterminatedstring) - 1);
2136
+ }
2137
+ return $nullterminatedstring;
2138
+ }
2139
+
2140
+ public function Pascal2String($pascalstring) {
2141
+ // Pascal strings have 1 unsigned byte at the beginning saying how many chars (1-255) are in the string
2142
+ return substr($pascalstring, 1);
2143
+ }
2144
+
2145
+ }
{view → includes}/getid3/module.audio-video.real.php RENAMED
@@ -1,528 +1,527 @@
1
- <?php
2
- /////////////////////////////////////////////////////////////////
3
- /// getID3() by James Heinrich <info@getid3.org> //
4
- // available at http://getid3.sourceforge.net //
5
- // or http://www.getid3.org //
6
- /////////////////////////////////////////////////////////////////
7
- // See readme.txt for more details //
8
- /////////////////////////////////////////////////////////////////
9
- // //
10
- // module.audio-video.real.php //
11
- // module for analyzing Real Audio/Video files //
12
- // dependencies: module.audio-video.riff.php //
13
- // ///
14
- /////////////////////////////////////////////////////////////////
15
-
16
- getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);
17
-
18
- class getid3_real
19
- {
20
-
21
- function getid3_real(&$fd, &$ThisFileInfo) {
22
- $ThisFileInfo['fileformat'] = 'real';
23
- $ThisFileInfo['bitrate'] = 0;
24
- $ThisFileInfo['playtime_seconds'] = 0;
25
-
26
- fseek($fd, $ThisFileInfo['avdataoffset'], SEEK_SET);
27
- $ChunkCounter = 0;
28
- while (ftell($fd) < $ThisFileInfo['avdataend']) {
29
- $ChunkData = fread($fd, 8);
30
- $ChunkName = substr($ChunkData, 0, 4);
31
- $ChunkSize = getid3_lib::BigEndian2Int(substr($ChunkData, 4, 4));
32
-
33
- if ($ChunkName == '.ra'."\xFD") {
34
- $ChunkData .= fread($fd, $ChunkSize - 8);
35
- if ($this->ParseOldRAheader(substr($ChunkData, 0, 128), $ThisFileInfo['real']['old_ra_header'])) {
36
- $ThisFileInfo['audio']['dataformat'] = 'real';
37
- $ThisFileInfo['audio']['lossless'] = false;
38
- $ThisFileInfo['audio']['sample_rate'] = $ThisFileInfo['real']['old_ra_header']['sample_rate'];
39
- $ThisFileInfo['audio']['bits_per_sample'] = $ThisFileInfo['real']['old_ra_header']['bits_per_sample'];
40
- $ThisFileInfo['audio']['channels'] = $ThisFileInfo['real']['old_ra_header']['channels'];
41
-
42
- $ThisFileInfo['playtime_seconds'] = 60 * ($ThisFileInfo['real']['old_ra_header']['audio_bytes'] / $ThisFileInfo['real']['old_ra_header']['bytes_per_minute']);
43
- $ThisFileInfo['audio']['bitrate'] = 8 * ($ThisFileInfo['real']['old_ra_header']['audio_bytes'] / $ThisFileInfo['playtime_seconds']);
44
- $ThisFileInfo['audio']['codec'] = $this->RealAudioCodecFourCClookup($ThisFileInfo['real']['old_ra_header']['fourcc'], $ThisFileInfo['audio']['bitrate']);
45
-
46
- foreach ($ThisFileInfo['real']['old_ra_header']['comments'] as $key => $valuearray) {
47
- if (strlen(trim($valuearray[0])) > 0) {
48
- $ThisFileInfo['real']['comments'][$key][] = trim($valuearray[0]);
49
- }
50
- }
51
- return true;
52
- }
53
- $ThisFileInfo['error'][] = 'There was a problem parsing this RealAudio file. Please submit it for analysis to http://www.getid3.org/upload/ or info@getid3.org';
54
- unset($ThisFileInfo['bitrate']);
55
- unset($ThisFileInfo['playtime_seconds']);
56
- return false;
57
- }
58
-
59
- // shortcut
60
- $ThisFileInfo['real']['chunks'][$ChunkCounter] = array();
61
- $thisfile_real_chunks_currentchunk = &$ThisFileInfo['real']['chunks'][$ChunkCounter];
62
-
63
- $thisfile_real_chunks_currentchunk['name'] = $ChunkName;
64
- $thisfile_real_chunks_currentchunk['offset'] = ftell($fd) - 8;
65
- $thisfile_real_chunks_currentchunk['length'] = $ChunkSize;
66
- if (($thisfile_real_chunks_currentchunk['offset'] + $thisfile_real_chunks_currentchunk['length']) > $ThisFileInfo['avdataend']) {
67
- $ThisFileInfo['warning'][] = 'Chunk "'.$thisfile_real_chunks_currentchunk['name'].'" at offset '.$thisfile_real_chunks_currentchunk['offset'].' claims to be '.$thisfile_real_chunks_currentchunk['length'].' bytes long, which is beyond end of file';
68
- return false;
69
- }
70
-
71
- if ($ChunkSize > (GETID3_FREAD_BUFFER_SIZE + 8)) {
72
-
73
- $ChunkData .= fread($fd, GETID3_FREAD_BUFFER_SIZE - 8);
74
- fseek($fd, $thisfile_real_chunks_currentchunk['offset'] + $ChunkSize, SEEK_SET);
75
-
76
- } elseif(($ChunkSize - 8) > 0) {
77
-
78
- $ChunkData .= fread($fd, $ChunkSize - 8);
79
-
80
- }
81
- $offset = 8;
82
-
83
- switch ($ChunkName) {
84
-
85
- case '.RMF': // RealMedia File Header
86
- $thisfile_real_chunks_currentchunk['object_version'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 2));
87
- $offset += 2;
88
- switch ($thisfile_real_chunks_currentchunk['object_version']) {
89
-
90
- case 0:
91
- $thisfile_real_chunks_currentchunk['file_version'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 4));
92
- $offset += 4;
93
- $thisfile_real_chunks_currentchunk['headers_count'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 4));
94
- $offset += 4;
95
- break;
96
-
97
- default:
98
- //$ThisFileInfo['warning'][] = 'Expected .RMF-object_version to be "0", actual value is "'.$thisfile_real_chunks_currentchunk['object_version'].'" (should not be a problem)';
99
- break;
100
-
101
- }
102
- break;
103
-
104
-
105
- case 'PROP': // Properties Header
106
- $thisfile_real_chunks_currentchunk['object_version'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 2));
107
- $offset += 2;
108
- if ($thisfile_real_chunks_currentchunk['object_version'] == 0) {
109
- $thisfile_real_chunks_currentchunk['max_bit_rate'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 4));
110
- $offset += 4;
111
- $thisfile_real_chunks_currentchunk['avg_bit_rate'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 4));
112
- $offset += 4;
113
- $thisfile_real_chunks_currentchunk['max_packet_size'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 4));
114
- $offset += 4;
115
- $thisfile_real_chunks_currentchunk['avg_packet_size'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 4));
116
- $offset += 4;
117
- $thisfile_real_chunks_currentchunk['num_packets'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 4));
118
- $offset += 4;
119
- $thisfile_real_chunks_currentchunk['duration'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 4));
120
- $offset += 4;
121
- $thisfile_real_chunks_currentchunk['preroll'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 4));
122
- $offset += 4;
123
- $thisfile_real_chunks_currentchunk['index_offset'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 4));
124
- $offset += 4;
125
- $thisfile_real_chunks_currentchunk['data_offset'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 4));
126
- $offset += 4;
127
- $thisfile_real_chunks_currentchunk['num_streams'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 2));
128
- $offset += 2;
129
- $thisfile_real_chunks_currentchunk['flags_raw'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 2));
130
- $offset += 2;
131
- $ThisFileInfo['playtime_seconds'] = $thisfile_real_chunks_currentchunk['duration'] / 1000;
132
- if ($thisfile_real_chunks_currentchunk['duration'] > 0) {
133
- $ThisFileInfo['bitrate'] += $thisfile_real_chunks_currentchunk['avg_bit_rate'];
134
- }
135
- $thisfile_real_chunks_currentchunk['flags']['save_enabled'] = (bool) ($thisfile_real_chunks_currentchunk['flags_raw'] & 0x0001);
136
- $thisfile_real_chunks_currentchunk['flags']['perfect_play'] = (bool) ($thisfile_real_chunks_currentchunk['flags_raw'] & 0x0002);
137
- $thisfile_real_chunks_currentchunk['flags']['live_broadcast'] = (bool) ($thisfile_real_chunks_currentchunk['flags_raw'] & 0x0004);
138
- }
139
- break;
140
-
141
- case 'MDPR': // Media Properties Header
142
- $thisfile_real_chunks_currentchunk['object_version'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 2));
143
- $offset += 2;
144
- if ($thisfile_real_chunks_currentchunk['object_version'] == 0) {
145
- $thisfile_real_chunks_currentchunk['stream_number'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 2));
146
- $offset += 2;
147
- $thisfile_real_chunks_currentchunk['max_bit_rate'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 4));
148
- $offset += 4;
149
- $thisfile_real_chunks_currentchunk['avg_bit_rate'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 4));
150
- $offset += 4;
151
- $thisfile_real_chunks_currentchunk['max_packet_size'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 4));
152
- $offset += 4;
153
- $thisfile_real_chunks_currentchunk['avg_packet_size'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 4));
154
- $offset += 4;
155
- $thisfile_real_chunks_currentchunk['start_time'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 4));
156
- $offset += 4;
157
- $thisfile_real_chunks_currentchunk['preroll'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 4));
158
- $offset += 4;
159
- $thisfile_real_chunks_currentchunk['duration'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 4));
160
- $offset += 4;
161
- $thisfile_real_chunks_currentchunk['stream_name_size'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 1));
162
- $offset += 1;
163
- $thisfile_real_chunks_currentchunk['stream_name'] = substr($ChunkData, $offset, $thisfile_real_chunks_currentchunk['stream_name_size']);
164
- $offset += $thisfile_real_chunks_currentchunk['stream_name_size'];
165
- $thisfile_real_chunks_currentchunk['mime_type_size'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 1));
166
- $offset += 1;
167
- $thisfile_real_chunks_currentchunk['mime_type'] = substr($ChunkData, $offset, $thisfile_real_chunks_currentchunk['mime_type_size']);
168
- $offset += $thisfile_real_chunks_currentchunk['mime_type_size'];
169
- $thisfile_real_chunks_currentchunk['type_specific_len'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 4));
170
- $offset += 4;
171
- $thisfile_real_chunks_currentchunk['type_specific_data'] = substr($ChunkData, $offset, $thisfile_real_chunks_currentchunk['type_specific_len']);
172
- $offset += $thisfile_real_chunks_currentchunk['type_specific_len'];
173
-
174
- // shortcut
175
- $thisfile_real_chunks_currentchunk_typespecificdata = &$thisfile_real_chunks_currentchunk['type_specific_data'];
176
-
177
- switch ($thisfile_real_chunks_currentchunk['mime_type']) {
178
- case 'video/x-pn-realvideo':
179
- case 'video/x-pn-multirate-realvideo':
180
- // http://www.freelists.org/archives/matroska-devel/07-2003/msg00010.html
181
-
182
- // shortcut
183
- $thisfile_real_chunks_currentchunk['video_info'] = array();
184
- $thisfile_real_chunks_currentchunk_videoinfo = &$thisfile_real_chunks_currentchunk['video_info'];
185
-
186
- $thisfile_real_chunks_currentchunk_videoinfo['dwSize'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 0, 4));
187
- $thisfile_real_chunks_currentchunk_videoinfo['fourcc1'] = substr($thisfile_real_chunks_currentchunk_typespecificdata, 4, 4);
188
- $thisfile_real_chunks_currentchunk_videoinfo['fourcc2'] = substr($thisfile_real_chunks_currentchunk_typespecificdata, 8, 4);
189
- $thisfile_real_chunks_currentchunk_videoinfo['width'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 12, 2));
190
- $thisfile_real_chunks_currentchunk_videoinfo['height'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 14, 2));
191
- $thisfile_real_chunks_currentchunk_videoinfo['bits_per_sample'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 16, 2));
192
- //$thisfile_real_chunks_currentchunk_videoinfo['unknown1'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 18, 2));
193
- //$thisfile_real_chunks_currentchunk_videoinfo['unknown2'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 20, 2));
194
- $thisfile_real_chunks_currentchunk_videoinfo['frames_per_second'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 22, 2));
195
- //$thisfile_real_chunks_currentchunk_videoinfo['unknown3'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 24, 2));
196
- //$thisfile_real_chunks_currentchunk_videoinfo['unknown4'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 26, 2));
197
- //$thisfile_real_chunks_currentchunk_videoinfo['unknown5'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 28, 2));
198
- //$thisfile_real_chunks_currentchunk_videoinfo['unknown6'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 30, 2));
199
- //$thisfile_real_chunks_currentchunk_videoinfo['unknown7'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 32, 2));
200
- //$thisfile_real_chunks_currentchunk_videoinfo['unknown8'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 34, 2));
201
- //$thisfile_real_chunks_currentchunk_videoinfo['unknown9'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 36, 2));
202
-
203
- $thisfile_real_chunks_currentchunk_videoinfo['codec'] = getid3_riff::RIFFfourccLookup($thisfile_real_chunks_currentchunk_videoinfo['fourcc2']);
204
-
205
- $ThisFileInfo['video']['resolution_x'] = $thisfile_real_chunks_currentchunk_videoinfo['width'];
206
- $ThisFileInfo['video']['resolution_y'] = $thisfile_real_chunks_currentchunk_videoinfo['height'];
207
- $ThisFileInfo['video']['frame_rate'] = (float) $thisfile_real_chunks_currentchunk_videoinfo['frames_per_second'];
208
- $ThisFileInfo['video']['codec'] = $thisfile_real_chunks_currentchunk_videoinfo['codec'];
209
- $ThisFileInfo['video']['bits_per_sample'] = $thisfile_real_chunks_currentchunk_videoinfo['bits_per_sample'];
210
- break;
211
-
212
- case 'audio/x-pn-realaudio':
213
- case 'audio/x-pn-multirate-realaudio':
214
- $this->ParseOldRAheader($thisfile_real_chunks_currentchunk_typespecificdata, $thisfile_real_chunks_currentchunk['parsed_audio_data']);
215
-
216
- $ThisFileInfo['audio']['sample_rate'] = $thisfile_real_chunks_currentchunk['parsed_audio_data']['sample_rate'];
217
- $ThisFileInfo['audio']['bits_per_sample'] = $thisfile_real_chunks_currentchunk['parsed_audio_data']['bits_per_sample'];
218
- $ThisFileInfo['audio']['channels'] = $thisfile_real_chunks_currentchunk['parsed_audio_data']['channels'];
219
- if (!empty($ThisFileInfo['audio']['dataformat'])) {
220
- foreach ($ThisFileInfo['audio'] as $key => $value) {
221
- if ($key != 'streams') {
222
- $ThisFileInfo['audio']['streams'][$thisfile_real_chunks_currentchunk['stream_number']][$key] = $value;
223
- }
224
- }
225
- }
226
- break;
227
-
228
- case 'logical-fileinfo':
229
- // shortcut
230
- $thisfile_real_chunks_currentchunk['logical_fileinfo'] = array();
231
- $thisfile_real_chunks_currentchunk_logicalfileinfo = &$thisfile_real_chunks_currentchunk['logical_fileinfo'];
232
-
233
- $thisfile_real_chunks_currentchunk_logicalfileinfo_offset = 0;
234
- $thisfile_real_chunks_currentchunk_logicalfileinfo['logical_fileinfo_length'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, $thisfile_real_chunks_currentchunk_logicalfileinfo_offset, 4));
235
- $thisfile_real_chunks_currentchunk_logicalfileinfo_offset += 4;
236
-
237
- //$thisfile_real_chunks_currentchunk_logicalfileinfo['unknown1'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, $thisfile_real_chunks_currentchunk_logicalfileinfo_offset, 4));
238
- $thisfile_real_chunks_currentchunk_logicalfileinfo_offset += 4;
239
-
240
- $thisfile_real_chunks_currentchunk_logicalfileinfo['num_tags'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, $thisfile_real_chunks_currentchunk_logicalfileinfo_offset, 4));
241
- $thisfile_real_chunks_currentchunk_logicalfileinfo_offset += 4;
242
-
243
- //$thisfile_real_chunks_currentchunk_logicalfileinfo['unknown2'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, $thisfile_real_chunks_currentchunk_logicalfileinfo_offset, 4));
244
- $thisfile_real_chunks_currentchunk_logicalfileinfo_offset += 4;
245
-
246
- //$thisfile_real_chunks_currentchunk_logicalfileinfo['d'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, $thisfile_real_chunks_currentchunk_logicalfileinfo_offset, 1));
247
-
248
- //$thisfile_real_chunks_currentchunk_logicalfileinfo['one_type'] = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, $thisfile_real_chunks_currentchunk_logicalfileinfo_offset, 4));
249
- //$thisfile_real_chunks_currentchunk_logicalfileinfo_thislength = getid3_lib::BigEndian2Int(substr($thisfile_real_chunks_currentchunk_typespecificdata, 4 + $thisfile_real_chunks_currentchunk_logicalfileinfo_offset, 2));
250
- //$thisfile_real_chunks_currentchunk_logicalfileinfo['one'] = substr($thisfile_real_chunks_currentchunk_typespecificdata, 6 + $thisfile_real_chunks_currentchunk_logicalfileinfo_offset, $thisfile_real_chunks_currentchunk_logicalfileinfo_thislength);
251
- //$thisfile_real_chunks_currentchunk_logicalfileinfo_offset += (6 + $thisfile_real_chunks_currentchunk_logicalfileinfo_thislength);
252
-
253
- break;
254
-
255
- }
256
-
257
-
258
- if (empty($ThisFileInfo['playtime_seconds'])) {
259
- $ThisFileInfo['playtime_seconds'] = max($ThisFileInfo['playtime_seconds'], ($thisfile_real_chunks_currentchunk['duration'] + $thisfile_real_chunks_currentchunk['start_time']) / 1000);
260
- }
261
- if ($thisfile_real_chunks_currentchunk['duration'] > 0) {
262
- switch ($thisfile_real_chunks_currentchunk['mime_type']) {
263
- case 'audio/x-pn-realaudio':
264
- case 'audio/x-pn-multirate-realaudio':
265
- $ThisFileInfo['audio']['bitrate'] = (isset($ThisFileInfo['audio']['bitrate']) ? $ThisFileInfo['audio']['bitrate'] : 0) + $thisfile_real_chunks_currentchunk['avg_bit_rate'];
266
- $ThisFileInfo['audio']['codec'] = $this->RealAudioCodecFourCClookup($thisfile_real_chunks_currentchunk['parsed_audio_data']['fourcc'], $ThisFileInfo['audio']['bitrate']);
267
- $ThisFileInfo['audio']['dataformat'] = 'real';
268
- $ThisFileInfo['audio']['lossless'] = false;
269
- break;
270
-
271
- case 'video/x-pn-realvideo':
272
- case 'video/x-pn-multirate-realvideo':
273
- $ThisFileInfo['video']['bitrate'] = (isset($ThisFileInfo['video']['bitrate']) ? $ThisFileInfo['video']['bitrate'] : 0) + $thisfile_real_chunks_currentchunk['avg_bit_rate'];
274
- $ThisFileInfo['video']['bitrate_mode'] = 'cbr';
275
- $ThisFileInfo['video']['dataformat'] = 'real';
276
- $ThisFileInfo['video']['lossless'] = false;
277
- $ThisFileInfo['video']['pixel_aspect_ratio'] = (float) 1;
278
- break;
279
-
280
- case 'audio/x-ralf-mpeg4-generic':
281
- $ThisFileInfo['audio']['bitrate'] = (isset($ThisFileInfo['audio']['bitrate']) ? $ThisFileInfo['audio']['bitrate'] : 0) + $thisfile_real_chunks_currentchunk['avg_bit_rate'];
282
- $ThisFileInfo['audio']['codec'] = 'RealAudio Lossless';
283
- $ThisFileInfo['audio']['dataformat'] = 'real';
284
- $ThisFileInfo['audio']['lossless'] = true;
285
- break;
286
- }
287
- $ThisFileInfo['bitrate'] = (isset($ThisFileInfo['video']['bitrate']) ? $ThisFileInfo['video']['bitrate'] : 0) + (isset($ThisFileInfo['audio']['bitrate']) ? $ThisFileInfo['audio']['bitrate'] : 0);
288
- }
289
- }
290
- break;
291
-
292
- case 'CONT': // Content Description Header (text comments)
293
- $thisfile_real_chunks_currentchunk['object_version'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 2));
294
- $offset += 2;
295
- if ($thisfile_real_chunks_currentchunk['object_version'] == 0) {
296
- $thisfile_real_chunks_currentchunk['title_len'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 2));
297
- $offset += 2;
298
- $thisfile_real_chunks_currentchunk['title'] = (string) substr($ChunkData, $offset, $thisfile_real_chunks_currentchunk['title_len']);
299
- $offset += $thisfile_real_chunks_currentchunk['title_len'];
300
-
301
- $thisfile_real_chunks_currentchunk['artist_len'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 2));
302
- $offset += 2;
303
- $thisfile_real_chunks_currentchunk['artist'] = (string) substr($ChunkData, $offset, $thisfile_real_chunks_currentchunk['artist_len']);
304
- $offset += $thisfile_real_chunks_currentchunk['artist_len'];
305
-
306
- $thisfile_real_chunks_currentchunk['copyright_len'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 2));
307
- $offset += 2;
308
- $thisfile_real_chunks_currentchunk['copyright'] = (string) substr($ChunkData, $offset, $thisfile_real_chunks_currentchunk['copyright_len']);
309
- $offset += $thisfile_real_chunks_currentchunk['copyright_len'];
310
-
311
- $thisfile_real_chunks_currentchunk['comment_len'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 2));
312
- $offset += 2;
313
- $thisfile_real_chunks_currentchunk['comment'] = (string) substr($ChunkData, $offset, $thisfile_real_chunks_currentchunk['comment_len']);
314
- $offset += $thisfile_real_chunks_currentchunk['comment_len'];
315
-
316
-
317
- $commentkeystocopy = array('title'=>'title', 'artist'=>'artist', 'copyright'=>'copyright', 'comment'=>'comment');
318
- foreach ($commentkeystocopy as $key => $val) {
319
- if ($thisfile_real_chunks_currentchunk[$key]) {
320
- $ThisFileInfo['real']['comments'][$val][] = trim($thisfile_real_chunks_currentchunk[$key]);
321
- }
322
- }
323
-
324
- }
325
- break;
326
-
327
-
328
- case 'DATA': // Data Chunk Header
329
- // do nothing
330
- break;
331
-
332
- case 'INDX': // Index Section Header
333
- $thisfile_real_chunks_currentchunk['object_version'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 2));
334
- $offset += 2;
335
- if ($thisfile_real_chunks_currentchunk['object_version'] == 0) {
336
- $thisfile_real_chunks_currentchunk['num_indices'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 4));
337
- $offset += 4;
338
- $thisfile_real_chunks_currentchunk['stream_number'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 2));
339
- $offset += 2;
340
- $thisfile_real_chunks_currentchunk['next_index_header'] = getid3_lib::BigEndian2Int(substr($ChunkData, $offset, 4));
341
- $offset += 4;
342
-
343
- if ($thisfile_real_chunks_currentchunk['next_index_header'] == 0) {
344
- // last index chunk found, ignore rest of file
345
- break 2;
346
- } else {
347
- // non-last index chunk, seek to next index chunk (skipping actual index data)
348
- fseek($fd, $thisfile_real_chunks_currentchunk['next_index_header'], SEEK_SET);
349
- }
350
- }
351
- break;
352
-
353
- default:
354
- $ThisFileInfo['warning'][] = 'Unhandled RealMedia chunk "'.$ChunkName.'" at offset '.$thisfile_real_chunks_currentchunk['offset'];
355
- break;
356
- }
357
- $ChunkCounter++;
358
- }
359
-
360
- if (!empty($ThisFileInfo['audio']['streams'])) {
361
- $ThisFileInfo['audio']['bitrate'] = 0;
362
- foreach ($ThisFileInfo['audio']['streams'] as $key => $valuearray) {
363
- $ThisFileInfo['audio']['bitrate'] += $valuearray['bitrate'];
364
- }
365
- }
366
-
367
- return true;
368
- }
369
-
370
-
371
- function ParseOldRAheader($OldRAheaderData, &$ParsedArray) {
372
- // http://www.freelists.org/archives/matroska-devel/07-2003/msg00010.html
373
-
374
- $ParsedArray = array();
375
- $ParsedArray['magic'] = substr($OldRAheaderData, 0, 4);
376
- if ($ParsedArray['magic'] != '.ra'."\xFD") {
377
- return false;
378
- }
379
- $ParsedArray['version1'] = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 4, 2));
380
-
381
- if ($ParsedArray['version1'] < 3) {
382
-
383
- return false;
384
-
385
- } elseif ($ParsedArray['version1'] == 3) {
386
-
387
- $ParsedArray['fourcc1'] = '.ra3';
388
- $ParsedArray['bits_per_sample'] = 16; // hard-coded for old versions?
389
- $ParsedArray['sample_rate'] = 8000; // hard-coded for old versions?
390
-
391
- $ParsedArray['header_size'] = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 6, 2));
392
- $ParsedArray['channels'] = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 8, 2)); // always 1 (?)
393
- //$ParsedArray['unknown1'] = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 10, 2));
394
- //$ParsedArray['unknown2'] = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 12, 2));
395
- //$ParsedArray['unknown3'] = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 14, 2));
396
- $ParsedArray['bytes_per_minute'] = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 16, 2));
397
- $ParsedArray['audio_bytes'] = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 18, 4));
398
- $ParsedArray['comments_raw'] = substr($OldRAheaderData, 22, $ParsedArray['header_size'] - 22 + 1); // not including null terminator
399
-
400
- $commentoffset = 0;
401
- $commentlength = getid3_lib::BigEndian2Int(substr($ParsedArray['comments_raw'], $commentoffset++, 1));
402
- $ParsedArray['comments']['title'][] = substr($ParsedArray['comments_raw'], $commentoffset, $commentlength);
403
- $commentoffset += $commentlength;
404
-
405
- $commentlength = getid3_lib::BigEndian2Int(substr($ParsedArray['comments_raw'], $commentoffset++, 1));
406
- $ParsedArray['comments']['artist'][] = substr($ParsedArray['comments_raw'], $commentoffset, $commentlength);
407
- $commentoffset += $commentlength;
408
-
409
- $commentlength = getid3_lib::BigEndian2Int(substr($ParsedArray['comments_raw'], $commentoffset++, 1));
410
- $ParsedArray['comments']['copyright'][] = substr($ParsedArray['comments_raw'], $commentoffset, $commentlength);
411
- $commentoffset += $commentlength;
412
-
413
- $commentoffset++; // final null terminator (?)
414
- $commentoffset++; // fourcc length (?) should be 4
415
- $ParsedArray['fourcc'] = substr($OldRAheaderData, 23 + $commentoffset, 4);
416
-
417
- } elseif ($ParsedArray['version1'] <= 5) {
418
-
419
- //$ParsedArray['unknown1'] = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 6, 2));
420
- $ParsedArray['fourcc1'] = substr($OldRAheaderData, 8, 4);
421
- $ParsedArray['file_size'] = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 12, 4));
422
- $ParsedArray['version2'] = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 16, 2));
423
- $ParsedArray['header_size'] = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 18, 4));
424
- $ParsedArray['codec_flavor_id'] = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 22, 2));
425
- $ParsedArray['coded_frame_size'] = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 24, 4));
426
- $ParsedArray['audio_bytes'] = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 28, 4));
427
- $ParsedArray['bytes_per_minute'] = getid3_lib::BigEndian2Int(substr($OldRAheaderData, 32, 4));
428
- //$ParsedArray['unknown5'] = getid3_lib::BigEndian2Int(subst