mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 07:47:17 +00:00
Initial import of gstdashdemux sources
This commit is contained in:
parent
5d406192c3
commit
6fc0db0e0b
14 changed files with 6188 additions and 0 deletions
1
ext/dash/AUTHORS
Normal file
1
ext/dash/AUTHORS
Normal file
|
@ -0,0 +1 @@
|
|||
Orange
|
482
ext/dash/LICENSE
Normal file
482
ext/dash/LICENSE
Normal file
|
@ -0,0 +1,482 @@
|
|||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1991 Free Software Foundation, Inc.
|
||||
675 Mass Ave, Cambridge, MA 02139, USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the library GPL. It is
|
||||
numbered 2 because it goes with version 2 of the ordinary GPL.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Library General Public License, applies to some
|
||||
specially designated Free Software Foundation software, and to any
|
||||
other libraries whose authors decide to use it. You can use it for
|
||||
your libraries, 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
|
||||
this service 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 make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if
|
||||
you distribute copies of the library, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link a program with the library, you must provide
|
||||
complete object files to the recipients so that they can relink them
|
||||
with the library, after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
Our method of protecting your rights has two steps: (1) copyright
|
||||
the library, and (2) offer you this license which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
Also, for each distributor's protection, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
library. If the library is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original
|
||||
version, so that any problems introduced by others will not reflect on
|
||||
the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that companies distributing free
|
||||
software will individually obtain patent licenses, thus in effect
|
||||
transforming the program into proprietary software. To prevent this,
|
||||
we have made it clear that any patent must be licensed for everyone's
|
||||
free use or not licensed at all.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the ordinary
|
||||
GNU General Public License, which was designed for utility programs. This
|
||||
license, the GNU Library General Public License, applies to certain
|
||||
designated libraries. This license is quite different from the ordinary
|
||||
one; be sure to read it in full, and don't assume that anything in it is
|
||||
the same as in the ordinary license.
|
||||
|
||||
The reason we have a separate public license for some libraries is that
|
||||
they blur the distinction we usually make between modifying or adding to a
|
||||
program and simply using it. Linking a program with a library, without
|
||||
changing the library, is in some sense simply using the library, and is
|
||||
analogous to running a utility program or application program. However, in
|
||||
a textual and legal sense, the linked executable is a combined work, a
|
||||
derivative of the original library, and the ordinary General Public License
|
||||
treats it as such.
|
||||
|
||||
Because of this blurred distinction, using the ordinary General
|
||||
Public License for libraries did not effectively promote software
|
||||
sharing, because most developers did not use the libraries. We
|
||||
concluded that weaker conditions might promote sharing better.
|
||||
|
||||
However, unrestricted linking of non-free programs would deprive the
|
||||
users of those programs of all benefit from the free status of the
|
||||
libraries themselves. This Library General Public License is intended to
|
||||
permit developers of non-free programs to use free libraries, while
|
||||
preserving your freedom as a user of such programs to change the free
|
||||
libraries that are incorporated in them. (We have not seen how to achieve
|
||||
this as regards changes in header files, but we have achieved it as regards
|
||||
changes in the actual functions of the Library.) The hope is that this
|
||||
will lead to faster development of free libraries.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, while the latter only
|
||||
works together with the library.
|
||||
|
||||
Note that it is possible for a library to be covered by the ordinary
|
||||
General Public License rather than by this special one.
|
||||
|
||||
GNU LIBRARY GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library which
|
||||
contains a notice placed by the copyright holder or other authorized
|
||||
party saying it may be distributed under the terms of this Library
|
||||
General Public License (also called "this License"). Each licensee is
|
||||
addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also compile or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
c) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
d) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the source code distributed need not include anything that is normally
|
||||
distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
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
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Library 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 Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "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
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY 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
|
||||
LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey 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 library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
24
ext/dash/Makefile.am
Normal file
24
ext/dash/Makefile.am
Normal file
|
@ -0,0 +1,24 @@
|
|||
|
||||
plugin_LTLIBRARIES = libgstdashdemux.la
|
||||
|
||||
libgstdashdemux_la_SOURCES = \
|
||||
gstmpdparser.c \
|
||||
gstdashdemux.c \
|
||||
gstfragment.c \
|
||||
gsturidownloader.c \
|
||||
gstplugin.c
|
||||
|
||||
# headers we need but don't want installed
|
||||
noinst_HEADERS = \
|
||||
gstmpdparser.h \
|
||||
gstfragmented.h \
|
||||
gstfragment.h \
|
||||
gstdashdemux.h \
|
||||
gsturidownloader.h
|
||||
|
||||
# compiler and linker flags used to compile this plugin, set in configure.ac
|
||||
libgstdashdemux_la_CFLAGS = $(GST_CFLAGS)
|
||||
libgstdashdemux_la_LIBADD = $(GST_LIBS)
|
||||
libgstdashdemux_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
||||
libgstdashdemux_la_LIBTOOLFLAGS = --tag=disable-static
|
||||
|
35
ext/dash/README
Normal file
35
ext/dash/README
Normal file
|
@ -0,0 +1,35 @@
|
|||
dashdemux
|
||||
|
||||
GStreamer plugin allowing the playback of MPEG DASH streams.
|
||||
|
||||
The plugin is based on some basic objects defined in the GStreamer HLS
|
||||
Demux plugin from the gst-plugins-bad module.
|
||||
|
||||
Minimum requirements:
|
||||
- glib 2.32.1
|
||||
- gstreamer 0.10.36
|
||||
- gst-plugins-base 0.10.36
|
||||
- gst-plugins-good 0.10.31
|
||||
- gst-plugins-bad 0.10.23
|
||||
|
||||
The following patches need in addition to be applied:
|
||||
|
||||
isomp4 (from gst-plugins-good):
|
||||
https://bugzilla.gnome.org/show_bug.cgi?id=677535
|
||||
https://bugzilla.gnome.org/show_bug.cgi?id=678767
|
||||
https://bugzilla.gnome.org/show_bug.cgi?id=678772
|
||||
|
||||
decodebin2 (from gst-plugins-base):
|
||||
To be completed
|
||||
|
||||
To build gst-dashdemux:
|
||||
./autogen.sh
|
||||
./configure
|
||||
./make
|
||||
sudo make install
|
||||
|
||||
To launch gst-dashdemux:
|
||||
|
||||
gst-launch playbin2 uri=http://www-itec.uni-klu.ac.at/ftp/datasets/mmsys12/RedBullPlayStreets/redbull_4s/RedBullPlayStreets_4s_isoffmain_DIS_23009_1_v_2_1c2_2011_08_30.mpd
|
||||
|
||||
|
1347
ext/dash/gstdashdemux.c
Normal file
1347
ext/dash/gstdashdemux.c
Normal file
File diff suppressed because it is too large
Load diff
109
ext/dash/gstdashdemux.h
Normal file
109
ext/dash/gstdashdemux.h
Normal file
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* DASH demux plugin for GStreamer
|
||||
*
|
||||
* gstdashdemux.h
|
||||
*
|
||||
* Copyright (C) 2012 Orange
|
||||
*
|
||||
* Authors:
|
||||
* David Corvoysier <david.corvoysier@orange.com>
|
||||
* Hamid Zakari <hamid.zakari@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library (LICENSE); if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GST_DASH_DEMUX_H__
|
||||
#define __GST_DASH_DEMUX_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/base/gstadapter.h>
|
||||
#include <gst/gst.h>
|
||||
#include <gst/base/gstadapter.h>
|
||||
#include "gstmpdparser.h"
|
||||
#include "gstfragmented.h"
|
||||
#include "gsturidownloader.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
#define GST_TYPE_DASH_DEMUX \
|
||||
(gst_dash_demux_get_type())
|
||||
#define GST_DASH_DEMUX(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DASH_DEMUX,GstDashDemux))
|
||||
#define GST_DASH_DEMUX_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DASH_DEMUX,GstDashDemuxClass))
|
||||
#define GST_IS_DASH_DEMUX(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DASH_DEMUX))
|
||||
#define GST_IS_DASH_DEMUX_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DASH_DEMUX))
|
||||
//
|
||||
typedef struct _GstDashDemux GstDashDemux;
|
||||
typedef struct _GstDashDemuxClass GstDashDemuxClass;
|
||||
/**
|
||||
* GstDashDemux:
|
||||
*
|
||||
* Opaque #GstDashDemux data structure.
|
||||
*/
|
||||
struct _GstDashDemux
|
||||
{
|
||||
GstElement parent;
|
||||
GstPad *sinkpad;
|
||||
GstPad *srcpad[3]; /*Video/Audio/Application src pad*/
|
||||
GstCaps *output_caps[3]; /*Video/Audio/Application output buf caps*/
|
||||
GstCaps *input_caps[3]; /*Video/Audio/Application input caps*/
|
||||
|
||||
GstBuffer *playlist;
|
||||
GstUriDownloader *downloader;
|
||||
GstMpdClient *client; /* MPD client */
|
||||
GQueue *queue; /*Video/Audio/Application List of fragment storing the fetched fragments */
|
||||
gboolean end_of_playlist;
|
||||
|
||||
/* Properties */
|
||||
GstClockTime min_buffering_time; /* Minimum buffering time accumulated before playback */
|
||||
GstClockTime max_buffering_time; /* Maximum buffering time accumulated during playback */
|
||||
gfloat bandwidth_usage; /* Percentage of the available bandwidth to use */
|
||||
guint64 max_bitrate; /* max of bitrate supported by target decoder */
|
||||
|
||||
/* Streaming task */
|
||||
GstTask *stream_task;
|
||||
GStaticRecMutex stream_lock;
|
||||
gboolean stop_stream_task;
|
||||
GMutex *stream_timed_lock;
|
||||
GTimeVal next_stream; /* Time of the next push */
|
||||
|
||||
/* Download task */
|
||||
GstTask *download_task;
|
||||
GStaticRecMutex download_lock;
|
||||
gboolean cancelled;
|
||||
GMutex *download_timed_lock;
|
||||
GTimeVal next_download; /* Time of the next download */
|
||||
|
||||
/* Position in the stream */
|
||||
GstClockTime position;
|
||||
GstClockTime position_shift;
|
||||
gboolean need_segment;
|
||||
/* Download rate */
|
||||
guint64 dnl_rate;
|
||||
};
|
||||
|
||||
struct _GstDashDemuxClass
|
||||
{
|
||||
GstElementClass parent_class;
|
||||
};
|
||||
|
||||
GType gst_dash_demux_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
#endif /* __GST_DASH_DEMUX_H__ */
|
||||
|
281
ext/dash/gstfragment.c
Normal file
281
ext/dash/gstfragment.c
Normal file
|
@ -0,0 +1,281 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2011 Andoni Morales Alastruey <ylatuya@gmail.com>
|
||||
*
|
||||
* gstfragment.c:
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include <gst/base/gsttypefindhelper.h>
|
||||
#include "gstfragmented.h"
|
||||
#include "gstfragment.h"
|
||||
|
||||
#define GST_CAT_DEFAULT fragmented_debug
|
||||
|
||||
#define GST_FRAGMENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_FRAGMENT, GstFragmentPrivate))
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_INDEX,
|
||||
PROP_NAME,
|
||||
PROP_DURATION,
|
||||
PROP_DISCONTINOUS,
|
||||
PROP_BUFFER_LIST,
|
||||
PROP_CAPS,
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
struct _GstFragmentPrivate
|
||||
{
|
||||
GstBufferList *buffer_list;
|
||||
guint64 size;
|
||||
GstBufferListIterator *buffer_iterator;
|
||||
GstCaps *caps;
|
||||
GMutex lock;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (GstFragment, gst_fragment, G_TYPE_OBJECT);
|
||||
|
||||
static void gst_fragment_dispose (GObject * object);
|
||||
static void gst_fragment_finalize (GObject * object);
|
||||
|
||||
static void
|
||||
gst_fragment_set_property (GObject * object,
|
||||
guint property_id, const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GstFragment *fragment = GST_FRAGMENT (object);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_CAPS:
|
||||
gst_fragment_set_caps (fragment, g_value_get_boxed (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
/* We don't have any other property... */
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gst_fragment_get_property (GObject * object,
|
||||
guint property_id, GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GstFragment *fragment = GST_FRAGMENT (object);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_INDEX:
|
||||
g_value_set_uint (value, fragment->index);
|
||||
break;
|
||||
|
||||
case PROP_NAME:
|
||||
g_value_set_string (value, fragment->name);
|
||||
break;
|
||||
|
||||
case PROP_DURATION:
|
||||
g_value_set_uint64 (value, fragment->stop_time - fragment->start_time);
|
||||
break;
|
||||
|
||||
case PROP_DISCONTINOUS:
|
||||
g_value_set_boolean (value, fragment->discontinuous);
|
||||
break;
|
||||
|
||||
case PROP_BUFFER_LIST:
|
||||
g_value_set_object (value, gst_fragment_get_buffer_list (fragment));
|
||||
break;
|
||||
|
||||
case PROP_CAPS:
|
||||
g_value_set_boxed (value, gst_fragment_get_caps (fragment));
|
||||
break;
|
||||
|
||||
default:
|
||||
/* We don't have any other property... */
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
gst_fragment_class_init (GstFragmentClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
g_type_class_add_private (klass, sizeof (GstFragmentPrivate));
|
||||
|
||||
gobject_class->set_property = gst_fragment_set_property;
|
||||
gobject_class->get_property = gst_fragment_get_property;
|
||||
gobject_class->dispose = gst_fragment_dispose;
|
||||
gobject_class->finalize = gst_fragment_finalize;
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_INDEX,
|
||||
g_param_spec_uint ("index", "Index", "Index of the fragment", 0,
|
||||
G_MAXUINT, 0, G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_NAME,
|
||||
g_param_spec_string ("name", "Name",
|
||||
"Name of the fragment (eg:fragment-12.ts)", NULL, G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_DISCONTINOUS,
|
||||
g_param_spec_boolean ("discontinuous", "Discontinous",
|
||||
"Whether this fragment has a discontinuity or not",
|
||||
FALSE, G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_DURATION,
|
||||
g_param_spec_uint64 ("duration", "Fragment duration",
|
||||
"Duration of the fragment", 0, G_MAXUINT64, 0, G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_BUFFER_LIST,
|
||||
g_param_spec_object ("buffer-list", "Buffer List",
|
||||
"A list with the fragment's buffers", GST_TYPE_FRAGMENT,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_CAPS,
|
||||
g_param_spec_boxed ("caps", "Fragment caps",
|
||||
"The caps of the fragment's buffer. (NULL = detect)", GST_TYPE_CAPS,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
|
||||
static void
|
||||
gst_fragment_init (GstFragment * fragment)
|
||||
{
|
||||
GstFragmentPrivate *priv;
|
||||
|
||||
fragment->priv = priv = GST_FRAGMENT_GET_PRIVATE (fragment);
|
||||
|
||||
g_mutex_init (&fragment->priv->lock);
|
||||
priv->buffer_list = gst_buffer_list_new ();
|
||||
priv->size = 0;
|
||||
priv->buffer_iterator = gst_buffer_list_iterate (priv->buffer_list);
|
||||
gst_buffer_list_iterator_add_group (priv->buffer_iterator);
|
||||
fragment->download_start_time = g_get_real_time ();
|
||||
fragment->start_time = 0;
|
||||
fragment->stop_time = 0;
|
||||
fragment->index = 0;
|
||||
fragment->name = g_strdup ("");
|
||||
fragment->completed = FALSE;
|
||||
fragment->discontinuous = FALSE;
|
||||
}
|
||||
|
||||
GstFragment *
|
||||
gst_fragment_new (void)
|
||||
{
|
||||
return GST_FRAGMENT (g_object_new (GST_TYPE_FRAGMENT, NULL));
|
||||
}
|
||||
|
||||
static void
|
||||
gst_fragment_finalize (GObject * gobject)
|
||||
{
|
||||
GstFragment *fragment = GST_FRAGMENT (gobject);
|
||||
|
||||
g_free (fragment->name);
|
||||
g_mutex_clear (&fragment->priv->lock);
|
||||
|
||||
G_OBJECT_CLASS (gst_fragment_parent_class)->finalize (gobject);
|
||||
}
|
||||
|
||||
void
|
||||
gst_fragment_dispose (GObject * object)
|
||||
{
|
||||
GstFragmentPrivate *priv = GST_FRAGMENT (object)->priv;
|
||||
|
||||
if (priv->buffer_list != NULL) {
|
||||
gst_buffer_list_iterator_free (priv->buffer_iterator);
|
||||
gst_buffer_list_unref (priv->buffer_list);
|
||||
priv->buffer_list = NULL;
|
||||
priv->size = 0;
|
||||
}
|
||||
|
||||
if (priv->caps != NULL) {
|
||||
gst_caps_unref (priv->caps);
|
||||
priv->caps = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (gst_fragment_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
GstBufferList *
|
||||
gst_fragment_get_buffer_list (GstFragment * fragment)
|
||||
{
|
||||
g_return_val_if_fail (fragment != NULL, NULL);
|
||||
|
||||
if (!fragment->completed)
|
||||
return NULL;
|
||||
|
||||
gst_buffer_list_ref (fragment->priv->buffer_list);
|
||||
return fragment->priv->buffer_list;
|
||||
}
|
||||
|
||||
void
|
||||
gst_fragment_set_caps (GstFragment * fragment, GstCaps * caps)
|
||||
{
|
||||
g_return_if_fail (fragment != NULL);
|
||||
|
||||
g_mutex_lock (&fragment->priv->lock);
|
||||
gst_caps_replace (&fragment->priv->caps, caps);
|
||||
g_mutex_unlock (&fragment->priv->lock);
|
||||
}
|
||||
|
||||
GstCaps *
|
||||
gst_fragment_get_caps (GstFragment * fragment)
|
||||
{
|
||||
g_return_val_if_fail (fragment != NULL, NULL);
|
||||
|
||||
if (!fragment->completed)
|
||||
return NULL;
|
||||
|
||||
g_mutex_lock (&fragment->priv->lock);
|
||||
if (fragment->priv->caps == NULL) {
|
||||
GstBuffer *buf = gst_buffer_list_get (fragment->priv->buffer_list, 0, 0);
|
||||
fragment->priv->caps = gst_type_find_helper_for_buffer (NULL, buf, NULL);
|
||||
}
|
||||
gst_caps_ref (fragment->priv->caps);
|
||||
g_mutex_unlock (&fragment->priv->lock);
|
||||
|
||||
return fragment->priv->caps;
|
||||
}
|
||||
|
||||
guint64
|
||||
gst_fragment_get_buffer_size (GstFragment * fragment)
|
||||
{
|
||||
g_return_val_if_fail (fragment != NULL, 0);
|
||||
|
||||
if (!fragment->completed)
|
||||
return 0;
|
||||
return fragment->priv->size;
|
||||
}
|
||||
|
||||
|
||||
|
||||
gboolean
|
||||
gst_fragment_add_buffer (GstFragment * fragment, GstBuffer * buffer)
|
||||
{
|
||||
g_return_val_if_fail (fragment != NULL, FALSE);
|
||||
g_return_val_if_fail (buffer != NULL, FALSE);
|
||||
|
||||
if (fragment->completed) {
|
||||
GST_WARNING ("Fragment is completed, could not add more buffers");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gst_buffer_list_iterator_add (fragment->priv->buffer_iterator, buffer);
|
||||
fragment->priv->size = fragment->priv->size + GST_BUFFER_SIZE (buffer);
|
||||
return TRUE;
|
||||
}
|
||||
|
72
ext/dash/gstfragment.h
Normal file
72
ext/dash/gstfragment.h
Normal file
|
@ -0,0 +1,72 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2011 Andoni Morales Alastruey <ylatuya@gmail.com>
|
||||
*
|
||||
* gstfragment.h:
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GSTFRAGMENT_H__
|
||||
#define __GSTFRAGMENT_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_FRAGMENT (gst_fragment_get_type())
|
||||
#define GST_FRAGMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FRAGMENT,GstFragment))
|
||||
#define GST_FRAGMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FRAGMENT,GstFragmentClass))
|
||||
#define GST_IS_FRAGMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FRAGMENT))
|
||||
#define GST_IS_FRAGMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FRAGMENT))
|
||||
|
||||
typedef struct _GstFragment GstFragment;
|
||||
typedef struct _GstFragmentPrivate GstFragmentPrivate;
|
||||
typedef struct _GstFragmentClass GstFragmentClass;
|
||||
|
||||
struct _GstFragment
|
||||
{
|
||||
GObject parent;
|
||||
|
||||
gchar * name; /* Name of the fragment */
|
||||
gboolean completed; /* Whether the fragment is complete or not */
|
||||
guint64 download_start_time; /* Epoch time when the download started */
|
||||
guint64 download_stop_time; /* Epoch time when the download finished */
|
||||
guint64 start_time; /* Start time of the fragment */
|
||||
guint64 stop_time; /* Stop time of the fragment */
|
||||
gboolean index; /* Index of the fragment */
|
||||
gboolean discontinuous; /* Whether this fragment is discontinuous or not */
|
||||
|
||||
GstFragmentPrivate *priv;
|
||||
};
|
||||
|
||||
struct _GstFragmentClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
GType gst_fragment_get_type (void);
|
||||
|
||||
guint64 gst_fragment_get_buffer_size (GstFragment * fragment);
|
||||
GstBufferList * gst_fragment_get_buffer_list (GstFragment *fragment);
|
||||
void gst_fragment_set_caps (GstFragment * fragment, GstCaps * caps);
|
||||
GstCaps * gst_fragment_get_caps (GstFragment * fragment);
|
||||
gboolean gst_fragment_add_buffer (GstFragment *fragment, GstBuffer *buffer);
|
||||
GstFragment * gst_fragment_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
#endif /* __GSTFRAGMENT_H__ */
|
||||
|
16
ext/dash/gstfragmented.h
Normal file
16
ext/dash/gstfragmented.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef __GST_FRAGMENTED_H__
|
||||
#define __GST_FRAGMENTED_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GST_DEBUG_CATEGORY_EXTERN (fragmented_debug);
|
||||
|
||||
#define LOG_CAPS(obj, caps) GST_DEBUG_OBJECT (obj, "%s: %" GST_PTR_FORMAT, #caps, caps)
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_FRAGMENTED_H__ */
|
||||
|
||||
|
2897
ext/dash/gstmpdparser.c
Normal file
2897
ext/dash/gstmpdparser.c
Normal file
File diff suppressed because it is too large
Load diff
489
ext/dash/gstmpdparser.h
Normal file
489
ext/dash/gstmpdparser.h
Normal file
|
@ -0,0 +1,489 @@
|
|||
/*
|
||||
* gstmpdparser.h - DASH MPD helper library
|
||||
* Copyright (C) 2012 STMicroelectronics
|
||||
* Authors:
|
||||
* Gianluca Gennari <gennarone@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the
|
||||
* GNU Lesser General Public License Version 2.1 (the "LGPL"), in
|
||||
* which case the following provisions apply instead of the ones
|
||||
* mentioned above:
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GST_MPDPARSER_H__
|
||||
#define __GST_MPDPARSER_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GstMpdClient GstMpdClient;
|
||||
typedef struct _GstActiveStream GstActiveStream;
|
||||
typedef struct _GstMediaSegment GstMediaSegment;
|
||||
typedef struct _GstMPDNode GstMPDNode;
|
||||
typedef struct _GstPeriodNode GstPeriodNode;
|
||||
typedef struct _GstRepresentationBaseType GstRepresentationBaseType;
|
||||
typedef struct _GstDescriptorType GstDescriptorType;
|
||||
typedef struct _GstContentComponentNode GstContentComponentNode;
|
||||
typedef struct _GstAdaptationSetNode GstAdaptationSetNode;
|
||||
typedef struct _GstRepresentationNode GstRepresentationNode;
|
||||
typedef struct _GstSubRepresentationNode GstSubRepresentationNode;
|
||||
typedef struct _GstSegmentListNode GstSegmentListNode;
|
||||
typedef struct _GstSegmentTemplateNode GstSegmentTemplateNode;
|
||||
typedef struct _GstSegmentURLNode GstSegmentURLNode;
|
||||
typedef struct _GstBaseURL GstBaseURL;
|
||||
typedef struct _GstRange GstRange;
|
||||
typedef struct _GstRatio GstRatio;
|
||||
typedef struct _GstFrameRate GstFrameRate;
|
||||
typedef struct _GstConditionalUintType GstConditionalUintType;
|
||||
typedef struct _GstSubsetNode GstSubsetNode;
|
||||
typedef struct _GstProgramInformationNode GstProgramInformationNode;
|
||||
typedef struct _GstMetricsRangeNode GstMetricsRangeNode;
|
||||
typedef struct _GstMetricsNode GstMetricsNode;
|
||||
typedef struct _GstSNode GstSNode;
|
||||
typedef struct _GstSegmentTimelineNode GstSegmentTimelineNode;
|
||||
typedef struct _GstSegmentBaseType GstSegmentBaseType;
|
||||
typedef struct _GstURLType GstURLType;
|
||||
typedef struct _GstMultSegmentBaseType GstMultSegmentBaseType;
|
||||
|
||||
#define GST_MPD_CLIENT_LOCK(c) g_mutex_lock (c->lock);
|
||||
#define GST_MPD_CLIENT_UNLOCK(c) g_mutex_unlock (c->lock);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GST_STREAM_VIDEO, /* video stream (the main one) */
|
||||
GST_STREAM_AUDIO, /* audio stream (optional) */
|
||||
GST_STREAM_APPLICATION /* application stream (optional): for timed text/subtitles */
|
||||
} GstStreamMimeType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GST_MPD_FILE_TYPE_STATIC,
|
||||
GST_MPD_FILE_TYPE_DYNAMIC
|
||||
} GstMPDFileType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GST_SAP_TYPE_0 = 0,
|
||||
GST_SAP_TYPE_1,
|
||||
GST_SAP_TYPE_2,
|
||||
GST_SAP_TYPE_3,
|
||||
GST_SAP_TYPE_4,
|
||||
GST_SAP_TYPE_5,
|
||||
GST_SAP_TYPE_6
|
||||
} GstSAPType;
|
||||
|
||||
struct _GstBaseURL
|
||||
{
|
||||
gchar *baseURL;
|
||||
gchar *serviceLocation;
|
||||
gchar *byteRange;
|
||||
};
|
||||
|
||||
struct _GstRange
|
||||
{
|
||||
guint64 first_byte_pos;
|
||||
guint64 last_byte_pos;
|
||||
};
|
||||
|
||||
struct _GstRatio
|
||||
{
|
||||
guint num;
|
||||
guint den;
|
||||
};
|
||||
|
||||
struct _GstFrameRate
|
||||
{
|
||||
guint num;
|
||||
guint den;
|
||||
};
|
||||
|
||||
struct _GstConditionalUintType
|
||||
{
|
||||
gboolean flag;
|
||||
guint value;
|
||||
};
|
||||
|
||||
struct _GstSNode
|
||||
{
|
||||
guint t;
|
||||
guint d;
|
||||
guint r;
|
||||
};
|
||||
|
||||
struct _GstSegmentTimelineNode
|
||||
{
|
||||
/* list of S nodes (1..N) */
|
||||
GList *S;
|
||||
};
|
||||
|
||||
struct _GstURLType
|
||||
{
|
||||
gchar *sourceURL;
|
||||
GstRange *range;
|
||||
};
|
||||
|
||||
struct _GstSegmentBaseType
|
||||
{
|
||||
guint timescale;
|
||||
guint presentationTimeOffset;
|
||||
gchar *indexRange;
|
||||
gboolean indexRangeExact;
|
||||
/* Initialization node */
|
||||
GstURLType *Initialization;
|
||||
/* RepresentationIndex node */
|
||||
GstURLType *RepresentationIndex;
|
||||
};
|
||||
|
||||
struct _GstMultSegmentBaseType
|
||||
{
|
||||
guint duration; /* in seconds */
|
||||
guint startNumber;
|
||||
/* SegmentBaseType extension */
|
||||
GstSegmentBaseType *SegBaseType;
|
||||
/* SegmentTimeline node */
|
||||
GstSegmentTimelineNode *SegmentTimeline;
|
||||
/* BitstreamSwitching node */
|
||||
GstURLType *BitstreamSwitching;
|
||||
};
|
||||
|
||||
struct _GstSegmentListNode
|
||||
{
|
||||
/* extension */
|
||||
GstMultSegmentBaseType *MultSegBaseType;
|
||||
/* list of SegmentURL nodes */
|
||||
GList *SegmentURL;
|
||||
};
|
||||
|
||||
struct _GstSegmentTemplateNode
|
||||
{
|
||||
/* extension */
|
||||
GstMultSegmentBaseType *MultSegBaseType;
|
||||
gchar *media;
|
||||
gchar *index;
|
||||
gchar *initialization;
|
||||
gchar *bitstreamSwitching;
|
||||
};
|
||||
|
||||
struct _GstSegmentURLNode
|
||||
{
|
||||
gchar *media;
|
||||
GstRange *mediaRange;
|
||||
gchar *index;
|
||||
GstRange *indexRange;
|
||||
};
|
||||
|
||||
struct _GstRepresentationBaseType
|
||||
{
|
||||
gchar *profiles;
|
||||
guint width;
|
||||
guint height;
|
||||
GstRatio *sar;
|
||||
GstFrameRate *frameRate;
|
||||
gchar *audioSamplingRate;
|
||||
gchar *mimeType;
|
||||
gchar *segmentProfiles;
|
||||
gchar *codecs;
|
||||
gdouble maximumSAPPeriod;
|
||||
GstSAPType startWithSAP;
|
||||
gdouble maxPlayoutRate;
|
||||
gboolean codingDependency;
|
||||
gchar *scanType;
|
||||
/* list of FramePacking DescriptorType nodes */
|
||||
GList *FramePacking;
|
||||
/* list of AudioChannelConfiguration DescriptorType nodes */
|
||||
GList *AudioChannelConfiguration;
|
||||
/* list of ContentProtection DescriptorType nodes */
|
||||
GList *ContentProtection;
|
||||
};
|
||||
|
||||
struct _GstSubRepresentationNode
|
||||
{
|
||||
/* RepresentationBase extension */
|
||||
GstRepresentationBaseType *RepresentationBase;
|
||||
guint level;
|
||||
guint *dependencyLevel; /* UIntVectorType */
|
||||
guint size; /* size of "dependencyLevel" array */
|
||||
guint bandwidth;
|
||||
gchar **contentComponent; /* StringVectorType */
|
||||
};
|
||||
|
||||
struct _GstRepresentationNode
|
||||
{
|
||||
gchar *id;
|
||||
guint bandwidth;
|
||||
guint qualityRanking;
|
||||
gchar **dependencyId; /* StringVectorType */
|
||||
gchar **mediaStreamStructureId; /* StringVectorType */
|
||||
/* RepresentationBase extension */
|
||||
GstRepresentationBaseType *RepresentationBase;
|
||||
/* list of BaseURL nodes */
|
||||
GList *BaseURLs;
|
||||
/* list of SubRepresentation nodes */
|
||||
GList *SubRepresentations;
|
||||
/* SegmentBase node */
|
||||
GstSegmentBaseType *SegmentBase;
|
||||
/* SegmentTemplate node */
|
||||
GstSegmentTemplateNode *SegmentTemplate;
|
||||
/* list of SegmentList nodes */
|
||||
GList *SegmentList;
|
||||
};
|
||||
|
||||
struct _GstDescriptorType
|
||||
{
|
||||
gchar *schemeIdUri;
|
||||
gchar *value;
|
||||
};
|
||||
|
||||
struct _GstContentComponentNode
|
||||
{
|
||||
guint id;
|
||||
gchar *lang; /* LangVectorType RFC 5646 */
|
||||
gchar *contentType;
|
||||
GstRatio *par;
|
||||
/* list of Accessibility DescriptorType nodes */
|
||||
GList *Accessibility;
|
||||
/* list of Role DescriptorType nodes */
|
||||
GList *Role;
|
||||
/* list of Rating DescriptorType nodes */
|
||||
GList *Rating;
|
||||
/* list of Viewpoint DescriptorType nodes */
|
||||
GList *Viewpoint;
|
||||
};
|
||||
|
||||
struct _GstAdaptationSetNode
|
||||
{
|
||||
guint id;
|
||||
guint group;
|
||||
gchar *lang; /* LangVectorType RFC 5646 */
|
||||
gchar *contentType;
|
||||
GstRatio *par;
|
||||
guint minBandwidth;
|
||||
guint maxBandwidth;
|
||||
guint minWidth;
|
||||
guint maxWidth;
|
||||
guint minHeight;
|
||||
guint maxHeight;
|
||||
GstFrameRate *minFrameRate;
|
||||
GstFrameRate *maxFrameRate;
|
||||
GstConditionalUintType *segmentAlignment;
|
||||
GstConditionalUintType *subsegmentAlignment;
|
||||
GstSAPType subsegmentStartsWithSAP;
|
||||
gboolean bitstreamSwitching;
|
||||
/* RepresentationBase extension */
|
||||
GstRepresentationBaseType *RepresentationBase;
|
||||
/* SegmentBase node */
|
||||
GstSegmentBaseType *SegmentBase;
|
||||
/* SegmentTemplate node */
|
||||
GstSegmentTemplateNode *SegmentTemplate;
|
||||
/* list of BaseURL nodes */
|
||||
GList *BaseURLs;
|
||||
/* list of Representation nodes */
|
||||
GList *Representations;
|
||||
/* list of ContentComponent nodes */
|
||||
GList *ContentComponents;
|
||||
};
|
||||
|
||||
struct _GstSubsetNode
|
||||
{
|
||||
guint *contains; /* UIntVectorType */
|
||||
guint size; /* size of the "contains" array */
|
||||
};
|
||||
|
||||
struct _GstPeriodNode
|
||||
{
|
||||
gchar *id;
|
||||
gint64 start; /* [ms] */
|
||||
gint64 duration; /* [ms] */
|
||||
gboolean bitstreamSwitching;
|
||||
/* SegmentBase node */
|
||||
GstSegmentBaseType *SegmentBase;
|
||||
/* SegmentTemplate node */
|
||||
GstSegmentTemplateNode *SegmentTemplate;
|
||||
/* list of Adaptation Set nodes */
|
||||
GList *AdaptationSets;
|
||||
/* list of Representation nodes */
|
||||
GList *Representations;
|
||||
/* list of Subset nodes */
|
||||
GList *Subsets;
|
||||
/* list of BaseURL nodes */
|
||||
GList *BaseURLs;
|
||||
};
|
||||
|
||||
struct _GstProgramInformationNode
|
||||
{
|
||||
gchar *moreInformationURL;
|
||||
/* children nodes */
|
||||
gchar *Title;
|
||||
gchar *Source;
|
||||
gchar *Copyright;
|
||||
};
|
||||
|
||||
struct _GstMetricsRangeNode
|
||||
{
|
||||
gint64 starttime; /* [ms] */
|
||||
gint64 duration; /* [ms] */
|
||||
};
|
||||
|
||||
struct _GstMetricsNode
|
||||
{
|
||||
gchar *metrics;
|
||||
/* list of Metrics Range nodes */
|
||||
GList *MetricsRanges;
|
||||
/* list of Reporting nodes */
|
||||
GList *Reportings;
|
||||
};
|
||||
|
||||
struct _GstMPDNode
|
||||
{
|
||||
gchar *default_namespace;
|
||||
gchar *namespace_xsi;
|
||||
gchar *namespace_ext;
|
||||
gchar *schemaLocation;
|
||||
gchar *id;
|
||||
gchar *profiles;
|
||||
GstMPDFileType type;
|
||||
GstDateTime *availabilityStartTime;
|
||||
GstDateTime *availabilityEndTime;
|
||||
gint64 mediaPresentationDuration; /* [ms] */
|
||||
gint64 minimumUpdatePeriod; /* [ms] */
|
||||
gint64 minBufferTime; /* [ms] */
|
||||
gint64 timeShiftBufferDepth; /* [ms] */
|
||||
gint64 suggestedPresentationDelay; /* [ms] */
|
||||
gint64 maxSegmentDuration; /* [ms] */
|
||||
gint64 maxSubsegmentDuration; /* [ms] */
|
||||
/* list of BaseURL nodes */
|
||||
GList *BaseURLs;
|
||||
/* list of Location nodes */
|
||||
GList *Locations;
|
||||
/* ProgramInformation node */
|
||||
GstProgramInformationNode *ProgramInfo;
|
||||
/* list of Periods nodes */
|
||||
GList *Periods;
|
||||
/* list of Metrics nodes */
|
||||
GList *Metrics;
|
||||
};
|
||||
|
||||
/**
|
||||
* GstMediaSegment:
|
||||
*
|
||||
* Media segment data structure
|
||||
*/
|
||||
struct _GstMediaSegment
|
||||
{
|
||||
GstSegmentURLNode *SegmentURL; /* this is NULL when using a SegmentTemplate */
|
||||
guint number; /* segment number */
|
||||
GstClockTime start_time; /* segment start time */
|
||||
GstClockTime duration; /* segment duration */
|
||||
};
|
||||
|
||||
/**
|
||||
* GstActiveStream:
|
||||
*
|
||||
* Active stream data structure
|
||||
*/
|
||||
struct _GstActiveStream
|
||||
{
|
||||
GstStreamMimeType mimeType; /* video/audio/application */
|
||||
|
||||
guint baseURL_idx; /* index of the baseURL used for last request */
|
||||
gchar *baseURL; /* active baseURL used for last request */
|
||||
guint max_bandwidth; /* max bandwidth allowed for this mimeType */
|
||||
|
||||
GstAdaptationSetNode *cur_adapt_set; /* active adaptation set */
|
||||
gint representation_idx; /* index of current representation */
|
||||
GstRepresentationNode *cur_representation; /* active representation */
|
||||
GstSegmentBaseType *cur_segment_base; /* active segment base */
|
||||
GstSegmentListNode *cur_segment_list; /* active segment list */
|
||||
GstSegmentTemplateNode *cur_seg_template; /* active segment template */
|
||||
gint segment_idx; /* index of next sequence chunk */
|
||||
GList *segments; /* list of GstMediaSegment nodes */
|
||||
};
|
||||
|
||||
struct _GstMpdClient
|
||||
{
|
||||
GstMPDNode *mpd_node; /* active MPD manifest file */
|
||||
GstPeriodNode *cur_period; /* active period */
|
||||
|
||||
GList *active_streams; /* list of GstActiveStream (only one supported on the first implementation) */
|
||||
guint stream_idx; /* currently active stream */
|
||||
|
||||
guint update_failed_count;
|
||||
gchar *mpd_uri; /* manifest file URI */
|
||||
GMutex *lock;
|
||||
};
|
||||
|
||||
/* Basic initialization/deinitialization functions */
|
||||
GstMpdClient *gst_mpd_client_new ();
|
||||
void gst_mpd_client_free (GstMpdClient * client);
|
||||
|
||||
/* Basic parsing */
|
||||
gboolean gst_mpd_parse (GstMpdClient *client, const gchar *data, gint size);
|
||||
gboolean gst_mpd_client_setup_streaming (GstMpdClient *client, GstStreamMimeType mimeType);
|
||||
gboolean gst_mpd_client_setup_representation (GstMpdClient *client, GstActiveStream *stream, GstRepresentationNode *representation);
|
||||
void gst_mpd_client_get_current_position (GstMpdClient *client, GstClockTime * timestamp);
|
||||
GstClockTime gst_mpd_client_get_duration (GstMpdClient *client);
|
||||
GstClockTime gst_mpd_client_get_target_duration (GstMpdClient *client);
|
||||
gboolean gst_mpd_client_get_next_fragment (GstMpdClient *client, guint indexStream, gboolean *discontinuity, const gchar **uri, GstClockTime *duration, GstClockTime *timestamp);
|
||||
gboolean gst_mpd_client_get_next_header (GstMpdClient *client, const gchar **uri, guint stream_idx);
|
||||
gboolean gst_mpd_client_is_live (GstMpdClient * client);
|
||||
|
||||
/* Representation selection */
|
||||
gint gst_mpdparser_get_rep_idx_with_max_bandwidth (GList *Representations, gint max_bandwidth);
|
||||
|
||||
/* URL management */
|
||||
const gchar *gst_mpdparser_get_baseURL (GstMpdClient *client);
|
||||
GstMediaSegment *gst_mpdparser_get_chunk_by_index (GstMpdClient *client, guint indexStream, guint indexChunk);
|
||||
|
||||
/* Active stream */
|
||||
guint gst_mpdparser_get_nb_active_stream (GstMpdClient *client);
|
||||
GstActiveStream *gst_mpdparser_get_active_stream_by_index (GstMpdClient *client, gint stream_idx);
|
||||
|
||||
/* AdaptationSet */
|
||||
guint gst_mpdparser_get_nb_adaptationSet(GstMpdClient *client);
|
||||
|
||||
/* Get With and high of video parameter by stream */
|
||||
guint gst_mpd_client_get_width_of_video_current_stream (GstMpdClient *client, GstActiveStream *stream);
|
||||
guint gst_mpd_client_get_height_of_video_current_stream (GstMpdClient *client, GstActiveStream *stream);
|
||||
|
||||
/* Get channel and rate of audio parameter by stream */
|
||||
guint gst_mpd_client_get_rate_of_audio_current_stream (GstMpdClient *client, GstActiveStream *stream);
|
||||
guint gst_mpd_client_get_num_channels_of_audio_current_stream (GstMpdClient *client, GstActiveStream *stream);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_MPDPARSER_H__ */
|
||||
|
29
ext/dash/gstplugin.c
Normal file
29
ext/dash/gstplugin.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "gstfragmented.h"
|
||||
#include "gstdashdemux.h"
|
||||
|
||||
GST_DEBUG_CATEGORY (fragmented_debug);
|
||||
|
||||
static gboolean
|
||||
fragmented_init (GstPlugin * plugin)
|
||||
{
|
||||
GST_DEBUG_CATEGORY_INIT (fragmented_debug, "dashdemux", 0, "dashdemux");
|
||||
|
||||
if (!gst_element_register (plugin, "dashdemux", GST_RANK_PRIMARY,
|
||||
GST_TYPE_DASH_DEMUX) || FALSE)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
||||
GST_VERSION_MINOR,
|
||||
"fragmented",
|
||||
"Fragmented streaming plugins",
|
||||
fragmented_init, VERSION, "LGPL", PACKAGE_NAME, "http://www.gstreamer.org/")
|
||||
|
||||
|
341
ext/dash/gsturidownloader.c
Normal file
341
ext/dash/gsturidownloader.c
Normal file
|
@ -0,0 +1,341 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2011 Andoni Morales Alastruey <ylatuya@gmail.com>
|
||||
*
|
||||
* gstfragment.c:
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include "gstfragmented.h"
|
||||
#include "gstfragment.h"
|
||||
#include "gsturidownloader.h"
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (uridownloader_debug);
|
||||
#define GST_CAT_DEFAULT (uridownloader_debug)
|
||||
|
||||
#define GST_URI_DOWNLOADER_GET_PRIVATE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
|
||||
GST_TYPE_URI_DOWNLOADER, GstUriDownloaderPrivate))
|
||||
|
||||
struct _GstUriDownloaderPrivate
|
||||
{
|
||||
/* Fragments fetcher */
|
||||
GstElement *urisrc;
|
||||
GstBus *bus;
|
||||
GstPad *pad;
|
||||
GTimeVal *timeout;
|
||||
GstFragment *download;
|
||||
GMutex *lock;
|
||||
GCond *cond;
|
||||
};
|
||||
|
||||
static void gst_uri_downloader_finalize (GObject * object);
|
||||
static void gst_uri_downloader_dispose (GObject * object);
|
||||
|
||||
static GstFlowReturn gst_uri_downloader_chain (GstPad * pad, GstBuffer * buf);
|
||||
static gboolean gst_uri_downloader_sink_event (GstPad * pad, GstEvent * event);
|
||||
static GstBusSyncReply gst_uri_downloader_bus_handler (GstBus * bus,
|
||||
GstMessage * message, gpointer data);
|
||||
|
||||
static GstStaticPadTemplate sinkpadtemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS_ANY);
|
||||
|
||||
#define _do_init \
|
||||
{ \
|
||||
GST_DEBUG_CATEGORY_INIT (uridownloader_debug, "uridownloader", 0, "URI downloader"); \
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GstUriDownloader, gst_uri_downloader, GST_TYPE_OBJECT,
|
||||
_do_init);
|
||||
|
||||
static void
|
||||
gst_uri_downloader_class_init (GstUriDownloaderClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
|
||||
gobject_class = (GObjectClass *) klass;
|
||||
|
||||
g_type_class_add_private (klass, sizeof (GstUriDownloaderPrivate));
|
||||
|
||||
gobject_class->dispose = gst_uri_downloader_dispose;
|
||||
gobject_class->finalize = gst_uri_downloader_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_uri_downloader_init (GstUriDownloader * downloader)
|
||||
{
|
||||
downloader->priv = GST_URI_DOWNLOADER_GET_PRIVATE (downloader);
|
||||
|
||||
/* Initialize the sink pad. This pad will be connected to the src pad of the
|
||||
* element created with gst_element_make_from_uri and will handle the download */
|
||||
downloader->priv->pad =
|
||||
gst_pad_new_from_static_template (&sinkpadtemplate, "sink");
|
||||
gst_pad_set_chain_function (downloader->priv->pad,
|
||||
GST_DEBUG_FUNCPTR (gst_uri_downloader_chain));
|
||||
gst_pad_set_event_function (downloader->priv->pad,
|
||||
GST_DEBUG_FUNCPTR (gst_uri_downloader_sink_event));
|
||||
gst_pad_set_element_private (downloader->priv->pad, downloader);
|
||||
gst_pad_activate_push (downloader->priv->pad, TRUE);
|
||||
|
||||
/* Create a bus to handle error and warning message from the source element */
|
||||
downloader->priv->bus = gst_bus_new ();
|
||||
|
||||
downloader->priv->lock = g_mutex_new ();
|
||||
downloader->priv->cond = g_cond_new ();
|
||||
}
|
||||
|
||||
static void
|
||||
gst_uri_downloader_dispose (GObject * object)
|
||||
{
|
||||
GstUriDownloader *downloader = GST_URI_DOWNLOADER (object);
|
||||
|
||||
if (downloader->priv->urisrc != NULL) {
|
||||
gst_object_unref (downloader->priv->urisrc);
|
||||
downloader->priv->urisrc = NULL;
|
||||
}
|
||||
|
||||
if (downloader->priv->bus != NULL) {
|
||||
gst_object_unref (downloader->priv->bus);
|
||||
downloader->priv->bus = NULL;
|
||||
}
|
||||
|
||||
if (downloader->priv->pad) {
|
||||
gst_object_unref (downloader->priv->pad);
|
||||
downloader->priv->pad = NULL;
|
||||
}
|
||||
|
||||
if (downloader->priv->download) {
|
||||
g_object_unref (downloader->priv->download);
|
||||
downloader->priv->download = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (gst_uri_downloader_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_uri_downloader_finalize (GObject * object)
|
||||
{
|
||||
GstUriDownloader *downloader = GST_URI_DOWNLOADER (object);
|
||||
|
||||
g_mutex_free (downloader->priv->lock);
|
||||
g_cond_free (downloader->priv->cond);
|
||||
|
||||
G_OBJECT_CLASS (gst_uri_downloader_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
GstUriDownloader *
|
||||
gst_uri_downloader_new (void)
|
||||
{
|
||||
return g_object_new (GST_TYPE_URI_DOWNLOADER, NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_uri_downloader_sink_event (GstPad * pad, GstEvent * event)
|
||||
{
|
||||
GstUriDownloader *downloader =
|
||||
(GstUriDownloader *) (gst_pad_get_element_private (pad));
|
||||
|
||||
switch (event->type) {
|
||||
case GST_EVENT_EOS:{
|
||||
GST_OBJECT_LOCK (downloader);
|
||||
GST_DEBUG_OBJECT (downloader, "Got EOS on the fetcher pad");
|
||||
if (downloader->priv->download != NULL) {
|
||||
/* signal we have fetched the URI */
|
||||
downloader->priv->download->completed = TRUE;
|
||||
downloader->priv->download->download_stop_time = g_get_real_time ();
|
||||
GST_OBJECT_UNLOCK (downloader);
|
||||
GST_DEBUG_OBJECT (downloader, "Signaling chain funtion");
|
||||
g_cond_signal (downloader->priv->cond);
|
||||
|
||||
} else {
|
||||
GST_OBJECT_UNLOCK (downloader);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
gst_event_unref (event);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static GstBusSyncReply
|
||||
gst_uri_downloader_bus_handler (GstBus * bus,
|
||||
GstMessage * message, gpointer data)
|
||||
{
|
||||
GstUriDownloader *downloader = (GstUriDownloader *) (data);
|
||||
|
||||
if (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR ||
|
||||
GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING) {
|
||||
GST_WARNING_OBJECT (downloader,
|
||||
"Received error in bus from the source element, "
|
||||
"the download will be cancelled");
|
||||
/* remove the sync handler to avoid duplicated messages */
|
||||
gst_bus_set_sync_handler (downloader->priv->bus, NULL, NULL);
|
||||
gst_uri_downloader_cancel (downloader);
|
||||
}
|
||||
|
||||
gst_message_unref (message);
|
||||
return GST_BUS_DROP;
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_uri_downloader_chain (GstPad * pad, GstBuffer * buf)
|
||||
{
|
||||
GstUriDownloader *downloader =
|
||||
(GstUriDownloader *) gst_pad_get_element_private (pad);
|
||||
|
||||
/* HTML errors (404, 500, etc...) are also pushed through this pad as
|
||||
* response but the source element will also post a warning or error message
|
||||
* in the bus, which is handled synchronously cancelling the download.
|
||||
*/
|
||||
GST_OBJECT_LOCK (downloader);
|
||||
if (downloader->priv->download == NULL) {
|
||||
/* Download cancelled, quit */
|
||||
GST_OBJECT_UNLOCK (downloader);
|
||||
goto done;
|
||||
}
|
||||
|
||||
GST_LOG_OBJECT (downloader,
|
||||
"The uri fetcher received a new buffer of size %u",
|
||||
GST_BUFFER_SIZE (buf));
|
||||
if (!gst_fragment_add_buffer (downloader->priv->download, buf))
|
||||
GST_WARNING_OBJECT (downloader, "Could not add buffer to fragment");
|
||||
GST_OBJECT_UNLOCK (downloader);
|
||||
|
||||
done:
|
||||
{
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gst_uri_downloader_stop (GstUriDownloader * downloader)
|
||||
{
|
||||
GstPad *pad;
|
||||
|
||||
GST_DEBUG_OBJECT (downloader, "Stopping source element");
|
||||
|
||||
/* remove the bus' sync handler */
|
||||
gst_bus_set_sync_handler (downloader->priv->bus, NULL, NULL);
|
||||
/* unlink the source element from the internal pad */
|
||||
pad = gst_pad_get_peer (downloader->priv->pad);
|
||||
if (pad) {
|
||||
gst_pad_unlink (pad, downloader->priv->pad);
|
||||
gst_object_unref (pad);
|
||||
}
|
||||
/* set the element state to NULL */
|
||||
gst_element_set_state (downloader->priv->urisrc, GST_STATE_NULL);
|
||||
gst_element_get_state (downloader->priv->urisrc, NULL, NULL,
|
||||
GST_CLOCK_TIME_NONE);
|
||||
}
|
||||
|
||||
void
|
||||
gst_uri_downloader_cancel (GstUriDownloader * downloader)
|
||||
{
|
||||
GST_OBJECT_LOCK (downloader);
|
||||
if (downloader->priv->download != NULL) {
|
||||
GST_DEBUG_OBJECT (downloader, "Cancelling download");
|
||||
g_object_unref (downloader->priv->download);
|
||||
downloader->priv->download = NULL;
|
||||
GST_OBJECT_UNLOCK (downloader);
|
||||
GST_DEBUG_OBJECT (downloader, "Signaling chain funtion");
|
||||
g_cond_signal (downloader->priv->cond);
|
||||
} else {
|
||||
GST_OBJECT_UNLOCK (downloader);
|
||||
GST_DEBUG_OBJECT (downloader,
|
||||
"Trying to cancell a download that was alredy cancelled");
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_uri_downloader_set_uri (GstUriDownloader * downloader, const gchar * uri)
|
||||
{
|
||||
GstPad *pad;
|
||||
|
||||
if (!gst_uri_is_valid (uri))
|
||||
return FALSE;
|
||||
|
||||
GST_DEBUG_OBJECT (downloader, "Creating source element for the URI:%s", uri);
|
||||
downloader->priv->urisrc = gst_element_make_from_uri (GST_URI_SRC, uri, NULL);
|
||||
if (!downloader->priv->urisrc)
|
||||
return FALSE;
|
||||
|
||||
/* add a sync handler for the bus messages to detect errors in the download */
|
||||
gst_element_set_bus (GST_ELEMENT (downloader->priv->urisrc),
|
||||
downloader->priv->bus);
|
||||
gst_bus_set_sync_handler (downloader->priv->bus,
|
||||
gst_uri_downloader_bus_handler, downloader);
|
||||
|
||||
pad = gst_element_get_static_pad (downloader->priv->urisrc, "src");
|
||||
if (!pad)
|
||||
return FALSE;
|
||||
gst_pad_link (pad, downloader->priv->pad);
|
||||
gst_object_unref (pad);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GstFragment *
|
||||
gst_uri_downloader_fetch_uri (GstUriDownloader * downloader, const gchar * uri)
|
||||
{
|
||||
GstStateChangeReturn ret;
|
||||
GstFragment *download = NULL;
|
||||
|
||||
g_mutex_lock (downloader->priv->lock);
|
||||
|
||||
if (!gst_uri_downloader_set_uri (downloader, uri)) {
|
||||
goto quit;
|
||||
}
|
||||
|
||||
downloader->priv->download = gst_fragment_new ();
|
||||
|
||||
ret = gst_element_set_state (downloader->priv->urisrc, GST_STATE_PLAYING);
|
||||
if (ret == GST_STATE_CHANGE_FAILURE) {
|
||||
g_object_unref (downloader->priv->download);
|
||||
downloader->priv->download = NULL;
|
||||
goto quit;
|
||||
}
|
||||
|
||||
/* wait until:
|
||||
* - the download succeed (EOS in the src pad)
|
||||
* - the download failed (Error message on the fetcher bus)
|
||||
* - the download was canceled
|
||||
*/
|
||||
GST_DEBUG_OBJECT (downloader, "Waiting to fetch the URI");
|
||||
g_cond_wait (downloader->priv->cond, downloader->priv->lock);
|
||||
|
||||
GST_OBJECT_LOCK (downloader);
|
||||
download = downloader->priv->download;
|
||||
downloader->priv->download = NULL;
|
||||
GST_OBJECT_UNLOCK (downloader);
|
||||
|
||||
if (download != NULL)
|
||||
GST_INFO_OBJECT (downloader, "URI fetched successfully");
|
||||
else
|
||||
GST_INFO_OBJECT (downloader, "Error fetching URI");
|
||||
|
||||
quit:
|
||||
{
|
||||
gst_uri_downloader_stop (downloader);
|
||||
g_mutex_unlock (downloader->priv->lock);
|
||||
return download;
|
||||
}
|
||||
}
|
||||
|
65
ext/dash/gsturidownloader.h
Normal file
65
ext/dash/gsturidownloader.h
Normal file
|
@ -0,0 +1,65 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2011 Andoni Morales Alastruey <ylatuya@gmail.com>
|
||||
*
|
||||
* gsturidownloader.h:
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* Youshould have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GSTURI_DOWNLOADER_H__
|
||||
#define __GSTURI_DOWNLOADER_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gst/gst.h>
|
||||
#include "gstfragment.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_URI_DOWNLOADER (gst_uri_downloader_get_type())
|
||||
#define GST_URI_DOWNLOADER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_URI_DOWNLOADER,GstUriDownloader))
|
||||
#define GST_URI_DOWNLOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_URI_DOWNLOADER,GstUriDownloaderClass))
|
||||
#define GST_IS_URI_DOWNLOADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_URI_DOWNLOADER))
|
||||
#define GST_IS_URI_DOWNLOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_URI_DOWNLOADER))
|
||||
|
||||
typedef struct _GstUriDownloader GstUriDownloader;
|
||||
typedef struct _GstUriDownloaderPrivate GstUriDownloaderPrivate;
|
||||
typedef struct _GstUriDownloaderClass GstUriDownloaderClass;
|
||||
|
||||
struct _GstUriDownloader
|
||||
{
|
||||
GstObject parent;
|
||||
|
||||
GstUriDownloaderPrivate *priv;
|
||||
};
|
||||
|
||||
struct _GstUriDownloaderClass
|
||||
{
|
||||
GstObjectClass parent_class;
|
||||
|
||||
/*< private >*/
|
||||
gpointer _gst_reserved[GST_PADDING];
|
||||
};
|
||||
|
||||
GType gst_uri_downloader_get_type (void);
|
||||
|
||||
GstUriDownloader * gst_uri_downloader_new (void);
|
||||
GstFragment * gst_uri_downloader_fetch_uri (GstUriDownloader * downloader, const gchar * uri);
|
||||
void gst_uri_downloader_cancel (GstUriDownloader *downloader);
|
||||
void gst_uri_downloader_free (GstUriDownloader *downloader);
|
||||
|
||||
G_END_DECLS
|
||||
#endif /* __GSTURIDOWNLOADER_H__ */
|
||||
|
Loading…
Reference in a new issue