/pidgin/main: fa361c7394a2: Merged in xhaakon/pidgin (pull reque...
Gary Kramlich
grim at reaperworld.com
Mon Jul 18 00:33:09 EDT 2016
Changeset: fa361c7394a259510beaefe6134211aa3ba2c3fb
Author: Gary Kramlich <grim at reaperworld.com>
Date: 2016-07-07 22:56 -0500
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/fa361c7394a2
Description:
Merged in xhaakon/pidgin (pull request #86)
GStreamer 1.0 media device management
diffstat:
ChangeLog.API | 1 +
finch/gntmedia.c | 45 +++-
libpurple/media-gst.h | 16 +-
libpurple/mediamanager.c | 533 ++++++++++++++++++++++++++++++++++++++++++++++-
pidgin/gtkmedia.c | 83 +++++-
pidgin/gtkprefs.c | 350 ++++++++++++------------------
6 files changed, 787 insertions(+), 241 deletions(-)
diffs (truncated from 1412 to 300 lines):
diff --git a/ChangeLog.API b/ChangeLog.API
--- a/ChangeLog.API
+++ b/ChangeLog.API
@@ -71,6 +71,7 @@ version 3.0.0 (??/??/????):
* purple_notify_searchresult_column_set_visible
* purple_notify_user_info_entry_destroy
* purple_notify_user_info_prepend_pair_plaintext
+ * purple_media_manager_enumerate_elements
* purple_menu_action_get_callback
* purple_menu_action_get_children
* purple_menu_action_get_data
diff --git a/finch/gntmedia.c b/finch/gntmedia.c
--- a/finch/gntmedia.c
+++ b/finch/gntmedia.c
@@ -408,8 +408,10 @@ call_cmd_cb(PurpleConversation *conv, co
return PURPLE_CMD_RET_OK;
}
+#ifndef USE_GSTREAMER
+
static GstElement *
-create_default_audio_src(PurpleMedia *media,
+create_default_audio_src(PurpleMediaElementInfo *info, PurpleMedia *media,
const gchar *session_id, const gchar *participant)
{
GstElement *src;
@@ -432,7 +434,7 @@ create_default_audio_src(PurpleMedia *me
}
static GstElement *
-create_default_audio_sink(PurpleMedia *media,
+create_default_audio_sink(PurpleMediaElementInfo *info, PurpleMedia *media,
const gchar *session_id, const gchar *participant)
{
GstElement *sink;
@@ -446,14 +448,41 @@ create_default_audio_sink(PurpleMedia *m
}
return sink;
}
+#endif /* USE_GSTREAMER */
#endif /* USE_VV */
void finch_media_manager_init(void)
{
#ifdef USE_VV
PurpleMediaManager *manager = purple_media_manager_get();
- PurpleMediaElementInfo *default_audio_src =
- g_object_new(PURPLE_TYPE_MEDIA_ELEMENT_INFO,
+ PurpleMediaElementInfo *audio_src;
+ PurpleMediaElementInfo *audio_sink;
+#ifdef USE_GSTREAMER
+ const char *pref;
+
+ pref = purple_prefs_get_string(
+ FINCH_PREFS_ROOT "/vvconfig/audio/src/device");
+ audio_src = purple_media_manager_get_element_info(manager, pref);
+ if (!audio_src) {
+ pref = "autoaudiosrc";
+ purple_prefs_set_string(
+ FINCH_PREFS_ROOT "/vvconfig/audio/src/device", pref);
+ audio_src = purple_media_manager_get_element_info(manager,
+ pref);
+ }
+
+ pref = purple_prefs_get_string(
+ FINCH_PREFS_ROOT "/vvconfig/audio/sink/device");
+ audio_sink = purple_media_manager_get_element_info(manager, pref);
+ if (!audio_sink) {
+ pref = "autoaudiosink";
+ purple_prefs_set_string(
+ FINCH_PREFS_ROOT "/vvconfig/audio/sink/device", pref);
+ audio_sink = purple_media_manager_get_element_info(manager,
+ pref);
+ }
+#else
+ audio_src = g_object_new(PURPLE_TYPE_MEDIA_ELEMENT_INFO,
"id", "finchdefaultaudiosrc",
"name", "Finch Default Audio Source",
"type", PURPLE_MEDIA_ELEMENT_AUDIO
@@ -461,14 +490,14 @@ void finch_media_manager_init(void)
| PURPLE_MEDIA_ELEMENT_ONE_SRC
| PURPLE_MEDIA_ELEMENT_UNIQUE,
"create-cb", create_default_audio_src, NULL);
- PurpleMediaElementInfo *default_audio_sink =
- g_object_new(PURPLE_TYPE_MEDIA_ELEMENT_INFO,
+ audio_sink = g_object_new(PURPLE_TYPE_MEDIA_ELEMENT_INFO,
"id", "finchdefaultaudiosink",
"name", "Finch Default Audio Sink",
"type", PURPLE_MEDIA_ELEMENT_AUDIO
| PURPLE_MEDIA_ELEMENT_SINK
| PURPLE_MEDIA_ELEMENT_ONE_SINK,
"create-cb", create_default_audio_sink, NULL);
+#endif /* USE_GSTREAMER */
g_signal_connect(G_OBJECT(manager), "init-media", G_CALLBACK(finch_new_media), NULL);
purple_cmd_register("call", "", PURPLE_CMD_P_DEFAULT,
@@ -480,8 +509,8 @@ void finch_media_manager_init(void)
PURPLE_MEDIA_CAPS_AUDIO_SINGLE_DIRECTION);
purple_debug_info("gntmedia", "Registering media element types\n");
- purple_media_manager_set_active_element(manager, default_audio_src);
- purple_media_manager_set_active_element(manager, default_audio_sink);
+ purple_media_manager_set_active_element(manager, audio_src);
+ purple_media_manager_set_active_element(manager, audio_sink);
#endif
}
diff --git a/libpurple/media-gst.h b/libpurple/media-gst.h
--- a/libpurple/media-gst.h
+++ b/libpurple/media-gst.h
@@ -49,8 +49,9 @@
typedef struct _PurpleMediaElementInfo PurpleMediaElementInfo;
typedef struct _PurpleMediaElementInfoClass PurpleMediaElementInfoClass;
-typedef GstElement *(*PurpleMediaElementCreateCallback)(PurpleMedia *media,
- const gchar *session_id, const gchar *participant);
+typedef GstElement *(*PurpleMediaElementCreateCallback)(
+ PurpleMediaElementInfo *info, PurpleMedia *media,
+ const gchar *session_id, const gchar *participant);
/**
* PurpleMediaElementType:
@@ -162,6 +163,17 @@ GstElement *purple_media_manager_get_ele
PurpleMediaSessionType type, PurpleMedia *media,
const gchar *session_id, const gchar *participant);
+/**
+ * purple_media_manager_enumerate_elements:
+ * @manager: The media manager to use to obtain the element infos.
+ * @type: The type of element infos to get.
+ *
+ * Returns: A #GList of registered #PurpleMediaElementInfo instances that match
+ * @type.
+ */
+GList *purple_media_manager_enumerate_elements(PurpleMediaManager *manager,
+ PurpleMediaElementType type);
+
PurpleMediaElementInfo *purple_media_manager_get_element_info(
PurpleMediaManager *manager, const gchar *name);
gboolean purple_media_manager_register_element(PurpleMediaManager *manager,
diff --git a/libpurple/mediamanager.c b/libpurple/mediamanager.c
--- a/libpurple/mediamanager.c
+++ b/libpurple/mediamanager.c
@@ -72,6 +72,12 @@ struct _PurpleMediaManagerPrivate
PurpleMediaElementInfo *audio_src;
PurpleMediaElementInfo *audio_sink;
+#ifdef USE_GSTREAMER
+#if GST_CHECK_VERSION(1, 4, 0)
+ GstDeviceMonitor *device_monitor;
+#endif /* GST_CHECK_VERSION(1, 4, 0) */
+#endif /* USE_GSTREAMER */
+
#ifdef HAVE_MEDIA_APPLICATION
/* Application data streams */
GList *appdata_info; /* holds PurpleMediaAppDataInfo */
@@ -113,6 +119,10 @@ static void purple_media_manager_finaliz
#ifdef HAVE_MEDIA_APPLICATION
static void free_appdata_info_locked (PurpleMediaAppDataInfo *info);
#endif
+#ifdef USE_GSTREAMER
+static void purple_media_manager_init_device_monitor(PurpleMediaManager *manager);
+static void purple_media_manager_register_static_elements(PurpleMediaManager *manager);
+#endif
static GObjectClass *parent_class = NULL;
@@ -122,6 +132,7 @@ enum {
INIT_MEDIA,
INIT_PRIVATE_MEDIA,
UI_CAPS_CHANGED,
+ ELEMENTS_CHANGED,
LAST_SIGNAL
};
static guint purple_media_manager_signals[LAST_SIGNAL] = {0};
@@ -188,12 +199,24 @@ purple_media_manager_class_init (PurpleM
G_TYPE_NONE, 2, PURPLE_MEDIA_TYPE_CAPS,
PURPLE_MEDIA_TYPE_CAPS);
+ purple_media_manager_signals[ELEMENTS_CHANGED] =
+ g_signal_new("elements-changed",
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
g_type_class_add_private(klass, sizeof(PurpleMediaManagerPrivate));
}
static void
purple_media_manager_init (PurpleMediaManager *media)
{
+#ifdef USE_GSTREAMER
+ GError *error;
+#endif /* USE_GSTREAMER */
+
media->priv = PURPLE_MEDIA_MANAGER_GET_PRIVATE(media);
media->priv->medias = NULL;
media->priv->private_medias = NULL;
@@ -203,6 +226,19 @@ purple_media_manager_init (PurpleMediaMa
media->priv->appdata_info = NULL;
g_mutex_init (&media->priv->appdata_mutex);
#endif
+#ifdef USE_GSTREAMER
+ if (gst_init_check(NULL, NULL, &error)) {
+ purple_media_manager_register_static_elements(media);
+ purple_media_manager_init_device_monitor(media);
+ } else {
+ purple_debug_error("mediamanager",
+ "GStreamer failed to initialize: %s.",
+ error ? error->message : "");
+ if (error) {
+ g_error_free(error);
+ }
+ }
+#endif /* USE_GSTREAMER */
purple_prefs_add_none("/purple/media");
purple_prefs_add_none("/purple/media/audio");
@@ -236,6 +272,14 @@ purple_media_manager_finalize (GObject *
(GDestroyNotify) free_appdata_info_locked);
g_mutex_clear (&priv->appdata_mutex);
#endif
+#ifdef USE_GSTREAMER
+#if GST_CHECK_VERSION(1, 4, 0)
+ if (priv->device_monitor) {
+ gst_device_monitor_stop(priv->device_monitor);
+ g_object_unref(priv->device_monitor);
+ }
+#endif /* GST_CHECK_VERSION(1, 4, 0) */
+#endif /* USE_GSTREAMER */
parent_class->finalize(media);
}
@@ -876,7 +920,7 @@ media_established_cb (PurpleMedia *media
}
static GstElement *
-create_send_appsrc(PurpleMedia *media,
+create_send_appsrc(PurpleMediaElementInfo *element_info, PurpleMedia *media,
const gchar *session_id, const gchar *participant)
{
PurpleMediaManager *manager = purple_media_manager_get ();
@@ -1022,7 +1066,7 @@ appsink_destroyed (PurpleMediaAppDataInf
}
static GstElement *
-create_recv_appsink(PurpleMedia *media,
+create_recv_appsink(PurpleMediaElementInfo *element_info, PurpleMedia *media,
const gchar *session_id, const gchar *participant)
{
PurpleMediaManager *manager = purple_media_manager_get ();
@@ -1233,6 +1277,30 @@ purple_media_manager_get_element_info(Pu
return NULL;
}
+static GQuark
+element_info_to_detail(PurpleMediaElementInfo *info)
+{
+ PurpleMediaElementType type;
+
+ type = purple_media_element_info_get_element_type(info);
+
+ if (type & PURPLE_MEDIA_ELEMENT_AUDIO) {
+ if (type & PURPLE_MEDIA_ELEMENT_SRC) {
+ return g_quark_from_string("audiosrc");
+ } else if (type & PURPLE_MEDIA_ELEMENT_SINK) {
+ return g_quark_from_string("audiosink");
+ }
+ } else if (type & PURPLE_MEDIA_ELEMENT_VIDEO) {
+ if (type & PURPLE_MEDIA_ELEMENT_SRC) {
+ return g_quark_from_string("videosrc");
+ } else if (type & PURPLE_MEDIA_ELEMENT_SINK) {
+ return g_quark_from_string("videosink");
+ }
+ }
+
+ return 0;
+}
+
gboolean
purple_media_manager_register_element(PurpleMediaManager *manager,
PurpleMediaElementInfo *info)
@@ -1240,6 +1308,7 @@ purple_media_manager_register_element(Pu
#ifdef USE_VV
PurpleMediaElementInfo *info2;
gchar *id;
+ GQuark detail;
g_return_val_if_fail(PURPLE_IS_MEDIA_MANAGER(manager), FALSE);
g_return_val_if_fail(info != NULL, FALSE);
@@ -1255,6 +1324,14 @@ purple_media_manager_register_element(Pu
manager->priv->elements =
g_list_prepend(manager->priv->elements, info);
+
+ detail = element_info_to_detail(info);
+ if (detail != 0) {
+ g_signal_emit(manager,
More information about the Commits
mailing list