Mercurial > pidgin
comparison libpurple/media.c @ 23876:f10e0ac24595
* Added input/output volume preferences for voice conversations.
* Properly freed media sessions regarding the media manager.
* Made purple_media_session_get_sink actually return the sink.
author | Mike Ruprecht <maiku@soc.pidgin.im> |
---|---|
date | Sun, 17 Aug 2008 07:55:38 +0000 |
parents | 89d873e217c1 |
children | c48f5c9600c3 |
comparison
equal
deleted
inserted
replaced
23875:eb289e9086bf | 23876:f10e0ac24595 |
---|---|
29 #include "internal.h" | 29 #include "internal.h" |
30 | 30 |
31 #include "connection.h" | 31 #include "connection.h" |
32 #include "media.h" | 32 #include "media.h" |
33 #include "marshallers.h" | 33 #include "marshallers.h" |
34 #include "mediamanager.h" | |
34 | 35 |
35 #include "debug.h" | 36 #include "debug.h" |
36 | 37 |
37 #ifdef USE_VV | 38 #ifdef USE_VV |
38 | 39 |
221 { | 222 { |
222 PurpleMediaPrivate *priv = PURPLE_MEDIA_GET_PRIVATE(media); | 223 PurpleMediaPrivate *priv = PURPLE_MEDIA_GET_PRIVATE(media); |
223 GList *sessions = g_hash_table_get_values(priv->sessions); | 224 GList *sessions = g_hash_table_get_values(priv->sessions); |
224 purple_debug_info("media","purple_media_finalize\n"); | 225 purple_debug_info("media","purple_media_finalize\n"); |
225 | 226 |
227 purple_media_manager_remove_media(purple_media_manager_get(), | |
228 PURPLE_MEDIA(media)); | |
229 | |
226 g_free(priv->name); | 230 g_free(priv->name); |
227 | 231 |
228 for (; sessions; sessions = g_list_delete_link(sessions, sessions)) { | 232 for (; sessions; sessions = g_list_delete_link(sessions, sessions)) { |
229 PurpleMediaSession *session = sessions->data; | 233 PurpleMediaSession *session = sessions->data; |
230 GList *streams = g_hash_table_get_values(session->streams); | 234 GList *streams = g_hash_table_get_values(session->streams); |
522 } | 526 } |
523 | 527 |
524 GstElement * | 528 GstElement * |
525 purple_media_get_sink(PurpleMedia *media, const gchar *sess_id) | 529 purple_media_get_sink(PurpleMedia *media, const gchar *sess_id) |
526 { | 530 { |
527 return purple_media_get_session(media, sess_id)->src; | 531 return purple_media_get_session(media, sess_id)->sink; |
528 } | 532 } |
529 | 533 |
530 static gboolean | 534 static gboolean |
531 media_bus_call(GstBus *bus, GstMessage *msg, gpointer media) | 535 media_bus_call(GstBus *bus, GstMessage *msg, gpointer media) |
532 { | 536 { |
765 GstElement *src; | 769 GstElement *src; |
766 GstElement *volume; | 770 GstElement *volume; |
767 GstPad *pad; | 771 GstPad *pad; |
768 GstPad *ghost; | 772 GstPad *ghost; |
769 const gchar *audio_device = purple_prefs_get_string("/purple/media/audio/device"); | 773 const gchar *audio_device = purple_prefs_get_string("/purple/media/audio/device"); |
774 double input_volume = purple_prefs_get_int("/purple/media/audio/volume/input")/10.0; | |
770 | 775 |
771 purple_debug_info("media", "purple_media_audio_init_src\n"); | 776 purple_debug_info("media", "purple_media_audio_init_src\n"); |
772 | 777 |
773 *sendbin = gst_bin_new("purplesendaudiobin"); | 778 *sendbin = gst_bin_new("purplesendaudiobin"); |
774 src = gst_element_factory_make("alsasrc", "asrc"); | 779 src = gst_element_factory_make("alsasrc", "asrc"); |
775 volume = gst_element_factory_make("volume", "purpleaudiovolume"); | 780 volume = gst_element_factory_make("volume", "purpleaudioinputvolume"); |
781 g_object_set(volume, "volume", input_volume, NULL); | |
776 *sendlevel = gst_element_factory_make("level", "sendlevel"); | 782 *sendlevel = gst_element_factory_make("level", "sendlevel"); |
777 gst_bin_add_many(GST_BIN(*sendbin), src, volume, *sendlevel, NULL); | 783 gst_bin_add_many(GST_BIN(*sendbin), src, volume, *sendlevel, NULL); |
778 gst_element_link(src, volume); | 784 gst_element_link(src, volume); |
779 gst_element_link(volume, *sendlevel); | 785 gst_element_link(volume, *sendlevel); |
780 pad = gst_element_get_pad(*sendlevel, "src"); | 786 pad = gst_element_get_pad(*sendlevel, "src"); |
803 purple_media_video_init_src(GstElement **sendbin) | 809 purple_media_video_init_src(GstElement **sendbin) |
804 { | 810 { |
805 GstElement *src, *tee, *queue, *local_sink; | 811 GstElement *src, *tee, *queue, *local_sink; |
806 GstPad *pad; | 812 GstPad *pad; |
807 GstPad *ghost; | 813 GstPad *ghost; |
808 const gchar *video_plugin = purple_prefs_get_string("/purple/media/video/plugin"); | 814 const gchar *video_plugin = purple_prefs_get_string( |
809 const gchar *video_device = purple_prefs_get_string("/purple/media/video/device"); | 815 "/purple/media/video/plugin"); |
816 const gchar *video_device = purple_prefs_get_string( | |
817 "/purple/media/video/device"); | |
810 | 818 |
811 purple_debug_info("media", "purple_media_video_init_src\n"); | 819 purple_debug_info("media", "purple_media_video_init_src\n"); |
812 | 820 |
813 *sendbin = gst_bin_new("purplesendvideobin"); | 821 *sendbin = gst_bin_new("purplesendvideobin"); |
814 src = gst_element_factory_make(video_plugin, "purplevideosource"); | 822 src = gst_element_factory_make(video_plugin, "purplevideosource"); |
857 } | 865 } |
858 | 866 |
859 void | 867 void |
860 purple_media_audio_init_recv(GstElement **recvbin, GstElement **recvlevel) | 868 purple_media_audio_init_recv(GstElement **recvbin, GstElement **recvlevel) |
861 { | 869 { |
862 GstElement *sink; | 870 GstElement *sink, *volume; |
863 GstPad *pad, *ghost; | 871 GstPad *pad, *ghost; |
872 double output_volume = purple_prefs_get_int( | |
873 "/purple/media/audio/volume/output")/10.0; | |
864 | 874 |
865 purple_debug_info("media", "purple_media_audio_init_recv\n"); | 875 purple_debug_info("media", "purple_media_audio_init_recv\n"); |
866 | 876 |
867 *recvbin = gst_bin_new("pidginrecvaudiobin"); | 877 *recvbin = gst_bin_new("pidginrecvaudiobin"); |
868 sink = gst_element_factory_make("alsasink", "asink"); | 878 sink = gst_element_factory_make("alsasink", "asink"); |
869 g_object_set(G_OBJECT(sink), "sync", FALSE, NULL); | 879 g_object_set(G_OBJECT(sink), "sync", FALSE, NULL); |
880 volume = gst_element_factory_make("volume", "purpleaudiooutputvolume"); | |
881 g_object_set(volume, "volume", output_volume, NULL); | |
870 *recvlevel = gst_element_factory_make("level", "recvlevel"); | 882 *recvlevel = gst_element_factory_make("level", "recvlevel"); |
871 gst_bin_add_many(GST_BIN(*recvbin), sink, *recvlevel, NULL); | 883 gst_bin_add_many(GST_BIN(*recvbin), sink, volume, *recvlevel, NULL); |
872 gst_element_link(*recvlevel, sink); | 884 gst_element_link(*recvlevel, sink); |
873 pad = gst_element_get_pad(*recvlevel, "sink"); | 885 gst_element_link(volume, *recvlevel); |
886 pad = gst_element_get_pad(volume, "sink"); | |
874 ghost = gst_ghost_pad_new("ghostsink", pad); | 887 ghost = gst_ghost_pad_new("ghostsink", pad); |
875 gst_element_add_pad(*recvbin, ghost); | 888 gst_element_add_pad(*recvbin, ghost); |
876 g_object_set(G_OBJECT(*recvlevel), "message", TRUE, NULL); | 889 g_object_set(G_OBJECT(*recvlevel), "message", TRUE, NULL); |
877 | 890 |
878 purple_debug_info("media", "purple_media_audio_init_recv end\n"); | 891 purple_debug_info("media", "purple_media_audio_init_recv end\n"); |
1270 for (; sessions; sessions = g_list_delete_link(sessions, sessions)) { | 1283 for (; sessions; sessions = g_list_delete_link(sessions, sessions)) { |
1271 PurpleMediaSession *session = sessions->data; | 1284 PurpleMediaSession *session = sessions->data; |
1272 if (session->type & PURPLE_MEDIA_SEND_AUDIO) { | 1285 if (session->type & PURPLE_MEDIA_SEND_AUDIO) { |
1273 GstElement *volume = gst_bin_get_by_name( | 1286 GstElement *volume = gst_bin_get_by_name( |
1274 GST_BIN(session->src), | 1287 GST_BIN(session->src), |
1275 "purpleaudiovolume"); | 1288 "purpleaudioinputvolume"); |
1276 g_object_set(volume, "mute", active, NULL); | 1289 g_object_set(volume, "mute", active, NULL); |
1277 } | 1290 } |
1278 } | 1291 } |
1279 } | 1292 } |
1280 | 1293 |