+++ /dev/null
-This version of cortado comes form http://theora.org/cortado.jar
+++ /dev/null
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- <program> Copyright (C) <year> <name of author>
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
\ No newline at end of file
+++ /dev/null
-Version history:
-
-RC2
----
-- fixed: setting the screen height in configuration did not have any effect
-
-RC1
------
-- better error message if plugin loading fails, shows the URL used
-- validates our redesigned multidomain license key correctly
-- fix to prevent the play button going visible when the onBufferEmpty event occurs
-- the commercial swf now correctly loads the controls using version information
-- fixed: the play button overlay became invisible with long fadeOutSpeeds
-
-beta6
------
-- removed the onFirstFramePause event
-- playing a clip for the second time caused a doubled sound
-- pausing on first frame did not work on some FLV files
-
-beta5
------
-- logo only uses percentage scaling if it's a SWF file (there is ".swf" in it's url)
-- context menu now correctly builds up from string entries in configuration
--always closes the previous connection before starting a new clip
-
-beta4
------
-- now it's possible to load a plugin into the panel without specifying any position/dimensions
- information, the plugin is placed to left: "50%", top: "50%" and using the plugin DisplayObject's width & height
-- The Flowplayer API was not fully initialized when onLoad was invoked on Flash plugins
-
-beta3
------
-- tweaking logo placement
-- "play" did not show up after repeated pause/resume
-- player now loads the latest controls SWF version, right now the latest SWF is called 'flowplayer.controls-3.0.0-beta2.swf'
-
-beta2
------
-- fixed support for RTMP stream groups
-- changed to loop through available fonts in order to find a suitable font also in IE
-- Preloader was broken on IE: When the player SWf was in browser's cache it did not initialize properly
-- Context menu now correctly handles menu items that are configured by their string labels only (not using json objects)
-- fixed custom logo positioning (was moved to the left edge of screen in fullscreen)
-- "play" now always follows the position and size of the screen
-- video was stretched below the controls in fullscreen when autoHide: 'never'
-- logo now takes 6.5% of the screen height, width is scaled so that the aspect ratio is preserved
-
-beta1
------
-- First public beta release
+++ /dev/null
-/**
- * flowplayer.js 3.0.0-rc2. The Flowplayer API.
- *
- * This file is part of Flowplayer, http://flowplayer.org
- *
- * Author: Tero Piirainen, <support@flowplayer.org>
- * Copyright (c) 2008 Flowplayer Ltd
- *
- * Released under the MIT License:
- * http://www.opensource.org/licenses/mit-license.php
- *
- * Version: 3.0.0-rc2 - Fri Nov 07 2008 16:50:59 GMT-0000 (GMT+00:00)
- */
-(function() {
-
-/*
- FEATURES
- --------
- - handling multiple instances
- - Flowplayer programming API
- - Flowplayer event model
- - player loading / unloading
- - $f() function
- - jQuery support
-*/
-
-
-/*jslint glovar: true, browser: true */
-/*global flowplayer, $f */
-
-// {{{ private utility methods
-
- function log(args) {
-
- // write into opera console
- if (typeof opera == 'object') {
- opera.postError("$f.fireEvent: " + args.join(" | "));
-
-
- } else if (typeof console == 'object') {
- console.log("$f.fireEvent", [].slice.call(args));
- }
- }
-
-
- // thanks: http://keithdevens.com/weblog/archive/2007/Jun/07/javascript.clone
- 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;
- }
-
- // stripped from jQuery, thanks John Resig
- function each(obj, fn) {
- if (!obj) { return; }
-
- var name, i = 0, length = obj.length;
-
- // object
- if (length === undefined) {
- for (name in obj) {
- if (fn.call(obj[name], name, obj[name]) === false) { break; }
- }
-
- // array
- } else {
- for (var value = obj[0];
- i < length && fn.call( value, i, value ) !== false; value = obj[++i]) {
- }
- }
-
- return obj;
- }
-
-
- // convenience
- function el(id) {
- return document.getElementById(id);
- }
-
-
- // used extensively. a very simple implementation.
- function extend(to, from, skipFuncs) {
- if (to && from) {
- each(from, function(name, value) {
- if (!skipFuncs || typeof value != 'function') {
- to[name] = value;
- }
- });
- }
- }
-
- // var arr = select("elem.className");
- 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;
- }
- }
-
- // fix event inconsistencies across browsers
- function stopEvent(e) {
- e = e || window.event;
-
- if (e.preventDefault) {
- e.stopPropagation();
- e.preventDefault();
-
- } else {
- e.returnValue = false;
- e.cancelBubble = true;
- }
- return false;
- }
-
- // push an event listener into existing array of listeners
- function bind(to, evt, fn) {
- to[evt] = to[evt] || [];
- to[evt].push(fn);
- }
-
-
- // generates an unique id
- function makeId() {
- return "_" + ("" + Math.random()).substring(2, 10);
- }
-
-//}}}
-
-
-// {{{ Clip
-
- var Clip = function(json, index, player) {
-
- // private variables
- var self = this;
- var cuepoints = {};
- var listeners = {};
- this.index = index;
-
- // instance variables
- if (typeof json == 'string') {
- json = {url:json};
- }
-
- extend(this, json, true);
-
- // event handling
- each(("Start*,MetaData,Pause*,Resume*,Seek*,Stop*,Finish,LastSecond,Update,BufferFull,BufferEmpty").split(","),
- function() {
-
- var evt = "on" + this;
-
- // before event
- 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;
- };
-
-
- // set common clip event listeners to player level
- if (index == -1) {
- if (self[before]) {
- player[before] = self[before];
- }
- if (self[evt]) {
- player[evt] = self[evt];
- }
- }
-
- });
-
- extend(this, {
-
-
- onCuepoint: function(points, fn) {
-
- // embedded cuepoints
- 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._config();
- var clip = (index == -1) ? conf.clip : conf.playlist[index];
- extend(clip, json, true);
- },
-
-
- // internal event for performing clip tasks. should be made private someday
- _fireEvent: function(evt, arg1, arg2, target) {
-
- if (evt == 'onLoad') {
- each(cuepoints, function(key, val) {
- player._api().fp_addCuepoints(val[0], index, key);
- });
- return false;
- }
-
- // target clip we are working against
- if (index != -1) {
- target = self;
- }
-
- if (evt == 'onCuepoint') {
- var fn = cuepoints[arg1];
- if (fn) {
- return fn[1].call(player, target, arg2);
- }
- }
-
- if (evt == 'onMetaData' || 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);
- });
- return ret;
- }
-
- });
-
-
- // get cuepoints from config
- if (json.onCuepoint) {
- self.onCuepoint.apply(self, json.onCuepoint);
- delete json.onCuepoint;
- }
-
- // get other events
- each(json, function(key, val) {
- if (typeof val == 'function') {
- bind(listeners, key, val);
- delete json[key];
- }
- });
-
-
- // setup common clip event callbacks for Player object too (shortcuts)
- if (index == -1) {
- player.onCuepoint = this.onCuepoint;
- }
-
- };
-
-//}}}
-
-
-// {{{ Plugin
-
- var Plugin = function(name, json, player, fn) {
-
- var listeners = {};
- var self = this;
- var hasMethods = false;
-
- if (fn) {
- extend(listeners, fn);
- }
-
- // custom callback functions in configuration
- each(json, function(key, val) {
- if (typeof val == 'function') {
- listeners[key] = val;
- delete json[key];
- }
- });
-
- // core plugin methods
- 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;
- },
-
-
- // internal method not meant to be used by clients
- _fireEvent: function(evt, arg) {
-
-
- // update plugins properties & methods
- if (evt == 'onUpdate') {
- var json = arg || 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;
- }
- }
-
- // plugin callbacks
- var fn = listeners[evt];
-
- if (fn) {
-
- fn.call(self, arg);
-
- // "one-shot" callback
- if (evt.substring(0, 1) == "_") {
- delete listeners[evt];
- }
- }
- }
-
- });
-
- };
-
-
-//}}}
-
-
-function Player(wrapper, params, conf) {
-
- // private variables (+ arguments)
- var
- self = this,
- api = null,
- html,
- commonClip,
- playlist = [],
- plugins = {},
- listeners = {},
- playerId,
- apiId,
- activeIndex,
- swfHeight;
-
-
-// {{{ public methods
-
- extend(self, {
-
- id: function() {
- return playerId;
- },
-
- isLoaded: function() {
- return (api !== null);
- },
-
- getParent: function() {
- return wrapper;
- },
-
- hide: function() {
- if (api) { api.style.height = "0px"; }
- return self;
- },
-
- show: function() {
- 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) {
-
- // unload all instances
- each(players, function() {
- this.unload();
- });
-
- html = wrapper.innerHTML;
- flashembed(wrapper, params, {config: conf});
-
- // function argument
- if (fn) {
- fn.cached = true;
- bind(listeners, "onLoad", fn);
- }
- }
-
- return self;
- },
-
- unload: function() {
-
- 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];
-
- // create plugin if nessessary
- 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() {
- return clone(conf);
- },
-
- getFlashParams: function() {
- return params;
- },
-
- loadPlugin: function(name, url, props, fn) {
-
- // properties not supplied
- if (typeof props == 'function') {
- fn = props;
- props = {};
- }
-
- // if fn not given, make a fake id so that plugin's onUpdate get's fired
- var fnId = fn ? makeId() : "_";
- self._api().fp_loadPlugin(name, url, props, fnId);
-
- // create new plugin
- 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;
- },
-
- // "lazy" play
- 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.0-rc2";
- 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;
- },
-
- _config: function() {
- return conf;
- }
-
- });
-
-
- // event handlers
- each(("Click*,Load*,Unload*,Keypress*,Volume*,Mute*,Unmute*,PlaylistReplace,Fullscreen*,FullscreenExit,Error").split(","),
- function() {
- var name = "on" + this;
-
- // before event
- 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;
- };
- }
-
- // normal event
- self[name] = function(fn) {
- bind(listeners, name, fn);
- return self;
- };
- }
- );
-
-
- // core API methods
- each(("pause,resume,mute,unmute,stop,toggle,seek,getStatus,getVolume,setVolume,getTime,isPaused,isPlaying,startBuffering,stopBuffering,isFullscreen,reset").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;
- };
- }
- );
-
-//}}}
-
-
-// {{{ public method: _fireEvent
-
- self._fireEvent = function(evt, arg0, arg1, arg2) {
-
- if (conf.debug) {
- log(arguments);
- }
-
- // internal onLoad
- if (evt == 'onLoad' && !api) {
-
- 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 == '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) {
- if (arg0.name) {
- p._fireEvent("onUpdate", arg0);
- }
- p._fireEvent(arg1);
- }
- return;
- }
-
- // onPlaylistReplace
- if (evt == 'onPlaylistReplace') {
- playlist = [];
- var index = 0;
- each(arg0, function() {
- playlist.push(new Clip(this, index++));
- });
- }
-
- var ret = true;
-
- // clip event
- if (arg0 === 0 || (arg0 && arg0 >= 0)) {
-
- activeIndex = arg0;
- var clip = playlist[arg0];
-
- if (!clip || clip._fireEvent(evt, arg1, arg2) !== false) {
-
- // clip argument is given for common clip, because it behaves as the target
- ret = commonClip._fireEvent(evt, arg1, arg2, clip);
- }
- }
-
- // player event
- var i = 0;
- each(listeners[evt], function() {
- ret = this.call(self, arg0);
-
- // remove cached entry
- if (this.cached) {
- listeners[evt].splice(i, 1);
- }
-
- // break loop
- if (ret === false) { return false; }
- i++;
-
- });
-
- return ret;
- };
-
-//}}}
-
-
-// {{{ init
-
- function init() {
-
- if ($f(wrapper)) {
- return null;
- }
-
- // register this player into global array of instances
- players.push(self);
-
-
- // flashembed parameters
- if (typeof params == 'string') {
- params = {src: params};
- }
-
- // playerId
- playerId = wrapper.id || "fp" + makeId();
- apiId = params.id || playerId + "_api";
- params.id = apiId;
- conf.playerId = playerId;
-
-
- // plain url is given as config
- if (typeof conf == 'string') {
- conf = {clip:{url:conf}};
- }
-
- // common clip is always there
- conf.clip = conf.clip || {};
- commonClip = new Clip(conf.clip, -1, self);
-
-
- // wrapper href as playlist
- if (wrapper.getAttribute("href")) {
- conf.playlist = [{url:wrapper.getAttribute("href", 2)}];
- }
-
- // playlist
- conf.playlist = conf.playlist || [conf.clip];
-
- var index = 0;
- each(conf.playlist, function() {
-
- var clip = this;
-
- // clip is an array, we don't allow that
- if (typeof clip == 'object' && clip.length) {
- clip = "" + clip;
- }
-
- if (!clip.url && typeof clip == 'string') {
- clip = {url: clip};
- }
-
- // populate common clip properties to each clip
- extend(clip, conf.clip, true);
-
- // modify configuration playlist
- conf.playlist[index] = clip;
-
- // populate playlist array
- clip = new Clip(clip, index, self);
- playlist.push(clip);
- index++;
- });
-
-
- // event listeners
- each(conf, function(key, val) {
- if (typeof val == 'function') {
- bind(listeners, key, val);
- delete conf[key];
- }
- });
-
-
- // plugins
- each(conf.plugins, function(name, val) {
- if (val) {
- plugins[name] = new Plugin(name, val, self);
- }
- });
-
-
- // setup controlbar plugin if not explicitly defined
- if (!conf.plugins || conf.plugins.controls === undefined) {
- plugins.controls = new Plugin("controls", null, self);
- }
-
- // Flowplayer uses black background by default
- params.bgcolor = params.bgcolor || "#000000";
-
-
- // setup default settings for express install
- params.version = params.version || [9,0];
- params.expressInstall = 'http://www.flowplayer.org/swf/expressinstall.swf';
-
-
- // click function
- function doClick(e) {
- if (self._fireEvent("onBeforeClick") !== false) {
- self.load();
- }
- return stopEvent(e);
- }
-
- // defer loading upon click
- html = wrapper.innerHTML;
- if (html.replace(/\s/g, '') !== '') {
-
- if (wrapper.addEventListener) {
- wrapper.addEventListener("click", doClick, false);
-
- } else if (wrapper.attachEvent) {
- wrapper.attachEvent("onclick", doClick);
- }
-
- // player is loaded upon page load
- } else {
-
- // prevent default action from wrapper (safari problem) loaded
- if (wrapper.addEventListener) {
- wrapper.addEventListener("click", stopEvent, false);
- }
-
- // load player
- self.load();
- }
-
- }
-
- // possibly defer initialization until DOM get's loaded
- if (typeof wrapper == 'string') {
- flashembed.domReady(function() {
- var node = el(wrapper);
-
- if (!node) {
- throw "Flowplayer cannot access element: " + wrapper;
- } else {
- wrapper = node;
- init();
- }
- });
-
- // we have a DOM element so page is already loaded
- } else {
- init();
- }
-
-
-//}}}
-
-
-}
-
-
-// {{{ flowplayer() & statics
-
-// container for player instances
-var players = [];
-
-
-// this object is returned when multiple player's are requested
-function Iterator(arr) {
-
- this.length = arr.length;
-
- this.each = function(fn) {
- each(arr, fn);
- };
-
- this.size = function() {
- return arr.length;
- };
-}
-
-// these two variables are the only global variables
-window.flowplayer = window.$f = function() {
-
- var instance = null;
- var arg = arguments[0];
-
-
- // $f()
- if (!arguments.length) {
- each(players, function() {
- if (this.isLoaded()) {
- instance = this;
- return false;
- }
- });
-
- return instance || players[0];
- }
-
- if (arguments.length == 1) {
-
- // $f(index);
- if (typeof arg == 'number') {
- return players[arg];
-
-
- // $f(wrapper || 'containerId' || '*');
- } else {
-
- // $f("*");
- if (arg == '*') {
- return new Iterator(players);
- }
-
- // $f(wrapper || 'containerId');
- each(players, function() {
- if (this.id() == arg.id || this.id() == arg || this.getParent() == arg) {
- instance = this;
- return false;
- }
- });
-
- return instance;
- }
- }
-
- // instance builder
- if (arguments.length > 1) {
-
- var swf = arguments[1];
- var conf = (arguments.length == 3) ? arguments[2] : {};
-
- if (typeof arg == 'string') {
-
- // select arg by classname
- if (arg.indexOf(".") != -1) {
- var instances = [];
-
- each(select(arg), function() {
- instances.push(new Player(this, clone(swf), clone(conf)));
- });
-
- return new Iterator(instances);
-
- // select node by id
- } else {
- var node = el(arg);
- return new Player(node !== null ? node : arg, swf, conf);
- }
-
-
- // arg is a DOM element
- } else if (arg) {
- return new Player(arg, swf, conf);
- }
-
- }
-
- return null;
-};
-
-extend(window.$f, {
-
- // called by Flash External Interface
- fireEvent: function(id, evt, a0, a1, a2) {
- var p = $f(id);
- return p ? p._fireEvent(evt, a0, a1, a2) : null;
- },
-
-
- // create plugins by modifying Player's prototype
- addPlugin: function(name, fn) {
- Player.prototype[name] = fn;
- return $f;
- },
-
- // utility methods for plugin developers
- each: each,
-
- extend: extend
-
-});
-
-//}}}
-
-
-//{{{ jQuery support
-
-if (typeof jQuery == 'function') {
-
- jQuery.prototype.flowplayer = function(params, conf) {
-
- // select instances
- 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);
- }
-
- // create flowplayer instances
- return this.each(function() {
- $f(this, clone(params), conf ? clone(conf) : {});
- });
-
- };
-
-}
-
-//}}}
-
-
-})();
-/**
- * flashembed 0.33. Adobe Flash embedding script
- *
- * http://flowplayer.org/tools/flash-embed.html
- *
- * Copyright (c) 2008 Tero Piirainen (support@flowplayer.org)
- *
- * Released under the MIT License:
- * http://www.opensource.org/licenses/mit-license.php
- *
- * >> Basically you can do anything you want but leave this header as is <<
- *
- * first version 0.01 - 03/11/2008
- * version 0.33 - Mon Nov 03 2008 15:37:15 GMT-0000 (GMT+00:00)
- */
-(function() {
-
-//{{{ utility functions
-
-var jQ = typeof jQuery == 'function';
-
-
-// from "Pro JavaScript techniques" by John Resig
-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;
- }
-}
-
-// if jQuery is present, use it's more effective domReady method
-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);
- }
-};
-
-
-// override extend params function
-function extend(to, from) {
- if (from) {
- for (key in from) {
- if (from.hasOwnProperty(key)) {
- to[key] = from[key];
- }
- }
- }
-}
-
-
-function concatVars(vars) {
- var out = "";
-
- for (var key in vars) {
- if (vars[key]) {
- out += [key] + '=' + toString(vars[key]) + '&';
- }
- }
- return out.substring(0, out.length -1);
-}
-
-
-
-// JSON.toString() function
-function toString(obj) {
-
- switch (typeOf(obj)){
- case 'string':
- obj = obj.replace(new RegExp('(["\\\\])', 'g'), '\\$1');
-
- // flash does not handle %- characters well. transforms "50%" to "50pct" (a dirty hack, I admit)
- obj = obj.replace(/^\s?(\d+)%/, "$1pct");
- return '"' +obj+ '"';
-
- case 'array':
- return '['+ map(obj, function(el) {
- return toString(el);
- }).join(',') +']';
-
- case 'function':
- return '"function()"';
-
- case 'object':
- var str = [];
- for (var prop in obj) {
- if (obj.hasOwnProperty(prop)) {
- str.push('"'+prop+'":'+ toString(obj[prop]));
- }
- }
- return '{'+str.join(',')+'}';
- }
-
- // replace ' --> " and remove spaces
- return String(obj).replace(/\s/g, " ").replace(/\'/g, "\"");
-}
-
-
-// private functions
-function typeOf(obj) {
- if (obj === null || obj === undefined) { return false; }
- var type = typeof obj;
- return (type == 'object' && obj.push) ? 'array' : type;
-}
-
-
-// version 9 bugfix: (http://blog.deconcept.com/2006/07/28/swfobject-143-released/)
-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;
-}
-
-//}}}
-
-
-window.flashembed = function(root, userParams, flashvars) {
-
-
-//{{{ getHTML
-
- function getHTML() {
-
- var html = "";
- if (typeof flashvars == 'function') { flashvars = flashvars(); }
-
-
- // sometimes ie fails to load flash if it's on cache
- params.src += ((params.src.indexOf("?") != -1 ? "&" : "?") + Math.random());
-
-
- // mozilla
- if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {
-
- html = '<embed type="application/x-shockwave-flash" ';
-
- if (params.id) {
- extend(params, {name:params.id});
- }
-
- for (var key in params) {
- if (params[key] !== null) {
- html += [key] + '="' +params[key]+ '"\n\t';
- }
- }
-
- if (flashvars) {
- html += 'flashvars=\'' + concatVars(flashvars) + '\'';
- }
-
- // thanks Tom Price (07/17/2008)
- html += '/>';
-
- // ie
- } else {
-
- html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
- html += 'width="' + params.width + '" height="' + params.height + '"';
-
- // force id for IE. otherwise embedded Flash object cannot be returned
- if (!params.id && document.all) {
- params.id = "_" + ("" + Math.random()).substring(5);
- }
-
- if (params.id) {
- html += ' id="' + params.id + '"';
- }
-
- html += '>';
- html += '\n\t<param name="movie" value="'+ params.src +'" />';
-
- params.id = params.src = params.width = params.height = null;
-
- for (var k in params) {
- if (params[k] !== null) {
- html += '\n\t<param name="'+ k +'" value="'+ params[k] +'" />';
- }
- }
-
- if (flashvars) {
- html += '\n\t<param name="flashvars" value=\'' + concatVars(flashvars) + '\' />';
- }
-
- html += "</object>";
- if (debug) {
- alert(html);
- }
-
- }
-
- return html;
- }
-
- //}}}
-
-
-//{{{ construction
-
- // setup params
- var params = {
-
- // very common params
- src: '#',
- width: '100%',
- height: '100%',
-
- // flashembed specific options
- version:null,
- onFail:null,
- expressInstall:null,
- debug: false,
-
- // flashembed defaults
- // bgcolor: 'transparent',
- 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; }
-
-
- // is supported
- if (!required || flashembed.isSupported(required)) {
- params.onFail = params.version = params.expressInstall = params.debug = null;
-
- // root.innerHTML may cause broplems: http://domscripting.com/blog/display/99
- // thanks to: Ryan Rud
- // var tmp = document.createElement("extradiv");
- // tmp.innerHTML = getHTML();
- // root.appendChild(tmp);
-
- root.innerHTML = getHTML();
-
- // return our API
- return root.firstChild;
-
- // custom fail event
- } else if (params.onFail) {
- var ret = params.onFail.call(params, flashembed.getVersion(), flashvars);
- if (ret === true) { root.innerHTML = ret; }
-
-
- // express install
- } else if (required && express && flashembed.isSupported([6,65])) {
-
- extend(params, {src: express});
-
- flashvars = {
- MMredirectURL: location.href,
- MMplayerType: 'PlugIn',
- MMdoctitle: document.title
- };
-
- root.innerHTML = getHTML();
-
- // not supported
- } else {
-
- // minor bug fixed here 08.04.2008 (thanks JRodman)
-
- if (root.innerHTML.replace(/\s/g, '') !== '') {
- // custom content was supplied
-
- } 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;
-
-//}}}
-
-
-};
-
-
-//{{{ static methods
-
-extend(window.flashembed, {
-
- // arr[major, minor, fix]
- 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 { // avoid fp 6 crashes
- var _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
-
- } catch(e) {
- try {
- _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
- version = [6, 0];
- _a.AllowScriptAccess = "always"; // throws if fp < 6.47
-
- } catch(ee) {
- if (version[0] == 6) { return; }
- }
- try {
- _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
- } catch(eee) {
-
- }
-
- }
-
- if (typeof _a == "object") {
- _d = _a.GetVariable("$version"); // bugs in fp 6.21 / 6.23
- 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,
-
- // returns a String representation from JSON object
- toString: toString
-
-});
-
-//}}}
-
-
-// setup jquery support
-if (jQ) {
-
- jQuery.prototype.flashembed = function(params, flashvars) {
- return this.each(function() {
- flashembed(this, params, flashvars);
- });
- };
-
-}
-
-})();
+++ /dev/null
-/**
- * flowplayer.js 3.0.0-rc2. The Flowplayer API.
- *
- * This file is part of Flowplayer, http://flowplayer.org
- *
- * Author: Tero Piirainen, <support@flowplayer.org>
- * Copyright (c) 2008 Flowplayer Ltd
- *
- * Released under the MIT License:
- * http://www.opensource.org/licenses/mit-license.php
- *
- * Version: 3.0.0-rc2 - Fri Nov 07 2008 16:50:52 GMT-0000 (GMT+00:00)
- */
-(function(){function log(args){if(typeof opera=='object'){opera.postError("$f.fireEvent: "+args.join(" | "));}else if(typeof console=='object'){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={};this.index=index;if(typeof json=='string'){json={url:json};}extend(this,json,true);each(("Start*,MetaData,Pause*,Resume*,Seek*,Stop*,Finish,LastSecond,Update,BufferFull,BufferEmpty").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._config();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){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=='onMetaData'||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);});return ret;}});if(json.onCuepoint){self.onCuepoint.apply(self,json.onCuepoint);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=arg||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
-self=this,api=null,html,commonClip,playlist=[],plugins={},listeners={},playerId,apiId,activeIndex,swfHeight;extend(self,{id:function(){return playerId;},isLoaded:function(){return(api!==null);},getParent:function(){return wrapper;},hide:function(){if(api){api.style.height="0px";}return self;},show:function(){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(){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(){return clone(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.0-rc2";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;},_config:function(){return conf;}});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").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(evt=='onLoad'&&!api){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=='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){if(arg0.name){p._fireEvent("onUpdate",arg0);}p._fireEvent(arg1);}return;}if(evt=='onPlaylistReplace'){playlist=[];var index=0;each(arg0,function(){playlist.push(new Clip(this,index++));});}var ret=true;if(arg0===0||(arg0&&arg0>=0)){activeIndex=arg0;var clip=playlist[arg0];if(!clip||clip._fireEvent(evt,arg1,arg2)!==false){ret=commonClip._fireEvent(evt,arg1,arg2,clip);}}var i=0;each(listeners[evt],function(){ret=this.call(self,arg0);if(this.cached){listeners[evt].splice(i,1);}if(ret===false){return false;}i++;});return ret;};function init(){if($f(wrapper)){return null;}players.push(self);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||{};commonClip=new Clip(conf.clip,-1,self);if(wrapper.getAttribute("href")){conf.playlist=[{url:wrapper.getAttribute("href",2)}];}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};}extend(clip,conf.clip,true);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._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(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];}}}}function concatVars(vars){var out="";for(var key in vars){if(vars[key]){out+=[key]+'='+toString(vars[key])+'&';}}return out.substring(0,out.length-1);}function toString(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 toString(el);}).join(',')+']';case'function':return'"function()"';case'object':var str=[];for(var prop in obj){if(obj.hasOwnProperty(prop)){str.push('"'+prop+'":'+toString(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;}window.flashembed=function(root,userParams,flashvars){function getHTML(){var html="";if(typeof flashvars=='function'){flashvars=flashvars();}params.src+=((params.src.indexOf("?")!=-1?"&":"?")+Math.random());if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){html='<embed type="application/x-shockwave-flash" ';if(params.id){extend(params,{name:params.id});}for(var key in params){if(params[key]!==null){html+=[key]+'="'+params[key]+'"\n\t';}}if(flashvars){html+='flashvars=\''+concatVars(flashvars)+'\'';}html+='/>';}else{html='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';html+='width="'+params.width+'" height="'+params.height+'"';if(!params.id&&document.all){params.id="_"+(""+Math.random()).substring(5);}if(params.id){html+=' id="'+params.id+'"';}html+='>';html+='\n\t<param name="movie" value="'+params.src+'" />';params.id=params.src=params.width=params.height=null;for(var k in params){if(params[k]!==null){html+='\n\t<param name="'+k+'" value="'+params[k]+'" />';}}if(flashvars){html+='\n\t<param name="flashvars" value=\''+concatVars(flashvars)+'\' />';}html+="</object>";if(debug){alert(html);}}return html;}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();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();}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,toString:toString});if(jQ){jQuery.prototype.flashembed=function(params,flashvars){return this.each(function(){flashembed(this,params,flashvars);});};}})();
\ No newline at end of file
+++ /dev/null
-This Kaltura Dynamic Player +Playlist (KDP) is a sub package of the taken Kaltura Community Edition (CE) Built from Kaltura.org source.
-
-The full Kaltura Community Edition is licensed under the (GNU Affero General Public License v3)
-
-And the source code is available on the kaltura.org site:
-http://www.kaltura.org/project/kalturaCE
-
-More info about the KDP:
-http://www.kaltura.org/kdp-dynamic-player-and-playlist-widget
-
-
+++ /dev/null
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
+++ /dev/null
-
- *** PRELIMINARY SOFTWARE ***
-
-Please note that this is a prerelease of the OMTK Flash library. No
-quality of this software can be guaranteed.
-
-
- *** haXe notes ***
-
-You need at least haXe 2.01 (with support for the new Flash 10 types)
-to compile the haXe source.
-
- *** Flash notes ***
-
-I am not able to create a .SWC library from the haXe .SWF file. It's
-therefore dynamically linked at runtime and hxmdct.swf must be placed
-in the same directory as the "real" Flash movie.
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package {
-
- import org.omtk.vorbis.VorbisSound;
-
- import flash.display.Shape;
- import flash.display.Sprite;
- import flash.display.StageAlign;
- import flash.display.StageQuality;
- import flash.display.StageScaleMode;
- import flash.net.*;
- import flash.events.Event;
- import flash.text.TextField;
- import flash.utils.ByteArray;
- import flash.utils.Endian;
- import flash.utils.getTimer;
- import flash.utils.setTimeout;
- import flash.utils.setInterval;
- import flash.external.ExternalInterface;
-
- [ SWF( backgroundColor = '#ffffff', width = '1', height = '1' ) ]
-
- public class Player extends Sprite {
-
- private var sound: VorbisSound;
- private var initialized: Boolean = false;
-
- public function Player() {
- if(stage != null) {
- stage.frameRate = 20;
- }
-
- setTimeout(registerJSCallbacks, 100);
- initialized = true;
- }
-
- private function registerJSCallbacks(): void {
- if (ExternalInterface.available) {
- ExternalInterface.addCallback("play", playJS);
- ExternalInterface.addCallback("getMetaData", getMetaDataJS);
- ExternalInterface.addCallback("getPosition", getPositionJS);
- }
- }
-
- public function playJS(url: String): void {
- if(sound != null) {
- sound.stop();
- }
- sound = new VorbisSound(new URLRequest(url));
- sound.addEventListener(Event.COMPLETE, complete);
- sound.addEventListener(VorbisSound.METADATA_UPDATE, metadataUpdate);
- sound.play();
- }
-
- public function getMetaDataJS(key: String): String {
- if(sound == null) {
- return null;
- }
- else {
- return sound.getMetaData(key);
- }
- }
-
- public function getPositionJS(): int {
- if(sound == null) {
- return -1;
- }
- else {
- return sound.position;
- }
- }
-
- private function complete(event: Event):void {
- trace("complete");
- if(ExternalInterface.available) {
- ExternalInterface.call("OMTK_P_complete");
- }
- }
-
- private function metadataUpdate(event: Event):void {
- trace("metadata update: " + sound.getMetaData("TITLE"));
- if(ExternalInterface.available) {
- ExternalInterface.call("OMTK_P_metadataUpdate");
- }
- }
-
- }
-
-}
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.ogg {
-
- public class EndOfOggStreamError extends Error {
-
- public function EndOfOggStreamError(message:String = null) {
- super(message);
- }
-
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.ogg {
-
- import org.omtk.util.BitByteArray;
- import flash.utils.Endian;
-
- public class LogicalOggStream {
-
- private var source:UncachedUrlStream;
-
- private var pageIndex:int;
- private var currentPage:OggPage;
- private var currentSegmentIndex:int;
-
- public function LogicalOggStream(source:UncachedUrlStream) {
- this.source = source;
- }
-
- public function getNextOggPacket(): OggPacket {
-
- var res:BitByteArray = new BitByteArray();
-
- var segmentLength:int = 0;
-
- if(currentPage == null) {
- currentPage = source.getNextOggPage();
- }
-
- do {
- if(currentSegmentIndex >= currentPage.segmentOffsets.length) {
- currentSegmentIndex=0;
-
- if(currentPage.eos) {
- throw new EndOfOggStreamError("End of OGG stream");
- }
-
- currentPage = source.getNextOggPage();
- }
-
- segmentLength = currentPage.segmentLengths[currentSegmentIndex];
- res.writeBytes(currentPage.data, currentPage.segmentOffsets[currentSegmentIndex], segmentLength);
- currentSegmentIndex++;
- }
- while(segmentLength==255);
-
- res.position = 0;
-
- var lastPacket: Boolean = currentPage.eos && currentSegmentIndex == currentPage.segmentOffsets.length;
- var lastGranulePosition: int = currentPage.absoluteGranulePosition;
-
- return new OggPacket(res, lastPacket, lastGranulePosition);
- }
-
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.ogg {
-
- import org.omtk.util.BitByteArray;
-
- public class OggPacket {
-
- private var _data: BitByteArray;
- private var _lastPacket: Boolean;
- private var _lastGranulePosition: int;
-
- public function OggPacket(data: BitByteArray, lastPacket: Boolean, lastGranulePosition: int) {
- _data = data;
- _lastPacket = lastPacket;
- _lastGranulePosition = lastGranulePosition;
- }
-
- public function get data(): BitByteArray {
- return _data;
- }
-
- public function get lastPacket(): Boolean {
- return _lastPacket;
- }
-
- public function get lastGranulePosition(): int {
- return _lastGranulePosition;
- }
-
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.ogg {
-
- import flash.net.*;
- import flash.utils.ByteArray;
-
- public class OggPage {
-
- private var _version:int;
- private var _continued:Boolean;
- private var _bos:Boolean;
- private var _eos:Boolean;
- private var _absoluteGranulePosition:int;
- private var _streamSerialNumber:int;
- private var _pageSequenceNumber:int;
- private var _pageCheckSum:int;
- private var _segmentOffsets:Array;
- private var _segmentLengths:Array;
- private var _totalLength:int;
- private var _data:ByteArray;
-
- public function OggPage(stream:URLStream) {
-
- var capture:int = stream.readInt();
- if(capture != 0x5367674f) {
- throw new Error("Ogg page does not start with 'OggS': "+capture);
- }
-
- _version = stream.readByte()&0xff;
- var tmp:int = stream.readByte();
-
- _continued = (tmp&1)!=0;;
- _bos = (tmp&2)!=0;
- _eos = (tmp&4)!=0;
-
- // absoluteGranulePosition is really 64 bits
- _absoluteGranulePosition = stream.readUnsignedInt();
- stream.readUnsignedInt(); // last 32 bits of _absoluteGranulePosition
-
- _streamSerialNumber = stream.readUnsignedInt();
- _pageSequenceNumber = stream.readUnsignedInt();
- _pageCheckSum = stream.readUnsignedInt();
-
- //trace("_pageSequenceNumber: " + _pageSequenceNumber);
-
- var pageSegments:int = stream.readUnsignedByte();
-
- //stream.waitFor(pageSegments);
-
- _segmentOffsets = [];
- _segmentLengths = [];
- _data = new ByteArray();
-
- var totalLength:int;
-
- var i:int;
- var l:int;
-
- for( i= 0 ; i < pageSegments ; i++ ) {
- l = stream.readUnsignedByte();
- _segmentLengths.push( l );
- _segmentOffsets.push( totalLength );
- totalLength += l;
- }
-
- stream.readBytes(_data, 0, totalLength);
- }
-
- public function get absoluteGranulePosition():int {
- return _absoluteGranulePosition;
- }
-
- public function get segmentOffsets():Array {
- return _segmentOffsets;
- }
-
- public function get segmentLengths():Array {
- return _segmentLengths;
- }
-
- public function get data():ByteArray {
- return _data;
- }
-
- public function get eos():Boolean {
- return _eos;
- }
-
- public function get bos():Boolean {
- return _bos;
- }
-
- public function get continued():Boolean {
- return _continued;
- }
-
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.ogg {
-
- import flash.net.*;
- import flash.utils.Endian;
- import flash.events.HTTPStatusEvent;
- import flash.events.ProgressEvent;
-
- public class UncachedUrlStream {
-
- private var source:URLStream;
-
- public function UncachedUrlStream(source: URLStream) {
- this.source = source;
- }
-
- public function get bytesAvailable():int {
- return source.bytesAvailable;
- }
-
- public function addEventListener(type:String, listener:Function):void {
- source.addEventListener(type, listener);
- }
-
- public function getLogicalOggStream():LogicalOggStream {
- return new LogicalOggStream(this);
- }
-
- public function getNextOggPage():OggPage {
- return new OggPage(source);
- }
-
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.util {
-
- import flash.utils.ByteArray;
- import flash.utils.Endian;
- import flash.errors.IllegalOperationError;
-
- public class BitByteArray extends ByteArray {
-
- private var currentByte:uint;
- private var bitIndex:int = 8;
-
- public function BitByteArray() {
- this.endian = Endian.LITTLE_ENDIAN;
- }
-
- public function readBit():Boolean {
- if (bitIndex > 7) {
- bitIndex = 0;
- currentByte = readUnsignedByte();
- }
- return (currentByte & (1 << (bitIndex++))) != 0;
- }
-
- public function readUnsignedBitwiseInt(bits:int):uint {
-
- var res:uint = 0;
-
- for (var i : int = 0; i < bits; i++) {
- if (bitIndex > 7) {
- bitIndex = 0;
- currentByte = readUnsignedByte();
- }
- if((currentByte & (1 << (bitIndex++))) != 0) {
- res |= (1 << i);
- }
- }
-
- return res;
- }
-
- public function readUnsignedHuffmanInt(root:HuffmanNode):uint {
-
- while (!root.hasValue) {
- if (bitIndex > 7) {
- bitIndex = 0;
- currentByte = readUnsignedByte();
- }
- root = (currentByte & (1 << (bitIndex++))) != 0 ? root._o1 : root._o0;
- }
-
- return root._value;
- }
-
- }
-
-
-}
\ No newline at end of file
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-package org.omtk.util {
-
- public class HuffmanNode {
-
- private var _parent:HuffmanNode;
-
- public var _o0:HuffmanNode;
- public var _o1:HuffmanNode;
-
- private var _depth:int;
-
- public var _value:int;
- public var hasValue: Boolean;
- private var _full:Boolean = false;
-
- public function HuffmanNode(parent:HuffmanNode = null, value:int = -1) {
- _parent = parent;
- if(_parent != null) {
- _depth = _parent.depth+1;
- }
- _value = value;
- _full = value >= 0;
- hasValue = value >= 0;
- }
-
- public function setNewValue(depth:int, value:uint):Boolean {
- if (full) {
- return false;
- }
- if (depth == 1) {
- if (_o0 == null) {
- _o0 = new HuffmanNode(this, value);
- return true;
- } else if (_o1 == null) {
- _o1 = new HuffmanNode(this, value);
- return true;
- } else {
- return false;
- }
- } else {
- return o0.setNewValue(depth - 1, value)
- ? true : o1.setNewValue(depth - 1, value);
- }
- }
-
- public function get value():uint {
- return _value;
- }
-
- public function get o0():HuffmanNode {
- if(_o0 == null) {
- _o0 = new HuffmanNode(this);
- }
- return _o0;
- }
-
- public function get o1():HuffmanNode {
- if(_o1 == null) {
- _o1 = new HuffmanNode(this);
- }
- return _o1;
- }
-
- public function get depth():int {
- return _depth;
- }
-
- public function get full():Boolean {
- return _full ? true
- : (_full = (_o0 != null && _o0.full && _o1 != null && _o1.full));
- }
-
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.vorbis {
-
- import flash.utils.getTimer;
- import flash.utils.ByteArray;
- import org.omtk.ogg.*;
- import org.omtk.util.BitByteArray;
-
- public class AudioPacket {
-
- private var modeNumber:int;
- private var mode:Mode;
- private var mapping:Mapping;
- private var n:int;
-
- private var blockFlag:Boolean;
- private var previousWindowFlag:Boolean;
- private var nextWindowFlag:Boolean;
-
- private var windowCenter:int;
- private var leftWindowStart:int;
- private var leftWindowEnd:int;
- private var leftN:int;
- private var rightWindowStart:int;
- private var rightWindowEnd:int;
- private var rightN:int;
-
- private var window:Vector.<Number>;
- private var freq0:Vector.<Number>;
- private var freq1:Vector.<Number>;
- private var pcm0:Vector.<Number>;
- private var pcm1:Vector.<Number>;
-
- private var channelFloors:Vector.<Floor>;
- private var noResidues:Vector.<Boolean>;
-
- private var _lastPacket: Boolean;
- private var _lastGranulePosition: int;
-
- public function AudioPacket(vorbis:VorbisStream, packet: OggPacket, currentGranulePosition: int) {
-
- var source: BitByteArray = packet.data;
- _lastPacket = packet.lastPacket;
- _lastGranulePosition = packet.lastGranulePosition;
-
- var i:int;
- var j:int;
- var k:int;
-
- var sHeader:SetupHeader = vorbis.setupHeader;
- var iHeader:IdentificationHeader = vorbis.identificationHeader;
- var modes:Vector.<Mode> = sHeader.modes;
- var mappings:Vector.<Mapping> = sHeader.mappings;
- var residues:Vector.<Residue> = sHeader.residues;
- var channels:int = iHeader.channels;
-
- if (source.readUnsignedBitwiseInt(1) != 0) {
- throw new Error("Packet type mismatch when trying to create an audio packet.");
- }
-
- modeNumber = source.readUnsignedBitwiseInt(Util.ilog(modes.length - 1));
-
- mode = modes[modeNumber];
-
- if(mode == null) {
- throw new Error("Reference to invalid mode in audio packet.");
- }
-
- mapping = mappings[mode.mapping];
-
- var magnitudes:Vector.<int> = mapping.magnitudes;
- var angles:Vector.<int> = mapping.angles;
-
- blockFlag = mode.blockFlag;
-
- var blockSize0:int = iHeader.blockSize0;
- var blockSize1:int = iHeader.blockSize1;
-
- n = blockFlag ? blockSize1 : blockSize0;
-
- if (blockFlag) {
- previousWindowFlag = source.readBit();
- nextWindowFlag = source.readBit();
- }
-
- windowCenter = n / 2;
-
- if (blockFlag && !previousWindowFlag) {
- leftWindowStart = n / 4 - blockSize0 / 4;
- leftWindowEnd = n / 4 + blockSize0 / 4;
- leftN = blockSize0 / 2;
- } else {
- leftWindowStart = 0;
- leftWindowEnd = n / 2;
- leftN = windowCenter;
- }
-
- if (blockFlag && !nextWindowFlag) {
- rightWindowStart = n * 3 / 4 - blockSize0 / 4;
- rightWindowEnd = n * 3 / 4 + blockSize0 / 4;
- rightN = blockSize0 / 2;
- } else {
- rightWindowStart = windowCenter;
- rightWindowEnd = n;
- rightN = n / 2;
- }
-
- window = getComputedWindow(vorbis);
-
- channelFloors = new Vector.<Floor>(channels, true);
- noResidues = new Vector.<Boolean>(channels, true);
-
- freq0 = new Vector.<Number>(n, true);
- freq1 = new Vector.<Number>(n, true);
- pcm0 = new Vector.<Number>(n, true);
- pcm1 = new Vector.<Number>(n, true);
-
- var allFloorsEmpty: Boolean = true;
- var submapNumber: int;
- var floorNumber: int;
- var decodedFloor: Floor;
-
- for(i = 0; i < channels; i++) {
- submapNumber = mapping.mux[i];
- floorNumber = mapping.submapFloors[submapNumber];
- decodedFloor = sHeader.floors[floorNumber].decodeFloor(vorbis, source);
- channelFloors[i] = decodedFloor;
- noResidues[i] = decodedFloor == null;
- if (decodedFloor != null) {
- allFloorsEmpty = false;
- }
- }
-
- if(allFloorsEmpty) {
- return;
- }
-
- var mag: int;
- var ang: int;
-
- for(i = 0; i < magnitudes.length; i++) {
- mag = magnitudes[i];
- ang = angles[i];
- if (!noResidues[mag] || !noResidues[ang]) {
- noResidues[mag] = false;
- noResidues[ang] = false;
- }
- }
-
- var ch: int;
- var doNotDecodeFlags: Vector.<Boolean>;
- var residue:Residue;
-
- for(i = 0; i < mapping.submaps; i++) {
-
- doNotDecodeFlags = new Vector.<Boolean>();
-
- for(j = 0; j < channels; j++) {
- if(mapping.mux[j] == i) {
- doNotDecodeFlags.push(noResidues[j]);
- }
- }
-
- residue = residues[mapping.submapResidues[i]];
-
- residue.decodeResidue(vorbis, source, mode, ch, doNotDecodeFlags, freq0, freq1);
- }
-
- var a: Number;
- var m: Number;
-
- for(i = mapping.couplingSteps - 1; i >= 0; i--) {
-
- mag = magnitudes[i];
- ang = angles[i];
-
- for (j = 0; j < freq0.length; j++) {
-
- a = ang == 0 ? freq0[j] : freq1[j];
- m = mag == 0 ? freq0[j] : freq1[j];
-
- if(a > 0) {
- if(ang == 0) {
- freq0[j] = m > 0 ? m - a : m + a;
- }
- else {
- freq1[j] = m > 0 ? m - a : m + a;
- }
- }
- else {
- if(mag == 0) {
- freq0[j] = m > 0 ? m + a : m - a;
- }
- else {
- freq1[j] = m > 0 ? m + a : m - a;
- }
-
- if(ang == 0) {
- freq0[j] = m;
- }
- else {
- freq1[j] = m;
- }
- }
- }
- }
-
- if(channelFloors[0] != null) {
- Floor(channelFloors[0]).computeFloor(freq0);
- }
-
- if(channelFloors[1] != null) {
- Floor(channelFloors[1]).computeFloor(freq1);
- }
-
- // perform an inverse mdct to all channels
- var mdct: Mdct = blockFlag ? iHeader.mdct1 : iHeader.mdct0;
- mdct.imdct(freq0, window, pcm0);
- mdct.imdct(freq1, window, pcm1);
-
- if(_lastPacket) {
- if(leftWindowEnd - leftWindowStart > _lastGranulePosition - currentGranulePosition) {
- leftWindowEnd = leftWindowStart + _lastGranulePosition - currentGranulePosition
- }
- if(rightWindowStart - leftWindowStart > _lastGranulePosition - currentGranulePosition) {
- rightWindowStart = leftWindowStart + _lastGranulePosition - currentGranulePosition
- }
- }
-
- }
-
- private function getComputedWindow(vorbis:VorbisStream):Vector.<Number> {
-
- var i:int;
-
- var ix:int = (blockFlag ? 4 : 0) + (previousWindowFlag ? 2 : 0) + (nextWindowFlag ? 1 : 0);
- var w:Vector.<Number> = vorbis.windows[ix];
-
- var x:Number;
-
- if (w == null) {
- w = new Vector.<Number>(n);
-
- for(i = 0; i < leftWindowStart; i++) {
- w[i] = 0;
- }
-
- for (i = 0; i < leftN; i++) {
- x = (i + .5) / leftN * Math.PI / 2.;
- x = Math.sin(x);
- x *= x;
- x *= Math.PI / 2.;
- x = Math.sin(x);
- w[i + leftWindowStart] = x;
- }
-
- for (i = leftWindowEnd; i < rightWindowStart; i++) {
- w[i] = 1;
- }
-
- for (i = 0; i < rightN; i++) {
- x = (rightN - i - .5) / rightN * Math.PI / 2.;
- x = Math.sin(x);
- x *= x;
- x *= Math.PI / 2.;
- x = Math.sin(x);
- w[i + rightWindowStart] = x;
- }
-
- for(i = rightN + rightWindowStart; i < n; i++) {
- w[i] = 0;
- }
-
- for(i = 0; i < w.length; i++) {
- w[i] *= 0.5;
- }
-
- vorbis.windows[ix] = w;
- }
-
- return w;
- }
-
-
- public function readPcm(previousPacket:AudioPacket, target: ByteArray): int {
-
- var j:int;
- var j2:int;
- var ppcm0:Vector.<Number> = previousPacket.pcm0;
- var ppcm1:Vector.<Number> = previousPacket.pcm1;
-
- j2 = previousPacket.rightWindowStart;
-
- for(j = leftWindowStart; j < leftWindowEnd; j++) {
- target.writeFloat(pcm0[j] + ppcm0[j2]);
- target.writeFloat(pcm1[j] + ppcm1[j2++]);
- }
-
- for (j = leftWindowEnd; j < rightWindowStart; j++) {
- target.writeFloat(pcm0[j]);
- target.writeFloat(pcm1[j]);
- }
-
- return numberOfSamples;
-
- }
-
- public function get numberOfSamples():int {
- return rightWindowStart - leftWindowStart;
- }
-
- public function get lastPacket(): Boolean {
- return lastPacket;
- }
-
- public function get lastGranulePosition(): int {
- return lastGranulePosition;
- }
-
- }
-
-
-}
\ No newline at end of file
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.vorbis {
-
- import flash.errors.IllegalOperationError;
- import org.omtk.util.*;
-
- public class CodeBook {
-
- private var entries:uint;
- private var entryLengths:Vector.<int>;
- private var valueVector:Vector.<Vector.<Number>>;
-
- private var codeBookLookupType:int = -1;
-
- public var huffmanRoot:HuffmanNode;
- public var dimensions:uint;
-
- public function CodeBook( source: BitByteArray ) {
-
- var i:int;
- var j:int;
-
- var syncPattern:uint = source.readUnsignedBitwiseInt(24);
- if(syncPattern !=0x564342) {
- throw new IllegalOperationError("Illegal codebook sync pattern: "+syncPattern);
- }
-
- dimensions = source.readUnsignedBitwiseInt(16);
- entries = source.readUnsignedBitwiseInt(24);
-
- entryLengths = new Vector.<int>(entries);
-
- var ordered:Boolean = source.readBit();
-
- if(ordered) {
- var cl:int = source.readUnsignedBitwiseInt(5)+1;
- for(i=0; i<entryLengths.length; ) {
- var num:int = source.readUnsignedBitwiseInt(Util.ilog(entryLengths.length-i));
- if(i+num>entryLengths.length) {
- throw new Error("The codebook entry length list is longer than the actual number of entry lengths.");
- }
- for(j=i; j<i+num; j++) {
- entryLengths[j] = cl;
- }
- //Arrays.fill(entryLengths, i, i+num, cl);
- cl++;
- i+=num;
- }
- }
- else {
- // !ordered
- var sparse:Boolean = source.readBit();
-
- if(sparse) {
- for(i=0; i<entryLengths.length; i++) {
- if(source.readBit()) {
- entryLengths[i]=source.readUnsignedBitwiseInt(5)+1;
- }
- else {
- entryLengths[i]=-1;
- }
- }
- }
- else {
- // !sparse
- //Alert.show("entryLengths.length: "+entryLengths.length, "CodeBook");
- for(i=0; i<entryLengths.length; i++) {
- entryLengths[i]=source.readUnsignedBitwiseInt(5)+1;
- }
- }
-
- }
-
- if (!createHuffmanTree(entryLengths)) {
- throw new Error("An exception was thrown when building the codebook Huffman tree.");
- }
-
- codeBookLookupType = source.readUnsignedBitwiseInt(4);
-
- switch(codeBookLookupType) {
- case 0:
- // codebook has no scalar vectors to be calculated
- break;
- case 1:
- case 2:
- var codeBookMinimumValue:Number = Util.float32unpack(source.readUnsignedBitwiseInt(32));
- var codeBookDeltaValue:Number = Util.float32unpack(source.readUnsignedBitwiseInt(32));
-
- var codeBookValueBits:uint = source.readUnsignedBitwiseInt(4)+1;
- var codeBookSequenceP:Boolean = source.readBit();
-
- var codeBookLookupValues:uint = 0;
-
- if(codeBookLookupType==1) {
- codeBookLookupValues=Util.lookup1Values(entries, dimensions);
- }
- else {
- codeBookLookupValues=entries*dimensions;
- }
-
- var codeBookMultiplicands:Vector.<int> = new Vector.<int>(codeBookLookupValues);
-
- for(i=0; i < codeBookMultiplicands.length; i++) {
- codeBookMultiplicands[i]=source.readUnsignedBitwiseInt(codeBookValueBits);
- }
-
- valueVector = new Vector.<Vector.<Number>>(entries);
-
- if(codeBookLookupType==1) {
- for(i=0; i<entries; i++) {
- valueVector[i] = new Vector.<Number>(dimensions);
- var last:Number = 0.0;
- var indexDivisor:uint = 1;
- for(j=0; j<dimensions; j++) {
- var multiplicandOffset:int = (i/indexDivisor)%codeBookLookupValues;
- valueVector[i][j]=
- codeBookMultiplicands[multiplicandOffset]*codeBookDeltaValue+codeBookMinimumValue+last;
- if(codeBookSequenceP) {
- last = valueVector[i][j];
- }
- indexDivisor*=codeBookLookupValues;
- }
- }
- }
- else {
- throw new Error("Unsupported codebook lookup type: "+codeBookLookupType);
- /** @todo implement */
- }
- break;
- default:
- throw new Error("Unsupported codebook lookup type: "+codeBookLookupType);
- }
- }
-
- private function createHuffmanTree(entryLengths:Vector.<int>):Boolean {
-
- var i:int;
-
- huffmanRoot = new HuffmanNode();
- for(i=0; i<entryLengths.length; i++) {
- var el:int = entryLengths[i];
- if(el>0) {
- if(!huffmanRoot.setNewValue(el, i)) {
- return false;
- }
- }
- }
- return true;
- }
-
-
- public function readVvAdd(a0:Vector.<Number>, a1:Vector.<Number>, left:Boolean, right:Boolean, source:BitByteArray, offset:int, length:int):void {
-
- var i:int;
- var j:int;
-
- if (!left && !right) {
- return;
- }
-
- // 1 or 2 channels
- var ch:int =
- left && right ? 2 : 1;
-
- var lim:int;
- var ix:int;
- var ve:Vector.<Number>;
-
- if(left && right) {
- lim = (offset + length) / 2;
- var chptr:int = 0;
- for (i = offset / 2; i < lim;) {
- ix = source.readUnsignedHuffmanInt(huffmanRoot);
- ve = valueVector[ix];
- for (j = 0; j < dimensions; j++) {
- if(chptr == 0) {
- a0[i] += ve[j];
- }
- else {
- a1[i] += ve[j];
- }
- chptr++;
- if(chptr == 2) {
- chptr = 0;
- i++;
- }
- }
- }
- }
- else {
- var a : Vector.<Number> = left ? a0 : a1;
- lim = offset + length;
- for (i = offset; i < lim;) {
- ve = valueVector[source.readUnsignedHuffmanInt(huffmanRoot)];
- for (j = 0; j < dimensions; j++) {
- a[i] += ve[j];
- i++;
- }
- }
- }
-
- }
-
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.vorbis {
-
- import flash.utils.ByteArray;
- import flash.utils.Endian;
- import flash.utils.Dictionary;
- import org.omtk.ogg.*;
-
- public class CommentHeader {
-
- private var _vendor:String;
- private var _comments:Dictionary = new Dictionary();
-
- public function CommentHeader(source:ByteArray)
- {
- init( source );
- }
-
- private function init( source: ByteArray ): void
- {
- source.readByte();
- source.readByte();
- source.readByte();
- source.readByte();
- source.readByte();
- source.readByte();
-
- _vendor = readUtf8String(source);
-
- var ucLength:int = source.readUnsignedInt();
-
- for(var i:int = 0; i < ucLength; i++) {
- var comment:String = readUtf8String(source);
- var ix:int = comment.indexOf('=');
- var key:String = comment.substring(0, ix);
- var value:String = comment.substring(ix+1);
- _comments[key.toUpperCase()]=value;
- }
- }
-
- private function readUtf8String(source:ByteArray):String {
- var length:uint = source.readUnsignedInt();
- return source.readUTFBytes(length);
- }
-
- public function get vendor():String {
- return _vendor;
- }
-
- public function get comments():Dictionary {
- return _comments;
- }
-
- public function get artist():String {
- return _comments["ARTIST"];
- }
-
- public function get title():String {
- return _comments["TITLE"];
- }
-
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.vorbis {
-
- import flash.errors.IllegalOperationError;
- import org.omtk.util.BitByteArray;
-
- public class Floor {
-
- public static const DB_STATIC_TABLE:Vector.<Number> = Vector.<Number>([
- 1.0649863e-07, 1.1341951e-07, 1.2079015e-07, 1.2863978e-07,
- 1.3699951e-07, 1.4590251e-07, 1.5538408e-07, 1.6548181e-07,
- 1.7623575e-07, 1.8768855e-07, 1.9988561e-07, 2.128753e-07,
- 2.2670913e-07, 2.4144197e-07, 2.5713223e-07, 2.7384213e-07,
- 2.9163793e-07, 3.1059021e-07, 3.3077411e-07, 3.5226968e-07,
- 3.7516214e-07, 3.9954229e-07, 4.2550680e-07, 4.5315863e-07,
- 4.8260743e-07, 5.1396998e-07, 5.4737065e-07, 5.8294187e-07,
- 6.2082472e-07, 6.6116941e-07, 7.0413592e-07, 7.4989464e-07,
- 7.9862701e-07, 8.5052630e-07, 9.0579828e-07, 9.6466216e-07,
- 1.0273513e-06, 1.0941144e-06, 1.1652161e-06, 1.2409384e-06,
- 1.3215816e-06, 1.4074654e-06, 1.4989305e-06, 1.5963394e-06,
- 1.7000785e-06, 1.8105592e-06, 1.9282195e-06, 2.0535261e-06,
- 2.1869758e-06, 2.3290978e-06, 2.4804557e-06, 2.6416497e-06,
- 2.8133190e-06, 2.9961443e-06, 3.1908506e-06, 3.3982101e-06,
- 3.6190449e-06, 3.8542308e-06, 4.1047004e-06, 4.3714470e-06,
- 4.6555282e-06, 4.9580707e-06, 5.2802740e-06, 5.6234160e-06,
- 5.9888572e-06, 6.3780469e-06, 6.7925283e-06, 7.2339451e-06,
- 7.7040476e-06, 8.2047000e-06, 8.7378876e-06, 9.3057248e-06,
- 9.9104632e-06, 1.0554501e-05, 1.1240392e-05, 1.1970856e-05,
- 1.2748789e-05, 1.3577278e-05, 1.4459606e-05, 1.5399272e-05,
- 1.6400004e-05, 1.7465768e-05, 1.8600792e-05, 1.9809576e-05,
- 2.1096914e-05, 2.2467911e-05, 2.3928002e-05, 2.5482978e-05,
- 2.7139006e-05, 2.8902651e-05, 3.0780908e-05, 3.2781225e-05,
- 3.4911534e-05, 3.7180282e-05, 3.9596466e-05, 4.2169667e-05,
- 4.4910090e-05, 4.7828601e-05, 5.0936773e-05, 5.4246931e-05,
- 5.7772202e-05, 6.1526565e-05, 6.5524908e-05, 6.9783085e-05,
- 7.4317983e-05, 7.9147585e-05, 8.4291040e-05, 8.9768747e-05,
- 9.5602426e-05, 0.00010181521, 0.00010843174, 0.00011547824,
- 0.00012298267, 0.00013097477, 0.00013948625, 0.00014855085,
- 0.00015820453, 0.00016848555, 0.00017943469, 0.00019109536,
- 0.00020351382, 0.00021673929, 0.00023082423, 0.00024582449,
- 0.00026179955, 0.00027881276, 0.00029693158, 0.00031622787,
- 0.00033677814, 0.00035866388, 0.00038197188, 0.00040679456,
- 0.00043323036, 0.00046138411, 0.00049136745, 0.00052329927,
- 0.00055730621, 0.00059352311, 0.00063209358, 0.00067317058,
- 0.00071691700, 0.00076350630, 0.00081312324, 0.00086596457,
- 0.00092223983, 0.00098217216, 0.0010459992, 0.0011139742,
- 0.0011863665, 0.0012634633, 0.0013455702, 0.0014330129,
- 0.0015261382, 0.0016253153, 0.0017309374, 0.0018434235,
- 0.0019632195, 0.0020908006, 0.0022266726, 0.0023713743,
- 0.0025254795, 0.0026895994, 0.0028643847, 0.0030505286,
- 0.0032487691, 0.0034598925, 0.0036847358, 0.0039241906,
- 0.0041792066, 0.0044507950, 0.0047400328, 0.0050480668,
- 0.0053761186, 0.0057254891, 0.0060975636, 0.0064938176,
- 0.0069158225, 0.0073652516, 0.0078438871, 0.0083536271,
- 0.0088964928, 0.009474637, 0.010090352, 0.010746080,
- 0.011444421, 0.012188144, 0.012980198, 0.013823725,
- 0.014722068, 0.015678791, 0.016697687, 0.017782797,
- 0.018938423, 0.020169149, 0.021479854, 0.022875735,
- 0.024362330, 0.025945531, 0.027631618, 0.029427276,
- 0.031339626, 0.033376252, 0.035545228, 0.037855157,
- 0.040315199, 0.042935108, 0.045725273, 0.048696758,
- 0.051861348, 0.055231591, 0.058820850, 0.062643361,
- 0.066714279, 0.071049749, 0.075666962, 0.080584227,
- 0.085821044, 0.091398179, 0.097337747, 0.10366330,
- 0.11039993, 0.11757434, 0.12521498, 0.13335215,
- 0.14201813, 0.15124727, 0.16107617, 0.17154380,
- 0.18269168, 0.19456402, 0.20720788, 0.22067342,
- 0.23501402, 0.25028656, 0.26655159, 0.28387361,
- 0.30232132, 0.32196786, 0.34289114, 0.36517414,
- 0.38890521, 0.41417847, 0.44109412, 0.46975890,
- 0.50028648, 0.53279791, 0.56742212, 0.60429640,
- 0.64356699, 0.68538959, 0.72993007, 0.77736504,
- 0.82788260, 0.88168307, 0.9389798, 1.0]);
-
- public static function createInstance(source:BitByteArray, header:SetupHeader):Floor {
-
- var type:int = source.readUnsignedBitwiseInt(16);
-
- switch (type) {
- case 0:
- return new Floor0(source, header);
- case 1:
- return new Floor1(source, header);
- default:
- throw new Error("Floor type " + type + " is not supported.");
- }
- }
-
- public function get type():int {
- throw new IllegalOperationError("operation not implemented");
- }
-
- public function decodeFloor(vorbis:VorbisStream, source:BitByteArray):Floor1 {
- throw new IllegalOperationError("operation not implemented");
- }
-
- public function computeFloor(vector:Vector.<Number>):void {
- throw new IllegalOperationError("operation not implemented");
- }
-
-
- }
-
-
-}
\ No newline at end of file
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.vorbis {
-
- import flash.errors.IllegalOperationError;
- import org.omtk.util.BitByteArray;
-
- public class Floor0 extends Floor {
-
- private var order:int;
- private var rate:int;
- private var barkMapSize:int;
- private var amplitudeBits:int;
- private var amplitudeOffset:int;
-
- private var bookList:Vector.<int>;
-
- public function Floor0(source:BitByteArray, header:SetupHeader) {
-
- order = source.readUnsignedBitwiseInt(8);
- rate = source.readUnsignedBitwiseInt(16);
- barkMapSize = source.readUnsignedBitwiseInt(16);
- amplitudeBits = source.readUnsignedBitwiseInt(6);
- amplitudeOffset = source.readUnsignedBitwiseInt(8);
-
- var bookCount:uint = source.readUnsignedBitwiseInt(4) + 1;
- bookList = new Vector.<int>(bookCount);
-
- var i:int;
-
- for (i = 0; i < bookList.length; i++) {
- bookList[i] = source.readUnsignedBitwiseInt(8);
- if (bookList[i] > header.codeBooks.length) {
- throw new Error("A floor0_book_list entry is higher than the code book count.");
- }
- }
- }
-
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.vorbis {
-
- import flash.errors.IllegalOperationError;
- import org.omtk.util.*;
-
- public class Floor1 extends Floor {
-
- private var partitionClassList:Vector.<int>;
- private var maximumClass:int;
- private var multiplier:int;
- private var rangeBits:int;
- private var classDimensions:Vector.<int>;
- private var classSubclasses:Vector.<int>;
- private var classMasterbooks:Vector.<int>;
- private var subclassBooks:Vector.<Vector.<int>>;
- private var xList:Vector.<int>;
- private var yList:Vector.<int>;
- private var lowNeighbours:Vector.<int>;
- private var highNeighbours:Vector.<int>;
- private static var RANGES:Vector.<int> = Vector.<int>([256, 128, 86, 64]);
-
- private var xList2:Vector.<int>;
- private var step2Flags:Vector.<Boolean>;
-
- public function Floor1(source:BitByteArray = null, header:SetupHeader = null) {
-
- if(source==null && header==null) {
- return;
- }
-
- var i:int;
- var j:int;
-
- maximumClass = -1;
- var partitions:int = source.readUnsignedBitwiseInt(5);
- partitionClassList = new Vector.<int>(partitions);
-
- for (i = 0; i < partitionClassList.length; i++) {
- partitionClassList[i] = source.readUnsignedBitwiseInt(4);
- if (partitionClassList[i] > maximumClass) {
- maximumClass = partitionClassList[i];
- }
- }
-
- classDimensions = new Vector.<int>(maximumClass + 1);
- classSubclasses = new Vector.<int>(maximumClass + 1);
- classMasterbooks = new Vector.<int>(maximumClass + 1);
- subclassBooks = new Vector.<Vector.<int>>(maximumClass + 1);
-
- var xListLength:int = 2;
-
- for (i = 0; i <= maximumClass; i++) {
- classDimensions[i] = source.readUnsignedBitwiseInt(3) + 1;
- xListLength += classDimensions[i];
- classSubclasses[i] = source.readUnsignedBitwiseInt(2);
-
- if (classDimensions[i] > header.codeBooks.length || classSubclasses[i] > header.codeBooks.length) {
- throw new Error("There is a class dimension or class subclasses entry higher than the number of codebooks in the setup header.");
- }
- if (classSubclasses[i] != 0) {
- classMasterbooks[i] = source.readUnsignedBitwiseInt(8);
- }
- subclassBooks[i] = new Vector.<int>(1 << classSubclasses[i]);
- for (j = 0; j < subclassBooks[i].length; j++) {
- subclassBooks[i][j] = source.readUnsignedBitwiseInt(8) - 1;
- }
- }
-
- multiplier = source.readUnsignedBitwiseInt(2) + 1;
- rangeBits = source.readUnsignedBitwiseInt(4);
-
- var floorValues:int = 0;
-
- xList = Vector.<int>([0, 1<<rangeBits]);
-
- for (i = 0; i < partitions; i++) {
- for (j = 0; j < classDimensions[partitionClassList[i]]; j++) {
- xList.push(source.readUnsignedBitwiseInt(rangeBits));
- }
- }
-
- lowNeighbours = new Vector.<int>(xList.length);
- highNeighbours = new Vector.<int>(xList.length);
-
- for (i = 0; i < xList.length; i++) {
- lowNeighbours[i] = Util.lowNeighbour(xList, i);
- highNeighbours[i] = Util.highNeighbour(xList, i);
- }
-
- xList2 = new Vector.<int>(xList.length, true);
- step2Flags = new Vector.<Boolean>(xList.length, true);
- }
-
- public override function get type():int {
- return 1;
- }
-
- public override function decodeFloor(vorbis:VorbisStream, source:BitByteArray):Floor1 {
-
- var i:int;
- var j:int;
- var offset:int;
-
- if (!source.readBit()) {
- return null;
- }
-
- var clone:Floor1 = clone();
-
- clone.yList = new Vector.<int>(xList.length);
-
- var range:int = RANGES[multiplier - 1];
-
- clone.yList[0] = source.readUnsignedBitwiseInt(Util.ilog(range - 1));
- clone.yList[1] = source.readUnsignedBitwiseInt(Util.ilog(range - 1));
-
- offset = 2;
-
- for (i = 0; i < partitionClassList.length; i++) {
- var cls:int = partitionClassList[i];
- var cdim:int = classDimensions[cls];
- var cbits:int = classSubclasses[cls];
- var csub:int = (1 << cbits) - 1;
- var cval:int = 0;
- if (cbits > 0) {
- cval = source.readUnsignedHuffmanInt(vorbis.setupHeader.codeBooks[classMasterbooks[cls]].huffmanRoot);
- }
-
- for (j = 0; j < cdim; j++) {
- var book:int = subclassBooks[cls][cval & csub];
- cval >>>= cbits;
- if (book >= 0) {
- clone.yList[j + offset] = source.readUnsignedHuffmanInt(vorbis.setupHeader.codeBooks[book].huffmanRoot);
- } else {
- clone.yList[j + offset] = 0;
- }
- }
- offset += cdim;
- }
-
- return clone;
- }
-
- public override function computeFloor(vector:Vector.<Number>):void {
-
- var i:int;
- var j:int;
-
- var n:int = vector.length;
- var values:int = xList.length;
- //var step2Flags:Vector.<Boolean> = new Vector.<Boolean>(values);
-
- var range:int = RANGES[multiplier - 1];
-
- for (i = 2; i < values; i++) {
-
- var lowNeighbourOffset:int = lowNeighbours[i];
- var highNeighbourOffset:int = highNeighbours[i];
-
- var predicted:int = Util.renderPoint(
- xList[lowNeighbourOffset], xList[highNeighbourOffset],
- yList[lowNeighbourOffset], yList[highNeighbourOffset], xList[i]);
-
- var val:int = yList[i];
- var highRoom:int = range - predicted;
- var lowRoom:int = predicted;
- var room:int = highRoom < lowRoom ? highRoom * 2 : lowRoom * 2;
-
- if (val != 0) {
- step2Flags[lowNeighbourOffset] = true;
- step2Flags[highNeighbourOffset] = true;
- step2Flags[i] = true;
- if (val >= room) {
- yList[i] = highRoom > lowRoom ? val - lowRoom + predicted
- : -val + highRoom + predicted - 1;
- } else {
- yList[i] = (val & 1) == 1 ? predicted - ((val + 1) >> 1)
- : predicted + (val >> 1);
- }
- } else {
- step2Flags[i] = false;
- yList[i] = predicted;
- }
- }
-
- for(i=0; i<xList.length; i++) {
- xList2[i] = xList[i];
- }
-
- sort(xList2, yList, step2Flags);
-
- var hx:int = 0;
- var hy:int = 0;
- var lx:int = 0;
- var ly:int = yList[0] * multiplier;
-
- for (i = 1; i < values; i++) {
- if (step2Flags[i]) {
- hy = yList[i] * multiplier;
- hx = xList2[i];
- Util.renderLine(lx, ly, hx, hy, vector);
- lx = hx;
- ly = hy;
- }
- }
-
- var r:Number = DB_STATIC_TABLE[hy];
-
- while(hx < n/2) {
- vector[hx++] = r;
- }
-
- }
-
- public function clone():Floor1 {
- var clone:Floor1 = new Floor1();
- clone.classDimensions = classDimensions;
- clone.classMasterbooks = classMasterbooks;
- clone.classSubclasses = classSubclasses;
- clone.maximumClass = maximumClass;
- clone.multiplier = multiplier;
- clone.partitionClassList = partitionClassList;
- clone.rangeBits = rangeBits;
- clone.subclassBooks = subclassBooks;
- clone.xList = xList;
- clone.yList = yList;
- clone.lowNeighbours = lowNeighbours;
- clone.highNeighbours = highNeighbours;
- clone.xList2 = xList2;
- clone.step2Flags = step2Flags;
- return clone;
- }
-
- private function sort(x:Vector.<int>, y:Vector.<int>, b:Vector.<Boolean>):void {
- var off:int = 0;
- var len:int = x.length;
- var lim:int = len + off;
- var itmp:int;
- var btmp:Boolean;
- var i:int;
- var j:int;
- // Insertion sort on smallest arrays
- for (i = off; i < lim; i++) {
- for (j = i; j > off && x[j - 1] > x[j]; j--) {
- itmp = x[j];
- x[j] = x[j - 1];
- x[j - 1] = itmp;
- itmp = y[j];
- y[j] = y[j - 1];
- y[j - 1] = itmp;
- btmp = b[j];
- b[j] = b[j - 1];
- b[j - 1] = btmp;
- }
- }
- }
-
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.vorbis {
-
- import flash.utils.ByteArray;
-
- public class IdentificationHeader {
-
- private var _version:uint;
- private var _channels:uint;
- private var _sampleRate:uint;
- private var _bitrateMaximum:int;
- private var _bitrateMinimum:int;
- private var _bitrateNominal:int;
- private var _blockSize0:uint;
- private var _blockSize1:uint;
-
- private var _mdct:Vector.<Mdct>;
-
- public function IdentificationHeader(source:ByteArray) {
-
- source.readByte();
- source.readByte();
- source.readByte();
- source.readByte();
- source.readByte();
- source.readByte();
-
- _version = source.readUnsignedInt();
- _channels = source.readUnsignedByte();
- _sampleRate = source.readUnsignedInt();
- _bitrateMaximum = source.readUnsignedInt();
- _bitrateNominal = source.readUnsignedInt();
- _bitrateMinimum = source.readUnsignedInt();
- var bs:int = source.readUnsignedByte();
- _blockSize0 = 1<<(bs&0xf);
- _blockSize1 = 1<<(bs>>4);
-
- _mdct = new Vector.<Mdct>(2, false);
- _mdct[0] = new Mdct(_blockSize0);
- _mdct[1] = new Mdct(_blockSize1);
- }
-
- public function get channels():uint {
- return _channels;
- }
-
- public function get sampleRate():uint {
- return _sampleRate;
- }
-
- public function get blockSize0():uint {
- return _blockSize0;
- }
-
- public function get blockSize1():uint {
- return _blockSize1;
- }
-
- public function get mdct0():Mdct {
- return _mdct[0];
- }
-
- public function get mdct1():Mdct {
- return _mdct[1];
- }
-
- }
-
-
-}
\ No newline at end of file
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.vorbis {
-
- import org.omtk.util.BitByteArray;
-
- public class Look {
-
- private var _map:int;
- private var _parts:int;
- private var _stages:int;
- private var _fullbooks:Vector.<CodeBook>;
- private var _phrasebook:CodeBook;
- private var _partbooks:Vector.<Vector.<int>>;
- private var _partvals:int;
- private var _decodemap:Vector.<Vector.<int>>;
- private var _postbits:int;
- private var _phrasebits:int;
- private var _frames:int;
-
- public function Look(source:VorbisStream, residue:Residue, mode:Mode) {
-
- var i:int;
- var j:int;
- var k:int;
-
- var dim:int = 0;
- var acc:int = 0;
- var maxstage:int = 0;
-
- _map = mode.mapping;
-
- _parts = residue.classifications;
- _fullbooks = source.setupHeader.codeBooks;
- _phrasebook = _fullbooks[residue.classBook];
- dim = _phrasebook.dimensions;
-
- _partbooks = new Vector.<Vector.<int>>(_parts);
-
- for (j = 0; j < _parts; j++) {
- var s:int = Util.ilog(residue.cascade[j]);
- if (s != 0) {
- if (s > maxstage) {
- maxstage = s;
- }
- _partbooks[j] = new Vector.<int>(s);
- for (k = 0; k < s; k++) {
- if ((residue.cascade[j] & (1 << k)) != 0) {
- _partbooks[j][k] = residue.books[j][k];
- }
- }
- }
- }
-
- _partvals = Math.round(Math.pow(_parts, dim));
- _stages = maxstage;
-
- _decodemap = new Vector.<Vector.<int>>(_partvals, true);
-
- for (j = 0; j < _partvals; j++) {
- var val:int = j;
- var mult:int = _partvals / _parts;
- _decodemap[j] = new Vector.<int>(dim);
-
- for (k = 0; k < dim; k++) {
- var deco:int = val / mult;
- val -= deco * mult;
- mult /= _parts;
- _decodemap[j][k] = deco;
- }
- }
- }
-
- public function get map():int {
- return _map;
- }
-
- public function get parts():int {
- return _parts;
- }
-
- public function get stages():int {
- return _stages;
- }
-
- public function get fullbooks():Vector.<CodeBook> {
- return _fullbooks;
- }
-
- public function get phrasebook():CodeBook {
- return _phrasebook;
- }
-
- public function get partbooks():Vector.<Vector.<int>> {
- return _partbooks;
- }
-
- public function get partvals():int {
- return _partvals;
- }
-
- public function get decodemap():Vector.<Vector.<int>> {
- return _decodemap;
- }
-
- public function get postbits():int {
- return _postbits;
- }
-
- public function get phrasebits():int {
- return _phrasebits;
- }
-
- public function get frames():int {
- return _frames;
- }
-
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.vorbis {
-
- import flash.errors.IllegalOperationError;
- import org.omtk.util.BitByteArray;
-
- public class Mapping {
-
- public static function createInstance(stream:VorbisStream, source:BitByteArray, header:SetupHeader):Mapping {
-
- var type:int = source.readUnsignedBitwiseInt(16);
- switch (type) {
- case 0:
- return new Mapping0(stream, source, header);
- default:
- throw new Error("Mapping type " + type + " is not supported.");
- }
-
- }
-
- public function get type():int {
- throw new IllegalOperationError("not implemented");
- }
-
- public function get couplingSteps():int {
- throw new IllegalOperationError("not implemented");
- }
-
- public function get submaps():int {
- throw new IllegalOperationError("not implemented");
- }
-
- public function get angles():Vector.<int> {
- throw new IllegalOperationError("not implemented");
- }
-
- public function get magnitudes():Vector.<int> {
- throw new IllegalOperationError("not implemented");
- }
-
- public function get mux():Vector.<int> {
- throw new IllegalOperationError("not implemented");
- }
-
- public function get submapFloors():Vector.<int> {
- throw new IllegalOperationError("not implemented");
- }
-
- public function get submapResidues():Vector.<int> {
- throw new IllegalOperationError("not implemented");
- }
-
-
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.vorbis {
-
- import flash.errors.IllegalOperationError;
- import org.omtk.util.BitByteArray;
-
- public class Mapping0 extends Mapping {
-
- private var _magnitudes:Vector.<int>;
- private var _angles:Vector.<int>;
- private var _mux:Vector.<int>;
- private var _submapFloors:Vector.<int>;
- private var _submapResidues:Vector.<int>;
-
- public function Mapping0(stream:VorbisStream, source:BitByteArray, header:SetupHeader) {
-
- var i:int;
- var j:int;
-
- var submaps:int = 1;
-
- if (source.readBit()) {
- submaps = source.readUnsignedBitwiseInt(4) + 1;
- }
-
- var channels:int = stream.identificationHeader.channels;
- var ilogChannels:int = Util.ilog(channels - 1);
-
- if (source.readBit()) {
- var couplingSteps:int = source.readUnsignedBitwiseInt(8) + 1;
- _magnitudes = new Vector.<int>(couplingSteps);
- _angles = new Vector.<int>(couplingSteps);
-
- for (i = 0; i < couplingSteps; i++) {
- magnitudes[i] = source.readUnsignedBitwiseInt(ilogChannels);
- angles[i] = source.readUnsignedBitwiseInt(ilogChannels);
- if (magnitudes[i] == angles[i] || magnitudes[i] >= channels
- || angles[i] >= channels) {
- throw new Error("The channel magnitude and/or angle mismatch.");
- }
- }
- } else {
- _magnitudes = Vector.<int>([]);
- _angles = Vector.<int>([]);
- }
-
- if (source.readUnsignedBitwiseInt(2) != 0) {
- throw new Error("A reserved mapping field has an invalid value.");
- }
-
- _mux = new Vector.<int>(channels);
- if (submaps > 1) {
- for (i = 0; i < channels; i++) {
- _mux[i] = source.readUnsignedBitwiseInt(4);
- if (_mux[i] > submaps) {
- throw new Error("A mapping mux value is higher than the number of submaps");
- }
- }
- } else {
- for (i = 0; i < channels; i++) {
- _mux[i] = 0;
- }
- }
-
- _submapFloors = new Vector.<int>(submaps);
- _submapResidues = new Vector.<int>(submaps);
-
- var floorCount:int = header.floors.length;
- var residueCount:int = header.residues.length;
-
- for (i = 0; i < submaps; i++) {
- source.readUnsignedBitwiseInt(8); // discard time placeholder
- _submapFloors[i] = source.readUnsignedBitwiseInt(8);
- _submapResidues[i] = source.readUnsignedBitwiseInt(8);
-
- if (_submapFloors[i] > floorCount) {
- throw new Error("A mapping floor value is higher than the number of floors.");
- }
-
- if (_submapResidues[i] > residueCount) {
- throw new Error("A mapping residue value is higher than the number of residues.");
- }
- }
- }
-
- public override function get type():int {
- return 0;
- }
-
- public override function get couplingSteps():int {
- return _angles.length;
- }
-
- public override function get submaps():int {
- return _submapFloors.length;
- }
-
- public override function get angles():Vector.<int> {
- return _angles;
- }
-
- public override function get magnitudes():Vector.<int> {
- return _magnitudes;
- }
-
- public override function get mux():Vector.<int> {
- return _mux;
- }
-
- public override function get submapFloors():Vector.<int> {
- return _submapFloors;
- }
-
- public override function get submapResidues():Vector.<int> {
- return _submapResidues;
- }
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.vorbis {
-
- import flash.events.*;
- import flash.system.*;
- import flash.display.*;
- import flash.net.*;
- import flash.utils.getTimer;
-
- /*
- * Wrapper for the haXe compiled class org.omtk.vorbis.MdctHX
- */
- public class Mdct {
-
- public static var initialized : Boolean = false;
- private static var hxClass : Class;
-
- public static function initialize() : void {
- var ldr:Loader = new Loader();
- var swfUrl:String = "hxmdct.swf";
- var req:URLRequest = new URLRequest(swfUrl);
- var ldrContext:LoaderContext =
- new LoaderContext(false, ApplicationDomain.currentDomain);
- ldr.load(req, ldrContext);
- ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoaded);
-
- function swfLoaded(e:Event):void {
- hxClass = ApplicationDomain.currentDomain.getDefinition("org.omtk.vorbis.MdctHX") as Class;
- initialized = true;
- }
- }
-
- private var delegate : Object;
-
- public function Mdct(n:int) {
- delegate = new hxClass(n);
- }
-
- public function imdct(frq:Vector.<Number>, window:Vector.<Number>, pcm:Vector.<Number>):void {
- delegate.imdct(frq, window, pcm);
- }
-
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.vorbis {
-
- import flash.errors.IllegalOperationError;
- import flash.utils.Dictionary;
- import org.omtk.util.BitByteArray;
-
- public class Mode
- {
- private var _blockFlag:Boolean;
- private var _windowType:uint;
- private var _transformType:uint;
- private var _mapping:uint;
-
- public function Mode(source:BitByteArray, header:SetupHeader) {
-
- _blockFlag=source.readBit();
- _windowType=source.readUnsignedBitwiseInt(16);
- _transformType=source.readUnsignedBitwiseInt(16);
- _mapping=source.readUnsignedBitwiseInt(8);
-
- if(_windowType!=0) {
- throw new Error("Window type = "+windowType+", != 0");
- }
-
- if(_transformType!=0) {
- throw new Error("Transform type = "+transformType+", != 0");
- }
-
- if(_mapping > header.mappings.length) {
- throw new Error("Mode mapping number is higher than total number of mappings.");
- }
- }
-
- public function get blockFlag():Boolean {
- return _blockFlag;
- }
-
- public function get windowType():uint {
- return _windowType;
- }
-
- public function get transformType():uint {
- return _transformType;
- }
-
- public function get mapping():uint {
- return _mapping;
- }
-
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.vorbis {
-
- import flash.errors.IllegalOperationError;
- import flash.utils.Dictionary;
- import org.omtk.util.BitByteArray;
-
- public class Residue {
-
- private var _begin:int;
- private var _end:int;
- private var _partitionSize:int;
- private var _classifications:int;
- private var _classBook:int;
- private var _cascade:Vector.<int>;
- private var _books:Vector.<Vector.<int>>;
-
- private var _looks:Dictionary;
-
-
- public function Residue(source:BitByteArray, header:SetupHeader) {
-
- _begin = source.readUnsignedBitwiseInt(24);
- _end = source.readUnsignedBitwiseInt(24);
- _partitionSize = source.readUnsignedBitwiseInt(24) + 1;
- _classifications = source.readUnsignedBitwiseInt(6) + 1;
- _classBook = source.readUnsignedBitwiseInt(8);
-
- _cascade = new Vector.<int>(classifications);
-
- var acc:int = 0;
- var i:int;
- var j:int;
-
- for (i = 0; i < classifications; i++) {
- var highBits:int = 0;
- var lowBits:int = 0;
-
- lowBits = source.readUnsignedBitwiseInt(3);
- if (source.readBit()) {
- highBits = source.readUnsignedBitwiseInt(5);
- }
- _cascade[i] = (highBits << 3) | lowBits;
- acc += Util.icount(cascade[i]);
- }
-
- _books = new Vector.<Vector.<int>>(classifications);
-
- for (i = 0; i < classifications; i++) {
- books[i] = new Vector.<int>(8);
- for (j = 0; j < 8; j++) {
- if ((cascade[i] & (1 << j)) != 0) {
- books[i][j] = source.readUnsignedBitwiseInt(8);
- if (books[i][j] > header.codeBooks.length) {
- throw new Error(
- "Reference to invalid codebook entry in residue header.");
- }
- }
- }
- }
-
- _looks = new Dictionary();
- }
-
- public static function createInstance(source:BitByteArray, header:SetupHeader):Residue {
-
- var type:int = source.readUnsignedBitwiseInt(16);
- switch (type) {
- case 2:
- return new Residue2(source, header);
- default:
- throw new Error("Residue type " + type + " is not supported.");
- }
- }
-
- public function decodeResidue(
- vorbis:VorbisStream, source:BitByteArray,
- mode:Mode, ch:int,
- doNotDecodeFlags:Vector.<Boolean>, vectors0:Vector.<Number>, vectors1:Vector.<Number>):void {
-
- throw new IllegalOperationError("not implemented");
- }
-
-
- public function getLook(stream:VorbisStream, key:Mode):Look {
- var look:Look = _looks[key];
- if (look == null) {
- look = new Look(stream, this, key);
- _looks[key] = look;
- }
- return new Look(stream, this, key);//look;
- }
-
-
- public function get begin():int {
- return _begin;
- }
-
- public function get end():int {
- return _end;
- }
-
- public function get partitionSize():int {
- return _partitionSize;
- }
-
- public function get classifications():int {
- return _classifications;
- }
-
- public function get classBook():int {
- return _classBook;
- }
-
- public function get cascade():Vector.<int> {
- return _cascade;
- }
-
- public function get books():Vector.<Vector.<int>> {
- return _books;
- }
-
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.vorbis {
-
- import flash.errors.IllegalOperationError;
- import flash.utils.Dictionary;
- import org.omtk.util.BitByteArray;
-
- public class Residue2 extends Residue {
-
- public function Residue2(source:BitByteArray, header:SetupHeader) {
- super(source, header);
- }
-
- public override function decodeResidue(
- vorbis:VorbisStream, source:BitByteArray,
- mode:Mode, ch:int,
- doNotDecodeFlags:Vector.<Boolean>, vectors0:Vector.<Number>, vectors1:Vector.<Number>):void {
-
- var i:int;
- var j:int;
- var k:int;
- var l:int;
- var s:int;
- var slim:int;
-
- var look:Look = getLook(vorbis, mode);
-
- var codeBook:CodeBook = vorbis.setupHeader.codeBooks[classBook];
-
- var classvalsPerCodeword:int = codeBook.dimensions;
- var nToRead:int = end - begin;
- var partitionsToRead:int = nToRead / partitionSize; // partvals
-
- var samplesPerPartition:int = partitionSize;
- var partitionsPerWord:int = look.phrasebook.dimensions;
-
- var partWords:int = (partitionsToRead + partitionsPerWord - 1) / partitionsPerWord;
-
- var offset:int;
-
- var left:Boolean = false;
- var right:Boolean = false;
-
- for (i = 0; i < doNotDecodeFlags.length; i++) {
- if (!doNotDecodeFlags[i]) {
- if(i==0) {
- left = true;
- }
- else if (i==1) {
- right = true;
- }
- }
- }
-
- var partword:Array = new Array(partWords);
-
- var pb:int = source.position;
-
- slim = look.stages;
- for (s = 0; s < slim; s++) {
-
- for (i = 0, l = 0; i < partitionsToRead; l++) {
-
- if (s == 0) {
- var temp:int = source.readUnsignedHuffmanInt(look.phrasebook.huffmanRoot);
- if (temp == -1) {
- throw new Error("Foo??");
- }
- partword[l] = look.decodemap[temp];
- if (partword[l] == null) {
- throw new Error("Foo??");
- }
- }
-
- for (k = 0; k < partitionsPerWord && i < partitionsToRead; k++, i++) {
- offset = begin + i * samplesPerPartition;
-
- if ((cascade[partword[l][k]] & (1 << s)) != 0) {
- var stagebook:CodeBook =
- vorbis.setupHeader.codeBooks[look.partbooks[partword[l][k]][s]];
- if (stagebook != null) {
- stagebook.readVvAdd(vectors0, vectors1, left, right, source, offset, samplesPerPartition);
- }
- }
- }
- }
- }
-
- }
-
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.vorbis {
-
- import org.omtk.util.BitByteArray;
-
- public class SetupHeader {
-
- private var _codeBooks:Vector.<CodeBook>;
- private var _floors:Vector.<Floor>;
- private var _residues:Vector.<Residue>;
- private var _mappings:Vector.<Mapping>;
- private var _modes:Vector.<Mode>;
-
- public function SetupHeader(stream:VorbisStream, source:BitByteArray) {
-
- var i:int;
-
- source.readByte();
- source.readByte();
- source.readByte();
- source.readByte();
- source.readByte();
- source.readByte();
-
- var codeBookCount:uint = source.readUnsignedBitwiseInt(8)+1;
- _codeBooks = new Vector.<CodeBook>(codeBookCount);
-
- for(i = 0; i < codeBookCount; i++) {
- _codeBooks[i] = new CodeBook(source);
- }
-
- // read the time domain transformations,
- // these should all be 0
-
- var timeCount:int = source.readUnsignedBitwiseInt(6) + 1;
- for (i = 0; i < timeCount; i++) {
- if (source.readUnsignedBitwiseInt(16) != 0) {
- throw new Error(
- "Time domain transformation != 0");
- }
- }
-
- // read floor entries
-
- var floorCount:int = source.readUnsignedBitwiseInt(6) + 1;
- _floors = new Vector.<Floor>(floorCount);
-
- for (i = 0; i < floorCount; i++) {
- _floors[i] = Floor.createInstance(source, this);
- }
-
- var residueCount:int = source.readUnsignedBitwiseInt(6) + 1;
- _residues = new Vector.<Residue>(residueCount);
-
- for (i = 0; i < residueCount; i++) {
- _residues[i] = Residue.createInstance(source, this);
- }
-
- var mappingCount:int = source.readUnsignedBitwiseInt(6) + 1;
- _mappings = new Vector.<Mapping>(mappingCount);
-
- for (i = 0; i < mappingCount; i++) {
- _mappings[i] = Mapping.createInstance(stream, source, this);
- }
-
- var modeCount:int = source.readUnsignedBitwiseInt(6) + 1;
- _modes = new Vector.<Mode>(modeCount);
-
- for (i = 0; i < modeCount; i++) {
- _modes[i] = new Mode(source, this);
- }
-
- if (!source.readBit()) {
- throw new Error("The setup header framing bit is incorrect.");
- }
- }
-
- public function get codeBooks():Vector.<CodeBook> {
- return _codeBooks;
- }
-
- public function get floors():Vector.<Floor> {
- return _floors;
- }
-
- public function get mappings():Vector.<Mapping> {
- return _mappings;
- }
-
- public function get residues():Vector.<Residue> {
- return _residues;
- }
-
- public function get modes():Vector.<Mode> {
- return _modes;
- }
-
- }
-
-
-}
\ No newline at end of file
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.vorbis {
-
- public class Util {
-
- public static function ilog(x:uint):uint {
- var res:int = 0;
- for(; x>0; x>>=1, res++);
- return res;
- }
-
- public static function float32unpack(x:uint):Number {
- var mantissa:Number = x&0x1fffff;
- var e:Number = (x&0x7fe00000)>>21;
- if((x&0x80000000)!=0) {
- mantissa=-mantissa;
- }
- return mantissa*Math.pow(2.0, e-788.0);
- }
-
- public static function lookup1Values(a:int, b:int):uint {
- var res:uint = Math.pow(Math.E, Math.log(a)/b);
- return intPow(res+1, b)<=a?res+1:res;
- }
-
- public static function intPow(base:uint, e:uint):uint {
- var res:uint = 1;
- for(; e>0; e--, res*=base);
- return res;
- }
-
- public static function isBitSet(value:uint, bit:uint):Boolean {
- return (value&(1<<bit))!=0;
- }
-
- public static function icount(value:uint):uint {
- var res:uint = 0;
- while (value > 0) {
- res += value & 1;
- value >>= 1;
- }
- return res;
- }
-
- public static function lowNeighbour(v:Vector.<int>, x:int):int {
-
- var max:int = -1;
- var n:int = 0;
- var i:int;
-
- for (i = 0; i < v.length && i < x; i++) {
- if (v[i] > max && v[i] < v[x]) {
- max = v[i];
- n = i;
- }
- }
- return n;
- }
-
- public static function highNeighbour(v:Vector.<int>, x:int):int {
-
- var min:int = int.MAX_VALUE;
- var n:int = 0;
- var i:int;
-
- for (i = 0; i < v.length && i < x; i++) {
- if (v[i] < min && v[i] > v[x]) {
- min = v[i];
- n = i;
- }
- }
- return n;
- }
-
- public static function renderPoint(x0:int, x1:int, y0:int, y1:int, x:int):int {
- return y0 + int(((y1-y0) * (x - x0)) / (x1 - x0));
- }
-
- public static function renderLine(x0:int, y0:int, x1:int, y1:int, v:Vector.<Number>):void {
-
- var dy:int = y1 - y0;
- var adx:int = x1 - x0;
- var b:int = dy / adx;
- var sy:int = dy < 0 ? b - 1 : b + 1;
- var x:int = x0;
- var y:int = y0;
- var err:int = 0;
- var ady:int = (dy < 0 ? -dy : dy) - (b > 0 ? b * adx : -b * adx);
-
- v[x] *= Floor.DB_STATIC_TABLE[y];
- for (x = x0 + 1; x < x1; x++) {
- err += ady;
- if (err >= adx) {
- err -= adx;
- v[x] *= Floor.DB_STATIC_TABLE[y += sy];
- } else {
- v[x] *= Floor.DB_STATIC_TABLE[y += b];
- }
- }
-
- }
-
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.vorbis {
-
- import flash.net.URLRequest;
- import flash.net.URLStream;
- import flash.utils.ByteArray;
- import flash.utils.Endian;
- import flash.events.Event;
- import flash.events.ProgressEvent;
- import flash.events.SampleDataEvent;
-
- import flash.external.ExternalInterface;
-
- import flash.media.Sound;
-
- import org.omtk.ogg.UncachedUrlStream;
- import org.omtk.ogg.EndOfOggStreamError;
- import flash.utils.setTimeout;
-
- public class VorbisSound extends Sound {
-
- public static var METADATA_UPDATE: String = "metadata_update";
-
- private var urlStream: URLStream;
-
- private var oggStream:UncachedUrlStream;
- private var vorbisStream:VorbisStream;
-
- private var bytesAvailable:int;
-
- private var initialized:Boolean = false;
- private var playing:Boolean = false;
-
- private var fill1:Boolean = true;
- private var fill2:Boolean = true;
-
- private var stopped: Boolean = false;
- private var completeEventDispatched: Boolean = false;
-
- public function VorbisSound(url: URLRequest ) {
- urlStream = new URLStream();
- urlStream.endian = Endian.LITTLE_ENDIAN;
- urlStream.load(url);
-
- Mdct.initialize();
-
- oggStream = new UncachedUrlStream(urlStream);
- oggStream.addEventListener('progress', progress);
- bytesAvailable = oggStream.bytesAvailable;
- addEventListener("sampleData", sampleGenerator);
- }
-
- private function initialize():void {
- vorbisStream = new VorbisStream(oggStream.getLogicalOggStream());
- setTimeout(dispatchEvent, 100, new Event(METADATA_UPDATE));
- initialized = true;
- }
-
- private var samplesPlayed: int = 0;
-
- private function sampleGenerator(event:SampleDataEvent):void {
-
- if(stopped) {
- return;
- }
-
- if(Mdct.initialized && !initialized && bytesAvailable > 64*1024) {
- initialize();
- }
-
- if(initialized && bytesAvailable > 16*1024 && !vorbisStream.finished) {
- var cnt: int;
- cnt = vorbisStream.readPcm(event.data);
- samplesPlayed += cnt;
- if(cnt < 2048 && oggStream.bytesAvailable > 0) {
- vorbisStream = new VorbisStream(oggStream.getLogicalOggStream());
- setTimeout(dispatchEvent, 100, new Event(METADATA_UPDATE));
- samplesPlayed += vorbisStream.readPcm(event.data);
- }
- }
- else if(vorbisStream == null || !vorbisStream.finished) {
- for(var c:int=0; c<2048; c++) {
- event.data.writeFloat(0);
- event.data.writeFloat(0);
- }
- }
-
- if(initialized && vorbisStream.finished && oggStream.bytesAvailable == 0 && !completeEventDispatched) {
- dispatchEvent(new Event(Event.COMPLETE));
- completeEventDispatched = true;
- }
-
- //trace("samples played: " + samplesPlayed + "/" + oggStream.bytesAvailable);
-
- }
-
- public function stop(): void {
- stopped = true;
- }
-
- public function progress(event:ProgressEvent):void {
- bytesAvailable = oggStream.bytesAvailable;
- }
-
- public function get position(): int {
- return samplesPlayed * 1000 / 44100;
- }
-
- public function getMetaData(key: String):String {
- if(vorbisStream != null) {
- return vorbisStream.commentHeader.comments[key];
- }
- else {
- return null;
- }
- }
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.vorbis {
-
- import flash.events.SampleDataEvent;
- import flash.utils.ByteArray;
- import flash.utils.Endian;
- import org.omtk.util.*;
- import org.omtk.ogg.*;
-
- public class VorbisStream {
-
- private const IDENTIFICATION_HEADER:int = 1;
- private const COMMENT_HEADER:int = 3;
- private const SETUP_HEADER:int = 5;
-
- private var source:LogicalOggStream;
-
- private var _identificationHeader:IdentificationHeader;
- private var _commentHeader:CommentHeader;
- private var _setupHeader:SetupHeader;
-
- private var _lastAudioPacket:AudioPacket;
-
- private var _currentGranulePosition:int=0;
- private var packetCounter:int;
-
- private var _finished: Boolean = false;
-
- public var windows:Vector.<Vector.<Number>> = new Vector.<Vector.<Number>>(8);
-
- public function VorbisStream(source:LogicalOggStream) {
-
- this.source = source;
-
- for (var i:int = 0; i < 3; i++) {
-
- var data:BitByteArray = source.getNextOggPacket().data;
- var headerType:int = data.readUnsignedByte();
-
- switch(headerType) {
- case IDENTIFICATION_HEADER:
- _identificationHeader = new IdentificationHeader(data);
- break;
- case COMMENT_HEADER:
- _commentHeader = new CommentHeader(data);
- break;
- case SETUP_HEADER:
- _setupHeader = new SetupHeader(this, data);
- break;
- }
- }
-
- }
-
- public function get identificationHeader():IdentificationHeader {
- return _identificationHeader;
- }
-
- public function get commentHeader():CommentHeader {
- return _commentHeader;
- }
-
- public function get setupHeader():SetupHeader {
- return _setupHeader;
- }
-
- public function readPcm(data:ByteArray): int {
-
- var total:int;
- var i:int;
-
- if(_lastAudioPacket == null) {
- _lastAudioPacket = getNextAudioPacket();
- }
-
- total = 0;
-
- while(total < 2048 && !_finished) {
- try {
- var ap:AudioPacket = getNextAudioPacket();
- total += ap.readPcm(_lastAudioPacket, data);
- _lastAudioPacket = ap;
- }
- catch(e: EndOfOggStreamError) {
- // ok, stream finished
- _finished = true;
- }
- }
-
- return total;
- }
-
- private function getNextAudioPacket():AudioPacket {
- packetCounter++;
- var packet:OggPacket = source.getNextOggPacket();
- var res:AudioPacket = new AudioPacket(this, packet, _currentGranulePosition);
- if(_lastAudioPacket != null) {
- // don't count the first packet, since it doesn't contain any "real" samples
- _currentGranulePosition += res.numberOfSamples;
- }
- return res;
- }
-
- public function get finished() : Boolean {
- return _finished;
- }
-
- public function get currentGranulePosition(): int {
- return _currentGranulePosition;
- }
- }
-
-}
\ No newline at end of file
+++ /dev/null
--main org.omtk.vorbis.MdctHX
--swf-version 10
--swf hxmdct.swf
+++ /dev/null
-/*
-
-Copyright 2008 Tor-Einar Jarnbjo
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.omtk.vorbis;
-
-import flash.Vector;
-
-class MdctHX {
-
- private static var cPI1_8:Float = 0.92387953251128675613;
- private static var cPI2_8:Float = 0.70710678118654752441;
- private static var cPI3_8:Float = 0.38268343236508977175;
-
- private var n:Int;
- private var log2n:Int;
- private var trig:Vector<Float>;
- private var bitrev:Vector<Int>;
-
- private var dtmp1:Float;
- private var dtmp2:Float;
- private var dtmp3:Float;
- private var dtmp4:Float;
-
- private var x:Vector<Float>;
- private var w:Vector<Float>;
-
- public function new(n:Int) {
- this.n = n;
-
- var i:Int;
- var j:Int;
-
- bitrev = new Vector<Int>();
- trig = new Vector<Float>(Std.int(n+n/4), true);
-
- for(i in 0...Std.int(n+n/4)) {
- trig[i] = 0;
- }
-
- x = new Vector<Float>(Std.int(n/2), true);
- w = new Vector<Float>(Std.int(n/2), true);
-
- for(i in 0...Std.int(n/2)) {
- x[i] = 0;
- w[i] = 0;
- }
-
- var n2:Int = n >>> 1;
- log2n = Math.round(Math.log(n) / Math.log(2));
-
- var AE:Int = 0;
- var AO:Int = 1;
- var BE:Int = Std.int(AE + n / 2);
- var BO:Int = BE + 1;
- var CE:Int = Std.int(BE + n / 2);
- var CO:Int = CE + 1;
-
- for (i in 0...Std.int(n/4)) {
- trig[AE + i * 2] = Math.cos((Math.PI / n) * (4 * i));
- trig[AO + i * 2] = -Math.sin((Math.PI / n) * (4 * i));
- trig[BE + i * 2] = Math.cos((Math.PI / (2 * n)) * (2 * i + 1));
- trig[BO + i * 2] = Math.sin((Math.PI / (2 * n)) * (2 * i + 1));
- }
-
- for (i in 0...Std.int(n/8)) {
- trig[CE + i * 2] = Math.cos((Math.PI / n) * (4 * i + 2));
- trig[CO + i * 2] = -Math.sin((Math.PI / n) * (4 * i + 2));
- }
-
- var mask:Int = (1 << (log2n - 1)) - 1;
- var msb:Int = 1 << (log2n - 2);
-
- for (i in 0...Std.int(n/8)) {
- var acc:Int = 0;
- j = 0;
- while(msb>>>j!=0) {
- if (((msb >>> j) & i) != 0) {
- acc |= 1 << j;
- }
- j++;
- }
- bitrev[i * 2] = ((~acc) & mask);
- bitrev[i * 2 + 1] = acc;
- }
-
- }
-
- public function imdct(frq:Vector<Float>, window:Vector<Float>, pcm:Vector<Float>):Void {
-
- var i:Int;
-
- var n2:Int;
- var n4:Int;
- var n8:Int;
-
- var inO:Int;
- var xO:Int;
- var A:Int;
-
- var temp1:Float;
- var temp2:Float;
-
- var B:Int;
- var o1:Int;
- var o2:Int;
- var o3:Int;
- var o4:Int;
-
- var xx:Int;
- var xxx:Vector<Float>;
-
- n2 = n >> 1;
- n4 = n >> 2;
- n8 = n >> 3;
-
- inO = -1;
- xO = 0;
- A = n2;
-
- temp1 = 0.0;
- temp2 = 0.0;
-
- for (i in 0...n8) {
- dtmp1 = frq[inO += 2];
- dtmp2 = frq[inO += 2];
- dtmp3 = trig[--A];
- dtmp4 = trig[--A];
- x[xO++] = -dtmp2 * dtmp3 - dtmp1 * dtmp4;
- x[xO++] = dtmp1 * dtmp3 - dtmp2 * dtmp4;
- }
-
- inO = n2;
-
- for(i in 0...n8) {
- dtmp1 = frq[inO -= 2];
- dtmp2 = frq[inO -= 2];
- dtmp3 = trig[--A];
- dtmp4 = trig[--A];
- x[xO++] = dtmp2 * dtmp3 + dtmp1 * dtmp4;
- x[xO++] = dtmp2 * dtmp4 - dtmp1 * dtmp3;
- }
-
- xxx = kernel(x, w, n, n2, n4, n8);
- xx = 0;
-
- B = n2;
- o1 = n4;
- o2 = o1 - 1;
- o3 = n4 + n2;
- o4 = o3 - 1;
-
- for (i in 0...n4) {
- dtmp1 = xxx[xx++];
- dtmp2 = xxx[xx++];
- dtmp3 = trig[B++];
- dtmp4 = trig[B++];
-
- temp1 = (dtmp1 * dtmp4 - dtmp2 * dtmp3);
- temp2 = -(dtmp1 * dtmp3 + dtmp2 * dtmp4);
-
- pcm[o1] = -temp1 * window[o1];
- pcm[o2] = temp1 * window[o2];
- pcm[o3] = temp2 * window[o3];
- pcm[o4] = temp2 * window[o4];
-
- o1++;
- o2--;
- o3++;
- o4--;
- }
-
- }
-
- private inline function kernel(x:Vector<Float>, w:Vector<Float>, n:Int, n2:Int, n4:Int, n8:Int):Vector<Float> {
-
- var i:Int;
- var r:Int;
- var s:Int;
- var rlim:Int;
- var slim:Int;
-
- var xA:Int = n4;
- var xB:Int = 0;
- var w1:Int = 0;
- var w2:Int = n4;
- var A:Int = n2;
-
- var x0:Float;
- var x1:Float;
- var wA:Float;
- var wB:Float;
- var wC:Float;
- var wD:Float;
- var k0:Int;
- var k1:Int;
- var t1:Int;
- var t2:Int;
-
- var wbase:Int;
- var temp:Vector<Float>;
-
- var wACE:Float;
- var wBCE:Float;
- var wACO:Float;
- var wBCO:Float;
-
- var AEv:Float;
- var AOv:Float;
-
- i=0;
- while(i < n4) {
- x0 = x[xA] - x[xB];
-
- w[w2 + i] = x[xA++] + x[xB++];
-
- x1 = x[xA] - x[xB];
- A -= 4;
-
- w[i++] = x0 * trig[A] + x1 * trig[A + 1];
- w[i] = x1 * trig[A] - x0 * trig[A + 1];
-
- w[w2 + i] = x[xA++] + x[xB++];
- i++;
- }
-
- for (i in 0...log2n-3) {
- k0 = n >>> (i + 2);
- k1 = 1 << (i + 3);
- wbase = n2 - 2;
-
- A = 0;
-
- rlim = k0 >>> 2;
- for (r in 0...rlim) {
-
- w1 = wbase;
- w2 = w1 - (k0 >> 1);
- AEv = trig[A];
- AOv = trig[A + 1];
- wbase -= 2;
-
- k0++;
-
- slim = 2 << i;
- for (s in 0...slim) {
- dtmp1 = w[w1];
- dtmp2 = w[w2];
- wB = dtmp1 - dtmp2;
- x[w1] = dtmp1 + dtmp2;
- dtmp1 = w[++w1];
- dtmp2 = w[++w2];
- wA = dtmp1 - dtmp2;
- x[w1] = dtmp1 + dtmp2;
- x[w2] = wA * AEv - wB * AOv;
- x[w2-1] = wB * AEv + wA * AOv;
- w1 -= k0;
- w2 -= k0;
- }
- k0--;
- A += k1;
- }
-
- temp = w;
- w = x;
- x = temp;
- }
-
-
- var C:Int = n;
- var bit:Int = 0;
- var xx1:Int = 0;
- var xx2:Int = n2 - 1;
-
- var wt1: Float;
- var wt2: Float;
- var wt12: Float;
- var wt21: Float;
- var trigV: Float;
-
- for (i in 0...n8) {
- t1 = bitrev[bit++];
- t2 = bitrev[bit++];
-
- wt1 = w[t1];
- wt2 = w[t2];
- wt12 = w[t1-1];
- wt21 = w[t2+1];
-
- wA = wt1 - wt21;
- wB = wt12 + wt2;
- wC = wt1 + wt21;
- wD = wt12 - wt2;
-
- trigV = trig[C];
-
- wACE = wA * trigV;
- wBCE = wB * trigV;
-
- trigV = trig[++C];
-
- wACO = wA * trigV;
- wBCO = wB * trigV;
-
- ++C;
-
- x[xx1++] = (wC + wACO + wBCE);
- x[xx2--] = (-wD + wBCO - wACE);
- x[xx1++] = (wD + wBCO - wACE);
- x[xx2--] = (wC - wACO - wBCE);
- }
-
- return x;
- }
-
- /*
- * Dummy function required for the haXe compiler to build this to
- * a .SWF file.
- */
- public static function main() : Void {
- }
-
-}
--- /dev/null
+This version of cortado comes form http://theora.org/cortado.jar
--- /dev/null
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
\ No newline at end of file
--- /dev/null
+Version history:
+
+RC2
+---
+- fixed: setting the screen height in configuration did not have any effect
+
+RC1
+-----
+- better error message if plugin loading fails, shows the URL used
+- validates our redesigned multidomain license key correctly
+- fix to prevent the play button going visible when the onBufferEmpty event occurs
+- the commercial swf now correctly loads the controls using version information
+- fixed: the play button overlay became invisible with long fadeOutSpeeds
+
+beta6
+-----
+- removed the onFirstFramePause event
+- playing a clip for the second time caused a doubled sound
+- pausing on first frame did not work on some FLV files
+
+beta5
+-----
+- logo only uses percentage scaling if it's a SWF file (there is ".swf" in it's url)
+- context menu now correctly builds up from string entries in configuration
+-always closes the previous connection before starting a new clip
+
+beta4
+-----
+- now it's possible to load a plugin into the panel without specifying any position/dimensions
+ information, the plugin is placed to left: "50%", top: "50%" and using the plugin DisplayObject's width & height
+- The Flowplayer API was not fully initialized when onLoad was invoked on Flash plugins
+
+beta3
+-----
+- tweaking logo placement
+- "play" did not show up after repeated pause/resume
+- player now loads the latest controls SWF version, right now the latest SWF is called 'flowplayer.controls-3.0.0-beta2.swf'
+
+beta2
+-----
+- fixed support for RTMP stream groups
+- changed to loop through available fonts in order to find a suitable font also in IE
+- Preloader was broken on IE: When the player SWf was in browser's cache it did not initialize properly
+- Context menu now correctly handles menu items that are configured by their string labels only (not using json objects)
+- fixed custom logo positioning (was moved to the left edge of screen in fullscreen)
+- "play" now always follows the position and size of the screen
+- video was stretched below the controls in fullscreen when autoHide: 'never'
+- logo now takes 6.5% of the screen height, width is scaled so that the aspect ratio is preserved
+
+beta1
+-----
+- First public beta release
--- /dev/null
+/**
+ * flowplayer.js 3.0.0-rc2. The Flowplayer API.
+ *
+ * This file is part of Flowplayer, http://flowplayer.org
+ *
+ * Author: Tero Piirainen, <support@flowplayer.org>
+ * Copyright (c) 2008 Flowplayer Ltd
+ *
+ * Released under the MIT License:
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ * Version: 3.0.0-rc2 - Fri Nov 07 2008 16:50:59 GMT-0000 (GMT+00:00)
+ */
+(function() {
+
+/*
+ FEATURES
+ --------
+ - handling multiple instances
+ - Flowplayer programming API
+ - Flowplayer event model
+ - player loading / unloading
+ - $f() function
+ - jQuery support
+*/
+
+
+/*jslint glovar: true, browser: true */
+/*global flowplayer, $f */
+
+// {{{ private utility methods
+
+ function log(args) {
+
+ // write into opera console
+ if (typeof opera == 'object') {
+ opera.postError("$f.fireEvent: " + args.join(" | "));
+
+
+ } else if (typeof console == 'object') {
+ console.log("$f.fireEvent", [].slice.call(args));
+ }
+ }
+
+
+ // thanks: http://keithdevens.com/weblog/archive/2007/Jun/07/javascript.clone
+ 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;
+ }
+
+ // stripped from jQuery, thanks John Resig
+ function each(obj, fn) {
+ if (!obj) { return; }
+
+ var name, i = 0, length = obj.length;
+
+ // object
+ if (length === undefined) {
+ for (name in obj) {
+ if (fn.call(obj[name], name, obj[name]) === false) { break; }
+ }
+
+ // array
+ } else {
+ for (var value = obj[0];
+ i < length && fn.call( value, i, value ) !== false; value = obj[++i]) {
+ }
+ }
+
+ return obj;
+ }
+
+
+ // convenience
+ function el(id) {
+ return document.getElementById(id);
+ }
+
+
+ // used extensively. a very simple implementation.
+ function extend(to, from, skipFuncs) {
+ if (to && from) {
+ each(from, function(name, value) {
+ if (!skipFuncs || typeof value != 'function') {
+ to[name] = value;
+ }
+ });
+ }
+ }
+
+ // var arr = select("elem.className");
+ 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;
+ }
+ }
+
+ // fix event inconsistencies across browsers
+ function stopEvent(e) {
+ e = e || window.event;
+
+ if (e.preventDefault) {
+ e.stopPropagation();
+ e.preventDefault();
+
+ } else {
+ e.returnValue = false;
+ e.cancelBubble = true;
+ }
+ return false;
+ }
+
+ // push an event listener into existing array of listeners
+ function bind(to, evt, fn) {
+ to[evt] = to[evt] || [];
+ to[evt].push(fn);
+ }
+
+
+ // generates an unique id
+ function makeId() {
+ return "_" + ("" + Math.random()).substring(2, 10);
+ }
+
+//}}}
+
+
+// {{{ Clip
+
+ var Clip = function(json, index, player) {
+
+ // private variables
+ var self = this;
+ var cuepoints = {};
+ var listeners = {};
+ this.index = index;
+
+ // instance variables
+ if (typeof json == 'string') {
+ json = {url:json};
+ }
+
+ extend(this, json, true);
+
+ // event handling
+ each(("Start*,MetaData,Pause*,Resume*,Seek*,Stop*,Finish,LastSecond,Update,BufferFull,BufferEmpty").split(","),
+ function() {
+
+ var evt = "on" + this;
+
+ // before event
+ 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;
+ };
+
+
+ // set common clip event listeners to player level
+ if (index == -1) {
+ if (self[before]) {
+ player[before] = self[before];
+ }
+ if (self[evt]) {
+ player[evt] = self[evt];
+ }
+ }
+
+ });
+
+ extend(this, {
+
+
+ onCuepoint: function(points, fn) {
+
+ // embedded cuepoints
+ 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._config();
+ var clip = (index == -1) ? conf.clip : conf.playlist[index];
+ extend(clip, json, true);
+ },
+
+
+ // internal event for performing clip tasks. should be made private someday
+ _fireEvent: function(evt, arg1, arg2, target) {
+
+ if (evt == 'onLoad') {
+ each(cuepoints, function(key, val) {
+ player._api().fp_addCuepoints(val[0], index, key);
+ });
+ return false;
+ }
+
+ // target clip we are working against
+ if (index != -1) {
+ target = self;
+ }
+
+ if (evt == 'onCuepoint') {
+ var fn = cuepoints[arg1];
+ if (fn) {
+ return fn[1].call(player, target, arg2);
+ }
+ }
+
+ if (evt == 'onMetaData' || 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);
+ });
+ return ret;
+ }
+
+ });
+
+
+ // get cuepoints from config
+ if (json.onCuepoint) {
+ self.onCuepoint.apply(self, json.onCuepoint);
+ delete json.onCuepoint;
+ }
+
+ // get other events
+ each(json, function(key, val) {
+ if (typeof val == 'function') {
+ bind(listeners, key, val);
+ delete json[key];
+ }
+ });
+
+
+ // setup common clip event callbacks for Player object too (shortcuts)
+ if (index == -1) {
+ player.onCuepoint = this.onCuepoint;
+ }
+
+ };
+
+//}}}
+
+
+// {{{ Plugin
+
+ var Plugin = function(name, json, player, fn) {
+
+ var listeners = {};
+ var self = this;
+ var hasMethods = false;
+
+ if (fn) {
+ extend(listeners, fn);
+ }
+
+ // custom callback functions in configuration
+ each(json, function(key, val) {
+ if (typeof val == 'function') {
+ listeners[key] = val;
+ delete json[key];
+ }
+ });
+
+ // core plugin methods
+ 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;
+ },
+
+
+ // internal method not meant to be used by clients
+ _fireEvent: function(evt, arg) {
+
+
+ // update plugins properties & methods
+ if (evt == 'onUpdate') {
+ var json = arg || 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;
+ }
+ }
+
+ // plugin callbacks
+ var fn = listeners[evt];
+
+ if (fn) {
+
+ fn.call(self, arg);
+
+ // "one-shot" callback
+ if (evt.substring(0, 1) == "_") {
+ delete listeners[evt];
+ }
+ }
+ }
+
+ });
+
+ };
+
+
+//}}}
+
+
+function Player(wrapper, params, conf) {
+
+ // private variables (+ arguments)
+ var
+ self = this,
+ api = null,
+ html,
+ commonClip,
+ playlist = [],
+ plugins = {},
+ listeners = {},
+ playerId,
+ apiId,
+ activeIndex,
+ swfHeight;
+
+
+// {{{ public methods
+
+ extend(self, {
+
+ id: function() {
+ return playerId;
+ },
+
+ isLoaded: function() {
+ return (api !== null);
+ },
+
+ getParent: function() {
+ return wrapper;
+ },
+
+ hide: function() {
+ if (api) { api.style.height = "0px"; }
+ return self;
+ },
+
+ show: function() {
+ 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) {
+
+ // unload all instances
+ each(players, function() {
+ this.unload();
+ });
+
+ html = wrapper.innerHTML;
+ flashembed(wrapper, params, {config: conf});
+
+ // function argument
+ if (fn) {
+ fn.cached = true;
+ bind(listeners, "onLoad", fn);
+ }
+ }
+
+ return self;
+ },
+
+ unload: function() {
+
+ 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];
+
+ // create plugin if nessessary
+ 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() {
+ return clone(conf);
+ },
+
+ getFlashParams: function() {
+ return params;
+ },
+
+ loadPlugin: function(name, url, props, fn) {
+
+ // properties not supplied
+ if (typeof props == 'function') {
+ fn = props;
+ props = {};
+ }
+
+ // if fn not given, make a fake id so that plugin's onUpdate get's fired
+ var fnId = fn ? makeId() : "_";
+ self._api().fp_loadPlugin(name, url, props, fnId);
+
+ // create new plugin
+ 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;
+ },
+
+ // "lazy" play
+ 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.0-rc2";
+ 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;
+ },
+
+ _config: function() {
+ return conf;
+ }
+
+ });
+
+
+ // event handlers
+ each(("Click*,Load*,Unload*,Keypress*,Volume*,Mute*,Unmute*,PlaylistReplace,Fullscreen*,FullscreenExit,Error").split(","),
+ function() {
+ var name = "on" + this;
+
+ // before event
+ 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;
+ };
+ }
+
+ // normal event
+ self[name] = function(fn) {
+ bind(listeners, name, fn);
+ return self;
+ };
+ }
+ );
+
+
+ // core API methods
+ each(("pause,resume,mute,unmute,stop,toggle,seek,getStatus,getVolume,setVolume,getTime,isPaused,isPlaying,startBuffering,stopBuffering,isFullscreen,reset").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;
+ };
+ }
+ );
+
+//}}}
+
+
+// {{{ public method: _fireEvent
+
+ self._fireEvent = function(evt, arg0, arg1, arg2) {
+
+ if (conf.debug) {
+ log(arguments);
+ }
+
+ // internal onLoad
+ if (evt == 'onLoad' && !api) {
+
+ 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 == '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) {
+ if (arg0.name) {
+ p._fireEvent("onUpdate", arg0);
+ }
+ p._fireEvent(arg1);
+ }
+ return;
+ }
+
+ // onPlaylistReplace
+ if (evt == 'onPlaylistReplace') {
+ playlist = [];
+ var index = 0;
+ each(arg0, function() {
+ playlist.push(new Clip(this, index++));
+ });
+ }
+
+ var ret = true;
+
+ // clip event
+ if (arg0 === 0 || (arg0 && arg0 >= 0)) {
+
+ activeIndex = arg0;
+ var clip = playlist[arg0];
+
+ if (!clip || clip._fireEvent(evt, arg1, arg2) !== false) {
+
+ // clip argument is given for common clip, because it behaves as the target
+ ret = commonClip._fireEvent(evt, arg1, arg2, clip);
+ }
+ }
+
+ // player event
+ var i = 0;
+ each(listeners[evt], function() {
+ ret = this.call(self, arg0);
+
+ // remove cached entry
+ if (this.cached) {
+ listeners[evt].splice(i, 1);
+ }
+
+ // break loop
+ if (ret === false) { return false; }
+ i++;
+
+ });
+
+ return ret;
+ };
+
+//}}}
+
+
+// {{{ init
+
+ function init() {
+
+ if ($f(wrapper)) {
+ return null;
+ }
+
+ // register this player into global array of instances
+ players.push(self);
+
+
+ // flashembed parameters
+ if (typeof params == 'string') {
+ params = {src: params};
+ }
+
+ // playerId
+ playerId = wrapper.id || "fp" + makeId();
+ apiId = params.id || playerId + "_api";
+ params.id = apiId;
+ conf.playerId = playerId;
+
+
+ // plain url is given as config
+ if (typeof conf == 'string') {
+ conf = {clip:{url:conf}};
+ }
+
+ // common clip is always there
+ conf.clip = conf.clip || {};
+ commonClip = new Clip(conf.clip, -1, self);
+
+
+ // wrapper href as playlist
+ if (wrapper.getAttribute("href")) {
+ conf.playlist = [{url:wrapper.getAttribute("href", 2)}];
+ }
+
+ // playlist
+ conf.playlist = conf.playlist || [conf.clip];
+
+ var index = 0;
+ each(conf.playlist, function() {
+
+ var clip = this;
+
+ // clip is an array, we don't allow that
+ if (typeof clip == 'object' && clip.length) {
+ clip = "" + clip;
+ }
+
+ if (!clip.url && typeof clip == 'string') {
+ clip = {url: clip};
+ }
+
+ // populate common clip properties to each clip
+ extend(clip, conf.clip, true);
+
+ // modify configuration playlist
+ conf.playlist[index] = clip;
+
+ // populate playlist array
+ clip = new Clip(clip, index, self);
+ playlist.push(clip);
+ index++;
+ });
+
+
+ // event listeners
+ each(conf, function(key, val) {
+ if (typeof val == 'function') {
+ bind(listeners, key, val);
+ delete conf[key];
+ }
+ });
+
+
+ // plugins
+ each(conf.plugins, function(name, val) {
+ if (val) {
+ plugins[name] = new Plugin(name, val, self);
+ }
+ });
+
+
+ // setup controlbar plugin if not explicitly defined
+ if (!conf.plugins || conf.plugins.controls === undefined) {
+ plugins.controls = new Plugin("controls", null, self);
+ }
+
+ // Flowplayer uses black background by default
+ params.bgcolor = params.bgcolor || "#000000";
+
+
+ // setup default settings for express install
+ params.version = params.version || [9,0];
+ params.expressInstall = 'http://www.flowplayer.org/swf/expressinstall.swf';
+
+
+ // click function
+ function doClick(e) {
+ if (self._fireEvent("onBeforeClick") !== false) {
+ self.load();
+ }
+ return stopEvent(e);
+ }
+
+ // defer loading upon click
+ html = wrapper.innerHTML;
+ if (html.replace(/\s/g, '') !== '') {
+
+ if (wrapper.addEventListener) {
+ wrapper.addEventListener("click", doClick, false);
+
+ } else if (wrapper.attachEvent) {
+ wrapper.attachEvent("onclick", doClick);
+ }
+
+ // player is loaded upon page load
+ } else {
+
+ // prevent default action from wrapper (safari problem) loaded
+ if (wrapper.addEventListener) {
+ wrapper.addEventListener("click", stopEvent, false);
+ }
+
+ // load player
+ self.load();
+ }
+
+ }
+
+ // possibly defer initialization until DOM get's loaded
+ if (typeof wrapper == 'string') {
+ flashembed.domReady(function() {
+ var node = el(wrapper);
+
+ if (!node) {
+ throw "Flowplayer cannot access element: " + wrapper;
+ } else {
+ wrapper = node;
+ init();
+ }
+ });
+
+ // we have a DOM element so page is already loaded
+ } else {
+ init();
+ }
+
+
+//}}}
+
+
+}
+
+
+// {{{ flowplayer() & statics
+
+// container for player instances
+var players = [];
+
+
+// this object is returned when multiple player's are requested
+function Iterator(arr) {
+
+ this.length = arr.length;
+
+ this.each = function(fn) {
+ each(arr, fn);
+ };
+
+ this.size = function() {
+ return arr.length;
+ };
+}
+
+// these two variables are the only global variables
+window.flowplayer = window.$f = function() {
+
+ var instance = null;
+ var arg = arguments[0];
+
+
+ // $f()
+ if (!arguments.length) {
+ each(players, function() {
+ if (this.isLoaded()) {
+ instance = this;
+ return false;
+ }
+ });
+
+ return instance || players[0];
+ }
+
+ if (arguments.length == 1) {
+
+ // $f(index);
+ if (typeof arg == 'number') {
+ return players[arg];
+
+
+ // $f(wrapper || 'containerId' || '*');
+ } else {
+
+ // $f("*");
+ if (arg == '*') {
+ return new Iterator(players);
+ }
+
+ // $f(wrapper || 'containerId');
+ each(players, function() {
+ if (this.id() == arg.id || this.id() == arg || this.getParent() == arg) {
+ instance = this;
+ return false;
+ }
+ });
+
+ return instance;
+ }
+ }
+
+ // instance builder
+ if (arguments.length > 1) {
+
+ var swf = arguments[1];
+ var conf = (arguments.length == 3) ? arguments[2] : {};
+
+ if (typeof arg == 'string') {
+
+ // select arg by classname
+ if (arg.indexOf(".") != -1) {
+ var instances = [];
+
+ each(select(arg), function() {
+ instances.push(new Player(this, clone(swf), clone(conf)));
+ });
+
+ return new Iterator(instances);
+
+ // select node by id
+ } else {
+ var node = el(arg);
+ return new Player(node !== null ? node : arg, swf, conf);
+ }
+
+
+ // arg is a DOM element
+ } else if (arg) {
+ return new Player(arg, swf, conf);
+ }
+
+ }
+
+ return null;
+};
+
+extend(window.$f, {
+
+ // called by Flash External Interface
+ fireEvent: function(id, evt, a0, a1, a2) {
+ var p = $f(id);
+ return p ? p._fireEvent(evt, a0, a1, a2) : null;
+ },
+
+
+ // create plugins by modifying Player's prototype
+ addPlugin: function(name, fn) {
+ Player.prototype[name] = fn;
+ return $f;
+ },
+
+ // utility methods for plugin developers
+ each: each,
+
+ extend: extend
+
+});
+
+//}}}
+
+
+//{{{ jQuery support
+
+if (typeof jQuery == 'function') {
+
+ jQuery.prototype.flowplayer = function(params, conf) {
+
+ // select instances
+ 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);
+ }
+
+ // create flowplayer instances
+ return this.each(function() {
+ $f(this, clone(params), conf ? clone(conf) : {});
+ });
+
+ };
+
+}
+
+//}}}
+
+
+})();
+/**
+ * flashembed 0.33. Adobe Flash embedding script
+ *
+ * http://flowplayer.org/tools/flash-embed.html
+ *
+ * Copyright (c) 2008 Tero Piirainen (support@flowplayer.org)
+ *
+ * Released under the MIT License:
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ * >> Basically you can do anything you want but leave this header as is <<
+ *
+ * first version 0.01 - 03/11/2008
+ * version 0.33 - Mon Nov 03 2008 15:37:15 GMT-0000 (GMT+00:00)
+ */
+(function() {
+
+//{{{ utility functions
+
+var jQ = typeof jQuery == 'function';
+
+
+// from "Pro JavaScript techniques" by John Resig
+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;
+ }
+}
+
+// if jQuery is present, use it's more effective domReady method
+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);
+ }
+};
+
+
+// override extend params function
+function extend(to, from) {
+ if (from) {
+ for (key in from) {
+ if (from.hasOwnProperty(key)) {
+ to[key] = from[key];
+ }
+ }
+ }
+}
+
+
+function concatVars(vars) {
+ var out = "";
+
+ for (var key in vars) {
+ if (vars[key]) {
+ out += [key] + '=' + toString(vars[key]) + '&';
+ }
+ }
+ return out.substring(0, out.length -1);
+}
+
+
+
+// JSON.toString() function
+function toString(obj) {
+
+ switch (typeOf(obj)){
+ case 'string':
+ obj = obj.replace(new RegExp('(["\\\\])', 'g'), '\\$1');
+
+ // flash does not handle %- characters well. transforms "50%" to "50pct" (a dirty hack, I admit)
+ obj = obj.replace(/^\s?(\d+)%/, "$1pct");
+ return '"' +obj+ '"';
+
+ case 'array':
+ return '['+ map(obj, function(el) {
+ return toString(el);
+ }).join(',') +']';
+
+ case 'function':
+ return '"function()"';
+
+ case 'object':
+ var str = [];
+ for (var prop in obj) {
+ if (obj.hasOwnProperty(prop)) {
+ str.push('"'+prop+'":'+ toString(obj[prop]));
+ }
+ }
+ return '{'+str.join(',')+'}';
+ }
+
+ // replace ' --> " and remove spaces
+ return String(obj).replace(/\s/g, " ").replace(/\'/g, "\"");
+}
+
+
+// private functions
+function typeOf(obj) {
+ if (obj === null || obj === undefined) { return false; }
+ var type = typeof obj;
+ return (type == 'object' && obj.push) ? 'array' : type;
+}
+
+
+// version 9 bugfix: (http://blog.deconcept.com/2006/07/28/swfobject-143-released/)
+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;
+}
+
+//}}}
+
+
+window.flashembed = function(root, userParams, flashvars) {
+
+
+//{{{ getHTML
+
+ function getHTML() {
+
+ var html = "";
+ if (typeof flashvars == 'function') { flashvars = flashvars(); }
+
+
+ // sometimes ie fails to load flash if it's on cache
+ params.src += ((params.src.indexOf("?") != -1 ? "&" : "?") + Math.random());
+
+
+ // mozilla
+ if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {
+
+ html = '<embed type="application/x-shockwave-flash" ';
+
+ if (params.id) {
+ extend(params, {name:params.id});
+ }
+
+ for (var key in params) {
+ if (params[key] !== null) {
+ html += [key] + '="' +params[key]+ '"\n\t';
+ }
+ }
+
+ if (flashvars) {
+ html += 'flashvars=\'' + concatVars(flashvars) + '\'';
+ }
+
+ // thanks Tom Price (07/17/2008)
+ html += '/>';
+
+ // ie
+ } else {
+
+ html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
+ html += 'width="' + params.width + '" height="' + params.height + '"';
+
+ // force id for IE. otherwise embedded Flash object cannot be returned
+ if (!params.id && document.all) {
+ params.id = "_" + ("" + Math.random()).substring(5);
+ }
+
+ if (params.id) {
+ html += ' id="' + params.id + '"';
+ }
+
+ html += '>';
+ html += '\n\t<param name="movie" value="'+ params.src +'" />';
+
+ params.id = params.src = params.width = params.height = null;
+
+ for (var k in params) {
+ if (params[k] !== null) {
+ html += '\n\t<param name="'+ k +'" value="'+ params[k] +'" />';
+ }
+ }
+
+ if (flashvars) {
+ html += '\n\t<param name="flashvars" value=\'' + concatVars(flashvars) + '\' />';
+ }
+
+ html += "</object>";
+ if (debug) {
+ alert(html);
+ }
+
+ }
+
+ return html;
+ }
+
+ //}}}
+
+
+//{{{ construction
+
+ // setup params
+ var params = {
+
+ // very common params
+ src: '#',
+ width: '100%',
+ height: '100%',
+
+ // flashembed specific options
+ version:null,
+ onFail:null,
+ expressInstall:null,
+ debug: false,
+
+ // flashembed defaults
+ // bgcolor: 'transparent',
+ 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; }
+
+
+ // is supported
+ if (!required || flashembed.isSupported(required)) {
+ params.onFail = params.version = params.expressInstall = params.debug = null;
+
+ // root.innerHTML may cause broplems: http://domscripting.com/blog/display/99
+ // thanks to: Ryan Rud
+ // var tmp = document.createElement("extradiv");
+ // tmp.innerHTML = getHTML();
+ // root.appendChild(tmp);
+
+ root.innerHTML = getHTML();
+
+ // return our API
+ return root.firstChild;
+
+ // custom fail event
+ } else if (params.onFail) {
+ var ret = params.onFail.call(params, flashembed.getVersion(), flashvars);
+ if (ret === true) { root.innerHTML = ret; }
+
+
+ // express install
+ } else if (required && express && flashembed.isSupported([6,65])) {
+
+ extend(params, {src: express});
+
+ flashvars = {
+ MMredirectURL: location.href,
+ MMplayerType: 'PlugIn',
+ MMdoctitle: document.title
+ };
+
+ root.innerHTML = getHTML();
+
+ // not supported
+ } else {
+
+ // minor bug fixed here 08.04.2008 (thanks JRodman)
+
+ if (root.innerHTML.replace(/\s/g, '') !== '') {
+ // custom content was supplied
+
+ } 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;
+
+//}}}
+
+
+};
+
+
+//{{{ static methods
+
+extend(window.flashembed, {
+
+ // arr[major, minor, fix]
+ 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 { // avoid fp 6 crashes
+ var _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
+
+ } catch(e) {
+ try {
+ _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
+ version = [6, 0];
+ _a.AllowScriptAccess = "always"; // throws if fp < 6.47
+
+ } catch(ee) {
+ if (version[0] == 6) { return; }
+ }
+ try {
+ _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
+ } catch(eee) {
+
+ }
+
+ }
+
+ if (typeof _a == "object") {
+ _d = _a.GetVariable("$version"); // bugs in fp 6.21 / 6.23
+ 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,
+
+ // returns a String representation from JSON object
+ toString: toString
+
+});
+
+//}}}
+
+
+// setup jquery support
+if (jQ) {
+
+ jQuery.prototype.flashembed = function(params, flashvars) {
+ return this.each(function() {
+ flashembed(this, params, flashvars);
+ });
+ };
+
+}
+
+})();
--- /dev/null
+/**
+ * flowplayer.js 3.0.0-rc2. The Flowplayer API.
+ *
+ * This file is part of Flowplayer, http://flowplayer.org
+ *
+ * Author: Tero Piirainen, <support@flowplayer.org>
+ * Copyright (c) 2008 Flowplayer Ltd
+ *
+ * Released under the MIT License:
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ * Version: 3.0.0-rc2 - Fri Nov 07 2008 16:50:52 GMT-0000 (GMT+00:00)
+ */
+(function(){function log(args){if(typeof opera=='object'){opera.postError("$f.fireEvent: "+args.join(" | "));}else if(typeof console=='object'){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={};this.index=index;if(typeof json=='string'){json={url:json};}extend(this,json,true);each(("Start*,MetaData,Pause*,Resume*,Seek*,Stop*,Finish,LastSecond,Update,BufferFull,BufferEmpty").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._config();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){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=='onMetaData'||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);});return ret;}});if(json.onCuepoint){self.onCuepoint.apply(self,json.onCuepoint);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=arg||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
+self=this,api=null,html,commonClip,playlist=[],plugins={},listeners={},playerId,apiId,activeIndex,swfHeight;extend(self,{id:function(){return playerId;},isLoaded:function(){return(api!==null);},getParent:function(){return wrapper;},hide:function(){if(api){api.style.height="0px";}return self;},show:function(){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(){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(){return clone(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.0-rc2";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;},_config:function(){return conf;}});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").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(evt=='onLoad'&&!api){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=='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){if(arg0.name){p._fireEvent("onUpdate",arg0);}p._fireEvent(arg1);}return;}if(evt=='onPlaylistReplace'){playlist=[];var index=0;each(arg0,function(){playlist.push(new Clip(this,index++));});}var ret=true;if(arg0===0||(arg0&&arg0>=0)){activeIndex=arg0;var clip=playlist[arg0];if(!clip||clip._fireEvent(evt,arg1,arg2)!==false){ret=commonClip._fireEvent(evt,arg1,arg2,clip);}}var i=0;each(listeners[evt],function(){ret=this.call(self,arg0);if(this.cached){listeners[evt].splice(i,1);}if(ret===false){return false;}i++;});return ret;};function init(){if($f(wrapper)){return null;}players.push(self);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||{};commonClip=new Clip(conf.clip,-1,self);if(wrapper.getAttribute("href")){conf.playlist=[{url:wrapper.getAttribute("href",2)}];}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};}extend(clip,conf.clip,true);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._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(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];}}}}function concatVars(vars){var out="";for(var key in vars){if(vars[key]){out+=[key]+'='+toString(vars[key])+'&';}}return out.substring(0,out.length-1);}function toString(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 toString(el);}).join(',')+']';case'function':return'"function()"';case'object':var str=[];for(var prop in obj){if(obj.hasOwnProperty(prop)){str.push('"'+prop+'":'+toString(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;}window.flashembed=function(root,userParams,flashvars){function getHTML(){var html="";if(typeof flashvars=='function'){flashvars=flashvars();}params.src+=((params.src.indexOf("?")!=-1?"&":"?")+Math.random());if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){html='<embed type="application/x-shockwave-flash" ';if(params.id){extend(params,{name:params.id});}for(var key in params){if(params[key]!==null){html+=[key]+'="'+params[key]+'"\n\t';}}if(flashvars){html+='flashvars=\''+concatVars(flashvars)+'\'';}html+='/>';}else{html='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';html+='width="'+params.width+'" height="'+params.height+'"';if(!params.id&&document.all){params.id="_"+(""+Math.random()).substring(5);}if(params.id){html+=' id="'+params.id+'"';}html+='>';html+='\n\t<param name="movie" value="'+params.src+'" />';params.id=params.src=params.width=params.height=null;for(var k in params){if(params[k]!==null){html+='\n\t<param name="'+k+'" value="'+params[k]+'" />';}}if(flashvars){html+='\n\t<param name="flashvars" value=\''+concatVars(flashvars)+'\' />';}html+="</object>";if(debug){alert(html);}}return html;}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();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();}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,toString:toString});if(jQ){jQuery.prototype.flashembed=function(params,flashvars){return this.each(function(){flashembed(this,params,flashvars);});};}})();
\ No newline at end of file
--- /dev/null
+This Kaltura Dynamic Player +Playlist (KDP) is a sub package of the taken Kaltura Community Edition (CE) Built from Kaltura.org source.
+
+The full Kaltura Community Edition is licensed under the (GNU Affero General Public License v3)
+
+And the source code is available on the kaltura.org site:
+http://www.kaltura.org/project/kalturaCE
+
+More info about the KDP:
+http://www.kaltura.org/kdp-dynamic-player-and-playlist-widget
+
+
--- /dev/null
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
--- /dev/null
+
+ *** PRELIMINARY SOFTWARE ***
+
+Please note that this is a prerelease of the OMTK Flash library. No
+quality of this software can be guaranteed.
+
+
+ *** haXe notes ***
+
+You need at least haXe 2.01 (with support for the new Flash 10 types)
+to compile the haXe source.
+
+ *** Flash notes ***
+
+I am not able to create a .SWC library from the haXe .SWF file. It's
+therefore dynamically linked at runtime and hxmdct.swf must be placed
+in the same directory as the "real" Flash movie.
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package {
+
+ import org.omtk.vorbis.VorbisSound;
+
+ import flash.display.Shape;
+ import flash.display.Sprite;
+ import flash.display.StageAlign;
+ import flash.display.StageQuality;
+ import flash.display.StageScaleMode;
+ import flash.net.*;
+ import flash.events.Event;
+ import flash.text.TextField;
+ import flash.utils.ByteArray;
+ import flash.utils.Endian;
+ import flash.utils.getTimer;
+ import flash.utils.setTimeout;
+ import flash.utils.setInterval;
+ import flash.external.ExternalInterface;
+
+ [ SWF( backgroundColor = '#ffffff', width = '1', height = '1' ) ]
+
+ public class Player extends Sprite {
+
+ private var sound: VorbisSound;
+ private var initialized: Boolean = false;
+
+ public function Player() {
+ if(stage != null) {
+ stage.frameRate = 20;
+ }
+
+ setTimeout(registerJSCallbacks, 100);
+ initialized = true;
+ }
+
+ private function registerJSCallbacks(): void {
+ if (ExternalInterface.available) {
+ ExternalInterface.addCallback("play", playJS);
+ ExternalInterface.addCallback("getMetaData", getMetaDataJS);
+ ExternalInterface.addCallback("getPosition", getPositionJS);
+ }
+ }
+
+ public function playJS(url: String): void {
+ if(sound != null) {
+ sound.stop();
+ }
+ sound = new VorbisSound(new URLRequest(url));
+ sound.addEventListener(Event.COMPLETE, complete);
+ sound.addEventListener(VorbisSound.METADATA_UPDATE, metadataUpdate);
+ sound.play();
+ }
+
+ public function getMetaDataJS(key: String): String {
+ if(sound == null) {
+ return null;
+ }
+ else {
+ return sound.getMetaData(key);
+ }
+ }
+
+ public function getPositionJS(): int {
+ if(sound == null) {
+ return -1;
+ }
+ else {
+ return sound.position;
+ }
+ }
+
+ private function complete(event: Event):void {
+ trace("complete");
+ if(ExternalInterface.available) {
+ ExternalInterface.call("OMTK_P_complete");
+ }
+ }
+
+ private function metadataUpdate(event: Event):void {
+ trace("metadata update: " + sound.getMetaData("TITLE"));
+ if(ExternalInterface.available) {
+ ExternalInterface.call("OMTK_P_metadataUpdate");
+ }
+ }
+
+ }
+
+}
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.ogg {
+
+ public class EndOfOggStreamError extends Error {
+
+ public function EndOfOggStreamError(message:String = null) {
+ super(message);
+ }
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.ogg {
+
+ import org.omtk.util.BitByteArray;
+ import flash.utils.Endian;
+
+ public class LogicalOggStream {
+
+ private var source:UncachedUrlStream;
+
+ private var pageIndex:int;
+ private var currentPage:OggPage;
+ private var currentSegmentIndex:int;
+
+ public function LogicalOggStream(source:UncachedUrlStream) {
+ this.source = source;
+ }
+
+ public function getNextOggPacket(): OggPacket {
+
+ var res:BitByteArray = new BitByteArray();
+
+ var segmentLength:int = 0;
+
+ if(currentPage == null) {
+ currentPage = source.getNextOggPage();
+ }
+
+ do {
+ if(currentSegmentIndex >= currentPage.segmentOffsets.length) {
+ currentSegmentIndex=0;
+
+ if(currentPage.eos) {
+ throw new EndOfOggStreamError("End of OGG stream");
+ }
+
+ currentPage = source.getNextOggPage();
+ }
+
+ segmentLength = currentPage.segmentLengths[currentSegmentIndex];
+ res.writeBytes(currentPage.data, currentPage.segmentOffsets[currentSegmentIndex], segmentLength);
+ currentSegmentIndex++;
+ }
+ while(segmentLength==255);
+
+ res.position = 0;
+
+ var lastPacket: Boolean = currentPage.eos && currentSegmentIndex == currentPage.segmentOffsets.length;
+ var lastGranulePosition: int = currentPage.absoluteGranulePosition;
+
+ return new OggPacket(res, lastPacket, lastGranulePosition);
+ }
+
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.ogg {
+
+ import org.omtk.util.BitByteArray;
+
+ public class OggPacket {
+
+ private var _data: BitByteArray;
+ private var _lastPacket: Boolean;
+ private var _lastGranulePosition: int;
+
+ public function OggPacket(data: BitByteArray, lastPacket: Boolean, lastGranulePosition: int) {
+ _data = data;
+ _lastPacket = lastPacket;
+ _lastGranulePosition = lastGranulePosition;
+ }
+
+ public function get data(): BitByteArray {
+ return _data;
+ }
+
+ public function get lastPacket(): Boolean {
+ return _lastPacket;
+ }
+
+ public function get lastGranulePosition(): int {
+ return _lastGranulePosition;
+ }
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.ogg {
+
+ import flash.net.*;
+ import flash.utils.ByteArray;
+
+ public class OggPage {
+
+ private var _version:int;
+ private var _continued:Boolean;
+ private var _bos:Boolean;
+ private var _eos:Boolean;
+ private var _absoluteGranulePosition:int;
+ private var _streamSerialNumber:int;
+ private var _pageSequenceNumber:int;
+ private var _pageCheckSum:int;
+ private var _segmentOffsets:Array;
+ private var _segmentLengths:Array;
+ private var _totalLength:int;
+ private var _data:ByteArray;
+
+ public function OggPage(stream:URLStream) {
+
+ var capture:int = stream.readInt();
+ if(capture != 0x5367674f) {
+ throw new Error("Ogg page does not start with 'OggS': "+capture);
+ }
+
+ _version = stream.readByte()&0xff;
+ var tmp:int = stream.readByte();
+
+ _continued = (tmp&1)!=0;;
+ _bos = (tmp&2)!=0;
+ _eos = (tmp&4)!=0;
+
+ // absoluteGranulePosition is really 64 bits
+ _absoluteGranulePosition = stream.readUnsignedInt();
+ stream.readUnsignedInt(); // last 32 bits of _absoluteGranulePosition
+
+ _streamSerialNumber = stream.readUnsignedInt();
+ _pageSequenceNumber = stream.readUnsignedInt();
+ _pageCheckSum = stream.readUnsignedInt();
+
+ //trace("_pageSequenceNumber: " + _pageSequenceNumber);
+
+ var pageSegments:int = stream.readUnsignedByte();
+
+ //stream.waitFor(pageSegments);
+
+ _segmentOffsets = [];
+ _segmentLengths = [];
+ _data = new ByteArray();
+
+ var totalLength:int;
+
+ var i:int;
+ var l:int;
+
+ for( i= 0 ; i < pageSegments ; i++ ) {
+ l = stream.readUnsignedByte();
+ _segmentLengths.push( l );
+ _segmentOffsets.push( totalLength );
+ totalLength += l;
+ }
+
+ stream.readBytes(_data, 0, totalLength);
+ }
+
+ public function get absoluteGranulePosition():int {
+ return _absoluteGranulePosition;
+ }
+
+ public function get segmentOffsets():Array {
+ return _segmentOffsets;
+ }
+
+ public function get segmentLengths():Array {
+ return _segmentLengths;
+ }
+
+ public function get data():ByteArray {
+ return _data;
+ }
+
+ public function get eos():Boolean {
+ return _eos;
+ }
+
+ public function get bos():Boolean {
+ return _bos;
+ }
+
+ public function get continued():Boolean {
+ return _continued;
+ }
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.ogg {
+
+ import flash.net.*;
+ import flash.utils.Endian;
+ import flash.events.HTTPStatusEvent;
+ import flash.events.ProgressEvent;
+
+ public class UncachedUrlStream {
+
+ private var source:URLStream;
+
+ public function UncachedUrlStream(source: URLStream) {
+ this.source = source;
+ }
+
+ public function get bytesAvailable():int {
+ return source.bytesAvailable;
+ }
+
+ public function addEventListener(type:String, listener:Function):void {
+ source.addEventListener(type, listener);
+ }
+
+ public function getLogicalOggStream():LogicalOggStream {
+ return new LogicalOggStream(this);
+ }
+
+ public function getNextOggPage():OggPage {
+ return new OggPage(source);
+ }
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.util {
+
+ import flash.utils.ByteArray;
+ import flash.utils.Endian;
+ import flash.errors.IllegalOperationError;
+
+ public class BitByteArray extends ByteArray {
+
+ private var currentByte:uint;
+ private var bitIndex:int = 8;
+
+ public function BitByteArray() {
+ this.endian = Endian.LITTLE_ENDIAN;
+ }
+
+ public function readBit():Boolean {
+ if (bitIndex > 7) {
+ bitIndex = 0;
+ currentByte = readUnsignedByte();
+ }
+ return (currentByte & (1 << (bitIndex++))) != 0;
+ }
+
+ public function readUnsignedBitwiseInt(bits:int):uint {
+
+ var res:uint = 0;
+
+ for (var i : int = 0; i < bits; i++) {
+ if (bitIndex > 7) {
+ bitIndex = 0;
+ currentByte = readUnsignedByte();
+ }
+ if((currentByte & (1 << (bitIndex++))) != 0) {
+ res |= (1 << i);
+ }
+ }
+
+ return res;
+ }
+
+ public function readUnsignedHuffmanInt(root:HuffmanNode):uint {
+
+ while (!root.hasValue) {
+ if (bitIndex > 7) {
+ bitIndex = 0;
+ currentByte = readUnsignedByte();
+ }
+ root = (currentByte & (1 << (bitIndex++))) != 0 ? root._o1 : root._o0;
+ }
+
+ return root._value;
+ }
+
+ }
+
+
+}
\ No newline at end of file
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+package org.omtk.util {
+
+ public class HuffmanNode {
+
+ private var _parent:HuffmanNode;
+
+ public var _o0:HuffmanNode;
+ public var _o1:HuffmanNode;
+
+ private var _depth:int;
+
+ public var _value:int;
+ public var hasValue: Boolean;
+ private var _full:Boolean = false;
+
+ public function HuffmanNode(parent:HuffmanNode = null, value:int = -1) {
+ _parent = parent;
+ if(_parent != null) {
+ _depth = _parent.depth+1;
+ }
+ _value = value;
+ _full = value >= 0;
+ hasValue = value >= 0;
+ }
+
+ public function setNewValue(depth:int, value:uint):Boolean {
+ if (full) {
+ return false;
+ }
+ if (depth == 1) {
+ if (_o0 == null) {
+ _o0 = new HuffmanNode(this, value);
+ return true;
+ } else if (_o1 == null) {
+ _o1 = new HuffmanNode(this, value);
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return o0.setNewValue(depth - 1, value)
+ ? true : o1.setNewValue(depth - 1, value);
+ }
+ }
+
+ public function get value():uint {
+ return _value;
+ }
+
+ public function get o0():HuffmanNode {
+ if(_o0 == null) {
+ _o0 = new HuffmanNode(this);
+ }
+ return _o0;
+ }
+
+ public function get o1():HuffmanNode {
+ if(_o1 == null) {
+ _o1 = new HuffmanNode(this);
+ }
+ return _o1;
+ }
+
+ public function get depth():int {
+ return _depth;
+ }
+
+ public function get full():Boolean {
+ return _full ? true
+ : (_full = (_o0 != null && _o0.full && _o1 != null && _o1.full));
+ }
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.vorbis {
+
+ import flash.utils.getTimer;
+ import flash.utils.ByteArray;
+ import org.omtk.ogg.*;
+ import org.omtk.util.BitByteArray;
+
+ public class AudioPacket {
+
+ private var modeNumber:int;
+ private var mode:Mode;
+ private var mapping:Mapping;
+ private var n:int;
+
+ private var blockFlag:Boolean;
+ private var previousWindowFlag:Boolean;
+ private var nextWindowFlag:Boolean;
+
+ private var windowCenter:int;
+ private var leftWindowStart:int;
+ private var leftWindowEnd:int;
+ private var leftN:int;
+ private var rightWindowStart:int;
+ private var rightWindowEnd:int;
+ private var rightN:int;
+
+ private var window:Vector.<Number>;
+ private var freq0:Vector.<Number>;
+ private var freq1:Vector.<Number>;
+ private var pcm0:Vector.<Number>;
+ private var pcm1:Vector.<Number>;
+
+ private var channelFloors:Vector.<Floor>;
+ private var noResidues:Vector.<Boolean>;
+
+ private var _lastPacket: Boolean;
+ private var _lastGranulePosition: int;
+
+ public function AudioPacket(vorbis:VorbisStream, packet: OggPacket, currentGranulePosition: int) {
+
+ var source: BitByteArray = packet.data;
+ _lastPacket = packet.lastPacket;
+ _lastGranulePosition = packet.lastGranulePosition;
+
+ var i:int;
+ var j:int;
+ var k:int;
+
+ var sHeader:SetupHeader = vorbis.setupHeader;
+ var iHeader:IdentificationHeader = vorbis.identificationHeader;
+ var modes:Vector.<Mode> = sHeader.modes;
+ var mappings:Vector.<Mapping> = sHeader.mappings;
+ var residues:Vector.<Residue> = sHeader.residues;
+ var channels:int = iHeader.channels;
+
+ if (source.readUnsignedBitwiseInt(1) != 0) {
+ throw new Error("Packet type mismatch when trying to create an audio packet.");
+ }
+
+ modeNumber = source.readUnsignedBitwiseInt(Util.ilog(modes.length - 1));
+
+ mode = modes[modeNumber];
+
+ if(mode == null) {
+ throw new Error("Reference to invalid mode in audio packet.");
+ }
+
+ mapping = mappings[mode.mapping];
+
+ var magnitudes:Vector.<int> = mapping.magnitudes;
+ var angles:Vector.<int> = mapping.angles;
+
+ blockFlag = mode.blockFlag;
+
+ var blockSize0:int = iHeader.blockSize0;
+ var blockSize1:int = iHeader.blockSize1;
+
+ n = blockFlag ? blockSize1 : blockSize0;
+
+ if (blockFlag) {
+ previousWindowFlag = source.readBit();
+ nextWindowFlag = source.readBit();
+ }
+
+ windowCenter = n / 2;
+
+ if (blockFlag && !previousWindowFlag) {
+ leftWindowStart = n / 4 - blockSize0 / 4;
+ leftWindowEnd = n / 4 + blockSize0 / 4;
+ leftN = blockSize0 / 2;
+ } else {
+ leftWindowStart = 0;
+ leftWindowEnd = n / 2;
+ leftN = windowCenter;
+ }
+
+ if (blockFlag && !nextWindowFlag) {
+ rightWindowStart = n * 3 / 4 - blockSize0 / 4;
+ rightWindowEnd = n * 3 / 4 + blockSize0 / 4;
+ rightN = blockSize0 / 2;
+ } else {
+ rightWindowStart = windowCenter;
+ rightWindowEnd = n;
+ rightN = n / 2;
+ }
+
+ window = getComputedWindow(vorbis);
+
+ channelFloors = new Vector.<Floor>(channels, true);
+ noResidues = new Vector.<Boolean>(channels, true);
+
+ freq0 = new Vector.<Number>(n, true);
+ freq1 = new Vector.<Number>(n, true);
+ pcm0 = new Vector.<Number>(n, true);
+ pcm1 = new Vector.<Number>(n, true);
+
+ var allFloorsEmpty: Boolean = true;
+ var submapNumber: int;
+ var floorNumber: int;
+ var decodedFloor: Floor;
+
+ for(i = 0; i < channels; i++) {
+ submapNumber = mapping.mux[i];
+ floorNumber = mapping.submapFloors[submapNumber];
+ decodedFloor = sHeader.floors[floorNumber].decodeFloor(vorbis, source);
+ channelFloors[i] = decodedFloor;
+ noResidues[i] = decodedFloor == null;
+ if (decodedFloor != null) {
+ allFloorsEmpty = false;
+ }
+ }
+
+ if(allFloorsEmpty) {
+ return;
+ }
+
+ var mag: int;
+ var ang: int;
+
+ for(i = 0; i < magnitudes.length; i++) {
+ mag = magnitudes[i];
+ ang = angles[i];
+ if (!noResidues[mag] || !noResidues[ang]) {
+ noResidues[mag] = false;
+ noResidues[ang] = false;
+ }
+ }
+
+ var ch: int;
+ var doNotDecodeFlags: Vector.<Boolean>;
+ var residue:Residue;
+
+ for(i = 0; i < mapping.submaps; i++) {
+
+ doNotDecodeFlags = new Vector.<Boolean>();
+
+ for(j = 0; j < channels; j++) {
+ if(mapping.mux[j] == i) {
+ doNotDecodeFlags.push(noResidues[j]);
+ }
+ }
+
+ residue = residues[mapping.submapResidues[i]];
+
+ residue.decodeResidue(vorbis, source, mode, ch, doNotDecodeFlags, freq0, freq1);
+ }
+
+ var a: Number;
+ var m: Number;
+
+ for(i = mapping.couplingSteps - 1; i >= 0; i--) {
+
+ mag = magnitudes[i];
+ ang = angles[i];
+
+ for (j = 0; j < freq0.length; j++) {
+
+ a = ang == 0 ? freq0[j] : freq1[j];
+ m = mag == 0 ? freq0[j] : freq1[j];
+
+ if(a > 0) {
+ if(ang == 0) {
+ freq0[j] = m > 0 ? m - a : m + a;
+ }
+ else {
+ freq1[j] = m > 0 ? m - a : m + a;
+ }
+ }
+ else {
+ if(mag == 0) {
+ freq0[j] = m > 0 ? m + a : m - a;
+ }
+ else {
+ freq1[j] = m > 0 ? m + a : m - a;
+ }
+
+ if(ang == 0) {
+ freq0[j] = m;
+ }
+ else {
+ freq1[j] = m;
+ }
+ }
+ }
+ }
+
+ if(channelFloors[0] != null) {
+ Floor(channelFloors[0]).computeFloor(freq0);
+ }
+
+ if(channelFloors[1] != null) {
+ Floor(channelFloors[1]).computeFloor(freq1);
+ }
+
+ // perform an inverse mdct to all channels
+ var mdct: Mdct = blockFlag ? iHeader.mdct1 : iHeader.mdct0;
+ mdct.imdct(freq0, window, pcm0);
+ mdct.imdct(freq1, window, pcm1);
+
+ if(_lastPacket) {
+ if(leftWindowEnd - leftWindowStart > _lastGranulePosition - currentGranulePosition) {
+ leftWindowEnd = leftWindowStart + _lastGranulePosition - currentGranulePosition
+ }
+ if(rightWindowStart - leftWindowStart > _lastGranulePosition - currentGranulePosition) {
+ rightWindowStart = leftWindowStart + _lastGranulePosition - currentGranulePosition
+ }
+ }
+
+ }
+
+ private function getComputedWindow(vorbis:VorbisStream):Vector.<Number> {
+
+ var i:int;
+
+ var ix:int = (blockFlag ? 4 : 0) + (previousWindowFlag ? 2 : 0) + (nextWindowFlag ? 1 : 0);
+ var w:Vector.<Number> = vorbis.windows[ix];
+
+ var x:Number;
+
+ if (w == null) {
+ w = new Vector.<Number>(n);
+
+ for(i = 0; i < leftWindowStart; i++) {
+ w[i] = 0;
+ }
+
+ for (i = 0; i < leftN; i++) {
+ x = (i + .5) / leftN * Math.PI / 2.;
+ x = Math.sin(x);
+ x *= x;
+ x *= Math.PI / 2.;
+ x = Math.sin(x);
+ w[i + leftWindowStart] = x;
+ }
+
+ for (i = leftWindowEnd; i < rightWindowStart; i++) {
+ w[i] = 1;
+ }
+
+ for (i = 0; i < rightN; i++) {
+ x = (rightN - i - .5) / rightN * Math.PI / 2.;
+ x = Math.sin(x);
+ x *= x;
+ x *= Math.PI / 2.;
+ x = Math.sin(x);
+ w[i + rightWindowStart] = x;
+ }
+
+ for(i = rightN + rightWindowStart; i < n; i++) {
+ w[i] = 0;
+ }
+
+ for(i = 0; i < w.length; i++) {
+ w[i] *= 0.5;
+ }
+
+ vorbis.windows[ix] = w;
+ }
+
+ return w;
+ }
+
+
+ public function readPcm(previousPacket:AudioPacket, target: ByteArray): int {
+
+ var j:int;
+ var j2:int;
+ var ppcm0:Vector.<Number> = previousPacket.pcm0;
+ var ppcm1:Vector.<Number> = previousPacket.pcm1;
+
+ j2 = previousPacket.rightWindowStart;
+
+ for(j = leftWindowStart; j < leftWindowEnd; j++) {
+ target.writeFloat(pcm0[j] + ppcm0[j2]);
+ target.writeFloat(pcm1[j] + ppcm1[j2++]);
+ }
+
+ for (j = leftWindowEnd; j < rightWindowStart; j++) {
+ target.writeFloat(pcm0[j]);
+ target.writeFloat(pcm1[j]);
+ }
+
+ return numberOfSamples;
+
+ }
+
+ public function get numberOfSamples():int {
+ return rightWindowStart - leftWindowStart;
+ }
+
+ public function get lastPacket(): Boolean {
+ return lastPacket;
+ }
+
+ public function get lastGranulePosition(): int {
+ return lastGranulePosition;
+ }
+
+ }
+
+
+}
\ No newline at end of file
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.vorbis {
+
+ import flash.errors.IllegalOperationError;
+ import org.omtk.util.*;
+
+ public class CodeBook {
+
+ private var entries:uint;
+ private var entryLengths:Vector.<int>;
+ private var valueVector:Vector.<Vector.<Number>>;
+
+ private var codeBookLookupType:int = -1;
+
+ public var huffmanRoot:HuffmanNode;
+ public var dimensions:uint;
+
+ public function CodeBook( source: BitByteArray ) {
+
+ var i:int;
+ var j:int;
+
+ var syncPattern:uint = source.readUnsignedBitwiseInt(24);
+ if(syncPattern !=0x564342) {
+ throw new IllegalOperationError("Illegal codebook sync pattern: "+syncPattern);
+ }
+
+ dimensions = source.readUnsignedBitwiseInt(16);
+ entries = source.readUnsignedBitwiseInt(24);
+
+ entryLengths = new Vector.<int>(entries);
+
+ var ordered:Boolean = source.readBit();
+
+ if(ordered) {
+ var cl:int = source.readUnsignedBitwiseInt(5)+1;
+ for(i=0; i<entryLengths.length; ) {
+ var num:int = source.readUnsignedBitwiseInt(Util.ilog(entryLengths.length-i));
+ if(i+num>entryLengths.length) {
+ throw new Error("The codebook entry length list is longer than the actual number of entry lengths.");
+ }
+ for(j=i; j<i+num; j++) {
+ entryLengths[j] = cl;
+ }
+ //Arrays.fill(entryLengths, i, i+num, cl);
+ cl++;
+ i+=num;
+ }
+ }
+ else {
+ // !ordered
+ var sparse:Boolean = source.readBit();
+
+ if(sparse) {
+ for(i=0; i<entryLengths.length; i++) {
+ if(source.readBit()) {
+ entryLengths[i]=source.readUnsignedBitwiseInt(5)+1;
+ }
+ else {
+ entryLengths[i]=-1;
+ }
+ }
+ }
+ else {
+ // !sparse
+ //Alert.show("entryLengths.length: "+entryLengths.length, "CodeBook");
+ for(i=0; i<entryLengths.length; i++) {
+ entryLengths[i]=source.readUnsignedBitwiseInt(5)+1;
+ }
+ }
+
+ }
+
+ if (!createHuffmanTree(entryLengths)) {
+ throw new Error("An exception was thrown when building the codebook Huffman tree.");
+ }
+
+ codeBookLookupType = source.readUnsignedBitwiseInt(4);
+
+ switch(codeBookLookupType) {
+ case 0:
+ // codebook has no scalar vectors to be calculated
+ break;
+ case 1:
+ case 2:
+ var codeBookMinimumValue:Number = Util.float32unpack(source.readUnsignedBitwiseInt(32));
+ var codeBookDeltaValue:Number = Util.float32unpack(source.readUnsignedBitwiseInt(32));
+
+ var codeBookValueBits:uint = source.readUnsignedBitwiseInt(4)+1;
+ var codeBookSequenceP:Boolean = source.readBit();
+
+ var codeBookLookupValues:uint = 0;
+
+ if(codeBookLookupType==1) {
+ codeBookLookupValues=Util.lookup1Values(entries, dimensions);
+ }
+ else {
+ codeBookLookupValues=entries*dimensions;
+ }
+
+ var codeBookMultiplicands:Vector.<int> = new Vector.<int>(codeBookLookupValues);
+
+ for(i=0; i < codeBookMultiplicands.length; i++) {
+ codeBookMultiplicands[i]=source.readUnsignedBitwiseInt(codeBookValueBits);
+ }
+
+ valueVector = new Vector.<Vector.<Number>>(entries);
+
+ if(codeBookLookupType==1) {
+ for(i=0; i<entries; i++) {
+ valueVector[i] = new Vector.<Number>(dimensions);
+ var last:Number = 0.0;
+ var indexDivisor:uint = 1;
+ for(j=0; j<dimensions; j++) {
+ var multiplicandOffset:int = (i/indexDivisor)%codeBookLookupValues;
+ valueVector[i][j]=
+ codeBookMultiplicands[multiplicandOffset]*codeBookDeltaValue+codeBookMinimumValue+last;
+ if(codeBookSequenceP) {
+ last = valueVector[i][j];
+ }
+ indexDivisor*=codeBookLookupValues;
+ }
+ }
+ }
+ else {
+ throw new Error("Unsupported codebook lookup type: "+codeBookLookupType);
+ /** @todo implement */
+ }
+ break;
+ default:
+ throw new Error("Unsupported codebook lookup type: "+codeBookLookupType);
+ }
+ }
+
+ private function createHuffmanTree(entryLengths:Vector.<int>):Boolean {
+
+ var i:int;
+
+ huffmanRoot = new HuffmanNode();
+ for(i=0; i<entryLengths.length; i++) {
+ var el:int = entryLengths[i];
+ if(el>0) {
+ if(!huffmanRoot.setNewValue(el, i)) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+
+ public function readVvAdd(a0:Vector.<Number>, a1:Vector.<Number>, left:Boolean, right:Boolean, source:BitByteArray, offset:int, length:int):void {
+
+ var i:int;
+ var j:int;
+
+ if (!left && !right) {
+ return;
+ }
+
+ // 1 or 2 channels
+ var ch:int =
+ left && right ? 2 : 1;
+
+ var lim:int;
+ var ix:int;
+ var ve:Vector.<Number>;
+
+ if(left && right) {
+ lim = (offset + length) / 2;
+ var chptr:int = 0;
+ for (i = offset / 2; i < lim;) {
+ ix = source.readUnsignedHuffmanInt(huffmanRoot);
+ ve = valueVector[ix];
+ for (j = 0; j < dimensions; j++) {
+ if(chptr == 0) {
+ a0[i] += ve[j];
+ }
+ else {
+ a1[i] += ve[j];
+ }
+ chptr++;
+ if(chptr == 2) {
+ chptr = 0;
+ i++;
+ }
+ }
+ }
+ }
+ else {
+ var a : Vector.<Number> = left ? a0 : a1;
+ lim = offset + length;
+ for (i = offset; i < lim;) {
+ ve = valueVector[source.readUnsignedHuffmanInt(huffmanRoot)];
+ for (j = 0; j < dimensions; j++) {
+ a[i] += ve[j];
+ i++;
+ }
+ }
+ }
+
+ }
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.vorbis {
+
+ import flash.utils.ByteArray;
+ import flash.utils.Endian;
+ import flash.utils.Dictionary;
+ import org.omtk.ogg.*;
+
+ public class CommentHeader {
+
+ private var _vendor:String;
+ private var _comments:Dictionary = new Dictionary();
+
+ public function CommentHeader(source:ByteArray)
+ {
+ init( source );
+ }
+
+ private function init( source: ByteArray ): void
+ {
+ source.readByte();
+ source.readByte();
+ source.readByte();
+ source.readByte();
+ source.readByte();
+ source.readByte();
+
+ _vendor = readUtf8String(source);
+
+ var ucLength:int = source.readUnsignedInt();
+
+ for(var i:int = 0; i < ucLength; i++) {
+ var comment:String = readUtf8String(source);
+ var ix:int = comment.indexOf('=');
+ var key:String = comment.substring(0, ix);
+ var value:String = comment.substring(ix+1);
+ _comments[key.toUpperCase()]=value;
+ }
+ }
+
+ private function readUtf8String(source:ByteArray):String {
+ var length:uint = source.readUnsignedInt();
+ return source.readUTFBytes(length);
+ }
+
+ public function get vendor():String {
+ return _vendor;
+ }
+
+ public function get comments():Dictionary {
+ return _comments;
+ }
+
+ public function get artist():String {
+ return _comments["ARTIST"];
+ }
+
+ public function get title():String {
+ return _comments["TITLE"];
+ }
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.vorbis {
+
+ import flash.errors.IllegalOperationError;
+ import org.omtk.util.BitByteArray;
+
+ public class Floor {
+
+ public static const DB_STATIC_TABLE:Vector.<Number> = Vector.<Number>([
+ 1.0649863e-07, 1.1341951e-07, 1.2079015e-07, 1.2863978e-07,
+ 1.3699951e-07, 1.4590251e-07, 1.5538408e-07, 1.6548181e-07,
+ 1.7623575e-07, 1.8768855e-07, 1.9988561e-07, 2.128753e-07,
+ 2.2670913e-07, 2.4144197e-07, 2.5713223e-07, 2.7384213e-07,
+ 2.9163793e-07, 3.1059021e-07, 3.3077411e-07, 3.5226968e-07,
+ 3.7516214e-07, 3.9954229e-07, 4.2550680e-07, 4.5315863e-07,
+ 4.8260743e-07, 5.1396998e-07, 5.4737065e-07, 5.8294187e-07,
+ 6.2082472e-07, 6.6116941e-07, 7.0413592e-07, 7.4989464e-07,
+ 7.9862701e-07, 8.5052630e-07, 9.0579828e-07, 9.6466216e-07,
+ 1.0273513e-06, 1.0941144e-06, 1.1652161e-06, 1.2409384e-06,
+ 1.3215816e-06, 1.4074654e-06, 1.4989305e-06, 1.5963394e-06,
+ 1.7000785e-06, 1.8105592e-06, 1.9282195e-06, 2.0535261e-06,
+ 2.1869758e-06, 2.3290978e-06, 2.4804557e-06, 2.6416497e-06,
+ 2.8133190e-06, 2.9961443e-06, 3.1908506e-06, 3.3982101e-06,
+ 3.6190449e-06, 3.8542308e-06, 4.1047004e-06, 4.3714470e-06,
+ 4.6555282e-06, 4.9580707e-06, 5.2802740e-06, 5.6234160e-06,
+ 5.9888572e-06, 6.3780469e-06, 6.7925283e-06, 7.2339451e-06,
+ 7.7040476e-06, 8.2047000e-06, 8.7378876e-06, 9.3057248e-06,
+ 9.9104632e-06, 1.0554501e-05, 1.1240392e-05, 1.1970856e-05,
+ 1.2748789e-05, 1.3577278e-05, 1.4459606e-05, 1.5399272e-05,
+ 1.6400004e-05, 1.7465768e-05, 1.8600792e-05, 1.9809576e-05,
+ 2.1096914e-05, 2.2467911e-05, 2.3928002e-05, 2.5482978e-05,
+ 2.7139006e-05, 2.8902651e-05, 3.0780908e-05, 3.2781225e-05,
+ 3.4911534e-05, 3.7180282e-05, 3.9596466e-05, 4.2169667e-05,
+ 4.4910090e-05, 4.7828601e-05, 5.0936773e-05, 5.4246931e-05,
+ 5.7772202e-05, 6.1526565e-05, 6.5524908e-05, 6.9783085e-05,
+ 7.4317983e-05, 7.9147585e-05, 8.4291040e-05, 8.9768747e-05,
+ 9.5602426e-05, 0.00010181521, 0.00010843174, 0.00011547824,
+ 0.00012298267, 0.00013097477, 0.00013948625, 0.00014855085,
+ 0.00015820453, 0.00016848555, 0.00017943469, 0.00019109536,
+ 0.00020351382, 0.00021673929, 0.00023082423, 0.00024582449,
+ 0.00026179955, 0.00027881276, 0.00029693158, 0.00031622787,
+ 0.00033677814, 0.00035866388, 0.00038197188, 0.00040679456,
+ 0.00043323036, 0.00046138411, 0.00049136745, 0.00052329927,
+ 0.00055730621, 0.00059352311, 0.00063209358, 0.00067317058,
+ 0.00071691700, 0.00076350630, 0.00081312324, 0.00086596457,
+ 0.00092223983, 0.00098217216, 0.0010459992, 0.0011139742,
+ 0.0011863665, 0.0012634633, 0.0013455702, 0.0014330129,
+ 0.0015261382, 0.0016253153, 0.0017309374, 0.0018434235,
+ 0.0019632195, 0.0020908006, 0.0022266726, 0.0023713743,
+ 0.0025254795, 0.0026895994, 0.0028643847, 0.0030505286,
+ 0.0032487691, 0.0034598925, 0.0036847358, 0.0039241906,
+ 0.0041792066, 0.0044507950, 0.0047400328, 0.0050480668,
+ 0.0053761186, 0.0057254891, 0.0060975636, 0.0064938176,
+ 0.0069158225, 0.0073652516, 0.0078438871, 0.0083536271,
+ 0.0088964928, 0.009474637, 0.010090352, 0.010746080,
+ 0.011444421, 0.012188144, 0.012980198, 0.013823725,
+ 0.014722068, 0.015678791, 0.016697687, 0.017782797,
+ 0.018938423, 0.020169149, 0.021479854, 0.022875735,
+ 0.024362330, 0.025945531, 0.027631618, 0.029427276,
+ 0.031339626, 0.033376252, 0.035545228, 0.037855157,
+ 0.040315199, 0.042935108, 0.045725273, 0.048696758,
+ 0.051861348, 0.055231591, 0.058820850, 0.062643361,
+ 0.066714279, 0.071049749, 0.075666962, 0.080584227,
+ 0.085821044, 0.091398179, 0.097337747, 0.10366330,
+ 0.11039993, 0.11757434, 0.12521498, 0.13335215,
+ 0.14201813, 0.15124727, 0.16107617, 0.17154380,
+ 0.18269168, 0.19456402, 0.20720788, 0.22067342,
+ 0.23501402, 0.25028656, 0.26655159, 0.28387361,
+ 0.30232132, 0.32196786, 0.34289114, 0.36517414,
+ 0.38890521, 0.41417847, 0.44109412, 0.46975890,
+ 0.50028648, 0.53279791, 0.56742212, 0.60429640,
+ 0.64356699, 0.68538959, 0.72993007, 0.77736504,
+ 0.82788260, 0.88168307, 0.9389798, 1.0]);
+
+ public static function createInstance(source:BitByteArray, header:SetupHeader):Floor {
+
+ var type:int = source.readUnsignedBitwiseInt(16);
+
+ switch (type) {
+ case 0:
+ return new Floor0(source, header);
+ case 1:
+ return new Floor1(source, header);
+ default:
+ throw new Error("Floor type " + type + " is not supported.");
+ }
+ }
+
+ public function get type():int {
+ throw new IllegalOperationError("operation not implemented");
+ }
+
+ public function decodeFloor(vorbis:VorbisStream, source:BitByteArray):Floor1 {
+ throw new IllegalOperationError("operation not implemented");
+ }
+
+ public function computeFloor(vector:Vector.<Number>):void {
+ throw new IllegalOperationError("operation not implemented");
+ }
+
+
+ }
+
+
+}
\ No newline at end of file
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.vorbis {
+
+ import flash.errors.IllegalOperationError;
+ import org.omtk.util.BitByteArray;
+
+ public class Floor0 extends Floor {
+
+ private var order:int;
+ private var rate:int;
+ private var barkMapSize:int;
+ private var amplitudeBits:int;
+ private var amplitudeOffset:int;
+
+ private var bookList:Vector.<int>;
+
+ public function Floor0(source:BitByteArray, header:SetupHeader) {
+
+ order = source.readUnsignedBitwiseInt(8);
+ rate = source.readUnsignedBitwiseInt(16);
+ barkMapSize = source.readUnsignedBitwiseInt(16);
+ amplitudeBits = source.readUnsignedBitwiseInt(6);
+ amplitudeOffset = source.readUnsignedBitwiseInt(8);
+
+ var bookCount:uint = source.readUnsignedBitwiseInt(4) + 1;
+ bookList = new Vector.<int>(bookCount);
+
+ var i:int;
+
+ for (i = 0; i < bookList.length; i++) {
+ bookList[i] = source.readUnsignedBitwiseInt(8);
+ if (bookList[i] > header.codeBooks.length) {
+ throw new Error("A floor0_book_list entry is higher than the code book count.");
+ }
+ }
+ }
+
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.vorbis {
+
+ import flash.errors.IllegalOperationError;
+ import org.omtk.util.*;
+
+ public class Floor1 extends Floor {
+
+ private var partitionClassList:Vector.<int>;
+ private var maximumClass:int;
+ private var multiplier:int;
+ private var rangeBits:int;
+ private var classDimensions:Vector.<int>;
+ private var classSubclasses:Vector.<int>;
+ private var classMasterbooks:Vector.<int>;
+ private var subclassBooks:Vector.<Vector.<int>>;
+ private var xList:Vector.<int>;
+ private var yList:Vector.<int>;
+ private var lowNeighbours:Vector.<int>;
+ private var highNeighbours:Vector.<int>;
+ private static var RANGES:Vector.<int> = Vector.<int>([256, 128, 86, 64]);
+
+ private var xList2:Vector.<int>;
+ private var step2Flags:Vector.<Boolean>;
+
+ public function Floor1(source:BitByteArray = null, header:SetupHeader = null) {
+
+ if(source==null && header==null) {
+ return;
+ }
+
+ var i:int;
+ var j:int;
+
+ maximumClass = -1;
+ var partitions:int = source.readUnsignedBitwiseInt(5);
+ partitionClassList = new Vector.<int>(partitions);
+
+ for (i = 0; i < partitionClassList.length; i++) {
+ partitionClassList[i] = source.readUnsignedBitwiseInt(4);
+ if (partitionClassList[i] > maximumClass) {
+ maximumClass = partitionClassList[i];
+ }
+ }
+
+ classDimensions = new Vector.<int>(maximumClass + 1);
+ classSubclasses = new Vector.<int>(maximumClass + 1);
+ classMasterbooks = new Vector.<int>(maximumClass + 1);
+ subclassBooks = new Vector.<Vector.<int>>(maximumClass + 1);
+
+ var xListLength:int = 2;
+
+ for (i = 0; i <= maximumClass; i++) {
+ classDimensions[i] = source.readUnsignedBitwiseInt(3) + 1;
+ xListLength += classDimensions[i];
+ classSubclasses[i] = source.readUnsignedBitwiseInt(2);
+
+ if (classDimensions[i] > header.codeBooks.length || classSubclasses[i] > header.codeBooks.length) {
+ throw new Error("There is a class dimension or class subclasses entry higher than the number of codebooks in the setup header.");
+ }
+ if (classSubclasses[i] != 0) {
+ classMasterbooks[i] = source.readUnsignedBitwiseInt(8);
+ }
+ subclassBooks[i] = new Vector.<int>(1 << classSubclasses[i]);
+ for (j = 0; j < subclassBooks[i].length; j++) {
+ subclassBooks[i][j] = source.readUnsignedBitwiseInt(8) - 1;
+ }
+ }
+
+ multiplier = source.readUnsignedBitwiseInt(2) + 1;
+ rangeBits = source.readUnsignedBitwiseInt(4);
+
+ var floorValues:int = 0;
+
+ xList = Vector.<int>([0, 1<<rangeBits]);
+
+ for (i = 0; i < partitions; i++) {
+ for (j = 0; j < classDimensions[partitionClassList[i]]; j++) {
+ xList.push(source.readUnsignedBitwiseInt(rangeBits));
+ }
+ }
+
+ lowNeighbours = new Vector.<int>(xList.length);
+ highNeighbours = new Vector.<int>(xList.length);
+
+ for (i = 0; i < xList.length; i++) {
+ lowNeighbours[i] = Util.lowNeighbour(xList, i);
+ highNeighbours[i] = Util.highNeighbour(xList, i);
+ }
+
+ xList2 = new Vector.<int>(xList.length, true);
+ step2Flags = new Vector.<Boolean>(xList.length, true);
+ }
+
+ public override function get type():int {
+ return 1;
+ }
+
+ public override function decodeFloor(vorbis:VorbisStream, source:BitByteArray):Floor1 {
+
+ var i:int;
+ var j:int;
+ var offset:int;
+
+ if (!source.readBit()) {
+ return null;
+ }
+
+ var clone:Floor1 = clone();
+
+ clone.yList = new Vector.<int>(xList.length);
+
+ var range:int = RANGES[multiplier - 1];
+
+ clone.yList[0] = source.readUnsignedBitwiseInt(Util.ilog(range - 1));
+ clone.yList[1] = source.readUnsignedBitwiseInt(Util.ilog(range - 1));
+
+ offset = 2;
+
+ for (i = 0; i < partitionClassList.length; i++) {
+ var cls:int = partitionClassList[i];
+ var cdim:int = classDimensions[cls];
+ var cbits:int = classSubclasses[cls];
+ var csub:int = (1 << cbits) - 1;
+ var cval:int = 0;
+ if (cbits > 0) {
+ cval = source.readUnsignedHuffmanInt(vorbis.setupHeader.codeBooks[classMasterbooks[cls]].huffmanRoot);
+ }
+
+ for (j = 0; j < cdim; j++) {
+ var book:int = subclassBooks[cls][cval & csub];
+ cval >>>= cbits;
+ if (book >= 0) {
+ clone.yList[j + offset] = source.readUnsignedHuffmanInt(vorbis.setupHeader.codeBooks[book].huffmanRoot);
+ } else {
+ clone.yList[j + offset] = 0;
+ }
+ }
+ offset += cdim;
+ }
+
+ return clone;
+ }
+
+ public override function computeFloor(vector:Vector.<Number>):void {
+
+ var i:int;
+ var j:int;
+
+ var n:int = vector.length;
+ var values:int = xList.length;
+ //var step2Flags:Vector.<Boolean> = new Vector.<Boolean>(values);
+
+ var range:int = RANGES[multiplier - 1];
+
+ for (i = 2; i < values; i++) {
+
+ var lowNeighbourOffset:int = lowNeighbours[i];
+ var highNeighbourOffset:int = highNeighbours[i];
+
+ var predicted:int = Util.renderPoint(
+ xList[lowNeighbourOffset], xList[highNeighbourOffset],
+ yList[lowNeighbourOffset], yList[highNeighbourOffset], xList[i]);
+
+ var val:int = yList[i];
+ var highRoom:int = range - predicted;
+ var lowRoom:int = predicted;
+ var room:int = highRoom < lowRoom ? highRoom * 2 : lowRoom * 2;
+
+ if (val != 0) {
+ step2Flags[lowNeighbourOffset] = true;
+ step2Flags[highNeighbourOffset] = true;
+ step2Flags[i] = true;
+ if (val >= room) {
+ yList[i] = highRoom > lowRoom ? val - lowRoom + predicted
+ : -val + highRoom + predicted - 1;
+ } else {
+ yList[i] = (val & 1) == 1 ? predicted - ((val + 1) >> 1)
+ : predicted + (val >> 1);
+ }
+ } else {
+ step2Flags[i] = false;
+ yList[i] = predicted;
+ }
+ }
+
+ for(i=0; i<xList.length; i++) {
+ xList2[i] = xList[i];
+ }
+
+ sort(xList2, yList, step2Flags);
+
+ var hx:int = 0;
+ var hy:int = 0;
+ var lx:int = 0;
+ var ly:int = yList[0] * multiplier;
+
+ for (i = 1; i < values; i++) {
+ if (step2Flags[i]) {
+ hy = yList[i] * multiplier;
+ hx = xList2[i];
+ Util.renderLine(lx, ly, hx, hy, vector);
+ lx = hx;
+ ly = hy;
+ }
+ }
+
+ var r:Number = DB_STATIC_TABLE[hy];
+
+ while(hx < n/2) {
+ vector[hx++] = r;
+ }
+
+ }
+
+ public function clone():Floor1 {
+ var clone:Floor1 = new Floor1();
+ clone.classDimensions = classDimensions;
+ clone.classMasterbooks = classMasterbooks;
+ clone.classSubclasses = classSubclasses;
+ clone.maximumClass = maximumClass;
+ clone.multiplier = multiplier;
+ clone.partitionClassList = partitionClassList;
+ clone.rangeBits = rangeBits;
+ clone.subclassBooks = subclassBooks;
+ clone.xList = xList;
+ clone.yList = yList;
+ clone.lowNeighbours = lowNeighbours;
+ clone.highNeighbours = highNeighbours;
+ clone.xList2 = xList2;
+ clone.step2Flags = step2Flags;
+ return clone;
+ }
+
+ private function sort(x:Vector.<int>, y:Vector.<int>, b:Vector.<Boolean>):void {
+ var off:int = 0;
+ var len:int = x.length;
+ var lim:int = len + off;
+ var itmp:int;
+ var btmp:Boolean;
+ var i:int;
+ var j:int;
+ // Insertion sort on smallest arrays
+ for (i = off; i < lim; i++) {
+ for (j = i; j > off && x[j - 1] > x[j]; j--) {
+ itmp = x[j];
+ x[j] = x[j - 1];
+ x[j - 1] = itmp;
+ itmp = y[j];
+ y[j] = y[j - 1];
+ y[j - 1] = itmp;
+ btmp = b[j];
+ b[j] = b[j - 1];
+ b[j - 1] = btmp;
+ }
+ }
+ }
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.vorbis {
+
+ import flash.utils.ByteArray;
+
+ public class IdentificationHeader {
+
+ private var _version:uint;
+ private var _channels:uint;
+ private var _sampleRate:uint;
+ private var _bitrateMaximum:int;
+ private var _bitrateMinimum:int;
+ private var _bitrateNominal:int;
+ private var _blockSize0:uint;
+ private var _blockSize1:uint;
+
+ private var _mdct:Vector.<Mdct>;
+
+ public function IdentificationHeader(source:ByteArray) {
+
+ source.readByte();
+ source.readByte();
+ source.readByte();
+ source.readByte();
+ source.readByte();
+ source.readByte();
+
+ _version = source.readUnsignedInt();
+ _channels = source.readUnsignedByte();
+ _sampleRate = source.readUnsignedInt();
+ _bitrateMaximum = source.readUnsignedInt();
+ _bitrateNominal = source.readUnsignedInt();
+ _bitrateMinimum = source.readUnsignedInt();
+ var bs:int = source.readUnsignedByte();
+ _blockSize0 = 1<<(bs&0xf);
+ _blockSize1 = 1<<(bs>>4);
+
+ _mdct = new Vector.<Mdct>(2, false);
+ _mdct[0] = new Mdct(_blockSize0);
+ _mdct[1] = new Mdct(_blockSize1);
+ }
+
+ public function get channels():uint {
+ return _channels;
+ }
+
+ public function get sampleRate():uint {
+ return _sampleRate;
+ }
+
+ public function get blockSize0():uint {
+ return _blockSize0;
+ }
+
+ public function get blockSize1():uint {
+ return _blockSize1;
+ }
+
+ public function get mdct0():Mdct {
+ return _mdct[0];
+ }
+
+ public function get mdct1():Mdct {
+ return _mdct[1];
+ }
+
+ }
+
+
+}
\ No newline at end of file
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.vorbis {
+
+ import org.omtk.util.BitByteArray;
+
+ public class Look {
+
+ private var _map:int;
+ private var _parts:int;
+ private var _stages:int;
+ private var _fullbooks:Vector.<CodeBook>;
+ private var _phrasebook:CodeBook;
+ private var _partbooks:Vector.<Vector.<int>>;
+ private var _partvals:int;
+ private var _decodemap:Vector.<Vector.<int>>;
+ private var _postbits:int;
+ private var _phrasebits:int;
+ private var _frames:int;
+
+ public function Look(source:VorbisStream, residue:Residue, mode:Mode) {
+
+ var i:int;
+ var j:int;
+ var k:int;
+
+ var dim:int = 0;
+ var acc:int = 0;
+ var maxstage:int = 0;
+
+ _map = mode.mapping;
+
+ _parts = residue.classifications;
+ _fullbooks = source.setupHeader.codeBooks;
+ _phrasebook = _fullbooks[residue.classBook];
+ dim = _phrasebook.dimensions;
+
+ _partbooks = new Vector.<Vector.<int>>(_parts);
+
+ for (j = 0; j < _parts; j++) {
+ var s:int = Util.ilog(residue.cascade[j]);
+ if (s != 0) {
+ if (s > maxstage) {
+ maxstage = s;
+ }
+ _partbooks[j] = new Vector.<int>(s);
+ for (k = 0; k < s; k++) {
+ if ((residue.cascade[j] & (1 << k)) != 0) {
+ _partbooks[j][k] = residue.books[j][k];
+ }
+ }
+ }
+ }
+
+ _partvals = Math.round(Math.pow(_parts, dim));
+ _stages = maxstage;
+
+ _decodemap = new Vector.<Vector.<int>>(_partvals, true);
+
+ for (j = 0; j < _partvals; j++) {
+ var val:int = j;
+ var mult:int = _partvals / _parts;
+ _decodemap[j] = new Vector.<int>(dim);
+
+ for (k = 0; k < dim; k++) {
+ var deco:int = val / mult;
+ val -= deco * mult;
+ mult /= _parts;
+ _decodemap[j][k] = deco;
+ }
+ }
+ }
+
+ public function get map():int {
+ return _map;
+ }
+
+ public function get parts():int {
+ return _parts;
+ }
+
+ public function get stages():int {
+ return _stages;
+ }
+
+ public function get fullbooks():Vector.<CodeBook> {
+ return _fullbooks;
+ }
+
+ public function get phrasebook():CodeBook {
+ return _phrasebook;
+ }
+
+ public function get partbooks():Vector.<Vector.<int>> {
+ return _partbooks;
+ }
+
+ public function get partvals():int {
+ return _partvals;
+ }
+
+ public function get decodemap():Vector.<Vector.<int>> {
+ return _decodemap;
+ }
+
+ public function get postbits():int {
+ return _postbits;
+ }
+
+ public function get phrasebits():int {
+ return _phrasebits;
+ }
+
+ public function get frames():int {
+ return _frames;
+ }
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.vorbis {
+
+ import flash.errors.IllegalOperationError;
+ import org.omtk.util.BitByteArray;
+
+ public class Mapping {
+
+ public static function createInstance(stream:VorbisStream, source:BitByteArray, header:SetupHeader):Mapping {
+
+ var type:int = source.readUnsignedBitwiseInt(16);
+ switch (type) {
+ case 0:
+ return new Mapping0(stream, source, header);
+ default:
+ throw new Error("Mapping type " + type + " is not supported.");
+ }
+
+ }
+
+ public function get type():int {
+ throw new IllegalOperationError("not implemented");
+ }
+
+ public function get couplingSteps():int {
+ throw new IllegalOperationError("not implemented");
+ }
+
+ public function get submaps():int {
+ throw new IllegalOperationError("not implemented");
+ }
+
+ public function get angles():Vector.<int> {
+ throw new IllegalOperationError("not implemented");
+ }
+
+ public function get magnitudes():Vector.<int> {
+ throw new IllegalOperationError("not implemented");
+ }
+
+ public function get mux():Vector.<int> {
+ throw new IllegalOperationError("not implemented");
+ }
+
+ public function get submapFloors():Vector.<int> {
+ throw new IllegalOperationError("not implemented");
+ }
+
+ public function get submapResidues():Vector.<int> {
+ throw new IllegalOperationError("not implemented");
+ }
+
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.vorbis {
+
+ import flash.errors.IllegalOperationError;
+ import org.omtk.util.BitByteArray;
+
+ public class Mapping0 extends Mapping {
+
+ private var _magnitudes:Vector.<int>;
+ private var _angles:Vector.<int>;
+ private var _mux:Vector.<int>;
+ private var _submapFloors:Vector.<int>;
+ private var _submapResidues:Vector.<int>;
+
+ public function Mapping0(stream:VorbisStream, source:BitByteArray, header:SetupHeader) {
+
+ var i:int;
+ var j:int;
+
+ var submaps:int = 1;
+
+ if (source.readBit()) {
+ submaps = source.readUnsignedBitwiseInt(4) + 1;
+ }
+
+ var channels:int = stream.identificationHeader.channels;
+ var ilogChannels:int = Util.ilog(channels - 1);
+
+ if (source.readBit()) {
+ var couplingSteps:int = source.readUnsignedBitwiseInt(8) + 1;
+ _magnitudes = new Vector.<int>(couplingSteps);
+ _angles = new Vector.<int>(couplingSteps);
+
+ for (i = 0; i < couplingSteps; i++) {
+ magnitudes[i] = source.readUnsignedBitwiseInt(ilogChannels);
+ angles[i] = source.readUnsignedBitwiseInt(ilogChannels);
+ if (magnitudes[i] == angles[i] || magnitudes[i] >= channels
+ || angles[i] >= channels) {
+ throw new Error("The channel magnitude and/or angle mismatch.");
+ }
+ }
+ } else {
+ _magnitudes = Vector.<int>([]);
+ _angles = Vector.<int>([]);
+ }
+
+ if (source.readUnsignedBitwiseInt(2) != 0) {
+ throw new Error("A reserved mapping field has an invalid value.");
+ }
+
+ _mux = new Vector.<int>(channels);
+ if (submaps > 1) {
+ for (i = 0; i < channels; i++) {
+ _mux[i] = source.readUnsignedBitwiseInt(4);
+ if (_mux[i] > submaps) {
+ throw new Error("A mapping mux value is higher than the number of submaps");
+ }
+ }
+ } else {
+ for (i = 0; i < channels; i++) {
+ _mux[i] = 0;
+ }
+ }
+
+ _submapFloors = new Vector.<int>(submaps);
+ _submapResidues = new Vector.<int>(submaps);
+
+ var floorCount:int = header.floors.length;
+ var residueCount:int = header.residues.length;
+
+ for (i = 0; i < submaps; i++) {
+ source.readUnsignedBitwiseInt(8); // discard time placeholder
+ _submapFloors[i] = source.readUnsignedBitwiseInt(8);
+ _submapResidues[i] = source.readUnsignedBitwiseInt(8);
+
+ if (_submapFloors[i] > floorCount) {
+ throw new Error("A mapping floor value is higher than the number of floors.");
+ }
+
+ if (_submapResidues[i] > residueCount) {
+ throw new Error("A mapping residue value is higher than the number of residues.");
+ }
+ }
+ }
+
+ public override function get type():int {
+ return 0;
+ }
+
+ public override function get couplingSteps():int {
+ return _angles.length;
+ }
+
+ public override function get submaps():int {
+ return _submapFloors.length;
+ }
+
+ public override function get angles():Vector.<int> {
+ return _angles;
+ }
+
+ public override function get magnitudes():Vector.<int> {
+ return _magnitudes;
+ }
+
+ public override function get mux():Vector.<int> {
+ return _mux;
+ }
+
+ public override function get submapFloors():Vector.<int> {
+ return _submapFloors;
+ }
+
+ public override function get submapResidues():Vector.<int> {
+ return _submapResidues;
+ }
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.vorbis {
+
+ import flash.events.*;
+ import flash.system.*;
+ import flash.display.*;
+ import flash.net.*;
+ import flash.utils.getTimer;
+
+ /*
+ * Wrapper for the haXe compiled class org.omtk.vorbis.MdctHX
+ */
+ public class Mdct {
+
+ public static var initialized : Boolean = false;
+ private static var hxClass : Class;
+
+ public static function initialize() : void {
+ var ldr:Loader = new Loader();
+ var swfUrl:String = "hxmdct.swf";
+ var req:URLRequest = new URLRequest(swfUrl);
+ var ldrContext:LoaderContext =
+ new LoaderContext(false, ApplicationDomain.currentDomain);
+ ldr.load(req, ldrContext);
+ ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoaded);
+
+ function swfLoaded(e:Event):void {
+ hxClass = ApplicationDomain.currentDomain.getDefinition("org.omtk.vorbis.MdctHX") as Class;
+ initialized = true;
+ }
+ }
+
+ private var delegate : Object;
+
+ public function Mdct(n:int) {
+ delegate = new hxClass(n);
+ }
+
+ public function imdct(frq:Vector.<Number>, window:Vector.<Number>, pcm:Vector.<Number>):void {
+ delegate.imdct(frq, window, pcm);
+ }
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.vorbis {
+
+ import flash.errors.IllegalOperationError;
+ import flash.utils.Dictionary;
+ import org.omtk.util.BitByteArray;
+
+ public class Mode
+ {
+ private var _blockFlag:Boolean;
+ private var _windowType:uint;
+ private var _transformType:uint;
+ private var _mapping:uint;
+
+ public function Mode(source:BitByteArray, header:SetupHeader) {
+
+ _blockFlag=source.readBit();
+ _windowType=source.readUnsignedBitwiseInt(16);
+ _transformType=source.readUnsignedBitwiseInt(16);
+ _mapping=source.readUnsignedBitwiseInt(8);
+
+ if(_windowType!=0) {
+ throw new Error("Window type = "+windowType+", != 0");
+ }
+
+ if(_transformType!=0) {
+ throw new Error("Transform type = "+transformType+", != 0");
+ }
+
+ if(_mapping > header.mappings.length) {
+ throw new Error("Mode mapping number is higher than total number of mappings.");
+ }
+ }
+
+ public function get blockFlag():Boolean {
+ return _blockFlag;
+ }
+
+ public function get windowType():uint {
+ return _windowType;
+ }
+
+ public function get transformType():uint {
+ return _transformType;
+ }
+
+ public function get mapping():uint {
+ return _mapping;
+ }
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.vorbis {
+
+ import flash.errors.IllegalOperationError;
+ import flash.utils.Dictionary;
+ import org.omtk.util.BitByteArray;
+
+ public class Residue {
+
+ private var _begin:int;
+ private var _end:int;
+ private var _partitionSize:int;
+ private var _classifications:int;
+ private var _classBook:int;
+ private var _cascade:Vector.<int>;
+ private var _books:Vector.<Vector.<int>>;
+
+ private var _looks:Dictionary;
+
+
+ public function Residue(source:BitByteArray, header:SetupHeader) {
+
+ _begin = source.readUnsignedBitwiseInt(24);
+ _end = source.readUnsignedBitwiseInt(24);
+ _partitionSize = source.readUnsignedBitwiseInt(24) + 1;
+ _classifications = source.readUnsignedBitwiseInt(6) + 1;
+ _classBook = source.readUnsignedBitwiseInt(8);
+
+ _cascade = new Vector.<int>(classifications);
+
+ var acc:int = 0;
+ var i:int;
+ var j:int;
+
+ for (i = 0; i < classifications; i++) {
+ var highBits:int = 0;
+ var lowBits:int = 0;
+
+ lowBits = source.readUnsignedBitwiseInt(3);
+ if (source.readBit()) {
+ highBits = source.readUnsignedBitwiseInt(5);
+ }
+ _cascade[i] = (highBits << 3) | lowBits;
+ acc += Util.icount(cascade[i]);
+ }
+
+ _books = new Vector.<Vector.<int>>(classifications);
+
+ for (i = 0; i < classifications; i++) {
+ books[i] = new Vector.<int>(8);
+ for (j = 0; j < 8; j++) {
+ if ((cascade[i] & (1 << j)) != 0) {
+ books[i][j] = source.readUnsignedBitwiseInt(8);
+ if (books[i][j] > header.codeBooks.length) {
+ throw new Error(
+ "Reference to invalid codebook entry in residue header.");
+ }
+ }
+ }
+ }
+
+ _looks = new Dictionary();
+ }
+
+ public static function createInstance(source:BitByteArray, header:SetupHeader):Residue {
+
+ var type:int = source.readUnsignedBitwiseInt(16);
+ switch (type) {
+ case 2:
+ return new Residue2(source, header);
+ default:
+ throw new Error("Residue type " + type + " is not supported.");
+ }
+ }
+
+ public function decodeResidue(
+ vorbis:VorbisStream, source:BitByteArray,
+ mode:Mode, ch:int,
+ doNotDecodeFlags:Vector.<Boolean>, vectors0:Vector.<Number>, vectors1:Vector.<Number>):void {
+
+ throw new IllegalOperationError("not implemented");
+ }
+
+
+ public function getLook(stream:VorbisStream, key:Mode):Look {
+ var look:Look = _looks[key];
+ if (look == null) {
+ look = new Look(stream, this, key);
+ _looks[key] = look;
+ }
+ return new Look(stream, this, key);//look;
+ }
+
+
+ public function get begin():int {
+ return _begin;
+ }
+
+ public function get end():int {
+ return _end;
+ }
+
+ public function get partitionSize():int {
+ return _partitionSize;
+ }
+
+ public function get classifications():int {
+ return _classifications;
+ }
+
+ public function get classBook():int {
+ return _classBook;
+ }
+
+ public function get cascade():Vector.<int> {
+ return _cascade;
+ }
+
+ public function get books():Vector.<Vector.<int>> {
+ return _books;
+ }
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.vorbis {
+
+ import flash.errors.IllegalOperationError;
+ import flash.utils.Dictionary;
+ import org.omtk.util.BitByteArray;
+
+ public class Residue2 extends Residue {
+
+ public function Residue2(source:BitByteArray, header:SetupHeader) {
+ super(source, header);
+ }
+
+ public override function decodeResidue(
+ vorbis:VorbisStream, source:BitByteArray,
+ mode:Mode, ch:int,
+ doNotDecodeFlags:Vector.<Boolean>, vectors0:Vector.<Number>, vectors1:Vector.<Number>):void {
+
+ var i:int;
+ var j:int;
+ var k:int;
+ var l:int;
+ var s:int;
+ var slim:int;
+
+ var look:Look = getLook(vorbis, mode);
+
+ var codeBook:CodeBook = vorbis.setupHeader.codeBooks[classBook];
+
+ var classvalsPerCodeword:int = codeBook.dimensions;
+ var nToRead:int = end - begin;
+ var partitionsToRead:int = nToRead / partitionSize; // partvals
+
+ var samplesPerPartition:int = partitionSize;
+ var partitionsPerWord:int = look.phrasebook.dimensions;
+
+ var partWords:int = (partitionsToRead + partitionsPerWord - 1) / partitionsPerWord;
+
+ var offset:int;
+
+ var left:Boolean = false;
+ var right:Boolean = false;
+
+ for (i = 0; i < doNotDecodeFlags.length; i++) {
+ if (!doNotDecodeFlags[i]) {
+ if(i==0) {
+ left = true;
+ }
+ else if (i==1) {
+ right = true;
+ }
+ }
+ }
+
+ var partword:Array = new Array(partWords);
+
+ var pb:int = source.position;
+
+ slim = look.stages;
+ for (s = 0; s < slim; s++) {
+
+ for (i = 0, l = 0; i < partitionsToRead; l++) {
+
+ if (s == 0) {
+ var temp:int = source.readUnsignedHuffmanInt(look.phrasebook.huffmanRoot);
+ if (temp == -1) {
+ throw new Error("Foo??");
+ }
+ partword[l] = look.decodemap[temp];
+ if (partword[l] == null) {
+ throw new Error("Foo??");
+ }
+ }
+
+ for (k = 0; k < partitionsPerWord && i < partitionsToRead; k++, i++) {
+ offset = begin + i * samplesPerPartition;
+
+ if ((cascade[partword[l][k]] & (1 << s)) != 0) {
+ var stagebook:CodeBook =
+ vorbis.setupHeader.codeBooks[look.partbooks[partword[l][k]][s]];
+ if (stagebook != null) {
+ stagebook.readVvAdd(vectors0, vectors1, left, right, source, offset, samplesPerPartition);
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.vorbis {
+
+ import org.omtk.util.BitByteArray;
+
+ public class SetupHeader {
+
+ private var _codeBooks:Vector.<CodeBook>;
+ private var _floors:Vector.<Floor>;
+ private var _residues:Vector.<Residue>;
+ private var _mappings:Vector.<Mapping>;
+ private var _modes:Vector.<Mode>;
+
+ public function SetupHeader(stream:VorbisStream, source:BitByteArray) {
+
+ var i:int;
+
+ source.readByte();
+ source.readByte();
+ source.readByte();
+ source.readByte();
+ source.readByte();
+ source.readByte();
+
+ var codeBookCount:uint = source.readUnsignedBitwiseInt(8)+1;
+ _codeBooks = new Vector.<CodeBook>(codeBookCount);
+
+ for(i = 0; i < codeBookCount; i++) {
+ _codeBooks[i] = new CodeBook(source);
+ }
+
+ // read the time domain transformations,
+ // these should all be 0
+
+ var timeCount:int = source.readUnsignedBitwiseInt(6) + 1;
+ for (i = 0; i < timeCount; i++) {
+ if (source.readUnsignedBitwiseInt(16) != 0) {
+ throw new Error(
+ "Time domain transformation != 0");
+ }
+ }
+
+ // read floor entries
+
+ var floorCount:int = source.readUnsignedBitwiseInt(6) + 1;
+ _floors = new Vector.<Floor>(floorCount);
+
+ for (i = 0; i < floorCount; i++) {
+ _floors[i] = Floor.createInstance(source, this);
+ }
+
+ var residueCount:int = source.readUnsignedBitwiseInt(6) + 1;
+ _residues = new Vector.<Residue>(residueCount);
+
+ for (i = 0; i < residueCount; i++) {
+ _residues[i] = Residue.createInstance(source, this);
+ }
+
+ var mappingCount:int = source.readUnsignedBitwiseInt(6) + 1;
+ _mappings = new Vector.<Mapping>(mappingCount);
+
+ for (i = 0; i < mappingCount; i++) {
+ _mappings[i] = Mapping.createInstance(stream, source, this);
+ }
+
+ var modeCount:int = source.readUnsignedBitwiseInt(6) + 1;
+ _modes = new Vector.<Mode>(modeCount);
+
+ for (i = 0; i < modeCount; i++) {
+ _modes[i] = new Mode(source, this);
+ }
+
+ if (!source.readBit()) {
+ throw new Error("The setup header framing bit is incorrect.");
+ }
+ }
+
+ public function get codeBooks():Vector.<CodeBook> {
+ return _codeBooks;
+ }
+
+ public function get floors():Vector.<Floor> {
+ return _floors;
+ }
+
+ public function get mappings():Vector.<Mapping> {
+ return _mappings;
+ }
+
+ public function get residues():Vector.<Residue> {
+ return _residues;
+ }
+
+ public function get modes():Vector.<Mode> {
+ return _modes;
+ }
+
+ }
+
+
+}
\ No newline at end of file
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.vorbis {
+
+ public class Util {
+
+ public static function ilog(x:uint):uint {
+ var res:int = 0;
+ for(; x>0; x>>=1, res++);
+ return res;
+ }
+
+ public static function float32unpack(x:uint):Number {
+ var mantissa:Number = x&0x1fffff;
+ var e:Number = (x&0x7fe00000)>>21;
+ if((x&0x80000000)!=0) {
+ mantissa=-mantissa;
+ }
+ return mantissa*Math.pow(2.0, e-788.0);
+ }
+
+ public static function lookup1Values(a:int, b:int):uint {
+ var res:uint = Math.pow(Math.E, Math.log(a)/b);
+ return intPow(res+1, b)<=a?res+1:res;
+ }
+
+ public static function intPow(base:uint, e:uint):uint {
+ var res:uint = 1;
+ for(; e>0; e--, res*=base);
+ return res;
+ }
+
+ public static function isBitSet(value:uint, bit:uint):Boolean {
+ return (value&(1<<bit))!=0;
+ }
+
+ public static function icount(value:uint):uint {
+ var res:uint = 0;
+ while (value > 0) {
+ res += value & 1;
+ value >>= 1;
+ }
+ return res;
+ }
+
+ public static function lowNeighbour(v:Vector.<int>, x:int):int {
+
+ var max:int = -1;
+ var n:int = 0;
+ var i:int;
+
+ for (i = 0; i < v.length && i < x; i++) {
+ if (v[i] > max && v[i] < v[x]) {
+ max = v[i];
+ n = i;
+ }
+ }
+ return n;
+ }
+
+ public static function highNeighbour(v:Vector.<int>, x:int):int {
+
+ var min:int = int.MAX_VALUE;
+ var n:int = 0;
+ var i:int;
+
+ for (i = 0; i < v.length && i < x; i++) {
+ if (v[i] < min && v[i] > v[x]) {
+ min = v[i];
+ n = i;
+ }
+ }
+ return n;
+ }
+
+ public static function renderPoint(x0:int, x1:int, y0:int, y1:int, x:int):int {
+ return y0 + int(((y1-y0) * (x - x0)) / (x1 - x0));
+ }
+
+ public static function renderLine(x0:int, y0:int, x1:int, y1:int, v:Vector.<Number>):void {
+
+ var dy:int = y1 - y0;
+ var adx:int = x1 - x0;
+ var b:int = dy / adx;
+ var sy:int = dy < 0 ? b - 1 : b + 1;
+ var x:int = x0;
+ var y:int = y0;
+ var err:int = 0;
+ var ady:int = (dy < 0 ? -dy : dy) - (b > 0 ? b * adx : -b * adx);
+
+ v[x] *= Floor.DB_STATIC_TABLE[y];
+ for (x = x0 + 1; x < x1; x++) {
+ err += ady;
+ if (err >= adx) {
+ err -= adx;
+ v[x] *= Floor.DB_STATIC_TABLE[y += sy];
+ } else {
+ v[x] *= Floor.DB_STATIC_TABLE[y += b];
+ }
+ }
+
+ }
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.vorbis {
+
+ import flash.net.URLRequest;
+ import flash.net.URLStream;
+ import flash.utils.ByteArray;
+ import flash.utils.Endian;
+ import flash.events.Event;
+ import flash.events.ProgressEvent;
+ import flash.events.SampleDataEvent;
+
+ import flash.external.ExternalInterface;
+
+ import flash.media.Sound;
+
+ import org.omtk.ogg.UncachedUrlStream;
+ import org.omtk.ogg.EndOfOggStreamError;
+ import flash.utils.setTimeout;
+
+ public class VorbisSound extends Sound {
+
+ public static var METADATA_UPDATE: String = "metadata_update";
+
+ private var urlStream: URLStream;
+
+ private var oggStream:UncachedUrlStream;
+ private var vorbisStream:VorbisStream;
+
+ private var bytesAvailable:int;
+
+ private var initialized:Boolean = false;
+ private var playing:Boolean = false;
+
+ private var fill1:Boolean = true;
+ private var fill2:Boolean = true;
+
+ private var stopped: Boolean = false;
+ private var completeEventDispatched: Boolean = false;
+
+ public function VorbisSound(url: URLRequest ) {
+ urlStream = new URLStream();
+ urlStream.endian = Endian.LITTLE_ENDIAN;
+ urlStream.load(url);
+
+ Mdct.initialize();
+
+ oggStream = new UncachedUrlStream(urlStream);
+ oggStream.addEventListener('progress', progress);
+ bytesAvailable = oggStream.bytesAvailable;
+ addEventListener("sampleData", sampleGenerator);
+ }
+
+ private function initialize():void {
+ vorbisStream = new VorbisStream(oggStream.getLogicalOggStream());
+ setTimeout(dispatchEvent, 100, new Event(METADATA_UPDATE));
+ initialized = true;
+ }
+
+ private var samplesPlayed: int = 0;
+
+ private function sampleGenerator(event:SampleDataEvent):void {
+
+ if(stopped) {
+ return;
+ }
+
+ if(Mdct.initialized && !initialized && bytesAvailable > 64*1024) {
+ initialize();
+ }
+
+ if(initialized && bytesAvailable > 16*1024 && !vorbisStream.finished) {
+ var cnt: int;
+ cnt = vorbisStream.readPcm(event.data);
+ samplesPlayed += cnt;
+ if(cnt < 2048 && oggStream.bytesAvailable > 0) {
+ vorbisStream = new VorbisStream(oggStream.getLogicalOggStream());
+ setTimeout(dispatchEvent, 100, new Event(METADATA_UPDATE));
+ samplesPlayed += vorbisStream.readPcm(event.data);
+ }
+ }
+ else if(vorbisStream == null || !vorbisStream.finished) {
+ for(var c:int=0; c<2048; c++) {
+ event.data.writeFloat(0);
+ event.data.writeFloat(0);
+ }
+ }
+
+ if(initialized && vorbisStream.finished && oggStream.bytesAvailable == 0 && !completeEventDispatched) {
+ dispatchEvent(new Event(Event.COMPLETE));
+ completeEventDispatched = true;
+ }
+
+ //trace("samples played: " + samplesPlayed + "/" + oggStream.bytesAvailable);
+
+ }
+
+ public function stop(): void {
+ stopped = true;
+ }
+
+ public function progress(event:ProgressEvent):void {
+ bytesAvailable = oggStream.bytesAvailable;
+ }
+
+ public function get position(): int {
+ return samplesPlayed * 1000 / 44100;
+ }
+
+ public function getMetaData(key: String):String {
+ if(vorbisStream != null) {
+ return vorbisStream.commentHeader.comments[key];
+ }
+ else {
+ return null;
+ }
+ }
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.vorbis {
+
+ import flash.events.SampleDataEvent;
+ import flash.utils.ByteArray;
+ import flash.utils.Endian;
+ import org.omtk.util.*;
+ import org.omtk.ogg.*;
+
+ public class VorbisStream {
+
+ private const IDENTIFICATION_HEADER:int = 1;
+ private const COMMENT_HEADER:int = 3;
+ private const SETUP_HEADER:int = 5;
+
+ private var source:LogicalOggStream;
+
+ private var _identificationHeader:IdentificationHeader;
+ private var _commentHeader:CommentHeader;
+ private var _setupHeader:SetupHeader;
+
+ private var _lastAudioPacket:AudioPacket;
+
+ private var _currentGranulePosition:int=0;
+ private var packetCounter:int;
+
+ private var _finished: Boolean = false;
+
+ public var windows:Vector.<Vector.<Number>> = new Vector.<Vector.<Number>>(8);
+
+ public function VorbisStream(source:LogicalOggStream) {
+
+ this.source = source;
+
+ for (var i:int = 0; i < 3; i++) {
+
+ var data:BitByteArray = source.getNextOggPacket().data;
+ var headerType:int = data.readUnsignedByte();
+
+ switch(headerType) {
+ case IDENTIFICATION_HEADER:
+ _identificationHeader = new IdentificationHeader(data);
+ break;
+ case COMMENT_HEADER:
+ _commentHeader = new CommentHeader(data);
+ break;
+ case SETUP_HEADER:
+ _setupHeader = new SetupHeader(this, data);
+ break;
+ }
+ }
+
+ }
+
+ public function get identificationHeader():IdentificationHeader {
+ return _identificationHeader;
+ }
+
+ public function get commentHeader():CommentHeader {
+ return _commentHeader;
+ }
+
+ public function get setupHeader():SetupHeader {
+ return _setupHeader;
+ }
+
+ public function readPcm(data:ByteArray): int {
+
+ var total:int;
+ var i:int;
+
+ if(_lastAudioPacket == null) {
+ _lastAudioPacket = getNextAudioPacket();
+ }
+
+ total = 0;
+
+ while(total < 2048 && !_finished) {
+ try {
+ var ap:AudioPacket = getNextAudioPacket();
+ total += ap.readPcm(_lastAudioPacket, data);
+ _lastAudioPacket = ap;
+ }
+ catch(e: EndOfOggStreamError) {
+ // ok, stream finished
+ _finished = true;
+ }
+ }
+
+ return total;
+ }
+
+ private function getNextAudioPacket():AudioPacket {
+ packetCounter++;
+ var packet:OggPacket = source.getNextOggPacket();
+ var res:AudioPacket = new AudioPacket(this, packet, _currentGranulePosition);
+ if(_lastAudioPacket != null) {
+ // don't count the first packet, since it doesn't contain any "real" samples
+ _currentGranulePosition += res.numberOfSamples;
+ }
+ return res;
+ }
+
+ public function get finished() : Boolean {
+ return _finished;
+ }
+
+ public function get currentGranulePosition(): int {
+ return _currentGranulePosition;
+ }
+ }
+
+}
\ No newline at end of file
--- /dev/null
+-main org.omtk.vorbis.MdctHX
+-swf-version 10
+-swf hxmdct.swf
--- /dev/null
+/*
+
+Copyright 2008 Tor-Einar Jarnbjo
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+package org.omtk.vorbis;
+
+import flash.Vector;
+
+class MdctHX {
+
+ private static var cPI1_8:Float = 0.92387953251128675613;
+ private static var cPI2_8:Float = 0.70710678118654752441;
+ private static var cPI3_8:Float = 0.38268343236508977175;
+
+ private var n:Int;
+ private var log2n:Int;
+ private var trig:Vector<Float>;
+ private var bitrev:Vector<Int>;
+
+ private var dtmp1:Float;
+ private var dtmp2:Float;
+ private var dtmp3:Float;
+ private var dtmp4:Float;
+
+ private var x:Vector<Float>;
+ private var w:Vector<Float>;
+
+ public function new(n:Int) {
+ this.n = n;
+
+ var i:Int;
+ var j:Int;
+
+ bitrev = new Vector<Int>();
+ trig = new Vector<Float>(Std.int(n+n/4), true);
+
+ for(i in 0...Std.int(n+n/4)) {
+ trig[i] = 0;
+ }
+
+ x = new Vector<Float>(Std.int(n/2), true);
+ w = new Vector<Float>(Std.int(n/2), true);
+
+ for(i in 0...Std.int(n/2)) {
+ x[i] = 0;
+ w[i] = 0;
+ }
+
+ var n2:Int = n >>> 1;
+ log2n = Math.round(Math.log(n) / Math.log(2));
+
+ var AE:Int = 0;
+ var AO:Int = 1;
+ var BE:Int = Std.int(AE + n / 2);
+ var BO:Int = BE + 1;
+ var CE:Int = Std.int(BE + n / 2);
+ var CO:Int = CE + 1;
+
+ for (i in 0...Std.int(n/4)) {
+ trig[AE + i * 2] = Math.cos((Math.PI / n) * (4 * i));
+ trig[AO + i * 2] = -Math.sin((Math.PI / n) * (4 * i));
+ trig[BE + i * 2] = Math.cos((Math.PI / (2 * n)) * (2 * i + 1));
+ trig[BO + i * 2] = Math.sin((Math.PI / (2 * n)) * (2 * i + 1));
+ }
+
+ for (i in 0...Std.int(n/8)) {
+ trig[CE + i * 2] = Math.cos((Math.PI / n) * (4 * i + 2));
+ trig[CO + i * 2] = -Math.sin((Math.PI / n) * (4 * i + 2));
+ }
+
+ var mask:Int = (1 << (log2n - 1)) - 1;
+ var msb:Int = 1 << (log2n - 2);
+
+ for (i in 0...Std.int(n/8)) {
+ var acc:Int = 0;
+ j = 0;
+ while(msb>>>j!=0) {
+ if (((msb >>> j) & i) != 0) {
+ acc |= 1 << j;
+ }
+ j++;
+ }
+ bitrev[i * 2] = ((~acc) & mask);
+ bitrev[i * 2 + 1] = acc;
+ }
+
+ }
+
+ public function imdct(frq:Vector<Float>, window:Vector<Float>, pcm:Vector<Float>):Void {
+
+ var i:Int;
+
+ var n2:Int;
+ var n4:Int;
+ var n8:Int;
+
+ var inO:Int;
+ var xO:Int;
+ var A:Int;
+
+ var temp1:Float;
+ var temp2:Float;
+
+ var B:Int;
+ var o1:Int;
+ var o2:Int;
+ var o3:Int;
+ var o4:Int;
+
+ var xx:Int;
+ var xxx:Vector<Float>;
+
+ n2 = n >> 1;
+ n4 = n >> 2;
+ n8 = n >> 3;
+
+ inO = -1;
+ xO = 0;
+ A = n2;
+
+ temp1 = 0.0;
+ temp2 = 0.0;
+
+ for (i in 0...n8) {
+ dtmp1 = frq[inO += 2];
+ dtmp2 = frq[inO += 2];
+ dtmp3 = trig[--A];
+ dtmp4 = trig[--A];
+ x[xO++] = -dtmp2 * dtmp3 - dtmp1 * dtmp4;
+ x[xO++] = dtmp1 * dtmp3 - dtmp2 * dtmp4;
+ }
+
+ inO = n2;
+
+ for(i in 0...n8) {
+ dtmp1 = frq[inO -= 2];
+ dtmp2 = frq[inO -= 2];
+ dtmp3 = trig[--A];
+ dtmp4 = trig[--A];
+ x[xO++] = dtmp2 * dtmp3 + dtmp1 * dtmp4;
+ x[xO++] = dtmp2 * dtmp4 - dtmp1 * dtmp3;
+ }
+
+ xxx = kernel(x, w, n, n2, n4, n8);
+ xx = 0;
+
+ B = n2;
+ o1 = n4;
+ o2 = o1 - 1;
+ o3 = n4 + n2;
+ o4 = o3 - 1;
+
+ for (i in 0...n4) {
+ dtmp1 = xxx[xx++];
+ dtmp2 = xxx[xx++];
+ dtmp3 = trig[B++];
+ dtmp4 = trig[B++];
+
+ temp1 = (dtmp1 * dtmp4 - dtmp2 * dtmp3);
+ temp2 = -(dtmp1 * dtmp3 + dtmp2 * dtmp4);
+
+ pcm[o1] = -temp1 * window[o1];
+ pcm[o2] = temp1 * window[o2];
+ pcm[o3] = temp2 * window[o3];
+ pcm[o4] = temp2 * window[o4];
+
+ o1++;
+ o2--;
+ o3++;
+ o4--;
+ }
+
+ }
+
+ private inline function kernel(x:Vector<Float>, w:Vector<Float>, n:Int, n2:Int, n4:Int, n8:Int):Vector<Float> {
+
+ var i:Int;
+ var r:Int;
+ var s:Int;
+ var rlim:Int;
+ var slim:Int;
+
+ var xA:Int = n4;
+ var xB:Int = 0;
+ var w1:Int = 0;
+ var w2:Int = n4;
+ var A:Int = n2;
+
+ var x0:Float;
+ var x1:Float;
+ var wA:Float;
+ var wB:Float;
+ var wC:Float;
+ var wD:Float;
+ var k0:Int;
+ var k1:Int;
+ var t1:Int;
+ var t2:Int;
+
+ var wbase:Int;
+ var temp:Vector<Float>;
+
+ var wACE:Float;
+ var wBCE:Float;
+ var wACO:Float;
+ var wBCO:Float;
+
+ var AEv:Float;
+ var AOv:Float;
+
+ i=0;
+ while(i < n4) {
+ x0 = x[xA] - x[xB];
+
+ w[w2 + i] = x[xA++] + x[xB++];
+
+ x1 = x[xA] - x[xB];
+ A -= 4;
+
+ w[i++] = x0 * trig[A] + x1 * trig[A + 1];
+ w[i] = x1 * trig[A] - x0 * trig[A + 1];
+
+ w[w2 + i] = x[xA++] + x[xB++];
+ i++;
+ }
+
+ for (i in 0...log2n-3) {
+ k0 = n >>> (i + 2);
+ k1 = 1 << (i + 3);
+ wbase = n2 - 2;
+
+ A = 0;
+
+ rlim = k0 >>> 2;
+ for (r in 0...rlim) {
+
+ w1 = wbase;
+ w2 = w1 - (k0 >> 1);
+ AEv = trig[A];
+ AOv = trig[A + 1];
+ wbase -= 2;
+
+ k0++;
+
+ slim = 2 << i;
+ for (s in 0...slim) {
+ dtmp1 = w[w1];
+ dtmp2 = w[w2];
+ wB = dtmp1 - dtmp2;
+ x[w1] = dtmp1 + dtmp2;
+ dtmp1 = w[++w1];
+ dtmp2 = w[++w2];
+ wA = dtmp1 - dtmp2;
+ x[w1] = dtmp1 + dtmp2;
+ x[w2] = wA * AEv - wB * AOv;
+ x[w2-1] = wB * AEv + wA * AOv;
+ w1 -= k0;
+ w2 -= k0;
+ }
+ k0--;
+ A += k1;
+ }
+
+ temp = w;
+ w = x;
+ x = temp;
+ }
+
+
+ var C:Int = n;
+ var bit:Int = 0;
+ var xx1:Int = 0;
+ var xx2:Int = n2 - 1;
+
+ var wt1: Float;
+ var wt2: Float;
+ var wt12: Float;
+ var wt21: Float;
+ var trigV: Float;
+
+ for (i in 0...n8) {
+ t1 = bitrev[bit++];
+ t2 = bitrev[bit++];
+
+ wt1 = w[t1];
+ wt2 = w[t2];
+ wt12 = w[t1-1];
+ wt21 = w[t2+1];
+
+ wA = wt1 - wt21;
+ wB = wt12 + wt2;
+ wC = wt1 + wt21;
+ wD = wt12 - wt2;
+
+ trigV = trig[C];
+
+ wACE = wA * trigV;
+ wBCE = wB * trigV;
+
+ trigV = trig[++C];
+
+ wACO = wA * trigV;
+ wBCO = wB * trigV;
+
+ ++C;
+
+ x[xx1++] = (wC + wACO + wBCE);
+ x[xx2--] = (-wD + wBCO - wACE);
+ x[xx1++] = (wD + wBCO - wACE);
+ x[xx2--] = (wC - wACO - wBCE);
+ }
+
+ return x;
+ }
+
+ /*
+ * Dummy function required for the haXe compiler to build this to
+ * a .SWF file.
+ */
+ public static function main() : Void {
+ }
+
+}
postEmbedJS: function()
{
var _this = this;
- js_log( 'embedFlow: uri:' + this.getSrc() + "\n" + mv_embed_path + 'binPlayers/flowplayer/flowplayer-3.0.1.swf' ) ;
+ js_log( 'embedFlow: uri:' + this.getSrc() + "\n" + mv_embed_path + 'libEmbedVideo/binPlayers/flowplayer/flowplayer-3.0.1.swf' ) ;
var flowConfig = {
clip: {
url: this.getSrc(),
}
} else {
// should be identical to cortado.jar
- applet_loc = mv_embed_path + 'binPlayers/cortado/cortado-ovt-stripped-0.5.0.jar';
+ applet_loc = mv_embed_path + 'libEmbedVideo/binPlayers/cortado/cortado-ovt-stripped-0.5.0.jar';
}
// load directly in the page..
// (media must be on the same server or applet must be signed)
return this.wrapEmebedContainer( embed_code );
},
getEmbedObj:function() {
- var player_path = mv_embed_path + 'binPlayers/kaltura-player';
+ var player_path = mv_embed_path + 'libEmbedVideo/binPlayers/kaltura-player';
return '<object width="' + this.width + '" height="' + this.height + '" '+
'data="' + player_path + '/wrapper.swf" allowfullscreen="true" '+
'allownetworking="all" allowscriptaccess="always" '+
return this.wrapEmebedContainer( embed_code );
},
getEmbedObj:function() {
- var player_path = mv_embed_path + 'binPlayers/omtk-fx/omtkp.swf';
+ var player_path = mv_embed_path + 'libEmbedVideo/binPlayers/omtk-fx/omtkp.swf';
// player_path = 'omtkp.swf';
js_log( "player path: " + player_path );
return '<object id="' + this.pid + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="1" height="1">' +