/pidgin/main: 7c0420c7ac81: VV: make prefs actually working; add...
Tomasz Wasilczyk
tomkiewicz at cpw.pidgin.im
Sun Jun 2 08:01:12 EDT 2013
Changeset: 7c0420c7ac8123f53712141ae369e14de05a49a1
Author: Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date: 2013-06-02 14:00 +0200
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/7c0420c7ac81
Description:
VV: make prefs actually working; add <Disabled> video source
diffstat:
pidgin/gtkmedia.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++----
pidgin/gtkprefs.c | 72 +++++++++++++++++++----------------------------------
2 files changed, 93 insertions(+), 52 deletions(-)
diffs (252 lines):
diff --git a/pidgin/gtkmedia.c b/pidgin/gtkmedia.c
--- a/pidgin/gtkmedia.c
+++ b/pidgin/gtkmedia.c
@@ -1057,6 +1057,49 @@ pidgin_media_new_cb(PurpleMediaManager *
}
static GstElement *
+create_configured_vv_element(const gchar *type, const gchar *dir)
+{
+ gchar *tmp;
+ const gchar *plugin, *device;
+ GstElement *ret;
+
+ tmp = g_strdup_printf(PIDGIN_PREFS_ROOT "/vvconfig/%s/%s/plugin", type, dir);
+ plugin = purple_prefs_get_string(tmp);
+ g_free(tmp);
+
+ tmp = g_strdup_printf(PIDGIN_PREFS_ROOT "/vvconfig/%s/%s/device", type, dir);
+ device = purple_prefs_get_string(tmp);
+ g_free(tmp);
+
+ if (plugin == NULL || plugin[0] == '\0')
+ return NULL;
+
+ if (g_strcmp0(type, "video") == 0 && g_strcmp0(dir, "src") == 0 &&
+ g_strcmp0(plugin, "disabled") == 0)
+ {
+ ret = gst_element_factory_make("videotestsrc", NULL);
+ g_object_set(G_OBJECT(ret), "is-live", 1, NULL);
+ if (g_strcmp0(device, "snow") == 0) {
+ /* GST_VIDEO_TEST_SRC_SNOW */
+ g_object_set(G_OBJECT(ret), "pattern", 1, NULL);
+ } else {
+ /* GST_VIDEO_TEST_SRC_BLACK */
+ g_object_set(G_OBJECT(ret), "pattern", 2, NULL);
+ }
+ return ret;
+ }
+
+ ret = gst_element_factory_make(plugin, NULL);
+ if (device != NULL && device[0] != '\0')
+ g_object_set(G_OBJECT(ret), "device", device, NULL);
+
+ if (g_strcmp0(plugin, "videotestsrc") == 0)
+ g_object_set(G_OBJECT(ret), "is-live", 1, NULL);
+
+ return ret;
+}
+
+static GstElement *
create_default_video_src(PurpleMedia *media,
const gchar *session_id, const gchar *participant)
{
@@ -1064,19 +1107,24 @@ create_default_video_src(PurpleMedia *me
GstPad *pad;
GstPad *ghost;
+ src = create_configured_vv_element("video", "src");
+
#ifdef _WIN32
/* autovideosrc doesn't pick ksvideosrc for some reason */
- src = gst_element_factory_make("ksvideosrc", NULL);
+ if (src == NULL)
+ src = gst_element_factory_make("ksvideosrc", NULL);
if (src == NULL)
src = gst_element_factory_make("dshowvideosrc", NULL);
if (src == NULL)
src = gst_element_factory_make("autovideosrc", NULL);
#elif defined(__APPLE__)
- src = gst_element_factory_make("osxvideosrc", NULL);
+ if (src == NULL)
+ src = gst_element_factory_make("osxvideosrc", NULL);
if (src == NULL)
src = gst_element_factory_make("autovideosrc", NULL);
#else
- src = gst_element_factory_make("gconfvideosrc", NULL);
+ if (src == NULL)
+ src = gst_element_factory_make("gconfvideosrc", NULL);
if (src == NULL)
src = gst_element_factory_make("autovideosrc", NULL);
if (src == NULL)
@@ -1111,7 +1159,12 @@ static GstElement *
create_default_video_sink(PurpleMedia *media,
const gchar *session_id, const gchar *participant)
{
- GstElement *sink = gst_element_factory_make("gconfvideosink", NULL);
+ GstElement *sink;
+
+ sink = create_configured_vv_element("video", "sink");
+
+ if (sink == NULL)
+ sink = gst_element_factory_make("gconfvideosink", NULL);
if (sink == NULL)
sink = gst_element_factory_make("autovideosink", NULL);
if (sink == NULL)
@@ -1125,7 +1178,11 @@ create_default_audio_src(PurpleMedia *me
const gchar *session_id, const gchar *participant)
{
GstElement *src;
- src = gst_element_factory_make("gconfaudiosrc", NULL);
+
+ src = create_configured_vv_element("audio", "src");
+
+ if (src == NULL)
+ src = gst_element_factory_make("gconfaudiosrc", NULL);
if (src == NULL)
src = gst_element_factory_make("autoaudiosrc", NULL);
if (src == NULL)
@@ -1150,7 +1207,11 @@ create_default_audio_sink(PurpleMedia *m
const gchar *session_id, const gchar *participant)
{
GstElement *sink;
- sink = gst_element_factory_make("gconfaudiosink", NULL);
+
+ sink = create_configured_vv_element("audio", "sink");
+
+ if (sink == NULL)
+ sink = gst_element_factory_make("gconfaudiosink", NULL);
if (sink == NULL)
sink = gst_element_factory_make("autoaudiosink",NULL);
if (sink == NULL) {
diff --git a/pidgin/gtkprefs.c b/pidgin/gtkprefs.c
--- a/pidgin/gtkprefs.c
+++ b/pidgin/gtkprefs.c
@@ -147,6 +147,7 @@ static const gchar *AUDIO_SINK_PLUGINS[]
};
static const gchar *VIDEO_SRC_PLUGINS[] = {
+ "disabled", N_("Disabled"),
"videotestsrc", "Test Input",
"dshowvideosrc","DirectDraw",
"ksvideosrc", "KS Video",
@@ -3106,6 +3107,13 @@ get_vv_element_devices(const gchar *elem
return g_list_reverse(ret);
}
+ if (g_strcmp0(element_name, "disabled") == 0) {
+ ret = g_list_prepend(ret, (gpointer)_("Random noise"));
+ ret = g_list_prepend(ret, "snow");
+
+ return g_list_reverse(ret);
+ }
+
element = gst_element_factory_make(element_name, "test");
if (!element) {
purple_debug_info("vvconfig", "'%s' - unable to find element\n",
@@ -3186,10 +3194,12 @@ get_vv_element_plugins(const gchar **plu
for (; plugins[0] && plugins[1]; plugins += 2) {
#if GST_CHECK_VERSION(1,0,0)
if (gst_registry_check_feature_version(gst_registry_get(),
- plugins[0], 0, 0, 0)) {
+ plugins[0], 0, 0, 0)
#else
- if (gst_default_registry_check_feature_version(plugins[0], 0, 0, 0)) {
+ if (gst_default_registry_check_feature_version(plugins[0], 0, 0, 0)
#endif
+ || g_strcmp0(plugins[0], "disabled") == 0)
+ {
ret = g_list_prepend(ret, (gpointer)plugins[1]);
ret = g_list_prepend(ret, (gpointer)plugins[0]);
}
@@ -3270,31 +3280,16 @@ make_vv_frame(GtkWidget *parent, GtkSize
}
static GstElement *
-create_test_element(const char *type, const char *dir, PurpleMediaElementInfo *info)
+create_test_element(PurpleMediaElementType type)
{
- char *tmp;
- const gchar *plugin;
- const gchar *device;
- GstElement *ret;
-
- tmp = g_strdup_printf(PIDGIN_PREFS_ROOT "/vvconfig/%s/%s/plugin", type, dir);
- plugin = purple_prefs_get_string(tmp);
- g_free(tmp);
-
- tmp = g_strdup_printf(PIDGIN_PREFS_ROOT "/vvconfig/%s/%s/device", type, dir);
- device = purple_prefs_get_string(tmp);
- g_free(tmp);
-
- if (plugin[0] == '\0')
- return purple_media_element_info_call_create(info, NULL, NULL, NULL);
-
- ret = gst_element_factory_make(plugin, NULL);
- if (device[0] != '\0')
- g_object_set(G_OBJECT(ret), "device", device, NULL);
- if (!strcmp(plugin, "videotestsrc"))
- g_object_set(G_OBJECT(ret), "is-live", 1, NULL);
-
- return ret;
+ PurpleMediaElementInfo *element_info;
+
+ element_info = purple_media_manager_get_active_element(purple_media_manager_get(), type);
+
+ g_return_val_if_fail(element_info, NULL);
+
+ return purple_media_element_info_call_create(element_info,
+ NULL, NULL, NULL);
}
static void
@@ -3307,23 +3302,16 @@ vv_test_switch_page_cb(GtkNotebook *note
static GstElement *
create_voice_pipeline(void)
{
- PurpleMediaManager *manager;
- PurpleMediaElementInfo *audio_src, *audio_sink;
GstElement *pipeline;
GstElement *src, *sink;
GstElement *volume;
GstElement *level;
GstElement *valve;
- manager = purple_media_manager_get();
- audio_src = purple_media_manager_get_active_element(manager,
- PURPLE_MEDIA_ELEMENT_AUDIO | PURPLE_MEDIA_ELEMENT_SRC);
- audio_sink = purple_media_manager_get_active_element(manager,
- PURPLE_MEDIA_ELEMENT_AUDIO | PURPLE_MEDIA_ELEMENT_SINK);
-
pipeline = gst_pipeline_new("voicetest");
- src = create_test_element("audio", "src", audio_src);
- sink = create_test_element("audio", "sink", audio_sink);
+
+ src = create_test_element(PURPLE_MEDIA_ELEMENT_AUDIO | PURPLE_MEDIA_ELEMENT_SRC);
+ sink = create_test_element(PURPLE_MEDIA_ELEMENT_AUDIO | PURPLE_MEDIA_ELEMENT_SINK);
volume = gst_element_factory_make("volume", "volume");
level = gst_element_factory_make("level", "level");
valve = gst_element_factory_make("valve", "valve");
@@ -3525,20 +3513,12 @@ make_voice_test(GtkWidget *vbox)
static GstElement *
create_video_pipeline(void)
{
- PurpleMediaManager *manager;
- PurpleMediaElementInfo *video_src, *video_sink;
GstElement *pipeline;
GstElement *src, *sink;
- manager = purple_media_manager_get();
- video_src = purple_media_manager_get_active_element(manager,
- PURPLE_MEDIA_ELEMENT_VIDEO | PURPLE_MEDIA_ELEMENT_SRC);
- video_sink = purple_media_manager_get_active_element(manager,
- PURPLE_MEDIA_ELEMENT_VIDEO | PURPLE_MEDIA_ELEMENT_SINK);
-
pipeline = gst_pipeline_new("videotest");
- src = create_test_element("video", "src", video_src);
- sink = create_test_element("video", "sink", video_sink);
+ src = create_test_element(PURPLE_MEDIA_ELEMENT_VIDEO | PURPLE_MEDIA_ELEMENT_SRC);
+ sink = create_test_element(PURPLE_MEDIA_ELEMENT_VIDEO | PURPLE_MEDIA_ELEMENT_SINK);
gst_bin_add_many(GST_BIN(pipeline), src, sink, NULL);
gst_element_link_many(src, sink, NULL);
More information about the Commits
mailing list