lib: Introduce Clapper playback library

An easy to use media playback library (libclapper) as a GstPlayer replacement.

Previously we tried to use upstream `gstplayer` library to control playback and
pass all events from multiple threads GStreamer uses into an app main thread.
Since this caused some thread racy problems and we needed additional ABI breaking
changes to better suit our needs, we ended up with a modified fork of said library
renamed to `gstclapper` as a temporary solution.

This new library simply named `clapper` replaces our previous `gstclapper` solution
and is written completely from scratch by myself. The aim here is to have an easy to
use playback library better suited to work with (but not limited to) GTK and GObject
properties bindings by relying on "notify" signals.

Major differences include:
* Operates on a playback queue (inherits `GListModel` interface) instead of a single URI
* Uses "notify" signals for property changes always dispatched to app thread
* Time is passed/read as decimal number in seconds instead of int64 in nanoseconds
* Integrates `GstDiscoverer` to figure out media info (such as title) before playback
* Easy to use MPRIS support as part of library
* Optional playback remote controls with WebSocket messages

The new library will be distributed with Clapper player. This includes public headers
and GObject Introspection support.

Licensed under LGPL-2.1-or-later.

Enjoy
This commit is contained in:
Rafał Dzięgiel
2024-03-13 20:45:03 +01:00
parent edaba00658
commit d7f069d6c3
196 changed files with 17622 additions and 21004 deletions

674
COPYING
View File

@@ -1,674 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://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 <https://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
<https://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
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@@ -55,7 +55,7 @@ modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
@@ -111,7 +111,7 @@ 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, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@@ -158,7 +158,7 @@ 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
@@ -216,7 +216,7 @@ 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.
@@ -267,7 +267,7 @@ Library will still fall under Section 6.)
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 combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
@@ -329,7 +329,7 @@ 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
@@ -370,7 +370,7 @@ 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 with
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
@@ -422,7 +422,7 @@ 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
@@ -456,7 +456,7 @@ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
@@ -485,7 +485,8 @@ convey the exclusion of warranty; and each file should have at least the
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
Also add information on how to contact you by electronic and paper mail.
@@ -494,7 +495,8 @@ 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.
library `Frob' (a library for tweaking knobs) written by James Random
Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice

View File

@@ -1,9 +0,0 @@
#!@GJS@
imports.package.init({
name: '@PACKAGE_NAME@',
version: '@PACKAGE_VERSION@',
prefix: '@prefix@',
libdir: '@libdir@',
});
imports.package.run(imports.src.main);

View File

@@ -1,22 +0,0 @@
bin_conf = configuration_data()
bin_conf.set('GJS', find_program('gjs').path())
bin_conf.set('PACKAGE_NAME', meson.project_name())
bin_conf.set('PACKAGE_VERSION', meson.project_version())
bin_conf.set('prefix', get_option('prefix'))
bin_conf.set('libdir', libdir)
configure_file(
input: 'com.github.rafostar.Clapper.in',
output: 'com.github.rafostar.Clapper',
configuration: bin_conf,
install: true,
install_dir: bindir,
install_mode: 'rwxr-xr-x'
)
clapper_symlink_cmd = 'ln -fs @0@ $DESTDIR@1@'.format(
'com.github.rafostar.Clapper',
join_paths(bindir, 'clapper')
)
meson.add_install_script('sh', '-c', clapper_symlink_cmd)

View File

@@ -1,22 +0,0 @@
#!/usr/bin/env python3
from os import environ, path
from subprocess import call
prefix = environ.get('MESON_INSTALL_PREFIX', '/usr/local')
sharedir = path.join(prefix, 'share')
destdir = environ.get('DESTDIR', '')
# Package managers set this so we don't need to run
if not destdir:
print('Updating icon cache...')
call(['gtk4-update-icon-cache', '-qtf', path.join(sharedir, 'icons', 'hicolor')])
print('Updating mime database...')
call(['update-mime-database', path.join(sharedir, 'mime')])
print('Updating desktop database...')
call(['update-desktop-database', '-q', path.join(sharedir, 'applications')])
print('Compiling GSettings schemas...')
call(['glib-compile-schemas', path.join(sharedir, 'glib-2.0', 'schemas')])

View File

@@ -1,426 +0,0 @@
/* Defaults */
scale marks {
color: currentColor;
}
radio {
margin-left: -2px;
}
scrolledwindow scrollbar.vertical slider {
min-height: 16px;
}
/* Consistent scales color */
scale trough highlight {
color: @accent_fg_color;
background-color: @accent_bg_color;
}
/* Consistent radio buttons color */
.osd radio {
color: @accent_fg_color;
background-color: transparent;
background-image: none;
}
.osd radio:hover,
.osd radio:checked {
background-image: image(rgba(255,255,255,0.1));
}
.osd radio:active {
background-image: image(rgba(255,255,255,0.3));
}
/* Adwaita OSD background color is unacceptable:
* https://gitlab.gnome.org/GNOME/libadwaita/-/issues/454 */
box.osd,
.osd popover contents,
.osd popover arrow,
.osdheaderbar button {
background-color: rgba(38,38,38,0.78);
}
.osdheaderbar button:hover,
.osdheaderbar button:checked {
background-color: rgba(63,63,63,0.78);
}
.osdheaderbar button:active {
background-color: rgba(82,82,82,0.78);
}
/* Adwaita is missing osd ListBox */
.clapperplaylist {
background: none;
}
.clapperplaylist row {
border-radius: 5px;
}
.clapperplaylist row {
color: @theme_fg_color;
}
.clapperplaylist row button {
margin: 0px;
padding: 0px;
min-width: 28px;
min-height: 28px;
}
.fullscreen.tvmode .clapperplaylist row button {
min-width: 36px;
min-height: 36px;
margin-left: 2px;
margin-right: 2px;
}
.osd .clapperplaylist row image {
-gtk-icon-shadow: none;
}
.osdheaderbar {
background: transparent;
}
.osdheaderbar button {
border: transparent;
}
.linkseparator {
background: rgba(24,24,24,0.72);
min-width: 1px;
}
.linkedleft image {
margin-left: 2px;
}
.linkedright image {
margin-right: 2px;
}
/* Flat popovers */
popover arrow,
popover contents {
border-color: transparent;
box-shadow: none;
}
.popoverseparator separator {
background-color: @insensitive_fg_color;
margin-left: 3px;
margin-right: 3px;
}
/* Rounded corners */
.adwrounded.csd {
border-radius: 8px;
}
.adwrounded.fullscreen,
.adwrounded.maximized,
.adwrounded.tiled,
.adwrounded.tiled-top,
.adwrounded.tiled-left,
.adwrounded.tiled-right,
.adwrounded.tiled-bottom {
border-radius: 0px;
}
.roundedcorners {
border-radius: 8px;
}
/* Reduce sliders size */
scale trough slider {
min-height: 18px;
min-width: 18px;
}
.fullscreen.tvmode scale trough slider {
min-height: 20px;
min-width: 20px;
}
.videowidget {
min-width: 320px;
min-height: 180px;
}
.fullscreen.tvmode popover box {
text-shadow: none;
font-size: 21px;
font-weight: 500;
}
.clappercontrols {
margin-left: 2px;
margin-right: 2px;
}
.fullscreen.tvmode .clappercontrols {
margin-left: 1px;
margin-right: 1px;
}
.clappercontrolsbutton {
margin: 3px;
margin-left: 1px;
margin-right: 1px;
}
.fullscreen.tvmode .clappercontrolsbutton {
min-width: 32px;
min-height: 32px;
margin: 5px;
margin-left: 4px;
margin-right: 4px;
}
.clappercontrolsbutton.text-button {
padding-left: 4px;
padding-right: 4px;
}
.fullscreen.tvmode button image {
-gtk-icon-shadow: none;
}
.fullscreen.tvmode radio {
margin-left: 0px;
margin-right: 4px;
border: 2px solid;
min-width: 16px;
min-height: 16px;
box-shadow: none;
}
/* Also affects popover buttons */
.fullscreen.tvmode .clappercontrols button image {
-gtk-icon-size: 26px;
}
.clappercontrolsbutton.text-button label {
font-family: 'Cantarell', sans-serif;
font-variant-numeric: tabular-nums;
font-weight: 600;
}
.fullscreen.tvmode .clappercontrolsbutton.text-button label {
font-size: 22px;
text-shadow: none;
}
/* Top Revealer */
.fullscreen.tvmode .revealertopgrid {
font-family: 'Cantarell', sans-serif;
}
.fullscreen.tvmode .tvtitle {
font-size: 28px;
font-weight: 500;
text-shadow: none;
}
.fullscreen.tvmode .tvtime {
margin-top: -2px;
margin-bottom: -2px;
min-height: 4px;
font-size: 38px;
font-weight: 700;
font-variant-numeric: tabular-nums;
}
.fullscreen.tvmode .tvendtime {
margin-top: -4px;
margin-bottom: 2px;
min-height: 6px;
font-size: 24px;
font-weight: 600;
font-variant-numeric: tabular-nums;
}
/* Position Scale */
.positionscale {
margin: -2px;
}
.positionscale trough highlight {
min-height: 6px;
}
.fullscreen.tvmode .positionscale {
padding-left: 12px;
padding-right: 12px;
}
.fullscreen.tvmode .positionscale.fine-tune {
padding-left: 12px;
padding-right: 12px;
}
.fullscreen.tvmode .positionscale trough slider {
color: transparent;
background: transparent;
border-color: transparent;
box-shadow: none;
outline: none;
}
.positionscale mark indicator {
min-height: 6px;
}
.positionscale.fine-tune mark indicator {
min-height: 6px;
}
.fullscreen.tvmode .positionscale mark indicator {
min-height: 7px;
min-width: 2px;
}
.fullscreen.tvmode .positionscale.fine-tune mark indicator {
min-height: 7px;
min-width: 2px;
}
.positionscale marks.top {
margin-top: -6px;
margin-bottom: 4px;
}
.positionscale marks.bottom {
margin-top: 4px;
margin-bottom: -6px;
}
.fullscreen.tvmode .positionscale marks.top {
margin-bottom: 2px;
}
.fullscreen.tvmode .positionscale marks.bottom {
margin-top: 2px;
}
.fullscreen.tvmode .positionscale trough {
border-radius: 3px;
}
.fullscreen.tvmode .positionscale trough highlight {
border-radius: 3px;
min-height: 20px;
}
.fullscreen.tvmode .positionscale.fine-tune trough highlight {
border-radius: 3px;
min-height: 20px;
}
/* Volume Scale */
.volumescale {
margin: -2px;
margin-left: -8px;
margin-right: -6px;
min-height: 180px;
}
.fullscreen.tvmode .volumescale {
margin: 2px;
margin-left: -6px;
margin-right: -4px;
min-height: 260px;
}
.volumescale marks label {
margin-right: 4px;
margin-top: -4px;
margin-bottom: -6px;
}
.volumescale trough highlight {
min-width: 4px;
}
.fullscreen.tvmode .volumescale trough highlight {
min-width: 6px;
}
.overamp trough highlight {
color: @error_fg_color;
background-color: @error_bg_color;
}
/* Elapsed Popover */
.elapsedpopover {
min-width: 326px;
}
.fullscreen.tvmode .elapsedpopover {
min-width: 448px;
}
.elapsedpopover contents {
padding-bottom: 0px;
}
.speedscale {
margin-left: 4px;
margin-right: 4px;
}
.speedscale trough highlight {
min-height: 4px;
}
.fullscreen.tvmode .speedscale trough highlight {
min-height: 6px;
}
.narrowbutton {
min-width: 8px;
}
@keyframes halfrotation {
to { transform: rotate(0.5turn); }
}
.halfrotate {
animation-name: halfrotation;
animation-duration: 200ms;
animation-delay: 280ms;
animation-timing-function: linear;
animation-fill-mode: forwards;
animation-iteration-count: 1;
}
/* Chapters */
.chapterlabel {
min-width: 32px;
}
.fullscreen.tvmode .chapterlabel {
min-width: 40px;
text-shadow: none;
font-size: 22px;
font-weight: 600;
}
/* Open URI Dialog */
.uridialogbox {
margin: 10px;
}
/* Tweaks */
.nobackground {
background: none;
}
.noborder {
border: none;
}
.controlsbox {
background: @popover_bg_color;
}
.gpufriendly {
box-shadow: -8px -8px transparent, 8px 8px transparent;
}
.fullscreen.gpufriendlyfs {
box-shadow: none;
}
/* Error BG */
.blackbackground {
background: black;
}
/** SCALING LOW-RES **/
.fullscreen.tvmode.lowres .clappercontrols button image {
-gtk-icon-size: 22px;
}
.fullscreen.tvmode.lowres .clappercontrolsbutton {
min-width: 28px;
min-height: 28px;
}
.fullscreen.tvmode.lowres .clappercontrolsbutton.text-button label {
font-size: 21px;
}
.fullscreen.tvmode.lowres .positionscale trough highlight {
min-height: 18px;
}
.fullscreen.tvmode.lowres .positionscale.fine-tune trough highlight {
min-height: 18px;
}
.fullscreen.tvmode.lowres popover box {
font-size: 19px;
}
.fullscreen.tvmode.lowres radio {
min-width: 15px;
min-height: 15px;
}
.fullscreen.tvmode.lowres .clapperplaylist row button {
min-width: 32px;
min-height: 32px;
}
.fullscreen.tvmode.lowres .tvtitle {
font-size: 26px;
}
.fullscreen.tvmode.lowres .tvtime {
font-size: 34px;
}
.fullscreen.tvmode.lowres .tvendtime {
font-size: 21px;
}
.fullscreen.tvmode.lowres .elapsedpopover {
min-width: 410px;
}
.fullscreen.tvmode.lowres .chapterlabel {
font-size: 21px;
}
/** SCALING HI-RES **/
.fullscreen.tvmode.hires .clappercontrols button image {
-gtk-icon-size: 24px; /* Sharpest on 2160p with scaling 2x */
}

View File

@@ -1,115 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="16"
height="16"
viewBox="0 0 4.2333333 4.2333334"
version="1.1"
id="svg5"
inkscape:version="1.1 (c68e22c387, 2021-05-23)"
sodipodi:docname="com.github.rafostar.Clapper-symbolic.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="mm"
showgrid="false"
inkscape:snap-bbox="true"
inkscape:bbox-paths="true"
inkscape:bbox-nodes="true"
inkscape:snap-bbox-edge-midpoints="true"
inkscape:snap-bbox-midpoints="true"
inkscape:object-paths="true"
inkscape:snap-intersection-paths="true"
inkscape:snap-smooth-nodes="true"
inkscape:snap-midpoints="true"
inkscape:snap-global="false"
units="px"
inkscape:zoom="32"
inkscape:cx="6.078125"
inkscape:cy="8.09375"
inkscape:window-width="1680"
inkscape:window-height="981"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs2">
<inkscape:path-effect
effect="fillet_chamfer"
id="path-effect1853"
is_visible="true"
lpeversion="1"
satellites_param="F,0,0,1,0,1.8520833,0,1 @ F,0,0,1,0,1.8520833,0,1 @ F,0,0,1,0,1.8520833,0,1 @ F,0,0,1,0,1.8520833,0,1"
unit="px"
method="auto"
mode="F"
radius="7"
chamfer_steps="1"
flexible="false"
use_knot_distance="true"
apply_no_radius="true"
apply_with_radius="true"
only_selected="false"
hide_knots="false" />
<inkscape:path-effect
effect="fillet_chamfer"
id="path-effect1732"
is_visible="true"
lpeversion="1"
satellites_param="F,0,0,1,0,1.8520833,0,1 @ F,0,0,1,0,1.8520833,0,1 @ F,0,0,1,0,1.8520833,0,1 @ F,0,0,1,0,1.8520833,0,1"
unit="px"
method="auto"
mode="F"
radius="7"
chamfer_steps="1"
flexible="false"
use_knot_distance="true"
apply_no_radius="true"
apply_with_radius="true"
only_selected="false"
hide_knots="false" />
</defs>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<g
id="g2022"
transform="matrix(0.06169519,0,0,0.06168906,-4.7800087,-3.2713603)">
<path
id="rect973"
style="fill:#000000;stroke-width:1.30776;stroke-linecap:round;stroke-linejoin:round;paint-order:stroke markers fill"
d="m 88.193064,81.795006 c -0.699254,0 -1.342327,0.227875 -1.864484,0.609782 h 51.32503 c -0.52216,-0.381907 -1.16471,-0.609782 -1.86397,-0.609782 z m -3.157945,10.475846 v 26.225278 c 0,1.74939 1.40856,3.15743 3.157945,3.15743 h 47.596576 c 1.74939,0 3.15795,-1.40804 3.15795,-3.15743 V 92.270852 Z m 20.323311,4.964038 15.40009,9.27283 -15.5205,9.56634 z" />
<path
style="fill:#000000;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 83.974394,69.464471 7.344033,-0.06509 a 2.7923103,2.7923103 33.047712 0 1 2.587466,1.683384 l 7.009937,16.201526 a 1.2163248,1.2163248 123.30899 0 1 -1.116623,1.699322 l -15.720141,-0.004 a 1.862525,1.862525 44.853691 0 1 -1.862019,-1.852534 l -0.08473,-15.79409 a 1.8585738,1.8585738 134.59241 0 1 1.842075,-1.868472 z"
id="path1422"
inkscape:path-effect="#path-effect1732"
inkscape:original-d="m 82.122383,69.480886 11.048055,-0.09792 8.480852,19.601124 -19.424307,-0.005 z" />
<rect
style="fill:#000000;stroke-width:1.3;stroke-linecap:round;stroke-linejoin:round;paint-order:stroke markers fill"
id="rect1544"
width="59.366463"
height="9.8661175"
x="82"
y="79.292183"
ry="1.2306831" />
<path
id="rect1847"
style="fill:#000000;stroke-width:4.91339;stroke-linecap:round;stroke-linejoin:round;paint-order:stroke markers fill"
d="m 522.12695,200.42773 c -0.45798,3.8e-4 -0.92335,0.0696 -1.38476,0.21289 l -172.88672,53.70313 5.28515,-0.0469 a 10.55362,10.55362 0 0 1 9.7793,6.36328 l 10.69922,24.72656 158.18359,-49.13477 c 2.46089,-0.7644 3.82691,-3.36137 3.0625,-5.82226 l -8.30078,-26.72657 c -0.62108,-1.99947 -2.4529,-3.277 -4.4375,-3.27539 z m -203.69531,63.05469 -3.08398,0.95899 c -2.46089,0.7644 -3.82691,3.35942 -3.0625,5.82031 l 6.29101,20.2539 z"
transform="scale(0.26458333)" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 4.8 KiB

View File

@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/com/github/rafostar/Clapper">
<file preprocess="xml-stripblanks" alias="icons/scalable/actions/play-symbolic.svg">icons/play-symbolic.svg</file>
<file preprocess="xml-stripblanks" alias="icons/scalable/actions/pause-symbolic.svg">icons/pause-symbolic.svg</file>
<file preprocess="xml-stripblanks" alias="icons/scalable/actions/pip-in-symbolic.svg">icons/pip-in-symbolic.svg</file>
<file preprocess="xml-stripblanks" alias="icons/scalable/actions/pip-out-symbolic.svg">icons/pip-out-symbolic.svg</file>
</gresource>
</gresources>

View File

@@ -1,16 +0,0 @@
[Desktop Entry]
Name=Clapper
GenericName=Multimedia Player
Comment=Play videos and music
Categories=GTK;GNOME;AudioVideo;Player;Video;TV;
MimeType=application/claps;application/mpeg4-iod;application/mpeg4-muxcodetable;application/mxf;application/ogg;application/ram;application/sdp;application/streamingmedia;application/vnd.apple.mpegurl;application/vnd.ms-asf;application/vnd.rn-realmedia;application/vnd.rn-realmedia-vbr;application/x-extension-m4a;application/x-extension-mp4;application/x-flac;application/x-flash-video;application/x-matroska;application/x-ogg;application/x-streamingmedia;audio/3gpp;audio/3gpp2;audio/aac;audio/ac3;audio/amr;audio/amr-wb;audio/basic;audio/dv;audio/eac3;audio/flac;audio/m4a;audio/midi;audio/mp1;audio/mp2;audio/mp3;audio/mp4;audio/mpeg;audio/mpegurl;audio/mpg;audio/ogg;audio/opus;audio/scpls;audio/vnd.dolby.heaac.1;audio/vnd.dolby.heaac.2;audio/vnd.dolby.mlp;audio/vnd.dts;audio/vnd.dts.hd;audio/vnd.rn-realaudio;audio/wav;audio/webm;audio/x-aac;audio/x-aiff;audio/x-ape;audio/x-flac;audio/x-gsm;audio/x-it;audio/x-m4a;audio/x-matroska;audio/x-mod;audio/x-mp1;audio/x-mp2;audio/x-mp3;audio/x-mpeg;audio/x-mpegurl;audio/x-mpg;audio/x-ms-asf;audio/x-ms-wma;audio/x-musepack;audio/x-pn-aiff;audio/x-pn-au;audio/x-pn-realaudio;audio/x-pn-wav;audio/x-real-audio;audio/x-realaudio;audio/x-s3m;audio/x-scpls;audio/x-shorten;audio/x-speex;audio/x-tta;audio/x-vorbis;audio/x-vorbis+ogg;audio/x-wav;audio/x-wavpack;audio/x-xm;video/3gp;video/3gpp;video/3gpp2;video/divx;video/dv;video/fli;video/flv;video/mp2t;video/mp4;video/mp4v-es;video/mpeg;video/mpeg-system;video/msvideo;video/ogg;video/quicktime;video/vnd.mpegurl;video/vnd.rn-realvideo;video/webm;video/x-avi;video/x-flc;video/x-fli;video/x-flv;video/x-m4v;video/x-matroska;video/x-mpeg;video/x-mpeg-system;video/x-mpeg2;video/x-ms-asf;video/x-ms-wm;video/x-ms-wmv;video/x-ms-wmx;video/x-msvideo;video/x-nsv;video/x-ogm+ogg;video/x-theora;video/x-theora+ogg;x-content/audio-cdda;x-content/audio-player;x-content/video-dvd;x-scheme-handler/mms;x-scheme-handler/mmsh;x-scheme-handler/rtmp;x-scheme-handler/rtp;x-scheme-handler/rtsp;
Exec=com.github.rafostar.Clapper %U
Icon=com.github.rafostar.Clapper
DBusActivatable=true
StartupNotify=true
Terminal=false
Type=Application
# Translators: Search terms to find this application. Do NOT translate the semicolons!
Keywords=Video;Movie;Film;Clip;Series;Player;Playlist;DVD;TV;Disc;Album;Music;GNOME;Clapper;
# Translators: Do NOT translate or transliterate this text (these are enum types)!
X-Purism-FormFactor=Workstation;Mobile;

View File

@@ -1,108 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="com.github.rafostar.Clapper">
<schema id="com.github.rafostar.Clapper" path="/com/github/rafostar/Clapper/">
<!-- General -->
<key name="fullscreen-auto" type="b">
<default>false</default>
<summary>Automatically enter fullscreen when first file is loaded</summary>
</key>
<key name="volume-custom" type="b">
<default>false</default>
<summary>Set custom volume value at startup</summary>
</key>
<key name="volume-value" type="i">
<default>100</default>
<summary>Custom initial volume value in percentage after startup</summary>
</key>
<key name="after-playback" type="i">
<default>0</default>
<summary>What to do after playback finishes</summary>
</key>
<!-- Behavior -->
<key name="seeking-mode" type="i">
<default>0</default>
<summary>Mode used for seeking</summary>
</key>
<key name="seeking-value" type="i">
<default>10</default>
<summary>Time amount to seek with single press of arrow keys</summary>
</key>
<key name="seeking-unit" type="i">
<default>0</default>
<summary>Unit ID to use with seeking value</summary>
</key>
<key name="resume-enabled" type="b">
<default>false</default>
<summary>Ask to resume unfinished video</summary>
</key>
<key name="resume-database" type="s">
<default>'[]'</default>
<summary>Data storing unfinished videos resume info</summary>
</key>
<key name="floating-stick" type="b">
<default>false</default>
<summary>Auto stick floating window to all workspaces</summary>
</key>
<!-- Audio -->
<key name="audio-offset" type="i">
<default>0</default>
<summary>Offset time for audio tracks relative to video (milliseconds)</summary>
</key>
<!-- Subtitles -->
<key name="subtitle-font" type="s">
<default>"Sans 12"</default>
<summary>The subtitles font description</summary>
</key>
<!-- Network -->
<key name="webserver-enabled" type="b">
<default>false</default>
<summary>Enable WebSocket server for remote playback control</summary>
</key>
<key name="webserver-port" type="i">
<default>6446</default>
<summary>Listening port to use for incoming WebSocket connections</summary>
</key>
<!-- Tweaks -->
<key name="dark-theme" type="b">
<default>true</default>
<summary>Enable to force the app to use dark theme variant</summary>
</key>
<key name="render-shadows" type="b">
<default>true</default>
<summary>Enable rendering window shadows (only if theme has them)</summary>
</key>
<!-- GStreamer -->
<key name="plugin-ranking" type="s">
<default>'{}'</default>
<summary>Custom values for GStreamer plugin ranking</summary>
</key>
<key name="use-playbin3" type="b">
<default>false</default>
<summary>Use playbin3 element instead of playbin2</summary>
</key>
<key name="use-pipewire" type="b">
<default>false</default>
<summary>Use PipeWire for audio output</summary>
</key>
<key name="play-flags" type="i">
<default>1559</default>
<summary>Set PlayFlags for playbin</summary>
</key>
<!-- Other -->
<key name="window-size" type="s">
<default>'[800, 490]'</default>
<summary>Stores window size to restore on next launch</summary>
</key>
<key name="volume-last" type="d">
<default>1</default>
<summary>Stores last linear volume value to apply on startup</summary>
</key>
</schema>
</schemalist>

View File

@@ -1,240 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
<id>com.github.rafostar.Clapper</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0-or-later</project_license>
<name>Clapper</name>
<summary>Simple and modern GNOME media player</summary>
<translation type="gettext">com.github.rafostar.Clapper</translation>
<launchable type="desktop-id">com.github.rafostar.Clapper.desktop</launchable>
<description>
<p>
Clapper is a GNOME media player built using GJS with GTK4 toolkit.
The media player is using GStreamer as a media backend and renders
everything via OpenGL. Player works natively on both Xorg and Wayland.
It also supports hardware acceleration through VA-API on AMD/Intel GPUs,
NVDEC on Nvidia and V4L2 on mobile devices.
</p>
<p>
The media player has an adaptive GUI. When viewing videos in "Windowed Mode",
Clapper will use mostly unmodified GTK widgets to match your OS look nicely.
When player enters "Fullscreen Mode" all GUI elements will become darker, bigger
and semi-transparent for your viewing comfort. It also has a "Floating Mode" which
displays only video on top of all other windows for a PiP-like viewing experience.
Mobile friendly transitions are also supported.
</p>
</description>
<developer_name>Rafał Dzięgiel</developer_name>
<url type="homepage">https://rafostar.github.io/clapper</url>
<url type="bugtracker">https://github.com/Rafostar/clapper/issues</url>
<url type="donation">https://liberapay.com/Clapper</url>
<url type="help">https://github.com/Rafostar/clapper/wiki</url>
<categories>
<category>AudioVideo</category>
<category>Video</category>
</categories>
<screenshots>
<screenshot type="default">
<image type="source">https://raw.githubusercontent.com/wiki/Rafostar/clapper/media/screenshot-windowed.png</image>
</screenshot>
<screenshot>
<image type="source">https://raw.githubusercontent.com/wiki/Rafostar/clapper/media/screenshot-fullscreen.png</image>
</screenshot>
<screenshot>
<image type="source">https://raw.githubusercontent.com/wiki/Rafostar/clapper/media/screenshot-floating.png</image>
</screenshot>
<screenshot>
<image type="source">https://raw.githubusercontent.com/wiki/Rafostar/clapper/media/screenshot-mobile.png</image>
</screenshot>
</screenshots>
<releases>
<release version="0.5.2" date="2022-06-24">
<description>
<p>Fixes:</p>
<ul>
<li>Fix time labels display on RTL languages</li>
<li>Improved GL/GLES context automatic selection</li>
</ul>
<p>New translations:</p>
<ul>
<li>Hebrew</li>
</ul>
</description>
</release>
<release version="0.5.1" date="2022-05-29">
<description>
<p>
A quick hotfix release. Fixes problems with new video sink on displays with non-100% scaling applied.
See 0.5.0 version release notes for full recent changelog.
</p>
</description>
</release>
<release version="0.5.0" date="2022-05-28">
<description>
<p>Changes:</p>
<ul>
<li>Includes and uses new, improved GStreamer video sink</li>
<li>All networking ported to libsoup3</li>
<li>A lot of cleanup, including removal of unfinished web application and old YT code</li>
<li>App now supports D-Bus launching (DBusActivatable)</li>
<li>Other small fixes</li>
</ul>
<p>New translations:</p>
<ul>
<li>Arabic</li>
<li>Basque</li>
<li>French</li>
<li>Japanese</li>
<li>Swedish</li>
<li>Turkish</li>
</ul>
</description>
</release>
<release version="0.4.1" date="2021-12-20">
<description>
<p>Fixes:</p>
<ul>
<li>Compatibility with more recent libadwaita versions</li>
<li>Toggle mute with M button alone</li>
<li>Allow handling YouTube with external GStreamer plugins</li>
<li>Fix catching errors when reading clipboard</li>
<li>Fix missing translator-credits</li>
<li>Fix missing gio-unix-2.0 dep</li>
<li>Fix playback pausing when entering fullscreen with touchscreen</li>
<li>Fix GST_PLUGIN_FEATURE_RANK env usage</li>
<li>Fix video/audio decoder change detection</li>
<li>Merge global video tags instead replacing them</li>
<li>Few other misc bug fixes</li>
</ul>
<p>New translations:</p>
<ul>
<li>Chinese Simplified</li>
<li>Czech</li>
<li>Hungarian</li>
<li>Portuguese</li>
<li>Portuguese, Brazilian</li>
<li>Russian</li>
<li>Spanish</li>
</ul>
</description>
</release>
<release version="0.4.0" date="2021-09-12">
<description>
<p>Changes:</p>
<ul>
<li>Now uses libadwaita</li>
<li>New and adaptive preferences window</li>
<li>Improved open URI dialog</li>
<li>Few small tweaks to fullscreen UI design</li>
<li>Show current video and audio decoders in popovers (easy way to check if HW accel is used)</li>
<li>Enabled NVDEC hardware acceleration by default (requires Nvidia proprietary drivers)</li>
<li>Added option to use PipeWire for audio output (experimental)</li>
<li>Added option to use playbin3 element (experimental)</li>
<li>New PiP icon from icon development kit</li>
<li>Improved performance on devices running OpenGL ES</li>
<li>Translations support</li>
<li>Various bug fixes</li>
</ul>
<p>New keyboard shortcuts:</p>
<ul>
<li>Leave fullscreen with Escape key</li>
<li>Toggle mute with Ctrl+M</li>
</ul>
<p>More touchscreen gestures:</p>
<ul>
<li>Toggle playback with a long press</li>
<li>Switch playlist items via double tap on screen side</li>
</ul>
<p>New translations:</p>
<ul>
<li>Catalan</li>
<li>Dutch</li>
<li>German</li>
<li>Italian</li>
<li>Polish</li>
</ul>
</description>
</release>
<release version="0.3.0" date="2021-06-18">
<description>
<p>Changes:</p>
<ul>
<li>Added MPRIS support</li>
<li>Added repeat modes: single video, whole playlist and shuffle</li>
<li>Support opening folders with media files</li>
<li>Append playlist items by holding Ctrl while doing Drag and Drop</li>
<li>Improved handling of keyboard shortcuts</li>
<li>Added more keyboard shortcuts</li>
<li>Added window that shows available keyboard shortcuts</li>
<li>Show black screen by default after playback (make showing last frame optional instead)</li>
<li>Added ability to export playlist to file</li>
<li>Improve handling of changing displays with different resolutions</li>
<li>Added support for EGL under x11 with GTK 4.3.1 or later</li>
<li>Added missing symbolic app icon</li>
<li>Some misc bug fixes and code cleanups</li>
</ul>
</description>
</release>
<release version="0.2.1" date="2021-04-19">
<description>
<p>Player:</p>
<ul>
<li>Fix missing top left menu buttons on some system configurations</li>
<li>Fix potential video sink deadlock</li>
<li>Do not show mobile controls transition on launch</li>
<li>Show tooltip with full playlist item text on hover</li>
</ul>
<p>YouTube:</p>
<ul>
<li>Auto select best matching resolution for used monitor</li>
<li>Added some YouTube related preferences</li>
<li>Added support for live HLS videos</li>
<li>Added support for non-adaptive live HLS streaming</li>
</ul>
</description>
</release>
<release version="0.2.0" date="2021-04-13">
<description>
<p>New features:</p>
<ul>
<li>YouTube support - drag and drop videos from youtube or use open URI dialog to play them</li>
<li>Added convenient ways of opening external subtitles</li>
</ul>
<p>Changes:</p>
<ul>
<li>Few GUI layout improvements</li>
<li>Simplified video sink code</li>
<li>Fixed missing Ctrl+O common keybinding</li>
<li>Fixed error when playback finishes during controls reveal animation</li>
<li>Fixed startup window size on Xorg</li>
<li>Fixed top time not showing up on fullscreen startup</li>
<li>Fixed missing file extensions in online URIs</li>
<li>Fixed some error messages not being displayed</li>
</ul>
</description>
</release>
<release version="0.1.0" date="2021-02-26">
<description>
<p>First stable release</p>
</description>
</release>
<release version="0.0.0" date="2020-10-31">
<description>
<p>GitHub version</p>
</description>
</release>
</releases>
<content_rating type="oars-1.1" />
<recommends>
<control>keyboard</control>
<control>pointing</control>
<control>touch</control>
</recommends>
<requires>
<display_length compare="ge">small</display_length>
</requires>
<custom>
<value key="Purism::form_factor">workstation</value>
<value key="Purism::form_factor">mobile</value>
</custom>
</component>

View File

@@ -1,3 +0,0 @@
[D-BUS Service]
Name=@app_id@
Exec=@bindir@/@app_id@ --gapplication-service

View File

@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/claps">
<comment>Clapper Playlist</comment>
<glob pattern="*.claps"/>
<icon name="com.github.rafostar.Clapper"/>
</mime-type>
</mime-info>

View File

@@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg">
<g fill="#2e3436">
<path d="m 3 3 h 4 v 10 h -4 z m 0 0"/>
<path d="m 9 3 h 4 v 10 h -4 z m 0 0"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 262 B

View File

@@ -1,112 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<filter id="a" height="100%" width="100%" x="0%" y="0%">
<feColorMatrix in="SourceGraphic" type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"/>
</filter>
<mask id="b">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.3"/>
</g>
</mask>
<clipPath id="c">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="d">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.05"/>
</g>
</mask>
<clipPath id="e">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="f">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.05"/>
</g>
</mask>
<clipPath id="g">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="h">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.05"/>
</g>
</mask>
<clipPath id="i">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="j">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.05"/>
</g>
</mask>
<clipPath id="k">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="l">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.05"/>
</g>
</mask>
<clipPath id="m">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="n">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.05"/>
</g>
</mask>
<clipPath id="o">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="p">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.3"/>
</g>
</mask>
<clipPath id="q">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="r">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.5"/>
</g>
</mask>
<clipPath id="s">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<g fill="#2e3436">
<path d="m 1 2.007812 c -0.550781 0 -1 0.449219 -1 1 v 9 c 0 0.550782 0.449219 1 1 1 h 4 v -2 h -3 v -7 h 10 v 3 h 2 v -4 c 0 -0.550781 -0.449219 -1 -1 -1 z m 0 0" fill-opacity="0.35"/>
<path d="m 9 10 c -0.550781 0 -1 0.449219 -1 1 v 4.007812 c 0 0.550782 0.449219 1 1 1 h 6 c 0.550781 0 1 -0.449218 1 -1 v -4.007812 c 0 -0.550781 -0.449219 -1 -1 -1 z m 1 2 h 4 v 2.007812 h -4 z m 0 0"/>
<path d="m 3.132812 5.140625 c 0.171876 -0.164063 0.496094 -0.1875 0.757813 0.015625 l 3.109375 3.089844 v 0.753906 h -0.753906 l -3.109375 -3.089844 c -0.191407 -0.191406 -0.179688 -0.597656 -0.003907 -0.769531 z m 0 0"/>
<path d="m 4 9 h 4 v 1 h -4 z m 0 0"/>
<path d="m 7 6 h 1 v 4 h -1 z m 0 0"/>
</g>
<g clip-path="url(#c)" mask="url(#b)" transform="matrix(1 0 0 1 -580 -764)">
<path d="m 562.460938 212.058594 h 10.449218 c -1.183594 0.492187 -1.296875 2.460937 0 3 h -10.449218 z m 0 0" fill="#2e3436"/>
</g>
<g clip-path="url(#e)" mask="url(#d)" transform="matrix(1 0 0 1 -580 -764)">
<path d="m 16 632 h 1 v 1 h -1 z m 0 0" fill="#2e3436" fill-rule="evenodd"/>
</g>
<g clip-path="url(#g)" mask="url(#f)" transform="matrix(1 0 0 1 -580 -764)">
<path d="m 17 631 h 1 v 1 h -1 z m 0 0" fill="#2e3436" fill-rule="evenodd"/>
</g>
<g clip-path="url(#i)" mask="url(#h)" transform="matrix(1 0 0 1 -580 -764)">
<path d="m 18 634 h 1 v 1 h -1 z m 0 0" fill="#2e3436" fill-rule="evenodd"/>
</g>
<g clip-path="url(#k)" mask="url(#j)" transform="matrix(1 0 0 1 -580 -764)">
<path d="m 16 634 h 1 v 1 h -1 z m 0 0" fill="#2e3436" fill-rule="evenodd"/>
</g>
<g clip-path="url(#m)" mask="url(#l)" transform="matrix(1 0 0 1 -580 -764)">
<path d="m 17 635 h 1 v 1 h -1 z m 0 0" fill="#2e3436" fill-rule="evenodd"/>
</g>
<g clip-path="url(#o)" mask="url(#n)" transform="matrix(1 0 0 1 -580 -764)">
<path d="m 19 635 h 1 v 1 h -1 z m 0 0" fill="#2e3436" fill-rule="evenodd"/>
</g>
<g clip-path="url(#q)" mask="url(#p)" transform="matrix(1 0 0 1 -580 -764)">
<path d="m 136 660 v 7 h 7 v -7 z m 0 0" fill="#2e3436"/>
</g>
<g clip-path="url(#s)" mask="url(#r)" transform="matrix(1 0 0 1 -580 -764)">
<path d="m 219 642 h 3 v 12 h -3 z m 0 0" fill="#2e3436"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 4.6 KiB

View File

@@ -1,112 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<filter id="a" height="100%" width="100%" x="0%" y="0%">
<feColorMatrix in="SourceGraphic" type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"/>
</filter>
<mask id="b">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.3"/>
</g>
</mask>
<clipPath id="c">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="d">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.05"/>
</g>
</mask>
<clipPath id="e">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="f">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.05"/>
</g>
</mask>
<clipPath id="g">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="h">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.05"/>
</g>
</mask>
<clipPath id="i">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="j">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.05"/>
</g>
</mask>
<clipPath id="k">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="l">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.05"/>
</g>
</mask>
<clipPath id="m">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="n">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.05"/>
</g>
</mask>
<clipPath id="o">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="p">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.3"/>
</g>
</mask>
<clipPath id="q">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<mask id="r">
<g filter="url(#a)">
<path d="m 0 0 h 16 v 16 h -16 z" fill-opacity="0.5"/>
</g>
</mask>
<clipPath id="s">
<path d="m 0 0 h 1024 v 800 h -1024 z"/>
</clipPath>
<g fill="#2e3436">
<path d="m 1 2.007812 c -0.550781 0 -1 0.449219 -1 1 v 9 c 0 0.550782 0.449219 1 1 1 h 4 v -2 h -3 v -7 h 10 v 3 h 2 v -4 c 0 -0.550781 -0.449219 -1 -1 -1 z m 0 0"/>
<path d="m 9 10 c -0.550781 0 -1 0.449219 -1 1 v 4.007812 c 0 0.550782 0.449219 1 1 1 h 6 c 0.550781 0 1 -0.449218 1 -1 v -4.007812 c 0 -0.550781 -0.449219 -1 -1 -1 z m 1 2 h 4 v 2.007812 h -4 z m 0 0" fill-opacity="0.35"/>
<path d="m 7.863281 9.871094 c -0.167969 0.164062 -0.492187 0.1875 -0.753906 -0.019532 l -3.113281 -3.085937 v -0.753906 h 0.753906 l 3.109375 3.085937 c 0.191406 0.191406 0.179687 0.601563 0.003906 0.773438 z m 0 0"/>
<path d="m 6.996094 6.011719 h -4 v -1 h 4 z m 0 0"/>
<path d="m 3.996094 9.011719 h -1 v -4 h 1 z m 0 0"/>
</g>
<g clip-path="url(#c)" mask="url(#b)" transform="matrix(1 0 0 1 -600 -764)">
<path d="m 562.460938 212.058594 h 10.449218 c -1.183594 0.492187 -1.296875 2.460937 0 3 h -10.449218 z m 0 0" fill="#2e3436"/>
</g>
<g clip-path="url(#e)" mask="url(#d)" transform="matrix(1 0 0 1 -600 -764)">
<path d="m 16 632 h 1 v 1 h -1 z m 0 0" fill="#2e3436" fill-rule="evenodd"/>
</g>
<g clip-path="url(#g)" mask="url(#f)" transform="matrix(1 0 0 1 -600 -764)">
<path d="m 17 631 h 1 v 1 h -1 z m 0 0" fill="#2e3436" fill-rule="evenodd"/>
</g>
<g clip-path="url(#i)" mask="url(#h)" transform="matrix(1 0 0 1 -600 -764)">
<path d="m 18 634 h 1 v 1 h -1 z m 0 0" fill="#2e3436" fill-rule="evenodd"/>
</g>
<g clip-path="url(#k)" mask="url(#j)" transform="matrix(1 0 0 1 -600 -764)">
<path d="m 16 634 h 1 v 1 h -1 z m 0 0" fill="#2e3436" fill-rule="evenodd"/>
</g>
<g clip-path="url(#m)" mask="url(#l)" transform="matrix(1 0 0 1 -600 -764)">
<path d="m 17 635 h 1 v 1 h -1 z m 0 0" fill="#2e3436" fill-rule="evenodd"/>
</g>
<g clip-path="url(#o)" mask="url(#n)" transform="matrix(1 0 0 1 -600 -764)">
<path d="m 19 635 h 1 v 1 h -1 z m 0 0" fill="#2e3436" fill-rule="evenodd"/>
</g>
<g clip-path="url(#q)" mask="url(#p)" transform="matrix(1 0 0 1 -600 -764)">
<path d="m 136 660 v 7 h 7 v -7 z m 0 0" fill="#2e3436"/>
</g>
<g clip-path="url(#s)" mask="url(#r)" transform="matrix(1 0 0 1 -600 -764)">
<path d="m 219 642 h 3 v 12 h -3 z m 0 0" fill="#2e3436"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 4.7 KiB

View File

@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg height="16px" viewBox="2 2 16 16" width="16px" xmlns="http://www.w3.org/2000/svg">
<path d="M 5 3.746094 L 5 16.246094 L 6.25 16.246094 C 6.46875 16.246094 6.683594 16.195312 6.875 16.089844 L 15.625 11.089844 C 16.015625 10.875 16.210938 10.433594 16.210938 9.996094 C 16.210938 9.554688 16.015625 9.117188 15.625 8.902344 L 6.875 3.902344 C 6.683594 3.792969 6.46875 3.746094 6.25 3.746094 Z M 5 3.746094" fill="#2e3436"/>
</svg>

Before

Width:  |  Height:  |  Size: 480 B

View File

@@ -1,46 +0,0 @@
iconsdir = join_paths(datadir, 'icons', 'hicolor')
appstream_util = find_program('appstream-util', required: false)
if appstream_util.found()
test('Validate appstream file', appstream_util, args: [
'validate-relax', '--nonet',
join_paths(meson.current_source_dir(), 'com.github.rafostar.Clapper.metainfo.xml')
])
endif
install_data('com.github.rafostar.Clapper.svg',
install_dir: join_paths(iconsdir, 'scalable', 'apps')
)
install_data('com.github.rafostar.Clapper-symbolic.svg',
install_dir: join_paths(iconsdir, 'symbolic', 'apps')
)
install_data('com.github.rafostar.Clapper.gschema.xml',
install_dir: join_paths(datadir, 'glib-2.0', 'schemas')
)
install_data('com.github.rafostar.Clapper.xml',
install_dir: join_paths(datadir, 'mime', 'packages')
)
install_data('com.github.rafostar.Clapper.desktop',
install_dir: join_paths(datadir, 'applications')
)
install_data('com.github.rafostar.Clapper.metainfo.xml',
install_dir: join_paths(datadir, 'metainfo')
)
gnome.compile_resources('com.github.rafostar.Clapper.data',
'com.github.rafostar.Clapper.data.gresource.xml',
gresource_bundle: true,
install: true,
install_dir: pkgdatadir,
)
dbus_conf = configuration_data()
dbus_conf.set('app_id', meson.project_name())
dbus_conf.set('bindir', bindir)
configure_file(
input: 'com.github.rafostar.Clapper.service.in',
output: 'com.github.rafostar.Clapper.service',
configuration: dbus_conf,
install: true,
install_dir: join_paths(datadir, 'dbus-1', 'services'),
)

10
doc/meson.build Normal file
View File

@@ -0,0 +1,10 @@
gi_docgen = find_program('gi-docgen', required: get_option('doc'))
dot = find_program('dot', required: get_option('doc')) # Class hierarchy generation
build_doc = (gi_docgen.found() and dot.found() and get_option('doc'))
if build_doc
if not build_gir
error('Building documentation requires introspection to be compiled')
endif
subdir('reference')
endif

View File

@@ -0,0 +1,73 @@
[library]
version = "@CLAPPER_VERSION@"
browse_url = "https://github.com/Rafostar/clapper/"
repository_url = "https://github.com/Rafostar/clapper.git"
website_url = "https://rafostar.github.io/clapper/"
docs_url = "https://rafostar.github.io/clapper/doc/clapper/"
authors = "Rafał Dzięgiel"
logo_url = "clapper-logo.svg"
license = "LGPL-2.1-or-later"
description = "Clapper playback library"
devhelp = true
search_index = true
dependencies = ["GLib-2.0", "GObject-2.0", "Gio-2.0", "Gst-1.0", "GstBase-1.0", "GstAudio-1.0", "GstTag-1.0", "GstPbutils-1.0"]
[dependencies."GLib-2.0"]
name = "GLib"
description = "A general-purpose, portable utility library"
docs_url = "https://docs.gtk.org/glib/"
[dependencies."GObject-2.0"]
name = "GObject"
description = "The base type system library"
docs_url = "https://docs.gtk.org/gobject/"
[dependencies."Gio-2.0"]
name = "Gio"
description = "GObject Interfaces and Objects, Networking, IPC, and I/O"
docs_url = "https://docs.gtk.org/gio/"
[dependencies."Gst-1.0"]
name = "Gst"
description = "GStreamer core library"
docs_url = "https://gstreamer.freedesktop.org/documentation/gstreamer/gi-index.html"
[dependencies."GstBase-1.0"]
name = "GstBase"
description = "GStreamer base and utility classes"
docs_url = "https://gstreamer.freedesktop.org/documentation/base/"
[dependencies."GstAudio-1.0"]
name = "GstAudio"
description = "GStreamer audio library"
docs_url = "https://gstreamer.freedesktop.org/documentation/audio/"
[dependencies."GstTag-1.0"]
name = "GstTag"
description = "GStreamer tag support library"
docs_url = "https://gstreamer.freedesktop.org/documentation/tag/"
[dependencies."GstPbutils-1.0"]
name = "GstPbutils"
description = "GStreamer base utils library"
docs_url = "https://gstreamer.freedesktop.org/documentation/pbutils/"
related = []
[theme]
name = "basic"
show_index_summary = true
show_class_hierarchy = true
[source-location]
base_url = "https://github.com/Rafostar/clapper/tree/master/"
[extra]
# The same order will be used when generating the index
content_files = [
]
content_images = [
"images/clapper-logo.svg",
]
urlmap_file = "urlmap.js"

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@@ -0,0 +1,29 @@
clapper_toml = configure_file(
input: 'clapper.toml.in',
output: 'clapper.toml',
configuration: doc_version_conf,
install: true,
install_dir: join_paths(datadir, 'doc', 'clapper'),
)
custom_target('clapper-doc',
input: [
clapper_toml,
clapper_gir[0],
],
output: 'clapper',
command: [
gi_docgen,
'generate',
gi_docgen_common_args,
'--add-include-path=@0@'.format(join_paths(meson.project_build_root(), 'src', 'lib', 'clapper')),
'--config=@INPUT0@',
'--output-dir=@OUTPUT@',
'--content-dir=@0@'.format(meson.current_build_dir()),
'--content-dir=@0@'.format(meson.current_source_dir()),
'@INPUT1@',
],
build_by_default: true,
install: true,
install_dir: join_paths(datadir, 'doc'),
)

View File

@@ -0,0 +1,10 @@
baseURLs = [
['GLib', 'https://docs.gtk.org/glib/'],
['GObject', 'https://docs.gtk.org/gobject/'],
['Gio', 'https://docs.gtk.org/gio/'],
['Gst', 'https://gstreamer.freedesktop.org/documentation/gstreamer/gi-index.html?'],
['GstBase', 'https://gstreamer.freedesktop.org/documentation/base/?'],
['GstAudio', 'https://gstreamer.freedesktop.org/documentation/audio/?'],
['GstTag', 'https://gstreamer.freedesktop.org/documentation/tag/?'],
['GstPbutils', 'https://gstreamer.freedesktop.org/documentation/pbutils/?'],
]

15
doc/reference/meson.build Normal file
View File

@@ -0,0 +1,15 @@
doc_version_conf = configuration_data()
doc_version_conf.set('CLAPPER_VERSION', meson.project_version())
doc_version_conf.set('CLAPPER_VERSION_SUFFIX', clapper_version_suffix)
gi_docgen_common_args = [
'--quiet',
'--no-namespace-dir',
]
if get_option('werror')
gi_docgen_common_args += ['--fatal-warnings']
endif
if build_clapper
subdir('clapper')
endif

View File

@@ -1,183 +0,0 @@
const { GLib } = imports.gi;
let ink = { Ink: null };
try {
ink = imports.ink;
} catch(e) {}
const { Ink } = ink;
const DEBUG_ENV = GLib.getenv('DEBUG');
var Debugger = class
{
constructor(name, opts)
{
opts = (opts && typeof opts === 'object')
? opts : {};
this.name = (name && typeof name === 'string')
? name : 'GJS';
this.print_state = (opts.print_state)
? true : false;
this.json_space = (typeof opts.json_space === 'number')
? opts.json_space : 2;
this.name_printer = opts.name_printer || this._getInkPrinter(true);
this.message_printer = opts.message_printer || this._getDefaultPrinter();
this.time_printer = opts.time_printer || this._getInkPrinter();
this.high_precision = opts.high_precision || false;
if(typeof opts.color !== 'undefined')
this.color = opts.color;
this._isEnabled = false;
this._lastDebug = GLib.get_monotonic_time();
this.enabled = (typeof opts.enabled !== 'undefined')
? opts.enabled : this._enabledAtStart;
}
get enabled()
{
return this._isEnabled;
}
set enabled(value)
{
if(this._isEnabled === value)
return;
this._isEnabled = (value) ? true : false;
if(!this.print_state)
return;
let state = (this.enabled) ? 'en' : 'dis';
this._runDebug(`debug ${state}abled`);
}
get color()
{
return this.name_printer.color;
}
set color(value)
{
this.name_printer.color = value;
this.time_printer.color = this.name_printer.color;
}
get debug()
{
return message => this._debug(message);
}
get _enabledAtStart()
{
if(!DEBUG_ENV)
return false;
let envArr = DEBUG_ENV.split(',');
return envArr.some(el => {
if(el === this.name || el === '*')
return true;
let searchType;
let offset = 0;
if(el.startsWith('*')) {
searchType = 'ends';
} else if(el.endsWith('*')) {
searchType = 'starts';
offset = 1;
}
if(!searchType)
return false;
return this.name[searchType + 'With'](
el.substring(1 - offset, el.length - offset)
);
});
}
_getInkPrinter(isBold)
{
if(!Ink)
return this._getDefaultPrinter();
let printer = new Ink.Printer({
color: Ink.colorFromText(this.name)
});
if(isBold)
printer.font = Ink.Font.BOLD;
return printer;
}
_getDefaultPrinter()
{
return {
getPainted: function() {
return Object.values(arguments);
}
};
}
_debug(message)
{
if(!this.enabled)
return;
this._runDebug(message);
}
_runDebug(message)
{
switch(typeof message) {
case 'string':
break;
case 'object':
if(
message !== null
&& (message.constructor === Object
|| message.constructor === Array)
) {
message = JSON.stringify(message, null, this.json_space);
break;
}
default:
message = String(message);
break;
}
let time = GLib.get_monotonic_time() - this._lastDebug;
if(!this.high_precision) {
time = (time < 1000)
? '+0ms'
: (time < 1000000)
? '+' + Math.floor(time / 1000) + 'ms'
: '+' + Math.floor(time / 1000000) + 's';
}
else {
time = (time < 1000)
? '+' + time + 'µs'
: (time < 1000000)
? '+' + (time / 1000).toFixed(3) + 'ms'
: '+' + (time / 1000000).toFixed(3) + 's';
}
printerr(
this.name_printer.getPainted(this.name),
this.message_printer.getPainted(message),
this.time_printer.getPainted(time)
);
this._lastDebug = GLib.get_monotonic_time();
}
}

View File

@@ -1,322 +0,0 @@
const TERM_ESC = '\x1B[';
const TERM_RESET = '0m';
var maxTransparency = 128;
var Font = {
VARIOUS: null,
REGULAR: 0,
BOLD: 1,
DIM: 2,
ITALIC: 3,
UNDERLINE: 4,
BLINK: 5,
REVERSE: 7,
HIDDEN: 8,
STRIKEOUT: 9,
};
var Color = {
VARIOUS: null,
DEFAULT: 39,
BLACK: 30,
RED: 31,
GREEN: 32,
YELLOW: 33,
BLUE: 34,
MAGENTA: 35,
CYAN: 36,
LIGHT_GRAY: 37,
DARK_GRAY: 90,
LIGHT_RED: 91,
LIGHT_GREEN: 92,
LIGHT_YELLOW: 93,
LIGHT_BLUE: 94,
LIGHT_MAGENTA: 95,
LIGHT_CYAN: 96,
WHITE: 97,
BROWN: colorFrom256(52),
LIGHT_BROWN: colorFrom256(130),
PINK: colorFrom256(205),
LIGHT_PINK: colorFrom256(211),
ORANGE: colorFrom256(208),
LIGHT_ORANGE: colorFrom256(214),
SALMON: colorFrom256(209),
LIGHT_SALMON: colorFrom256(216),
};
function colorFrom256(number)
{
if(typeof number === 'undefined')
number = Math.floor(Math.random() * 256) + 1;
return `38;5;${number || 0}`;
}
function colorFromRGB(R, G, B, A)
{
if(typeof R === 'undefined') {
R = Math.floor(Math.random() * 256);
G = Math.floor(Math.random() * 256);
B = Math.floor(Math.random() * 256);
}
else if(typeof G === 'undefined' && Array.isArray(R)) {
A = (R.length > 3) ? R[3] : 255;
B = (R.length > 2) ? R[2] : 0;
G = (R.length > 1) ? R[1] : 0;
R = (R.length > 0) ? R[0] : 0;
}
if(_getIsTransparent(A))
return Color.DEFAULT;
R = R || 0;
G = G || 0;
B = B || 0;
return `38;2;${R};${G};${B}`;
}
function colorFromHex(R, G, B, A)
{
if((Array.isArray(R)))
R = R.join('');
let str = (typeof G === 'undefined')
? String(R)
: (typeof A !== 'undefined')
? String(R) + String(G) + String(B) + String(A)
: (typeof B !== 'undefined')
? String(R) + String(G) + String(B)
: String(R) + String(G);
let offset = (str[0] === '#') ? 1 : 0;
let alphaIndex = 6 + offset;
while(str.length < alphaIndex)
str += '0';
A = (str.length > alphaIndex)
? parseInt(str.substring(alphaIndex, alphaIndex + 2), 16)
: 255;
str = str.substring(offset, alphaIndex);
let colorInt = parseInt(str, 16);
let u8arr = new Uint8Array(3);
u8arr[2] = colorInt;
u8arr[1] = colorInt >> 8;
u8arr[0] = colorInt >> 16;
return colorFromRGB(u8arr[0], u8arr[1], u8arr[2], A);
}
function colorFromText(text)
{
let value = _stringToDec(text);
/* Returns color from 1 to 221 every 10 */
return colorFrom256((value % 23) * 10 + 1);
}
function fontFromText(text)
{
let arr = Object.keys(Font);
let value = _stringToDec(text);
/* Return a font excluding first (null) */
return Font[arr[value % (arr.length - 1) + 1]];
}
function _getIsImage(args)
{
if(args.length !== 1)
return false;
let arg = args[0];
let argType = (typeof arg);
if(argType === 'string' || argType === 'number')
return false;
if(!Array.isArray(arg))
return false;
let depth = 2;
while(depth--) {
arg = arg[0];
if(!Array.isArray(arg))
return false;
}
return arg.some(val => val !== 'number');
}
function _getIsTransparent(A)
{
return (typeof A !== 'undefined' && A <= maxTransparency);
}
function _stringToDec(str)
{
str = str || '';
let len = str.length;
let total = 0;
while(len--)
total += Number(str.charCodeAt(len).toString(10));
return total;
}
var Printer = class
{
constructor(opts)
{
opts = opts || {};
const defaults = {
font: Font.REGULAR,
color: Color.DEFAULT,
background: Color.DEFAULT
};
for(let def in defaults) {
this[def] = (typeof opts[def] !== 'undefined')
? opts[def] : defaults[def];
}
}
print()
{
(_getIsImage(arguments))
? this._printImage(arguments[0], 'stdout')
: print(this._getPaintedArgs(arguments));
}
printerr()
{
(_getIsImage(arguments))
? this._printImage(arguments[0], 'stderr')
: printerr(this._getPaintedArgs(arguments));
}
getPainted()
{
return (_getIsImage(arguments))
? this._printImage(arguments[0], 'return')
: this._getPaintedArgs(arguments);
}
get background()
{
return this._background;
}
set background(value)
{
let valueType = (typeof value);
if(valueType === 'string') {
value = (value[2] === ';')
? '4' + value.substring(1)
: Number(value);
}
this._background = (valueType === 'object')
? null
: (value < 40 || value >= 90 && value < 100)
? value + 10
: value;
}
_getPaintedArgs(args)
{
let str = '';
for(let arg of args) {
if(Array.isArray(arg))
arg = arg.join(',');
let painted = this._getPaintedString(arg);
str += (str.length) ? ' ' + painted : painted;
}
return str;
}
_getPaintedString(text, noReset)
{
let str = TERM_ESC;
for(let option of ['font', 'color', '_background']) {
let optionType = (typeof this[option]);
str += (optionType === 'number' || optionType === 'string')
? this[option]
: (option === 'font' && Array.isArray(this[option]))
? this[option].join(';')
: (option === 'font')
? fontFromText(text)
: colorFromText(text);
str += (option !== '_background') ? ';' : 'm';
}
str += text;
return (noReset)
? str
: (str + TERM_ESC + TERM_RESET);
}
_printImage(pixelsArr, output)
{
let total = '';
let prevColor = this.color;
let prevBackground = this._background;
for(let row of pixelsArr) {
let paintedLine = '';
let block = ' ';
for(let i = 0; i < row.length; i++) {
let pixel = row[i];
let nextPixel = (i < row.length - 1) ? row[i + 1] : null;
if(nextPixel && pixel.every((value, index) =>
value === nextPixel[index]
)) {
block += ' ';
continue;
}
/* Do not use predefined functions here (it would impact performance) */
let isTransparent = (pixel.length >= 3) ? _getIsTransparent(pixel[3]) : false;
this.color = (isTransparent)
? Color.DEFAULT
: `38;2;${pixel[0]};${pixel[1]};${pixel[2]}`;
this._background = (isTransparent)
? Color.DEFAULT
: `48;2;${pixel[0]};${pixel[1]};${pixel[2]}`;
paintedLine += `${TERM_ESC}0;${this.color};${this._background}m${block}`;
block = ' ';
}
paintedLine += TERM_ESC + TERM_RESET;
switch(output) {
case 'stderr':
printerr(paintedLine);
break;
case 'return':
total += paintedLine + '\n';
break;
default:
print(paintedLine);
break;
}
}
this.color = prevColor;
this._background = prevBackground;
return total;
}
}

View File

@@ -1,42 +0,0 @@
/* GStreamer
* Copyright (C) 2018 GStreamer developers
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_CLAPPER_PRELUDE_H__
#define __GST_CLAPPER_PRELUDE_H__
#include <gst/gst.h>
#ifndef GST_CLAPPER_API
# ifdef BUILDING_GST_CLAPPER
# define GST_CLAPPER_API GST_API_EXPORT /* from config.h */
# else
# define GST_CLAPPER_API GST_API_IMPORT
# endif
#endif
#ifndef GST_DISABLE_DEPRECATED
#define GST_CLAPPER_DEPRECATED GST_CLAPPER_API
#define GST_CLAPPER_DEPRECATED_FOR(f) GST_CLAPPER_API
#else
#define GST_CLAPPER_DEPRECATED G_DEPRECATED GST_CLAPPER_API
#define GST_CLAPPER_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) GST_CLAPPER_API
#endif
#endif /* __GST_CLAPPER_PRELUDE_H__ */

View File

@@ -1,34 +0,0 @@
/* GStreamer
*
* Copyright (C) 2014 Sebastian Dröge <sebastian@centricular.com>
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __CLAPPER_H__
#define __CLAPPER_H__
#include <gst/clapper/clapper-prelude.h>
#include <gst/clapper/gstclapper.h>
#include <gst/clapper/gstclapper-media-info.h>
#include <gst/clapper/gstclapper-g-main-context-signal-dispatcher.h>
#include <gst/clapper/gstclapper-video-overlay-video-renderer.h>
#include <gst/clapper/gstclapper-visualization.h>
#include <gst/clapper/gstclapper-mpris.h>
#include <gst/clapper/gstclapper-gtk4-plugin.h>
#endif /* __CLAPPER_H__ */

View File

@@ -1,214 +0,0 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.com>
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* SECTION:gstclapper-gmaincontextsignaldispatcher
* @title: GstClapperGMainContextSignalDispatcher
* @short_description: Clapper GLib MainContext dispatcher
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstclapper-g-main-context-signal-dispatcher.h"
struct _GstClapperGMainContextSignalDispatcher
{
GObject parent;
GMainContext *application_context;
};
struct _GstClapperGMainContextSignalDispatcherClass
{
GObjectClass parent_class;
};
static void
gst_clapper_g_main_context_signal_dispatcher_interface_init
(GstClapperSignalDispatcherInterface * iface);
enum
{
G_MAIN_CONTEXT_SIGNAL_DISPATCHER_PROP_0,
G_MAIN_CONTEXT_SIGNAL_DISPATCHER_PROP_APPLICATION_CONTEXT,
G_MAIN_CONTEXT_SIGNAL_DISPATCHER_PROP_LAST
};
G_DEFINE_TYPE_WITH_CODE (GstClapperGMainContextSignalDispatcher,
gst_clapper_g_main_context_signal_dispatcher, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GST_TYPE_CLAPPER_SIGNAL_DISPATCHER,
gst_clapper_g_main_context_signal_dispatcher_interface_init));
static GParamSpec
* g_main_context_signal_dispatcher_param_specs
[G_MAIN_CONTEXT_SIGNAL_DISPATCHER_PROP_LAST] = { NULL, };
static void
gst_clapper_g_main_context_signal_dispatcher_finalize (GObject * object)
{
GstClapperGMainContextSignalDispatcher *self =
GST_CLAPPER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER (object);
if (self->application_context)
g_main_context_unref (self->application_context);
G_OBJECT_CLASS
(gst_clapper_g_main_context_signal_dispatcher_parent_class)->finalize
(object);
}
static void
gst_clapper_g_main_context_signal_dispatcher_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstClapperGMainContextSignalDispatcher *self =
GST_CLAPPER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER (object);
switch (prop_id) {
case G_MAIN_CONTEXT_SIGNAL_DISPATCHER_PROP_APPLICATION_CONTEXT:
self->application_context = g_value_dup_boxed (value);
if (!self->application_context)
self->application_context = g_main_context_ref_thread_default ();
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_clapper_g_main_context_signal_dispatcher_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec)
{
GstClapperGMainContextSignalDispatcher *self =
GST_CLAPPER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER (object);
switch (prop_id) {
case G_MAIN_CONTEXT_SIGNAL_DISPATCHER_PROP_APPLICATION_CONTEXT:
g_value_set_boxed (value, self->application_context);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_clapper_g_main_context_signal_dispatcher_class_init
(GstClapperGMainContextSignalDispatcherClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize =
gst_clapper_g_main_context_signal_dispatcher_finalize;
gobject_class->set_property =
gst_clapper_g_main_context_signal_dispatcher_set_property;
gobject_class->get_property =
gst_clapper_g_main_context_signal_dispatcher_get_property;
g_main_context_signal_dispatcher_param_specs
[G_MAIN_CONTEXT_SIGNAL_DISPATCHER_PROP_APPLICATION_CONTEXT] =
g_param_spec_boxed ("application-context", "Application Context",
"Application GMainContext to dispatch signals to", G_TYPE_MAIN_CONTEXT,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class,
G_MAIN_CONTEXT_SIGNAL_DISPATCHER_PROP_LAST,
g_main_context_signal_dispatcher_param_specs);
}
static void
gst_clapper_g_main_context_signal_dispatcher_init
(G_GNUC_UNUSED GstClapperGMainContextSignalDispatcher * self)
{
}
typedef struct
{
void (*emitter) (gpointer data);
gpointer data;
GDestroyNotify destroy;
} GMainContextSignalDispatcherData;
static gboolean
g_main_context_signal_dispatcher_dispatch_gsourcefunc (gpointer user_data)
{
GMainContextSignalDispatcherData *data = user_data;
data->emitter (data->data);
return G_SOURCE_REMOVE;
}
static void
g_main_context_signal_dispatcher_dispatch_destroy (gpointer user_data)
{
GMainContextSignalDispatcherData *data = user_data;
if (data->destroy)
data->destroy (data->data);
g_free (data);
}
static void
gst_clapper_g_main_context_signal_dispatcher_dispatch (GstClapperSignalDispatcher
* iface, G_GNUC_UNUSED GstClapper * clapper, void (*emitter) (gpointer data),
gpointer data, GDestroyNotify destroy)
{
GstClapperGMainContextSignalDispatcher *self =
GST_CLAPPER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER (iface);
GMainContextSignalDispatcherData *gsourcefunc_data =
g_new (GMainContextSignalDispatcherData, 1);
gsourcefunc_data->emitter = emitter;
gsourcefunc_data->data = data;
gsourcefunc_data->destroy = destroy;
g_main_context_invoke_full (self->application_context,
G_PRIORITY_DEFAULT, g_main_context_signal_dispatcher_dispatch_gsourcefunc,
gsourcefunc_data, g_main_context_signal_dispatcher_dispatch_destroy);
}
static void
gst_clapper_g_main_context_signal_dispatcher_interface_init
(GstClapperSignalDispatcherInterface * iface)
{
iface->dispatch = gst_clapper_g_main_context_signal_dispatcher_dispatch;
}
/**
* gst_clapper_g_main_context_signal_dispatcher_new:
* @application_context: (allow-none): GMainContext to use or %NULL
*
* Creates a new GstClapperSignalDispatcher that uses @application_context,
* or the thread default one if %NULL is used. See gst_clapper_new().
*
* Returns: (transfer full): the new GstClapperSignalDispatcher
*/
GstClapperSignalDispatcher *
gst_clapper_g_main_context_signal_dispatcher_new (GMainContext *
application_context)
{
return g_object_new (GST_TYPE_CLAPPER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER,
"application-context", application_context, NULL);
}

View File

@@ -1,51 +0,0 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.com>
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_CLAPPER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER_H__
#define __GST_CLAPPER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER_H__
#include <gst/clapper/gstclapper-types.h>
#include <gst/clapper/gstclapper-signal-dispatcher.h>
G_BEGIN_DECLS
typedef struct _GstClapperGMainContextSignalDispatcher
GstClapperGMainContextSignalDispatcher;
typedef struct _GstClapperGMainContextSignalDispatcherClass
GstClapperGMainContextSignalDispatcherClass;
#define GST_TYPE_CLAPPER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER (gst_clapper_g_main_context_signal_dispatcher_get_type ())
#define GST_IS_CLAPPER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_CLAPPER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER))
#define GST_IS_CLAPPER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_CLAPPER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER))
#define GST_CLAPPER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_CLAPPER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER, GstClapperGMainContextSignalDispatcherClass))
#define GST_CLAPPER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_CLAPPER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER, GstClapperGMainContextSignalDispatcher))
#define GST_CLAPPER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_CLAPPER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER, GstClapperGMainContextSignalDispatcherClass))
#define GST_CLAPPER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER_CAST(obj) ((GstClapperGMainContextSignalDispatcher*)(obj))
GST_CLAPPER_API
GType gst_clapper_g_main_context_signal_dispatcher_get_type (void);
GST_CLAPPER_API
GstClapperSignalDispatcher * gst_clapper_g_main_context_signal_dispatcher_new (GMainContext * application_context);
G_END_DECLS
#endif /* __GST_CLAPPER_G_MAIN_CONTEXT_SIGNAL_DISPATCHER_H__ */

View File

@@ -1,123 +0,0 @@
/* GStreamer
*
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* SECTION:gstclapper-gtk4plugin
* @title: GstClapperGtk4Plugin
* @short_description: Clapper GTK4 plugin
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstclapper-gtk4-plugin.h"
#include "gtk4/gstclapperglsink.h"
enum
{
PROP_0,
PROP_VIDEO_SINK,
PROP_LAST
};
#define parent_class gst_clapper_gtk4_plugin_parent_class
G_DEFINE_TYPE_WITH_CODE (GstClapperGtk4Plugin, gst_clapper_gtk4_plugin,
G_TYPE_OBJECT, NULL);
static GParamSpec *param_specs[PROP_LAST] = { NULL, };
static void gst_clapper_gtk4_plugin_constructed (GObject * object);
static void gst_clapper_gtk4_plugin_finalize (GObject * object);
static void gst_clapper_gtk4_plugin_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static void gst_clapper_gtk4_plugin_init
(G_GNUC_UNUSED GstClapperGtk4Plugin * self)
{
}
static void gst_clapper_gtk4_plugin_class_init
(G_GNUC_UNUSED GstClapperGtk4PluginClass * klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
gobject_class->constructed = gst_clapper_gtk4_plugin_constructed;
gobject_class->get_property = gst_clapper_gtk4_plugin_get_property;
gobject_class->finalize = gst_clapper_gtk4_plugin_finalize;
param_specs[PROP_VIDEO_SINK] =
g_param_spec_object ("video-sink",
"Video Sink", "Video sink to use with video renderer",
GST_TYPE_ELEMENT, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, PROP_LAST, param_specs);
}
static void
gst_clapper_gtk4_plugin_constructed (GObject * object)
{
GstClapperGtk4Plugin *self = GST_CLAPPER_GTK4_PLUGIN (object);
self->video_sink = g_object_new (GST_TYPE_CLAPPER_GL_SINK, NULL);
gst_object_ref_sink (self->video_sink);
G_OBJECT_CLASS (parent_class)->constructed (object);
}
static void
gst_clapper_gtk4_plugin_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstClapperGtk4Plugin *self = GST_CLAPPER_GTK4_PLUGIN (object);
switch (prop_id) {
case PROP_VIDEO_SINK:
g_value_set_object (value, self->video_sink);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_clapper_gtk4_plugin_finalize (GObject * object)
{
GstClapperGtk4Plugin *self = GST_CLAPPER_GTK4_PLUGIN (object);
gst_object_unref (self->video_sink);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
/**
* gst_clapper_gtk4_plugin_new:
*
* Creates a new GTK4 plugin.
*
* Returns: (transfer full): the new GstClapperGtk4Plugin
*/
GstClapperGtk4Plugin *
gst_clapper_gtk4_plugin_new (void)
{
return g_object_new (GST_TYPE_CLAPPER_GTK4_PLUGIN, NULL);
}

View File

@@ -1,72 +0,0 @@
/* GStreamer
*
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_CLAPPER_GTK4_PLUGIN_H__
#define __GST_CLAPPER_GTK4_PLUGIN_H__
#include <gst/gst.h>
#include <gst/clapper/clapper-prelude.h>
G_BEGIN_DECLS
#define GST_TYPE_CLAPPER_GTK4_PLUGIN (gst_clapper_gtk4_plugin_get_type ())
#define GST_IS_CLAPPER_GTK4_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_CLAPPER_GTK4_PLUGIN))
#define GST_IS_CLAPPER_GTK4_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_CLAPPER_GTK4_PLUGIN))
#define GST_CLAPPER_GTK4_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_CLAPPER_GTK4_PLUGIN, GstClapperGtk4PluginClass))
#define GST_CLAPPER_GTK4_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_CLAPPER_GTK4_PLUGIN, GstClapperGtk4Plugin))
#define GST_CLAPPER_GTK4_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_CLAPPER_GTK4_PLUGIN, GstClapperGtk4PluginClass))
#define GST_CLAPPER_GTK4_PLUGIN_CAST(obj) ((GstClapperGtk4Plugin*)(obj))
typedef struct _GstClapperGtk4Plugin GstClapperGtk4Plugin;
typedef struct _GstClapperGtk4PluginClass GstClapperGtk4PluginClass;
/**
* GstClapperGtk4Plugin:
*
* Opaque #GstClapperGtk4Plugin object
*/
struct _GstClapperGtk4Plugin
{
/* <private> */
GObject parent;
GstElement *video_sink;
};
/**
* GstClapperGtk4PluginClass:
*
* The #GstClapperGtk4PluginClass struct only contains private data
*/
struct _GstClapperGtk4PluginClass
{
/* <private> */
GstElementClass parent_class;
};
GST_CLAPPER_API
GType gst_clapper_gtk4_plugin_get_type (void);
GST_CLAPPER_API
GstClapperGtk4Plugin * gst_clapper_gtk4_plugin_new (void);
G_END_DECLS
#endif /* __GST_CLAPPER_GTK4_PLUGIN__ */

View File

@@ -1,125 +0,0 @@
/* GStreamer
*
* Copyright (C) 2015 Brijesh Singh <brijesh.ksingh@gmail.com>
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "gstclapper-media-info.h"
#ifndef __GST_CLAPPER_MEDIA_INFO_PRIVATE_H__
#define __GST_CLAPPER_MEDIA_INFO_PRIVATE_H__
struct _GstClapperStreamInfo
{
GObject parent;
gchar *codec;
GstCaps *caps;
gint stream_index;
GstTagList *tags;
gchar *stream_id;
};
struct _GstClapperStreamInfoClass
{
GObjectClass parent_class;
};
struct _GstClapperSubtitleInfo
{
GstClapperStreamInfo parent;
gchar *title;
gchar *language;
};
struct _GstClapperSubtitleInfoClass
{
GstClapperStreamInfoClass parent_class;
};
struct _GstClapperAudioInfo
{
GstClapperStreamInfo parent;
gint channels;
gint sample_rate;
guint bitrate;
guint max_bitrate;
gchar *language;
};
struct _GstClapperAudioInfoClass
{
GstClapperStreamInfoClass parent_class;
};
struct _GstClapperVideoInfo
{
GstClapperStreamInfo parent;
gint width;
gint height;
gint framerate_num;
gint framerate_denom;
gint par_num;
gint par_denom;
guint bitrate;
guint max_bitrate;
};
struct _GstClapperVideoInfoClass
{
GstClapperStreamInfoClass parent_class;
};
struct _GstClapperMediaInfo
{
GObject parent;
gchar *uri;
gchar *title;
gchar *container;
gboolean seekable, is_live;
GstTagList *tags;
GstToc *toc;
GstSample *image_sample;
GList *stream_list;
GList *audio_stream_list;
GList *video_stream_list;
GList *subtitle_stream_list;
GstClockTime duration;
};
struct _GstClapperMediaInfoClass
{
GObjectClass parent_class;
};
G_GNUC_INTERNAL GstClapperMediaInfo * gst_clapper_media_info_new (const gchar *uri);
G_GNUC_INTERNAL GstClapperMediaInfo * gst_clapper_media_info_copy (GstClapperMediaInfo *ref);
G_GNUC_INTERNAL GstClapperStreamInfo * gst_clapper_stream_info_new (gint stream_index, GType type);
G_GNUC_INTERNAL GstClapperStreamInfo * gst_clapper_stream_info_copy (GstClapperStreamInfo *ref);
#endif /* __GST_CLAPPER_MEDIA_INFO_PRIVATE_H__ */

View File

@@ -1,885 +0,0 @@
/* GStreamer
*
* Copyright (C) 2015 Brijesh Singh <brijesh.ksingh@gmail.com>
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* SECTION:gstclapper-mediainfo
* @title: GstClapperMediaInfo
* @short_description: Clapper Media Information
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstclapper-media-info.h"
#include "gstclapper-media-info-private.h"
/* Per-stream information */
G_DEFINE_ABSTRACT_TYPE (GstClapperStreamInfo, gst_clapper_stream_info,
G_TYPE_OBJECT);
static void
gst_clapper_stream_info_init (GstClapperStreamInfo * sinfo)
{
sinfo->stream_index = -1;
}
static void
gst_clapper_stream_info_finalize (GObject * object)
{
GstClapperStreamInfo *sinfo = GST_CLAPPER_STREAM_INFO (object);
g_free (sinfo->codec);
g_free (sinfo->stream_id);
if (sinfo->caps)
gst_caps_unref (sinfo->caps);
if (sinfo->tags)
gst_tag_list_unref (sinfo->tags);
G_OBJECT_CLASS (gst_clapper_stream_info_parent_class)->finalize (object);
}
static void
gst_clapper_stream_info_class_init (GstClapperStreamInfoClass * klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
gobject_class->finalize = gst_clapper_stream_info_finalize;
}
/**
* gst_clapper_stream_info_get_index:
* @info: a #GstClapperStreamInfo
*
* Function to get stream index from #GstClapperStreamInfo instance.
*
* Returns: the stream index of this stream.
*/
gint
gst_clapper_stream_info_get_index (const GstClapperStreamInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_STREAM_INFO (info), -1);
return info->stream_index;
}
/**
* gst_clapper_stream_info_get_stream_type:
* @info: a #GstClapperStreamInfo
*
* Function to return human readable name for the stream type
* of the given @info (ex: "audio", "video", "subtitle")
*
* Returns: a human readable name
*/
const gchar *
gst_clapper_stream_info_get_stream_type (const GstClapperStreamInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_STREAM_INFO (info), NULL);
if (GST_IS_CLAPPER_VIDEO_INFO (info))
return "video";
else if (GST_IS_CLAPPER_AUDIO_INFO (info))
return "audio";
else
return "subtitle";
}
/**
* gst_clapper_stream_info_get_tags:
* @info: a #GstClapperStreamInfo
*
* Returns: (transfer none): the tags contained in this stream.
*/
GstTagList *
gst_clapper_stream_info_get_tags (const GstClapperStreamInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_STREAM_INFO (info), NULL);
return info->tags;
}
/**
* gst_clapper_stream_info_get_codec:
* @info: a #GstClapperStreamInfo
*
* A string describing codec used in #GstClapperStreamInfo.
*
* Returns: codec string or NULL on unknown.
*/
const gchar *
gst_clapper_stream_info_get_codec (const GstClapperStreamInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_STREAM_INFO (info), NULL);
return info->codec;
}
/**
* gst_clapper_stream_info_get_caps:
* @info: a #GstClapperStreamInfo
*
* Returns: (transfer none): the #GstCaps of the stream.
*/
GstCaps *
gst_clapper_stream_info_get_caps (const GstClapperStreamInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_STREAM_INFO (info), NULL);
return info->caps;
}
/* Video information */
G_DEFINE_TYPE (GstClapperVideoInfo, gst_clapper_video_info,
GST_TYPE_CLAPPER_STREAM_INFO);
static void
gst_clapper_video_info_init (GstClapperVideoInfo * info)
{
info->width = -1;
info->height = -1;
info->framerate_num = 0;
info->framerate_denom = 1;
info->par_num = 1;
info->par_denom = 1;
}
static void
gst_clapper_video_info_class_init (G_GNUC_UNUSED GstClapperVideoInfoClass * klass)
{
/* nothing to do here */
}
/**
* gst_clapper_video_info_get_width:
* @info: a #GstClapperVideoInfo
*
* Returns: the width of video in #GstClapperVideoInfo.
*/
gint
gst_clapper_video_info_get_width (const GstClapperVideoInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_VIDEO_INFO (info), -1);
return info->width;
}
/**
* gst_clapper_video_info_get_height:
* @info: a #GstClapperVideoInfo
*
* Returns: the height of video in #GstClapperVideoInfo.
*/
gint
gst_clapper_video_info_get_height (const GstClapperVideoInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_VIDEO_INFO (info), -1);
return info->height;
}
/**
* gst_clapper_video_info_get_framerate:
* @info: a #GstClapperVideoInfo
* @fps_n: (out): Numerator of frame rate
* @fps_d: (out): Denominator of frame rate
*
*/
void
gst_clapper_video_info_get_framerate (const GstClapperVideoInfo * info,
gint * fps_n, gint * fps_d)
{
g_return_if_fail (GST_IS_CLAPPER_VIDEO_INFO (info));
*fps_n = info->framerate_num;
*fps_d = info->framerate_denom;
}
/**
* gst_clapper_video_info_get_pixel_aspect_ratio:
* @info: a #GstClapperVideoInfo
* @par_n: (out): numerator
* @par_d: (out): denominator
*
* Returns the pixel aspect ratio in @par_n and @par_d
*
*/
void
gst_clapper_video_info_get_pixel_aspect_ratio (const GstClapperVideoInfo * info,
guint * par_n, guint * par_d)
{
g_return_if_fail (GST_IS_CLAPPER_VIDEO_INFO (info));
*par_n = info->par_num;
*par_d = info->par_denom;
}
/**
* gst_clapper_video_info_get_bitrate:
* @info: a #GstClapperVideoInfo
*
* Returns: the current bitrate of video in #GstClapperVideoInfo.
*/
gint
gst_clapper_video_info_get_bitrate (const GstClapperVideoInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_VIDEO_INFO (info), -1);
return info->bitrate;
}
/**
* gst_clapper_video_info_get_max_bitrate:
* @info: a #GstClapperVideoInfo
*
* Returns: the maximum bitrate of video in #GstClapperVideoInfo.
*/
gint
gst_clapper_video_info_get_max_bitrate (const GstClapperVideoInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_VIDEO_INFO (info), -1);
return info->max_bitrate;
}
/* Audio information */
G_DEFINE_TYPE (GstClapperAudioInfo, gst_clapper_audio_info,
GST_TYPE_CLAPPER_STREAM_INFO);
static void
gst_clapper_audio_info_init (GstClapperAudioInfo * info)
{
info->channels = 0;
info->sample_rate = 0;
info->bitrate = -1;
info->max_bitrate = -1;
}
static void
gst_clapper_audio_info_finalize (GObject * object)
{
GstClapperAudioInfo *info = GST_CLAPPER_AUDIO_INFO (object);
g_free (info->language);
G_OBJECT_CLASS (gst_clapper_audio_info_parent_class)->finalize (object);
}
static void
gst_clapper_audio_info_class_init (GstClapperAudioInfoClass * klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
gobject_class->finalize = gst_clapper_audio_info_finalize;
}
/**
* gst_clapper_audio_info_get_language:
* @info: a #GstClapperAudioInfo
*
* Returns: the language of the stream, or NULL if unknown.
*/
const gchar *
gst_clapper_audio_info_get_language (const GstClapperAudioInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_AUDIO_INFO (info), NULL);
return info->language;
}
/**
* gst_clapper_audio_info_get_channels:
* @info: a #GstClapperAudioInfo
*
* Returns: the number of audio channels in #GstClapperAudioInfo.
*/
gint
gst_clapper_audio_info_get_channels (const GstClapperAudioInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_AUDIO_INFO (info), 0);
return info->channels;
}
/**
* gst_clapper_audio_info_get_sample_rate:
* @info: a #GstClapperAudioInfo
*
* Returns: the audio sample rate in #GstClapperAudioInfo.
*/
gint
gst_clapper_audio_info_get_sample_rate (const GstClapperAudioInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_AUDIO_INFO (info), 0);
return info->sample_rate;
}
/**
* gst_clapper_audio_info_get_bitrate:
* @info: a #GstClapperAudioInfo
*
* Returns: the audio bitrate in #GstClapperAudioInfo.
*/
gint
gst_clapper_audio_info_get_bitrate (const GstClapperAudioInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_AUDIO_INFO (info), -1);
return info->bitrate;
}
/**
* gst_clapper_audio_info_get_max_bitrate:
* @info: a #GstClapperAudioInfo
*
* Returns: the audio maximum bitrate in #GstClapperAudioInfo.
*/
gint
gst_clapper_audio_info_get_max_bitrate (const GstClapperAudioInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_AUDIO_INFO (info), -1);
return info->max_bitrate;
}
/* Subtitle information */
G_DEFINE_TYPE (GstClapperSubtitleInfo, gst_clapper_subtitle_info,
GST_TYPE_CLAPPER_STREAM_INFO);
static void
gst_clapper_subtitle_info_init (G_GNUC_UNUSED GstClapperSubtitleInfo * info)
{
/* nothing to do */
}
static void
gst_clapper_subtitle_info_finalize (GObject * object)
{
GstClapperSubtitleInfo *info = GST_CLAPPER_SUBTITLE_INFO (object);
g_free (info->title);
g_free (info->language);
G_OBJECT_CLASS (gst_clapper_subtitle_info_parent_class)->finalize (object);
}
static void
gst_clapper_subtitle_info_class_init (GstClapperSubtitleInfoClass * klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
gobject_class->finalize = gst_clapper_subtitle_info_finalize;
}
/**
* gst_clapper_subtitle_info_get_title:
* @info: a #GstClapperSubtitleInfo
*
* Returns: the title of the stream, or NULL if unknown.
*/
const gchar *
gst_clapper_subtitle_info_get_title (const GstClapperSubtitleInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_SUBTITLE_INFO (info), NULL);
return info->title;
}
/**
* gst_clapper_subtitle_info_get_language:
* @info: a #GstClapperSubtitleInfo
*
* Returns: the language of the stream, or NULL if unknown.
*/
const gchar *
gst_clapper_subtitle_info_get_language (const GstClapperSubtitleInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_SUBTITLE_INFO (info), NULL);
return info->language;
}
/* Global media information */
G_DEFINE_TYPE (GstClapperMediaInfo, gst_clapper_media_info, G_TYPE_OBJECT);
static void
gst_clapper_media_info_init (GstClapperMediaInfo * info)
{
info->duration = -1;
info->is_live = FALSE;
info->seekable = FALSE;
}
static void
gst_clapper_media_info_finalize (GObject * object)
{
GstClapperMediaInfo *info = GST_CLAPPER_MEDIA_INFO (object);
g_free (info->uri);
g_free (info->title);
g_free (info->container);
if (info->tags)
gst_tag_list_unref (info->tags);
if (info->toc)
gst_toc_unref (info->toc);
if (info->image_sample)
gst_sample_unref (info->image_sample);
if (info->audio_stream_list)
g_list_free (info->audio_stream_list);
if (info->video_stream_list)
g_list_free (info->video_stream_list);
if (info->subtitle_stream_list)
g_list_free (info->subtitle_stream_list);
if (info->stream_list)
g_list_free_full (info->stream_list, g_object_unref);
G_OBJECT_CLASS (gst_clapper_media_info_parent_class)->finalize (object);
}
static void
gst_clapper_media_info_class_init (GstClapperMediaInfoClass * klass)
{
GObjectClass *oclass = (GObjectClass *) klass;
oclass->finalize = gst_clapper_media_info_finalize;
}
static GstClapperVideoInfo *
gst_clapper_video_info_new (void)
{
return g_object_new (GST_TYPE_CLAPPER_VIDEO_INFO, NULL);
}
static GstClapperAudioInfo *
gst_clapper_audio_info_new (void)
{
return g_object_new (GST_TYPE_CLAPPER_AUDIO_INFO, NULL);
}
static GstClapperSubtitleInfo *
gst_clapper_subtitle_info_new (void)
{
return g_object_new (GST_TYPE_CLAPPER_SUBTITLE_INFO, NULL);
}
static GstClapperStreamInfo *
gst_clapper_video_info_copy (GstClapperVideoInfo * ref)
{
GstClapperVideoInfo *ret;
ret = gst_clapper_video_info_new ();
ret->width = ref->width;
ret->height = ref->height;
ret->framerate_num = ref->framerate_num;
ret->framerate_denom = ref->framerate_denom;
ret->par_num = ref->par_num;
ret->par_denom = ref->par_denom;
ret->bitrate = ref->bitrate;
ret->max_bitrate = ref->max_bitrate;
return (GstClapperStreamInfo *) ret;
}
static GstClapperStreamInfo *
gst_clapper_audio_info_copy (GstClapperAudioInfo * ref)
{
GstClapperAudioInfo *ret;
ret = gst_clapper_audio_info_new ();
ret->sample_rate = ref->sample_rate;
ret->channels = ref->channels;
ret->bitrate = ref->bitrate;
ret->max_bitrate = ref->max_bitrate;
if (ref->language)
ret->language = g_strdup (ref->language);
return (GstClapperStreamInfo *) ret;
}
static GstClapperStreamInfo *
gst_clapper_subtitle_info_copy (GstClapperSubtitleInfo * ref)
{
GstClapperSubtitleInfo *ret;
ret = gst_clapper_subtitle_info_new ();
if (ref->title)
ret->title = g_strdup (ref->title);
if (ref->language)
ret->language = g_strdup (ref->language);
return (GstClapperStreamInfo *) ret;
}
GstClapperStreamInfo *
gst_clapper_stream_info_copy (GstClapperStreamInfo * ref)
{
GstClapperStreamInfo *info = NULL;
if (!ref)
return NULL;
if (GST_IS_CLAPPER_VIDEO_INFO (ref))
info = gst_clapper_video_info_copy ((GstClapperVideoInfo *) ref);
else if (GST_IS_CLAPPER_AUDIO_INFO (ref))
info = gst_clapper_audio_info_copy ((GstClapperAudioInfo *) ref);
else
info = gst_clapper_subtitle_info_copy ((GstClapperSubtitleInfo *) ref);
info->stream_index = ref->stream_index;
if (ref->tags)
info->tags = gst_tag_list_ref (ref->tags);
if (ref->caps)
info->caps = gst_caps_copy (ref->caps);
if (ref->codec)
info->codec = g_strdup (ref->codec);
if (ref->stream_id)
info->stream_id = g_strdup (ref->stream_id);
return info;
}
GstClapperMediaInfo *
gst_clapper_media_info_copy (GstClapperMediaInfo * ref)
{
GList *l;
GstClapperMediaInfo *info;
if (!ref)
return NULL;
info = gst_clapper_media_info_new (ref->uri);
info->duration = ref->duration;
info->seekable = ref->seekable;
info->is_live = ref->is_live;
if (ref->tags)
info->tags = gst_tag_list_ref (ref->tags);
if (ref->toc)
info->toc = gst_toc_ref (ref->toc);
if (ref->title)
info->title = g_strdup (ref->title);
if (ref->container)
info->container = g_strdup (ref->container);
if (ref->image_sample)
info->image_sample = gst_sample_ref (ref->image_sample);
for (l = ref->stream_list; l != NULL; l = l->next) {
GstClapperStreamInfo *s;
s = gst_clapper_stream_info_copy ((GstClapperStreamInfo *) l->data);
info->stream_list = g_list_append (info->stream_list, s);
if (GST_IS_CLAPPER_AUDIO_INFO (s))
info->audio_stream_list = g_list_append (info->audio_stream_list, s);
else if (GST_IS_CLAPPER_VIDEO_INFO (s))
info->video_stream_list = g_list_append (info->video_stream_list, s);
else
info->subtitle_stream_list =
g_list_append (info->subtitle_stream_list, s);
}
return info;
}
GstClapperStreamInfo *
gst_clapper_stream_info_new (gint stream_index, GType type)
{
GstClapperStreamInfo *info = NULL;
if (type == GST_TYPE_CLAPPER_AUDIO_INFO)
info = (GstClapperStreamInfo *) gst_clapper_audio_info_new ();
else if (type == GST_TYPE_CLAPPER_VIDEO_INFO)
info = (GstClapperStreamInfo *) gst_clapper_video_info_new ();
else
info = (GstClapperStreamInfo *) gst_clapper_subtitle_info_new ();
info->stream_index = stream_index;
return info;
}
GstClapperMediaInfo *
gst_clapper_media_info_new (const gchar * uri)
{
GstClapperMediaInfo *info;
g_return_val_if_fail (uri != NULL, NULL);
info = g_object_new (GST_TYPE_CLAPPER_MEDIA_INFO, NULL);
info->uri = g_strdup (uri);
return info;
}
/**
* gst_clapper_media_info_get_uri:
* @info: a #GstClapperMediaInfo
*
* Returns: the URI associated with #GstClapperMediaInfo.
*/
const gchar *
gst_clapper_media_info_get_uri (const GstClapperMediaInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_MEDIA_INFO (info), NULL);
return info->uri;
}
/**
* gst_clapper_media_info_is_seekable:
* @info: a #GstClapperMediaInfo
*
* Returns: %TRUE if the media is seekable.
*/
gboolean
gst_clapper_media_info_is_seekable (const GstClapperMediaInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_MEDIA_INFO (info), FALSE);
return info->seekable;
}
/**
* gst_clapper_media_info_is_live:
* @info: a #GstClapperMediaInfo
*
* Returns: %TRUE if the media is live.
*/
gboolean
gst_clapper_media_info_is_live (const GstClapperMediaInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_MEDIA_INFO (info), FALSE);
return info->is_live;
}
/**
* gst_clapper_media_info_get_stream_list:
* @info: a #GstClapperMediaInfo
*
* Returns: (transfer none) (element-type GstClapperStreamInfo): A #GList of
* matching #GstClapperStreamInfo.
*/
GList *
gst_clapper_media_info_get_stream_list (const GstClapperMediaInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_MEDIA_INFO (info), NULL);
return info->stream_list;
}
/**
* gst_clapper_media_info_get_video_streams:
* @info: a #GstClapperMediaInfo
*
* Returns: (transfer none) (element-type GstClapperVideoInfo): A #GList of
* matching #GstClapperVideoInfo.
*/
GList *
gst_clapper_media_info_get_video_streams (const GstClapperMediaInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_MEDIA_INFO (info), NULL);
return info->video_stream_list;
}
/**
* gst_clapper_media_info_get_subtitle_streams:
* @info: a #GstClapperMediaInfo
*
* Returns: (transfer none) (element-type GstClapperSubtitleInfo): A #GList of
* matching #GstClapperSubtitleInfo.
*/
GList *
gst_clapper_media_info_get_subtitle_streams (const GstClapperMediaInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_MEDIA_INFO (info), NULL);
return info->subtitle_stream_list;
}
/**
* gst_clapper_media_info_get_audio_streams:
* @info: a #GstClapperMediaInfo
*
* Returns: (transfer none) (element-type GstClapperAudioInfo): A #GList of
* matching #GstClapperAudioInfo.
*/
GList *
gst_clapper_media_info_get_audio_streams (const GstClapperMediaInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_MEDIA_INFO (info), NULL);
return info->audio_stream_list;
}
/**
* gst_clapper_media_info_get_duration:
* @info: a #GstClapperMediaInfo
*
* Returns: duration of the media.
*/
GstClockTime
gst_clapper_media_info_get_duration (const GstClapperMediaInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_MEDIA_INFO (info), -1);
return info->duration;
}
/**
* gst_clapper_media_info_get_tags:
* @info: a #GstClapperMediaInfo
*
* Returns: (transfer none): the tags contained in media info.
*/
GstTagList *
gst_clapper_media_info_get_tags (const GstClapperMediaInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_MEDIA_INFO (info), NULL);
return info->tags;
}
/**
* gst_clapper_media_info_get_toc:
* @info: a #GstClapperMediaInfo
*
* Returns: (transfer none): the toc contained in media info.
*/
GstToc *
gst_clapper_media_info_get_toc (const GstClapperMediaInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_MEDIA_INFO (info), NULL);
return info->toc;
}
/**
* gst_clapper_media_info_get_title:
* @info: a #GstClapperMediaInfo
*
* Returns: the media title. When metadata does not contain title,
* returns title parsed from URI.
*/
const gchar *
gst_clapper_media_info_get_title (const GstClapperMediaInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_MEDIA_INFO (info), NULL);
return info->title;
}
/**
* gst_clapper_media_info_get_container_format:
* @info: a #GstClapperMediaInfo
*
* Returns: the container format.
*/
const gchar *
gst_clapper_media_info_get_container_format (const GstClapperMediaInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_MEDIA_INFO (info), NULL);
return info->container;
}
/**
* gst_clapper_media_info_get_image_sample:
* @info: a #GstClapperMediaInfo
*
* Function to get the image (or preview-image) stored in taglist.
* Application can use `gst_sample_*_()` API's to get caps, buffer etc.
*
* Returns: (transfer none): GstSample or NULL.
*/
GstSample *
gst_clapper_media_info_get_image_sample (const GstClapperMediaInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_MEDIA_INFO (info), NULL);
return info->image_sample;
}
/**
* gst_clapper_media_info_get_number_of_streams:
* @info: a #GstClapperMediaInfo
*
* Returns: number of total streams.
*/
guint
gst_clapper_media_info_get_number_of_streams (const GstClapperMediaInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_MEDIA_INFO (info), 0);
return g_list_length (info->stream_list);
}
/**
* gst_clapper_media_info_get_number_of_video_streams:
* @info: a #GstClapperMediaInfo
*
* Returns: number of video streams.
*/
guint
gst_clapper_media_info_get_number_of_video_streams (const GstClapperMediaInfo *
info)
{
g_return_val_if_fail (GST_IS_CLAPPER_MEDIA_INFO (info), 0);
return g_list_length (info->video_stream_list);
}
/**
* gst_clapper_media_info_get_number_of_audio_streams:
* @info: a #GstClapperMediaInfo
*
* Returns: number of audio streams.
*/
guint
gst_clapper_media_info_get_number_of_audio_streams (const GstClapperMediaInfo *
info)
{
g_return_val_if_fail (GST_IS_CLAPPER_MEDIA_INFO (info), 0);
return g_list_length (info->audio_stream_list);
}
/**
* gst_clapper_media_info_get_number_of_subtitle_streams:
* @info: a #GstClapperMediaInfo
*
* Returns: number of subtitle streams.
*/
guint gst_clapper_media_info_get_number_of_subtitle_streams
(const GstClapperMediaInfo * info)
{
g_return_val_if_fail (GST_IS_CLAPPER_MEDIA_INFO (info), 0);
return g_list_length (info->subtitle_stream_list);
}

View File

@@ -1,253 +0,0 @@
/* GStreamer
*
* Copyright (C) 2015 Brijesh Singh <brijesh.ksingh@gmail.com>
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_CLAPPER_MEDIA_INFO_H__
#define __GST_CLAPPER_MEDIA_INFO_H__
#include <gst/gst.h>
#include <gst/clapper/clapper-prelude.h>
G_BEGIN_DECLS
#define GST_TYPE_CLAPPER_STREAM_INFO \
(gst_clapper_stream_info_get_type ())
#define GST_CLAPPER_STREAM_INFO(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CLAPPER_STREAM_INFO,GstClapperStreamInfo))
#define GST_CLAPPER_STREAM_INFO_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CLAPPER_STREAM_INFO,GstClapperStreamInfo))
#define GST_IS_CLAPPER_STREAM_INFO(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CLAPPER_STREAM_INFO))
#define GST_IS_CLAPPER_STREAM_INFO_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CLAPPER_STREAM_INFO))
/**
* GstClapperStreamInfo:
*
* Base structure for information concerning a media stream. Depending on
* the stream type, one can find more media-specific information in
* #GstClapperVideoInfo, #GstClapperAudioInfo, #GstClapperSubtitleInfo.
*/
typedef struct _GstClapperStreamInfo GstClapperStreamInfo;
typedef struct _GstClapperStreamInfoClass GstClapperStreamInfoClass;
GST_CLAPPER_API
GType gst_clapper_stream_info_get_type (void);
GST_CLAPPER_API
gint gst_clapper_stream_info_get_index (const GstClapperStreamInfo *info);
GST_CLAPPER_API
const gchar* gst_clapper_stream_info_get_stream_type (const GstClapperStreamInfo *info);
GST_CLAPPER_API
GstTagList* gst_clapper_stream_info_get_tags (const GstClapperStreamInfo *info);
GST_CLAPPER_API
GstCaps* gst_clapper_stream_info_get_caps (const GstClapperStreamInfo *info);
GST_CLAPPER_API
const gchar* gst_clapper_stream_info_get_codec (const GstClapperStreamInfo *info);
#define GST_TYPE_CLAPPER_VIDEO_INFO \
(gst_clapper_video_info_get_type ())
#define GST_CLAPPER_VIDEO_INFO(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CLAPPER_VIDEO_INFO, GstClapperVideoInfo))
#define GST_CLAPPER_VIDEO_INFO_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((obj),GST_TYPE_CLAPPER_VIDEO_INFO, GstClapperVideoInfoClass))
#define GST_IS_CLAPPER_VIDEO_INFO(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CLAPPER_VIDEO_INFO))
#define GST_IS_CLAPPER_VIDEO_INFO_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((obj),GST_TYPE_CLAPPER_VIDEO_INFO))
/**
* GstClapperVideoInfo:
*
* #GstClapperStreamInfo specific to video streams.
*/
typedef struct _GstClapperVideoInfo GstClapperVideoInfo;
typedef struct _GstClapperVideoInfoClass GstClapperVideoInfoClass;
GST_CLAPPER_API
GType gst_clapper_video_info_get_type (void);
GST_CLAPPER_API
gint gst_clapper_video_info_get_bitrate (const GstClapperVideoInfo * info);
GST_CLAPPER_API
gint gst_clapper_video_info_get_max_bitrate (const GstClapperVideoInfo * info);
GST_CLAPPER_API
gint gst_clapper_video_info_get_width (const GstClapperVideoInfo * info);
GST_CLAPPER_API
gint gst_clapper_video_info_get_height (const GstClapperVideoInfo * info);
GST_CLAPPER_API
void gst_clapper_video_info_get_framerate (const GstClapperVideoInfo * info,
gint * fps_n,
gint * fps_d);
GST_CLAPPER_API
void gst_clapper_video_info_get_pixel_aspect_ratio (const GstClapperVideoInfo * info,
guint * par_n,
guint * par_d);
#define GST_TYPE_CLAPPER_AUDIO_INFO \
(gst_clapper_audio_info_get_type ())
#define GST_CLAPPER_AUDIO_INFO(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CLAPPER_AUDIO_INFO, GstClapperAudioInfo))
#define GST_CLAPPER_AUDIO_INFO_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CLAPPER_AUDIO_INFO, GstClapperAudioInfoClass))
#define GST_IS_CLAPPER_AUDIO_INFO(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CLAPPER_AUDIO_INFO))
#define GST_IS_CLAPPER_AUDIO_INFO_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CLAPPER_AUDIO_INFO))
/**
* GstClapperAudioInfo:
*
* #GstClapperStreamInfo specific to audio streams.
*/
typedef struct _GstClapperAudioInfo GstClapperAudioInfo;
typedef struct _GstClapperAudioInfoClass GstClapperAudioInfoClass;
GST_CLAPPER_API
GType gst_clapper_audio_info_get_type (void);
GST_CLAPPER_API
gint gst_clapper_audio_info_get_channels (const GstClapperAudioInfo* info);
GST_CLAPPER_API
gint gst_clapper_audio_info_get_sample_rate (const GstClapperAudioInfo* info);
GST_CLAPPER_API
gint gst_clapper_audio_info_get_bitrate (const GstClapperAudioInfo* info);
GST_CLAPPER_API
gint gst_clapper_audio_info_get_max_bitrate (const GstClapperAudioInfo* info);
GST_CLAPPER_API
const gchar* gst_clapper_audio_info_get_language (const GstClapperAudioInfo* info);
#define GST_TYPE_CLAPPER_SUBTITLE_INFO \
(gst_clapper_subtitle_info_get_type ())
#define GST_CLAPPER_SUBTITLE_INFO(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CLAPPER_SUBTITLE_INFO, GstClapperSubtitleInfo))
#define GST_CLAPPER_SUBTITLE_INFO_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CLAPPER_SUBTITLE_INFO,GstClapperSubtitleInfoClass))
#define GST_IS_CLAPPER_SUBTITLE_INFO(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CLAPPER_SUBTITLE_INFO))
#define GST_IS_CLAPPER_SUBTITLE_INFO_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CLAPPER_SUBTITLE_INFO))
/**
* GstClapperSubtitleInfo:
*
* #GstClapperStreamInfo specific to subtitle streams.
*/
typedef struct _GstClapperSubtitleInfo GstClapperSubtitleInfo;
typedef struct _GstClapperSubtitleInfoClass GstClapperSubtitleInfoClass;
GST_CLAPPER_API
GType gst_clapper_subtitle_info_get_type (void);
GST_CLAPPER_API
const gchar * gst_clapper_subtitle_info_get_title (const GstClapperSubtitleInfo *info);
GST_CLAPPER_API
const gchar * gst_clapper_subtitle_info_get_language (const GstClapperSubtitleInfo *info);
#define GST_TYPE_CLAPPER_MEDIA_INFO \
(gst_clapper_media_info_get_type())
#define GST_CLAPPER_MEDIA_INFO(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CLAPPER_MEDIA_INFO,GstClapperMediaInfo))
#define GST_CLAPPER_MEDIA_INFO_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CLAPPER_MEDIA_INFO,GstClapperMediaInfoClass))
#define GST_IS_CLAPPER_MEDIA_INFO(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CLAPPER_MEDIA_INFO))
#define GST_IS_CLAPPER_MEDIA_INFO_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CLAPPER_MEDIA_INFO))
/**
* GstClapperMediaInfo:
*
* Structure containing the media information of a URI.
*/
typedef struct _GstClapperMediaInfo GstClapperMediaInfo;
typedef struct _GstClapperMediaInfoClass GstClapperMediaInfoClass;
GST_CLAPPER_API
GType gst_clapper_media_info_get_type (void);
GST_CLAPPER_API
const gchar * gst_clapper_media_info_get_uri (const GstClapperMediaInfo *info);
GST_CLAPPER_API
gboolean gst_clapper_media_info_is_seekable (const GstClapperMediaInfo *info);
GST_CLAPPER_API
gboolean gst_clapper_media_info_is_live (const GstClapperMediaInfo *info);
GST_CLAPPER_API
GstClockTime gst_clapper_media_info_get_duration (const GstClapperMediaInfo *info);
GST_CLAPPER_API
GList * gst_clapper_media_info_get_stream_list (const GstClapperMediaInfo *info);
GST_CLAPPER_API
guint gst_clapper_media_info_get_number_of_streams (const GstClapperMediaInfo *info);
GST_CLAPPER_API
GList * gst_clapper_media_info_get_video_streams (const GstClapperMediaInfo *info);
GST_CLAPPER_API
guint gst_clapper_media_info_get_number_of_video_streams (const GstClapperMediaInfo *info);
GST_CLAPPER_API
GList * gst_clapper_media_info_get_audio_streams (const GstClapperMediaInfo *info);
GST_CLAPPER_API
guint gst_clapper_media_info_get_number_of_audio_streams (const GstClapperMediaInfo *info);
GST_CLAPPER_API
GList * gst_clapper_media_info_get_subtitle_streams (const GstClapperMediaInfo *info);
GST_CLAPPER_API
guint gst_clapper_media_info_get_number_of_subtitle_streams (const GstClapperMediaInfo *info);
GST_CLAPPER_API
GstTagList * gst_clapper_media_info_get_tags (const GstClapperMediaInfo *info);
GST_CLAPPER_API
GstToc * gst_clapper_media_info_get_toc (const GstClapperMediaInfo *info);
GST_CLAPPER_API
const gchar * gst_clapper_media_info_get_title (const GstClapperMediaInfo *info);
GST_CLAPPER_API
const gchar * gst_clapper_media_info_get_container_format (const GstClapperMediaInfo *info);
GST_CLAPPER_API
GstSample * gst_clapper_media_info_get_image_sample (const GstClapperMediaInfo *info);
G_END_DECLS
#endif /* __GST_CLAPPER_MEDIA_INFO_H */

View File

@@ -1,43 +0,0 @@
/*
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_CLAPPER_MPRIS_PRIVATE_H__
#define __GST_CLAPPER_MPRIS_PRIVATE_H__
#include <gst/clapper/gstclapper-mpris.h>
#include <gst/clapper/gstclapper.h>
G_BEGIN_DECLS
G_GNUC_INTERNAL
void gst_clapper_mpris_set_clapper (GstClapperMpris *self, GstClapper *clapper,
GstClapperSignalDispatcher *signal_dispatcher);
G_GNUC_INTERNAL
void gst_clapper_mpris_set_media_info (GstClapperMpris *self, GstClapperMediaInfo *info);
G_GNUC_INTERNAL
void gst_clapper_mpris_set_playback_status (GstClapperMpris *self, const gchar *status);
G_GNUC_INTERNAL
void gst_clapper_mpris_set_position (GstClapperMpris *self, gint64 position);
G_END_DECLS
#endif /* __GST_CLAPPER_MPRIS_PRIVATE_H__ */

View File

@@ -1,793 +0,0 @@
/*
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstclapper-mpris-gdbus.h"
#include "gstclapper-mpris.h"
#include "gstclapper-mpris-private.h"
#include "gstclapper-signal-dispatcher-private.h"
GST_DEBUG_CATEGORY_STATIC (gst_clapper_mpris_debug);
#define GST_CAT_DEFAULT gst_clapper_mpris_debug
#define MPRIS_DEFAULT_VOLUME 1.0
enum
{
PROP_0,
PROP_OWN_NAME,
PROP_ID_PATH,
PROP_IDENTITY,
PROP_DESKTOP_ENTRY,
PROP_DEFAULT_ART_URL,
PROP_VOLUME,
PROP_LAST
};
struct _GstClapperMpris
{
GObject parent;
GstClapperMprisMediaPlayer2 *base_skeleton;
GstClapperMprisMediaPlayer2Player *player_skeleton;
GstClapperSignalDispatcher *signal_dispatcher;
GstClapperMediaInfo *media_info;
guint name_id;
/* Properties */
gchar *own_name;
gchar *id_path;
gchar *identity;
gchar *desktop_entry;
gchar *default_art_url;
gboolean parse_media_info;
/* Current status */
gchar *playback_status;
gboolean can_play;
guint64 position;
GThread *thread;
GMutex lock;
GCond cond;
GMainContext *context;
GMainLoop *loop;
};
struct _GstClapperMprisClass
{
GObjectClass parent_class;
};
#define parent_class gst_clapper_mpris_parent_class
G_DEFINE_TYPE (GstClapperMpris, gst_clapper_mpris, G_TYPE_OBJECT);
static GParamSpec *param_specs[PROP_LAST] = { NULL, };
static void gst_clapper_mpris_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_clapper_mpris_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static void gst_clapper_mpris_dispose (GObject * object);
static void gst_clapper_mpris_finalize (GObject * object);
static void gst_clapper_mpris_constructed (GObject * object);
static gpointer gst_clapper_mpris_main (gpointer data);
static void unregister (GstClapperMpris * self);
static void
gst_clapper_mpris_init (GstClapperMpris * self)
{
GST_DEBUG_CATEGORY_INIT (gst_clapper_mpris_debug, "ClapperMpris", 0,
"GstClapperMpris");
GST_TRACE_OBJECT (self, "Initializing");
self = gst_clapper_mpris_get_instance_private (self);
g_mutex_init (&self->lock);
g_cond_init (&self->cond);
self->context = g_main_context_new ();
self->loop = g_main_loop_new (self->context, FALSE);
self->base_skeleton = gst_clapper_mpris_media_player2_skeleton_new ();
self->player_skeleton = gst_clapper_mpris_media_player2_player_skeleton_new ();
self->name_id = 0;
self->own_name = NULL;
self->id_path = NULL;
self->identity = NULL;
self->desktop_entry = NULL;
self->default_art_url = NULL;
self->signal_dispatcher = NULL;
self->media_info = NULL;
self->parse_media_info = FALSE;
self->playback_status = g_strdup ("Stopped");
self->can_play = FALSE;
self->position = 0;
GST_TRACE_OBJECT (self, "Initialized");
}
static void
gst_clapper_mpris_class_init (GstClapperMprisClass * klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
gobject_class->set_property = gst_clapper_mpris_set_property;
gobject_class->get_property = gst_clapper_mpris_get_property;
gobject_class->dispose = gst_clapper_mpris_dispose;
gobject_class->finalize = gst_clapper_mpris_finalize;
gobject_class->constructed = gst_clapper_mpris_constructed;
param_specs[PROP_OWN_NAME] =
g_param_spec_string ("own-name", "DBus own name",
"DBus name to own on connection",
NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
param_specs[PROP_ID_PATH] =
g_param_spec_string ("id-path", "DBus id path",
"A valid D-Bus path describing this player",
NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
param_specs[PROP_IDENTITY] =
g_param_spec_string ("identity", "Player name",
"A friendly name to identify the media player",
NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
param_specs[PROP_DESKTOP_ENTRY] =
g_param_spec_string ("desktop-entry", "Desktop entry filename",
"The basename of an installed .desktop file",
NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
param_specs[PROP_DEFAULT_ART_URL] =
g_param_spec_string ("default-art-url", "Default Art URL",
"Default art to show when media does not provide one",
NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
param_specs[PROP_VOLUME] =
g_param_spec_double ("volume", "Volume", "Volume",
0, 1.5, MPRIS_DEFAULT_VOLUME, G_PARAM_READWRITE |
G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, PROP_LAST, param_specs);
}
static void
gst_clapper_mpris_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstClapperMpris *self = GST_CLAPPER_MPRIS (object);
switch (prop_id) {
case PROP_OWN_NAME:
self->own_name = g_value_dup_string (value);
break;
case PROP_ID_PATH:
self->id_path = g_value_dup_string (value);
break;
case PROP_IDENTITY:
self->identity = g_value_dup_string (value);
break;
case PROP_DESKTOP_ENTRY:
self->desktop_entry = g_value_dup_string (value);
break;
case PROP_DEFAULT_ART_URL:
self->default_art_url = g_value_dup_string (value);
break;
case PROP_VOLUME:
g_object_set_property (G_OBJECT (self->player_skeleton), "volume", value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_clapper_mpris_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstClapperMpris *self = GST_CLAPPER_MPRIS (object);
switch (prop_id) {
case PROP_OWN_NAME:
g_value_set_string (value, self->own_name);
break;
case PROP_ID_PATH:
g_value_set_string (value, self->id_path);
break;
case PROP_IDENTITY:
g_value_set_string (value, self->identity);
break;
case PROP_DESKTOP_ENTRY:
g_value_set_string (value, self->desktop_entry);
break;
case PROP_DEFAULT_ART_URL:
g_value_set_string (value, self->default_art_url);
break;
case PROP_VOLUME:
g_object_get_property (G_OBJECT (self->player_skeleton), "volume", value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_clapper_mpris_dispose (GObject * object)
{
GstClapperMpris *self = GST_CLAPPER_MPRIS (object);
GST_TRACE_OBJECT (self, "Stopping main thread");
if (self->loop) {
g_main_loop_quit (self->loop);
if (self->thread != g_thread_self ())
g_thread_join (self->thread);
else
g_thread_unref (self->thread);
self->thread = NULL;
g_main_loop_unref (self->loop);
self->loop = NULL;
g_main_context_unref (self->context);
self->context = NULL;
}
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
gst_clapper_mpris_finalize (GObject * object)
{
GstClapperMpris *self = GST_CLAPPER_MPRIS (object);
GST_TRACE_OBJECT (self, "Finalize");
g_free (self->own_name);
g_free (self->id_path);
g_free (self->identity);
g_free (self->desktop_entry);
g_free (self->default_art_url);
g_free (self->playback_status);
if (self->base_skeleton)
g_object_unref (self->base_skeleton);
if (self->player_skeleton)
g_object_unref (self->player_skeleton);
if (self->signal_dispatcher)
g_object_unref (self->signal_dispatcher);
if (self->media_info)
g_object_unref (self->media_info);
g_mutex_clear (&self->lock);
g_cond_clear (&self->cond);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gst_clapper_mpris_constructed (GObject * object)
{
GstClapperMpris *self = GST_CLAPPER_MPRIS (object);
GST_TRACE_OBJECT (self, "Constructed");
g_mutex_lock (&self->lock);
self->thread = g_thread_new ("GstClapperMpris",
gst_clapper_mpris_main, self);
while (!self->loop || !g_main_loop_is_running (self->loop))
g_cond_wait (&self->cond, &self->lock);
g_mutex_unlock (&self->lock);
G_OBJECT_CLASS (parent_class)->constructed (object);
}
static gboolean
main_loop_running_cb (gpointer user_data)
{
GstClapperMpris *self = GST_CLAPPER_MPRIS (user_data);
GST_TRACE_OBJECT (self, "Main loop running now");
g_mutex_lock (&self->lock);
g_cond_signal (&self->cond);
g_mutex_unlock (&self->lock);
return G_SOURCE_REMOVE;
}
static gboolean
handle_play_cb (GstClapperMprisMediaPlayer2Player * player_skeleton,
GDBusMethodInvocation * invocation, gpointer user_data)
{
GstClapper *clapper = GST_CLAPPER (user_data);
GST_DEBUG ("Handle Play");
gst_clapper_play (clapper);
gst_clapper_mpris_media_player2_player_complete_play (player_skeleton, invocation);
return TRUE;
}
static gboolean
handle_pause_cb (GstClapperMprisMediaPlayer2Player * player_skeleton,
GDBusMethodInvocation * invocation, gpointer user_data)
{
GstClapper *clapper = GST_CLAPPER (user_data);
GST_DEBUG ("Handle Pause");
gst_clapper_pause (clapper);
gst_clapper_mpris_media_player2_player_complete_pause (player_skeleton, invocation);
return TRUE;
}
static gboolean
handle_play_pause_cb (GstClapperMprisMediaPlayer2Player * player_skeleton,
GDBusMethodInvocation * invocation, gpointer user_data)
{
GstClapper *clapper = GST_CLAPPER (user_data);
GST_DEBUG ("Handle PlayPause");
gst_clapper_toggle_play (clapper);
gst_clapper_mpris_media_player2_player_complete_play_pause (player_skeleton, invocation);
return TRUE;
}
static gboolean
handle_seek_cb (GstClapperMprisMediaPlayer2Player * player_skeleton,
GDBusMethodInvocation * invocation, gint64 offset, gpointer user_data)
{
GstClapper *clapper = GST_CLAPPER (user_data);
GST_DEBUG ("Handle Seek");
gst_clapper_seek_offset (clapper, offset * GST_USECOND);
gst_clapper_mpris_media_player2_player_complete_seek (player_skeleton, invocation);
return TRUE;
}
static gboolean
handle_set_position_cb (GstClapperMprisMediaPlayer2Player * player_skeleton,
GDBusMethodInvocation * invocation, const gchar * track_id,
gint64 position, gpointer user_data)
{
GstClapper *clapper = GST_CLAPPER (user_data);
GST_DEBUG ("Handle SetPosition");
gst_clapper_seek (clapper, position * GST_USECOND);
gst_clapper_mpris_media_player2_player_complete_set_position (player_skeleton, invocation);
return TRUE;
}
static gboolean
handle_open_uri_cb (GstClapperMprisMediaPlayer2Player * player_skeleton,
GDBusMethodInvocation * invocation, const gchar * uri,
gpointer user_data)
{
GstClapper *clapper = GST_CLAPPER (user_data);
GST_DEBUG ("Handle OpenUri");
/* FIXME: set one item playlist instead */
gst_clapper_set_uri (clapper, uri);
gst_clapper_mpris_media_player2_player_complete_open_uri (player_skeleton, invocation);
return TRUE;
}
static void
volume_notify_dispatch (gpointer user_data)
{
GstClapperMpris *self = user_data;
g_object_notify_by_pspec (G_OBJECT (self), param_specs[PROP_VOLUME]);
}
static void
handle_volume_notify_cb (G_GNUC_UNUSED GObject * obj,
G_GNUC_UNUSED GParamSpec * pspec, GstClapperMpris * self)
{
gst_clapper_signal_dispatcher_dispatch (self->signal_dispatcher, NULL,
volume_notify_dispatch, g_object_ref (self),
(GDestroyNotify) g_object_unref);
}
static void
unregister (GstClapperMpris * self)
{
if (!self->name_id)
return;
GST_DEBUG_OBJECT (self, "Unregister");
g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (self->base_skeleton));
g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (self->player_skeleton));
g_bus_unown_name (self->name_id);
self->name_id = 0;
}
static const gchar *
_get_mpris_trackid (GstClapperMpris * self)
{
/* TODO: Support more tracks */
return g_strdup_printf ("%s%s%i", self->id_path, "/Track/", 0);
}
static void
_set_supported_uri_schemes (GstClapperMpris * self)
{
const gchar *uri_schemes[96] = {};
GList *elements, *el;
guint index = 0;
elements = gst_element_factory_list_get_elements (
GST_ELEMENT_FACTORY_TYPE_SRC, GST_RANK_NONE);
for (el = elements; el != NULL; el = el->next) {
const gchar *const *protocols;
GstElementFactory *factory = GST_ELEMENT_FACTORY (el->data);
if (gst_element_factory_get_uri_type (factory) != GST_URI_SRC)
continue;
protocols = gst_element_factory_get_uri_protocols (factory);
if (protocols == NULL || *protocols == NULL)
continue;
while (*protocols != NULL) {
guint j = index;
while (j--) {
if (strcmp (uri_schemes[j], *protocols) == 0)
goto next;
}
uri_schemes[index] = *protocols;
GST_DEBUG_OBJECT (self, "Added supported URI scheme: %s", *protocols);
++index;
next:
++protocols;
}
}
gst_plugin_feature_list_free (elements);
gst_clapper_mpris_media_player2_set_supported_uri_schemes (
self->base_skeleton, uri_schemes);
}
static void
name_acquired_cb (GDBusConnection * connection,
const gchar *name, gpointer user_data)
{
GstClapperMpris *self = GST_CLAPPER_MPRIS (user_data);
GVariantBuilder builder;
g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->base_skeleton),
connection, "/org/mpris/MediaPlayer2", NULL);
g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->player_skeleton),
connection, "/org/mpris/MediaPlayer2", NULL);
if (self->identity)
gst_clapper_mpris_media_player2_set_identity (self->base_skeleton, self->identity);
if (self->desktop_entry)
gst_clapper_mpris_media_player2_set_desktop_entry (self->base_skeleton, self->desktop_entry);
_set_supported_uri_schemes (self);
gst_clapper_mpris_media_player2_player_set_playback_status (self->player_skeleton, "Stopped");
gst_clapper_mpris_media_player2_player_set_minimum_rate (self->player_skeleton, 0.01);
gst_clapper_mpris_media_player2_player_set_maximum_rate (self->player_skeleton, 2.0);
gst_clapper_mpris_media_player2_player_set_can_seek (self->player_skeleton, TRUE);
gst_clapper_mpris_media_player2_player_set_can_control (self->player_skeleton, TRUE);
g_object_bind_property (self->player_skeleton, "can-play",
self->player_skeleton, "can-pause", G_BINDING_DEFAULT);
g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
g_variant_builder_add (&builder, "{sv}", "mpris:trackid", g_variant_new_string (_get_mpris_trackid (self)));
g_variant_builder_add (&builder, "{sv}", "mpris:length", g_variant_new_uint64 (0));
if (self->default_art_url)
g_variant_builder_add (&builder, "{sv}", "mpris:artUrl", g_variant_new_string (self->default_art_url));
gst_clapper_mpris_media_player2_player_set_metadata (self->player_skeleton, g_variant_builder_end (&builder));
GST_DEBUG_OBJECT (self, "Ready");
}
static void
name_lost_cb (GDBusConnection * connection,
const gchar * name, gpointer user_data)
{
GstClapperMpris *self = GST_CLAPPER_MPRIS (user_data);
unregister (self);
}
static gboolean
mpris_update_props_dispatch (gpointer user_data)
{
GstClapperMpris *self = GST_CLAPPER_MPRIS (user_data);
GST_DEBUG_OBJECT (self, "Updating MPRIS props");
g_mutex_lock (&self->lock);
if (self->parse_media_info) {
GVariantBuilder builder;
guint64 duration;
const gchar *track_id, *uri, *title;
GST_DEBUG_OBJECT (self, "Parsing media info");
g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
track_id = _get_mpris_trackid (self);
uri = gst_clapper_media_info_get_uri (self->media_info);
title = gst_clapper_media_info_get_title (self->media_info);
if (track_id) {
g_variant_builder_add (&builder, "{sv}", "mpris:trackid",
g_variant_new_string (track_id));
GST_DEBUG_OBJECT (self, "mpris:trackid: %s", track_id);
}
if (uri) {
g_variant_builder_add (&builder, "{sv}", "xesam:url",
g_variant_new_string (uri));
GST_DEBUG_OBJECT (self, "xesam:url: %s", uri);
}
if (title) {
g_variant_builder_add (&builder, "{sv}", "xesam:title",
g_variant_new_string (title));
GST_DEBUG_OBJECT (self, "xesam:title: %s", title);
}
duration = gst_clapper_media_info_get_duration (self->media_info);
duration = (duration != GST_CLOCK_TIME_NONE) ? duration / GST_USECOND : 0;
g_variant_builder_add (&builder, "{sv}", "mpris:length", g_variant_new_uint64 (duration));
GST_DEBUG_OBJECT (self, "mpris:length: %ld", duration);
/* TODO: Check for image sample */
if (self->default_art_url) {
g_variant_builder_add (&builder, "{sv}", "mpris:artUrl", g_variant_new_string (self->default_art_url));
GST_DEBUG_OBJECT (self, "mpris:artUrl: %s", self->default_art_url);
}
GST_DEBUG_OBJECT (self, "Media info parsed");
self->parse_media_info = FALSE;
gst_clapper_mpris_media_player2_player_set_metadata (
self->player_skeleton, g_variant_builder_end (&builder));
}
if (gst_clapper_mpris_media_player2_player_get_can_play (
self->player_skeleton) != self->can_play) {
/* "can-play" is bound with "can-pause" */
gst_clapper_mpris_media_player2_player_set_can_play (
self->player_skeleton, self->can_play);
GST_DEBUG_OBJECT (self, "CanPlay/CanPause: %s", self->can_play ? "yes" : "no");
}
if (strcmp (gst_clapper_mpris_media_player2_player_get_playback_status (
self->player_skeleton), self->playback_status) != 0) {
gst_clapper_mpris_media_player2_player_set_playback_status (
self->player_skeleton, self->playback_status);
GST_DEBUG_OBJECT (self, "PlaybackStatus: %s", self->playback_status);
}
if (gst_clapper_mpris_media_player2_player_get_position (
self->player_skeleton) != self->position) {
gst_clapper_mpris_media_player2_player_set_position (
self->player_skeleton, self->position);
GST_DEBUG_OBJECT (self, "Position: %ld", self->position);
}
g_mutex_unlock (&self->lock);
GST_DEBUG_OBJECT (self, "MPRIS props updated");
return G_SOURCE_REMOVE;
}
static void
mpris_dispatcher_update_dispatch (GstClapperMpris * self)
{
if (!self->name_id)
return;
GST_DEBUG_OBJECT (self, "Queued update props dispatch");
g_main_context_invoke_full (self->context,
G_PRIORITY_DEFAULT, mpris_update_props_dispatch,
g_object_ref (self), g_object_unref);
}
static gpointer
gst_clapper_mpris_main (gpointer data)
{
GstClapperMpris *self = GST_CLAPPER_MPRIS (data);
GDBusConnectionFlags flags;
GDBusConnection *connection;
GSource *source;
gchar *address;
GST_TRACE_OBJECT (self, "Starting main thread");
g_main_context_push_thread_default (self->context);
source = g_idle_source_new ();
g_source_set_callback (source, (GSourceFunc) main_loop_running_cb, self,
NULL);
g_source_attach (source, self->context);
g_source_unref (source);
address = g_dbus_address_get_for_bus_sync (G_BUS_TYPE_SESSION, NULL, NULL);
if (!address) {
GST_WARNING_OBJECT (self, "No MPRIS bus address");
goto no_mpris;
}
GST_DEBUG_OBJECT (self, "Obtained MPRIS DBus address");
flags = G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT |
G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION;
connection = g_dbus_connection_new_for_address_sync (address,
flags, NULL, NULL, NULL);
g_free (address);
if (!connection) {
GST_WARNING_OBJECT (self, "No MPRIS bus connection");
goto no_mpris;
}
GST_DEBUG_OBJECT (self, "Obtained MPRIS DBus connection");
self->name_id = g_bus_own_name_on_connection (connection, self->own_name,
G_BUS_NAME_OWNER_FLAGS_NONE,
(GBusNameAcquiredCallback) name_acquired_cb,
(GBusNameLostCallback) name_lost_cb,
self, NULL);
g_object_unref (connection);
goto done;
no_mpris:
g_warning ("GstClapperMpris: failed to create DBus connection");
done:
GST_TRACE_OBJECT (self, "Starting main loop");
g_main_loop_run (self->loop);
GST_TRACE_OBJECT (self, "Stopped main loop");
unregister (self);
g_main_context_pop_thread_default (self->context);
GST_TRACE_OBJECT (self, "Stopped main thread");
return NULL;
}
void
gst_clapper_mpris_set_clapper (GstClapperMpris * self, GstClapper * clapper,
GstClapperSignalDispatcher * signal_dispatcher)
{
if (signal_dispatcher)
self->signal_dispatcher = g_object_ref (signal_dispatcher);
g_signal_connect (self->player_skeleton, "handle-play",
G_CALLBACK (handle_play_cb), clapper);
g_signal_connect (self->player_skeleton, "handle-pause",
G_CALLBACK (handle_pause_cb), clapper);
g_signal_connect (self->player_skeleton, "handle-play-pause",
G_CALLBACK (handle_play_pause_cb), clapper);
g_signal_connect (self->player_skeleton, "handle-seek",
G_CALLBACK (handle_seek_cb), clapper);
g_signal_connect (self->player_skeleton, "handle-set-position",
G_CALLBACK (handle_set_position_cb), clapper);
g_signal_connect (self->player_skeleton, "handle-open-uri",
G_CALLBACK (handle_open_uri_cb), clapper);
g_object_bind_property (clapper, "volume", self, "volume", G_BINDING_BIDIRECTIONAL);
g_signal_connect (self->player_skeleton, "notify::volume",
G_CALLBACK (handle_volume_notify_cb), self);
}
void
gst_clapper_mpris_set_playback_status (GstClapperMpris * self, const gchar * status)
{
g_mutex_lock (&self->lock);
if (strcmp (self->playback_status, status) == 0) {
g_mutex_unlock (&self->lock);
return;
}
g_free (self->playback_status);
self->playback_status = g_strdup (status);
self->can_play = strcmp (status, "Stopped") != 0;
g_mutex_unlock (&self->lock);
mpris_dispatcher_update_dispatch (self);
}
void
gst_clapper_mpris_set_position (GstClapperMpris * self, gint64 position)
{
position /= GST_USECOND;
g_mutex_lock (&self->lock);
if (self->position == position) {
g_mutex_unlock (&self->lock);
return;
}
self->position = position;
g_mutex_unlock (&self->lock);
mpris_dispatcher_update_dispatch (self);
}
void
gst_clapper_mpris_set_media_info (GstClapperMpris *self, GstClapperMediaInfo *info)
{
g_mutex_lock (&self->lock);
if (self->media_info)
g_object_unref (self->media_info);
self->media_info = info;
self->parse_media_info = TRUE;
g_mutex_unlock (&self->lock);
mpris_dispatcher_update_dispatch (self);
}
/**
* gst_clapper_mpris_new:
* @own_name: DBus own name
* @id_path: DBus id path used for prefix
* @identity: (allow-none): friendly name
* @desktop_entry: (allow-none): Desktop entry filename
* @default_art_url: (allow-none): filepath to default art
*
* Creates a new #GstClapperMpris instance.
*
* Returns: (transfer full): a new #GstClapperMpris instance
*/
GstClapperMpris *
gst_clapper_mpris_new (const gchar * own_name, const gchar * id_path,
const gchar * identity, const gchar * desktop_entry,
const gchar * default_art_url)
{
return g_object_new (GST_TYPE_CLAPPER_MPRIS,
"own-name", own_name, "id_path", id_path,
"identity", identity, "desktop-entry", desktop_entry,
"default-art-url", default_art_url, NULL);
}

View File

@@ -1,54 +0,0 @@
/*
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_CLAPPER_MPRIS_H__
#define __GST_CLAPPER_MPRIS_H__
#include <glib.h>
#include <gio/gio.h>
#include <gst/clapper/clapper-prelude.h>
G_BEGIN_DECLS
typedef struct _GstClapperMpris GstClapperMpris;
typedef struct _GstClapperMprisClass GstClapperMprisClass;
#define GST_TYPE_CLAPPER_MPRIS (gst_clapper_mpris_get_type ())
#define GST_IS_CLAPPER_MPRIS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_CLAPPER_MPRIS))
#define GST_IS_CLAPPER_MPRIS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_CLAPPER_MPRIS))
#define GST_CLAPPER_MPRIS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_CLAPPER_MPRIS, GstClapperMprisClass))
#define GST_CLAPPER_MPRIS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_CLAPPER_MPRIS, GstClapperMpris))
#define GST_CLAPPER_MPRIS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_CLAPPER_MPRIS, GstClapperMprisClass))
#define GST_CLAPPER_MPRIS_CAST(obj) ((GstClapperMpris*)(obj))
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstClapperMpris, g_object_unref)
#endif
GST_CLAPPER_API
GType gst_clapper_mpris_get_type (void);
GST_CLAPPER_API
GstClapperMpris * gst_clapper_mpris_new (const gchar *own_name, const gchar *id_path, const gchar *identity,
const gchar *desktop_entry, const gchar *default_art_url);
G_END_DECLS
#endif /* __GST_CLAPPER_MPRIS_H__ */

View File

@@ -1,35 +0,0 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.com>
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_CLAPPER_SIGNAL_DISPATCHER_PRIVATE_H__
#define __GST_CLAPPER_SIGNAL_DISPATCHER_PRIVATE_H__
#include <gst/clapper/gstclapper-signal-dispatcher.h>
G_BEGIN_DECLS
G_GNUC_INTERNAL void gst_clapper_signal_dispatcher_dispatch (GstClapperSignalDispatcher * self,
GstClapper * clapper, GstClapperSignalDispatcherFunc emitter, gpointer data,
GDestroyNotify destroy);
G_END_DECLS
#endif /* __GST_CLAPPER_SIGNAL_DISPATCHER_PRIVATE_H__ */

View File

@@ -1,58 +0,0 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.com>
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstclapper-signal-dispatcher.h"
#include "gstclapper-signal-dispatcher-private.h"
G_DEFINE_INTERFACE (GstClapperSignalDispatcher, gst_clapper_signal_dispatcher,
G_TYPE_OBJECT);
static void
gst_clapper_signal_dispatcher_default_init (G_GNUC_UNUSED
GstClapperSignalDispatcherInterface * iface)
{
}
void
gst_clapper_signal_dispatcher_dispatch (GstClapperSignalDispatcher * self,
GstClapper * clapper, GstClapperSignalDispatcherFunc emitter, gpointer data,
GDestroyNotify destroy)
{
GstClapperSignalDispatcherInterface *iface;
if (!self) {
emitter (data);
if (destroy)
destroy (data);
return;
}
g_return_if_fail (GST_IS_CLAPPER_SIGNAL_DISPATCHER (self));
iface = GST_CLAPPER_SIGNAL_DISPATCHER_GET_INTERFACE (self);
g_return_if_fail (iface->dispatch != NULL);
iface->dispatch (self, clapper, emitter, data, destroy);
}

View File

@@ -1,53 +0,0 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.com>
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_CLAPPER_SIGNAL_DISPATCHER_H__
#define __GST_CLAPPER_SIGNAL_DISPATCHER_H__
#include <gst/gst.h>
#include <gst/clapper/gstclapper-types.h>
G_BEGIN_DECLS
typedef struct _GstClapperSignalDispatcher GstClapperSignalDispatcher;
typedef struct _GstClapperSignalDispatcherInterface GstClapperSignalDispatcherInterface;
#define GST_TYPE_CLAPPER_SIGNAL_DISPATCHER (gst_clapper_signal_dispatcher_get_type ())
#define GST_CLAPPER_SIGNAL_DISPATCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_CLAPPER_SIGNAL_DISPATCHER, GstClapperSignalDispatcher))
#define GST_IS_CLAPPER_SIGNAL_DISPATCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_CLAPPER_SIGNAL_DISPATCHER))
#define GST_CLAPPER_SIGNAL_DISPATCHER_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_CLAPPER_SIGNAL_DISPATCHER, GstClapperSignalDispatcherInterface))
typedef void (*GstClapperSignalDispatcherFunc) (gpointer data);
struct _GstClapperSignalDispatcherInterface {
GTypeInterface parent_iface;
void (*dispatch) (GstClapperSignalDispatcher * self, GstClapper * clapper,
GstClapperSignalDispatcherFunc emitter, gpointer data,
GDestroyNotify destroy);
};
GST_CLAPPER_API
GType gst_clapper_signal_dispatcher_get_type (void);
G_END_DECLS
#endif /* __GST_CLAPPER_SIGNAL_DISPATCHER_H__ */

View File

@@ -1,37 +0,0 @@
/* GStreamer
*
* Copyright (C) 2015 Sebastian Dröge <sebastian@centricular.com>
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_CLAPPER_TYPES_H__
#define __GST_CLAPPER_TYPES_H__
#include <gst/gst.h>
#include <gst/clapper/clapper-prelude.h>
G_BEGIN_DECLS
typedef struct _GstClapper GstClapper;
typedef struct _GstClapperClass GstClapperClass;
G_END_DECLS
#endif /* __GST_CLAPPER_TYPES_H__ */

View File

@@ -1,345 +0,0 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.com>
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* SECTION:gstclapper-videooverlayvideorenderer
* @title: GstClapperVideoOverlayVideoRenderer
* @short_description: Clapper Video Overlay Video Renderer
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstclapper-video-overlay-video-renderer.h"
#include "gstclapper.h"
#include <gst/video/video.h>
struct _GstClapperVideoOverlayVideoRenderer
{
GObject parent;
GstVideoOverlay *video_overlay;
gpointer window_handle;
gint x, y, width, height;
GstElement *video_sink; /* configured video sink, or NULL */
};
struct _GstClapperVideoOverlayVideoRendererClass
{
GObjectClass parent_class;
};
static void
gst_clapper_video_overlay_video_renderer_interface_init
(GstClapperVideoRendererInterface * iface);
enum
{
VIDEO_OVERLAY_VIDEO_RENDERER_PROP_0,
VIDEO_OVERLAY_VIDEO_RENDERER_PROP_WINDOW_HANDLE,
VIDEO_OVERLAY_VIDEO_RENDERER_PROP_VIDEO_SINK,
VIDEO_OVERLAY_VIDEO_RENDERER_PROP_LAST
};
G_DEFINE_TYPE_WITH_CODE (GstClapperVideoOverlayVideoRenderer,
gst_clapper_video_overlay_video_renderer, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (GST_TYPE_CLAPPER_VIDEO_RENDERER,
gst_clapper_video_overlay_video_renderer_interface_init));
static GParamSpec
* video_overlay_video_renderer_param_specs
[VIDEO_OVERLAY_VIDEO_RENDERER_PROP_LAST] = { NULL, };
static void
gst_clapper_video_overlay_video_renderer_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstClapperVideoOverlayVideoRenderer *self =
GST_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER (object);
switch (prop_id) {
case VIDEO_OVERLAY_VIDEO_RENDERER_PROP_WINDOW_HANDLE:
self->window_handle = g_value_get_pointer (value);
if (self->video_overlay)
gst_video_overlay_set_window_handle (self->video_overlay,
(guintptr) self->window_handle);
break;
case VIDEO_OVERLAY_VIDEO_RENDERER_PROP_VIDEO_SINK:
self->video_sink = gst_object_ref_sink (g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_clapper_video_overlay_video_renderer_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec)
{
GstClapperVideoOverlayVideoRenderer *self =
GST_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER (object);
switch (prop_id) {
case VIDEO_OVERLAY_VIDEO_RENDERER_PROP_WINDOW_HANDLE:
g_value_set_pointer (value, self->window_handle);
break;
case VIDEO_OVERLAY_VIDEO_RENDERER_PROP_VIDEO_SINK:
g_value_set_object (value, self->video_sink);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_clapper_video_overlay_video_renderer_finalize (GObject * object)
{
GstClapperVideoOverlayVideoRenderer *self =
GST_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER (object);
if (self->video_overlay)
gst_object_unref (self->video_overlay);
if (self->video_sink)
gst_object_unref (self->video_sink);
G_OBJECT_CLASS
(gst_clapper_video_overlay_video_renderer_parent_class)->finalize (object);
}
static void
gst_clapper_video_overlay_video_renderer_class_init
(GstClapperVideoOverlayVideoRendererClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->set_property =
gst_clapper_video_overlay_video_renderer_set_property;
gobject_class->get_property =
gst_clapper_video_overlay_video_renderer_get_property;
gobject_class->finalize = gst_clapper_video_overlay_video_renderer_finalize;
video_overlay_video_renderer_param_specs
[VIDEO_OVERLAY_VIDEO_RENDERER_PROP_WINDOW_HANDLE] =
g_param_spec_pointer ("window-handle", "Window Handle",
"Window handle to embed the video into",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
video_overlay_video_renderer_param_specs
[VIDEO_OVERLAY_VIDEO_RENDERER_PROP_VIDEO_SINK] =
g_param_spec_object ("video-sink", "Video Sink",
"the video output element to use (NULL = default sink)",
GST_TYPE_ELEMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class,
VIDEO_OVERLAY_VIDEO_RENDERER_PROP_LAST,
video_overlay_video_renderer_param_specs);
}
static void
gst_clapper_video_overlay_video_renderer_init
(GstClapperVideoOverlayVideoRenderer * self)
{
self->x = self->y = self->width = self->height = -1;
self->video_sink = NULL;
}
static GstElement *gst_clapper_video_overlay_video_renderer_create_video_sink
(GstClapperVideoRenderer * iface, GstClapper * clapper)
{
GstElement *video_overlay;
GstClapperVideoOverlayVideoRenderer *self =
GST_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER (iface);
if (self->video_overlay)
gst_object_unref (self->video_overlay);
video_overlay = gst_clapper_get_pipeline (clapper);
g_return_val_if_fail (GST_IS_VIDEO_OVERLAY (video_overlay), NULL);
self->video_overlay = GST_VIDEO_OVERLAY (video_overlay);
gst_video_overlay_set_window_handle (self->video_overlay,
(guintptr) self->window_handle);
if (self->width != -1 || self->height != -1)
gst_video_overlay_set_render_rectangle (self->video_overlay, self->x,
self->y, self->width, self->height);
return self->video_sink;
}
static void
gst_clapper_video_overlay_video_renderer_interface_init
(GstClapperVideoRendererInterface * iface)
{
iface->create_video_sink =
gst_clapper_video_overlay_video_renderer_create_video_sink;
}
/**
* gst_clapper_video_overlay_video_renderer_new:
* @window_handle: (allow-none): Window handle to use or %NULL
*
* Returns: (transfer full):
*/
GstClapperVideoRenderer *
gst_clapper_video_overlay_video_renderer_new (gpointer window_handle)
{
return g_object_new (GST_TYPE_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER,
"window-handle", window_handle, NULL);
}
/**
* gst_clapper_video_overlay_video_renderer_new_with_sink:
* @window_handle: (allow-none): Window handle to use or %NULL
* @video_sink: (transfer floating): the custom video_sink element to be set for the video renderer
*
* Returns: (transfer full): clapper video renderer
*/
GstClapperVideoRenderer *
gst_clapper_video_overlay_video_renderer_new_with_sink (gpointer window_handle,
GstElement * video_sink)
{
return g_object_new (GST_TYPE_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER,
"window-handle", window_handle, "video-sink", video_sink, NULL);
}
/**
* gst_clapper_video_overlay_video_renderer_set_window_handle:
* @self: #GstClapperVideoRenderer instance
* @window_handle: handle referencing to the platform specific window
*
* Sets the platform specific window handle into which the video
* should be rendered
**/
void gst_clapper_video_overlay_video_renderer_set_window_handle
(GstClapperVideoOverlayVideoRenderer * self, gpointer window_handle)
{
g_return_if_fail (GST_IS_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER (self));
g_object_set (self, "window-handle", window_handle, NULL);
}
/**
* gst_clapper_video_overlay_video_renderer_get_window_handle:
* @self: #GstClapperVideoRenderer instance
*
* Returns: (transfer none): The currently set, platform specific window
* handle
*/
gpointer
gst_clapper_video_overlay_video_renderer_get_window_handle
(GstClapperVideoOverlayVideoRenderer * self) {
gpointer window_handle;
g_return_val_if_fail (GST_IS_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER (self),
NULL);
g_object_get (self, "window-handle", &window_handle, NULL);
return window_handle;
}
/**
* gst_clapper_video_overlay_video_renderer_expose:
* @self: a #GstClapperVideoOverlayVideoRenderer instance.
*
* Tell an overlay that it has been exposed. This will redraw the current frame
* in the drawable even if the pipeline is PAUSED.
*/
void gst_clapper_video_overlay_video_renderer_expose
(GstClapperVideoOverlayVideoRenderer * self)
{
g_return_if_fail (GST_IS_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER (self));
if (self->video_overlay)
gst_video_overlay_expose (self->video_overlay);
}
/**
* gst_clapper_video_overlay_video_renderer_set_render_rectangle:
* @self: a #GstClapperVideoOverlayVideoRenderer instance
* @x: the horizontal offset of the render area inside the window
* @y: the vertical offset of the render area inside the window
* @width: the width of the render area inside the window
* @height: the height of the render area inside the window
*
* Configure a subregion as a video target within the window set by
* gst_clapper_video_overlay_video_renderer_set_window_handle(). If this is not
* used or not supported the video will fill the area of the window set as the
* overlay to 100%. By specifying the rectangle, the video can be overlaid to
* a specific region of that window only. After setting the new rectangle one
* should call gst_clapper_video_overlay_video_renderer_expose() to force a
* redraw. To unset the region pass -1 for the @width and @height parameters.
*
* This method is needed for non fullscreen video overlay in UI toolkits that
* do not support subwindows.
*
*/
void gst_clapper_video_overlay_video_renderer_set_render_rectangle
(GstClapperVideoOverlayVideoRenderer * self, gint x, gint y, gint width,
gint height)
{
g_return_if_fail (GST_IS_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER (self));
self->x = x;
self->y = y;
self->width = width;
self->height = height;
if (self->video_overlay)
gst_video_overlay_set_render_rectangle (self->video_overlay,
x, y, width, height);
}
/**
* gst_clapper_video_overlay_video_renderer_get_render_rectangle:
* @self: a #GstClapperVideoOverlayVideoRenderer instance
* @x: (out) (allow-none): the horizontal offset of the render area inside the window
* @y: (out) (allow-none): the vertical offset of the render area inside the window
* @width: (out) (allow-none): the width of the render area inside the window
* @height: (out) (allow-none): the height of the render area inside the window
*
* Return the currently configured render rectangle. See gst_clapper_video_overlay_video_renderer_set_render_rectangle()
* for details.
*
*/
void gst_clapper_video_overlay_video_renderer_get_render_rectangle
(GstClapperVideoOverlayVideoRenderer * self, gint * x, gint * y,
gint * width, gint * height)
{
g_return_if_fail (GST_IS_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER (self));
if (x)
*x = self->x;
if (y)
*y = self->y;
if (width)
*width = self->width;
if (height)
*height = self->height;
}

View File

@@ -1,71 +0,0 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.com>
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER_H__
#define __GST_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER_H__
#include <gst/clapper/gstclapper-types.h>
#include <gst/clapper/gstclapper-video-renderer.h>
G_BEGIN_DECLS
typedef struct _GstClapperVideoOverlayVideoRenderer
GstClapperVideoOverlayVideoRenderer;
typedef struct _GstClapperVideoOverlayVideoRendererClass
GstClapperVideoOverlayVideoRendererClass;
#define GST_TYPE_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER (gst_clapper_video_overlay_video_renderer_get_type ())
#define GST_IS_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER))
#define GST_IS_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER))
#define GST_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER, GstClapperVideoOverlayVideoRendererClass))
#define GST_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER, GstClapperVideoOverlayVideoRenderer))
#define GST_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER, GstClapperVideoOverlayVideoRendererClass))
#define GST_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER_CAST(obj) ((GstClapperVideoOverlayVideoRenderer*)(obj))
GST_CLAPPER_API
GType gst_clapper_video_overlay_video_renderer_get_type (void);
GST_CLAPPER_API
GstClapperVideoRenderer *
gst_clapper_video_overlay_video_renderer_new (gpointer window_handle);
GST_CLAPPER_API
GstClapperVideoRenderer *
gst_clapper_video_overlay_video_renderer_new_with_sink (gpointer window_handle, GstElement *video_sink);
GST_CLAPPER_API
void gst_clapper_video_overlay_video_renderer_set_window_handle (GstClapperVideoOverlayVideoRenderer *self, gpointer window_handle);
GST_CLAPPER_API
gpointer gst_clapper_video_overlay_video_renderer_get_window_handle (GstClapperVideoOverlayVideoRenderer *self);
GST_CLAPPER_API
void gst_clapper_video_overlay_video_renderer_expose (GstClapperVideoOverlayVideoRenderer *self);
GST_CLAPPER_API
void gst_clapper_video_overlay_video_renderer_set_render_rectangle (GstClapperVideoOverlayVideoRenderer *self, gint x, gint y, gint width, gint height);
GST_CLAPPER_API
void gst_clapper_video_overlay_video_renderer_get_render_rectangle (GstClapperVideoOverlayVideoRenderer *self, gint *x, gint *y, gint *width, gint *height);
G_END_DECLS
#endif /* __GST_CLAPPER_VIDEO_OVERLAY_VIDEO_RENDERER_H__ */

View File

@@ -1,33 +0,0 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.com>
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_CLAPPER_VIDEO_RENDERER_PRIVATE_H__
#define __GST_CLAPPER_VIDEO_RENDERER_PRIVATE_H__
#include <gst/clapper/gstclapper-video-renderer.h>
G_BEGIN_DECLS
G_GNUC_INTERNAL GstElement * gst_clapper_video_renderer_create_video_sink (GstClapperVideoRenderer *self, GstClapper *clapper);
G_END_DECLS
#endif /* __GST_CLAPPER_VIDEO_RENDERER_PRIVATE_H__ */

View File

@@ -1,50 +0,0 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.com>
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstclapper-video-renderer.h"
#include "gstclapper-video-renderer-private.h"
G_DEFINE_INTERFACE (GstClapperVideoRenderer, gst_clapper_video_renderer,
G_TYPE_OBJECT);
static void
gst_clapper_video_renderer_default_init (G_GNUC_UNUSED
GstClapperVideoRendererInterface * iface)
{
}
GstElement *
gst_clapper_video_renderer_create_video_sink (GstClapperVideoRenderer * self,
GstClapper * clapper)
{
GstClapperVideoRendererInterface *iface;
g_return_val_if_fail (GST_IS_CLAPPER_VIDEO_RENDERER (self), NULL);
iface = GST_CLAPPER_VIDEO_RENDERER_GET_INTERFACE (self);
g_return_val_if_fail (iface->create_video_sink != NULL, NULL);
return iface->create_video_sink (self, clapper);
}

View File

@@ -1,49 +0,0 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.com>
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_CLAPPER_VIDEO_RENDERER_H__
#define __GST_CLAPPER_VIDEO_RENDERER_H__
#include <gst/gst.h>
#include <gst/clapper/gstclapper-types.h>
G_BEGIN_DECLS
typedef struct _GstClapperVideoRenderer GstClapperVideoRenderer;
typedef struct _GstClapperVideoRendererInterface GstClapperVideoRendererInterface;
#define GST_TYPE_CLAPPER_VIDEO_RENDERER (gst_clapper_video_renderer_get_type ())
#define GST_CLAPPER_VIDEO_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_CLAPPER_VIDEO_RENDERER, GstClapperVideoRenderer))
#define GST_IS_CLAPPER_VIDEO_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_CLAPPER_VIDEO_RENDERER))
#define GST_CLAPPER_VIDEO_RENDERER_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_CLAPPER_VIDEO_RENDERER, GstClapperVideoRendererInterface))
struct _GstClapperVideoRendererInterface {
GTypeInterface parent_iface;
GstElement * (*create_video_sink) (GstClapperVideoRenderer * self, GstClapper * clapper);
};
GST_CLAPPER_API
GType gst_clapper_video_renderer_get_type (void);
G_END_DECLS
#endif /* __GST_CLAPPER_VIDEO_RENDERER_H__ */

View File

@@ -1,180 +0,0 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.com>
* Copyright (C) 2015 Brijesh Singh <brijesh.ksingh@gmail.com>
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* SECTION:gstclapper-visualization
* @title: GstClapperVisualization
* @short_description: Clapper Visualization
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstclapper-visualization.h"
#include <string.h>
static GMutex vis_lock;
static GQueue vis_list = G_QUEUE_INIT;
static guint32 vis_cookie;
G_DEFINE_BOXED_TYPE (GstClapperVisualization, gst_clapper_visualization,
(GBoxedCopyFunc) gst_clapper_visualization_copy,
(GBoxedFreeFunc) gst_clapper_visualization_free);
/**
* gst_clapper_visualization_free:
* @vis: #GstClapperVisualization instance
*
* Frees a #GstClapperVisualization.
*/
void
gst_clapper_visualization_free (GstClapperVisualization * vis)
{
g_return_if_fail (vis != NULL);
g_free (vis->name);
g_free (vis->description);
g_free (vis);
}
/**
* gst_clapper_visualization_copy:
* @vis: #GstClapperVisualization instance
*
* Makes a copy of the #GstClapperVisualization. The result must be
* freed using gst_clapper_visualization_free().
*
* Returns: (transfer full): an allocated copy of @vis.
*/
GstClapperVisualization *
gst_clapper_visualization_copy (const GstClapperVisualization * vis)
{
GstClapperVisualization *ret;
g_return_val_if_fail (vis != NULL, NULL);
ret = g_new0 (GstClapperVisualization, 1);
ret->name = vis->name ? g_strdup (vis->name) : NULL;
ret->description = vis->description ? g_strdup (vis->description) : NULL;
return ret;
}
/**
* gst_clapper_visualizations_free:
* @viss: a %NULL terminated array of #GstClapperVisualization to free
*
* Frees a %NULL terminated array of #GstClapperVisualization.
*/
void
gst_clapper_visualizations_free (GstClapperVisualization ** viss)
{
GstClapperVisualization **p;
g_return_if_fail (viss != NULL);
p = viss;
while (*p) {
g_free ((*p)->name);
g_free ((*p)->description);
g_free (*p);
p++;
}
g_free (viss);
}
static void
gst_clapper_update_visualization_list (void)
{
GList *features;
GList *l;
guint32 cookie;
GstClapperVisualization *vis;
g_mutex_lock (&vis_lock);
/* check if we need to update the list */
cookie = gst_registry_get_feature_list_cookie (gst_registry_get ());
if (vis_cookie == cookie) {
g_mutex_unlock (&vis_lock);
return;
}
/* if update is needed then first free the existing list */
while ((vis = g_queue_pop_head (&vis_list)))
gst_clapper_visualization_free (vis);
features = gst_registry_get_feature_list (gst_registry_get (),
GST_TYPE_ELEMENT_FACTORY);
for (l = features; l; l = l->next) {
GstPluginFeature *feature = l->data;
const gchar *klass;
klass = gst_element_factory_get_metadata (GST_ELEMENT_FACTORY (feature),
GST_ELEMENT_METADATA_KLASS);
if (strstr (klass, "Visualization")) {
vis = g_new0 (GstClapperVisualization, 1);
vis->name = g_strdup (gst_plugin_feature_get_name (feature));
vis->description =
g_strdup (gst_element_factory_get_metadata (GST_ELEMENT_FACTORY
(feature), GST_ELEMENT_METADATA_DESCRIPTION));
g_queue_push_tail (&vis_list, vis);
}
}
gst_plugin_feature_list_free (features);
vis_cookie = cookie;
g_mutex_unlock (&vis_lock);
}
/**
* gst_clapper_visualizations_get:
*
* Returns: (transfer full) (array zero-terminated=1) (element-type GstClapperVisualization):
* a %NULL terminated array containing all available
* visualizations. Use gst_clapper_visualizations_free() after
* usage.
*/
GstClapperVisualization **
gst_clapper_visualizations_get (void)
{
gint i = 0;
GList *l;
GstClapperVisualization **ret;
gst_clapper_update_visualization_list ();
g_mutex_lock (&vis_lock);
ret = g_new0 (GstClapperVisualization *, g_queue_get_length (&vis_list) + 1);
for (l = vis_list.head; l; l = l->next)
ret[i++] = gst_clapper_visualization_copy (l->data);
g_mutex_unlock (&vis_lock);
return ret;
}

View File

@@ -1,61 +0,0 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.com>
* Copyright (C) 2015 Brijesh Singh <brijesh.ksingh@gmail.com>
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_CLAPPER_VISUALIZATION_H__
#define __GST_CLAPPER_VISUALIZATION_H__
#include <gst/gst.h>
#include <gst/clapper/clapper-prelude.h>
G_BEGIN_DECLS
typedef struct _GstClapperVisualization GstClapperVisualization;
/**
* GstClapperVisualization:
* @name: name of the visualization.
* @description: description of the visualization.
*
* A #GstClapperVisualization descriptor.
*/
struct _GstClapperVisualization {
gchar *name;
gchar *description;
};
GST_CLAPPER_API
GType gst_clapper_visualization_get_type (void);
GST_CLAPPER_API
GstClapperVisualization * gst_clapper_visualization_copy (const GstClapperVisualization *vis);
GST_CLAPPER_API
void gst_clapper_visualization_free (GstClapperVisualization *vis);
GST_CLAPPER_API
GstClapperVisualization ** gst_clapper_visualizations_get (void);
GST_CLAPPER_API
void gst_clapper_visualizations_free (GstClapperVisualization **viss);
G_END_DECLS
#endif /* __GST_CLAPPER_VISUALIZATION_H__ */

File diff suppressed because it is too large Load Diff

View File

@@ -1,318 +0,0 @@
/* GStreamer
*
* Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.com>
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_CLAPPER_H__
#define __GST_CLAPPER_H__
#include <gst/gst.h>
#include <gst/video/video.h>
#include <gst/clapper/clapper-prelude.h>
#include <gst/clapper/gstclapper-types.h>
#include <gst/clapper/gstclapper-signal-dispatcher.h>
#include <gst/clapper/gstclapper-video-renderer.h>
#include <gst/clapper/gstclapper-media-info.h>
#include <gst/clapper/gstclapper-mpris.h>
G_BEGIN_DECLS
/* ClapperState */
GST_CLAPPER_API
GType gst_clapper_state_get_type (void);
#define GST_TYPE_CLAPPER_STATE (gst_clapper_state_get_type ())
/**
* GstClapperState:
* @GST_CLAPPER_STATE_STOPPED: clapper is stopped.
* @GST_CLAPPER_STATE_BUFFERING: clapper is buffering.
* @GST_CLAPPER_STATE_PAUSED: clapper is paused.
* @GST_CLAPPER_STATE_PLAYING: clapper is currently playing a stream.
*/
typedef enum
{
GST_CLAPPER_STATE_STOPPED,
GST_CLAPPER_STATE_BUFFERING,
GST_CLAPPER_STATE_PAUSED,
GST_CLAPPER_STATE_PLAYING
} GstClapperState;
GST_CLAPPER_API
const gchar * gst_clapper_state_get_name (GstClapperState state);
/* ClapperSeekMode */
GST_CLAPPER_API
GType gst_clapper_seek_mode_get_type (void);
#define GST_TYPE_CLAPPER_SEEK_MODE (gst_clapper_seek_mode_get_type ())
/**
* GstClapperSeekMode:
* @GST_CLAPPER_SEEK_MODE_DEFAULT: default seek method (flush only).
* @GST_CLAPPER_SEEK_MODE_ACCURATE: accurate seek method.
* @GST_CLAPPER_SEEK_MODE_FAST: fast seek method (next keyframe).
*/
typedef enum
{
GST_CLAPPER_SEEK_MODE_DEFAULT,
GST_CLAPPER_SEEK_MODE_ACCURATE,
GST_CLAPPER_SEEK_MODE_FAST,
} GstClapperSeekMode;
/* ClapperError */
GST_CLAPPER_API
GQuark gst_clapper_error_quark (void);
GST_CLAPPER_API
GType gst_clapper_error_get_type (void);
#define GST_CLAPPER_ERROR (gst_clapper_error_quark ())
#define GST_TYPE_CLAPPER_ERROR (gst_clapper_error_get_type ())
/**
* GstClapperError:
* @GST_CLAPPER_ERROR_FAILED: generic error.
*/
typedef enum {
GST_CLAPPER_ERROR_FAILED = 0
} GstClapperError;
GST_CLAPPER_API
const gchar * gst_clapper_error_get_name (GstClapperError error);
/* ClapperColorBalanceType */
GST_CLAPPER_API
GType gst_clapper_color_balance_type_get_type (void);
#define GST_TYPE_CLAPPER_COLOR_BALANCE_TYPE (gst_clapper_color_balance_type_get_type ())
/**
* GstClapperColorBalanceType:
* @GST_CLAPPER_COLOR_BALANCE_BRIGHTNESS: brightness or black level.
* @GST_CLAPPER_COLOR_BALANCE_CONTRAST: contrast or luma gain.
* @GST_CLAPPER_COLOR_BALANCE_SATURATION: color saturation or chroma
* gain.
* @GST_CLAPPER_COLOR_BALANCE_HUE: hue or color balance.
*/
typedef enum
{
GST_CLAPPER_COLOR_BALANCE_BRIGHTNESS,
GST_CLAPPER_COLOR_BALANCE_CONTRAST,
GST_CLAPPER_COLOR_BALANCE_SATURATION,
GST_CLAPPER_COLOR_BALANCE_HUE,
} GstClapperColorBalanceType;
GST_CLAPPER_API
const gchar * gst_clapper_color_balance_type_get_name (GstClapperColorBalanceType type);
/* ClapperSnapshotFormat */
/**
* GstClapperSnapshotFormat:
* @GST_CLAPPER_THUMBNAIL_RAW_NATIVE: RAW Native.
* @GST_CLAPPER_THUMBNAIL_RAW_xRGB: RAW xRGB.
* @GST_CLAPPER_THUMBNAIL_RAW_BGRx: RAW BGRx.
* @GST_CLAPPER_THUMBNAIL_JPG: JPG.
* @GST_CLAPPER_THUMBNAIL_PNG: PNG.
*/
typedef enum
{
GST_CLAPPER_THUMBNAIL_RAW_NATIVE = 0,
GST_CLAPPER_THUMBNAIL_RAW_xRGB,
GST_CLAPPER_THUMBNAIL_RAW_BGRx,
GST_CLAPPER_THUMBNAIL_JPG,
GST_CLAPPER_THUMBNAIL_PNG
} GstClapperSnapshotFormat;
#define GST_TYPE_CLAPPER (gst_clapper_get_type ())
#define GST_IS_CLAPPER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_CLAPPER))
#define GST_IS_CLAPPER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_CLAPPER))
#define GST_CLAPPER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_CLAPPER, GstClapperClass))
#define GST_CLAPPER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_CLAPPER, GstClapper))
#define GST_CLAPPER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_CLAPPER, GstClapperClass))
#define GST_CLAPPER_CAST(obj) ((GstClapper*)(obj))
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstClapper, gst_object_unref)
#endif
GST_CLAPPER_API
GType gst_clapper_get_type (void);
GST_CLAPPER_API
void gst_clapper_gst_init (int *argc, char **argv[]);
GST_CLAPPER_API
GstClapper * gst_clapper_new (GstClapperVideoRenderer *video_renderer, GstClapperSignalDispatcher *signal_dispatcher,
GstClapperMpris *mpris);
GST_CLAPPER_API
void gst_clapper_play (GstClapper *clapper);
GST_CLAPPER_API
void gst_clapper_pause (GstClapper *clapper);
GST_CLAPPER_API
void gst_clapper_toggle_play (GstClapper *clapper);
GST_CLAPPER_API
void gst_clapper_stop (GstClapper *clapper);
GST_CLAPPER_API
void gst_clapper_seek (GstClapper *clapper, GstClockTime position);
GST_CLAPPER_API
void gst_clapper_seek_offset (GstClapper *clapper, GstClockTime offset);
GST_CLAPPER_API
GstClapperState
gst_clapper_get_state (GstClapper *clapper);
GST_CLAPPER_API
GstClapperSeekMode
gst_clapper_get_seek_mode (GstClapper *clapper);
GST_CLAPPER_API
void gst_clapper_set_seek_mode (GstClapper *clapper, GstClapperSeekMode mode);
GST_CLAPPER_API
void gst_clapper_set_rate (GstClapper *clapper, gdouble rate);
GST_CLAPPER_API
gdouble gst_clapper_get_rate (GstClapper *clapper);
GST_CLAPPER_API
gchar * gst_clapper_get_uri (GstClapper *clapper);
GST_CLAPPER_API
void gst_clapper_set_uri (GstClapper *clapper, const gchar *uri);
GST_CLAPPER_API
gchar * gst_clapper_get_subtitle_uri (GstClapper *clapper);
GST_CLAPPER_API
void gst_clapper_set_subtitle_uri (GstClapper *clapper, const gchar *uri);
GST_CLAPPER_API
GstClockTime gst_clapper_get_position (GstClapper *clapper);
GST_CLAPPER_API
GstClockTime gst_clapper_get_duration (GstClapper *clapper);
GST_CLAPPER_API
gdouble gst_clapper_get_volume (GstClapper *clapper);
GST_CLAPPER_API
void gst_clapper_set_volume (GstClapper *clapper, gdouble val);
GST_CLAPPER_API
gboolean gst_clapper_get_mute (GstClapper *clapper);
GST_CLAPPER_API
void gst_clapper_set_mute (GstClapper *clapper, gboolean val);
GST_CLAPPER_API
GstElement * gst_clapper_get_pipeline (GstClapper *clapper);
GST_CLAPPER_API
GstClapperMpris *
gst_clapper_get_mpris (GstClapper *clapper);
GST_CLAPPER_API
void gst_clapper_set_video_track_enabled (GstClapper *clapper, gboolean enabled);
GST_CLAPPER_API
void gst_clapper_set_audio_track_enabled (GstClapper *clapper, gboolean enabled);
GST_CLAPPER_API
void gst_clapper_set_subtitle_track_enabled (GstClapper *clapper, gboolean enabled);
GST_CLAPPER_API
gboolean gst_clapper_set_audio_track (GstClapper *clapper, gint stream_index);
GST_CLAPPER_API
gboolean gst_clapper_set_video_track (GstClapper *clapper, gint stream_index);
GST_CLAPPER_API
gboolean gst_clapper_set_subtitle_track (GstClapper *clapper, gint stream_index);
GST_CLAPPER_API
GstClapperMediaInfo *
gst_clapper_get_media_info (GstClapper *clapper);
GST_CLAPPER_API
GstClapperAudioInfo *
gst_clapper_get_current_audio_track (GstClapper *clapper);
GST_CLAPPER_API
GstClapperVideoInfo *
gst_clapper_get_current_video_track (GstClapper *clapper);
GST_CLAPPER_API
GstClapperSubtitleInfo *
gst_clapper_get_current_subtitle_track (GstClapper *clapper);
GST_CLAPPER_API
gboolean gst_clapper_set_visualization (GstClapper *clapper, const gchar *name);
GST_CLAPPER_API
void gst_clapper_set_visualization_enabled (GstClapper *clapper, gboolean enabled);
GST_CLAPPER_API
gchar * gst_clapper_get_current_visualization (GstClapper *clapper);
GST_CLAPPER_API
gboolean gst_clapper_has_color_balance (GstClapper *clapper);
GST_CLAPPER_API
void gst_clapper_set_color_balance (GstClapper *clapper, GstClapperColorBalanceType type, gdouble value);
GST_CLAPPER_API
gdouble gst_clapper_get_color_balance (GstClapper *clapper, GstClapperColorBalanceType type);
GST_CLAPPER_API
GstVideoMultiviewFramePacking
gst_clapper_get_multiview_mode (GstClapper *clapper);
GST_CLAPPER_API
void gst_clapper_set_multiview_mode (GstClapper *clapper, GstVideoMultiviewFramePacking mode);
GST_CLAPPER_API
GstVideoMultiviewFlags
gst_clapper_get_multiview_flags (GstClapper *clapper);
GST_CLAPPER_API
void gst_clapper_set_multiview_flags (GstClapper *clapper, GstVideoMultiviewFlags flags);
GST_CLAPPER_API
gint64 gst_clapper_get_audio_video_offset (GstClapper *clapper);
GST_CLAPPER_API
void gst_clapper_set_audio_video_offset (GstClapper *clapper, gint64 offset);
GST_CLAPPER_API
gint64 gst_clapper_get_subtitle_video_offset (GstClapper *clapper);
GST_CLAPPER_API
void gst_clapper_set_subtitle_video_offset (GstClapper *clapper, gint64 offset);
GST_CLAPPER_API
GstSample * gst_clapper_get_video_snapshot (GstClapper *clapper, GstClapperSnapshotFormat format, const GstStructure *config);
G_END_DECLS
#endif /* __GST_CLAPPER_H__ */

View File

@@ -1,759 +0,0 @@
/*
* GStreamer
* Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
* Copyright (C) 2020 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* SECTION:gstclapperglsink
* @title: GstClapperGLSink
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gl/gstglfuncs.h>
#include "gstclapperglsink.h"
#include "gstgtkutils.h"
GST_DEBUG_CATEGORY (gst_debug_clapper_gl_sink);
#define GST_CAT_DEFAULT gst_debug_clapper_gl_sink
#define GST_CLAPPER_GL_SINK_CAPS \
"video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "), " \
"format = (string) RGBA, " \
"width = " GST_VIDEO_SIZE_RANGE ", " \
"height = " GST_VIDEO_SIZE_RANGE ", " \
"framerate = " GST_VIDEO_FPS_RANGE ", " \
"texture-target = (string) { 2D, external-oes } " \
" ; " \
"video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "," \
GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION "), " \
"format = (string) RGBA, " \
"width = " GST_VIDEO_SIZE_RANGE ", " \
"height = " GST_VIDEO_SIZE_RANGE ", " \
"framerate = " GST_VIDEO_FPS_RANGE ", " \
"texture-target = (string) { 2D, external-oes } "
static GstStaticPadTemplate gst_clapper_gl_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_CLAPPER_GL_SINK_CAPS));
static void gst_clapper_gl_sink_finalize (GObject * object);
static void gst_clapper_gl_sink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * param_spec);
static void gst_clapper_gl_sink_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * param_spec);
static gboolean gst_clapper_gl_sink_propose_allocation (GstBaseSink * bsink,
GstQuery * query);
static gboolean gst_clapper_gl_sink_query (GstBaseSink * bsink, GstQuery * query);
static gboolean gst_clapper_gl_sink_start (GstBaseSink * bsink);
static gboolean gst_clapper_gl_sink_stop (GstBaseSink * bsink);
static GstFlowReturn gst_clapper_gl_sink_wait_event (GstBaseSink * bsink, GstEvent * event);
static GstStateChangeReturn
gst_clapper_gl_sink_change_state (GstElement * element,
GstStateChange transition);
static void gst_clapper_gl_sink_get_times (GstBaseSink * bsink, GstBuffer * buf,
GstClockTime * start, GstClockTime * end);
static GstCaps *gst_clapper_gl_sink_get_caps (GstBaseSink * bsink,
GstCaps * filter);
static gboolean gst_clapper_gl_sink_set_caps (GstBaseSink * bsink,
GstCaps * caps);
static GstFlowReturn gst_clapper_gl_sink_show_frame (GstVideoSink * bsink,
GstBuffer * buf);
static void
gst_clapper_gl_sink_navigation_interface_init (GstNavigationInterface * iface);
#define gst_clapper_gl_sink_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstClapperGLSink, gst_clapper_gl_sink,
GST_TYPE_VIDEO_SINK,
G_IMPLEMENT_INTERFACE (GST_TYPE_NAVIGATION,
gst_clapper_gl_sink_navigation_interface_init);
GST_DEBUG_CATEGORY_INIT (gst_debug_clapper_gl_sink,
"clapperglsink", 0, "Clapper GL Sink"));
static void
gst_clapper_gl_sink_class_init (GstClapperGLSinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstBaseSinkClass *gstbasesink_class;
GstVideoSinkClass *gstvideosink_class;
GstClapperGLSinkClass *gstclapperglsink_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstbasesink_class = (GstBaseSinkClass *) klass;
gstvideosink_class = (GstVideoSinkClass *) klass;
gstclapperglsink_class = (GstClapperGLSinkClass *) klass;
gobject_class->set_property = gst_clapper_gl_sink_set_property;
gobject_class->get_property = gst_clapper_gl_sink_get_property;
gobject_class->finalize = gst_clapper_gl_sink_finalize;
g_object_class_install_property (gobject_class, PROP_WIDGET,
g_param_spec_object ("widget", "GTK Widget",
"The GtkWidget to place in the widget hierarchy "
"(must only be get from the GTK main thread)",
GTK_TYPE_WIDGET, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
gst_gtk_install_shared_properties (gobject_class);
gstelement_class->change_state = gst_clapper_gl_sink_change_state;
gstbasesink_class->get_caps = gst_clapper_gl_sink_get_caps;
gstbasesink_class->set_caps = gst_clapper_gl_sink_set_caps;
gstbasesink_class->get_times = gst_clapper_gl_sink_get_times;
gstbasesink_class->propose_allocation = gst_clapper_gl_sink_propose_allocation;
gstbasesink_class->query = gst_clapper_gl_sink_query;
gstbasesink_class->start = gst_clapper_gl_sink_start;
gstbasesink_class->stop = gst_clapper_gl_sink_stop;
gstbasesink_class->wait_event = gst_clapper_gl_sink_wait_event;
gstvideosink_class->show_frame = gst_clapper_gl_sink_show_frame;
gstclapperglsink_class->create_widget = gtk_clapper_gl_widget_new;
gstclapperglsink_class->window_title = "GTK4 GL Renderer";
gst_element_class_set_metadata (gstelement_class,
"GTK4 GL Video Sink",
"Sink/Video", "A video sink that renders to a GtkWidget using OpenGL",
"Matthew Waters <matthew@centricular.com>, "
"Rafał Dzięgiel <rafostar.github@gmail.com>");
gst_element_class_add_static_pad_template (gstelement_class,
&gst_clapper_gl_sink_template);
gst_type_mark_as_plugin_api (GST_TYPE_CLAPPER_GL_SINK, 0);
}
static void
gst_clapper_gl_sink_init (GstClapperGLSink * clapper_sink)
{
clapper_sink->force_aspect_ratio = DEFAULT_FORCE_ASPECT_RATIO;
clapper_sink->par_n = DEFAULT_PAR_N;
clapper_sink->par_d = DEFAULT_PAR_D;
clapper_sink->keep_last_frame = DEFAULT_KEEP_LAST_FRAME;
clapper_sink->had_eos = FALSE;
}
static void
gst_clapper_gl_sink_finalize (GObject * object)
{
GstClapperGLSink *clapper_sink = GST_CLAPPER_GL_SINK (object);
GST_DEBUG ("Finalizing Clapper GL sink");
GST_OBJECT_LOCK (clapper_sink);
if (clapper_sink->window && clapper_sink->window_destroy_id)
g_signal_handler_disconnect (clapper_sink->window, clapper_sink->window_destroy_id);
if (clapper_sink->widget && clapper_sink->widget_destroy_id)
g_signal_handler_disconnect (clapper_sink->widget, clapper_sink->widget_destroy_id);
g_clear_object (&clapper_sink->widget);
GST_OBJECT_UNLOCK (clapper_sink);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
widget_destroy_cb (GtkWidget * widget, GstClapperGLSink * clapper_sink)
{
GST_OBJECT_LOCK (clapper_sink);
g_clear_object (&clapper_sink->widget);
GST_OBJECT_UNLOCK (clapper_sink);
}
static void
window_destroy_cb (GtkWidget * widget, GstClapperGLSink * clapper_sink)
{
GST_OBJECT_LOCK (clapper_sink);
if (clapper_sink->widget) {
if (clapper_sink->widget_destroy_id) {
g_signal_handler_disconnect (clapper_sink->widget,
clapper_sink->widget_destroy_id);
clapper_sink->widget_destroy_id = 0;
}
g_clear_object (&clapper_sink->widget);
}
clapper_sink->window = NULL;
GST_OBJECT_UNLOCK (clapper_sink);
}
static GtkClapperGLWidget *
gst_clapper_gl_sink_get_widget (GstClapperGLSink * clapper_sink)
{
if (clapper_sink->widget != NULL)
return clapper_sink->widget;
/* Ensure GTK is initialized, this has no side effect if it was already
* initialized. Also, we do that lazily, so the application can be first */
if (!gtk_init_check ()) {
GST_ERROR_OBJECT (clapper_sink, "Could not ensure GTK initialization.");
return NULL;
}
g_assert (GST_CLAPPER_GL_SINK_GET_CLASS (clapper_sink)->create_widget);
clapper_sink->widget = (GtkClapperGLWidget *)
GST_CLAPPER_GL_SINK_GET_CLASS (clapper_sink)->create_widget ();
g_object_bind_property (clapper_sink, "force-aspect-ratio", clapper_sink->widget,
"force-aspect-ratio", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
g_object_bind_property (clapper_sink, "pixel-aspect-ratio", clapper_sink->widget,
"pixel-aspect-ratio", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
g_object_bind_property (clapper_sink, "keep-last-frame", clapper_sink->widget,
"keep-last-frame", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
/* Take the floating ref, other wise the destruction of the container will
* make this widget disappear possibly before we are done. */
gst_object_ref_sink (clapper_sink->widget);
clapper_sink->widget_destroy_id = g_signal_connect (clapper_sink->widget, "destroy",
G_CALLBACK (widget_destroy_cb), clapper_sink);
/* back pointer */
gtk_clapper_gl_widget_set_element (GTK_CLAPPER_GL_WIDGET (clapper_sink->widget),
GST_ELEMENT (clapper_sink));
return clapper_sink->widget;
}
static void
gst_clapper_gl_sink_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstClapperGLSink *clapper_sink = GST_CLAPPER_GL_SINK (object);
switch (prop_id) {
case PROP_WIDGET:
{
GObject *widget = NULL;
GST_OBJECT_LOCK (clapper_sink);
if (clapper_sink->widget != NULL)
widget = G_OBJECT (clapper_sink->widget);
GST_OBJECT_UNLOCK (clapper_sink);
if (!widget)
widget =
gst_gtk_invoke_on_main ((GThreadFunc) gst_clapper_gl_sink_get_widget,
clapper_sink);
g_value_set_object (value, widget);
break;
}
case PROP_FORCE_ASPECT_RATIO:
g_value_set_boolean (value, clapper_sink->force_aspect_ratio);
break;
case PROP_PIXEL_ASPECT_RATIO:
gst_value_set_fraction (value, clapper_sink->par_n, clapper_sink->par_d);
break;
case PROP_KEEP_LAST_FRAME:
g_value_set_boolean (value, clapper_sink->keep_last_frame);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_clapper_gl_sink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstClapperGLSink *clapper_sink = GST_CLAPPER_GL_SINK (object);
switch (prop_id) {
case PROP_FORCE_ASPECT_RATIO:
clapper_sink->force_aspect_ratio = g_value_get_boolean (value);
break;
case PROP_PIXEL_ASPECT_RATIO:
clapper_sink->par_n = gst_value_get_fraction_numerator (value);
clapper_sink->par_d = gst_value_get_fraction_denominator (value);
break;
case PROP_KEEP_LAST_FRAME:
clapper_sink->keep_last_frame = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_clapper_gl_sink_navigation_send_event (GstNavigation * navigation,
GstStructure * structure)
{
GstClapperGLSink *sink = GST_CLAPPER_GL_SINK (navigation);
GstEvent *event;
GstPad *pad;
event = gst_event_new_navigation (structure);
pad = gst_pad_get_peer (GST_VIDEO_SINK_PAD (sink));
GST_TRACE_OBJECT (sink, "navigation event %" GST_PTR_FORMAT, structure);
if (GST_IS_PAD (pad) && GST_IS_EVENT (event)) {
if (!gst_pad_send_event (pad, gst_event_ref (event))) {
/* If upstream didn't handle the event we'll post a message with it
* for the application in case it wants to do something with it */
gst_element_post_message (GST_ELEMENT_CAST (sink),
gst_navigation_message_new_event (GST_OBJECT_CAST (sink), event));
}
gst_event_unref (event);
gst_object_unref (pad);
}
}
static void
gst_clapper_gl_sink_navigation_interface_init (GstNavigationInterface * iface)
{
iface->send_event = gst_clapper_gl_sink_navigation_send_event;
}
static gboolean
gst_clapper_gl_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
{
GstClapperGLSink *clapper_sink = GST_CLAPPER_GL_SINK (bsink);
GstBufferPool *pool = NULL;
GstStructure *config;
GstCaps *caps;
GstVideoInfo info;
guint size;
gboolean need_pool;
GstStructure *allocation_meta = NULL;
gint display_width, display_height;
if (!clapper_sink->display || !clapper_sink->context)
return FALSE;
gst_query_parse_allocation (query, &caps, &need_pool);
if (caps == NULL)
goto no_caps;
if (!gst_video_info_from_caps (&info, caps))
goto invalid_caps;
/* the normal size of a frame */
size = info.size;
if (need_pool) {
GST_DEBUG_OBJECT (clapper_sink, "create new pool");
pool = gst_gl_buffer_pool_new (clapper_sink->context);
config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_set_params (config, caps, size, 0, 0);
gst_buffer_pool_config_add_option (config,
GST_BUFFER_POOL_OPTION_GL_SYNC_META);
if (!gst_buffer_pool_set_config (pool, config)) {
gst_object_unref (pool);
goto config_failed;
}
}
/* we need at least 2 buffer because we hold on to the last one */
gst_query_add_allocation_pool (query, pool, size, 2, 0);
if (pool)
gst_object_unref (pool);
GST_OBJECT_LOCK (clapper_sink);
display_width = clapper_sink->display_width;
display_height = clapper_sink->display_height;
GST_OBJECT_UNLOCK (clapper_sink);
if (display_width != 0 && display_height != 0) {
GST_DEBUG_OBJECT (clapper_sink, "sending alloc query with size %dx%d",
display_width, display_height);
allocation_meta = gst_structure_new ("GstVideoOverlayCompositionMeta",
"width", G_TYPE_UINT, display_width,
"height", G_TYPE_UINT, display_height, NULL);
}
gst_query_add_allocation_meta (query,
GST_VIDEO_OVERLAY_COMPOSITION_META_API_TYPE, allocation_meta);
if (allocation_meta)
gst_structure_free (allocation_meta);
/* we also support various metadata */
gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, 0);
if (clapper_sink->context->gl_vtable->FenceSync)
gst_query_add_allocation_meta (query, GST_GL_SYNC_META_API_TYPE, 0);
return TRUE;
/* ERRORS */
no_caps:
{
GST_DEBUG_OBJECT (bsink, "no caps specified");
return FALSE;
}
invalid_caps:
{
GST_DEBUG_OBJECT (bsink, "invalid caps specified");
return FALSE;
}
config_failed:
{
GST_DEBUG_OBJECT (bsink, "failed setting config");
return FALSE;
}
}
static gboolean
gst_clapper_gl_sink_query (GstBaseSink * bsink, GstQuery * query)
{
GstClapperGLSink *clapper_sink = GST_CLAPPER_GL_SINK (bsink);
gboolean res = FALSE;
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_CONTEXT:
res = gst_gl_handle_context_query ((GstElement *) clapper_sink, query,
clapper_sink->display, clapper_sink->context, clapper_sink->gtk_context);
break;
default:
res = GST_BASE_SINK_CLASS (parent_class)->query (bsink, query);
break;
}
return res;
}
static gboolean
gst_clapper_gl_sink_start_on_main (GstBaseSink * bsink)
{
GstClapperGLSink *gst_sink = GST_CLAPPER_GL_SINK (bsink);
GstClapperGLSinkClass *klass = GST_CLAPPER_GL_SINK_GET_CLASS (bsink);
GtkWidget *toplevel;
GtkRoot *root;
if (gst_clapper_gl_sink_get_widget (gst_sink) == NULL)
return FALSE;
/* After this point, clapper_sink->widget will always be set */
root = gtk_widget_get_root (GTK_WIDGET (gst_sink->widget));
if (!GTK_IS_ROOT (root)) {
GtkWidget *parent = gtk_widget_get_parent (GTK_WIDGET (gst_sink->widget));
if (parent) {
GtkWidget *temp_parent;
while ((temp_parent = gtk_widget_get_parent (parent)))
parent = temp_parent;
}
toplevel = (parent) ? parent : GTK_WIDGET (gst_sink->widget);
/* sanity check */
g_assert (klass->window_title);
/* User did not add widget its own UI, let's popup a new GtkWindow to
* make gst-launch-1.0 work. */
gst_sink->window = gtk_window_new ();
gtk_window_set_default_size (GTK_WINDOW (gst_sink->window), 640, 480);
gtk_window_set_title (GTK_WINDOW (gst_sink->window), klass->window_title);
gtk_window_set_child (GTK_WINDOW (gst_sink->window), toplevel);
gst_sink->window_destroy_id = g_signal_connect (
GTK_WINDOW (gst_sink->window),
"destroy", G_CALLBACK (window_destroy_cb), gst_sink);
}
return TRUE;
}
static gboolean
gst_clapper_gl_sink_start (GstBaseSink * bsink)
{
GstClapperGLSink *clapper_sink = GST_CLAPPER_GL_SINK (bsink);
GtkClapperGLWidget *clapper_widget;
if (!(! !gst_gtk_invoke_on_main ((GThreadFunc) (GCallback)
gst_clapper_gl_sink_start_on_main, bsink)))
return FALSE;
/* After this point, clapper_sink->widget will always be set */
clapper_widget = GTK_CLAPPER_GL_WIDGET (clapper_sink->widget);
if (!gtk_clapper_gl_widget_init_winsys (clapper_widget)) {
GST_ELEMENT_ERROR (bsink, RESOURCE, NOT_FOUND, ("%s",
"Failed to initialize OpenGL with GTK"), (NULL));
return FALSE;
}
if (!clapper_sink->display)
clapper_sink->display = gtk_clapper_gl_widget_get_display (clapper_widget);
if (!clapper_sink->context)
clapper_sink->context = gtk_clapper_gl_widget_get_context (clapper_widget);
if (!clapper_sink->gtk_context)
clapper_sink->gtk_context = gtk_clapper_gl_widget_get_gtk_context (clapper_widget);
if (!clapper_sink->display || !clapper_sink->context || !clapper_sink->gtk_context) {
GST_ELEMENT_ERROR (bsink, RESOURCE, NOT_FOUND, ("%s",
"Failed to retrieve OpenGL context from GTK"), (NULL));
return FALSE;
}
gst_gl_element_propagate_display_context (GST_ELEMENT (bsink),
clapper_sink->display);
return TRUE;
}
static gboolean
gst_clapper_gl_sink_stop_on_main (GstBaseSink * bsink)
{
GstClapperGLSink *gst_sink = GST_CLAPPER_GL_SINK (bsink);
if (gst_sink->window) {
gtk_window_destroy (GTK_WINDOW (gst_sink->window));
gst_sink->window = NULL;
gst_sink->widget = NULL;
}
return TRUE;
}
static gboolean
gst_clapper_gl_sink_stop (GstBaseSink * bsink)
{
GstClapperGLSink *clapper_sink = GST_CLAPPER_GL_SINK (bsink);
if (clapper_sink->display) {
gst_object_unref (clapper_sink->display);
clapper_sink->display = NULL;
}
if (clapper_sink->context) {
gst_object_unref (clapper_sink->context);
clapper_sink->context = NULL;
}
if (clapper_sink->gtk_context) {
gst_object_unref (clapper_sink->gtk_context);
clapper_sink->gtk_context = NULL;
}
if (clapper_sink->window)
return ! !gst_gtk_invoke_on_main ((GThreadFunc) (GCallback)
gst_clapper_gl_sink_stop_on_main, bsink);
return TRUE;
}
static void
gst_gtk_window_show_all_and_unref (GtkWidget * window)
{
gtk_window_present (GTK_WINDOW (window));
g_object_unref (window);
}
static GstStateChangeReturn
gst_clapper_gl_sink_change_state (GstElement * element, GstStateChange transition)
{
GstClapperGLSink *clapper_sink = GST_CLAPPER_GL_SINK (element);
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
GST_DEBUG_OBJECT (element, "changing state: %s => %s",
gst_element_state_get_name (GST_STATE_TRANSITION_CURRENT (transition)),
gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition)));
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
if (ret == GST_STATE_CHANGE_FAILURE)
return ret;
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
GST_OBJECT_LOCK (clapper_sink);
clapper_sink->had_eos = FALSE;
if (clapper_sink->widget) {
GTK_CLAPPER_GL_WIDGET_LOCK (clapper_sink->widget);
clapper_sink->widget->ignore_buffers = FALSE;
GTK_CLAPPER_GL_WIDGET_UNLOCK (clapper_sink->widget);
}
GST_OBJECT_UNLOCK (clapper_sink);
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:{
GtkWindow *window = NULL;
GST_OBJECT_LOCK (clapper_sink);
if (clapper_sink->window)
window = g_object_ref (GTK_WINDOW (clapper_sink->window));
GST_OBJECT_UNLOCK (clapper_sink);
if (window) {
gst_gtk_invoke_on_main ((GThreadFunc) (GCallback)
gst_gtk_window_show_all_and_unref, window);
}
break;
}
case GST_STATE_CHANGE_READY_TO_NULL:
GST_OBJECT_LOCK (clapper_sink);
if (clapper_sink->widget) {
GTK_CLAPPER_GL_WIDGET_LOCK (clapper_sink->widget);
clapper_sink->widget->ignore_buffers =
!clapper_sink->had_eos || !clapper_sink->keep_last_frame;
GTK_CLAPPER_GL_WIDGET_UNLOCK (clapper_sink->widget);
}
GST_OBJECT_UNLOCK (clapper_sink);
/* Fall through to render black bg */
case GST_STATE_CHANGE_PAUSED_TO_READY:
GST_OBJECT_LOCK (clapper_sink);
if (clapper_sink->widget)
gtk_clapper_gl_widget_set_buffer (clapper_sink->widget, NULL);
GST_OBJECT_UNLOCK (clapper_sink);
break;
default:
break;
}
return ret;
}
static void
gst_clapper_gl_sink_get_times (GstBaseSink * bsink, GstBuffer * buf,
GstClockTime * start, GstClockTime * end)
{
GstClapperGLSink *clapper_sink = GST_CLAPPER_GL_SINK (bsink);
if (GST_BUFFER_TIMESTAMP_IS_VALID (buf)) {
*start = GST_BUFFER_TIMESTAMP (buf);
if (GST_BUFFER_DURATION_IS_VALID (buf))
*end = *start + GST_BUFFER_DURATION (buf);
else {
if (GST_VIDEO_INFO_FPS_N (&clapper_sink->v_info) > 0) {
*end = *start +
gst_util_uint64_scale_int (GST_SECOND,
GST_VIDEO_INFO_FPS_D (&clapper_sink->v_info),
GST_VIDEO_INFO_FPS_N (&clapper_sink->v_info));
}
}
}
}
static GstCaps *
gst_clapper_gl_sink_get_caps (GstBaseSink * bsink, GstCaps * filter)
{
GstCaps *tmp = NULL;
GstCaps *result = NULL;
tmp = gst_pad_get_pad_template_caps (GST_BASE_SINK_PAD (bsink));
if (filter) {
GST_DEBUG_OBJECT (bsink, "intersecting with filter caps %" GST_PTR_FORMAT,
filter);
result = gst_caps_intersect_full (filter, tmp, GST_CAPS_INTERSECT_FIRST);
gst_caps_unref (tmp);
} else {
result = tmp;
}
result = gst_gl_overlay_compositor_add_caps (result);
GST_DEBUG_OBJECT (bsink, "returning caps: %" GST_PTR_FORMAT, result);
return result;
}
static gboolean
gst_clapper_gl_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
{
GstClapperGLSink *clapper_sink = GST_CLAPPER_GL_SINK (bsink);
gboolean res = FALSE;
GST_DEBUG ("set caps with %" GST_PTR_FORMAT, caps);
if (!gst_video_info_from_caps (&clapper_sink->v_info, caps))
return FALSE;
GST_OBJECT_LOCK (clapper_sink);
if (clapper_sink->widget == NULL) {
GST_OBJECT_UNLOCK (clapper_sink);
GST_ELEMENT_ERROR (clapper_sink, RESOURCE, NOT_FOUND,
("%s", "Output widget was destroyed"), (NULL));
return FALSE;
}
if (!gtk_clapper_gl_widget_set_format (clapper_sink->widget, &clapper_sink->v_info)) {
GST_OBJECT_UNLOCK (clapper_sink);
return FALSE;
}
res = gtk_clapper_gl_widget_update_output_format (clapper_sink->widget, caps);
GST_OBJECT_UNLOCK (clapper_sink);
return res;
}
static GstFlowReturn
gst_clapper_gl_sink_wait_event (GstBaseSink * bsink, GstEvent * event)
{
GstClapperGLSink *clapper_sink = GST_CLAPPER_GL_SINK (bsink);
GstFlowReturn ret;
ret = GST_BASE_SINK_CLASS (parent_class)->wait_event (bsink, event);
switch (event->type) {
case GST_EVENT_EOS:
if (ret == GST_FLOW_OK) {
GST_OBJECT_LOCK (clapper_sink);
clapper_sink->had_eos = TRUE;
GST_OBJECT_UNLOCK (clapper_sink);
}
break;
default:
break;
}
return ret;
}
static GstFlowReturn
gst_clapper_gl_sink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
{
GstClapperGLSink *clapper_sink;
GST_TRACE ("rendering buffer:%p", buf);
clapper_sink = GST_CLAPPER_GL_SINK (vsink);
GST_OBJECT_LOCK (clapper_sink);
if (clapper_sink->widget == NULL) {
GST_OBJECT_UNLOCK (clapper_sink);
GST_ELEMENT_ERROR (clapper_sink, RESOURCE, NOT_FOUND,
("%s", "Output widget was destroyed"), (NULL));
return GST_FLOW_ERROR;
}
gtk_clapper_gl_widget_set_buffer (clapper_sink->widget, buf);
GST_OBJECT_UNLOCK (clapper_sink);
return GST_FLOW_OK;
}

View File

@@ -1,105 +0,0 @@
/*
* GStreamer
* Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
* Copyright (C) 2020 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_CLAPPER_GL_SINK_H__
#define __GST_CLAPPER_GL_SINK_H__
#include <gtk/gtk.h>
#include <gst/gst.h>
#include <gst/video/gstvideosink.h>
#include <gst/video/video.h>
#include <gst/gl/gl.h>
#include "gtkclapperglwidget.h"
#define GST_TYPE_CLAPPER_GL_SINK (gst_clapper_gl_sink_get_type())
#define GST_CLAPPER_GL_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CLAPPER_GL_SINK,GstClapperGLSink))
#define GST_CLAPPER_GL_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CLAPPER_GL_SINK,GstClapperGLClass))
#define GST_CLAPPER_GL_SINK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_CLAPPER_GL_SINK, GstClapperGLSinkClass))
#define GST_IS_CLAPPER_GL_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CLAPPER_GL_SINK))
#define GST_IS_CLAPPER_GL_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CLAPPER_GL_SINK))
#define GST_CLAPPER_GL_SINK_CAST(obj) ((GstClapperGLSink*)(obj))
G_BEGIN_DECLS
typedef struct _GstClapperGLSink GstClapperGLSink;
typedef struct _GstClapperGLSinkClass GstClapperGLSinkClass;
GType gst_clapper_gl_sink_get_type (void);
/**
* GstClapperGLSink:
*
* Opaque #GstClapperGLSink object
*/
struct _GstClapperGLSink
{
/* <private> */
GstVideoSink parent;
GstVideoInfo v_info;
GtkClapperGLWidget *widget;
gboolean had_eos;
/* properties */
gboolean force_aspect_ratio;
gint par_n, par_d;
gboolean keep_last_frame;
gboolean ignore_textures;
GtkWidget *window;
gulong widget_destroy_id;
gulong window_destroy_id;
GstGLDisplay *display;
GstGLContext *context;
GstGLContext *gtk_context;
GstGLUpload *upload;
GstBuffer *uploaded_buffer;
/* read/write with object lock */
gint display_width, display_height;
};
/**
* GstClapperGLSinkClass:
*
* The #GstClapperGLSinkClass struct only contains private data
*/
struct _GstClapperGLSinkClass
{
GstVideoSinkClass object_class;
/* metadata */
const gchar *window_title;
/* virtuals */
GtkWidget* (*create_widget) (void);
};
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GstClapperGLSink, gst_object_unref)
G_END_DECLS
#endif /* __GST_CLAPPER_GL_SINK_H__ */

View File

@@ -1,103 +0,0 @@
/*
* GStreamer
* Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
* Copyright (C) 2015 Thibault Saunier <tsaunier@gnome.org>
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/* FIXME: remove these once their headers are public in gstreamer:
* https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/804
*/
#include "gstclapperglutils.h"
static const gfloat identity_matrix[] = {
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0,
};
static const gfloat from_ndc_matrix[] = {
0.5, 0.0, 0.0, 0.0,
0.0, 0.5, 0.0, 0.0,
0.0, 0.0, 0.5, 0.0,
0.5, 0.5, 0.5, 1.0,
};
static const gfloat to_ndc_matrix[] = {
2.0, 0.0, 0.0, 0.0,
0.0, 2.0, 0.0, 0.0,
0.0, 0.0, 2.0, 0.0,
-1.0, -1.0, -1.0, 1.0,
};
/* multiplies two 4x4 matrices, @a X @b, and stores the result in @result
* https://en.wikipedia.org/wiki/Matrix_multiplication
*/
static void
gst_gl_multiply_matrix4 (const gfloat * a, const gfloat * b, gfloat * result)
{
int i, j, k;
gfloat tmp[16] = { 0.0f };
if (!a || !b || !result)
return;
for (i = 0; i < 4; i++) { /* column */
for (j = 0; j < 4; j++) { /* row */
for (k = 0; k < 4; k++) {
tmp[j + (i * 4)] += a[k + (i * 4)] * b[j + (k * 4)];
}
}
}
for (i = 0; i < 16; i++)
result[i] = tmp[i];
}
/*
* gst_clapper_gl_get_affine_transformation_meta_as_ndc:
* @meta: (nullable): a #GstVideoAffineTransformationMeta
* @matrix: (out): result of the 4x4 matrix
*
* Retrieves the stored 4x4 affine transformation matrix stored in @meta in
* NDC coordinates. if @meta is NULL, an identity matrix is returned.
*
* NDC is a left-handed coordinate system
* - x - [-1, 1] - +ve X moves right
* - y - [-1, 1] - +ve Y moves up
* - z - [-1, 1] - +ve Z moves into
*/
void
gst_clapper_gl_get_affine_transformation_meta_as_ndc (GstVideoAffineTransformationMeta *
meta, gfloat * matrix)
{
if (!meta) {
int i;
for (i = 0; i < 16; i++) {
matrix[i] = identity_matrix[i];
}
} else {
float tmp[16];
/* change of basis multiplications */
gst_gl_multiply_matrix4 (from_ndc_matrix, meta->matrix, tmp);
gst_gl_multiply_matrix4 (tmp, to_ndc_matrix, matrix);
}
}

View File

@@ -1,29 +0,0 @@
/*
* GStreamer
* Copyright (C) 2016 Matthew Waters <matthew@centricular.com>
* Copyright (C) 2021 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_CLAPPER_GL_UTILS_H__
#define __GST_CLAPPER_GL_UTILS_H__
#include <gst/video/gstvideoaffinetransformationmeta.h>
void gst_clapper_gl_get_affine_transformation_meta_as_ndc (GstVideoAffineTransformationMeta *meta, gfloat *matrix);
#endif /* __GST_CLAPPER_GL_UTILS_H__ */

View File

@@ -1,95 +0,0 @@
/*
* GStreamer
* Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
* Copyright (C) 2015 Thibault Saunier <tsaunier@gnome.org>
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <gst/gst.h>
#include "gstgtkutils.h"
struct invoke_context
{
GThreadFunc func;
gpointer data;
GMutex lock;
GCond cond;
gboolean fired;
gpointer res;
};
static gboolean
gst_gtk_invoke_func (struct invoke_context *info)
{
g_mutex_lock (&info->lock);
info->res = info->func (info->data);
info->fired = TRUE;
g_cond_signal (&info->cond);
g_mutex_unlock (&info->lock);
return G_SOURCE_REMOVE;
}
gpointer
gst_gtk_invoke_on_main (GThreadFunc func, gpointer data)
{
GMainContext *main_context = g_main_context_default ();
struct invoke_context info;
g_mutex_init (&info.lock);
g_cond_init (&info.cond);
info.fired = FALSE;
info.func = func;
info.data = data;
g_main_context_invoke (main_context, (GSourceFunc) gst_gtk_invoke_func,
&info);
g_mutex_lock (&info.lock);
while (!info.fired)
g_cond_wait (&info.cond, &info.lock);
g_mutex_unlock (&info.lock);
g_mutex_clear (&info.lock);
g_cond_clear (&info.cond);
return info.res;
}
void
gst_gtk_install_shared_properties (GObjectClass *gobject_class)
{
g_object_class_install_property (gobject_class, PROP_FORCE_ASPECT_RATIO,
g_param_spec_boolean ("force-aspect-ratio",
"Force aspect ratio",
"When enabled, scaling will respect original aspect ratio",
DEFAULT_FORCE_ASPECT_RATIO,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_PIXEL_ASPECT_RATIO,
gst_param_spec_fraction ("pixel-aspect-ratio", "Pixel Aspect Ratio",
"The pixel aspect ratio of the device", DEFAULT_PAR_N, DEFAULT_PAR_D,
G_MAXINT, 1, 1, 1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_KEEP_LAST_FRAME,
g_param_spec_boolean ("keep-last-frame",
"Keep last frame",
"Keep showing last video frame after playback instead of black screen",
DEFAULT_KEEP_LAST_FRAME,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}

View File

@@ -1,46 +0,0 @@
/*
* GStreamer
* Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
* Copyright (C) 2015 Thibault Saunier <tsaunier@gnome.org>
*
* 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_GTK_UTILS_H__
#define __GST_GTK_UTILS_H__
#define DEFAULT_FORCE_ASPECT_RATIO TRUE
#define DEFAULT_PAR_N 0
#define DEFAULT_PAR_D 1
#define DEFAULT_KEEP_LAST_FRAME FALSE
#include <glib.h>
#include <glib-object.h>
enum
{
PROP_0,
PROP_WIDGET,
PROP_FORCE_ASPECT_RATIO,
PROP_PIXEL_ASPECT_RATIO,
PROP_KEEP_LAST_FRAME
};
gpointer gst_gtk_invoke_on_main (GThreadFunc func, gpointer data);
void gst_gtk_install_shared_properties (GObjectClass *gobject_class);
#endif /* __GST_GTK_UTILS_H__ */

File diff suppressed because it is too large Load Diff

View File

@@ -1,113 +0,0 @@
/*
* GStreamer
* Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
* Copyright (C) 2020 Rafał Dzięgiel <rafostar.github@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 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., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GTK_CLAPPER_GL_WIDGET_H__
#define __GTK_CLAPPER_GL_WIDGET_H__
#include <gtk/gtk.h>
#include <gst/gst.h>
#include <gst/video/video.h>
#include <gst/gl/gl.h>
G_BEGIN_DECLS
GType gtk_clapper_gl_widget_get_type (void);
#define GTK_TYPE_CLAPPER_GL_WIDGET (gtk_clapper_gl_widget_get_type())
#define GTK_CLAPPER_GL_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GTK_TYPE_CLAPPER_GL_WIDGET,GtkClapperGLWidget))
#define GTK_CLAPPER_GL_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GTK_TYPE_CLAPPER_GL_WIDGET,GtkClapperGLWidgetClass))
#define GTK_IS_CLAPPER_GL_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GTK_TYPE_CLAPPER_GL_WIDGET))
#define GTK_IS_CLAPPER_GL_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GTK_TYPE_CLAPPER_GL_WIDGET))
#define GTK_CLAPPER_GL_WIDGET_CAST(obj) ((GtkClapperGLWidget*)(obj))
#define GTK_CLAPPER_GL_WIDGET_LOCK(w) g_mutex_lock(&((GtkClapperGLWidget*)(w))->lock)
#define GTK_CLAPPER_GL_WIDGET_UNLOCK(w) g_mutex_unlock(&((GtkClapperGLWidget*)(w))->lock)
typedef struct _GtkClapperGLWidget GtkClapperGLWidget;
typedef struct _GtkClapperGLWidgetClass GtkClapperGLWidgetClass;
typedef struct _GtkClapperGLWidgetPrivate GtkClapperGLWidgetPrivate;
struct _GtkClapperGLWidget
{
/* <private> */
GtkGLArea parent;
GtkClapperGLWidgetPrivate *priv;
/* properties */
gboolean force_aspect_ratio;
gint par_n, par_d;
gboolean keep_last_frame;
gint display_width;
gint display_height;
/* Widget dimensions */
gint scaled_width;
gint scaled_height;
/* Position coords */
gdouble last_pos_x;
gdouble last_pos_y;
gboolean negotiated;
gboolean ignore_buffers;
GstBuffer *pending_buffer;
GstBuffer *buffer;
GstVideoInfo v_info;
/* resize */
gboolean pending_resize;
GstVideoInfo pending_v_info;
guint display_ratio_num;
guint display_ratio_den;
/*< private >*/
GMutex lock;
GWeakRef element;
/* event controllers */
GtkEventController *key_controller;
GtkEventController *motion_controller;
GtkGesture *click_gesture;
/* Pending draw idles callback */
guint draw_id;
};
struct _GtkClapperGLWidgetClass
{
GtkGLAreaClass parent_class;
};
/* API */
gboolean gtk_clapper_gl_widget_set_format (GtkClapperGLWidget * widget, GstVideoInfo * v_info);
void gtk_clapper_gl_widget_set_buffer (GtkClapperGLWidget * widget, GstBuffer * buffer);
void gtk_clapper_gl_widget_set_element (GtkClapperGLWidget * widget, GstElement * element);
GtkWidget * gtk_clapper_gl_widget_new (void);
gboolean gtk_clapper_gl_widget_init_winsys (GtkClapperGLWidget * widget);
GstGLDisplay * gtk_clapper_gl_widget_get_display (GtkClapperGLWidget * widget);
GstGLContext * gtk_clapper_gl_widget_get_context (GtkClapperGLWidget * widget);
GstGLContext * gtk_clapper_gl_widget_get_gtk_context (GtkClapperGLWidget * widget);
gboolean gtk_clapper_gl_widget_update_output_format (GtkClapperGLWidget * widget, GstCaps * caps);
G_END_DECLS
#endif /* __GTK_CLAPPER_GL_WIDGET_H__ */

View File

@@ -1,120 +0,0 @@
gstclapper_sources = [
'gstclapper.c',
'gstclapper-signal-dispatcher.c',
'gstclapper-video-renderer.c',
'gstclapper-media-info.c',
'gstclapper-g-main-context-signal-dispatcher.c',
'gstclapper-video-overlay-video-renderer.c',
'gstclapper-visualization.c',
'gstclapper-mpris.c',
'gstclapper-gtk4-plugin.c',
'gtk4/gstclapperglsink.c',
'gtk4/gstgtkutils.c',
'gtk4/gtkclapperglwidget.c',
'gtk4/gstclapperglutils.c',
]
gstclapper_headers = [
'clapper.h',
'clapper-prelude.h',
'gstclapper.h',
'gstclapper-types.h',
'gstclapper-signal-dispatcher.h',
'gstclapper-video-renderer.h',
'gstclapper-media-info.h',
'gstclapper-g-main-context-signal-dispatcher.h',
'gstclapper-video-overlay-video-renderer.h',
'gstclapper-visualization.h',
'gstclapper-mpris.h',
'gstclapper-gtk4-plugin.h',
]
gstclapper_defines = [
'-DHAVE_CONFIG_H',
'-DBUILDING_GST_CLAPPER',
'-DGST_USE_UNSTABLE_API',
'-DHAVE_GTK_GL',
]
gtk_deps = [gstgl_dep, gstglproto_dep]
have_gtk_gl_windowing = false
gtk4_dep = dependency('gtk4', required: true)
if not gtk4_dep.version().version_compare('>=4.0.0')
error('GTK4 version on this system is too old')
endif
if not gir.found()
error('Cannot build lib without GIR support')
endif
if gst_gl_have_window_x11 and (gst_gl_have_platform_egl or gst_gl_have_platform_glx)
gtk_x11_dep = dependency('gtk4-x11', required: false)
if gtk_x11_dep.found()
gtk_deps += gtk_x11_dep
if gst_gl_have_platform_glx
gtk_deps += gstglx11_dep
endif
have_gtk_gl_windowing = true
endif
endif
if gst_gl_have_window_wayland and gst_gl_have_platform_egl
gtk_wayland_dep = dependency('gtk4-wayland', required: false)
if gtk_wayland_dep.found()
gtk_deps += [gtk_wayland_dep, gstglwayland_dep]
have_gtk_gl_windowing = true
endif
endif
if gst_gl_have_platform_egl
gtk_deps += gstglegl_dep
endif
if not have_gtk_gl_windowing
error('GTK4 widget requires GL windowing')
endif
gstclapper_mpris_gdbus = gnome.gdbus_codegen('gstclapper-mpris-gdbus',
sources: '../../../data/gstclapper-mpris-gdbus.xml',
interface_prefix: 'org.mpris.',
namespace: 'GstClapperMpris'
)
gstclapper_deps = [
gtk4_dep, glib_dep, gio_dep,
gstbase_dep, gstvideo_dep, gstaudio_dep,
gsttag_dep, gstpbutils_dep, libm
] + gtk_deps
if os_unix
gstclapper_deps += giounix_dep
else
gstclapper_deps += giowin_dep
endif
gstclapper = library('gstclapper-' + api_version,
gstclapper_sources + gstclapper_mpris_gdbus,
c_args: gstclapper_defines,
link_args: noseh_link_args,
include_directories: [configinc, libsinc],
version: libversion,
install: true,
install_dir: pkglibdir,
dependencies: gstclapper_deps,
)
clapper_gir = gnome.generate_gir(gstclapper,
sources: gstclapper_sources + gstclapper_headers,
namespace: 'GstClapper',
nsversion: api_version,
identifier_prefix: 'Gst',
symbol_prefix: 'gst',
export_packages: 'gstreamer-clapper-1.0',
includes: ['Gst-1.0', 'GstPbutils-1.0', 'GstBase-1.0', 'GstVideo-1.0',
'GstAudio-1.0', 'GstTag-1.0'],
install: true,
install_dir_typelib: join_paths(pkglibdir, 'girepository-1.0'),
extra_args: gir_init_section + ['-DGST_USE_UNSTABLE_API'],
dependencies: [gstbase_dep, gstvideo_dep, gstaudio_dep,
gsttag_dep, gstpbutils_dep]
)

View File

@@ -1,5 +0,0 @@
if get_option('lib')
subdir('clapper')
endif
subdir('plugin')

View File

@@ -1,83 +0,0 @@
gst_clapper_gl_ch_dep = dependency('', required: false)
build_gl_ch = (
not get_option('glimporter').disabled()
or not get_option('gluploader').disabled()
)
gl_support_required = (
get_option('glimporter').enabled()
or get_option('gluploader').enabled()
)
gst_plugin_gl_ch_deps = [gst_clapper_sink_dep, gstgl_dep, gstglproto_dep]
have_gtk_gl_windowing = false
if gst_gl_have_window_x11 and (gst_gl_have_platform_egl or gst_gl_have_platform_glx)
gtk_x11_dep = dependency('gtk4-x11', required: false)
if gtk_x11_dep.found()
gst_plugin_gl_ch_deps += gtk_x11_dep
if gst_gl_have_platform_glx
gst_plugin_gl_ch_deps += gstglx11_dep
endif
have_gtk_gl_windowing = true
endif
endif
if gst_gl_have_window_wayland and gst_gl_have_platform_egl
gtk_wayland_dep = dependency('gtk4-wayland', required: false)
if gtk_wayland_dep.found()
gst_plugin_gl_ch_deps += [gtk_wayland_dep, gstglwayland_dep]
have_gtk_gl_windowing = true
endif
endif
if gst_gl_have_window_win32 and (gst_gl_have_platform_egl or gst_gl_have_platform_wgl)
gtk_win32_dep = dependency('gtk4-win32', required: false)
if gtk_win32_dep.found()
gst_plugin_gl_ch_deps += gtk_win32_dep
have_gtk_gl_windowing = true
endif
endif
if gst_gl_have_window_cocoa and gst_gl_have_platform_cgl
gtk_macos_dep = dependency('gtk4-macos', required: false)
if gtk_macos_dep.found()
gst_plugin_gl_ch_deps += gtk_macos_dep
have_gtk_gl_windowing = true
endif
endif
if not have_gtk_gl_windowing
if gl_support_required
error('GL-based importer was enabled, but support for current GL windowing is missing')
endif
build_gl_ch = false
endif
if gst_gl_have_platform_egl
gst_plugin_gl_ch_deps += gstglegl_dep
endif
foreach dep : gst_plugin_gl_ch_deps
if not dep.found()
if gl_support_required
error('GL-based importer was enabled, but required dependencies were not found')
endif
build_gl_ch = false
endif
endforeach
if build_gl_ch
gst_clapper_gl_ch_dep = declare_dependency(
link_with: library('gstclapperglcontexthandler',
'gstclapperglcontexthandler.c',
c_args: gst_clapper_plugin_args,
include_directories: configinc,
dependencies: gst_plugin_gl_ch_deps,
version: libversion,
install: true,
),
include_directories: configinc,
dependencies: gst_plugin_gl_ch_deps,
)
endif

View File

@@ -1,274 +0,0 @@
glib_req = '>= 2.68.0'
gst_req = '>= 1.20.0'
api_version = '1.0'
libversion = meson.project_version()
cc = meson.get_compiler('c')
cxx = meson.get_compiler('cpp')
cdata = configuration_data()
os_unix = host_machine.system() != 'windows'
if cc.get_id() == 'msvc'
msvc_args = [
# Ignore several spurious warnings for things gstreamer does very commonly
# If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
# If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
# NOTE: Only add warnings here if you are sure they're spurious
'/wd4018', # implicit signed/unsigned conversion
'/wd4146', # unary minus on unsigned (beware INT_MIN)
'/wd4244', # lossy type conversion (e.g. double -> int)
'/wd4305', # truncating type conversion (e.g. double -> float)
cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8
# Enable some warnings on MSVC to match GCC/Clang behaviour
'/w14062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled
'/w14101', # 'identifier' : unreferenced local variable
'/w14189', # 'identifier' : local variable is initialized but not referenced
]
add_project_arguments(msvc_args, language: ['c', 'cpp'])
noseh_link_args = ['/SAFESEH:NO']
else
if cxx.has_argument('-Wno-non-virtual-dtor')
add_project_arguments('-Wno-non-virtual-dtor', language: 'cpp')
endif
noseh_link_args = []
endif
if cc.has_link_argument('-Wl,-Bsymbolic-functions')
add_project_link_arguments('-Wl,-Bsymbolic-functions', language: 'c')
endif
# Symbol visibility
if cc.get_id() == 'msvc'
export_define = '__declspec(dllexport) extern'
else
export_define = 'extern'
endif
# Passing this through the command line would be too messy
cdata.set('GST_API_EXPORT', export_define)
# Disable strict aliasing
if cc.has_argument('-fno-strict-aliasing')
add_project_arguments('-fno-strict-aliasing', language: 'c')
endif
if cxx.has_argument('-fno-strict-aliasing')
add_project_arguments('-fno-strict-aliasing', language: 'cpp')
endif
if not get_option('deprecated-glib-api')
message('Disabling deprecated GLib API')
add_project_arguments('-DG_DISABLE_DEPRECATED', language: 'c')
endif
if not get_option('devel-checks')
message('Disabling GLib cast checks')
add_project_arguments('-DG_DISABLE_CAST_CHECKS', language: 'c')
message('Disabling GLib asserts')
add_project_arguments('-DG_DISABLE_ASSERT', language: 'c')
message('Disabling GLib checks')
add_project_arguments('-DG_DISABLE_CHECKS', language: 'c')
endif
check_headers = [
['HAVE_DLFCN_H', 'dlfcn.h'],
['HAVE_FCNTL_H', 'fcntl.h'],
['HAVE_INTTYPES_H', 'inttypes.h'],
['HAVE_MEMORY_H', 'memory.h'],
['HAVE_NETINET_IN_H', 'netinet/in.h'],
['HAVE_NETINET_IP_H', 'netinet/ip.h'],
['HAVE_NETINET_TCP_H', 'netinet/tcp.h'],
['HAVE_PTHREAD_H', 'pthread.h'],
['HAVE_STDINT_H', 'stdint.h'],
['HAVE_STDLIB_H', 'stdlib.h'],
['HAVE_STRINGS_H', 'strings.h'],
['HAVE_STRING_H', 'string.h'],
['HAVE_SYS_PARAM_H', 'sys/param.h'],
['HAVE_SYS_SOCKET_H', 'sys/socket.h'],
['HAVE_SYS_STAT_H', 'sys/stat.h'],
['HAVE_SYS_TIME_H', 'sys/time.h'],
['HAVE_SYS_TYPES_H', 'sys/types.h'],
['HAVE_SYS_UTSNAME_H', 'sys/utsname.h'],
['HAVE_UNISTD_H', 'unistd.h'],
]
foreach h : check_headers
if cc.has_header(h.get(1))
cdata.set(h.get(0), 1)
endif
endforeach
check_functions = [
['HAVE_DCGETTEXT', 'dcgettext'],
['HAVE_GETPAGESIZE', 'getpagesize'],
['HAVE_GMTIME_R', 'gmtime_r'],
['HAVE_MEMFD_CREATE', 'memfd_create'],
['HAVE_MMAP', 'mmap'],
['HAVE_PIPE2', 'pipe2'],
['HAVE_GETRUSAGE', 'getrusage', '#include<sys/resource.h>'],
]
foreach f : check_functions
prefix = ''
if f.length() == 3
prefix = f.get(2)
endif
if cc.has_function(f.get(1), prefix: prefix)
cdata.set(f.get(0), 1)
endif
endforeach
cdata.set('SIZEOF_CHAR', cc.sizeof('char'))
cdata.set('SIZEOF_INT', cc.sizeof('int'))
cdata.set('SIZEOF_LONG', cc.sizeof('long'))
cdata.set('SIZEOF_SHORT', cc.sizeof('short'))
cdata.set('SIZEOF_VOIDP', cc.sizeof('void*'))
cdata.set_quoted('VERSION', libversion)
cdata.set_quoted('PACKAGE', 'clapper')
cdata.set_quoted('PACKAGE_VERSION', libversion)
cdata.set_quoted('PACKAGE_BUGREPORT', 'https://github.com/Rafostar/clapper/issues/new')
cdata.set_quoted('PACKAGE_NAME', 'GStreamer Clapper Libs')
cdata.set_quoted('GST_API_VERSION', api_version)
cdata.set_quoted('GST_LICENSE', 'LGPL')
cdata.set_quoted('LIBDIR', pkglibdir)
cdata.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
warning_flags = [
'-Wmissing-declarations',
'-Wredundant-decls',
'-Wwrite-strings',
'-Wformat',
'-Wformat-security',
'-Winit-self',
'-Wmissing-include-dirs',
'-Waddress',
'-Wno-multichar',
'-Wvla',
'-Wpointer-arith',
]
warning_c_flags = [
'-Wmissing-prototypes',
'-Wdeclaration-after-statement',
'-Wold-style-definition',
]
warning_cxx_flags = [
'-Wformat-nonliteral',
]
foreach extra_arg : warning_c_flags
if cc.has_argument (extra_arg)
add_project_arguments([extra_arg], language: 'c')
endif
endforeach
foreach extra_arg : warning_cxx_flags
if cxx.has_argument (extra_arg)
add_project_arguments([extra_arg], language: 'cpp')
endif
endforeach
foreach extra_arg : warning_flags
if cc.has_argument (extra_arg)
add_project_arguments([extra_arg], language: 'c')
endif
if cxx.has_argument (extra_arg)
add_project_arguments([extra_arg], language: 'cpp')
endif
endforeach
cdata.set_quoted('GST_PACKAGE_NAME', 'gst-plugin-clapper')
cdata.set_quoted('GST_PACKAGE_ORIGIN', 'https://github.com/Rafostar/clapper')
# Mandatory GST deps
gst_dep = dependency('gstreamer-1.0', version: gst_req,
fallback: ['gstreamer', 'gst_dep'])
gstbase_dep = dependency('gstreamer-base-1.0', version: gst_req,
fallback: ['gstreamer', 'gst_base_dep'])
gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version: gst_req,
fallback: ['gst-plugins-base', 'pbutils_dep'])
gstaudio_dep = dependency('gstreamer-audio-1.0', version: gst_req,
fallback: ['gst-plugins-base', 'audio_dep'])
gsttag_dep = dependency('gstreamer-tag-1.0', version: gst_req,
fallback: ['gst-plugins-base', 'tag_dep'])
gstvideo_dep = dependency('gstreamer-video-1.0', version: gst_req,
fallback: ['gst-plugins-base', 'video_dep'])
# GStreamer OpenGL
gstgl_dep = dependency('gstreamer-gl-1.0', version: gst_req,
fallback: ['gst-plugins-base', 'gstgl_dep'], required: true)
gstglx11_dep = dependency('', required: false)
gstglwayland_dep = dependency('', required: false)
gstglegl_dep = dependency('', required: false)
gst_gl_apis = gstgl_dep.get_pkgconfig_variable('gl_apis')
gst_gl_winsys = gstgl_dep.get_pkgconfig_variable('gl_winsys')
gst_gl_platforms = gstgl_dep.get_pkgconfig_variable('gl_platforms')
message('GStreamer OpenGL window systems: @0@'.format(gst_gl_winsys))
message('GStreamer OpenGL platforms: @0@'.format(gst_gl_platforms))
message('GStreamer OpenGL apis: @0@'.format(gst_gl_apis))
foreach ws : ['x11', 'wayland', 'android', 'cocoa', 'eagl', 'win32', 'dispmanx', 'viv_fb']
set_variable('gst_gl_have_window_@0@'.format(ws), gst_gl_winsys.contains(ws))
endforeach
foreach p : ['glx', 'egl', 'cgl', 'eagl', 'wgl']
set_variable('gst_gl_have_platform_@0@'.format(p), gst_gl_platforms.contains(p))
endforeach
foreach api : ['gl', 'gles2']
set_variable('gst_gl_have_api_@0@'.format(api), gst_gl_apis.contains(api))
endforeach
gstglproto_dep = dependency('gstreamer-gl-prototypes-1.0', version: gst_req,
fallback: ['gst-plugins-base', 'gstglproto_dep'], required: true)
if gst_gl_have_window_x11
gstglx11_dep = dependency('gstreamer-gl-x11-1.0', version: gst_req,
fallback: ['gst-plugins-base', 'gstglx11_dep'], required: true)
endif
if gst_gl_have_window_wayland
gstglwayland_dep = dependency('gstreamer-gl-wayland-1.0', version: gst_req,
fallback: ['gst-plugins-base', 'gstglwayland_dep'], required: true)
endif
if gst_gl_have_platform_egl
gstglegl_dep = dependency('gstreamer-gl-egl-1.0', version: gst_req,
fallback: ['gst-plugins-base', 'gstglegl_dep'], required: true)
endif
libm = cc.find_library('m', required: false)
glib_dep = dependency('glib-2.0', version: glib_req, fallback: ['glib', 'libglib_dep'])
gmodule_dep = dependency('gmodule-2.0', fallback: ['glib', 'libgmodule_dep'])
gio_dep = dependency('gio-2.0', fallback: ['glib', 'libgio_dep'])
if os_unix
giounix_dep = dependency('gio-unix-2.0', version: glib_req, fallback: ['glib', 'libgio_dep'])
else
giowin_dep = dependency('gio-windows-2.0', version: glib_req, fallback : ['glib', 'libgio_dep'])
endif
cdata.set('DISABLE_ORC', 1)
cdata.set('GST_ENABLE_EXTRA_CHECKS', get_option('devel-checks'))
configinc = include_directories('.')
libsinc = include_directories('gst')
gir = find_program('g-ir-scanner', required: false)
gir_init_section = ['--add-init-section=extern void gst_init(gint*,gchar**);' + \
'g_setenv("GST_REGISTRY_1.0", "@0@", TRUE);'.format(meson.current_build_dir() + '/gir_empty_registry.reg') + \
'g_setenv("GST_PLUGIN_PATH_1_0", "", TRUE);' + \
'g_setenv("GST_PLUGIN_SYSTEM_PATH_1_0", "", TRUE);' + \
'gst_init(NULL,NULL);', '--quiet'
]
gst_clapper_plugin_libdir = join_paths(get_option('prefix'), libdir, 'clapper-@0@'.format(api_version), 'gst', 'plugin')
gst_clapper_importers_libdir = join_paths(gst_clapper_plugin_libdir, 'importers')
cdata.set_quoted('CLAPPER_SINK_IMPORTER_PATH', gst_clapper_importers_libdir)
subdir('gst')
configure_file(output: 'config.h', configuration: cdata)

View File

@@ -1,39 +1,140 @@
project('com.github.rafostar.Clapper', 'c', 'cpp',
project('clapper', 'c',
version: '0.5.2',
meson_version: '>= 0.50.0',
license: 'GPL-3.0-or-later',
meson_version: '>= 0.64.0',
license: 'LGPL-2.1-or-later AND GPL-3.0-or-later', # LGPL-2.1+ for libs and gst-plugin, GPL-3.0+ for app
default_options: [
'warning_level=1',
'buildtype=debugoptimized'
]
'buildtype=debugoptimized',
],
)
glib_req = '>= 2.76.0'
gst_req = '>= 1.20.0'
gtk4_req = '>= 4.10.0'
clapper_version = meson.project_version().split('-')[0]
version_array = clapper_version.split('.')
clapper_version_suffix = '-' + version_array[0] + '.0'
clapper_api_name = meson.project_name() + clapper_version_suffix
gnome = import('gnome')
pkgconfig = import('pkgconfig')
i18n = import('i18n')
python = import('python')
bindir = join_paths(get_option('prefix'), get_option('bindir'))
libdir = join_paths(get_option('prefix'), get_option('libdir'))
datadir = join_paths(get_option('prefix'), get_option('datadir'))
prefix = get_option('prefix')
bindir = get_option('bindir')
datadir = get_option('datadir')
libdir = get_option('libdir')
localedir = get_option('localedir')
includedir = get_option('includedir')
optimization = get_option('optimization')
pkglibdir = join_paths(libdir, meson.project_name())
pkgdatadir = join_paths(datadir, meson.project_name())
clapper_libdir = join_paths(prefix, libdir, clapper_api_name)
build_optimized = optimization in ['2', '3', 's']
subdir('lib')
gst_dep = dependency('gstreamer-1.0',
version: gst_req,
required: false,
)
gst_base_dep = dependency('gstreamer-base-1.0',
version: gst_req,
required: false,
)
gst_video_dep = dependency('gstreamer-video-1.0',
version: gst_req,
required: false,
)
gst_audio_dep = dependency('gstreamer-audio-1.0',
version: gst_req,
required: false,
)
gst_pbutils_dep = dependency('gstreamer-pbutils-1.0',
version: gst_req,
required: false,
)
gst_tag_dep = dependency('gstreamer-tag-1.0',
version: gst_req,
required: false,
)
glib_dep = dependency('glib-2.0',
version: glib_req,
required: false,
)
gobject_dep = dependency('gobject-2.0',
version: glib_req,
required: false,
)
gio_dep = dependency('gio-2.0',
version: glib_req,
required: false,
)
gmodule_dep = dependency('gmodule-2.0',
version: glib_req,
required: false,
)
gtk4_dep = dependency('gtk4',
version: gtk4_req,
required: false,
)
if get_option('player')
subdir('bin')
subdir('data')
subdir('po')
cc = meson.get_compiler('c')
libm = cc.find_library('m', required: false)
install_subdir('src', install_dir: pkgdatadir)
install_subdir('extras', install_dir: pkgdatadir)
install_subdir('css', install_dir: pkgdatadir)
install_subdir('ui', install_dir: pkgdatadir)
warning_flags = [
'-Wmissing-declarations',
'-Wredundant-decls',
'-Wwrite-strings',
'-Wformat',
'-Wformat-security',
'-Winit-self',
'-Wmissing-include-dirs',
'-Waddress',
'-Wno-multichar',
'-Wvla',
'-Wpointer-arith',
'-Wmissing-prototypes',
'-Wdeclaration-after-statement',
'-Wold-style-definition',
'-Wsign-compare',
]
python_bin = python.find_installation('python3')
if not python_bin.found()
error('No valid python3 binary found')
foreach extra_arg : warning_flags
if cc.has_argument (extra_arg)
add_project_arguments([extra_arg], language: 'c')
endif
meson.add_install_script('build-aux/meson/postinstall.py')
endforeach
if build_optimized
message('Disabling GLib cast checks')
add_project_arguments('-DG_DISABLE_CAST_CHECKS', language: 'c')
message('Disabling GLib asserts')
add_project_arguments('-DG_DISABLE_ASSERT', language: 'c')
message('Disabling GLib checks')
add_project_arguments('-DG_DISABLE_CHECKS', language: 'c')
endif
subdir('src')
subdir('doc')
summary({
'prefix': prefix,
'bindir': bindir,
'datadir': datadir,
'libdir': libdir,
'localedir': localedir,
'includedir': includedir,
'optimization': optimization,
}, section: 'Directories')
summary('clapper', build_clapper ? 'Yes' : 'No', section: 'Build')
summary('gst-plugin', build_gst_plugin ? 'Yes' : 'No', section: 'Build')
summary('introspection', build_gir ? 'Yes' : 'No', section: 'Build')
summary('vapi', build_vapi ? 'Yes' : 'No', section: 'Build')
summary('doc', build_doc ? 'Yes' : 'No', section: 'Build')
foreach name : clapper_possible_features
summary(name, clapper_available_features.contains(name) ? 'Yes' : 'No', section: 'Features')
endforeach

View File

@@ -1,19 +1,48 @@
option('player',
type: 'boolean',
value: true,
description: 'Build Clapper player'
)
option('lib',
type: 'boolean',
value: true,
description: 'Build GstClapper lib'
# Build
option('clapper',
type: 'feature',
value: 'auto',
description: 'Build Clapper library'
)
option('gst-plugin',
type: 'feature',
value: 'auto',
description: 'Build GStreamer plugin (includes GTK video sink element)'
)
option('introspection',
type: 'feature',
value: 'auto',
description: 'Build GObject Introspection data'
)
option('vapi',
type: 'feature',
value: 'auto',
description: 'Build Vala bindings'
)
option('doc',
type: 'boolean',
value: false,
description: 'Build documentation'
)
# Features
option('discoverer',
type: 'feature',
value: 'auto',
description: 'Build Clapper Discoverer feature'
)
option('mpris',
type: 'feature',
value: 'auto',
description: 'Build Clapper MPRIS feature'
)
option('server',
type: 'feature',
value: 'auto',
description: 'Build Clapper Server feature'
)
# GStreamer plugin options
option('glimporter',
type: 'feature',
value: 'auto',
@@ -29,14 +58,3 @@ option('rawimporter',
value: 'auto',
description: 'Build RAW system memory importer for clappersink'
)
option('devel-checks',
type: 'boolean',
value: false,
description: 'GStreamer GLib checks and asserts such as API guards (disable for stable releases)'
)
option('deprecated-glib-api',
type: 'boolean',
value: true,
description: 'Allow using of deprecated GLib API'
)

View File

@@ -1,111 +0,0 @@
const { Gtk } = imports.gi;
const Dialogs = imports.src.dialogs;
const Prefs = imports.src.prefs;
const Misc = imports.src.misc;
var actions = {
open_local: ['<Ctrl>O'],
export_playlist: ['<Ctrl>E'],
open_uri: ['<Ctrl>U'],
prefs: ['<Ctrl>comma'],
shortcuts: ['F1', '<Ctrl>question'],
about: null,
progress_forward: ['Right'],
progress_backward: ['Left'],
next_chapter: ['<Shift>Right'],
prev_chapter: ['<Shift>Left'],
next_track: ['<Ctrl>Right'],
prev_track: ['<Ctrl>Left'],
volume_up: ['Up'],
volume_down: ['Down'],
mute: ['<Ctrl>M', 'M'],
toggle_play: ['space'],
change_repeat: ['<Ctrl>R'],
reveal_controls: ['Return'],
toggle_fullscreen: ['F11', 'F'],
leave_fullscreen: ['Escape'],
quit: ['<Ctrl>Q', 'Q'],
};
function handleAction(action, window)
{
const clapperWidget = window.child;
if(!clapperWidget) return;
const { player } = clapperWidget;
let bool = false;
switch(action.name) {
case 'open_local':
case 'export_playlist':
new Dialogs.FileChooser(window, action.name);
break;
case 'open_uri':
new Dialogs.UriDialog(window);
break;
case 'prefs':
new Prefs.PrefsWindow(window);
break;
case 'shortcuts':
if(!window.get_help_overlay()) {
const helpBuilder = Misc.getBuilderForName('help-overlay.ui');
window.set_help_overlay(helpBuilder.get_object('help_overlay'));
}
clapperWidget.activate_action('win.show-help-overlay', null);
break;
case 'about':
new Dialogs.AboutDialog(window);
break;
case 'progress_forward':
bool = true;
case 'progress_backward':
player.adjust_position(bool);
if(
clapperWidget.isReleaseKeyEnabled
&& clapperWidget.isFullscreenMode
)
clapperWidget.revealControls();
/* Actual seek is handled on release */
clapperWidget.isReleaseKeyEnabled = true;
if(!clapperWidget.has_focus)
clapperWidget.grab_focus();
break;
case 'volume_up':
bool = true;
case 'volume_down':
player.adjust_volume(bool);
break;
case 'mute':
player.mute ^= true;
break;
case 'next_track':
player.playlistWidget.nextTrack();
break;
case 'prev_track':
player.playlistWidget.prevTrack();
break;
case 'reveal_controls':
if(clapperWidget.isFullscreenMode)
clapperWidget.revealControls();
break;
case 'leave_fullscreen':
if(!clapperWidget.isFullscreenMode)
break;
case 'toggle_fullscreen':
clapperWidget.toggleFullscreen();
break;
case 'change_repeat':
player.playlistWidget.changeRepeatMode();
break;
case 'quit':
clapperWidget.activate_action('window.close', null);
break;
case 'toggle_play':
case 'next_chapter':
case 'prev_chapter':
player[action.name]();
break;
default:
break;
}
}

View File

@@ -1,126 +0,0 @@
const { Gio, GObject, Gtk } = imports.gi;
const { Widget } = imports.src.widget;
const Debug = imports.src.debug;
const FileOps = imports.src.fileOps;
const Misc = imports.src.misc;
const Actions = imports.src.actions;
const { debug } = Debug;
const { settings } = Misc;
var App = GObject.registerClass({
GTypeName: 'ClapperApp',
},
class ClapperApp extends Gtk.Application
{
_init()
{
super._init({
application_id: Misc.appId,
flags: Gio.ApplicationFlags.HANDLES_OPEN,
});
this.doneFirstActivate = false;
this.isFileAppend = false;
this.mapSignal = null;
}
vfunc_open(files, hint)
{
super.vfunc_open(files, hint);
this.activate();
this._openFilesAsync(files).catch(debug);
}
vfunc_activate()
{
super.vfunc_activate();
if(!this.doneFirstActivate)
this._onFirstActivate();
this.active_window.present();
}
async _openFilesAsync(files)
{
const urisArr = [];
for(let file of files) {
const uri = file.get_uri();
if(!uri.startsWith('file:')) {
urisArr.push(uri);
continue;
}
/* If file is not a dir its URI will be returned in an array */
const uris = await FileOps.getDirFilesUrisPromise(file).catch(debug);
if(uris && uris.length)
urisArr.push(...uris);
}
const [playlist, subs] = Misc.parsePlaylistFiles(urisArr);
const { player } = this.active_window.get_child();
const action = (this.isFileAppend) ? 'append' : 'set';
if(playlist && playlist.length)
player[`${action}_playlist`](playlist);
if(subs)
player.set_subtitles(subs);
/* Restore default behavior */
this.isFileAppend = false;
}
_onFirstActivate()
{
const window = new Gtk.ApplicationWindow({
application: this,
title: Misc.appName,
});
window.add_css_class('adwrounded');
if(!settings.get_boolean('render-shadows'))
window.add_css_class('gpufriendly');
window.add_css_class('gpufriendlyfs');
const clapperWidget = new Widget();
const dummyHeaderbar = new Gtk.Box({
can_focus: false,
focusable: false,
visible: false,
});
window.add_css_class('nobackground');
window.set_child(clapperWidget);
window.set_titlebar(dummyHeaderbar);
for(let name in Actions.actions) {
const simpleAction = new Gio.SimpleAction({ name });
simpleAction.connect('activate', (action) =>
Actions.handleAction(action, window)
);
this.add_action(simpleAction);
const accels = Actions.actions[name];
if(accels)
this.set_accels_for_action(`app.${name}`, accels);
}
this.mapSignal = window.connect('map', this._onWindowMap.bind(this));
this.doneFirstActivate = true;
}
_onWindowMap(window)
{
window.disconnect(this.mapSignal);
this.mapSignal = null;
debug('window mapped');
window.child._onWindowMap(window);
}
});

View File

@@ -1,260 +0,0 @@
const { GObject, Gtk } = imports.gi;
const Misc = imports.src.misc;
var CustomButton = GObject.registerClass({
GTypeName: 'ClapperCustomButton',
},
class ClapperCustomButton extends Gtk.Button
{
_init(opts)
{
opts = opts || {};
const defaults = {
halign: Gtk.Align.CENTER,
valign: Gtk.Align.CENTER,
can_focus: false,
};
Object.assign(opts, defaults);
super._init(opts);
this.add_css_class('flat');
this.add_css_class('clappercontrolsbutton');
}
vfunc_clicked()
{
const clapperWidget = this.get_ancestor(Gtk.Grid);
if(clapperWidget.isFullscreenMode)
clapperWidget.revealControls();
}
});
var IconToggleButton = GObject.registerClass({
GTypeName: 'ClapperIconToggleButton',
},
class ClapperIconToggleButton extends CustomButton
{
_init(primaryIcon, secondaryIcon)
{
super._init({
icon_name: primaryIcon,
});
this.primaryIcon = primaryIcon;
this.secondaryIcon = secondaryIcon;
}
setPrimaryIcon()
{
this.icon_name = this.primaryIcon;
}
setSecondaryIcon()
{
this.icon_name = this.secondaryIcon;
}
});
var PopoverSeparator = GObject.registerClass({
GTypeName: 'ClapperPopoverSeparator',
Template: Misc.getResourceUri('ui/popover-separator.ui'),
InternalChildren: ['middle_label'],
Properties: {
'label': GObject.ParamSpec.string(
'label',
'Middle label',
'Text to set in the middle',
GObject.ParamFlags.WRITABLE,
null
),
}
},
class ClapperPopoverSeparator extends Gtk.Box
{
_init(opts)
{
super._init();
if(!opts.label)
this.visible = false;
this.label = opts.label;
}
set label(value)
{
this._middle_label.label = value || "";
if(value)
this.visible = true;
}
});
var PopoverButtonBase = GObject.registerClass({
GTypeName: 'ClapperPopoverButtonBase',
},
class ClapperPopoverButtonBase extends Gtk.MenuButton
{
_init(opts = {})
{
super._init(opts);
if(opts.icon_name)
this.icon_name = opts.icon_name;
else if(opts.label)
this.label = opts.label;
this.toggleButton = this.get_first_child();
this.toggleButton.add_css_class('clappercontrolsbutton');
this.set_create_popup_func(this._onPopoverOpened);
this.popover.connect('closed', this._onPopoverClosed.bind(this));
}
_onPopoverOpened(self)
{
const clapperWidget = self.get_ancestor(Gtk.Grid);
if(clapperWidget.isFullscreenMode) {
clapperWidget.revealControls();
clapperWidget.isPopoverOpen = true;
}
}
_onPopoverClosed(popover)
{
const clapperWidget = this.get_ancestor(Gtk.Grid);
/* Set again timeout as popover is now closed */
if(clapperWidget.isFullscreenMode)
clapperWidget.revealControls();
clapperWidget.isPopoverOpen = false;
}
});
var ElapsedTimeButton = GObject.registerClass({
GTypeName: 'ClapperElapsedTimeButton',
Template: Misc.getResourceUri('ui/elapsed-time-button.ui'),
Children: ['scrolledWindow', 'speedScale'],
},
class ClapperElapsedTimeButton extends PopoverButtonBase
{
_init(opts)
{
super._init(opts);
this.setInitialState();
this.popover.add_css_class('elapsedpopover');
this.scrolledWindow.max_content_height = 150;
}
set label(value)
{
this.toggleButton.label = value;
}
get label()
{
return this.toggleButton.label;
}
setInitialState()
{
this.label = `00${Misc.timeColon}0000${Misc.timeColon}00`;
}
setFullscreenMode(isFullscreen, isMobileMonitor)
{
this.scrolledWindow.max_content_height = (isFullscreen && !isMobileMonitor)
? 190 : 150;
}
});
var TrackSelectButton = GObject.registerClass({
GTypeName: 'ClapperTrackSelectButton',
Template: Misc.getResourceUri('ui/track-select-button.ui'),
Children: ['popoverBox'],
InternalChildren: ['scrolled_window', 'decoder_separator'],
},
class ClapperTrackSelectButton extends PopoverButtonBase
{
_init(opts)
{
super._init(opts);
this._scrolled_window.max_content_height = 220;
}
setFullscreenMode(isFullscreen, isMobileMonitor)
{
this._scrolled_window.max_content_height = (isFullscreen && !isMobileMonitor)
? 290 : 220;
}
setDecoder(decoder)
{
this._decoder_separator.label = _('Decoder: %s').format(decoder);
}
});
var VolumeButton = GObject.registerClass({
GTypeName: 'ClapperVolumeButton',
Template: Misc.getResourceUri('ui/volume-button.ui'),
Children: ['volumeScale'],
Properties: {
'muted': GObject.ParamSpec.boolean(
'muted',
'Set muted',
'Mark scale as muted',
GObject.ParamFlags.WRITABLE,
false
),
}
},
class ClapperVolumeButton extends PopoverButtonBase
{
_init(opts)
{
super._init(opts);
this._isMuted = false;
}
set muted(isMuted)
{
this._isMuted = isMuted;
this._onVolumeScaleValueChanged(this.volumeScale);
}
_onVolumeScaleValueChanged(scale)
{
const volume = scale.get_value();
const cssClass = 'overamp';
const hasOveramp = (scale.has_css_class(cssClass));
if(volume > 1) {
if(!hasOveramp)
scale.add_css_class(cssClass);
}
else {
if(hasOveramp)
scale.remove_css_class(cssClass);
}
const icon = (volume <= 0 || this._isMuted)
? 'muted'
: (volume <= 0.3)
? 'low'
: (volume <= 0.7)
? 'medium'
: (volume <= 1)
? 'high'
: 'overamplified';
this.icon_name = `audio-volume-${icon}-symbolic`;
}
});

493
src/controls.js vendored
View File

@@ -1,493 +0,0 @@
const { GLib, GObject, Gdk, Gtk } = imports.gi;
const Buttons = imports.src.buttons;
const Debug = imports.src.debug;
const Misc = imports.src.misc;
const Revealers = imports.src.revealers;
const { debug } = Debug;
const { settings } = Misc;
var Controls = GObject.registerClass({
GTypeName: 'ClapperControls',
},
class ClapperControls extends Gtk.Box
{
_init()
{
super._init({
orientation: Gtk.Orientation.HORIZONTAL,
valign: Gtk.Align.END,
can_focus: false,
});
this.minFullViewWidth = 560;
this.currentPosition = 0;
this.isPositionDragging = false;
this.isMobile = false;
this.showHours = false;
this.durationFormatted = `00${Misc.timeColon}00`;
this.revealersArr = [];
this.chapters = null;
this.chapterShowId = null;
this.chapterHideId = null;
this.togglePlayButton = new Buttons.IconToggleButton(
'play-symbolic',
'pause-symbolic'
);
this.togglePlayButton.connect(
'clicked', this._onTogglePlayClicked.bind(this)
);
this.append(this.togglePlayButton);
const elapsedRevealer = new Revealers.ButtonsRevealer('SLIDE_RIGHT');
this.elapsedButton = new Buttons.ElapsedTimeButton();
elapsedRevealer.append(this.elapsedButton);
elapsedRevealer.reveal_child = true;
this.append(elapsedRevealer);
this.revealersArr.push(elapsedRevealer);
this._addPositionScale();
const revealTracksButton = new Buttons.IconToggleButton(
'go-previous-symbolic',
'go-next-symbolic'
);
revealTracksButton.add_css_class('narrowbutton');
const tracksRevealer = new Revealers.ButtonsRevealer(
'SLIDE_LEFT', revealTracksButton
);
this.visualizationsButton = new Buttons.TrackSelectButton({
icon_name: 'display-projector-symbolic',
visible: false,
});
tracksRevealer.append(this.visualizationsButton);
this.videoTracksButton = new Buttons.TrackSelectButton({
icon_name: 'emblem-videos-symbolic',
visible: false,
});
tracksRevealer.append(this.videoTracksButton);
this.audioTracksButton = new Buttons.TrackSelectButton({
icon_name: 'emblem-music-symbolic',
visible: false,
});
tracksRevealer.append(this.audioTracksButton);
this.subtitleTracksButton = new Buttons.TrackSelectButton({
icon_name: 'media-view-subtitles-symbolic',
visible: false,
});
tracksRevealer.append(this.subtitleTracksButton);
this.revealTracksRevealer = new Revealers.ButtonsRevealer('SLIDE_LEFT');
this.revealTracksRevealer.append(revealTracksButton);
this.revealTracksRevealer.set_visible(false);
this.append(this.revealTracksRevealer);
tracksRevealer.set_reveal_child(true);
this.revealersArr.push(tracksRevealer);
this.append(tracksRevealer);
this.volumeButton = new Buttons.VolumeButton();
this.append(this.volumeButton);
this.unfullscreenButton = new Buttons.CustomButton({
icon_name: 'view-restore-symbolic',
});
this.unfullscreenButton.connect('clicked', this._onUnfullscreenClicked.bind(this));
this.unfullscreenButton.set_visible(false);
this.append(this.unfullscreenButton);
this.add_css_class('clappercontrols');
this.realizeSignal = this.connect('realize', this._onRealize.bind(this));
}
setFullscreenMode(isFullscreen, isMobileMonitor)
{
/* Allow recheck on next resize */
this.isMobile = null;
this.elapsedButton.setFullscreenMode(isFullscreen, isMobileMonitor);
this.visualizationsButton.setFullscreenMode(isFullscreen, isMobileMonitor);
this.videoTracksButton.setFullscreenMode(isFullscreen, isMobileMonitor);
this.audioTracksButton.setFullscreenMode(isFullscreen, isMobileMonitor);
this.subtitleTracksButton.setFullscreenMode(isFullscreen, isMobileMonitor);
this.unfullscreenButton.visible = isFullscreen;
}
setLiveMode(isLive, isSeekable)
{
if(isLive)
this.elapsedButton.label = 'LIVE';
this.positionScale.visible = isSeekable;
}
setInitialState()
{
this.currentPosition = 0;
this.positionScale.set_value(0);
this.positionScale.visible = false;
this.elapsedButton.setInitialState();
this.togglePlayButton.setPrimaryIcon();
for(let type of ['video', 'audio', 'subtitle'])
this[`${type}TracksButton`].visible = false;
this.visualizationsButton.visible = false;
}
updateElapsedLabel(value)
{
value = value || 0;
const elapsed = Misc.getFormattedTime(value, this.showHours)
+ '' + this.durationFormatted;
this.elapsedButton.label = elapsed;
}
addCheckButtons(box, array, activeId)
{
let group = null;
let child = box.get_first_child();
let i = 0;
while(child || i < array.length) {
if(i >= array.length) {
if(child.visible) {
debug(`hiding unused ${child.type} checkButton nr: ${i}`);
child.visible = false;
}
i++;
child = child.get_next_sibling();
continue;
}
const el = array[i];
let checkButton;
if(child) {
checkButton = child;
debug(`reusing ${el.type} checkButton nr: ${i}`);
}
else {
debug(`creating new ${el.type} checkButton nr: ${i}`);
checkButton = new Gtk.CheckButton({
group: group,
});
checkButton.connect(
'toggled',
this._onCheckButtonToggled.bind(this)
);
box.append(checkButton);
}
checkButton.label = el.label;
debug(`checkButton label: ${checkButton.label}`);
checkButton.type = el.type;
debug(`checkButton type: ${checkButton.type}`);
checkButton.activeId = el.activeId;
debug(`checkButton id: ${checkButton.activeId}`);
checkButton.visible = true;
if(checkButton.activeId === activeId) {
checkButton.set_active(true);
debug(`activated ${el.type} checkButton nr: ${i}`);
}
if(!group)
group = checkButton;
i++;
if(child)
child = child.get_next_sibling();
}
}
_handleTrackChange(checkButton)
{
const clapperWidget = this.get_ancestor(Gtk.Grid);
if(checkButton.activeId < 0) {
return clapperWidget.player[
`set_${checkButton.type}_track_enabled`
](false);
}
const setTrack = `set_${checkButton.type}_track`;
clapperWidget.player[setTrack](checkButton.activeId);
clapperWidget.player[`${setTrack}_enabled`](true);
}
_handleVisualizationChange(checkButton)
{
const clapperWidget = this.get_ancestor(Gtk.Grid);
const isEnabled = clapperWidget.player.get_visualization_enabled();
if(!checkButton.activeId) {
if(isEnabled) {
clapperWidget.player.set_visualization_enabled(false);
debug('disabled visualizations');
}
return;
}
const currVis = clapperWidget.player.get_current_visualization();
if(currVis === checkButton.activeId)
return;
debug(`set visualization: ${checkButton.activeId}`);
clapperWidget.player.set_visualization(checkButton.activeId);
if(!isEnabled) {
clapperWidget.player.set_visualization_enabled(true);
debug('enabled visualizations');
}
}
_addPositionScale()
{
this.positionScale = new Gtk.Scale({
orientation: Gtk.Orientation.HORIZONTAL,
value_pos: Gtk.PositionType.LEFT,
draw_value: false,
hexpand: true,
valign: Gtk.Align.CENTER,
can_focus: false,
visible: false,
});
const scrollController = new Gtk.EventControllerScroll();
scrollController.set_flags(Gtk.EventControllerScrollFlags.BOTH_AXES);
scrollController.connect('scroll', this._onPositionScaleScroll.bind(this));
this.positionScale.add_controller(scrollController);
this.positionScale.add_css_class('positionscale');
this.positionScaleValueSignal = this.positionScale.connect(
'value-changed', this._onPositionScaleValueChanged.bind(this)
);
/* GTK4 is missing pressed/released signals for GtkRange/GtkScale.
* We cannot add controllers, cause it already has them, so we
* workaround this by observing css classes it currently has */
this.positionScaleDragSignal = this.positionScale.connect(
'notify::css-classes', this._onPositionScaleDragging.bind(this)
);
this.positionAdjustment = this.positionScale.get_adjustment();
this.positionAdjustment.set_page_increment(0);
this.positionAdjustment.set_step_increment(8);
const chapterLabel = new Gtk.Label();
chapterLabel.add_css_class('chapterlabel');
this.chapterPopover = new Gtk.Popover({
position: Gtk.PositionType.TOP,
autohide: false,
child: chapterLabel,
});
const box = new Gtk.Box({
orientation: Gtk.Orientation.VERTICAL,
hexpand: true,
valign: Gtk.Align.CENTER,
can_focus: false,
});
box.append(this.chapterPopover);
box.append(this.positionScale);
this.append(box);
}
_setChapterVisible(isVisible)
{
const type = (isVisible) ? 'Show' : 'Hide';
const anti = (isVisible) ? 'Hide' : 'Show';
if(this[`chapter${anti}Id`]) {
GLib.source_remove(this[`chapter${anti}Id`]);
this[`chapter${anti}Id`] = null;
}
if(
this[`chapter${type}Id`]
|| (!isVisible && this.chapterPopover.visible === isVisible)
)
return;
debug(`changing chapter visibility to: ${isVisible}`);
this[`chapter${type}Id`] = GLib.idle_add(
GLib.PRIORITY_DEFAULT_IDLE + 20,
() => {
if(isVisible) {
const [start, end] = this.positionScale.get_slider_range();
const controlsHeight = this.parent.get_height();
const scaleBoxHeight = this.positionScale.parent.get_height();
const [isShared, destX, destY] = this.positionScale.translate_coordinates(
this.positionScale.parent, 0, 0
);
const clapperWidget = this.get_ancestor(Gtk.Grid);
/* Half of slider width, values are defined in CSS */
const sliderOffset = (
clapperWidget.isFullscreenMode && !clapperWidget.isMobileMonitor
) ? 10 : 9;
this.chapterPopover.set_pointing_to(new Gdk.Rectangle({
x: destX + end - sliderOffset,
y: -(controlsHeight - scaleBoxHeight) / 2,
width: 0,
height: 0,
}));
}
this.chapterPopover.visible = isVisible;
this[`chapter${type}Id`] = null;
debug(`chapter visible: ${isVisible}`);
return GLib.SOURCE_REMOVE;
}
);
}
_onRealize()
{
this.disconnect(this.realizeSignal);
this.realizeSignal = null;
const clapperWidget = this.get_ancestor(Gtk.Grid);
const scrollController = new Gtk.EventControllerScroll();
scrollController.set_flags(
Gtk.EventControllerScrollFlags.VERTICAL
| Gtk.EventControllerScrollFlags.DISCRETE
);
scrollController.connect('scroll', clapperWidget._onScroll.bind(clapperWidget));
this.volumeButton.add_controller(scrollController);
const initialVolume = (settings.get_boolean('volume-custom'))
? settings.get_int('volume-value') / 100
: settings.get_double('volume-last');
clapperWidget.player.volume = initialVolume;
clapperWidget.player.bind_property('mute', this.volumeButton, 'muted',
GObject.BindingFlags.DEFAULT
);
}
_onPlayerResize(width, height)
{
const isMobile = (width < this.minFullViewWidth);
if(this.isMobile === isMobile)
return;
for(let revealer of this.revealersArr)
revealer.set_reveal_child(!isMobile);
this.revealTracksRevealer.set_reveal_child(isMobile);
this.isMobile = isMobile;
}
_onUnfullscreenClicked(button)
{
const root = button.get_root();
root.unfullscreen();
}
_onCheckButtonToggled(checkButton)
{
if(!checkButton.get_active())
return;
switch(checkButton.type) {
case 'video':
case 'audio':
case 'subtitle':
this._handleTrackChange(checkButton);
break;
case 'visualization':
this._handleVisualizationChange(checkButton);
break;
default:
break;
}
}
_onTogglePlayClicked()
{
/* Parent of controls changes, so get ancestor instead */
const { player } = this.get_ancestor(Gtk.Grid);
player.toggle_play();
}
_onPositionScaleScroll(controller, dx, dy)
{
const clapperWidget = this.get_ancestor(Gtk.Grid);
clapperWidget._onScroll(controller, dx || dy, 0);
}
_onPositionScaleValueChanged(scale)
{
const scaleValue = scale.get_value();
const positionSeconds = Math.round(scaleValue);
this.currentPosition = positionSeconds;
this.updateElapsedLabel(positionSeconds);
if(this.chapters && this.isPositionDragging) {
const chapter = this.chapters[scaleValue];
const isChapter = (chapter != null);
if(isChapter)
this.chapterPopover.child.label = chapter;
this._setChapterVisible(isChapter);
}
}
_onPositionScaleDragging(scale)
{
const isPositionDragging = scale.has_css_class('dragging');
if(this.isPositionDragging === isPositionDragging)
return;
const clapperWidget = this.get_ancestor(Gtk.Grid);
if(!clapperWidget) return;
if(clapperWidget.isFullscreenMode) {
clapperWidget.revealControls();
if(isPositionDragging)
clapperWidget._clearTimeout('hideControls');
}
if((this.isPositionDragging = isPositionDragging))
return;
const scaleValue = scale.get_value();
const isChapterSeek = this.chapterPopover.visible;
if(!isChapterSeek) {
const positionSeconds = Math.round(scaleValue);
clapperWidget.player.seek_seconds(positionSeconds);
}
else {
clapperWidget.player.seek_chapter(scaleValue);
this._setChapterVisible(false);
}
}
_onCloseRequest()
{
debug('controls close request');
this.positionScale.disconnect(this.positionScaleValueSignal);
this.positionScale.disconnect(this.positionScaleDragSignal);
}
});

View File

@@ -1,57 +0,0 @@
const { Gio } = imports.gi;
const Debug = imports.src.debug;
const { debug } = Debug;
const ShellProxyWrapper = Gio.DBusProxy.makeProxyWrapper(`
<node>
<interface name="org.gnome.Shell">
<method name="Eval">
<arg type="s" direction="in" name="script"/>
<arg type="b" direction="out" name="success"/>
<arg type="s" direction="out" name="result"/>
</method>
</interface>
</node>`
);
let shellProxy = null;
debug('creating GNOME Shell DBus proxy');
new ShellProxyWrapper(
Gio.DBus.session,
'org.gnome.Shell',
'/org/gnome/Shell',
(proxy, err) => {
if(err) {
debug(err);
return;
}
shellProxy = proxy;
debug('GNOME Shell DBus proxy is ready');
},
null,
Gio.DBusProxyFlags.DO_NOT_AUTO_START_AT_CONSTRUCTION
| Gio.DBusProxyFlags.DO_NOT_CONNECT_SIGNALS
);
function shellWindowEval(fn, isEnabled)
{
if(!shellProxy)
return;
const un = (isEnabled) ? '' : 'un';
debug(`changing ${fn}`);
shellProxy.EvalRemote(
`global.display.focus_window.${un}${fn}()`,
(out) => {
const debugMsg = (out[0])
? `window ${fn}: ${isEnabled}`
: new Error(out[1]);
debug(debugMsg);
}
);
}

View File

@@ -1,55 +0,0 @@
const { GLib } = imports.gi;
const { Debug } = imports.extras.debug;
const { Ink } = imports.extras.ink;
const G_DEBUG_ENV = GLib.getenv('G_MESSAGES_DEBUG');
const clapperDebugger = new Debug.Debugger('Clapper', {
name_printer: new Ink.Printer({
font: Ink.Font.BOLD,
color: Ink.Color.MAGENTA
}),
time_printer: new Ink.Printer({
color: Ink.Color.ORANGE
}),
high_precision: true,
});
clapperDebugger.enabled = (
clapperDebugger.enabled
|| G_DEBUG_ENV != null
&& G_DEBUG_ENV.includes('Clapper')
);
function _logStructured(debuggerName, msg, level)
{
GLib.log_structured(
debuggerName, level, {
MESSAGE: msg,
SYSLOG_IDENTIFIER: debuggerName.toLowerCase()
});
}
function _debug(debuggerName, msg)
{
if(msg.message) {
_logStructured(
debuggerName,
msg.message,
GLib.LogLevelFlags.LEVEL_CRITICAL
);
return;
}
clapperDebugger.debug(msg);
}
function debug(msg)
{
_debug('Clapper', msg);
}
function warn(msg)
{
_logStructured('Clapper', msg, GLib.LogLevelFlags.LEVEL_WARNING);
}

View File

@@ -1,314 +0,0 @@
const { Adw, Gdk, Gio, GObject, Gst, Gtk } = imports.gi;
const System = imports.system;
const Debug = imports.src.debug;
const FileOps = imports.src.fileOps;
const Misc = imports.src.misc;
const { debug } = Debug;
var FileChooser = GObject.registerClass({
GTypeName: 'ClapperFileChooser',
},
class ClapperFileChooser extends Gtk.FileChooserNative
{
_init(window, purpose)
{
super._init({
transient_for: window,
modal: true,
});
switch(purpose) {
case 'open_local':
this._prepareOpenLocal();
break;
case 'export_playlist':
this._prepareExportPlaylist();
break;
default:
debug(new Error(`unknown file chooser purpose: ${purpose}`));
break;
}
this.chooserPurpose = purpose;
/* File chooser closes itself when nobody is holding its ref */
this.ref();
this.show();
}
_prepareOpenLocal()
{
this.select_multiple = true;
const filter = new Gtk.FileFilter({
name: 'Media Files',
});
filter.add_mime_type('video/*');
filter.add_mime_type('audio/*');
filter.add_mime_type('application/claps');
Misc.subsMimes.forEach(mime => filter.add_mime_type(mime));
this.add_filter(filter);
}
_prepareExportPlaylist()
{
this.action = Gtk.FileChooserAction.SAVE;
this.set_current_name('playlist.claps');
const filter = new Gtk.FileFilter({
name: 'Playlist Files',
});
filter.add_mime_type('application/claps');
this.add_filter(filter);
}
vfunc_response(respId)
{
debug('closing file chooser dialog');
if(respId === Gtk.ResponseType.ACCEPT) {
switch(this.chooserPurpose) {
case 'open_local':
this._handleOpenLocal();
break;
case 'export_playlist':
this._handleExportPlaylist();
break;
}
}
this.unref();
this.destroy();
}
_handleOpenLocal()
{
const files = this.get_files();
const filesArray = [];
let index = 0;
let file;
while((file = files.get_item(index))) {
filesArray.push(file);
index++;
}
const { application } = this.transient_for;
const isHandlesOpen = Boolean(
application.flags & Gio.ApplicationFlags.HANDLES_OPEN
);
/* Remote app does not handle open */
if(isHandlesOpen)
application.open(filesArray, "");
else
application._openFilesAsync(filesArray);
}
_handleExportPlaylist()
{
const file = this.get_file();
const { playlistWidget } = this.transient_for.child.player;
const playlist = playlistWidget.getPlaylist(true);
FileOps.saveFileSimplePromise(file, playlist.join('\n'))
.then(() => {
debug(`exported playlist to file: ${file.get_path()}`);
})
.catch(err => {
debug(err);
});
}
});
var UriDialog = GObject.registerClass({
GTypeName: 'ClapperUriDialog',
},
class ClapperUriDialog extends Gtk.Dialog
{
_init(window)
{
super._init({
transient_for: window,
modal: true,
use_header_bar: true,
title: _('Open URI'),
default_width: 420,
});
const contentBox = this.get_content_area();
contentBox.vexpand = true;
contentBox.add_css_class('uridialogbox');
const linkEntry = new Gtk.Entry({
activates_default: true,
truncate_multiline: true,
height_request: 38,
hexpand: true,
valign: Gtk.Align.CENTER,
input_purpose: Gtk.InputPurpose.URL,
placeholder_text: _('Enter or drop URI here'),
});
linkEntry.connect('notify::text', this._onTextNotify.bind(this));
contentBox.append(linkEntry);
this.add_button(_('Cancel'), Gtk.ResponseType.CANCEL);
this.add_button(_('Open'), Gtk.ResponseType.OK);
this.set_default_response(Gtk.ResponseType.OK);
this.set_response_sensitive(Gtk.ResponseType.OK, false);
const display = Gdk.Display.get_default();
const clipboard = (display) ? display.get_clipboard() : null;
if(clipboard)
clipboard.read_text_async(null, this._readTextAsyncCb.bind(this));
this.show();
}
vfunc_response(respId)
{
if(respId === Gtk.ResponseType.OK) {
const contentBox = this.get_content_area();
const linkEntry = contentBox.get_last_child();
const { player } = this.transient_for.child;
player.set_playlist([linkEntry.text]);
}
this.destroy();
}
_onTextNotify(entry)
{
const isUriValid = (entry.text.length)
? Gst.uri_is_valid(entry.text)
: false;
this.set_response_sensitive(Gtk.ResponseType.OK, isUriValid);
}
_readTextAsyncCb(clipboard, result)
{
let uri = null;
try {
uri = clipboard.read_text_finish(result);
}
catch(err) {
debug(`could not read clipboard: ${err.message}`);
}
if(!uri || !Gst.uri_is_valid(uri))
return;
const contentBox = this.get_content_area();
const linkEntry = contentBox.get_last_child();
linkEntry.set_text(uri);
linkEntry.select_region(0, -1);
}
});
var ResumeDialog = GObject.registerClass({
GTypeName: 'ClapperResumeDialog',
},
class ClapperResumeDialog extends Gtk.MessageDialog
{
_init(window, resumeInfo)
{
const percentage = Math.round((resumeInfo.time / resumeInfo.duration) * 100);
const msg = [
'<b>' + _('Title') + `:</b> ${resumeInfo.title}`,
'<b>' + _('Completed') + `:</b> ${percentage}%`
].join('\n');
super._init({
transient_for: window,
modal: true,
message_type: Gtk.MessageType.QUESTION,
buttons: Gtk.ButtonsType.YES_NO,
text: _('Resume playback?'),
secondary_use_markup: true,
secondary_text: msg,
});
this.resumeInfo = resumeInfo;
this.set_default_response(Gtk.ResponseType.YES);
this.show();
}
vfunc_response(respId)
{
const { player } = this.transient_for.child;
if(respId === Gtk.ResponseType.YES)
player.seek_seconds(this.resumeInfo.time);
this.destroy();
}
});
var AboutDialog = GObject.registerClass({
GTypeName: 'ClapperAboutDialog',
},
class ClapperAboutDialog extends Gtk.AboutDialog
{
_init(window)
{
const gstVer = [
Gst.VERSION_MAJOR, Gst.VERSION_MINOR, Gst.VERSION_MICRO
].join('.');
const gtkVer = [
Gtk.MAJOR_VERSION, Gtk.MINOR_VERSION, Gtk.MICRO_VERSION
].join('.');
/* TODO: This is as of Alpha2 still broken, requires:
* https://gitlab.gnome.org/GNOME/libadwaita/-/merge_requests/230
* can be simplified later in future */
const adwVer = Adw.MAJOR_VERSION ? [
Adw.MAJOR_VERSION, Adw.MINOR_VERSION, Adw.MICRO_VERSION
].join('.') : '1.0.0';
const gjsVerStr = String(System.version);
let gjsVer = '';
gjsVer += gjsVerStr.charAt(0) + '.';
gjsVer += gjsVerStr.charAt(1) + gjsVerStr.charAt(2) + '.';
if(gjsVerStr.charAt(3) !== '0')
gjsVer += gjsVerStr.charAt(3);
gjsVer += gjsVerStr.charAt(4);
const osInfo = [
_('GTK version: %s').format(gtkVer),
_('Adwaita version: %s').format(adwVer),
_('GStreamer version: %s').format(gstVer),
_('GJS version: %s').format(gjsVer)
].join('\n');
super._init({
transient_for: window,
destroy_with_parent: true,
modal: true,
program_name: Misc.appName,
comments: _('A GNOME media player powered by GStreamer'),
version: pkg.version,
authors: ['Rafał Dzięgiel'],
artists: ['Rafał Dzięgiel'],
/* TRANSLATORS: Put your name(s) here for credits or leave untranslated */
translator_credits: _('translator-credits'),
license_type: Gtk.License.GPL_3_0,
logo_icon_name: 'com.github.rafostar.Clapper',
website: 'https://rafostar.github.io/clapper',
system_information: osInfo,
});
this.show();
}
});

View File

@@ -1,227 +0,0 @@
const { Gio, GLib } = imports.gi;
const ByteArray = imports.byteArray;
const Debug = imports.src.debug;
const Misc = imports.src.misc;
const { debug } = Debug;
/* FIXME: Use Gio._LocalFilePrototype once we are safe to assume
* that GJS with https://gitlab.gnome.org/GNOME/gjs/-/commit/ec9385b8 is used. */
const LocalFilePrototype = Gio.File.new_for_path('/').constructor.prototype;
Gio._promisify(LocalFilePrototype, 'load_bytes_async', 'load_bytes_finish');
Gio._promisify(LocalFilePrototype, 'make_directory_async', 'make_directory_finish');
Gio._promisify(LocalFilePrototype, 'replace_contents_bytes_async', 'replace_contents_finish');
Gio._promisify(LocalFilePrototype, 'query_info_async', 'query_info_finish');
Gio._promisify(LocalFilePrototype, 'enumerate_children_async', 'enumerate_children_finish');
Gio._promisify(Gio.FileEnumerator.prototype, 'close_async', 'close_finish');
Gio._promisify(Gio.FileEnumerator.prototype, 'next_files_async', 'next_files_finish');
function createCacheDirPromise()
{
const dir = Gio.File.new_for_path(
GLib.get_user_cache_dir() + '/' + Misc.appId
);
return createDirPromise(dir);
}
function createTempDirPromise()
{
const dir = Gio.File.new_for_path(
GLib.get_tmp_dir() + '/' + Misc.appId
);
return createDirPromise(dir);
}
/* Creates dir and resolves with it */
function createDirPromise(dir)
{
return new Promise((resolve, reject) => {
if(dir.query_exists(null))
return resolve(dir);
dir.make_directory_async(
GLib.PRIORITY_DEFAULT,
null
)
.then(success => {
if(success)
return resolve(dir);
reject(new Error(`could not create dir: ${dir.get_path()}`));
})
.catch(err => reject(err));
});
}
/* Simple save data to GioFile */
function saveFileSimplePromise(file, data)
{
return file.replace_contents_bytes_async(
GLib.Bytes.new_take(data),
null,
false,
Gio.FileCreateFlags.NONE,
null
);
}
/* Saves file in optional subdirectory and resolves with it */
function saveFilePromise(place, subdirName, fileName, data)
{
return new Promise(async (resolve, reject) => {
let folderPath = GLib[`get_${place}_dir`]() + '/' + Misc.appId;
if(subdirName)
folderPath += `/${subdirName}`;
const destDir = Gio.File.new_for_path(folderPath);
const destPath = folderPath + '/' + fileName;
debug(`saving file: ${destPath}`);
const checkFolders = (subdirName)
? [destDir.get_parent(), destDir]
: [destDir];
for(let dir of checkFolders) {
const createdDir = await createDirPromise(dir).catch(debug);
if(!createdDir)
return reject(new Error(`could not create dir: ${dir.get_path()}`));
}
const destFile = destDir.get_child(fileName);
saveFileSimplePromise(destFile, data)
.then(() => {
debug(`saved file: ${destPath}`);
resolve(destFile);
})
.catch(err => reject(err));
});
}
function getFileContentsPromise(place, subdirName, fileName)
{
return new Promise((resolve, reject) => {
let destPath = GLib[`get_${place}_dir`]() + '/' + Misc.appId;
if(subdirName)
destPath += `/${subdirName}`;
destPath += `/${fileName}`;
const file = Gio.File.new_for_path(destPath);
debug(`reading data from: ${destPath}`);
if(!file.query_exists(null)) {
debug(`no such file: ${file.get_path()}`);
return resolve(null);
}
file.load_bytes_async(null)
.then(result => {
const data = result[0].get_data();
if(!data || !data.length)
return reject(new Error('source file is empty'));
debug(`read data from: ${destPath}`);
if(data instanceof Uint8Array)
resolve(ByteArray.toString(data));
else
resolve(data);
})
.catch(err => reject(err));
});
}
function _getDirUrisPromise(dir, isDeep)
{
return new Promise(async (resolve, reject) => {
const enumerator = await dir.enumerate_children_async(
'standard::name,standard::type',
Gio.FileQueryInfoFlags.NONE,
GLib.PRIORITY_DEFAULT,
null
).catch(debug);
if(!enumerator)
return reject(new Error('could not create file enumerator'));
const dirPath = dir.get_path();
const arr = [];
debug(`enumerating files in dir: ${dirPath}`);
while(true) {
const infos = await enumerator.next_files_async(
1,
GLib.PRIORITY_DEFAULT,
null
).catch(debug);
if(!infos || !infos.length)
break;
const fileUri = dir.get_uri() + '/' + infos[0].get_name();
if(infos[0].get_file_type() !== Gio.FileType.DIRECTORY) {
arr.push(fileUri);
continue;
}
if(!isDeep)
continue;
const subDir = Misc.getFileFromLocalUri(fileUri);
const subDirUris = await _getDirUrisPromise(subDir, isDeep).catch(debug);
if(subDirUris && subDirUris.length)
arr.push(...subDirUris);
}
const isClosed = await enumerator.close_async(
GLib.PRIORITY_DEFAULT,
null
).catch(debug);
if(isClosed)
debug(`closed enumerator for dir: ${dirPath}`);
else
debug(new Error(`could not close file enumerator for dir: ${dirPath}`));
resolve(arr);
});
}
/* Either GioFile or URI for dir arg */
function getDirFilesUrisPromise(dir, isDeep)
{
return new Promise(async (resolve, reject) => {
if(!dir.get_path)
dir = Misc.getFileFromLocalUri(dir);
if(!dir)
return reject(new Error('invalid directory'));
const fileInfo = await dir.query_info_async(
'standard::type',
Gio.FileQueryInfoFlags.NONE,
GLib.PRIORITY_DEFAULT,
null
).catch(debug);
if(!fileInfo)
return reject(new Error('no file type info'));
if(fileInfo.get_file_type() !== Gio.FileType.DIRECTORY)
return resolve([dir.get_uri()]);
const arr = await _getDirUrisPromise(dir, isDeep).catch(debug);
if(!arr || !arr.length)
return reject(new Error('enumerated files list is empty'));
resolve(arr.sort());
});
}

View File

@@ -1,299 +0,0 @@
const { GObject, Gtk } = imports.gi;
const Debug = imports.src.debug;
const Misc = imports.src.misc;
const { debug } = Debug;
var HeaderBar = GObject.registerClass({
GTypeName: 'ClapperHeaderBar',
},
class ClapperHeaderBar extends Gtk.Box
{
_init()
{
super._init({
can_focus: false,
orientation: Gtk.Orientation.HORIZONTAL,
spacing: 6,
margin_top: 6,
margin_start: 6,
margin_end: 6,
});
this.add_css_class('osdheaderbar');
this.isMaximized = false;
this.isMenuOnLeft = true;
const uiBuilder = Misc.getBuilderForName('clapper.ui');
this.menuWidget = new Gtk.Box({
orientation: Gtk.Orientation.HORIZONTAL,
valign: Gtk.Align.CENTER,
spacing: 6,
});
this.menuButton = new Gtk.MenuButton({
icon_name: 'open-menu-symbolic',
valign: Gtk.Align.CENTER,
can_focus: false,
});
const menuToggleButton = this.menuButton.get_first_child();
menuToggleButton.add_css_class('osd');
const mainMenuModel = uiBuilder.get_object('mainMenu');
const mainMenuPopover = new HeaderBarPopover(mainMenuModel);
this.menuButton.set_popover(mainMenuPopover);
this.menuButton.add_css_class('circular');
this.menuWidget.append(this.menuButton);
this.extraButtonsBox = new Gtk.Box({
orientation: Gtk.Orientation.HORIZONTAL,
valign: Gtk.Align.CENTER,
});
this.extraButtonsBox.add_css_class('linked');
const floatButton = new Gtk.Button({
icon_name: 'pip-in-symbolic',
can_focus: false,
});
floatButton.add_css_class('osd');
floatButton.add_css_class('circular');
floatButton.add_css_class('linkedleft');
floatButton.connect('clicked',
this._onFloatButtonClicked.bind(this)
);
this.extraButtonsBox.append(floatButton);
const separator = new Gtk.Separator({
orientation: Gtk.Orientation.VERTICAL,
});
separator.add_css_class('linkseparator');
this.extraButtonsBox.append(separator);
const fullscreenButton = new Gtk.Button({
icon_name: 'view-fullscreen-symbolic',
can_focus: false,
});
fullscreenButton.add_css_class('osd');
fullscreenButton.add_css_class('circular');
fullscreenButton.add_css_class('linkedright');
fullscreenButton.connect('clicked',
this._onFullscreenButtonClicked.bind(this)
);
this.extraButtonsBox.append(fullscreenButton);
this.menuWidget.append(this.extraButtonsBox);
this.spacerWidget = new Gtk.Box({
hexpand: true,
});
this.minimizeWidget = this._getWindowButton('minimize');
this.maximizeWidget = this._getWindowButton('maximize');
this.closeWidget = this._getWindowButton('close');
const gtkSettings = Gtk.Settings.get_default();
this._onLayoutUpdate(gtkSettings);
gtkSettings.connect(
'notify::gtk-decoration-layout',
this._onLayoutUpdate.bind(this)
);
}
setMenuOnLeft(isOnLeft)
{
if(this.isMenuOnLeft === isOnLeft)
return;
if(isOnLeft) {
this.menuWidget.reorder_child_after(
this.extraButtonsBox, this.menuButton
);
}
else {
this.menuWidget.reorder_child_after(
this.menuButton, this.extraButtonsBox
);
}
this.isMenuOnLeft = isOnLeft;
}
setMaximized(isMaximized)
{
if(this.isMaximized === isMaximized)
return;
this.maximizeWidget.icon_name = (isMaximized)
? 'window-restore-symbolic'
: 'window-maximize-symbolic';
this.isMaximized = isMaximized;
}
_onLayoutUpdate(gtkSettings)
{
const gtkLayout = gtkSettings.gtk_decoration_layout;
this._replaceButtons(gtkLayout);
}
_replaceButtons(gtkLayout)
{
const modLayout = gtkLayout.replace(':', ',spacer,');
const layoutArr = modLayout.split(',');
let lastWidget = null;
let showMinimize = false;
let showMaximize = false;
let showClose = false;
let menuAdded = false;
let spacerAdded = false;
debug(`headerbar layout: ${modLayout}`);
for(let name of layoutArr) {
/* Menu might be named "appmenu" */
if(!menuAdded && (!name || name === 'appmenu' || name === 'icon'))
name = 'menu';
const widget = this[`${name}Widget`];
if(!widget) continue;
if(!widget.parent)
this.append(widget);
else
this.reorder_child_after(widget, lastWidget);
switch(name) {
case 'spacer':
spacerAdded = true;
break;
case 'minimize':
showMinimize = true;
break;
case 'maximize':
showMaximize = true;
break;
case 'close':
showClose = true;
break;
case 'menu':
this.setMenuOnLeft(!spacerAdded);
menuAdded = true;
break;
default:
break;
}
lastWidget = widget;
}
this.minimizeWidget.visible = showMinimize;
this.maximizeWidget.visible = showMaximize;
this.closeWidget.visible = showClose;
}
_getWindowButton(name)
{
const button = new Gtk.Button({
icon_name: `window-${name}-symbolic`,
valign: Gtk.Align.CENTER,
can_focus: false,
});
button.add_css_class('osd');
button.add_css_class('circular');
if(name === 'maximize')
name = 'toggle-maximized';
button.connect('clicked',
this._onWindowButtonActivate.bind(this, name)
);
return button;
}
_updateFloatIcon(isFloating)
{
const floatButton = this.extraButtonsBox.get_first_child();
if(!floatButton) return;
const iconName = (isFloating)
? 'pip-out-symbolic'
: 'pip-in-symbolic';
if(floatButton.icon_name !== iconName)
floatButton.icon_name = iconName;
}
_onWindowButtonActivate(action)
{
this.activate_action(`window.${action}`, null);
}
_onFloatButtonClicked(button)
{
const clapperWidget = this.root.child;
const { controlsRevealer } = clapperWidget;
controlsRevealer.toggleReveal();
/* Reset timer to not disappear during click */
clapperWidget._setHideControlsTimeout();
this._updateFloatIcon(!controlsRevealer.reveal_child);
}
_onFullscreenButtonClicked(button)
{
this.root.fullscreen();
}
});
var HeaderBarPopover = GObject.registerClass({
GTypeName: 'ClapperHeaderBarPopover',
},
class ClapperHeaderBarPopover extends Gtk.PopoverMenu
{
_init(model)
{
super._init({
menu_model: model,
});
this.connect('map', this._onMap.bind(this));
this.connect('closed', this._onClosed.bind(this));
}
_onMap()
{
const { child } = this.root;
if(
!child
|| !child.player
|| !child.player.widget
)
return;
child.revealControls();
child.isPopoverOpen = true;
}
_onClosed()
{
const { child } = this.root;
if(
!child
|| !child.player
|| !child.player.widget
)
return;
child.revealControls();
child.isPopoverOpen = false;
}
});

View File

@@ -0,0 +1,54 @@
/* Clapper Playback Library
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#include <glib.h>
#include <glib-object.h>
#include <gst/gst.h>
G_BEGIN_DECLS
#define CLAPPER_TYPE_APP_BUS (clapper_app_bus_get_type())
#define CLAPPER_APP_BUS_CAST(obj) ((ClapperAppBus *)(obj))
/**
* ClapperAppBus:
*/
G_DECLARE_FINAL_TYPE (ClapperAppBus, clapper_app_bus, CLAPPER, APP_BUS, GstBus)
void clapper_app_bus_initialize (void);
ClapperAppBus * clapper_app_bus_new (void);
void clapper_app_bus_forward_message (ClapperAppBus *app_bus, GstMessage *msg);
void clapper_app_bus_post_prop_notify (ClapperAppBus *app_bus, GstObject *src, GParamSpec *pspec);
void clapper_app_bus_post_refresh_streams (ClapperAppBus *app_bus, GstObject *src);
void clapper_app_bus_post_refresh_timeline (ClapperAppBus *app_bus, GstObject *src);
void clapper_app_bus_post_simple_signal (ClapperAppBus *app_bus, GstObject *src, guint signal_id);
void clapper_app_bus_post_desc_with_details_signal (ClapperAppBus *app_bus, GstObject *src, guint signal_id, const gchar *desc, const gchar *details);
void clapper_app_bus_post_error_signal (ClapperAppBus *app_bus, GstObject *src, guint signal_id, GError *error, const gchar *debug_info);
G_END_DECLS

View File

@@ -0,0 +1,307 @@
/* Clapper Playback Library
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <gio/gio.h>
#include "clapper-bus-private.h"
#include "clapper-app-bus-private.h"
#include "clapper-player-private.h"
#include "clapper-media-item-private.h"
#include "clapper-timeline-private.h"
#define GST_CAT_DEFAULT clapper_app_bus_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
struct _ClapperAppBus
{
GstBus parent;
};
#define parent_class clapper_app_bus_parent_class
G_DEFINE_TYPE (ClapperAppBus, clapper_app_bus, GST_TYPE_BUS);
enum
{
CLAPPER_APP_BUS_STRUCTURE_UNKNOWN = 0,
CLAPPER_APP_BUS_STRUCTURE_PROP_NOTIFY,
CLAPPER_APP_BUS_STRUCTURE_REFRESH_STREAMS,
CLAPPER_APP_BUS_STRUCTURE_REFRESH_TIMELINE,
CLAPPER_APP_BUS_STRUCTURE_SIMPLE_SIGNAL,
CLAPPER_APP_BUS_STRUCTURE_DESC_WITH_DETAILS_SIGNAL,
CLAPPER_APP_BUS_STRUCTURE_ERROR_SIGNAL
};
static ClapperBusQuark _structure_quarks[] = {
{"unknown", 0},
{"prop-notify", 0},
{"refresh-streams", 0},
{"refresh-timeline", 0},
{"simple-signal", 0},
{"desc-with-details-signal", 0},
{"error-signal", 0},
{NULL, 0}
};
enum
{
CLAPPER_APP_BUS_FIELD_UNKNOWN = 0,
CLAPPER_APP_BUS_FIELD_PSPEC,
CLAPPER_APP_BUS_FIELD_SIGNAL_ID,
CLAPPER_APP_BUS_FIELD_DESC,
CLAPPER_APP_BUS_FIELD_DETAILS,
CLAPPER_APP_BUS_FIELD_ERROR,
CLAPPER_APP_BUS_FIELD_DEBUG_INFO
};
static ClapperBusQuark _field_quarks[] = {
{"unknown", 0},
{"pspec", 0},
{"signal-id", 0},
{"desc", 0},
{"details", 0},
{"error", 0},
{"debug-info", 0},
{NULL, 0}
};
#define _STRUCTURE_QUARK(q) (_structure_quarks[CLAPPER_APP_BUS_STRUCTURE_##q].quark)
#define _FIELD_QUARK(q) (_field_quarks[CLAPPER_APP_BUS_FIELD_##q].quark)
#define _MESSAGE_SRC_GOBJECT(msg) ((GObject *) GST_MESSAGE_SRC (msg))
void
clapper_app_bus_initialize (void)
{
gint i;
for (i = 0; _structure_quarks[i].name; ++i)
_structure_quarks[i].quark = g_quark_from_static_string (_structure_quarks[i].name);
for (i = 0; _field_quarks[i].name; ++i)
_field_quarks[i].quark = g_quark_from_static_string (_field_quarks[i].name);
}
void
clapper_app_bus_forward_message (ClapperAppBus *self, GstMessage *msg)
{
gst_bus_post (GST_BUS_CAST (self), gst_message_ref (msg));
}
/* FIXME: It should be faster to wait for gst_message_new_property_notify() from
* playbin bus and forward them to app bus instead of connecting to notify
* signals of playbin, so change into using gst_message_new_property_notify() here too */
void
clapper_app_bus_post_prop_notify (ClapperAppBus *self,
GstObject *src, GParamSpec *pspec)
{
GstStructure *structure = gst_structure_new_id (_STRUCTURE_QUARK (PROP_NOTIFY),
_FIELD_QUARK (PSPEC), G_TYPE_PARAM, pspec,
NULL);
gst_bus_post (GST_BUS_CAST (self), gst_message_new_application (src, structure));
}
static inline void
_handle_prop_notify_msg (GstMessage *msg, const GstStructure *structure)
{
GParamSpec *pspec = NULL;
gst_structure_id_get (structure,
_FIELD_QUARK (PSPEC), G_TYPE_PARAM, &pspec,
NULL);
g_object_notify_by_pspec (_MESSAGE_SRC_GOBJECT (msg), pspec);
g_param_spec_unref (pspec);
}
void
clapper_app_bus_post_refresh_streams (ClapperAppBus *self, GstObject *src)
{
GstStructure *structure = gst_structure_new_id_empty (_STRUCTURE_QUARK (REFRESH_STREAMS));
gst_bus_post (GST_BUS_CAST (self), gst_message_new_application (src, structure));
}
static inline void
_handle_refresh_streams_msg (GstMessage *msg, const GstStructure *structure)
{
ClapperPlayer *player = CLAPPER_PLAYER_CAST (GST_MESSAGE_SRC (msg));
clapper_player_refresh_streams (player);
}
void
clapper_app_bus_post_refresh_timeline (ClapperAppBus *self, GstObject *src)
{
GstStructure *structure = gst_structure_new_id_empty (_STRUCTURE_QUARK (REFRESH_TIMELINE));
gst_bus_post (GST_BUS_CAST (self), gst_message_new_application (src, structure));
}
static inline void
_handle_refresh_timeline_msg (GstMessage *msg, const GstStructure *structure)
{
ClapperMediaItem *item = CLAPPER_MEDIA_ITEM_CAST (GST_MESSAGE_SRC (msg));
ClapperTimeline *timeline = clapper_media_item_get_timeline (item);
clapper_timeline_refresh (timeline);
}
void
clapper_app_bus_post_simple_signal (ClapperAppBus *self, GstObject *src, guint signal_id)
{
GstStructure *structure = gst_structure_new_id (_STRUCTURE_QUARK (SIMPLE_SIGNAL),
_FIELD_QUARK (SIGNAL_ID), G_TYPE_UINT, signal_id,
NULL);
gst_bus_post (GST_BUS_CAST (self), gst_message_new_application (src, structure));
}
static inline void
_handle_simple_signal_msg (GstMessage *msg, const GstStructure *structure)
{
guint signal_id = 0;
gst_structure_id_get (structure,
_FIELD_QUARK (SIGNAL_ID), G_TYPE_UINT, &signal_id,
NULL);
g_signal_emit (_MESSAGE_SRC_GOBJECT (msg), signal_id, 0);
}
void
clapper_app_bus_post_desc_with_details_signal (ClapperAppBus *self,
GstObject *src, guint signal_id,
const gchar *desc, const gchar *details)
{
GstStructure *structure = gst_structure_new_id (_STRUCTURE_QUARK (DESC_WITH_DETAILS_SIGNAL),
_FIELD_QUARK (SIGNAL_ID), G_TYPE_UINT, signal_id,
_FIELD_QUARK (DESC), G_TYPE_STRING, desc,
_FIELD_QUARK (DETAILS), G_TYPE_STRING, details,
NULL);
gst_bus_post (GST_BUS_CAST (self), gst_message_new_application (src, structure));
}
static inline void
_handle_desc_with_details_signal_msg (GstMessage *msg, const GstStructure *structure)
{
guint signal_id = 0;
gchar *desc = NULL, *details = NULL;
gst_structure_id_get (structure,
_FIELD_QUARK (SIGNAL_ID), G_TYPE_UINT, &signal_id,
_FIELD_QUARK (DESC), G_TYPE_STRING, &desc,
_FIELD_QUARK (DETAILS), G_TYPE_STRING, &details,
NULL);
g_signal_emit (_MESSAGE_SRC_GOBJECT (msg), signal_id, 0, desc, details);
g_free (desc);
g_free (details);
}
void
clapper_app_bus_post_error_signal (ClapperAppBus *self,
GstObject *src, guint signal_id,
GError *error, const gchar *debug_info)
{
GstStructure *structure = gst_structure_new_id (_STRUCTURE_QUARK (ERROR_SIGNAL),
_FIELD_QUARK (SIGNAL_ID), G_TYPE_UINT, signal_id,
_FIELD_QUARK (ERROR), G_TYPE_ERROR, error,
_FIELD_QUARK (DEBUG_INFO), G_TYPE_STRING, debug_info,
NULL);
gst_bus_post (GST_BUS_CAST (self), gst_message_new_application (src, structure));
}
static inline void
_handle_error_signal_msg (GstMessage *msg, const GstStructure *structure)
{
guint signal_id = 0;
GError *error = NULL;
gchar *debug_info = NULL;
gst_structure_id_get (structure,
_FIELD_QUARK (SIGNAL_ID), G_TYPE_UINT, &signal_id,
_FIELD_QUARK (ERROR), G_TYPE_ERROR, &error,
_FIELD_QUARK (DEBUG_INFO), G_TYPE_STRING, &debug_info,
NULL);
g_signal_emit (_MESSAGE_SRC_GOBJECT (msg), signal_id, 0, error, debug_info);
g_clear_error (&error);
g_free (debug_info);
}
static gboolean
clapper_app_bus_message_func (GstBus *bus, GstMessage *msg, gpointer user_data G_GNUC_UNUSED)
{
if (G_LIKELY (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_APPLICATION)) {
const GstStructure *structure = gst_message_get_structure (msg);
GQuark quark = gst_structure_get_name_id (structure);
if (quark == _STRUCTURE_QUARK (PROP_NOTIFY))
_handle_prop_notify_msg (msg, structure);
else if (quark == _STRUCTURE_QUARK (REFRESH_STREAMS))
_handle_refresh_streams_msg (msg, structure);
else if (quark == _STRUCTURE_QUARK (REFRESH_TIMELINE))
_handle_refresh_timeline_msg (msg, structure);
else if (quark == _STRUCTURE_QUARK (SIMPLE_SIGNAL))
_handle_simple_signal_msg (msg, structure);
else if (quark == _STRUCTURE_QUARK (ERROR_SIGNAL))
_handle_error_signal_msg (msg, structure);
else if (quark == _STRUCTURE_QUARK (DESC_WITH_DETAILS_SIGNAL))
_handle_desc_with_details_signal_msg (msg, structure);
}
return G_SOURCE_CONTINUE;
}
/*
* clapper_app_bus_new:
*
* Returns: (transfer full): a new #ClapperAppBus instance
*/
ClapperAppBus *
clapper_app_bus_new (void)
{
GstBus *app_bus;
app_bus = GST_BUS_CAST (g_object_new (CLAPPER_TYPE_APP_BUS, NULL));
gst_object_ref_sink (app_bus);
gst_bus_add_watch (app_bus, (GstBusFunc) clapper_app_bus_message_func, NULL);
return CLAPPER_APP_BUS_CAST (app_bus);
}
static void
clapper_app_bus_init (ClapperAppBus *self)
{
}
static void
clapper_app_bus_finalize (GObject *object)
{
ClapperAppBus *self = CLAPPER_APP_BUS_CAST (object);
GST_TRACE_OBJECT (self, "Finalize");
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
clapper_app_bus_class_init (ClapperAppBusClass *klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "clapperappbus", 0,
"Clapper App Bus");
gobject_class->finalize = clapper_app_bus_finalize;
}

View File

@@ -0,0 +1,32 @@
/* Clapper Playback Library
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#include <glib.h>
#include <gst/gst.h>
#include "clapper-audio-stream.h"
G_BEGIN_DECLS
G_GNUC_INTERNAL
ClapperStream * clapper_audio_stream_new (GstStream *gst_stream);
G_END_DECLS

View File

@@ -0,0 +1,429 @@
/* Clapper Playback Library
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* ClapperAudioStream:
*
* Represents an audio stream within media.
*/
#include <gst/tag/tag.h>
#include "clapper-audio-stream-private.h"
#include "clapper-stream-private.h"
#define GST_CAT_DEFAULT clapper_audio_stream_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
struct _ClapperAudioStream
{
ClapperStream parent;
gchar *codec;
guint bitrate;
gchar *sample_format;
gint sample_rate;
gint channels;
gchar *lang_code;
gchar *lang_name;
};
#define parent_class clapper_audio_stream_parent_class
G_DEFINE_TYPE (ClapperAudioStream, clapper_audio_stream, CLAPPER_TYPE_STREAM);
enum
{
PROP_0,
PROP_CODEC,
PROP_BITRATE,
PROP_SAMPLE_FORMAT,
PROP_SAMPLE_RATE,
PROP_CHANNELS,
PROP_LANG_CODE,
PROP_LANG_NAME,
PROP_LAST
};
static GParamSpec *param_specs[PROP_LAST] = { NULL, };
static void
_update_using_caps (ClapperAudioStream *self, GstCaps *caps)
{
ClapperStream *stream = CLAPPER_STREAM_CAST (self);
GstStructure *structure;
gint sample_rate = 0, channels = 0;
if (gst_caps_get_size (caps) == 0)
return;
structure = gst_caps_get_structure (caps, 0);
clapper_stream_set_string_prop (stream, param_specs[PROP_SAMPLE_FORMAT], &self->sample_format,
gst_structure_get_string (structure, "format"));
gst_structure_get_int (structure, "rate", &sample_rate);
clapper_stream_set_int_prop (stream, param_specs[PROP_SAMPLE_RATE], &self->sample_rate, sample_rate);
gst_structure_get_int (structure, "channels", &channels);
clapper_stream_set_int_prop (stream, param_specs[PROP_CHANNELS], &self->channels, channels);
}
static void
_update_using_tags (ClapperAudioStream *self, GstTagList *tags)
{
ClapperStream *stream = CLAPPER_STREAM_CAST (self);
gchar *codec = NULL, *lang_code = NULL, *lang_name = NULL;
guint bitrate = 0;
gst_tag_list_get_string_index (tags, GST_TAG_AUDIO_CODEC, 0, &codec);
clapper_stream_take_string_prop (stream, param_specs[PROP_CODEC], &self->codec, codec);
gst_tag_list_get_uint_index (tags, GST_TAG_BITRATE, 0, &bitrate);
clapper_stream_set_uint_prop (stream, param_specs[PROP_BITRATE], &self->bitrate, bitrate);
/* Prefer code (and name from it), fallback to extracted name */
if (!gst_tag_list_get_string_index (tags, GST_TAG_LANGUAGE_CODE, 0, &lang_code))
gst_tag_list_get_string_index (tags, GST_TAG_LANGUAGE_NAME, 0, &lang_name);
clapper_stream_take_string_prop (stream, param_specs[PROP_LANG_CODE], &self->lang_code, lang_code);
clapper_stream_take_string_prop (stream, param_specs[PROP_LANG_NAME], &self->lang_name, lang_name);
}
ClapperStream *
clapper_audio_stream_new (GstStream *gst_stream)
{
ClapperAudioStream *audio_stream;
audio_stream = g_object_new (CLAPPER_TYPE_AUDIO_STREAM,
"stream-type", CLAPPER_STREAM_TYPE_AUDIO, NULL);
gst_object_ref_sink (audio_stream);
clapper_stream_set_gst_stream (CLAPPER_STREAM_CAST (audio_stream), gst_stream);
return CLAPPER_STREAM_CAST (audio_stream);
}
/**
* clapper_audio_stream_get_codec:
* @stream: a #ClapperAudioStream
*
* Get codec used to encode @stream.
*
* Returns: (transfer full) (nullable): the audio codec of stream
* or %NULL if undetermined.
*/
gchar *
clapper_audio_stream_get_codec (ClapperAudioStream *self)
{
gchar *codec;
g_return_val_if_fail (CLAPPER_IS_AUDIO_STREAM (self), NULL);
GST_OBJECT_LOCK (self);
codec = g_strdup (self->codec);
GST_OBJECT_UNLOCK (self);
return codec;
}
/**
* clapper_audio_stream_get_bitrate:
* @stream: a #ClapperAudioStream
*
* Get bitrate of audio @stream.
*
* Returns: the bitrate of audio stream.
*/
guint
clapper_audio_stream_get_bitrate (ClapperAudioStream *self)
{
guint bitrate;
g_return_val_if_fail (CLAPPER_IS_AUDIO_STREAM (self), 0);
GST_OBJECT_LOCK (self);
bitrate = self->bitrate;
GST_OBJECT_UNLOCK (self);
return bitrate;
}
/**
* clapper_audio_stream_get_sample_format:
* @stream: a #ClapperAudioStream
*
* Get sample format of audio @stream.
*
* Returns: (transfer full) (nullable): the sample format of stream
* or %NULL if undetermined.
*/
gchar *
clapper_audio_stream_get_sample_format (ClapperAudioStream *self)
{
gchar *sample_format;
g_return_val_if_fail (CLAPPER_IS_AUDIO_STREAM (self), NULL);
GST_OBJECT_LOCK (self);
sample_format = g_strdup (self->sample_format);
GST_OBJECT_UNLOCK (self);
return sample_format;
}
/**
* clapper_audio_stream_get_sample_rate:
* @stream: a #ClapperAudioStream
*
* Get sample rate of audio @stream (in Hz).
*
* Returns: the sample rate of audio stream.
*/
gint
clapper_audio_stream_get_sample_rate (ClapperAudioStream *self)
{
gint sample_rate;
g_return_val_if_fail (CLAPPER_IS_AUDIO_STREAM (self), 0);
GST_OBJECT_LOCK (self);
sample_rate = self->sample_rate;
GST_OBJECT_UNLOCK (self);
return sample_rate;
}
/**
* clapper_audio_stream_get_channels:
* @stream: a #ClapperAudioStream
*
* Get number of audio channels in @stream.
*
* Returns: the number of audio channels.
*/
gint
clapper_audio_stream_get_channels (ClapperAudioStream *self)
{
gint channels;
g_return_val_if_fail (CLAPPER_IS_AUDIO_STREAM (self), 0);
GST_OBJECT_LOCK (self);
channels = self->channels;
GST_OBJECT_UNLOCK (self);
return channels;
}
/**
* clapper_audio_stream_get_lang_code:
* @stream: a #ClapperAudioStream
*
* Get an ISO-639 language code of the @stream.
*
* Returns: (transfer full) (nullable): the language code of audio stream.
*/
gchar *
clapper_audio_stream_get_lang_code (ClapperAudioStream *self)
{
gchar *lang_code;
g_return_val_if_fail (CLAPPER_IS_AUDIO_STREAM (self), NULL);
GST_OBJECT_LOCK (self);
lang_code = g_strdup (self->lang_code);
GST_OBJECT_UNLOCK (self);
return lang_code;
}
/**
* clapper_audio_stream_get_lang_name:
* @stream: a #ClapperAudioStream
*
* Get an ISO-639 language code of the @stream.
*
* Returns: (transfer full) (nullable): the language code of audio stream.
*/
gchar *
clapper_audio_stream_get_lang_name (ClapperAudioStream *self)
{
gchar *lang_name = NULL;
g_return_val_if_fail (CLAPPER_IS_AUDIO_STREAM (self), NULL);
GST_OBJECT_LOCK (self);
/* Prefer from code as its translated to user locale,
* otherwise try to fallback to the one sent in tags */
if (self->lang_code)
lang_name = g_strdup (gst_tag_get_language_name (self->lang_code));
if (!lang_name)
lang_name = g_strdup (self->lang_name);
GST_OBJECT_UNLOCK (self);
return lang_name;
}
static void
clapper_audio_stream_init (ClapperAudioStream *self)
{
}
static void
clapper_audio_stream_finalize (GObject *object)
{
ClapperAudioStream *self = CLAPPER_AUDIO_STREAM_CAST (object);
g_free (self->codec);
g_free (self->sample_format);
g_free (self->lang_code);
g_free (self->lang_name);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
clapper_audio_stream_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
ClapperAudioStream *self = CLAPPER_AUDIO_STREAM_CAST (object);
switch (prop_id) {
case PROP_CODEC:
g_value_take_string (value, clapper_audio_stream_get_codec (self));
break;
case PROP_BITRATE:
g_value_set_uint (value, clapper_audio_stream_get_bitrate (self));
break;
case PROP_SAMPLE_FORMAT:
g_value_take_string (value, clapper_audio_stream_get_sample_format (self));
break;
case PROP_SAMPLE_RATE:
g_value_set_int (value, clapper_audio_stream_get_sample_rate (self));
break;
case PROP_CHANNELS:
g_value_set_int (value, clapper_audio_stream_get_channels (self));
break;
case PROP_LANG_CODE:
g_value_take_string (value, clapper_audio_stream_get_lang_code (self));
break;
case PROP_LANG_NAME:
g_value_take_string (value, clapper_audio_stream_get_lang_name (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
clapper_audio_stream_internal_stream_updated (ClapperStream *stream,
GstCaps *caps, GstTagList *tags)
{
ClapperAudioStream *self = CLAPPER_AUDIO_STREAM_CAST (stream);
CLAPPER_STREAM_CLASS (parent_class)->internal_stream_updated (stream, caps, tags);
if (caps)
_update_using_caps (self, caps);
if (tags)
_update_using_tags (self, tags);
}
static void
clapper_audio_stream_class_init (ClapperAudioStreamClass *klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
ClapperStreamClass *stream_class = (ClapperStreamClass *) klass;
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "clapperaudiostream", 0,
"Clapper Audio Stream");
gobject_class->get_property = clapper_audio_stream_get_property;
gobject_class->finalize = clapper_audio_stream_finalize;
stream_class->internal_stream_updated = clapper_audio_stream_internal_stream_updated;
/**
* ClapperAudioStream:codec:
*
* Stream codec.
*/
param_specs[PROP_CODEC] = g_param_spec_string ("codec",
NULL, NULL, NULL,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* ClapperAudioStream:bitrate:
*
* Stream bitrate.
*/
param_specs[PROP_BITRATE] = g_param_spec_uint ("bitrate",
NULL, NULL, 0, G_MAXUINT, 0,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* ClapperAudioStream:sample-format:
*
* Stream sample format.
*/
param_specs[PROP_SAMPLE_FORMAT] = g_param_spec_string ("sample-format",
NULL, NULL, NULL,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* ClapperAudioStream:sample-rate:
*
* Stream sample rate (in Hz).
*/
param_specs[PROP_SAMPLE_RATE] = g_param_spec_int ("sample-rate",
NULL, NULL, 0, G_MAXINT, 0,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* ClapperAudioStream:channels:
*
* Stream number of audio channels.
*/
param_specs[PROP_CHANNELS] = g_param_spec_int ("channels",
NULL, NULL, 0, G_MAXINT, 0,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* ClapperAudioStream:lang-code:
*
* Stream language code in ISO-639 format.
*/
param_specs[PROP_LANG_CODE] = g_param_spec_string ("lang-code",
NULL, NULL, NULL,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* ClapperAudioStream:lang-name:
*
* Stream full language name determined from lang code.
*/
param_specs[PROP_LANG_NAME] = g_param_spec_string ("lang-name",
NULL, NULL, NULL,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, PROP_LAST, param_specs);
}

View File

@@ -0,0 +1,51 @@
/* Clapper Playback Library
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#if !defined(__CLAPPER_INSIDE__) && !defined(CLAPPER_COMPILATION)
#error "Only <clapper/clapper.h> can be included directly."
#endif
#include <glib.h>
#include <glib-object.h>
#include <clapper/clapper-stream.h>
G_BEGIN_DECLS
#define CLAPPER_TYPE_AUDIO_STREAM (clapper_audio_stream_get_type())
#define CLAPPER_AUDIO_STREAM_CAST(obj) ((ClapperAudioStream *)(obj))
G_DECLARE_FINAL_TYPE (ClapperAudioStream, clapper_audio_stream, CLAPPER, AUDIO_STREAM, ClapperStream)
gchar * clapper_audio_stream_get_codec (ClapperAudioStream *stream);
guint clapper_audio_stream_get_bitrate (ClapperAudioStream *stream);
gchar * clapper_audio_stream_get_sample_format (ClapperAudioStream *stream);
gint clapper_audio_stream_get_sample_rate (ClapperAudioStream *stream);
gint clapper_audio_stream_get_channels (ClapperAudioStream *stream);
gchar * clapper_audio_stream_get_lang_code (ClapperAudioStream *stream);
gchar * clapper_audio_stream_get_lang_name (ClapperAudioStream *stream);
G_END_DECLS

View File

@@ -0,0 +1,32 @@
/* Clapper Playback Library
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#include <glib.h>
G_BEGIN_DECLS
typedef struct
{
const gchar *name;
GQuark quark;
} ClapperBusQuark;
G_END_DECLS

View File

@@ -0,0 +1,69 @@
/* Clapper Playback Library
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#include <glib.h>
G_BEGIN_DECLS
typedef enum
{
CLAPPER_PLAYER_PLAY_FLAG_VIDEO = (1 << 0),
CLAPPER_PLAYER_PLAY_FLAG_AUDIO = (1 << 1),
CLAPPER_PLAYER_PLAY_FLAG_TEXT = (1 << 2),
CLAPPER_PLAYER_PLAY_FLAG_VIS = (1 << 3),
CLAPPER_PLAYER_PLAY_FLAG_SOFT_VOLUME = (1 << 4),
CLAPPER_PLAYER_PLAY_FLAG_NATIVE_AUDIO = (1 << 5),
CLAPPER_PLAYER_PLAY_FLAG_NATIVE_VIDEO = (1 << 6),
CLAPPER_PLAYER_PLAY_FLAG_DOWNLOAD = (1 << 7),
CLAPPER_PLAYER_PLAY_FLAG_BUFFERING = (1 << 8),
CLAPPER_PLAYER_PLAY_FLAG_DEINTERLACE = (1 << 9),
CLAPPER_PLAYER_PLAY_FLAG_SOFT_COLORBALANCE = (1 << 10),
CLAPPER_PLAYER_PLAY_FLAG_FORCE_FILTERS = (1 << 11),
CLAPPER_PLAYER_PLAY_FLAG_FORCE_SW_DECODERS = (1 << 12)
} ClapperPlayerPlayFlags;
typedef enum
{
CLAPPER_FEATURES_MANAGER_EVENT_UNKNOWN = 0,
CLAPPER_FEATURES_MANAGER_EVENT_FEATURE_ADDED,
CLAPPER_FEATURES_MANAGER_EVENT_FEATURE_PROPERTY_CHANGED,
CLAPPER_FEATURES_MANAGER_EVENT_STATE_CHANGED,
CLAPPER_FEATURES_MANAGER_EVENT_POSITION_CHANGED,
CLAPPER_FEATURES_MANAGER_EVENT_SPEED_CHANGED,
CLAPPER_FEATURES_MANAGER_EVENT_VOLUME_CHANGED,
CLAPPER_FEATURES_MANAGER_EVENT_MUTE_CHANGED,
CLAPPER_FEATURES_MANAGER_EVENT_PLAYED_ITEM_CHANGED,
CLAPPER_FEATURES_MANAGER_EVENT_ITEM_UPDATED,
CLAPPER_FEATURES_MANAGER_EVENT_QUEUE_ITEM_ADDED,
CLAPPER_FEATURES_MANAGER_EVENT_QUEUE_ITEM_REMOVED,
CLAPPER_FEATURES_MANAGER_EVENT_QUEUE_ITEM_REPOSITIONED,
CLAPPER_FEATURES_MANAGER_EVENT_QUEUE_CLEARED,
CLAPPER_FEATURES_MANAGER_EVENT_QUEUE_PROGRESSION_CHANGED
} ClapperFeaturesManagerEvent;
typedef enum
{
CLAPPER_QUEUE_ITEM_CHANGE_NORMAL = 1,
CLAPPER_QUEUE_ITEM_CHANGE_INSTANT = 2,
CLAPPER_QUEUE_ITEM_CHANGE_GAPLESS = 3,
} ClapperQueueItemChangeMode;
G_END_DECLS

View File

@@ -0,0 +1,130 @@
/* Clapper Playback Library
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#if !defined(__CLAPPER_INSIDE__) && !defined(CLAPPER_COMPILATION)
#error "Only <clapper/clapper.h> can be included directly."
#endif
#include <clapper/clapper-enum-types.h>
G_BEGIN_DECLS
/**
* ClapperPlayerState:
* @CLAPPER_PLAYER_STATE_STOPPED: Player is stopped.
* @CLAPPER_PLAYER_STATE_BUFFERING: Player is buffering.
* @CLAPPER_PLAYER_STATE_PAUSED: Player is paused.
* @CLAPPER_PLAYER_STATE_PLAYING: Player is playing.
*/
typedef enum
{
CLAPPER_PLAYER_STATE_STOPPED = 0,
CLAPPER_PLAYER_STATE_BUFFERING,
CLAPPER_PLAYER_STATE_PAUSED,
CLAPPER_PLAYER_STATE_PLAYING,
} ClapperPlayerState;
/**
* ClapperPlayerSeekMethod:
* @CLAPPER_PLAYER_SEEK_METHOD_ACCURATE: Seek to exact position (slow).
* @CLAPPER_PLAYER_SEEK_METHOD_NORMAL: Seek to approximated position.
* @CLAPPER_PLAYER_SEEK_METHOD_FAST: Seek to position of nearest keyframe (fast).
*/
typedef enum
{
CLAPPER_PLAYER_SEEK_METHOD_ACCURATE = 0,
CLAPPER_PLAYER_SEEK_METHOD_NORMAL,
CLAPPER_PLAYER_SEEK_METHOD_FAST,
} ClapperPlayerSeekMethod;
/**
* ClapperQueueProgressionMode:
* @CLAPPER_QUEUE_PROGRESSION_NONE: Queue will not change current item after playback finishes.
* @CLAPPER_QUEUE_PROGRESSION_CONSECUTIVE: Queue selects items one after another until the end.
* When end of queue is reached, this mode will continue one another item is added to the queue,
* playing it if player autoplay property is set, otherwise current player state is kept.
* @CLAPPER_QUEUE_PROGRESSION_REPEAT_ITEM: Queue keeps repeating current media item.
* @CLAPPER_QUEUE_PROGRESSION_CAROUSEL: Queue starts from beginning after last media item.
* @CLAPPER_QUEUE_PROGRESSION_SHUFFLE: Queue selects a random media item after current one.
* Shuffle mode will avoid reselecting previously shuffled items as long as possible.
* After it runs out of unused items, shuffling begins anew.
*/
typedef enum
{
CLAPPER_QUEUE_PROGRESSION_NONE = 0,
CLAPPER_QUEUE_PROGRESSION_CONSECUTIVE,
CLAPPER_QUEUE_PROGRESSION_REPEAT_ITEM,
CLAPPER_QUEUE_PROGRESSION_CAROUSEL,
CLAPPER_QUEUE_PROGRESSION_SHUFFLE,
} ClapperQueueProgressionMode;
/**
* ClapperMarkerType:
* @CLAPPER_MARKER_TYPE_UNKNOWN: Unknown marker type.
* @CLAPPER_MARKER_TYPE_TITLE: A title marker in timeline.
* @CLAPPER_MARKER_TYPE_CHAPTER: A chapter marker in timeline.
* @CLAPPER_MARKER_TYPE_TRACK: A track marker in timeline.
* @CLAPPER_STREAM_TYPE_CUSTOM_1: A custom marker 1 for free usage by application.
* @CLAPPER_STREAM_TYPE_CUSTOM_2: A custom marker 2 for free usage by application.
* @CLAPPER_STREAM_TYPE_CUSTOM_3: A custom marker 3 for free usage by application.
*/
typedef enum
{
CLAPPER_MARKER_TYPE_UNKNOWN = 0,
CLAPPER_MARKER_TYPE_TITLE,
CLAPPER_MARKER_TYPE_CHAPTER,
CLAPPER_MARKER_TYPE_TRACK,
CLAPPER_MARKER_TYPE_CUSTOM_1 = 101,
CLAPPER_MARKER_TYPE_CUSTOM_2 = 102,
CLAPPER_MARKER_TYPE_CUSTOM_3 = 103,
} ClapperMarkerType;
/**
* ClapperStreamType:
* @CLAPPER_STREAM_TYPE_UNKNOWN: Unknown stream type.
* @CLAPPER_STREAM_TYPE_VIDEO: Stream is a #ClapperVideoStream.
* @CLAPPER_STREAM_TYPE_AUDIO: Stream is a #ClapperAudioStream.
* @CLAPPER_STREAM_TYPE_SUBTITLE: Stream is a #ClapperSubtitleStream.
*/
typedef enum
{
CLAPPER_STREAM_TYPE_UNKNOWN = 0,
CLAPPER_STREAM_TYPE_VIDEO,
CLAPPER_STREAM_TYPE_AUDIO,
CLAPPER_STREAM_TYPE_SUBTITLE,
} ClapperStreamType;
/**
* ClapperDiscovererDiscoveryMode:
* @CLAPPER_DISCOVERER_DISCOVERY_ALWAYS: Run discovery for every single media item added to [class@Clapper.Queue].
* This mode is useful when application presents a list of items to select from to the user before playback.
* It will scan every single item in queue, so user can have an updated list of items when selecting what to play.
* @CLAPPER_DISCOVERER_DISCOVERY_NONCURRENT: Only run discovery on an item if it is not a currently selected item in [class@Clapper.Queue].
* This mode is optimal when application always plays (or at least goes into paused) after selecting item from queue.
* It will skip discovery of such items since they will be discovered by [class@Clapper.Player] anyway.
*/
typedef enum
{
CLAPPER_DISCOVERER_DISCOVERY_ALWAYS = 0,
CLAPPER_DISCOVERER_DISCOVERY_NONCURRENT,
} ClapperDiscovererDiscoveryMode;
G_END_DECLS

View File

@@ -0,0 +1,72 @@
/* Clapper Playback Library
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#include <clapper/clapper-feature.h>
#include <clapper/clapper-enums.h>
G_BEGIN_DECLS
G_GNUC_INTERNAL
void clapper_feature_call_prepare (ClapperFeature *feature);
G_GNUC_INTERNAL
void clapper_feature_call_unprepare (ClapperFeature *feature);
G_GNUC_INTERNAL
void clapper_feature_call_property_changed (ClapperFeature *feature, GParamSpec *pspec);
G_GNUC_INTERNAL
void clapper_feature_call_state_changed (ClapperFeature *feature, ClapperPlayerState state);
G_GNUC_INTERNAL
void clapper_feature_call_position_changed (ClapperFeature *feature, gdouble position);
G_GNUC_INTERNAL
void clapper_feature_call_speed_changed (ClapperFeature *feature, gdouble speed);
G_GNUC_INTERNAL
void clapper_feature_call_volume_changed (ClapperFeature *feature, gdouble volume);
G_GNUC_INTERNAL
void clapper_feature_call_mute_changed (ClapperFeature *feature, gboolean mute);
G_GNUC_INTERNAL
void clapper_feature_call_played_item_changed (ClapperFeature *feature, ClapperMediaItem *item);
G_GNUC_INTERNAL
void clapper_feature_call_item_updated (ClapperFeature *feature, ClapperMediaItem *item);
G_GNUC_INTERNAL
void clapper_feature_call_queue_item_added (ClapperFeature *feature, ClapperMediaItem *item, guint index);
G_GNUC_INTERNAL
void clapper_feature_call_queue_item_removed (ClapperFeature *feature, ClapperMediaItem *item, guint index);
G_GNUC_INTERNAL
void clapper_feature_call_queue_item_repositioned (ClapperFeature *self, guint before, guint after);
G_GNUC_INTERNAL
void clapper_feature_call_queue_cleared (ClapperFeature *feature);
G_GNUC_INTERNAL
void clapper_feature_call_queue_progression_changed (ClapperFeature *feature, ClapperQueueProgressionMode mode);
G_END_DECLS

View File

@@ -0,0 +1,225 @@
/* Clapper Playback Library
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* ClapperFeature:
*
* A base class for creating new features for the player.
*
* Feature objects are meant for adding additional functionalities that
* are supposed to either act on playback/properties changes and/or change
* them themselves due to some external signal/event.
*
* For reacting to playback changes subclass should override this class
* virtual functions logic, while for controlling playback implementation
* may call [method@Gst.Object.get_parent] to acquire a weak reference on
* a parent [class@Clapper.Player] object feature was added to.
*/
#include "clapper-feature.h"
#include "clapper-feature-private.h"
#include "clapper-player-private.h"
#define GST_CAT_DEFAULT clapper_feature_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
typedef struct _ClapperFeaturePrivate ClapperFeaturePrivate;
struct _ClapperFeaturePrivate
{
gboolean prepared;
};
#define parent_class clapper_feature_parent_class
G_DEFINE_TYPE_WITH_PRIVATE (ClapperFeature, clapper_feature, GST_TYPE_OBJECT);
#define CALL_WITH_ARGS(_feature,_vfunc,...) \
ClapperFeaturePrivate *priv = clapper_feature_get_instance_private (_feature); \
if (priv->prepared) { \
ClapperFeatureClass *feature_class = CLAPPER_FEATURE_GET_CLASS (_feature); \
if (feature_class->_vfunc) \
feature_class->_vfunc (_feature, __VA_ARGS__); }
#define CALL_WITHOUT_ARGS(_feature,_vfunc) \
ClapperFeaturePrivate *priv = clapper_feature_get_instance_private (_feature); \
if (priv->prepared) { \
ClapperFeatureClass *feature_class = CLAPPER_FEATURE_GET_CLASS (_feature); \
if (feature_class->_vfunc) \
feature_class->_vfunc (_feature); }
void
clapper_feature_call_prepare (ClapperFeature *self)
{
ClapperFeaturePrivate *priv = clapper_feature_get_instance_private (self);
if (!priv->prepared) {
ClapperFeatureClass *feature_class = CLAPPER_FEATURE_GET_CLASS (self);
gboolean prepared = TRUE; // mark subclass without prepare method as prepared
if (feature_class->prepare)
prepared = feature_class->prepare (self);
priv->prepared = prepared;
}
}
void
clapper_feature_call_unprepare (ClapperFeature *self)
{
ClapperFeaturePrivate *priv = clapper_feature_get_instance_private (self);
if (priv->prepared) {
ClapperFeatureClass *feature_class = CLAPPER_FEATURE_GET_CLASS (self);
gboolean unprepared = TRUE; // mark subclass without unprepare method as unprepared
if (feature_class->unprepare)
unprepared = feature_class->unprepare (self);
priv->prepared = !unprepared;
}
}
void
clapper_feature_call_property_changed (ClapperFeature *self, GParamSpec *pspec)
{
CALL_WITH_ARGS (self, property_changed, pspec);
}
void
clapper_feature_call_state_changed (ClapperFeature *self, ClapperPlayerState state)
{
CALL_WITH_ARGS (self, state_changed, state);
}
void
clapper_feature_call_position_changed (ClapperFeature *self, gdouble position)
{
CALL_WITH_ARGS (self, position_changed, position);
}
void
clapper_feature_call_speed_changed (ClapperFeature *self, gdouble speed)
{
CALL_WITH_ARGS (self, speed_changed, speed);
}
void
clapper_feature_call_volume_changed (ClapperFeature *self, gdouble volume)
{
CALL_WITH_ARGS (self, volume_changed, volume);
}
void
clapper_feature_call_mute_changed (ClapperFeature *self, gboolean mute)
{
CALL_WITH_ARGS (self, mute_changed, mute);
}
void
clapper_feature_call_played_item_changed (ClapperFeature *self, ClapperMediaItem *item)
{
CALL_WITH_ARGS (self, played_item_changed, item);
}
void
clapper_feature_call_item_updated (ClapperFeature *self, ClapperMediaItem *item)
{
CALL_WITH_ARGS (self, item_updated, item);
}
void
clapper_feature_call_queue_item_added (ClapperFeature *self, ClapperMediaItem *item, guint index)
{
CALL_WITH_ARGS (self, queue_item_added, item, index);
}
void
clapper_feature_call_queue_item_removed (ClapperFeature *self, ClapperMediaItem *item, guint index)
{
CALL_WITH_ARGS (self, queue_item_removed, item, index);
}
void
clapper_feature_call_queue_item_repositioned (ClapperFeature *self, guint before, guint after)
{
CALL_WITH_ARGS (self, queue_item_repositioned, before, after);
}
void
clapper_feature_call_queue_cleared (ClapperFeature *self)
{
CALL_WITHOUT_ARGS (self, queue_cleared);
}
void
clapper_feature_call_queue_progression_changed (ClapperFeature *self, ClapperQueueProgressionMode mode)
{
CALL_WITH_ARGS (self, queue_progression_changed, mode);
}
static void
clapper_feature_init (ClapperFeature *self)
{
}
static void
clapper_feature_dispatch_properties_changed (GObject *object,
guint n_pspecs, GParamSpec **pspecs)
{
ClapperPlayer *player;
if ((player = CLAPPER_PLAYER_CAST (gst_object_get_parent (GST_OBJECT_CAST (object))))) {
ClapperFeaturesManager *features_manager;
if ((features_manager = clapper_player_get_features_manager (player))) {
guint i;
for (i = 0; i < n_pspecs; ++i) {
clapper_features_manager_trigger_property_changed (features_manager,
CLAPPER_FEATURE_CAST (object), pspecs[i]);
}
}
gst_object_unref (player);
}
G_OBJECT_CLASS (parent_class)->dispatch_properties_changed (object, n_pspecs, pspecs);
}
static void
clapper_feature_finalize (GObject *object)
{
ClapperFeature *self = CLAPPER_FEATURE_CAST (object);
GST_TRACE_OBJECT (self, "Finalize");
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
clapper_feature_class_init (ClapperFeatureClass *klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "clapperfeature", 0,
"Clapper Feature");
gobject_class->dispatch_properties_changed = clapper_feature_dispatch_properties_changed;
gobject_class->finalize = clapper_feature_finalize;
}

View File

@@ -0,0 +1,219 @@
/* Clapper Playback Library
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#if !defined(__CLAPPER_INSIDE__) && !defined(CLAPPER_COMPILATION)
#error "Only <clapper/clapper.h> can be included directly."
#endif
#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <gst/gst.h>
#include <clapper/clapper-media-item.h>
#include <clapper/clapper-enums.h>
G_BEGIN_DECLS
#define CLAPPER_TYPE_FEATURE (clapper_feature_get_type())
#define CLAPPER_FEATURE_CAST(obj) ((ClapperFeature *)(obj))
G_DECLARE_DERIVABLE_TYPE (ClapperFeature, clapper_feature, CLAPPER, FEATURE, GstObject)
/**
* ClapperFeatureClass:
* @parent_class: The object class structure.
* @prepare: Prepare feature for operation (optional).
* @unprepare: Revert the changes done in @prepare (optional).
* @property_changed: A property of @feature changed its value.
* @state_changed: Player state was changed.
* @position_changed: Player position was changed.
* @speed_changed: Player speed was changed.
* @volume_changed: Player volume was changed.
* @mute_changed: Player mute state was changed.
* @played_item_changed: Currently playing media item got changed.
* @item_updated: An item in queue got updated.
* @queue_item_added: An item was added to the queue.
* @queue_item_removed: An item was removed from queue.
* @queue_item_reposition: An item changed position within queue.
* @queue_cleared: All items were removed from queue.
* @queue_progression_changed: Progression mode of the queue was changed.
*/
struct _ClapperFeatureClass
{
GstObjectClass parent_class;
/**
* ClapperFeatureClass::prepare:
* @feature: a #ClapperFeature
*
* Prepare feature for operation (optional).
*
* This is different from init() as its called from features thread once
* feature is added to the player, so it can already access it parent using
* gst_object_get_parent(). If it fails, no other method will be called.
*
* Returns: %TRUE on success, %FALSE otherwise.
*/
gboolean (* prepare) (ClapperFeature *feature);
/**
* ClapperFeatureClass::unprepare:
* @feature: a #ClapperFeature
*
* Revert the changes done in @prepare (optional).
*
* Returns: %TRUE on success, %FALSE otherwise.
*/
gboolean (* unprepare) (ClapperFeature *feature);
/**
* ClapperFeatureClass::property_changed:
* @feature: a #ClapperFeature
* @pspec: a #GParamSpec
*
* A property of @feature changed its value.
*
* Useful for reconfiguring @feature, since unlike "notify" signal
* this is always called from the thread that feature works on and
* only after feature was prepared.
*/
void (* property_changed) (ClapperFeature *feature, GParamSpec *pspec);
/**
* ClapperFeatureClass::state_changed:
* @feature: a #ClapperFeature
* @state: a #ClapperPlayerState
*
* Player state was changed.
*/
void (* state_changed) (ClapperFeature *feature, ClapperPlayerState state);
/**
* ClapperFeatureClass::position_changed:
* @feature: a #ClapperFeature
* @position: a decimal number with current position in seconds
*
* Player position was changed.
*/
void (* position_changed) (ClapperFeature *feature, gdouble position);
/**
* ClapperFeatureClass::speed_changed:
* @feature: a #ClapperFeature
* @speed: the playback speed multiplier
*
* Player speed was changed.
*/
void (* speed_changed) (ClapperFeature *feature, gdouble speed);
/**
* ClapperFeatureClass::volume_changed:
* @feature: a #ClapperFeature
* @volume: the volume level
*
* Player volume was changed.
*/
void (* volume_changed) (ClapperFeature *feature, gdouble volume);
/**
* ClapperFeatureClass::mute_changed:
* @feature: a #ClapperFeature
* @mute: %TRUE if player is muted, %FALSE otherwise
*
* Player mute state was changed.
*/
void (* mute_changed) (ClapperFeature *feature, gboolean mute);
/**
* ClapperFeatureClass::played_item_changed:
* @feature: a #ClapperFeature
* @item: a #ClapperMediaItem that is now playing
*
* New media item started playing. All following events (such as position changes)
* will be related to this @item from now on.
*/
void (* played_item_changed) (ClapperFeature *feature, ClapperMediaItem *item);
/**
* ClapperFeatureClass::item_updated:
* @feature: a #ClapperFeature
* @item: a #ClapperMediaItem that was updated
*
* An item in queue got updated. This might be (or not) currently
* played item. Implementations can get parent player object
* if they want to check that from its queue.
*/
void (* item_updated) (ClapperFeature *feature, ClapperMediaItem *item);
/**
* ClapperFeatureClass::queue_item_added:
* @feature: a #ClapperFeature
* @item: a #ClapperMediaItem that was added
* @index: position at which @item was placed in queue
*
* An item was added to the queue.
*/
void (* queue_item_added) (ClapperFeature *feature, ClapperMediaItem *item, guint index);
/**
* ClapperFeatureClass::queue_item_removed:
* @feature: a #ClapperFeature
* @item: a #ClapperMediaItem that was removed
* @index: position from which @item was removed in queue
*
* An item was removed from queue.
*/
void (* queue_item_removed) (ClapperFeature *feature, ClapperMediaItem *item, guint index);
/**
* ClapperFeatureClass::queue_item_reposition:
* @feature: a #ClapperFeature
* @before: position from which #ClapperMediaItem was removed
* @after: position at which #ClapperMediaItem was inserted after removal
*
* An item changed position within queue.
*/
void (* queue_item_repositioned) (ClapperFeature *feature, guint before, guint after);
/**
* ClapperFeatureClass::queue_cleared:
* @feature: a #ClapperFeature
*
* All items were removed from queue. Note that in such event
* @queue_item_removed will NOT be called for each item for performance reasons.
* You probably want to implement this function if you also implemented item removal.
*/
void (* queue_cleared) (ClapperFeature *feature);
/**
* ClapperFeatureClass::queue_progression_changed:
* @feature: a #ClapperFeature
* @mode: a #ClapperQueueProgressionMode
*
* Progression mode of the queue was changed.
*/
void (* queue_progression_changed) (ClapperFeature *feature, ClapperQueueProgressionMode mode);
/*< private >*/
gpointer padding[8];
};
G_END_DECLS

View File

@@ -0,0 +1,44 @@
/* Clapper Playback Library
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#include <gst/gst.h>
#include <glib-object.h>
#include "clapper-features-manager-private.h"
#include "clapper-enums-private.h"
G_BEGIN_DECLS
#define CLAPPER_TYPE_FEATURES_BUS (clapper_features_bus_get_type())
#define CLAPPER_FEATURES_BUS_CAST(obj) ((ClapperFeaturesBus *)(obj))
/**
* ClapperFeaturesBus:
*/
G_DECLARE_FINAL_TYPE (ClapperFeaturesBus, clapper_features_bus, CLAPPER, FEATURES_BUS, GstBus)
void clapper_features_bus_initialize (void);
ClapperFeaturesBus * clapper_features_bus_new (void);
void clapper_features_bus_post_event (ClapperFeaturesBus *features_bus, ClapperFeaturesManager *src, ClapperFeaturesManagerEvent event, GValue *value, GValue *extra_value);
G_END_DECLS

View File

@@ -0,0 +1,168 @@
/* Clapper Playback Library
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "clapper-bus-private.h"
#include "clapper-features-manager-private.h"
#include "clapper-features-bus-private.h"
#define GST_CAT_DEFAULT clapper_features_bus_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
struct _ClapperFeaturesBus
{
GstBus parent;
};
#define parent_class clapper_features_bus_parent_class
G_DEFINE_TYPE (ClapperFeaturesBus, clapper_features_bus, GST_TYPE_BUS);
enum
{
CLAPPER_FEATURES_BUS_STRUCTURE_UNKNOWN = 0,
CLAPPER_FEATURES_BUS_STRUCTURE_EVENT
};
static ClapperBusQuark _structure_quarks[] = {
{"unknown", 0},
{"event", 0},
{NULL, 0}
};
enum
{
CLAPPER_FEATURES_BUS_FIELD_UNKNOWN = 0,
CLAPPER_FEATURES_BUS_FIELD_EVENT,
CLAPPER_FEATURES_BUS_FIELD_VALUE,
CLAPPER_FEATURES_BUS_FIELD_EXTRA_VALUE
};
static ClapperBusQuark _field_quarks[] = {
{"unknown", 0},
{"event", 0},
{"value", 0},
{"extra-value", 0},
{NULL, 0}
};
#define _STRUCTURE_QUARK(q) (_structure_quarks[CLAPPER_FEATURES_BUS_STRUCTURE_##q].quark)
#define _FIELD_QUARK(q) (_field_quarks[CLAPPER_FEATURES_BUS_FIELD_##q].quark)
#define _MESSAGE_SRC_CLAPPER_FEATURES_MANAGER(msg) ((ClapperFeaturesManager *) GST_MESSAGE_SRC (msg))
void
clapper_features_bus_initialize (void)
{
gint i;
for (i = 0; _structure_quarks[i].name; ++i)
_structure_quarks[i].quark = g_quark_from_static_string (_structure_quarks[i].name);
for (i = 0; _field_quarks[i].name; ++i)
_field_quarks[i].quark = g_quark_from_static_string (_field_quarks[i].name);
}
void
clapper_features_bus_post_event (ClapperFeaturesBus *self,
ClapperFeaturesManager *src, ClapperFeaturesManagerEvent event,
GValue *value, GValue *extra_value)
{
GstStructure *structure = gst_structure_new_id (_STRUCTURE_QUARK (EVENT),
_FIELD_QUARK (EVENT), G_TYPE_ENUM, event,
NULL);
if (value)
gst_structure_id_take_value (structure, _FIELD_QUARK (VALUE), value);
if (extra_value)
gst_structure_id_take_value (structure, _FIELD_QUARK (EXTRA_VALUE), extra_value);
gst_bus_post (GST_BUS_CAST (self), gst_message_new_application (
GST_OBJECT_CAST (src), structure));
}
static inline void
_handle_event_msg (GstMessage *msg, const GstStructure *structure,
ClapperFeaturesManager *features_manager)
{
ClapperFeaturesManagerEvent event = CLAPPER_FEATURES_MANAGER_EVENT_UNKNOWN;
const GValue *value = gst_structure_id_get_value (structure, _FIELD_QUARK (VALUE));
const GValue *extra_value = gst_structure_id_get_value (structure, _FIELD_QUARK (EXTRA_VALUE));
gst_structure_id_get (structure,
_FIELD_QUARK (EVENT), G_TYPE_ENUM, &event,
NULL);
clapper_features_manager_handle_event (features_manager, event, value, extra_value);
}
static gboolean
clapper_features_bus_message_func (GstBus *bus, GstMessage *msg, gpointer user_data G_GNUC_UNUSED)
{
if (G_LIKELY (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_APPLICATION)) {
ClapperFeaturesManager *features_manager = _MESSAGE_SRC_CLAPPER_FEATURES_MANAGER (msg);
const GstStructure *structure = gst_message_get_structure (msg);
GQuark quark = gst_structure_get_name_id (structure);
if (quark == _STRUCTURE_QUARK (EVENT))
_handle_event_msg (msg, structure, features_manager);
}
return G_SOURCE_CONTINUE;
}
/*
* clapper_features_bus_new:
*
* Returns: (transfer full): a new #ClapperFeaturesBus instance.
*/
ClapperFeaturesBus *
clapper_features_bus_new (void)
{
GstBus *features_bus;
features_bus = GST_BUS_CAST (g_object_new (CLAPPER_TYPE_FEATURES_BUS, NULL));
gst_object_ref_sink (features_bus);
gst_bus_add_watch (features_bus, (GstBusFunc) clapper_features_bus_message_func, NULL);
return CLAPPER_FEATURES_BUS_CAST (features_bus);
}
static void
clapper_features_bus_init (ClapperFeaturesBus *self)
{
}
static void
clapper_features_bus_finalize (GObject *object)
{
ClapperFeaturesBus *self = CLAPPER_FEATURES_BUS_CAST (object);
GST_TRACE_OBJECT (self, "Finalize");
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
clapper_features_bus_class_init (ClapperFeaturesBusClass *klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "clapperfeaturesbus", 0,
"Clapper Features Bus");
gobject_class->finalize = clapper_features_bus_finalize;
}

View File

@@ -0,0 +1,81 @@
/* Clapper Playback Library
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#include "clapper-enums-private.h"
#include "clapper-threaded-object.h"
#include "clapper-feature.h"
G_BEGIN_DECLS
#define CLAPPER_TYPE_FEATURES_MANAGER (clapper_features_manager_get_type())
#define CLAPPER_FEATURES_MANAGER_CAST(obj) ((ClapperFeaturesManager *)(obj))
G_DECLARE_FINAL_TYPE (ClapperFeaturesManager, clapper_features_manager, CLAPPER, FEATURES_MANAGER, ClapperThreadedObject)
G_GNUC_INTERNAL
ClapperFeaturesManager * clapper_features_manager_new (void);
G_GNUC_INTERNAL
void clapper_features_manager_add_feature (ClapperFeaturesManager *features, ClapperFeature *feature, GstObject *parent);
G_GNUC_INTERNAL
void clapper_features_manager_trigger_property_changed (ClapperFeaturesManager *self, ClapperFeature *feature, GParamSpec *pspec);
G_GNUC_INTERNAL
void clapper_features_manager_trigger_state_changed (ClapperFeaturesManager *features, ClapperPlayerState state);
G_GNUC_INTERNAL
void clapper_features_manager_trigger_position_changed (ClapperFeaturesManager *features, gdouble position);
G_GNUC_INTERNAL
void clapper_features_manager_trigger_speed_changed (ClapperFeaturesManager *features, gdouble speed);
G_GNUC_INTERNAL
void clapper_features_manager_trigger_volume_changed (ClapperFeaturesManager *features, gdouble volume);
G_GNUC_INTERNAL
void clapper_features_manager_trigger_mute_changed (ClapperFeaturesManager *features, gboolean mute);
G_GNUC_INTERNAL
void clapper_features_manager_trigger_played_item_changed (ClapperFeaturesManager *features, ClapperMediaItem *item);
G_GNUC_INTERNAL
void clapper_features_manager_trigger_item_updated (ClapperFeaturesManager *features, ClapperMediaItem *item);
G_GNUC_INTERNAL
void clapper_features_manager_trigger_queue_item_added (ClapperFeaturesManager *features, ClapperMediaItem *item, guint index);
G_GNUC_INTERNAL
void clapper_features_manager_trigger_queue_item_removed (ClapperFeaturesManager *features, ClapperMediaItem *item, guint index);
G_GNUC_INTERNAL
void clapper_features_manager_trigger_queue_item_repositioned (ClapperFeaturesManager *features, guint before, guint after);
G_GNUC_INTERNAL
void clapper_features_manager_trigger_queue_cleared (ClapperFeaturesManager *features);
G_GNUC_INTERNAL
void clapper_features_manager_trigger_queue_progression_changed (ClapperFeaturesManager *features, ClapperQueueProgressionMode mode);
G_GNUC_INTERNAL
void clapper_features_manager_handle_event (ClapperFeaturesManager *features, ClapperFeaturesManagerEvent event, const GValue *value, const GValue *extra_value);
G_END_DECLS

View File

@@ -0,0 +1,371 @@
/* Clapper Playback Library
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "clapper-features-manager-private.h"
#include "clapper-features-bus-private.h"
#include "clapper-feature-private.h"
#define GST_CAT_DEFAULT clapper_features_manager_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
struct _ClapperFeaturesManager
{
ClapperThreadedObject parent;
GPtrArray *features;
ClapperFeaturesBus *bus;
};
#define parent_class clapper_features_manager_parent_class
G_DEFINE_TYPE (ClapperFeaturesManager, clapper_features_manager, CLAPPER_TYPE_THREADED_OBJECT);
static inline void
_post_object (ClapperFeaturesManager *self, ClapperFeaturesManagerEvent event, GObject *data)
{
GValue value = G_VALUE_INIT;
g_value_init (&value, G_TYPE_OBJECT);
g_value_set_object (&value, data);
clapper_features_bus_post_event (self->bus, self, event, &value, NULL);
}
static inline void
_post_int (ClapperFeaturesManager *self, ClapperFeaturesManagerEvent event, gint data)
{
GValue value = G_VALUE_INIT;
g_value_init (&value, G_TYPE_INT);
g_value_set_int (&value, data);
clapper_features_bus_post_event (self->bus, self, event, &value, NULL);
}
static inline void
_post_double (ClapperFeaturesManager *self, ClapperFeaturesManagerEvent event, gdouble data)
{
GValue value = G_VALUE_INIT;
g_value_init (&value, G_TYPE_DOUBLE);
g_value_set_double (&value, data);
clapper_features_bus_post_event (self->bus, self, event, &value, NULL);
}
static inline void
_post_boolean (ClapperFeaturesManager *self, ClapperFeaturesManagerEvent event, gboolean data)
{
GValue value = G_VALUE_INIT;
g_value_init (&value, G_TYPE_BOOLEAN);
g_value_set_boolean (&value, data);
clapper_features_bus_post_event (self->bus, self, event, &value, NULL);
}
static inline void
_post_item_added_or_removed (ClapperFeaturesManager *self, ClapperFeaturesManagerEvent event,
ClapperMediaItem *item, guint index)
{
GValue value = G_VALUE_INIT;
GValue extra_value = G_VALUE_INIT;
g_value_init (&value, G_TYPE_OBJECT);
g_value_set_object (&value, (GObject *) item);
g_value_init (&extra_value, G_TYPE_UINT);
g_value_set_uint (&extra_value, index);
clapper_features_bus_post_event (self->bus, self, event, &value, &extra_value);
}
static inline void
_post_item_reposition (ClapperFeaturesManager *self, guint data_1, guint data_2)
{
GValue value = G_VALUE_INIT;
GValue extra_value = G_VALUE_INIT;
g_value_init (&value, G_TYPE_UINT);
g_value_set_uint (&value, data_1);
g_value_init (&extra_value, G_TYPE_UINT);
g_value_set_uint (&extra_value, data_2);
clapper_features_bus_post_event (self->bus, self,
CLAPPER_FEATURES_MANAGER_EVENT_QUEUE_ITEM_REPOSITIONED, &value, &extra_value);
}
/*
* clapper_features_manager_new:
*
* Returns: (transfer full): a new #ClapperFeaturesManager instance.
*/
ClapperFeaturesManager *
clapper_features_manager_new (void)
{
ClapperFeaturesManager *features_manager;
features_manager = g_object_new (CLAPPER_TYPE_FEATURES_MANAGER, NULL);
gst_object_ref_sink (features_manager);
return features_manager;
}
void
clapper_features_manager_add_feature (ClapperFeaturesManager *self, ClapperFeature *feature, GstObject *parent)
{
GValue value = G_VALUE_INIT;
GValue extra_value = G_VALUE_INIT;
g_value_init (&value, G_TYPE_OBJECT);
g_value_set_object (&value, G_OBJECT (feature));
g_value_init (&extra_value, G_TYPE_OBJECT);
g_value_set_object (&extra_value, G_OBJECT (parent));
clapper_features_bus_post_event (self->bus, self,
CLAPPER_FEATURES_MANAGER_EVENT_FEATURE_ADDED, &value, &extra_value);
}
void
clapper_features_manager_trigger_property_changed (ClapperFeaturesManager *self, ClapperFeature *feature, GParamSpec *pspec)
{
GValue value = G_VALUE_INIT;
GValue extra_value = G_VALUE_INIT;
g_value_init (&value, G_TYPE_OBJECT);
g_value_set_object (&value, G_OBJECT (feature));
g_value_init (&extra_value, G_TYPE_PARAM);
g_value_set_param (&extra_value, pspec);
clapper_features_bus_post_event (self->bus, self,
CLAPPER_FEATURES_MANAGER_EVENT_FEATURE_PROPERTY_CHANGED, &value, &extra_value);
}
void
clapper_features_manager_trigger_state_changed (ClapperFeaturesManager *self, ClapperPlayerState state)
{
_post_int (self, CLAPPER_FEATURES_MANAGER_EVENT_STATE_CHANGED, state);
}
void
clapper_features_manager_trigger_position_changed (ClapperFeaturesManager *self, gdouble position)
{
_post_double (self, CLAPPER_FEATURES_MANAGER_EVENT_POSITION_CHANGED, position);
}
void
clapper_features_manager_trigger_speed_changed (ClapperFeaturesManager *self, gdouble speed)
{
_post_double (self, CLAPPER_FEATURES_MANAGER_EVENT_SPEED_CHANGED, speed);
}
void
clapper_features_manager_trigger_volume_changed (ClapperFeaturesManager *self, gdouble volume)
{
_post_double (self, CLAPPER_FEATURES_MANAGER_EVENT_VOLUME_CHANGED, volume);
}
void
clapper_features_manager_trigger_mute_changed (ClapperFeaturesManager *self, gboolean mute)
{
_post_boolean (self, CLAPPER_FEATURES_MANAGER_EVENT_MUTE_CHANGED, mute);
}
void
clapper_features_manager_trigger_played_item_changed (ClapperFeaturesManager *self, ClapperMediaItem *item)
{
_post_object (self, CLAPPER_FEATURES_MANAGER_EVENT_PLAYED_ITEM_CHANGED, (GObject *) item);
}
void
clapper_features_manager_trigger_item_updated (ClapperFeaturesManager *self, ClapperMediaItem *item)
{
_post_object (self, CLAPPER_FEATURES_MANAGER_EVENT_ITEM_UPDATED, (GObject *) item);
}
void
clapper_features_manager_trigger_queue_item_added (ClapperFeaturesManager *self, ClapperMediaItem *item, guint index)
{
_post_item_added_or_removed (self, CLAPPER_FEATURES_MANAGER_EVENT_QUEUE_ITEM_ADDED, item, index);
}
void
clapper_features_manager_trigger_queue_item_removed (ClapperFeaturesManager *self, ClapperMediaItem *item, guint index)
{
_post_item_added_or_removed (self, CLAPPER_FEATURES_MANAGER_EVENT_QUEUE_ITEM_REMOVED, item, index);
}
void
clapper_features_manager_trigger_queue_item_repositioned (ClapperFeaturesManager *self, guint before, guint after)
{
_post_item_reposition (self, before, after);
}
void
clapper_features_manager_trigger_queue_cleared (ClapperFeaturesManager *self)
{
clapper_features_bus_post_event (self->bus, self, CLAPPER_FEATURES_MANAGER_EVENT_QUEUE_CLEARED, NULL, NULL);
}
void
clapper_features_manager_trigger_queue_progression_changed (ClapperFeaturesManager *self, ClapperQueueProgressionMode mode)
{
_post_int (self, CLAPPER_FEATURES_MANAGER_EVENT_QUEUE_PROGRESSION_CHANGED, mode);
}
void
clapper_features_manager_handle_event (ClapperFeaturesManager *self, ClapperFeaturesManagerEvent event,
const GValue *value, const GValue *extra_value)
{
guint i;
switch (event) {
case CLAPPER_FEATURES_MANAGER_EVENT_FEATURE_ADDED:{
ClapperFeature *feature = g_value_get_object (value);
GstObject *parent = g_value_get_object (extra_value);
if (!g_ptr_array_find (self->features, feature, NULL)) {
g_ptr_array_add (self->features, gst_object_ref (feature));
gst_object_set_parent (GST_OBJECT_CAST (feature), parent);
clapper_feature_call_prepare (feature);
}
/* Nothing more to do */
return;
}
default:
break;
}
for (i = 0; i < self->features->len; ++i) {
ClapperFeature *feature = g_ptr_array_index (self->features, i);
switch (event) {
case CLAPPER_FEATURES_MANAGER_EVENT_FEATURE_PROPERTY_CHANGED:{
ClapperFeature *event_feature = g_value_get_object (value);
if (feature == event_feature) {
clapper_feature_call_property_changed (feature,
g_value_get_param (extra_value));
}
break;
}
case CLAPPER_FEATURES_MANAGER_EVENT_STATE_CHANGED:
clapper_feature_call_state_changed (feature, g_value_get_int (value));
break;
case CLAPPER_FEATURES_MANAGER_EVENT_POSITION_CHANGED:
clapper_feature_call_position_changed (feature, g_value_get_double (value));
break;
case CLAPPER_FEATURES_MANAGER_EVENT_SPEED_CHANGED:
clapper_feature_call_speed_changed (feature, g_value_get_double (value));
break;
case CLAPPER_FEATURES_MANAGER_EVENT_VOLUME_CHANGED:
clapper_feature_call_volume_changed (feature, g_value_get_double (value));
break;
case CLAPPER_FEATURES_MANAGER_EVENT_MUTE_CHANGED:
clapper_feature_call_mute_changed (feature, g_value_get_boolean (value));
break;
case CLAPPER_FEATURES_MANAGER_EVENT_PLAYED_ITEM_CHANGED:
clapper_feature_call_played_item_changed (feature,
CLAPPER_MEDIA_ITEM_CAST (g_value_get_object (value)));
break;
case CLAPPER_FEATURES_MANAGER_EVENT_ITEM_UPDATED:
clapper_feature_call_item_updated (feature,
CLAPPER_MEDIA_ITEM_CAST (g_value_get_object (value)));
break;
case CLAPPER_FEATURES_MANAGER_EVENT_QUEUE_ITEM_ADDED:
clapper_feature_call_queue_item_added (feature,
CLAPPER_MEDIA_ITEM_CAST (g_value_get_object (value)),
g_value_get_uint (extra_value));
break;
case CLAPPER_FEATURES_MANAGER_EVENT_QUEUE_ITEM_REMOVED:
clapper_feature_call_queue_item_removed (feature,
CLAPPER_MEDIA_ITEM_CAST (g_value_get_object (value)),
g_value_get_uint (extra_value));
break;
case CLAPPER_FEATURES_MANAGER_EVENT_QUEUE_ITEM_REPOSITIONED:
clapper_feature_call_queue_item_repositioned (feature,
g_value_get_uint (value),
g_value_get_uint (extra_value));
break;
case CLAPPER_FEATURES_MANAGER_EVENT_QUEUE_CLEARED:
clapper_feature_call_queue_cleared (feature);
break;
case CLAPPER_FEATURES_MANAGER_EVENT_QUEUE_PROGRESSION_CHANGED:
clapper_feature_call_queue_progression_changed (feature, g_value_get_int (value));
break;
default:
break;
}
}
}
static void
clapper_features_manager_thread_start (ClapperThreadedObject *threaded_object)
{
ClapperFeaturesManager *self = CLAPPER_FEATURES_MANAGER_CAST (threaded_object);
GST_TRACE_OBJECT (threaded_object, "Features manager thread start");
self->features = g_ptr_array_new_with_free_func (
(GDestroyNotify) gst_object_unref);
self->bus = clapper_features_bus_new ();
}
static void
clapper_features_manager_thread_stop (ClapperThreadedObject *threaded_object)
{
ClapperFeaturesManager *self = CLAPPER_FEATURES_MANAGER_CAST (threaded_object);
guint i;
GST_TRACE_OBJECT (threaded_object, "Features manager thread stop");
gst_bus_set_flushing (GST_BUS_CAST (self->bus), TRUE);
gst_bus_remove_watch (GST_BUS_CAST (self->bus));
gst_clear_object (&self->bus);
for (i = 0; i < self->features->len; ++i) {
ClapperFeature *feature = g_ptr_array_index (self->features, i);
clapper_feature_call_unprepare (feature);
gst_object_unparent (GST_OBJECT_CAST (feature));
}
g_ptr_array_unref (self->features);
}
static void
clapper_features_manager_init (ClapperFeaturesManager *self)
{
}
static void
clapper_features_manager_class_init (ClapperFeaturesManagerClass *klass)
{
ClapperThreadedObjectClass *threaded_object = (ClapperThreadedObjectClass *) klass;
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "clapperfeaturesmanager", 0,
"Clapper Features Manager");
threaded_object->thread_start = clapper_features_manager_thread_start;
threaded_object->thread_stop = clapper_features_manager_thread_stop;
}

View File

@@ -0,0 +1,35 @@
/* Clapper Playback Library
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#include <glib.h>
#include "clapper-enums.h"
#include "clapper-marker.h"
G_BEGIN_DECLS
G_GNUC_INTERNAL
ClapperMarker * clapper_marker_new_internal (ClapperMarkerType marker_type, const gchar *name, gdouble start, gdouble end);
G_GNUC_INTERNAL
gboolean clapper_marker_is_internal (ClapperMarker *marker);
G_END_DECLS

View File

@@ -0,0 +1,338 @@
/* Clapper Playback Library
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* ClapperMarker:
*
* Represents a point in timeline.
*
* Markers are a convienient way of marking points of interest within a
* [class@Clapper.Timeline] of [class@Clapper.MediaItem]. Use them
* to indicate certain areas on the timeline.
*
* Markers are reference counted immutable objects. Once a marker is created
* it can only be inserted into a single [class@Clapper.Timeline] at a time.
*
* Please note that markers are independent of [property@Clapper.MediaItem:duration]
* and applications should not assume that all markers must have start/end times
* lower or equal the item duration. This is not the case in e.g. live streams
* where duration is unknown, but markers are still allowed to mark entries
* (like EPG titles for example).
*
* Remember that [class@Clapper.Player] will also automatically insert certain
* markers extracted from media such as video chapters. Clapper will never
* "touch" the ones created by the application. If you want to differentiate
* your own markers, applications can define and create markers with one of
* the custom types from [enum@Clapper.MarkerType] enum.
*
* Example:
*
* ```c
* #define MY_APP_MARKER (CLAPPER_MARKER_TYPE_CUSTOM_1)
*
* ClapperMarker *marker = clapper_marker_new (MY_APP_MARKER, title, start, end);
* ```
*
* ```c
* ClapperMarkerType marker_type = clapper_marker_get_marker_type (marker);
*
* if (marker_type == MY_APP_MARKER) {
* // Do something with your custom marker
* }
* ```
*/
#include "clapper-marker-private.h"
#define GST_CAT_DEFAULT clapper_marker_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
struct _ClapperMarker
{
GstObject parent;
ClapperMarkerType marker_type;
gchar *title;
gdouble start;
gdouble end;
gboolean is_internal;
};
enum
{
PROP_0,
PROP_MARKER_TYPE,
PROP_TITLE,
PROP_START,
PROP_END,
PROP_LAST
};
#define parent_class clapper_marker_parent_class
G_DEFINE_TYPE (ClapperMarker, clapper_marker, GST_TYPE_OBJECT);
static GParamSpec *param_specs[PROP_LAST] = { NULL, };
/**
* clapper_marker_new:
* @marker_type: a #ClapperMarkerType
* @title: (nullable): title of the marker
* @start: a start position of the marker
* @end: an end position of the marker or [const@Clapper.MARKER_NO_END] if none
*
* Creates a new #ClapperMarker with given params.
*
* It is considered a programmer error trying to set an ending
* point that is before the starting one. If end is unknown or
* not defined a special [const@Clapper.MARKER_NO_END] value
* should be used.
*
* Returns: (transfer full): a new #ClapperMarker.
*/
ClapperMarker *
clapper_marker_new (ClapperMarkerType marker_type, const gchar *title,
gdouble start, gdouble end)
{
ClapperMarker *marker;
marker = g_object_new (CLAPPER_TYPE_MARKER,
"marker-type", marker_type,
"title", title,
"start", start,
"end", end, NULL);
gst_object_ref_sink (marker);
return marker;
}
ClapperMarker *
clapper_marker_new_internal (ClapperMarkerType marker_type, const gchar *title,
gdouble start, gdouble end)
{
ClapperMarker *marker;
marker = clapper_marker_new (marker_type, title, start, end);
marker->is_internal = TRUE;
return marker;
}
/**
* clapper_marker_get_marker_type:
* @marker: a #ClapperMarker
*
* Get the #ClapperMarkerType of @marker.
*
* Returns: type of marker.
*/
ClapperMarkerType
clapper_marker_get_marker_type (ClapperMarker *self)
{
g_return_val_if_fail (CLAPPER_IS_MARKER (self), CLAPPER_MARKER_TYPE_UNKNOWN);
return self->marker_type;
}
/**
* clapper_marker_get_title:
* @marker: a #ClapperMarker
*
* Get the title of @marker.
*
* Returns: the marker title.
*/
const gchar *
clapper_marker_get_title (ClapperMarker *self)
{
g_return_val_if_fail (CLAPPER_IS_MARKER (self), NULL);
return self->title;
}
/**
* clapper_marker_get_start:
* @marker: a #ClapperMarker
*
* Get the start position (in seconds) of @marker.
*
* Returns: marker start.
*/
gdouble
clapper_marker_get_start (ClapperMarker *self)
{
g_return_val_if_fail (CLAPPER_IS_MARKER (self), 0);
return self->start;
}
/**
* clapper_marker_get_end:
* @marker: a #ClapperMarker
*
* Get the end position (in seconds) of @marker.
*
* Returns: marker end.
*/
gdouble
clapper_marker_get_end (ClapperMarker *self)
{
g_return_val_if_fail (CLAPPER_IS_MARKER (self), CLAPPER_MARKER_NO_END);
return self->end;
}
gboolean
clapper_marker_is_internal (ClapperMarker *self)
{
return self->is_internal;
}
static void
clapper_marker_init (ClapperMarker *self)
{
self->marker_type = CLAPPER_MARKER_TYPE_UNKNOWN;
self->end = CLAPPER_MARKER_NO_END;
}
static void
clapper_marker_constructed (GObject *object)
{
ClapperMarker *self = CLAPPER_MARKER_CAST (object);
G_OBJECT_CLASS (parent_class)->constructed (object);
GST_TRACE_OBJECT (self, "Created new marker"
", type: %i, title: \"%s\", start: %lf, end: %lf",
self->marker_type, GST_STR_NULL (self->title), self->start, self->end);
}
static void
clapper_marker_finalize (GObject *object)
{
ClapperMarker *self = CLAPPER_MARKER_CAST (object);
GST_TRACE_OBJECT (self, "Finalize");
g_free (self->title);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
clapper_marker_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
ClapperMarker *self = CLAPPER_MARKER_CAST (object);
switch (prop_id) {
case PROP_MARKER_TYPE:
g_value_set_enum (value, clapper_marker_get_marker_type (self));
break;
case PROP_TITLE:
g_value_set_string (value, clapper_marker_get_title (self));
break;
case PROP_START:
g_value_set_double (value, clapper_marker_get_start (self));
break;
case PROP_END:
g_value_set_double (value, clapper_marker_get_end (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
clapper_marker_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
ClapperMarker *self = CLAPPER_MARKER_CAST (object);
switch (prop_id) {
case PROP_MARKER_TYPE:
self->marker_type = g_value_get_enum (value);
break;
case PROP_TITLE:
self->title = g_value_dup_string (value);
break;
case PROP_START:
self->start = g_value_get_double (value);
break;
case PROP_END:
self->end = g_value_get_double (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
clapper_marker_class_init (ClapperMarkerClass *klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "clappermarker", 0,
"Clapper Marker");
gobject_class->constructed = clapper_marker_constructed;
gobject_class->get_property = clapper_marker_get_property;
gobject_class->set_property = clapper_marker_set_property;
gobject_class->finalize = clapper_marker_finalize;
/**
* ClapperMarker:marker-type:
*
* Type of stream.
*/
param_specs[PROP_MARKER_TYPE] = g_param_spec_enum ("marker-type",
NULL, NULL, CLAPPER_TYPE_MARKER_TYPE, CLAPPER_MARKER_TYPE_UNKNOWN,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* ClapperMarker:title:
*
* Title of marker.
*/
param_specs[PROP_TITLE] = g_param_spec_string ("title",
NULL, NULL, NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* ClapperMarker:start:
*
* Starting time of marker.
*/
param_specs[PROP_START] = g_param_spec_double ("start",
NULL, NULL, 0, G_MAXDOUBLE, 0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* ClapperMarker:end:
*
* Ending time of marker.
*/
param_specs[PROP_END] = g_param_spec_double ("end",
NULL, NULL, -1, G_MAXDOUBLE, CLAPPER_MARKER_NO_END,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, PROP_LAST, param_specs);
}

View File

@@ -0,0 +1,58 @@
/* Clapper Playback Library
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#if !defined(__CLAPPER_INSIDE__) && !defined(CLAPPER_COMPILATION)
#error "Only <clapper/clapper.h> can be included directly."
#endif
#include <glib.h>
#include <glib-object.h>
#include <gst/gst.h>
#include <clapper/clapper-enums.h>
G_BEGIN_DECLS
#define CLAPPER_TYPE_MARKER (clapper_marker_get_type())
#define CLAPPER_MARKER_CAST(obj) ((ClapperMarker *)(obj))
/* NOTE: #ClapperMarker are immutable objects that cannot be derived,
* otherwise #ClapperFeaturesManager would not be able to announce media
* item changed caused by changes within them */
G_DECLARE_FINAL_TYPE (ClapperMarker, clapper_marker, CLAPPER, MARKER, GstObject)
/**
* CLAPPER_MARKER_NO_END:
*
* The value used to indicate that marker does not have an ending time specified
*/
#define CLAPPER_MARKER_NO_END (-1.0)
ClapperMarker * clapper_marker_new (ClapperMarkerType marker_type, const gchar *title, gdouble start, gdouble end);
ClapperMarkerType clapper_marker_get_marker_type (ClapperMarker *marker);
const gchar * clapper_marker_get_title (ClapperMarker *marker);
gdouble clapper_marker_get_start (ClapperMarker *marker);
gdouble clapper_marker_get_end (ClapperMarker *marker);
G_END_DECLS

View File

@@ -0,0 +1,46 @@
/* Clapper Playback Library
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#include <glib.h>
#include <gst/pbutils/pbutils.h>
#include "clapper-media-item.h"
#include "clapper-player-private.h"
#include "clapper-app-bus-private.h"
G_BEGIN_DECLS
G_GNUC_INTERNAL
void clapper_media_item_update_from_tag_list (ClapperMediaItem *item, const GstTagList *tags, ClapperPlayer *player);
G_GNUC_INTERNAL
void clapper_media_item_update_from_discoverer_info (ClapperMediaItem *self, GstDiscovererInfo *info);
G_GNUC_INTERNAL
gboolean clapper_media_item_set_duration (ClapperMediaItem *item, gdouble duration, ClapperAppBus *app_bus);
G_GNUC_INTERNAL
void clapper_media_item_set_used (ClapperMediaItem *item, gboolean used);
G_GNUC_INTERNAL
gboolean clapper_media_item_get_used (ClapperMediaItem *item);
G_END_DECLS

View File

@@ -0,0 +1,641 @@
/* Clapper Playback Library
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* ClapperMediaItem:
*
* Represents a media item.
*
* A newly created media item must be added to player [class@Clapper.Queue]
* first in order to be played.
*/
#include "clapper-media-item-private.h"
#include "clapper-timeline-private.h"
#include "clapper-player-private.h"
#include "clapper-playbin-bus-private.h"
#include "clapper-features-manager-private.h"
#include "clapper-utils-private.h"
#define GST_CAT_DEFAULT clapper_media_item_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
struct _ClapperMediaItem
{
GstObject parent;
gchar *uri;
gchar *suburi;
ClapperTimeline *timeline;
guint id;
gchar *title;
gchar *container_format;
gdouble duration;
/* For shuffle */
gboolean used;
};
enum
{
PROP_0,
PROP_ID,
PROP_URI,
PROP_SUBURI,
PROP_TITLE,
PROP_CONTAINER_FORMAT,
PROP_DURATION,
PROP_TIMELINE,
PROP_LAST
};
#define parent_class clapper_media_item_parent_class
G_DEFINE_TYPE (ClapperMediaItem, clapper_media_item, GST_TYPE_OBJECT);
static guint _item_id = 0;
static GMutex id_lock;
static GParamSpec *param_specs[PROP_LAST] = { NULL, };
/**
* clapper_media_item_new:
* @uri: a media URI
*
* Creates new #ClapperMediaItem from URI.
*
* Use one of the URI protocols supported by plugins in #GStreamer
* installation. For local files you can use either "file" protocol
* or [ctor@Clapper.MediaItem.new_from_file] method.
*
* It is considered a programmer error trying to create new media item from
* invalid URI. If URI is valid, but unsupported by installed plugins on user
* system, [class@Clapper.Player] will emit a [signal@Clapper.Player::missing-plugin]
* signal upon playback.
*
* Returns: (transfer full): a new #ClapperMediaItem.
*/
ClapperMediaItem *
clapper_media_item_new (const gchar *uri)
{
ClapperMediaItem *item;
g_return_val_if_fail (uri != NULL, NULL);
item = g_object_new (CLAPPER_TYPE_MEDIA_ITEM, "uri", uri, NULL);
gst_object_ref_sink (item);
g_mutex_lock (&id_lock);
item->id = _item_id;
_item_id++;
g_mutex_unlock (&id_lock);
/* FIXME: Set initial container format from file extension parsing */
GST_TRACE_OBJECT (item, "New media item, ID: %u, URI: %s, title: %s",
item->id, item->uri, item->title);
return item;
}
/**
* clapper_media_item_new_from_file:
* @file: a #GFile
*
* Creates new #ClapperMediaItem from #GFile.
*
* Same as [ctor@Clapper.MediaItem.new], but uses a [iface@Gio.File]
* for convenience in some situations instead of an URI.
*
* Returns: (transfer full): a new #ClapperMediaItem.
*/
ClapperMediaItem *
clapper_media_item_new_from_file (GFile *file)
{
ClapperMediaItem *item;
gchar *uri;
g_return_val_if_fail (G_IS_FILE (file), NULL);
uri = clapper_utils_uri_from_file (file);
item = clapper_media_item_new (uri);
g_free (uri);
return item;
}
/**
* clapper_media_item_get_id:
* @item: a #ClapperMediaItem
*
* Get the unique ID of #ClapperMediaItem.
*
* Returns: an ID of #ClapperMediaItem.
*/
guint
clapper_media_item_get_id (ClapperMediaItem *self)
{
g_return_val_if_fail (CLAPPER_IS_MEDIA_ITEM (self), G_MAXUINT);
return self->id;
}
/**
* clapper_media_item_get_uri:
* @item: a #ClapperMediaItem
*
* Get the URI of #ClapperMediaItem.
*
* Returns: an URI of #ClapperMediaItem.
*/
const gchar *
clapper_media_item_get_uri (ClapperMediaItem *self)
{
g_return_val_if_fail (CLAPPER_IS_MEDIA_ITEM (self), NULL);
return self->uri;
}
/**
* clapper_media_item_set_suburi:
* @item: a #ClapperMediaItem
*
* Set the additional URI of #ClapperMediaItem.
*
* This is typically used to add an external subtitles URI
* to the @item.
*/
void
clapper_media_item_set_suburi (ClapperMediaItem *self, const gchar *suburi)
{
gboolean changed;
GST_OBJECT_LOCK (self);
changed = g_set_str (&self->suburi, suburi);
GST_OBJECT_UNLOCK (self);
if (changed) {
ClapperPlayer *player = clapper_player_get_from_ancestor (GST_OBJECT_CAST (self));
if (player) {
clapper_app_bus_post_prop_notify (player->app_bus,
GST_OBJECT_CAST (self), param_specs[PROP_SUBURI]);
clapper_playbin_bus_post_item_suburi_change (player->bus, self);
gst_object_unref (player);
}
}
}
/**
* clapper_media_item_get_suburi:
* @item: a #ClapperMediaItem
*
* Get the additional URI of #ClapperMediaItem.
*
* Returns: (transfer full) (nullable): an additional URI of #ClapperMediaItem.
*/
gchar *
clapper_media_item_get_suburi (ClapperMediaItem *self)
{
gchar *suburi;
g_return_val_if_fail (CLAPPER_IS_MEDIA_ITEM (self), NULL);
GST_OBJECT_LOCK (self);
suburi = g_strdup (self->suburi);
GST_OBJECT_UNLOCK (self);
return suburi;
}
static gboolean
clapper_media_item_take_title (ClapperMediaItem *self, gchar *title,
ClapperAppBus *app_bus)
{
gboolean changed;
GST_OBJECT_LOCK (self);
if ((changed = g_strcmp0 (self->title, title) != 0)) {
g_free (self->title);
self->title = title;
}
GST_OBJECT_UNLOCK (self);
if (changed)
clapper_app_bus_post_prop_notify (app_bus, GST_OBJECT_CAST (self), param_specs[PROP_TITLE]);
else
g_free (title);
return changed;
}
/**
* clapper_media_item_get_title:
* @item: a #ClapperMediaItem
*
* Get media item title.
*
* The title can be either text detected by media discovery once it
* completes. Otherwise whenever possible this will try to return a title
* extracted from media URI e.g. basename without extension for local files.
*
* Returns: (transfer full) (nullable): media title.
*/
gchar *
clapper_media_item_get_title (ClapperMediaItem *self)
{
gchar *title;
g_return_val_if_fail (CLAPPER_IS_MEDIA_ITEM (self), NULL);
GST_OBJECT_LOCK (self);
title = g_strdup (self->title);
GST_OBJECT_UNLOCK (self);
return title;
}
static gboolean
clapper_media_item_take_container_format (ClapperMediaItem *self, gchar *container_format,
ClapperAppBus *app_bus)
{
gboolean changed;
GST_OBJECT_LOCK (self);
if ((changed = g_strcmp0 (self->container_format, container_format) != 0)) {
g_free (self->container_format);
self->container_format = container_format;
}
GST_OBJECT_UNLOCK (self);
if (changed)
clapper_app_bus_post_prop_notify (app_bus, GST_OBJECT_CAST (self), param_specs[PROP_CONTAINER_FORMAT]);
else
g_free (container_format);
return changed;
}
/**
* clapper_media_item_get_container_format:
* @item: a #ClapperMediaItem
*
* Get media item container format.
*
* Returns: (transfer full) (nullable): media container format.
*/
gchar *
clapper_media_item_get_container_format (ClapperMediaItem *self)
{
gchar *container_format;
g_return_val_if_fail (CLAPPER_IS_MEDIA_ITEM (self), NULL);
GST_OBJECT_LOCK (self);
container_format = g_strdup (self->container_format);
GST_OBJECT_UNLOCK (self);
return container_format;
}
gboolean
clapper_media_item_set_duration (ClapperMediaItem *self, gdouble duration,
ClapperAppBus *app_bus)
{
gboolean changed;
GST_OBJECT_LOCK (self);
if ((changed = !G_APPROX_VALUE (self->duration, duration, FLT_EPSILON)))
self->duration = duration;
GST_OBJECT_UNLOCK (self);
if (changed) {
GST_DEBUG_OBJECT (self, "Duration: %" GST_TIME_FORMAT, GST_TIME_ARGS (duration * GST_SECOND));
clapper_app_bus_post_prop_notify (app_bus, GST_OBJECT_CAST (self), param_specs[PROP_DURATION]);
}
return changed;
}
/**
* clapper_media_item_get_duration:
* @item: a #ClapperMediaItem
*
* Get media item duration as decimal number in seconds.
*
* Returns: media duration.
*/
gdouble
clapper_media_item_get_duration (ClapperMediaItem *self)
{
gdouble duration;
g_return_val_if_fail (CLAPPER_IS_MEDIA_ITEM (self), 0);
GST_OBJECT_LOCK (self);
duration = self->duration;
GST_OBJECT_UNLOCK (self);
return duration;
}
/**
* clapper_media_item_get_timeline:
* @item: a #ClapperMediaItem
*
* Get the [class@Clapper.Timeline] assosiated with @item.
*
* Returns: (transfer none): a #ClapperTimeline of item.
*/
ClapperTimeline *
clapper_media_item_get_timeline (ClapperMediaItem *self)
{
g_return_val_if_fail (CLAPPER_IS_MEDIA_ITEM (self), NULL);
return self->timeline;
}
static gboolean
clapper_media_item_update_from_container_tags (ClapperMediaItem *self, const GstTagList *tags,
ClapperAppBus *app_bus)
{
gchar *string = NULL;
gboolean changed = FALSE;
if (gst_tag_list_get_string (tags, GST_TAG_CONTAINER_FORMAT, &string))
changed |= clapper_media_item_take_container_format (self, string, app_bus);
if (gst_tag_list_get_string (tags, GST_TAG_TITLE, &string))
changed |= clapper_media_item_take_title (self, string, app_bus);
return changed;
}
void
clapper_media_item_update_from_tag_list (ClapperMediaItem *self, const GstTagList *tags,
ClapperPlayer *player)
{
GstTagScope scope = gst_tag_list_get_scope (tags);
if (scope == GST_TAG_SCOPE_GLOBAL) {
gboolean changed = clapper_media_item_update_from_container_tags (self, tags, player->app_bus);
if (changed) {
ClapperFeaturesManager *features_manager;
if ((features_manager = clapper_player_get_features_manager (player)))
clapper_features_manager_trigger_item_updated (features_manager, self);
}
}
}
void
clapper_media_item_update_from_discoverer_info (ClapperMediaItem *self, GstDiscovererInfo *info)
{
ClapperPlayer *player;
GstDiscovererStreamInfo *sinfo;
GstClockTime duration;
gdouble val_dbl;
gboolean changed = FALSE;
if (!(player = clapper_player_get_from_ancestor (GST_OBJECT_CAST (self))))
return;
for (sinfo = gst_discoverer_info_get_stream_info (info);
sinfo != NULL;
sinfo = gst_discoverer_stream_info_get_next (sinfo)) {
const GstTagList *tags;
if (GST_IS_DISCOVERER_CONTAINER_INFO (sinfo)) {
GstDiscovererContainerInfo *cinfo = (GstDiscovererContainerInfo *) sinfo;
if ((tags = gst_discoverer_container_info_get_tags (cinfo)))
changed |= clapper_media_item_update_from_container_tags (self, tags, player->app_bus);
}
gst_discoverer_stream_info_unref (sinfo);
}
duration = gst_discoverer_info_get_duration (info);
if (G_UNLIKELY (duration == GST_CLOCK_TIME_NONE))
duration = 0;
val_dbl = (gdouble) duration / GST_SECOND;
changed |= clapper_media_item_set_duration (self, val_dbl, player->app_bus);
if (changed) {
ClapperFeaturesManager *features_manager;
if ((features_manager = clapper_player_get_features_manager (player)))
clapper_features_manager_trigger_item_updated (features_manager, self);
}
gst_object_unref (player);
}
void
clapper_media_item_set_used (ClapperMediaItem *self, gboolean used)
{
GST_OBJECT_LOCK (self);
self->used = used;
GST_OBJECT_UNLOCK (self);
}
gboolean
clapper_media_item_get_used (ClapperMediaItem *self)
{
gboolean used;
GST_OBJECT_LOCK (self);
used = self->used;
GST_OBJECT_UNLOCK (self);
return used;
}
static void
clapper_media_item_init (ClapperMediaItem *self)
{
self->timeline = clapper_timeline_new ();
gst_object_set_parent (GST_OBJECT_CAST (self->timeline), GST_OBJECT_CAST (self));
}
static void
clapper_media_item_constructed (GObject *object)
{
ClapperMediaItem *self = CLAPPER_MEDIA_ITEM_CAST (object);
/* Be safe when someone incorrectly constructs item without URI */
if (G_UNLIKELY (self->uri == NULL))
self->uri = g_strdup ("file://");
self->title = clapper_utils_title_from_uri (self->uri);
G_OBJECT_CLASS (parent_class)->constructed (object);
}
static void
clapper_media_item_finalize (GObject *object)
{
ClapperMediaItem *self = CLAPPER_MEDIA_ITEM_CAST (object);
GST_TRACE_OBJECT (self, "Finalize");
g_free (self->uri);
g_free (self->title);
g_free (self->container_format);
gst_object_unparent (GST_OBJECT_CAST (self->timeline));
gst_object_unref (self->timeline);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
clapper_media_item_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
ClapperMediaItem *self = CLAPPER_MEDIA_ITEM_CAST (object);
switch (prop_id) {
case PROP_URI:
self->uri = g_value_dup_string (value);
break;
case PROP_SUBURI:
clapper_media_item_set_suburi (self, g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
clapper_media_item_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
ClapperMediaItem *self = CLAPPER_MEDIA_ITEM_CAST (object);
switch (prop_id) {
case PROP_ID:
g_value_set_uint (value, clapper_media_item_get_id (self));
break;
case PROP_URI:
g_value_set_string (value, clapper_media_item_get_uri (self));
break;
case PROP_SUBURI:
g_value_take_string (value, clapper_media_item_get_suburi (self));
break;
case PROP_TITLE:
g_value_take_string (value, clapper_media_item_get_title (self));
break;
case PROP_CONTAINER_FORMAT:
g_value_take_string (value, clapper_media_item_get_container_format (self));
break;
case PROP_DURATION:
g_value_set_double (value, clapper_media_item_get_duration (self));
break;
case PROP_TIMELINE:
g_value_set_object (value, clapper_media_item_get_timeline (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
clapper_media_item_class_init (ClapperMediaItemClass *klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "clappermediaitem", 0,
"Clapper Media Item");
gobject_class->constructed = clapper_media_item_constructed;
gobject_class->set_property = clapper_media_item_set_property;
gobject_class->get_property = clapper_media_item_get_property;
gobject_class->finalize = clapper_media_item_finalize;
/**
* ClapperMediaItem:id:
*
* Media Item ID.
*/
param_specs[PROP_ID] = g_param_spec_uint ("id",
NULL, NULL, 0, G_MAXUINT, G_MAXUINT,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* ClapperMediaItem:uri:
*
* Media URI.
*/
param_specs[PROP_URI] = g_param_spec_string ("uri",
NULL, NULL, NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* ClapperMediaItem:suburi:
*
* Media additional URI.
*/
param_specs[PROP_SUBURI] = g_param_spec_string ("suburi",
NULL, NULL, NULL,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* ClapperMediaItem:title:
*
* Media title.
*/
param_specs[PROP_TITLE] = g_param_spec_string ("title",
NULL, NULL, NULL,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* ClapperMediaItem:container-format:
*
* Media container format.
*/
param_specs[PROP_CONTAINER_FORMAT] = g_param_spec_string ("container-format",
NULL, NULL, NULL,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* ClapperMediaItem:duration:
*
* Media duration as a decimal number in seconds.
*/
param_specs[PROP_DURATION] = g_param_spec_double ("duration",
NULL, NULL, 0, G_MAXDOUBLE, 0,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* ClapperPlayer:timeline:
*
* Media timeline.
*/
param_specs[PROP_TIMELINE] = g_param_spec_object ("timeline",
NULL, NULL, CLAPPER_TYPE_TIMELINE,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, PROP_LAST, param_specs);
}

View File

@@ -0,0 +1,60 @@
/* Clapper Playback Library
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#if !defined(__CLAPPER_INSIDE__) && !defined(CLAPPER_COMPILATION)
#error "Only <clapper/clapper.h> can be included directly."
#endif
#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <gst/gst.h>
#include <clapper/clapper-timeline.h>
G_BEGIN_DECLS
#define CLAPPER_TYPE_MEDIA_ITEM (clapper_media_item_get_type())
#define CLAPPER_MEDIA_ITEM_CAST(obj) ((ClapperMediaItem *)(obj))
G_DECLARE_FINAL_TYPE (ClapperMediaItem, clapper_media_item, CLAPPER, MEDIA_ITEM, GstObject)
ClapperMediaItem * clapper_media_item_new (const gchar *uri);
ClapperMediaItem * clapper_media_item_new_from_file (GFile *file);
guint clapper_media_item_get_id (ClapperMediaItem *item);
const gchar * clapper_media_item_get_uri (ClapperMediaItem *item);
void clapper_media_item_set_suburi (ClapperMediaItem *item, const gchar *suburi);
gchar * clapper_media_item_get_suburi (ClapperMediaItem *item);
gchar * clapper_media_item_get_title (ClapperMediaItem *item);
gchar * clapper_media_item_get_container_format (ClapperMediaItem *item);
gdouble clapper_media_item_get_duration (ClapperMediaItem *item);
ClapperTimeline * clapper_media_item_get_timeline (ClapperMediaItem *item);
G_END_DECLS

View File

@@ -0,0 +1,53 @@
/* Clapper Playback Library
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#include <glib.h>
#include <gst/gst.h>
#include "clapper-enums-private.h"
#include "clapper-player.h"
#include "clapper-media-item.h"
G_BEGIN_DECLS
void clapper_playbin_bus_initialize (void);
gboolean clapper_playbin_bus_message_func (GstBus *bus, GstMessage *msg, ClapperPlayer *player);
void clapper_playbin_bus_post_set_volume (GstBus *bus, GstElement *playbin, gdouble volume);
void clapper_playbin_bus_post_set_prop (GstBus *bus, GstObject *src, const gchar *name, GValue *value);
void clapper_playbin_bus_post_set_play_flag (GstBus *bus, ClapperPlayerPlayFlags flag, gboolean enabled);
void clapper_playbin_bus_post_request_state (GstBus *bus, ClapperPlayer *player, GstState state);
void clapper_playbin_bus_post_seek (GstBus *bus, gdouble position, ClapperPlayerSeekMethod flags);
void clapper_playbin_bus_post_rate_change (GstBus *bus, gdouble rate);
void clapper_playbin_bus_post_stream_change (GstBus *bus);
void clapper_playbin_bus_post_current_item_change (GstBus *bus, ClapperMediaItem *current_item, ClapperQueueItemChangeMode mode);
void clapper_playbin_bus_post_item_suburi_change (GstBus *bus, ClapperMediaItem *item);
G_END_DECLS

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,138 @@
/* Clapper Playback Library
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#include "clapper-player.h"
#include "clapper-queue.h"
#include "clapper-enums.h"
#include "clapper-app-bus-private.h"
#include "clapper-features-manager-private.h"
G_BEGIN_DECLS
#define clapper_player_set_have_features(player,have) (g_atomic_int_set (&player->have_features, (gint) have))
#define clapper_player_get_have_features(player) (g_atomic_int_get (&player->have_features) == 1)
#define clapper_player_get_features_manager(player) (clapper_player_get_have_features(player) ? player->features_manager : NULL)
struct _ClapperPlayer
{
ClapperThreadedObject parent;
ClapperQueue *queue;
ClapperStreamList *video_streams;
ClapperStreamList *audio_streams;
ClapperStreamList *subtitle_streams;
ClapperFeaturesManager *features_manager;
gint have_features; // atomic integer
/* This is different from queue current item as it is used/changed only
* on player thread, so we can always update correct item without lock */
ClapperMediaItem *played_item;
/* Will eventually become our "played_item", can be set from
* different thread, thus needs a lock */
ClapperMediaItem *pending_item;
GstElement *playbin;
GstBus *bus;
ClapperAppBus *app_bus;
GSource *tick_source;
GstQuery *position_query;
/* Must only be used from player thread */
GstState current_state; // reported from playbin
GstState target_state; // state requested by user
gboolean is_buffering;
gdouble pending_position; // store seek before playback
gdouble requested_speed, pending_speed; // store speed for consecutive rate changes
/* Stream collection */
GstStreamCollection *collection;
gulong stream_notify_id;
/* Extra params */
gboolean use_playbin3; // when using playbin3
gboolean had_error; // so we do not do stuff after error
gboolean seeking; // during seek operation
gboolean speed_changing; // during rate change operation
gboolean pending_eos; // when pausing due to EOS
gint eos; // atomic integer
/* Playbin2 compat */
gint n_video, n_audio, n_text;
/* Props */
gboolean autoplay;
gboolean mute;
gdouble volume;
gdouble speed;
gdouble position;
ClapperPlayerState state;
GstElement *video_decoder;
GstElement *audio_decoder;
gboolean video_enabled;
gboolean audio_enabled;
gboolean subtitles_enabled;
gdouble audio_offset;
gdouble subtitle_offset;
};
ClapperPlayer * clapper_player_get_from_ancestor (GstObject *object);
gboolean clapper_player_refresh_position (ClapperPlayer *player);
void clapper_player_add_tick_source (ClapperPlayer *player);
void clapper_player_remove_tick_source (ClapperPlayer *player);
void clapper_player_handle_playbin_state_changed (ClapperPlayer *player);
void clapper_player_handle_playbin_volume_changed (ClapperPlayer *player, const GValue *value);
void clapper_player_handle_playbin_mute_changed (ClapperPlayer *player, const GValue *value);
void clapper_player_handle_playbin_flags_changed (ClapperPlayer *player, const GValue *value);
void clapper_player_handle_playbin_av_offset_changed (ClapperPlayer *player, const GValue *value);
void clapper_player_handle_playbin_text_offset_changed (ClapperPlayer *player, const GValue *value);
void clapper_player_handle_playbin_common_prop_changed (ClapperPlayer *player, const gchar *prop_name);
void clapper_player_handle_playbin_rate_changed (ClapperPlayer *player, gdouble speed);
void clapper_player_set_pending_item (ClapperPlayer *player, ClapperMediaItem *pending_item, ClapperQueueItemChangeMode mode);
void clapper_player_take_stream_collection (ClapperPlayer *player, GstStreamCollection *collection);
void clapper_player_refresh_streams (ClapperPlayer *player);
gboolean clapper_player_find_active_decoder_with_stream_id (ClapperPlayer *player, GstElementFactoryListType type, const gchar *stream_id);
void clapper_player_playbin_update_current_decoders (ClapperPlayer *player);
void clapper_player_reset (ClapperPlayer *player, gboolean pending_dispose);
G_END_DECLS

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,128 @@
/* Clapper Playback Library
* Copyright (C) 2024 Rafał Dzięgiel <rafostar.github@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#pragma once
#if !defined(__CLAPPER_INSIDE__) && !defined(CLAPPER_COMPILATION)
#error "Only <clapper/clapper.h> can be included directly."
#endif
#include <glib.h>
#include <glib-object.h>
#include <gst/gst.h>
#include <clapper/clapper-threaded-object.h>
#include <clapper/clapper-queue.h>
#include <clapper/clapper-stream-list.h>
#include <clapper/clapper-feature.h>
#include <clapper/clapper-enums.h>
G_BEGIN_DECLS
#define CLAPPER_TYPE_PLAYER (clapper_player_get_type())
#define CLAPPER_PLAYER_CAST(obj) ((ClapperPlayer *)(obj))
G_DECLARE_FINAL_TYPE (ClapperPlayer, clapper_player, CLAPPER, PLAYER, ClapperThreadedObject)
ClapperPlayer * clapper_player_new (void);
ClapperQueue * clapper_player_get_queue (ClapperPlayer *player);
ClapperStreamList * clapper_player_get_video_streams (ClapperPlayer *player);
ClapperStreamList * clapper_player_get_audio_streams (ClapperPlayer *player);
ClapperStreamList * clapper_player_get_subtitle_streams (ClapperPlayer *player);
void clapper_player_set_autoplay (ClapperPlayer *player, gboolean enabled);
gboolean clapper_player_get_autoplay (ClapperPlayer *player);
gdouble clapper_player_get_position (ClapperPlayer *player);
ClapperPlayerState clapper_player_get_state (ClapperPlayer *player);
void clapper_player_set_mute (ClapperPlayer *player, gboolean mute);
gboolean clapper_player_get_mute (ClapperPlayer *player);
void clapper_player_set_volume (ClapperPlayer *player, gdouble volume);
gdouble clapper_player_get_volume (ClapperPlayer *player);
void clapper_player_set_speed (ClapperPlayer *player, gdouble speed);
gdouble clapper_player_get_speed (ClapperPlayer *player);
void clapper_player_set_video_sink (ClapperPlayer *player, GstElement *element);
GstElement * clapper_player_get_video_sink (ClapperPlayer *player);
void clapper_player_set_audio_sink (ClapperPlayer *player, GstElement *element);
GstElement * clapper_player_get_audio_sink (ClapperPlayer *player);
void clapper_player_set_video_filter (ClapperPlayer *player, GstElement *element);
GstElement * clapper_player_get_video_filter (ClapperPlayer *player);
void clapper_player_set_audio_filter (ClapperPlayer *player, GstElement *element);
GstElement * clapper_player_get_audio_filter (ClapperPlayer *player);
GstElement * clapper_player_get_current_video_decoder (ClapperPlayer *player);
GstElement * clapper_player_get_current_audio_decoder (ClapperPlayer *player);
void clapper_player_set_video_enabled (ClapperPlayer *player, gboolean enabled);
gboolean clapper_player_get_video_enabled (ClapperPlayer *player);
void clapper_player_set_audio_enabled (ClapperPlayer *player, gboolean enabled);
gboolean clapper_player_get_audio_enabled (ClapperPlayer *player);
void clapper_player_set_subtitles_enabled (ClapperPlayer *player, gboolean enabled);
gboolean clapper_player_get_subtitles_enabled (ClapperPlayer *player);
void clapper_player_set_audio_offset (ClapperPlayer *player, gdouble offset);
gdouble clapper_player_get_audio_offset (ClapperPlayer *player);
void clapper_player_set_subtitle_offset (ClapperPlayer *player, gdouble offset);
gdouble clapper_player_get_subtitle_offset (ClapperPlayer *player);
void clapper_player_set_subtitle_font_desc (ClapperPlayer *player, const gchar *font_desc);
gchar * clapper_player_get_subtitle_font_desc (ClapperPlayer *player);
void clapper_player_play (ClapperPlayer *player);
void clapper_player_pause (ClapperPlayer *player);
void clapper_player_stop (ClapperPlayer *player);
void clapper_player_seek (ClapperPlayer *player, gdouble position);
void clapper_player_seek_custom (ClapperPlayer *player, gdouble position, ClapperPlayerSeekMethod method);
void clapper_player_add_feature (ClapperPlayer *player, ClapperFeature *feature);
G_END_DECLS

Some files were not shown because too many files have changed in this diff Show More