comparison libpurple/mediamanager.c @ 29342:3ad839deed75

propagate from branch 'im.pidgin.pidgin' (head 780ee14f6ced21de7257b3149c186223ab446d57) to branch 'im.pidgin.pidgin.next.minor' (head bca91e5200ed5372978a121437fd19fe2774c583)
author John Bailey <rekkanoryo@rekkanoryo.org>
date Mon, 14 Dec 2009 15:49:07 +0000
parents 2b2b930281a0
children a8cc50c2279f
comparison
equal deleted inserted replaced
28800:139aa186e8cc 29342:3ad839deed75
35 #include "marshallers.h" 35 #include "marshallers.h"
36 #include "media-gst.h" 36 #include "media-gst.h"
37 #endif 37 #endif
38 38
39 #ifdef USE_VV 39 #ifdef USE_VV
40 40 #include <media/backend-fs2.h>
41 #include <gst/farsight/fs-conference-iface.h> 41
42 #include <gst/farsight/fs-element-added-notifier.h> 42 #include <gst/farsight/fs-element-added-notifier.h>
43 #include <gst/interfaces/xoverlay.h> 43 #include <gst/interfaces/xoverlay.h>
44 44
45 /** @copydoc _PurpleMediaManagerPrivate */ 45 /** @copydoc _PurpleMediaManagerPrivate */
46 typedef struct _PurpleMediaManagerPrivate PurpleMediaManagerPrivate; 46 typedef struct _PurpleMediaManagerPrivate PurpleMediaManagerPrivate;
78 PurpleMediaCaps ui_caps; 78 PurpleMediaCaps ui_caps;
79 GList *medias; 79 GList *medias;
80 GList *elements; 80 GList *elements;
81 GList *output_windows; 81 GList *output_windows;
82 gulong next_output_window_id; 82 gulong next_output_window_id;
83 GType backend_type;
83 84
84 PurpleMediaElementInfo *video_src; 85 PurpleMediaElementInfo *video_src;
85 PurpleMediaElementInfo *video_sink; 86 PurpleMediaElementInfo *video_sink;
86 PurpleMediaElementInfo *audio_src; 87 PurpleMediaElementInfo *audio_src;
87 PurpleMediaElementInfo *audio_sink; 88 PurpleMediaElementInfo *audio_sink;
98 99
99 100
100 101
101 enum { 102 enum {
102 INIT_MEDIA, 103 INIT_MEDIA,
104 UI_CAPS_CHANGED,
103 LAST_SIGNAL 105 LAST_SIGNAL
104 }; 106 };
105 static guint purple_media_manager_signals[LAST_SIGNAL] = {0}; 107 static guint purple_media_manager_signals[LAST_SIGNAL] = {0};
106 #endif 108 #endif
107 109
146 G_SIGNAL_RUN_LAST, 148 G_SIGNAL_RUN_LAST,
147 0, NULL, NULL, 149 0, NULL, NULL,
148 purple_smarshal_BOOLEAN__OBJECT_POINTER_STRING, 150 purple_smarshal_BOOLEAN__OBJECT_POINTER_STRING,
149 G_TYPE_BOOLEAN, 3, PURPLE_TYPE_MEDIA, 151 G_TYPE_BOOLEAN, 3, PURPLE_TYPE_MEDIA,
150 G_TYPE_POINTER, G_TYPE_STRING); 152 G_TYPE_POINTER, G_TYPE_STRING);
153
154 purple_media_manager_signals[UI_CAPS_CHANGED] = g_signal_new ("ui-caps-changed",
155 G_TYPE_FROM_CLASS (klass),
156 G_SIGNAL_RUN_LAST,
157 0, NULL, NULL,
158 purple_smarshal_VOID__FLAGS_FLAGS,
159 G_TYPE_NONE, 2, PURPLE_MEDIA_TYPE_CAPS,
160 PURPLE_MEDIA_TYPE_CAPS);
161
151 g_type_class_add_private(klass, sizeof(PurpleMediaManagerPrivate)); 162 g_type_class_add_private(klass, sizeof(PurpleMediaManagerPrivate));
152 } 163 }
153 164
154 static void 165 static void
155 purple_media_manager_init (PurpleMediaManager *media) 166 purple_media_manager_init (PurpleMediaManager *media)
156 { 167 {
157 media->priv = PURPLE_MEDIA_MANAGER_GET_PRIVATE(media); 168 media->priv = PURPLE_MEDIA_MANAGER_GET_PRIVATE(media);
158 media->priv->medias = NULL; 169 media->priv->medias = NULL;
159 media->priv->next_output_window_id = 1; 170 media->priv->next_output_window_id = 1;
171 #ifdef USE_VV
172 media->priv->backend_type = PURPLE_TYPE_MEDIA_BACKEND_FS2;
173 #endif
160 174
161 purple_prefs_add_none("/purple/media"); 175 purple_prefs_add_none("/purple/media");
162 purple_prefs_add_none("/purple/media/audio"); 176 purple_prefs_add_none("/purple/media/audio");
163 purple_prefs_add_none("/purple/media/audio/volume"); 177 purple_prefs_add_none("/purple/media/audio/volume");
164 purple_prefs_add_int("/purple/media/audio/volume/input", 10); 178 purple_prefs_add_int("/purple/media/audio/volume/input", 10);
302 const char *remote_user, 316 const char *remote_user,
303 gboolean initiator) 317 gboolean initiator)
304 { 318 {
305 #ifdef USE_VV 319 #ifdef USE_VV
306 PurpleMedia *media; 320 PurpleMedia *media;
307 FsConference *conference = FS_CONFERENCE(gst_element_factory_make(conference_type, NULL));
308 GstStateChangeReturn ret;
309 gboolean signal_ret; 321 gboolean signal_ret;
310
311 if (conference == NULL) {
312 purple_conv_present_error(remote_user, account,
313 _("Error creating conference."));
314 purple_debug_error("media", "Conference == NULL\n");
315 return NULL;
316 }
317 322
318 media = PURPLE_MEDIA(g_object_new(purple_media_get_type(), 323 media = PURPLE_MEDIA(g_object_new(purple_media_get_type(),
319 "manager", manager, 324 "manager", manager,
320 "account", account, 325 "account", account,
321 "conference", conference, 326 "conference-type", conference_type,
322 "initiator", initiator, 327 "initiator", initiator,
323 NULL)); 328 NULL));
324
325 ret = gst_element_set_state(GST_ELEMENT(conference), GST_STATE_PLAYING);
326
327 if (ret == GST_STATE_CHANGE_FAILURE) {
328 purple_conv_present_error(remote_user, account,
329 _("Error creating conference."));
330 purple_debug_error("media", "Failed to start conference.\n");
331 g_object_unref(media);
332 return NULL;
333 }
334 329
335 g_signal_emit(manager, purple_media_manager_signals[INIT_MEDIA], 0, 330 g_signal_emit(manager, purple_media_manager_signals[INIT_MEDIA], 0,
336 media, account, remote_user, &signal_ret); 331 media, account, remote_user, &signal_ret);
337 332
338 if (signal_ret == FALSE) { 333 if (signal_ret == FALSE) {
892 void 887 void
893 purple_media_manager_set_ui_caps(PurpleMediaManager *manager, 888 purple_media_manager_set_ui_caps(PurpleMediaManager *manager,
894 PurpleMediaCaps caps) 889 PurpleMediaCaps caps)
895 { 890 {
896 #ifdef USE_VV 891 #ifdef USE_VV
892 PurpleMediaCaps oldcaps;
893
897 g_return_if_fail(PURPLE_IS_MEDIA_MANAGER(manager)); 894 g_return_if_fail(PURPLE_IS_MEDIA_MANAGER(manager));
895
896 oldcaps = manager->priv->ui_caps;
898 manager->priv->ui_caps = caps; 897 manager->priv->ui_caps = caps;
898
899 if (caps != oldcaps)
900 g_signal_emit(manager,
901 purple_media_manager_signals[UI_CAPS_CHANGED],
902 0, caps, oldcaps);
899 #endif 903 #endif
900 } 904 }
901 905
902 PurpleMediaCaps 906 PurpleMediaCaps
903 purple_media_manager_get_ui_caps(PurpleMediaManager *manager) 907 purple_media_manager_get_ui_caps(PurpleMediaManager *manager)
906 g_return_val_if_fail(PURPLE_IS_MEDIA_MANAGER(manager), 910 g_return_val_if_fail(PURPLE_IS_MEDIA_MANAGER(manager),
907 PURPLE_MEDIA_CAPS_NONE); 911 PURPLE_MEDIA_CAPS_NONE);
908 return manager->priv->ui_caps; 912 return manager->priv->ui_caps;
909 #else 913 #else
910 return PURPLE_MEDIA_CAPS_NONE; 914 return PURPLE_MEDIA_CAPS_NONE;
915 #endif
916 }
917
918 void
919 purple_media_manager_set_backend_type(PurpleMediaManager *manager,
920 GType backend_type)
921 {
922 #ifdef USE_VV
923 g_return_if_fail(PURPLE_IS_MEDIA_MANAGER(manager));
924
925 manager->priv->backend_type = backend_type;
926 #endif
927 }
928
929 GType
930 purple_media_manager_get_backend_type(PurpleMediaManager *manager)
931 {
932 #ifdef USE_VV
933 g_return_val_if_fail(PURPLE_IS_MEDIA_MANAGER(manager),
934 PURPLE_MEDIA_CAPS_NONE);
935
936 return manager->priv->backend_type;
937 #else
938 return G_TYPE_NONE;
911 #endif 939 #endif
912 } 940 }
913 941
914 #ifdef USE_GSTREAMER 942 #ifdef USE_GSTREAMER
915 943