12 Commits

Author SHA1 Message Date
Rafał Dzięgiel
16430c4c66 clapper-app: Allow usage of all reactable enhancers
Enable and use all found enhancer plugins on the system
2025-06-22 13:36:09 +02:00
Rafał Dzięgiel
9f1102bafd clapper: Add ability to enable/disable creation of given enhancer
Allow apps to enable or disable given enhancer instances from being created.
Also as a safely measure, by default only enable enhancers that work
on-demand (extractables) and disable others (reactables).
2025-06-22 13:35:57 +02:00
Rafał Dzięgiel
7b4a19659b Merge pull request #561 from musicinmybrain/remote-only-fsf
Update LGPL-2.1-or-later notices and text for remote-only FSF
2025-06-19 12:43:50 +02:00
Benjamin A. Beasley
8fe46d315c Update LGPL-2.1-or-later license text for remote-only FSF
The Free Software Foundation is now remote-only, and no longer has a
street address. Updated license text is from
https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt.
2025-06-14 11:35:04 -04:00
Benjamin A. Beasley
b5cc171803 Update LGPL-2.1-or-later license notices for remote-only FSF
The Free Software Foundation is now remote-only, and no longer has a
street address. Updated license notice text is from
https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html#SEC4.
2025-06-14 11:35:02 -04:00
Rafał Dzięgiel
0f929014d5 clapper: reactable: Fix invalid assert check
Fix a copy-paste bug. There is no item to check in this function.
2025-06-09 20:57:45 +02:00
Rafał Dzięgiel
f3b120f451 Merge pull request #559 from Rafostar/reactable
clapper: Add "Reactable" interface
2025-06-09 20:52:15 +02:00
Rafał Dzięgiel
c354d31436 clapper: reactable: Inform which properties were updated 2025-06-09 20:21:39 +02:00
Rafał Dzięgiel
c0b360dc0f clapper-app: Add support for MPRIS enhancer 2025-06-09 18:37:40 +02:00
Rafał Dzięgiel
a6ca0b726c clapper: Implement reactables manager
An object for managing instances of reactable type of enhancers.

Based on/similar to features manager which along with Clapper
features objects gets deprecated in favour of reactables.
2025-06-09 18:36:06 +02:00
Rafał Dzięgiel
976bcc338f clapper: Add "Reactable" interface
An interface for creating enhancers that react to the
playback and/or events that should influence it.
2025-06-08 17:46:35 +02:00
Rafał Dzięgiel
6273446817 Merge pull request #558 from Rafostar/tagged
clapper: Add taglist to media items
2025-06-08 17:43:12 +02:00
170 changed files with 1840 additions and 622 deletions

View File

@@ -2,7 +2,7 @@
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
<https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@@ -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
@@ -484,9 +484,7 @@ convey the exclusion of warranty; and each file should have at least the
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 Street, Fifth Floor, Boston, MA 02110-1301
USA
License along with this library; if not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
@@ -495,10 +493,9 @@ 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
<signature of Moe Ghoul>, 1 April 1990
Moe Ghoul, President of Vice
That's all there is to it!

View File

@@ -86,9 +86,7 @@ typedef struct
gint64 last_tick;
} ClapperAppWindowResizeData;
#if CLAPPER_HAVE_MPRIS
static guint16 instance_count = 0;
#endif
static inline GQuark
clapper_app_window_extra_options_get_quark (void)
@@ -1252,16 +1250,28 @@ clapper_app_window_constructed (GObject *object)
#if (CLAPPER_HAVE_MPRIS || CLAPPER_HAVE_SERVER || CLAPPER_HAVE_DISCOVERER)
ClapperFeature *feature = NULL;
#endif
#if CLAPPER_HAVE_MPRIS
#if (!CLAPPER_HAVE_MPRIS || !CLAPPER_HAVE_SERVER || !CLAPPER_HAVE_DISCOVERER)
ClapperEnhancerProxyList *proxies = clapper_player_get_enhancer_proxies (player);
ClapperEnhancerProxy *proxy;
#endif
gchar mpris_name[45];
g_snprintf (mpris_name, sizeof (mpris_name),
"org.mpris.MediaPlayer2.Clapper.instance%" G_GUINT16_FORMAT, instance_count++);
#endif
self->settings = g_settings_new (CLAPPER_APP_ID);
self->last_volume = PERCENTAGE_ROUND (g_settings_get_double (self->settings, "volume"));
#if CLAPPER_HAVE_MPRIS
#if !CLAPPER_HAVE_MPRIS
if ((proxy = clapper_enhancer_proxy_list_get_proxy_by_module (proxies, "clapper-mpris"))) {
clapper_enhancer_proxy_set_locally (proxy,
"own-name", mpris_name,
"identity", CLAPPER_APP_NAME,
"desktop-entry", CLAPPER_APP_ID,
"queue-controllable", TRUE, NULL);
gst_object_unref (proxy);
}
#else
feature = CLAPPER_FEATURE (clapper_mpris_new (
mpris_name, CLAPPER_APP_NAME, CLAPPER_APP_ID));
clapper_mpris_set_queue_controllable (CLAPPER_MPRIS (feature), TRUE);

View File

@@ -31,8 +31,10 @@
gint
main (gint argc, gchar **argv)
{
const gchar *clapper_ldir;
GApplication *application;
ClapperEnhancerProxyList *proxies;
const gchar *clapper_ldir;
guint i, n_proxies;
gint status;
#ifdef G_OS_WIN32
@@ -64,6 +66,15 @@ main (gint argc, gchar **argv)
resolution = clapper_app_utils_win_hi_res_clock_start ();
#endif
proxies = clapper_get_global_enhancer_proxies ();
n_proxies = clapper_enhancer_proxy_list_get_n_proxies (proxies);
/* Allow usage of all enhancers */
for (i = 0; i < n_proxies; ++i) {
ClapperEnhancerProxy *proxy = clapper_enhancer_proxy_list_peek_proxy (proxies, i);
clapper_enhancer_proxy_set_target_creation_allowed (proxy, TRUE);
}
application = clapper_app_application_new ();
status = g_application_run (application, argc, argv);

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
/**

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#include <clapper/clapper.h>

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#include "clapper-gtk-buffering-paintable-private.h"

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
/**

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
/**

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
/**

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#include <clapper/clapper.h>

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
/**

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
/**

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
/**

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
/**

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
/**

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
/**

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
/**

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
/**

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
/**

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#include <gio/gio.h>

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
/**

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"
@@ -29,6 +28,7 @@
#include "clapper-app-bus-private.h"
#include "clapper-features-bus-private.h"
#include "clapper-enhancer-proxy-list-private.h"
#include "clapper-reactables-manager-private.h"
#include "gst/clapper-plugin-private.h"
#include "clapper-functionalities-availability.h"
@@ -56,6 +56,7 @@ clapper_init_check_internal (int *argc, char **argv[])
clapper_playbin_bus_initialize ();
clapper_app_bus_initialize ();
clapper_features_bus_initialize ();
clapper_reactables_manager_initialize ();
_proxies = clapper_enhancer_proxy_list_new_named ("global-proxy-list");

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,20 +12,21 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#include "clapper-cache-private.h"
#include "clapper-version.h"
#include "clapper-extractable.h"
#include "clapper-reactable.h"
#define CLAPPER_CACHE_HEADER "CLAPPER"
typedef enum
{
CLAPPER_CACHE_IFACE_EXTRACTABLE = 1,
CLAPPER_CACHE_IFACE_REACTABLE,
} ClapperCacheIfaces;
static GArray *enum_registry = NULL;
@@ -243,6 +244,8 @@ clapper_cache_read_iface (const gchar **data)
switch (iface_id) {
case CLAPPER_CACHE_IFACE_EXTRACTABLE:
return CLAPPER_TYPE_EXTRACTABLE;
case CLAPPER_CACHE_IFACE_REACTABLE:
return CLAPPER_TYPE_REACTABLE;
default:
return 0;
}
@@ -433,6 +436,8 @@ clapper_cache_store_iface (GByteArray *bytes, GType iface)
if (iface == CLAPPER_TYPE_EXTRACTABLE)
iface_id = CLAPPER_CACHE_IFACE_EXTRACTABLE;
else if (iface == CLAPPER_TYPE_REACTABLE)
iface_id = CLAPPER_CACHE_IFACE_REACTABLE;
else
return FALSE;

View File

@@ -12,14 +12,14 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <glib.h>
#include <glib-object.h>
#include "clapper-enhancer-proxy-list.h"
#include "clapper-enhancer-proxy.h"
@@ -38,4 +38,7 @@ void clapper_enhancer_proxy_list_fill_from_global_proxies (ClapperEnhancerProxyL
G_GNUC_INTERNAL
void clapper_enhancer_proxy_list_sort (ClapperEnhancerProxyList *list);
G_GNUC_INTERNAL
gboolean clapper_enhancer_proxy_list_has_proxy_with_interface (ClapperEnhancerProxyList *list, GType iface_type);
G_END_DECLS

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
/**
@@ -161,6 +160,29 @@ clapper_enhancer_proxy_list_sort (ClapperEnhancerProxyList *self)
g_ptr_array_sort_values (self->proxies, (GCompareFunc) _sort_values_by_name);
}
/*
* clapper_enhancer_proxy_list_has_proxy_with_interface:
* @iface_type: an interface #GType
*
* Check if any enhancer implementing given interface type is available.
*
* Returns: whether any enhancer proxy was found.
*/
gboolean
clapper_enhancer_proxy_list_has_proxy_with_interface (ClapperEnhancerProxyList *self, GType iface_type)
{
guint i;
for (i = 0; i < self->proxies->len; ++i) {
ClapperEnhancerProxy *proxy = clapper_enhancer_proxy_list_peek_proxy (self, i);
if (clapper_enhancer_proxy_target_has_interface (proxy, iface_type))
return TRUE;
}
return FALSE;
}
/**
* clapper_enhancer_proxy_list_get_proxy:
* @list: a #ClapperEnhancerProxyList

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once
@@ -45,6 +44,9 @@ void clapper_enhancer_proxy_export_to_cache (ClapperEnhancerProxy *proxy);
G_GNUC_INTERNAL
GObject * clapper_enhancer_proxy_get_peas_info (ClapperEnhancerProxy *proxy);
G_GNUC_INTERNAL
gboolean clapper_enhancer_proxy_has_locally_set (ClapperEnhancerProxy *proxy, const gchar *property_name);
G_GNUC_INTERNAL
GstStructure * clapper_enhancer_proxy_make_current_config (ClapperEnhancerProxy *proxy);

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
/**
@@ -48,6 +47,9 @@
#include "clapper-basic-functions.h"
#include "clapper-cache-private.h"
#include "clapper-extractable.h"
#include "clapper-reactable.h"
#include "clapper-player-private.h"
#include "clapper-utils-private.h"
#include "clapper-enums.h"
#include "clapper-functionalities-availability.h"
@@ -84,6 +86,8 @@ struct _ClapperEnhancerProxy
ClapperEnhancerParamFlags scope;
GstStructure *local_config;
gboolean allowed;
/* GSettings are not thread-safe,
* so store schema instead */
GSettingsSchema *schema;
@@ -98,6 +102,7 @@ enum
PROP_MODULE_DIR,
PROP_DESCRIPTION,
PROP_VERSION,
PROP_TARGET_CREATION_ALLOWED,
PROP_LAST
};
@@ -227,6 +232,8 @@ clapper_enhancer_proxy_copy (ClapperEnhancerProxy *src_proxy, const gchar *copy_
if (src_proxy->local_config)
copy->local_config = gst_structure_copy (src_proxy->local_config);
copy->allowed = src_proxy->allowed;
GST_OBJECT_UNLOCK (src_proxy);
gst_object_ref_sink (copy);
@@ -357,6 +364,8 @@ clapper_enhancer_proxy_fill_from_cache (ClapperEnhancerProxy *self)
if (G_UNLIKELY ((self->ifaces[i] = clapper_cache_read_iface (&data)) == 0))
goto abort_reading;
}
/* Reactable type is always last */
self->allowed = (self->ifaces[self->n_ifaces - 1] != CLAPPER_TYPE_REACTABLE);
}
/* Restore ParamSpecs */
@@ -454,7 +463,8 @@ clapper_enhancer_proxy_export_to_cache (ClapperEnhancerProxy *self)
gboolean
clapper_enhancer_proxy_fill_from_instance (ClapperEnhancerProxy *self, GObject *enhancer)
{
GType enhancer_types[1] = { CLAPPER_TYPE_EXTRACTABLE };
/* NOTE: REACTABLE must be last for "allowed" to work as expected */
const GType enhancer_types[] = { CLAPPER_TYPE_EXTRACTABLE, CLAPPER_TYPE_REACTABLE };
GType *ifaces;
GParamSpec **pspecs;
GParamFlags enhancer_flags;
@@ -463,9 +473,12 @@ clapper_enhancer_proxy_fill_from_instance (ClapperEnhancerProxy *self, GObject *
/* Filter to only Clapper interfaces */
ifaces = g_type_interfaces (G_OBJECT_TYPE (enhancer), &n);
for (i = 0; i < n; ++i) {
for (j = 0; j < G_N_ELEMENTS (enhancer_types); ++j) {
const guint n_types = G_N_ELEMENTS (enhancer_types);
for (j = 0; j < n_types; ++j) {
if (ifaces[i] == enhancer_types[j]) {
ifaces[write_index++] = ifaces[i];
self->allowed = (j < n_types - 1);
break; // match found, do next iface
}
}
@@ -500,6 +513,18 @@ clapper_enhancer_proxy_get_peas_info (ClapperEnhancerProxy *self)
return self->peas_info;
}
gboolean
clapper_enhancer_proxy_has_locally_set (ClapperEnhancerProxy *self, const gchar *property_name)
{
gboolean has_field;
GST_OBJECT_LOCK (self);
has_field = (self->local_config && gst_structure_has_field (self->local_config, property_name));
GST_OBJECT_UNLOCK (self);
return has_field;
}
static gboolean
_apply_config_cb (GQuark field_id, const GValue *value, GObject *enhancer)
{
@@ -527,6 +552,7 @@ clapper_enhancer_proxy_make_current_config (ClapperEnhancerProxy *self)
/* Using "has_field", as set value might be %NULL */
if ((pspec->flags & CLAPPER_ENHANCER_PARAM_LOCAL)
&& self->local_config
&& gst_structure_has_field (self->local_config, pspec->name)) {
if (!merged_config)
merged_config = gst_structure_new_empty (CONFIG_STRUCTURE_NAME);
@@ -540,44 +566,13 @@ clapper_enhancer_proxy_make_current_config (ClapperEnhancerProxy *self)
GVariant *def = g_settings_get_default_value (settings, pspec->name);
if (!g_variant_equal (val, def)) {
if (!merged_config)
merged_config = gst_structure_new_empty (CONFIG_STRUCTURE_NAME);
GValue value = G_VALUE_INIT;
switch (pspec->value_type) {
case G_TYPE_BOOLEAN:
gst_structure_set (merged_config, pspec->name,
pspec->value_type, g_variant_get_boolean (val), NULL);
break;
case G_TYPE_INT:
gst_structure_set (merged_config, pspec->name,
pspec->value_type, g_variant_get_int32 (val), NULL);
break;
case G_TYPE_UINT:
gst_structure_set (merged_config, pspec->name,
pspec->value_type, g_variant_get_uint32 (val), NULL);
break;
case G_TYPE_DOUBLE:
gst_structure_set (merged_config, pspec->name,
pspec->value_type, g_variant_get_double (val), NULL);
break;
case G_TYPE_STRING:
gst_structure_set (merged_config, pspec->name,
pspec->value_type, g_variant_get_string (val, NULL), NULL);
break;
default:{
if (G_IS_PARAM_SPEC_ENUM (pspec)) {
gst_structure_set (merged_config, pspec->name,
G_TYPE_INT, g_variant_get_int32 (val), NULL);
break;
} else if (G_IS_PARAM_SPEC_FLAGS (pspec)) {
gst_structure_set (merged_config, pspec->name,
G_TYPE_UINT, g_variant_get_uint32 (val), NULL);
break;
}
GST_ERROR_OBJECT (self, "Unsupported enhancer \"%s\" setting type: %s",
pspec->name, g_type_name (pspec->value_type));
break;
}
if (G_LIKELY (clapper_utils_set_value_from_variant (&value, val))) {
if (!merged_config)
merged_config = gst_structure_new_empty (CONFIG_STRUCTURE_NAME);
gst_structure_take_value (merged_config, pspec->name, &value);
}
}
@@ -947,6 +942,20 @@ _structure_take_value_by_pspec (ClapperEnhancerProxy *self,
return FALSE;
}
static void
_trigger_reactable_configure_take (ClapperEnhancerProxy *self, GstStructure *structure)
{
ClapperPlayer *player = clapper_player_get_from_ancestor (GST_OBJECT_CAST (self));
if (G_LIKELY (player != NULL)) {
clapper_reactables_manager_trigger_configure_take_config (
player->reactables_manager, self, structure);
gst_object_unref (player);
} else {
gst_structure_free (structure);
}
}
/**
* clapper_enhancer_proxy_set_locally:
* @proxy: a #ClapperEnhancerProxy
@@ -1017,10 +1026,10 @@ clapper_enhancer_proxy_set_locally (ClapperEnhancerProxy *self, const gchar *fir
_update_local_config_from_structure (self, structure);
/* TODO: _post_local_config instead of free if managed
* (for when managed interfaces are implemented) */
gst_structure_free (structure);
if (clapper_enhancer_proxy_target_has_interface (self, CLAPPER_TYPE_REACTABLE))
_trigger_reactable_configure_take (self, structure);
else
gst_structure_free (structure);
}
/**
@@ -1084,10 +1093,62 @@ clapper_enhancer_proxy_set_locally_with_table (ClapperEnhancerProxy *self, GHash
_update_local_config_from_structure (self, structure);
/* TODO: _post_local_config instead of free if managed
* (for when managed interfaces are implemented) */
if (clapper_enhancer_proxy_target_has_interface (self, CLAPPER_TYPE_REACTABLE))
_trigger_reactable_configure_take (self, structure);
else
gst_structure_free (structure);
}
gst_structure_free (structure);
/**
* clapper_enhancer_proxy_set_target_creation_allowed:
* @proxy: a #ClapperEnhancerProxy
* @allowed: whether allowed
*
* Set whether to allow instances of proxy target to be created.
*
* See [property@Clapper.EnhancerProxy:target-creation-allowed] for
* detailed descripton what this does.
*
* Since: 0.10
*/
void
clapper_enhancer_proxy_set_target_creation_allowed (ClapperEnhancerProxy *self, gboolean allowed)
{
gboolean changed;
g_return_if_fail (CLAPPER_IS_ENHANCER_PROXY (self));
GST_OBJECT_LOCK (self);
if ((changed = self->allowed != allowed))
self->allowed = allowed;
GST_OBJECT_UNLOCK (self);
if (changed)
g_object_notify_by_pspec (G_OBJECT (self), param_specs[PROP_TARGET_CREATION_ALLOWED]);
}
/**
* clapper_enhancer_proxy_get_target_creation_allowed:
* @proxy: a #ClapperEnhancerProxy
*
* Get whether it is allowed to create instances of enhancer that this proxy targets.
*
* Returns: whether target creation is allowed.
*
* Since: 0.10
*/
gboolean
clapper_enhancer_proxy_get_target_creation_allowed (ClapperEnhancerProxy *self)
{
gboolean allowed;
g_return_val_if_fail (CLAPPER_IS_ENHANCER_PROXY (self), FALSE);
GST_OBJECT_LOCK (self);
allowed = self->allowed;
GST_OBJECT_UNLOCK (self);
return allowed;
}
static void
@@ -1139,6 +1200,25 @@ clapper_enhancer_proxy_get_property (GObject *object, guint prop_id,
case PROP_VERSION:
g_value_set_string (value, clapper_enhancer_proxy_get_version (self));
break;
case PROP_TARGET_CREATION_ALLOWED:
g_value_set_boolean (value, clapper_enhancer_proxy_get_target_creation_allowed (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
clapper_enhancer_proxy_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
ClapperEnhancerProxy *self = CLAPPER_ENHANCER_PROXY_CAST (object);
switch (prop_id) {
case PROP_TARGET_CREATION_ALLOWED:
clapper_enhancer_proxy_set_target_creation_allowed (self, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1154,6 +1234,7 @@ clapper_enhancer_proxy_class_init (ClapperEnhancerProxyClass *klass)
"Clapper Enhancer Proxy");
gobject_class->get_property = clapper_enhancer_proxy_get_property;
gobject_class->set_property = clapper_enhancer_proxy_set_property;
gobject_class->finalize = clapper_enhancer_proxy_finalize;
/**
@@ -1211,5 +1292,29 @@ clapper_enhancer_proxy_class_init (ClapperEnhancerProxyClass *klass)
NULL, NULL, NULL,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* ClapperEnhancerProxy:target-creation-allowed:
*
* Whether to allow instances of proxy target to be created.
*
* This effectively means whether the given enhancer can be used.
*
* By default all enhancers that work on-demand such as [iface@Clapper.Extractable]
* are allowed while enhancers implementing [iface@Clapper.Reactable] are not.
*
* Value of this property from a `GLOBAL` [class@Clapper.EnhancerProxyList] will carry
* over to all newly created [class@Clapper.Player] objects, while altering this on
* `LOCAL` proxy list will only influence given player instance that list belongs to.
*
* Changing this property will not remove already created enhancer instances, thus
* it is usually best practice to allow/disallow creation of given enhancer plugin
* right after [class@Clapper.Player] is created (before it or its queue are used).
*
* Since: 0.10
*/
param_specs[PROP_TARGET_CREATION_ALLOWED] = g_param_spec_boolean ("target-creation-allowed",
NULL, NULL, FALSE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (gobject_class, PROP_LAST, param_specs);
}

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once
@@ -77,4 +76,10 @@ void clapper_enhancer_proxy_set_locally (ClapperEnhancerProxy *proxy, const gcha
CLAPPER_API
void clapper_enhancer_proxy_set_locally_with_table (ClapperEnhancerProxy *proxy, GHashTable *table);
CLAPPER_API
void clapper_enhancer_proxy_set_target_creation_allowed (ClapperEnhancerProxy *proxy, gboolean allowed);
CLAPPER_API
gboolean clapper_enhancer_proxy_get_target_creation_allowed (ClapperEnhancerProxy *proxy);
G_END_DECLS

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"
@@ -33,6 +32,9 @@ static HMODULE _enhancers_dll_handle = NULL;
// Supported interfaces
#include "clapper-extractable.h"
#include "clapper-reactable.h"
#include <clapper-functionalities-availability.h>
#define GST_CAT_DEFAULT clapper_enhancers_loader_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
@@ -52,6 +54,28 @@ _import_enhancers (const gchar *enhancers_path)
g_strfreev (dir_paths);
}
static GObject *
_force_create_enhancer (ClapperEnhancerProxy *proxy, GType iface_type)
{
GObject *enhancer = NULL;
PeasPluginInfo *info = (PeasPluginInfo *) clapper_enhancer_proxy_get_peas_info (proxy);
g_mutex_lock (&load_lock);
if (!peas_plugin_info_is_loaded (info) && !peas_engine_load_plugin (_engine, info)) {
GST_ERROR ("Could not load enhancer: %s", peas_plugin_info_get_module_name (info));
} else if (!peas_engine_provides_extension (_engine, info, iface_type)) {
GST_LOG ("No \"%s\" enhancer in module: %s", g_type_name (iface_type),
peas_plugin_info_get_module_name (info));
} else {
enhancer = peas_engine_create_extension (_engine, info, iface_type, NULL);
}
g_mutex_unlock (&load_lock);
return enhancer;
}
/*
* clapper_enhancers_loader_initialize:
*
@@ -110,6 +134,36 @@ clapper_enhancers_loader_initialize (ClapperEnhancerProxyList *proxies)
ClapperEnhancerProxy *proxy;
gboolean filled;
/* FIXME: 1.0: Remove together with features code and manager.
* These would clash with each other, so avoid loading these
* as enhancers when also compiled as part of the library. */
#if (CLAPPER_HAVE_MPRIS || CLAPPER_HAVE_DISCOVERER || CLAPPER_HAVE_SERVER)
guint f_index;
const gchar *module_name = peas_plugin_info_get_module_name (info);
const gchar *ported_features[] = {
#if CLAPPER_HAVE_MPRIS
"clapper-mpris",
#endif
#if CLAPPER_HAVE_DISCOVERER
"clapper-discoverer",
#endif
#if CLAPPER_HAVE_SERVER
"clapper-server",
#endif
};
for (f_index = 0; f_index < G_N_ELEMENTS (ported_features); ++f_index) {
if (strcmp (module_name, ported_features[f_index]) == 0) {
GST_INFO ("Skipped \"%s\" enhancer module, since its"
" loaded from deprecated feature object", module_name);
g_clear_object (&info);
}
}
if (!info) // cleared when exists as feature
continue;
#endif
/* Clapper supports only 1 proxy per plugin. Each plugin can
* ship 1 class, but it can implement more than 1 interface. */
proxy = clapper_enhancer_proxy_new_global_take ((GObject *) info);
@@ -118,12 +172,12 @@ clapper_enhancers_loader_initialize (ClapperEnhancerProxyList *proxies)
* Otherwise make an instance and fill missing data from it (slow). */
if (!(filled = clapper_enhancer_proxy_fill_from_cache (proxy))) {
GObject *enhancer;
GType main_types[1] = { CLAPPER_TYPE_EXTRACTABLE };
const GType main_types[] = { CLAPPER_TYPE_EXTRACTABLE, CLAPPER_TYPE_REACTABLE };
guint j;
/* We cannot ask libpeas for "any" of our main interfaces, so try each one until found */
for (j = 0; j < G_N_ELEMENTS (main_types); ++j) {
if ((enhancer = clapper_enhancers_loader_create_enhancer (proxy, main_types[j]))) {
if ((enhancer = _force_create_enhancer (proxy, main_types[j]))) {
filled = clapper_enhancer_proxy_fill_from_instance (proxy, enhancer);
g_object_unref (enhancer);
@@ -168,21 +222,8 @@ clapper_enhancers_loader_initialize (ClapperEnhancerProxyList *proxies)
GObject *
clapper_enhancers_loader_create_enhancer (ClapperEnhancerProxy *proxy, GType iface_type)
{
GObject *enhancer = NULL;
PeasPluginInfo *info = (PeasPluginInfo *) clapper_enhancer_proxy_get_peas_info (proxy);
if (!clapper_enhancer_proxy_get_target_creation_allowed (proxy))
return NULL;
g_mutex_lock (&load_lock);
if (!peas_plugin_info_is_loaded (info) && !peas_engine_load_plugin (_engine, info)) {
GST_ERROR ("Could not load enhancer: %s", peas_plugin_info_get_module_name (info));
} else if (!peas_engine_provides_extension (_engine, info, iface_type)) {
GST_LOG ("No \"%s\" enhancer in module: %s", g_type_name (iface_type),
peas_plugin_info_get_module_name (info));
} else {
enhancer = peas_engine_create_extension (_engine, info, iface_type, NULL);
}
g_mutex_unlock (&load_lock);
return enhancer;
return _force_create_enhancer (proxy, iface_type);
}

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once
@@ -151,4 +150,23 @@ typedef enum
CLAPPER_ENHANCER_PARAM_DIRPATH = 1 << 20,
} ClapperEnhancerParamFlags;
/**
* ClapperReactableItemUpdatedFlags:
* @CLAPPER_REACTABLE_ITEM_UPDATED_TITLE: Media item title was updated.
* @CLAPPER_REACTABLE_ITEM_UPDATED_DURATION: Media item duration was updated.
* @CLAPPER_REACTABLE_ITEM_UPDATED_TIMELINE: Media item timeline was updated.
* @CLAPPER_REACTABLE_ITEM_UPDATED_TAGS: Media item tags were updated.
*
* Flags informing which properties were updated within [class@Clapper.MediaItem].
*
* Since: 0.10
*/
typedef enum
{
CLAPPER_REACTABLE_ITEM_UPDATED_TITLE = 1 << 0,
CLAPPER_REACTABLE_ITEM_UPDATED_DURATION = 1 << 1,
CLAPPER_REACTABLE_ITEM_UPDATED_TIMELINE = 1 << 2,
CLAPPER_REACTABLE_ITEM_UPDATED_TAGS = 1 << 3,
} ClapperReactableItemUpdatedFlags;
G_END_DECLS

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
/**

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
/**
@@ -30,6 +29,8 @@
* 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.
*
* Deprecated: 0.10: Use [iface@Clapper.Reactable] instead.
*/
#include "clapper-feature.h"

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once
@@ -37,7 +36,7 @@ G_BEGIN_DECLS
#define CLAPPER_TYPE_FEATURE (clapper_feature_get_type())
#define CLAPPER_FEATURE_CAST(obj) ((ClapperFeature *)(obj))
CLAPPER_API
CLAPPER_DEPRECATED_FOR(ClapperReactable)
G_DECLARE_DERIVABLE_TYPE (ClapperFeature, clapper_feature, CLAPPER, FEATURE, GstObject)
/**

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#include "clapper-bus-private.h"

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#include "clapper-features-manager-private.h"

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
/**

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
/**

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once
@@ -23,7 +22,7 @@
#include <gst/pbutils/pbutils.h>
#include "clapper-media-item.h"
#include "clapper-player-private.h"
#include "clapper-player.h"
#include "clapper-app-bus-private.h"
G_BEGIN_DECLS

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
/**
@@ -30,6 +29,7 @@
#include "clapper-timeline-private.h"
#include "clapper-player-private.h"
#include "clapper-playbin-bus-private.h"
#include "clapper-reactables-manager-private.h"
#include "clapper-features-manager-private.h"
#include "clapper-utils-private.h"
@@ -470,7 +470,7 @@ _tags_replace_func (const GstTagList *tags, const gchar *tag, ClapperMediaItemTa
static gboolean
clapper_media_item_insert_tags_internal (ClapperMediaItem *self, const GstTagList *tags,
ClapperAppBus *app_bus, gboolean from_user)
ClapperAppBus *app_bus, gboolean from_user, ClapperReactableItemUpdatedFlags *flags)
{
ClapperMediaItemTagIterData data;
gboolean title_changed = FALSE, cont_changed = FALSE;
@@ -485,8 +485,12 @@ clapper_media_item_insert_tags_internal (ClapperMediaItem *self, const GstTagLis
gst_tag_list_foreach (tags, (GstTagForeachFunc) _tags_replace_func, &data);
if (data.changed) {
title_changed = _refresh_tag_prop_unlocked (self, GST_TAG_TITLE,
from_user, &self->title);
*flags |= CLAPPER_REACTABLE_ITEM_UPDATED_TAGS;
if ((title_changed = _refresh_tag_prop_unlocked (self, GST_TAG_TITLE,
from_user, &self->title))) {
*flags |= CLAPPER_REACTABLE_ITEM_UPDATED_TITLE;
}
cont_changed = _refresh_tag_prop_unlocked (self, GST_TAG_CONTAINER_FORMAT,
from_user, &self->container_format);
}
@@ -547,6 +551,7 @@ clapper_media_item_populate_tags (ClapperMediaItem *self, const GstTagList *tags
{
ClapperPlayer *player;
ClapperAppBus *app_bus = NULL;
ClapperReactableItemUpdatedFlags flags = 0;
gboolean changed;
g_return_val_if_fail (CLAPPER_IS_MEDIA_ITEM (self), FALSE);
@@ -560,11 +565,13 @@ clapper_media_item_populate_tags (ClapperMediaItem *self, const GstTagList *tags
if ((player = clapper_player_get_from_ancestor (GST_OBJECT_CAST (self))))
app_bus = player->app_bus;
changed = clapper_media_item_insert_tags_internal (self, tags, app_bus, TRUE);
changed = clapper_media_item_insert_tags_internal (self, tags, app_bus, TRUE, &flags);
if (changed && player) {
ClapperFeaturesManager *features_manager;
if (player->reactables_manager)
clapper_reactables_manager_trigger_item_updated (player->reactables_manager, self, flags);
if ((features_manager = clapper_player_get_features_manager (player)))
clapper_features_manager_trigger_item_updated (features_manager, self);
}
@@ -597,11 +604,14 @@ clapper_media_item_update_from_tag_list (ClapperMediaItem *self, const GstTagLis
GstTagScope scope = gst_tag_list_get_scope (tags);
if (scope == GST_TAG_SCOPE_GLOBAL) {
gboolean changed = clapper_media_item_insert_tags_internal (self, tags, player->app_bus, FALSE);
ClapperReactableItemUpdatedFlags flags = 0;
gboolean changed = clapper_media_item_insert_tags_internal (self, tags, player->app_bus, FALSE, &flags);
if (changed) {
ClapperFeaturesManager *features_manager;
if (player->reactables_manager)
clapper_reactables_manager_trigger_item_updated (player->reactables_manager, self, flags);
if ((features_manager = clapper_player_get_features_manager (player)))
clapper_features_manager_trigger_item_updated (features_manager, self);
}
@@ -614,6 +624,7 @@ clapper_media_item_update_from_discoverer_info (ClapperMediaItem *self, GstDisco
ClapperPlayer *player;
GstDiscovererStreamInfo *sinfo;
GstClockTime duration;
ClapperReactableItemUpdatedFlags flags = 0;
gdouble val_dbl;
gboolean changed = FALSE;
@@ -629,7 +640,7 @@ clapper_media_item_update_from_discoverer_info (ClapperMediaItem *self, GstDisco
GstDiscovererContainerInfo *cinfo = (GstDiscovererContainerInfo *) sinfo;
if ((tags = gst_discoverer_container_info_get_tags (cinfo)))
changed |= clapper_media_item_insert_tags_internal (self, tags, player->app_bus, FALSE);
changed |= clapper_media_item_insert_tags_internal (self, tags, player->app_bus, FALSE, &flags);
}
gst_discoverer_stream_info_unref (sinfo);
}
@@ -640,11 +651,16 @@ clapper_media_item_update_from_discoverer_info (ClapperMediaItem *self, GstDisco
duration = 0;
val_dbl = (gdouble) duration / GST_SECOND;
changed |= clapper_media_item_set_duration (self, val_dbl, player->app_bus);
if (clapper_media_item_set_duration (self, val_dbl, player->app_bus)) {
changed = TRUE;
flags |= CLAPPER_REACTABLE_ITEM_UPDATED_DURATION;
}
if (changed) {
ClapperFeaturesManager *features_manager;
if (player->reactables_manager)
clapper_reactables_manager_trigger_item_updated (player->reactables_manager, self, flags);
if ((features_manager = clapper_player_get_features_manager (player)))
clapper_features_manager_trigger_item_updated (features_manager, self);
}

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#include <gst/pbutils/pbutils.h>
@@ -173,6 +172,10 @@ _update_current_duration (ClapperPlayer *player)
if (clapper_media_item_set_duration (player->played_item, duration_dbl, player->app_bus)) {
ClapperFeaturesManager *features_manager;
if (player->reactables_manager) {
clapper_reactables_manager_trigger_item_updated (player->reactables_manager, player->played_item,
CLAPPER_REACTABLE_ITEM_UPDATED_DURATION);
}
if ((features_manager = clapper_player_get_features_manager (player)))
clapper_features_manager_trigger_item_updated (features_manager, player->played_item);
}
@@ -1046,6 +1049,8 @@ _handle_stream_start_msg (GstMessage *msg, ClapperPlayer *player)
if (G_LIKELY (changed)) {
clapper_queue_handle_played_item_changed (player->queue, player->played_item, player->app_bus);
if (player->reactables_manager)
clapper_reactables_manager_trigger_played_item_changed (player->reactables_manager, player->played_item);
if (clapper_player_get_have_features (player))
clapper_features_manager_trigger_played_item_changed (player->features_manager, player->played_item);
}

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once
@@ -27,6 +26,7 @@
#include "clapper-app-bus-private.h"
#include "clapper-features-manager-private.h"
#include "clapper-reactables-manager-private.h"
G_BEGIN_DECLS
@@ -47,6 +47,8 @@ struct _ClapperPlayer
ClapperFeaturesManager *features_manager;
gint have_features; // atomic integer
ClapperReactablesManager *reactables_manager;
ClapperEnhancerProxyList *enhancer_proxies;
/* This is different from queue current item as it is used/changed only

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
/**
@@ -50,6 +49,7 @@
#include "clapper-audio-stream-private.h"
#include "clapper-subtitle-stream-private.h"
#include "clapper-enhancer-proxy-list-private.h"
#include "clapper-reactable.h"
#include "clapper-enums-private.h"
#include "clapper-utils-private.h"
#include "../shared/clapper-shared-utils-private.h"
@@ -159,6 +159,8 @@ clapper_player_refresh_position (ClapperPlayer *self)
clapper_app_bus_post_prop_notify (self->app_bus,
GST_OBJECT_CAST (self), param_specs[PROP_POSITION]);
if (self->reactables_manager)
clapper_reactables_manager_trigger_position_changed (self->reactables_manager, position_dbl);
if (clapper_player_get_have_features (self))
clapper_features_manager_trigger_position_changed (self->features_manager, position_dbl);
}
@@ -225,6 +227,8 @@ clapper_player_handle_playbin_state_changed (ClapperPlayer *self)
clapper_app_bus_post_prop_notify (self->app_bus,
GST_OBJECT_CAST (self), param_specs[PROP_STATE]);
if (self->reactables_manager)
clapper_reactables_manager_trigger_state_changed (self->reactables_manager, state);
if (clapper_player_get_have_features (self))
clapper_features_manager_trigger_state_changed (self->features_manager, state);
}
@@ -256,6 +260,8 @@ clapper_player_handle_playbin_volume_changed (ClapperPlayer *self, const GValue
clapper_app_bus_post_prop_notify (self->app_bus,
GST_OBJECT_CAST (self), param_specs[PROP_VOLUME]);
if (self->reactables_manager)
clapper_reactables_manager_trigger_volume_changed (self->reactables_manager, volume);
if (clapper_player_get_have_features (self))
clapper_features_manager_trigger_volume_changed (self->features_manager, volume);
}
@@ -280,6 +286,8 @@ clapper_player_handle_playbin_mute_changed (ClapperPlayer *self, const GValue *v
clapper_app_bus_post_prop_notify (self->app_bus,
GST_OBJECT_CAST (self), param_specs[PROP_MUTE]);
if (self->reactables_manager)
clapper_reactables_manager_trigger_mute_changed (self->reactables_manager, mute);
if (clapper_player_get_have_features (self))
clapper_features_manager_trigger_mute_changed (self->features_manager, mute);
}
@@ -400,6 +408,8 @@ clapper_player_handle_playbin_rate_changed (ClapperPlayer *self, gdouble speed)
clapper_app_bus_post_prop_notify (self->app_bus,
GST_OBJECT_CAST (self), param_specs[PROP_SPEED]);
if (self->reactables_manager)
clapper_reactables_manager_trigger_speed_changed (self->reactables_manager, speed);
if (clapper_player_get_have_features (self))
clapper_features_manager_trigger_speed_changed (self->features_manager, speed);
}
@@ -2326,6 +2336,11 @@ clapper_player_init (ClapperPlayer *self)
clapper_enhancer_proxy_list_fill_from_global_proxies (self->enhancer_proxies);
if (clapper_enhancer_proxy_list_has_proxy_with_interface (self->enhancer_proxies, CLAPPER_TYPE_REACTABLE)) {
self->reactables_manager = clapper_reactables_manager_new ();
gst_object_set_parent (GST_OBJECT_CAST (self->reactables_manager), GST_OBJECT_CAST (self));
}
self->position_query = gst_query_new_position (GST_FORMAT_TIME);
self->current_state = GST_STATE_NULL;
@@ -2392,6 +2407,11 @@ clapper_player_finalize (GObject *object)
gst_object_unparent (GST_OBJECT_CAST (self->subtitle_streams));
gst_object_unref (self->subtitle_streams);
if (self->reactables_manager) {
gst_object_unparent (GST_OBJECT_CAST (self->reactables_manager));
gst_object_unref (self->reactables_manager);
}
gst_object_unparent (GST_OBJECT_CAST (self->enhancer_proxies));
gst_object_unref (self->enhancer_proxies);

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
/**
@@ -29,6 +28,8 @@
#include "clapper-media-item-private.h"
#include "clapper-player-private.h"
#include "clapper-playbin-bus-private.h"
#include "clapper-reactables-manager-private.h"
#include "clapper-features-manager-private.h"
#define CLAPPER_QUEUE_GET_REC_LOCK(obj) (&CLAPPER_QUEUE_CAST(obj)->rec_lock)
#define CLAPPER_QUEUE_REC_LOCK(obj) g_rec_mutex_lock (CLAPPER_QUEUE_GET_REC_LOCK(obj))
@@ -132,15 +133,27 @@ _announce_model_update (ClapperQueue *self, guint index, guint removed, guint ad
if (removed != added) {
ClapperPlayer *player = clapper_player_get_from_ancestor (GST_OBJECT_CAST (self));
if (player && clapper_player_get_have_features (player)) {
if (added == 1) // addition
clapper_features_manager_trigger_queue_item_added (player->features_manager, changed_item, index);
else if (removed == 1) // removal
clapper_features_manager_trigger_queue_item_removed (player->features_manager, changed_item, index);
else if (removed > 1 && added == 0) // queue cleared
clapper_features_manager_trigger_queue_cleared (player->features_manager);
else
if (player) {
gboolean have_features = clapper_player_get_have_features (player);
if (added == 1) { // addition
if (player->reactables_manager)
clapper_reactables_manager_trigger_queue_item_added (player->reactables_manager, changed_item, index);
if (have_features)
clapper_features_manager_trigger_queue_item_added (player->features_manager, changed_item, index);
} else if (removed == 1) { // removal
if (player->reactables_manager)
clapper_reactables_manager_trigger_queue_item_removed (player->reactables_manager, changed_item, index);
if (have_features)
clapper_features_manager_trigger_queue_item_removed (player->features_manager, changed_item, index);
} else if (removed > 1 && added == 0) { // queue cleared
if (player->reactables_manager)
clapper_reactables_manager_trigger_queue_cleared (player->reactables_manager);
if (have_features)
clapper_features_manager_trigger_queue_cleared (player->features_manager);
} else {
g_assert_not_reached ();
}
}
gst_clear_object (&player);
@@ -160,6 +173,8 @@ _announce_reposition (ClapperQueue *self, guint before, guint after)
GST_DEBUG_OBJECT (self, "Announcing item reposition: %u -> %u", before, after);
if ((player = clapper_player_get_from_ancestor (GST_OBJECT_CAST (self)))) {
if (player->reactables_manager)
clapper_reactables_manager_trigger_queue_item_repositioned (player->reactables_manager, before, after);
if (clapper_player_get_have_features (player))
clapper_features_manager_trigger_queue_item_repositioned (player->features_manager, before, after);
@@ -989,6 +1004,8 @@ clapper_queue_set_progression_mode (ClapperQueue *self, ClapperQueueProgressionM
clapper_app_bus_post_prop_notify (player->app_bus,
GST_OBJECT_CAST (self), param_specs[PROP_PROGRESSION_MODE]);
if (player->reactables_manager)
clapper_reactables_manager_trigger_queue_progression_changed (player->reactables_manager, mode);
if (clapper_player_get_have_features (player))
clapper_features_manager_trigger_queue_progression_changed (player->features_manager, mode);

View File

@@ -12,9 +12,8 @@
* 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.
* License along with this library; if not, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once

View File

@@ -0,0 +1,208 @@
/* Clapper Playback Library
* Copyright (C) 2025 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, see
* <https://www.gnu.org/licenses/>.
*/
/**
* ClapperReactable:
*
* An interface for creating enhancers that react to the
* playback and/or events that should influence it.
*
* Since: 0.10
*/
#include "clapper-reactable.h"
#include "clapper-utils-private.h"
#define CLAPPER_REACTABLE_DO_WITH_QUEUE(reactable, _queue_dst, ...) { \
ClapperPlayer *_player = clapper_reactable_get_player (reactable); \
if (G_LIKELY (_player != NULL)) { \
*_queue_dst = clapper_player_get_queue (_player); \
__VA_ARGS__ \
gst_object_unref (_player); }}
G_DEFINE_INTERFACE (ClapperReactable, clapper_reactable, GST_TYPE_OBJECT);
static void
clapper_reactable_default_init (ClapperReactableInterface *iface)
{
}
/**
* clapper_reactable_get_player:
* @reactable: a #ClapperReactable
*
* Get the [class@Clapper.Player] that this reactable is reacting to.
*
* This is meant to be used in implementations where reaction goes the
* other way around (from enhancer plugin to the player). For example
* some external event needs to influence parent player object like
* changing its state, seeking, etc.
*
* Note that enhancers are working in a non-main application thread, thus
* if you need to do operations on a [class@Clapper.Queue] such as adding/removing
* items, you need to switch thread first. Otherwise this will not be thread safe
* for applications that use single threaded toolkits such as #GTK. You can do this
* manually or use provided reactable convenience functions.
*
* Due to the threaded nature, you should also avoid comparisons to the current
* properties values in the player or its queue. While these are thread safe, there
* is no guarantee that values/objects between threads are still the same in both
* (or still exist). For example, instead of using [property@Clapper.Queue:current_item],
* monitor it with implemented [vfunc@Clapper.Reactable.played_item_changed] instead,
* as these functions are all serialized into your implementation thread.
*
* Returns: (transfer full) (nullable): A reference to the parent #ClapperPlayer.
*
* Since: 0.10
*/
ClapperPlayer *
clapper_reactable_get_player (ClapperReactable *self)
{
g_return_val_if_fail (CLAPPER_IS_REACTABLE (self), NULL);
return CLAPPER_PLAYER_CAST (gst_object_get_parent (GST_OBJECT_CAST (self)));
}
/**
* clapper_reactable_queue_append_sync:
* @reactable: a #ClapperReactable
* @item: a #ClapperMediaItem
*
* A convenience function that within application main thread synchronously appends
* an @item to the playback queue of the player that @reactable belongs to.
*
* Reactable enhancers should only modify the queue from the application
* main thread, switching thread either themselves or using this convenience
* function that does so.
*
* Note that this function will do no operation if called when there is no player
* set yet (e.g. inside enhancer construction) or if enhancer outlived the parent
* instance somehow. Both cases are considered to be implementation bug.
*
* Since: 0.10
*/
void
clapper_reactable_queue_append_sync (ClapperReactable *self, ClapperMediaItem *item)
{
ClapperQueue *queue;
g_return_if_fail (CLAPPER_IS_REACTABLE (self));
g_return_if_fail (CLAPPER_IS_MEDIA_ITEM (item));
CLAPPER_REACTABLE_DO_WITH_QUEUE (self, &queue, {
clapper_utils_queue_append_on_main_sync (queue, item);
});
}
/**
* clapper_reactable_queue_insert_sync:
* @reactable: a #ClapperReactable
* @item: a #ClapperMediaItem
* @after_item: a #ClapperMediaItem after which to insert or %NULL to prepend
*
* A convenience function that within application main thread synchronously inserts
* an @item to the playback queue position after @after_item of the player that
* @reactable belongs to.
*
* This function uses @after_item instead of position index in order to ensure
* desired position does not change during thread switching.
*
* Reactable enhancers should only modify the queue from the application
* main thread, switching thread either themselves or using this convenience
* function that does so.
*
* Note that this function will do no operation if called when there is no player
* set yet (e.g. inside enhancer construction) or if enhancer outlived the parent
* instance somehow. Both cases are considered to be implementation bug.
*
* Since: 0.10
*/
void
clapper_reactable_queue_insert_sync (ClapperReactable *self,
ClapperMediaItem *item, ClapperMediaItem *after_item)
{
ClapperQueue *queue;
g_return_if_fail (CLAPPER_IS_REACTABLE (self));
g_return_if_fail (CLAPPER_IS_MEDIA_ITEM (item));
g_return_if_fail (after_item == NULL || CLAPPER_IS_MEDIA_ITEM (after_item));
CLAPPER_REACTABLE_DO_WITH_QUEUE (self, &queue, {
clapper_utils_queue_insert_on_main_sync (queue, item, after_item);
});
}
/**
* clapper_reactable_queue_remove_sync:
* @reactable: a #ClapperReactable
* @item: a #ClapperMediaItem
*
* A convenience function that within application main thread synchronously removes
* an @item from the playback queue of the player that @reactable belongs to.
*
* Reactable enhancers should only modify the queue from the application
* main thread, switching thread either themselves or using this convenience
* function that does so.
*
* Note that this function will do no operation if called when there is no player
* set yet (e.g. inside enhancer construction) or if enhancer outlived the parent
* instance somehow. Both cases are considered to be implementation bug.
*
* Since: 0.10
*/
void
clapper_reactable_queue_remove_sync (ClapperReactable *self, ClapperMediaItem *item)
{
ClapperQueue *queue;
g_return_if_fail (CLAPPER_IS_REACTABLE (self));
g_return_if_fail (CLAPPER_IS_MEDIA_ITEM (item));
CLAPPER_REACTABLE_DO_WITH_QUEUE (self, &queue, {
clapper_utils_queue_remove_on_main_sync (queue, item);
});
}
/**
* clapper_reactable_queue_clear_sync:
* @reactable: a #ClapperReactable
*
* A convenience function that within application main thread synchronously clears
* the playback queue of the player that @reactable belongs to.
*
* Reactable enhancers should only modify the queue from the application
* main thread, switching thread either themselves or using this convenience
* function that does so.
*
* Note that this function will do no operation if called when there is no player
* set yet (e.g. inside enhancer construction) or if enhancer outlived the parent
* instance somehow. Both cases are considered to be implementation bug.
*
* Since: 0.10
*/
void
clapper_reactable_queue_clear_sync (ClapperReactable *self)
{
ClapperQueue *queue;
g_return_if_fail (CLAPPER_IS_REACTABLE (self));
CLAPPER_REACTABLE_DO_WITH_QUEUE (self, &queue, {
clapper_utils_queue_clear_on_main_sync (queue);
});
}

View File

@@ -0,0 +1,228 @@
/* Clapper Playback Library
* Copyright (C) 2025 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, see
* <https://www.gnu.org/licenses/>.
*/
#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-visibility.h>
#include <clapper/clapper-player.h>
#include <clapper/clapper-enums.h>
G_BEGIN_DECLS
#define CLAPPER_TYPE_REACTABLE (clapper_reactable_get_type())
#define CLAPPER_REACTABLE_CAST(obj) ((ClapperReactable *)(obj))
CLAPPER_API
G_DECLARE_INTERFACE (ClapperReactable, clapper_reactable, CLAPPER, REACTABLE, GstObject)
/**
* ClapperReactableInterface:
* @parent_iface: The parent interface structure.
* @state_changed: Player state changed.
* @position_changed: Player position changed.
* @speed_changed: Player speed changed.
* @volume_changed: Player volume changed.
* @mute_changed: Player mute state changed.
* @played_item_changed: New media item started playing.
* @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_repositioned: 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 _ClapperReactableInterface
{
GTypeInterface parent_iface;
/**
* ClapperReactableInterface::state_changed:
* @reactable: a #ClapperReactable
* @state: a #ClapperPlayerState
*
* Player state changed.
*
* Since: 0.10
*/
void (* state_changed) (ClapperReactable *reactable, ClapperPlayerState state);
/**
* ClapperReactableInterface::position_changed:
* @reactable: a #ClapperReactable
* @position: a decimal number with current position in seconds
*
* Player position changed.
*
* Since: 0.10
*/
void (* position_changed) (ClapperReactable *reactable, gdouble position);
/**
* ClapperReactableInterface::speed_changed:
* @reactable: a #ClapperReactable
* @speed: the playback speed multiplier
*
* Player speed changed.
*
* Since: 0.10
*/
void (* speed_changed) (ClapperReactable *reactable, gdouble speed);
/**
* ClapperReactableInterface::volume_changed:
* @reactable: a #ClapperReactable
* @volume: the volume level
*
* Player volume changed.
*
* Since: 0.10
*/
void (* volume_changed) (ClapperReactable *reactable, gdouble volume);
/**
* ClapperReactableInterface::mute_changed:
* @reactable: a #ClapperReactable
* @mute: %TRUE if player is muted, %FALSE otherwise
*
* Player mute state changed.
*
* Since: 0.10
*/
void (* mute_changed) (ClapperReactable *reactable, gboolean mute);
/**
* ClapperReactableInterface::played_item_changed:
* @reactable: a #ClapperReactable
* @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.
*
* Since: 0.10
*/
void (* played_item_changed) (ClapperReactable *reactable, ClapperMediaItem *item);
/**
* ClapperReactableInterface::item_updated:
* @reactable: a #ClapperReactable
* @item: a #ClapperMediaItem that was updated
* @flags: flags informing which properties were updated
*
* An item in queue got updated.
*
* This might be (or not) currently played item.
* Implementations can compare it against the last item from
* [vfunc@Clapper.Reactable.played_item_changed] if they
* need to know that.
*
* Since: 0.10
*/
void (* item_updated) (ClapperReactable *reactable, ClapperMediaItem *item, ClapperReactableItemUpdatedFlags flags);
/**
* ClapperReactableInterface::queue_item_added:
* @reactable: a #ClapperReactable
* @item: a #ClapperMediaItem that was added
* @index: position at which @item was placed in queue
*
* An item was added to the queue.
*
* Since: 0.10
*/
void (* queue_item_added) (ClapperReactable *reactable, ClapperMediaItem *item, guint index);
/**
* ClapperReactableInterface::queue_item_removed:
* @reactable: a #ClapperReactable
* @item: a #ClapperMediaItem that was removed
* @index: position from which @item was removed in queue
*
* An item was removed from queue.
*
* Implementations that are interested in queue items removal
* should also implement [vfunc@Clapper.Reactable.queue_cleared].
*
* Since: 0.10
*/
void (* queue_item_removed) (ClapperReactable *reactable, ClapperMediaItem *item, guint index);
/**
* ClapperReactableInterface::queue_item_repositioned:
* @reactable: a #ClapperReactable
* @before: position from which #ClapperMediaItem was removed
* @after: position at which #ClapperMediaItem was inserted after removal
*
* An item changed position within queue.
*
* Since: 0.10
*/
void (* queue_item_repositioned) (ClapperReactable *reactable, guint before, guint after);
/**
* ClapperReactableInterface::queue_cleared:
* @reactable: a #ClapperReactable
*
* All items were removed from queue.
*
* Note that in such event [vfunc@Clapper.Reactable.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.
*
* Since: 0.10
*/
void (* queue_cleared) (ClapperReactable *reactable);
/**
* ClapperReactableInterface::queue_progression_changed:
* @reactable: a #ClapperReactable
* @mode: a #ClapperQueueProgressionMode
*
* Progression mode of the queue was changed.
*
* Since: 0.10
*/
void (* queue_progression_changed) (ClapperReactable *reactable, ClapperQueueProgressionMode mode);
/*< private >*/
gpointer padding[8];
};
CLAPPER_API
ClapperPlayer * clapper_reactable_get_player (ClapperReactable *reactable);
CLAPPER_API
void clapper_reactable_queue_append_sync (ClapperReactable *reactable, ClapperMediaItem *item);
CLAPPER_API
void clapper_reactable_queue_insert_sync (ClapperReactable *reactable, ClapperMediaItem *item, ClapperMediaItem *after_item);
CLAPPER_API
void clapper_reactable_queue_remove_sync (ClapperReactable *reactable, ClapperMediaItem *item);
CLAPPER_API
void clapper_reactable_queue_clear_sync (ClapperReactable *reactable);
G_END_DECLS

View File

@@ -0,0 +1,78 @@
/* Clapper Playback Library
* Copyright (C) 2025 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, see
* <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "clapper-enums.h"
#include "clapper-threaded-object.h"
#include "clapper-enhancer-proxy.h"
#include "clapper-media-item.h"
G_BEGIN_DECLS
#define CLAPPER_TYPE_REACTABLES_MANAGER (clapper_reactables_manager_get_type())
#define CLAPPER_REACTABLES_MANAGER_CAST(obj) ((ClapperReactablesManager *)(obj))
G_DECLARE_FINAL_TYPE (ClapperReactablesManager, clapper_reactables_manager, CLAPPER, REACTABLES_MANAGER, ClapperThreadedObject)
G_GNUC_INTERNAL
void clapper_reactables_manager_initialize (void);
G_GNUC_INTERNAL
ClapperReactablesManager * clapper_reactables_manager_new (void);
G_GNUC_INTERNAL
void clapper_reactables_manager_trigger_configure_take_config (ClapperReactablesManager *manager, ClapperEnhancerProxy *proxy, GstStructure *config);
G_GNUC_INTERNAL
void clapper_reactables_manager_trigger_state_changed (ClapperReactablesManager *manager, ClapperPlayerState state);
G_GNUC_INTERNAL
void clapper_reactables_manager_trigger_position_changed (ClapperReactablesManager *manager, gdouble position);
G_GNUC_INTERNAL
void clapper_reactables_manager_trigger_speed_changed (ClapperReactablesManager *manager, gdouble speed);
G_GNUC_INTERNAL
void clapper_reactables_manager_trigger_volume_changed (ClapperReactablesManager *manager, gdouble volume);
G_GNUC_INTERNAL
void clapper_reactables_manager_trigger_mute_changed (ClapperReactablesManager *manager, gboolean mute);
G_GNUC_INTERNAL
void clapper_reactables_manager_trigger_played_item_changed (ClapperReactablesManager *manager, ClapperMediaItem *item);
G_GNUC_INTERNAL
void clapper_reactables_manager_trigger_item_updated (ClapperReactablesManager *manager, ClapperMediaItem *item, ClapperReactableItemUpdatedFlags flags);
G_GNUC_INTERNAL
void clapper_reactables_manager_trigger_queue_item_added (ClapperReactablesManager *manager, ClapperMediaItem *item, guint index);
G_GNUC_INTERNAL
void clapper_reactables_manager_trigger_queue_item_removed (ClapperReactablesManager *manager, ClapperMediaItem *item, guint index);
G_GNUC_INTERNAL
void clapper_reactables_manager_trigger_queue_item_repositioned (ClapperReactablesManager *manager, guint before, guint after);
G_GNUC_INTERNAL
void clapper_reactables_manager_trigger_queue_cleared (ClapperReactablesManager *manager);
G_GNUC_INTERNAL
void clapper_reactables_manager_trigger_queue_progression_changed (ClapperReactablesManager *manager, ClapperQueueProgressionMode mode);
G_END_DECLS

View File

@@ -0,0 +1,524 @@
/* Clapper Playback Library
* Copyright (C) 2025 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, see
* <https://www.gnu.org/licenses/>.
*/
#include <gst/gst.h>
#include "clapper-reactables-manager-private.h"
#include "clapper-reactable.h"
#include "clapper-bus-private.h"
#include "clapper-player.h"
#include "clapper-enhancer-proxy-list.h"
#include "clapper-enhancer-proxy-private.h"
#include "clapper-utils-private.h"
#include "clapper-functionalities-availability.h"
#if CLAPPER_WITH_ENHANCERS_LOADER
#include "clapper-enhancers-loader-private.h"
#endif
#define CONFIG_STRUCTURE_NAME "config"
#define GST_CAT_DEFAULT clapper_reactables_manager_debug
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
struct _ClapperReactablesManager
{
ClapperThreadedObject parent;
GstBus *bus;
GPtrArray *array;
gboolean prepare_called;
};
#define parent_class clapper_reactables_manager_parent_class
G_DEFINE_TYPE (ClapperReactablesManager, clapper_reactables_manager, CLAPPER_TYPE_THREADED_OBJECT);
typedef struct
{
ClapperReactable *reactable;
ClapperEnhancerProxy *proxy;
GSettings *settings;
} ClapperReactableManagerData;
enum
{
CLAPPER_REACTABLES_MANAGER_EVENT_INVALID = 0,
CLAPPER_REACTABLES_MANAGER_EVENT_STATE_CHANGED,
CLAPPER_REACTABLES_MANAGER_EVENT_POSITION_CHANGED,
CLAPPER_REACTABLES_MANAGER_EVENT_SPEED_CHANGED,
CLAPPER_REACTABLES_MANAGER_EVENT_VOLUME_CHANGED,
CLAPPER_REACTABLES_MANAGER_EVENT_MUTE_CHANGED,
CLAPPER_REACTABLES_MANAGER_EVENT_PLAYED_ITEM_CHANGED,
CLAPPER_REACTABLES_MANAGER_EVENT_ITEM_UPDATED,
CLAPPER_REACTABLES_MANAGER_EVENT_QUEUE_ITEM_ADDED,
CLAPPER_REACTABLES_MANAGER_EVENT_QUEUE_ITEM_REMOVED,
CLAPPER_REACTABLES_MANAGER_EVENT_QUEUE_ITEM_REPOSITIONED,
CLAPPER_REACTABLES_MANAGER_EVENT_QUEUE_CLEARED,
CLAPPER_REACTABLES_MANAGER_EVENT_QUEUE_PROGRESSION_CHANGED
};
enum
{
CLAPPER_REACTABLES_MANAGER_QUARK_CONFIGURE = 0,
CLAPPER_REACTABLES_MANAGER_QUARK_EVENT,
CLAPPER_REACTABLES_MANAGER_QUARK_VALUE,
CLAPPER_REACTABLES_MANAGER_QUARK_EXTRA_VALUE
};
static ClapperBusQuark _quarks[] = {
{"configure", 0},
{"event", 0},
{"value", 0},
{"extra-value", 0},
{NULL, 0}
};
#define _EVENT(e) G_PASTE(CLAPPER_REACTABLES_MANAGER_EVENT_, e)
#define _QUARK(q) (_quarks[CLAPPER_REACTABLES_MANAGER_QUARK_##q].quark)
#define _BUS_POST_EVENT_SINGLE(event_id,lower,type,val) { \
GValue _value = G_VALUE_INIT; \
g_value_init (&_value, type); \
g_value_set_##lower (&_value, val); \
_bus_post_event (self, event_id, &_value, NULL); }
#define _BUS_POST_EVENT_DUAL(event_id,lower1,type1,val1,lower2,type2,val2) { \
GValue _value1 = G_VALUE_INIT; \
GValue _value2 = G_VALUE_INIT; \
g_value_init (&_value1, type1); \
g_value_init (&_value2, type2); \
g_value_set_##lower1 (&_value1, val1); \
g_value_set_##lower2 (&_value2, val2); \
_bus_post_event (self, event_id, &_value1, &_value2); }
void
clapper_reactables_manager_initialize (void)
{
gint i;
for (i = 0; _quarks[i].name; ++i)
_quarks[i].quark = g_quark_from_static_string (_quarks[i].name);
}
static void
_settings_changed_cb (GSettings *settings, const gchar *key, ClapperReactableManagerData *data)
{
GST_DEBUG_OBJECT (data->reactable, "Global setting \"%s\" changed", key);
/* Local settings are applied through bus events, so all that is
* needed here is a check to not overwrite locally set setting */
if (!clapper_enhancer_proxy_has_locally_set (data->proxy, key)) {
GVariant *variant = g_settings_get_value (settings, key);
GValue value = G_VALUE_INIT;
if (G_LIKELY (clapper_utils_set_value_from_variant (&value, variant))) {
g_object_set_property (G_OBJECT (data->reactable), key, &value);
g_value_unset (&value);
}
g_variant_unref (variant);
}
}
static inline void
clapper_reactables_manager_handle_prepare (ClapperReactablesManager *self)
{
ClapperPlayer *player;
GST_INFO_OBJECT (self, "Preparing reactable enhancers");
player = CLAPPER_PLAYER_CAST (gst_object_get_parent (GST_OBJECT_CAST (self)));
if (G_LIKELY (player != NULL)) {
ClapperEnhancerProxyList *proxies = clapper_player_get_enhancer_proxies (player);
guint i, n_proxies = clapper_enhancer_proxy_list_get_n_proxies (proxies);
for (i = 0; i < n_proxies; ++i) {
ClapperEnhancerProxy *proxy = clapper_enhancer_proxy_list_peek_proxy (proxies, i);
ClapperReactable *reactable = NULL;
if (!clapper_enhancer_proxy_target_has_interface (proxy, CLAPPER_TYPE_REACTABLE))
continue;
#if CLAPPER_WITH_ENHANCERS_LOADER
reactable = CLAPPER_REACTABLE_CAST (
clapper_enhancers_loader_create_enhancer (proxy, CLAPPER_TYPE_REACTABLE));
#endif
if (reactable) {
ClapperReactableManagerData *data;
GstStructure *config;
if (g_object_is_floating (reactable))
gst_object_ref_sink (reactable);
data = g_new (ClapperReactableManagerData, 1);
data->reactable = reactable;
data->proxy = gst_object_ref (proxy);
data->settings = clapper_enhancer_proxy_get_settings (proxy);
GST_TRACE_OBJECT (self, "Created data for reactable: %" GST_PTR_FORMAT, data->reactable);
/* Settings are stored in data in order for this signal to keep working */
if (data->settings)
g_signal_connect (data->settings, "changed", G_CALLBACK (_settings_changed_cb), data);
if ((config = clapper_enhancer_proxy_make_current_config (proxy))) {
clapper_enhancer_proxy_apply_config_to_enhancer (proxy, config, (GObject *) reactable);
gst_structure_free (config);
}
g_ptr_array_add (self->array, data);
gst_object_set_parent (GST_OBJECT_CAST (data->reactable), GST_OBJECT_CAST (player));
}
}
GST_INFO_OBJECT (self, "Prepared %i reactable enhancers", self->array->len);
gst_object_unref (player);
} else {
GST_ERROR_OBJECT (self, "Could not prepare reactable enhancers!");
}
}
static inline void
clapper_reactables_manager_handle_configure (ClapperReactablesManager *self, const GstStructure *structure)
{
const GValue *proxy_val, *config_val;
ClapperEnhancerProxy *proxy;
const GstStructure *config;
guint i;
proxy_val = gst_structure_id_get_value (structure, _QUARK (VALUE));
config_val = gst_structure_id_get_value (structure, _QUARK (EXTRA_VALUE));
proxy = CLAPPER_ENHANCER_PROXY_CAST (g_value_get_object (proxy_val));
config = gst_value_get_structure (config_val);
for (i = 0; i < self->array->len; ++i) {
ClapperReactableManagerData *data = g_ptr_array_index (self->array, i);
if (data->proxy == proxy) {
clapper_enhancer_proxy_apply_config_to_enhancer (data->proxy,
config, (GObject *) data->reactable);
break;
}
}
}
static inline void
clapper_reactables_manager_handle_event (ClapperReactablesManager *self, const GstStructure *structure)
{
const GValue *value = gst_structure_id_get_value (structure, _QUARK (VALUE));
const GValue *extra_value = gst_structure_id_get_value (structure, _QUARK (EXTRA_VALUE));
guint i, event_id;
if (G_UNLIKELY (!gst_structure_id_get (structure,
_QUARK (EVENT), G_TYPE_ENUM, &event_id, NULL))) {
GST_ERROR_OBJECT (self, "Could not read event ID");
return;
}
for (i = 0; i < self->array->len; ++i) {
ClapperReactableManagerData *data = g_ptr_array_index (self->array, i);
ClapperReactableInterface *reactable_iface = CLAPPER_REACTABLE_GET_IFACE (data->reactable);
switch (event_id) {
case _EVENT (STATE_CHANGED):
if (reactable_iface->state_changed)
reactable_iface->state_changed (data->reactable, g_value_get_int (value));
break;
case _EVENT (POSITION_CHANGED):
if (reactable_iface->position_changed)
reactable_iface->position_changed (data->reactable, g_value_get_double (value));
break;
case _EVENT (SPEED_CHANGED):
if (reactable_iface->speed_changed)
reactable_iface->speed_changed (data->reactable, g_value_get_double (value));
break;
case _EVENT (VOLUME_CHANGED):
if (reactable_iface->volume_changed)
reactable_iface->volume_changed (data->reactable, g_value_get_double (value));
break;
case _EVENT (MUTE_CHANGED):
if (reactable_iface->mute_changed)
reactable_iface->mute_changed (data->reactable, g_value_get_boolean (value));
break;
case _EVENT (PLAYED_ITEM_CHANGED):
if (reactable_iface->played_item_changed) {
reactable_iface->played_item_changed (data->reactable,
CLAPPER_MEDIA_ITEM_CAST (g_value_get_object (value)));
}
break;
case _EVENT (ITEM_UPDATED):
if (reactable_iface->item_updated) {
reactable_iface->item_updated (data->reactable,
CLAPPER_MEDIA_ITEM_CAST (g_value_get_object (value)),
g_value_get_flags (extra_value));
}
break;
case _EVENT (QUEUE_ITEM_ADDED):
if (reactable_iface->queue_item_added) {
reactable_iface->queue_item_added (data->reactable,
CLAPPER_MEDIA_ITEM_CAST (g_value_get_object (value)),
g_value_get_uint (extra_value));
}
break;
case _EVENT (QUEUE_ITEM_REMOVED):
if (reactable_iface->queue_item_removed) {
reactable_iface->queue_item_removed (data->reactable,
CLAPPER_MEDIA_ITEM_CAST (g_value_get_object (value)),
g_value_get_uint (extra_value));
}
break;
case _EVENT (QUEUE_ITEM_REPOSITIONED):
if (reactable_iface->queue_item_repositioned) {
reactable_iface->queue_item_repositioned (data->reactable,
g_value_get_uint (value),
g_value_get_uint (extra_value));
}
break;
case _EVENT (QUEUE_CLEARED):
if (reactable_iface->queue_cleared)
reactable_iface->queue_cleared (data->reactable);
break;
case _EVENT (QUEUE_PROGRESSION_CHANGED):
if (reactable_iface->queue_progression_changed)
reactable_iface->queue_progression_changed (data->reactable, g_value_get_int (value));
break;
default:
GST_ERROR_OBJECT (self, "Invalid event ID on reactables bus: %u", event_id);
break;
}
}
}
static gboolean
_bus_message_func (GstBus *bus, GstMessage *msg, gpointer user_data G_GNUC_UNUSED)
{
if (G_LIKELY (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_APPLICATION)) {
ClapperReactablesManager *self = CLAPPER_REACTABLES_MANAGER_CAST (GST_MESSAGE_SRC (msg));
const GstStructure *structure = gst_message_get_structure (msg);
GQuark quark = gst_structure_get_name_id (structure);
if (quark == _QUARK (EVENT)) {
if (G_UNLIKELY (!self->prepare_called)) {
clapper_reactables_manager_handle_prepare (self);
self->prepare_called = TRUE;
}
clapper_reactables_manager_handle_event (self, structure);
} else if (quark == _QUARK (CONFIGURE)) {
clapper_reactables_manager_handle_configure (self, structure);
} else {
GST_ERROR_OBJECT (self, "Received invalid quark on reactables bus!");
}
}
return G_SOURCE_CONTINUE;
}
static void
_bus_post_event (ClapperReactablesManager *self, guint event_id,
GValue *value, GValue *extra_value)
{
GstStructure *structure = gst_structure_new_id (_QUARK (EVENT),
_QUARK (EVENT), G_TYPE_ENUM, event_id,
NULL);
if (value)
gst_structure_id_take_value (structure, _QUARK (VALUE), value);
if (extra_value)
gst_structure_id_take_value (structure, _QUARK (EXTRA_VALUE), extra_value);
gst_bus_post (self->bus, gst_message_new_application (
GST_OBJECT_CAST (self), structure));
}
/*
* clapper_reactables_manager_new:
*
* Returns: (transfer full): a new #ClapperReactablesManager instance.
*/
ClapperReactablesManager *
clapper_reactables_manager_new (void)
{
ClapperReactablesManager *reactables_manager;
reactables_manager = g_object_new (CLAPPER_TYPE_REACTABLES_MANAGER, NULL);
gst_object_ref_sink (reactables_manager);
return reactables_manager;
}
void
clapper_reactables_manager_trigger_configure_take_config (ClapperReactablesManager *self,
ClapperEnhancerProxy *proxy, GstStructure *config)
{
GstStructure *structure = gst_structure_new_id (_QUARK (CONFIGURE),
_QUARK (VALUE), G_TYPE_OBJECT, proxy, NULL);
GValue extra_value = G_VALUE_INIT;
g_value_init (&extra_value, GST_TYPE_STRUCTURE);
g_value_take_boxed (&extra_value, config);
gst_structure_id_take_value (structure, _QUARK (EXTRA_VALUE), &extra_value);
gst_bus_post (self->bus, gst_message_new_application (
GST_OBJECT_CAST (self), structure));
}
void
clapper_reactables_manager_trigger_state_changed (ClapperReactablesManager *self, ClapperPlayerState state)
{
_BUS_POST_EVENT_SINGLE (_EVENT (STATE_CHANGED), int, G_TYPE_INT, state);
}
void
clapper_reactables_manager_trigger_position_changed (ClapperReactablesManager *self, gdouble position)
{
_BUS_POST_EVENT_SINGLE (_EVENT (POSITION_CHANGED), double, G_TYPE_DOUBLE, position);
}
void
clapper_reactables_manager_trigger_speed_changed (ClapperReactablesManager *self, gdouble speed)
{
_BUS_POST_EVENT_SINGLE (_EVENT (SPEED_CHANGED), double, G_TYPE_DOUBLE, speed);
}
void
clapper_reactables_manager_trigger_volume_changed (ClapperReactablesManager *self, gdouble volume)
{
_BUS_POST_EVENT_SINGLE (_EVENT (VOLUME_CHANGED), double, G_TYPE_DOUBLE, volume);
}
void
clapper_reactables_manager_trigger_mute_changed (ClapperReactablesManager *self, gboolean mute)
{
_BUS_POST_EVENT_SINGLE (_EVENT (MUTE_CHANGED), boolean, G_TYPE_BOOLEAN, mute);
}
void
clapper_reactables_manager_trigger_played_item_changed (ClapperReactablesManager *self, ClapperMediaItem *item)
{
_BUS_POST_EVENT_SINGLE (_EVENT (PLAYED_ITEM_CHANGED), object, CLAPPER_TYPE_MEDIA_ITEM, item);
}
void
clapper_reactables_manager_trigger_item_updated (ClapperReactablesManager *self, ClapperMediaItem *item, ClapperReactableItemUpdatedFlags _flags)
{
_BUS_POST_EVENT_DUAL (_EVENT (ITEM_UPDATED), object, CLAPPER_TYPE_MEDIA_ITEM, item, flags, CLAPPER_TYPE_REACTABLE_ITEM_UPDATED_FLAGS, _flags);
}
void
clapper_reactables_manager_trigger_queue_item_added (ClapperReactablesManager *self, ClapperMediaItem *item, guint index)
{
_BUS_POST_EVENT_DUAL (_EVENT (QUEUE_ITEM_ADDED), object, CLAPPER_TYPE_MEDIA_ITEM, item, uint, G_TYPE_UINT, index);
}
void
clapper_reactables_manager_trigger_queue_item_removed (ClapperReactablesManager *self, ClapperMediaItem *item, guint index)
{
_BUS_POST_EVENT_DUAL (_EVENT (QUEUE_ITEM_REMOVED), object, CLAPPER_TYPE_MEDIA_ITEM, item, uint, G_TYPE_UINT, index);
}
void
clapper_reactables_manager_trigger_queue_item_repositioned (ClapperReactablesManager *self, guint before, guint after)
{
_BUS_POST_EVENT_DUAL (_EVENT (QUEUE_ITEM_REPOSITIONED), uint, G_TYPE_UINT, before, uint, G_TYPE_UINT, after);
}
void
clapper_reactables_manager_trigger_queue_cleared (ClapperReactablesManager *self)
{
_bus_post_event (self, _EVENT (QUEUE_CLEARED), NULL, NULL);
}
void
clapper_reactables_manager_trigger_queue_progression_changed (ClapperReactablesManager *self, ClapperQueueProgressionMode mode)
{
_BUS_POST_EVENT_SINGLE (_EVENT (QUEUE_PROGRESSION_CHANGED), int, G_TYPE_INT, mode);
}
static void
_data_remove_func (ClapperReactableManagerData *data)
{
GST_TRACE ("Removing data for reactable: %" GST_PTR_FORMAT, data->reactable);
g_clear_object (&data->settings);
gst_object_unparent (GST_OBJECT_CAST (data->reactable));
gst_object_unref (data->reactable);
gst_object_unref (data->proxy);
g_free (data);
}
static void
clapper_reactables_manager_thread_start (ClapperThreadedObject *threaded_object)
{
ClapperReactablesManager *self = CLAPPER_REACTABLES_MANAGER_CAST (threaded_object);
GST_TRACE_OBJECT (threaded_object, "Reactables manager thread start");
self->array = g_ptr_array_new_with_free_func (
(GDestroyNotify) _data_remove_func);
self->bus = gst_bus_new ();
gst_bus_add_watch (self->bus, (GstBusFunc) _bus_message_func, NULL);
}
static void
clapper_reactables_manager_thread_stop (ClapperThreadedObject *threaded_object)
{
ClapperReactablesManager *self = CLAPPER_REACTABLES_MANAGER_CAST (threaded_object);
GST_TRACE_OBJECT (self, "Reactables manager thread stop");
gst_bus_set_flushing (self->bus, TRUE);
gst_bus_remove_watch (self->bus);
gst_clear_object (&self->bus);
g_ptr_array_unref (self->array);
}
static void
clapper_reactables_manager_init (ClapperReactablesManager *self)
{
}
static void
clapper_reactables_manager_finalize (GObject *object)
{
GST_TRACE_OBJECT (object, "Finalize");
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
clapper_reactables_manager_class_init (ClapperReactablesManagerClass *klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
ClapperThreadedObjectClass *threaded_object = (ClapperThreadedObjectClass *) klass;
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "clapperreactablesmanager", 0,
"Clapper Reactables Manager");
gobject_class->finalize = clapper_reactables_manager_finalize;
threaded_object->thread_start = clapper_reactables_manager_thread_start;
threaded_object->thread_stop = clapper_reactables_manager_thread_stop;
}

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