commit b78b3c2849e01e9f8589bce64ada54d6bda0f2a2
parent d2574cf4a0aa947e43b8525869304b06e5e3987d
Author: Jacki <jacki@thejackimonster.de>
Date: Fri, 26 Jul 2024 17:38:05 +0200
Merge branch 'master' of ssh://git.gnunet.org/messenger-gtk
Diffstat:
6 files changed, 68 insertions(+), 38 deletions(-)
diff --git a/resources/ui/discourse_panel.ui b/resources/ui/discourse_panel.ui
@@ -72,9 +72,13 @@ Author: Tobias Frisch
</packing>
</child>
<child>
- <object class="GtkDrawingArea" id="video_drawing_area">
+ <object class="GtkBox" id="video_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <placeholder/>
+ </child>
</object>
<packing>
<property name="name">video_page</property>
diff --git a/src/discourse.c b/src/discourse.c
@@ -219,21 +219,21 @@ _setup_gst_pipelines(MESSENGER_DiscourseInfo *info)
{
g_assert(info);
- info->record_pipeline = gst_parse_launch(
+ info->record_audio_pipeline = gst_parse_launch(
"autoaudiosrc ! audioconvert ! capsfilter name=filter ! fdsink name=sink",
NULL
);
- info->record_sink = gst_bin_get_by_name(
- GST_BIN(info->record_pipeline), "sink"
+ info->record_audio_sink = gst_bin_get_by_name(
+ GST_BIN(info->record_audio_pipeline), "sink"
);
GstElement *filter = gst_bin_get_by_name(
- GST_BIN(info->record_pipeline), "filter"
+ GST_BIN(info->record_audio_pipeline), "filter"
);
{
- GstBus *bus = gst_element_get_bus(info->record_pipeline);
+ GstBus *bus = gst_element_get_bus(info->record_audio_pipeline);
gst_bus_add_signal_watch(bus);
g_signal_connect(G_OBJECT(bus), "message::error", (GCallback)error_cb, info);
gst_object_unref(bus);
@@ -252,9 +252,9 @@ _setup_gst_pipelines(MESSENGER_DiscourseInfo *info)
const int fd = GNUNET_CHAT_discourse_get_fd(info->discourse);
if (-1 != fd)
- g_object_set(info->record_sink, "fd", fd, NULL);
+ g_object_set(info->record_audio_sink, "fd", fd, NULL);
- gst_element_set_state(info->record_pipeline, GST_STATE_PLAYING);
+ gst_element_set_state(info->record_audio_pipeline, GST_STATE_PLAYING);
}
info->mix_pipeline = gst_parse_launch(
@@ -293,8 +293,8 @@ discourse_create_info(struct GNUNET_CHAT_Discourse *discourse)
info->discourse = discourse;
- info->record_pipeline = NULL;
- info->record_sink = NULL;
+ info->record_audio_pipeline = NULL;
+ info->record_audio_sink = NULL;
info->mix_pipeline = NULL;
info->mix_element = NULL;
@@ -342,10 +342,10 @@ discourse_destroy_info(struct GNUNET_CHAT_Discourse *discourse)
gst_object_unref(GST_OBJECT(info->mix_pipeline));
}
- if (info->record_pipeline)
+ if (info->record_audio_pipeline)
{
- gst_element_set_state(info->record_pipeline, GST_STATE_NULL);
- gst_object_unref(GST_OBJECT(info->record_pipeline));
+ gst_element_set_state(info->record_audio_pipeline, GST_STATE_NULL);
+ gst_object_unref(GST_OBJECT(info->record_audio_pipeline));
}
pthread_mutex_lock(&(info->mutex));
@@ -494,17 +494,27 @@ discourse_stream_message(struct GNUNET_CHAT_Discourse *discourse,
}
bool
-discourse_has_controls(struct GNUNET_CHAT_Discourse *discourse)
+discourse_has_controls(struct GNUNET_CHAT_Discourse *discourse,
+ MESSENGER_DiscourseControl control)
{
MESSENGER_DiscourseInfo* info = GNUNET_CHAT_discourse_get_user_pointer(discourse);
if (!info)
return FALSE;
- if ((!(info->record_pipeline)) && (!(info->mix_pipeline)))
- return FALSE;
-
- return TRUE;
+ switch (control)
+ {
+ case MESSENGER_DISCOURSE_CTRL_MICROPHONE:
+ return (info->record_audio_pipeline? TRUE : FALSE);
+ case MESSENGER_DISCOURSE_CTRL_SPEAKERS:
+ return (info->mix_pipeline? TRUE : FALSE);
+ case MESSENGER_DISCOURSE_CTRL_WEBCAM:
+ return FALSE;
+ case MESSENGER_DISCOURSE_CTRL_SCREEN_CAPTURE:
+ return FALSE;
+ default:
+ return FALSE;
+ }
}
void
@@ -539,11 +549,11 @@ discourse_set_mute(struct GNUNET_CHAT_Discourse *discourse,
{
MESSENGER_DiscourseInfo* info = GNUNET_CHAT_discourse_get_user_pointer(discourse);
- if ((!info) || (!(info->record_pipeline)))
+ if ((!info) || (!(info->record_audio_pipeline)))
return;
gst_element_set_state(
- info->record_pipeline,
+ info->record_audio_pipeline,
mute? GST_STATE_NULL : GST_STATE_PLAYING
);
}
@@ -553,12 +563,12 @@ discourse_is_mute(struct GNUNET_CHAT_Discourse *discourse)
{
MESSENGER_DiscourseInfo* info = GNUNET_CHAT_discourse_get_user_pointer(discourse);
- if ((!info) || (!(info->record_pipeline)))
+ if ((!info) || (!(info->record_audio_pipeline)))
return TRUE;
GstState state;
gst_element_get_state(
- info->record_pipeline,
+ info->record_audio_pipeline,
&state,
NULL,
GST_CLOCK_TIME_NONE
diff --git a/src/discourse.h b/src/discourse.h
@@ -31,12 +31,24 @@
#include <gnunet/gnunet_chat_lib.h>
#include <pthread.h>
+typedef enum MESSENGER_DiscourseControl {
+ MESSENGER_DISCOURSE_CTRL_MICROPHONE = 1,
+ MESSENGER_DISCOURSE_CTRL_SPEAKERS = 2,
+ MESSENGER_DISCOURSE_CTRL_WEBCAM = 3,
+ MESSENGER_DISCOURSE_CTRL_SCREEN_CAPTURE = 4,
+
+ MESSENGER_DISCOURSE_CTRL_UNKNOWN = 0
+} MESSENGER_DiscourseControl;
+
typedef struct MESSENGER_DiscourseInfo
{
struct GNUNET_CHAT_Discourse *discourse;
- GstElement *record_pipeline;
- GstElement *record_sink;
+ GstElement *record_audio_pipeline;
+ GstElement *record_audio_sink;
+
+ GstElement *record_video_pipeline;
+ GstElement *record_video_sink;
GstElement *mix_pipeline;
GstElement *mix_element;
@@ -97,7 +109,8 @@ discourse_stream_message(struct GNUNET_CHAT_Discourse *discourse,
const struct GNUNET_CHAT_Message *message);
bool
-discourse_has_controls(struct GNUNET_CHAT_Discourse *discourse);
+discourse_has_controls(struct GNUNET_CHAT_Discourse *discourse,
+ MESSENGER_DiscourseControl control);
/**
* Sets the volume for speakers of a given discourse.
diff --git a/src/ui/discourse.c b/src/ui/discourse.c
@@ -634,18 +634,21 @@ _update_discourse_via_context(UI_DISCOURSE_Handle *handle)
discourses
);
- const gboolean has_voice_controls = discourse_has_controls(
- discourses[0]
- );
+ gtk_widget_set_sensitive(GTK_WIDGET(handle->microphone_button), discourse_has_controls(
+ discourses[0], MESSENGER_DISCOURSE_CTRL_MICROPHONE
+ ));
- const gboolean has_video_controls = discourse_has_controls(
- discourses[1]
- );
+ gtk_widget_set_sensitive(GTK_WIDGET(handle->camera_button), discourse_has_controls(
+ discourses[1], MESSENGER_DISCOURSE_CTRL_WEBCAM
+ ));
+
+ gtk_widget_set_sensitive(GTK_WIDGET(handle->screen_button), discourse_has_controls(
+ discourses[1], MESSENGER_DISCOURSE_CTRL_SCREEN_CAPTURE
+ ));
- gtk_widget_set_sensitive(GTK_WIDGET(handle->microphone_button), has_voice_controls);
- gtk_widget_set_sensitive(GTK_WIDGET(handle->camera_button), has_video_controls);
- gtk_widget_set_sensitive(GTK_WIDGET(handle->screen_button), has_video_controls);
- gtk_widget_set_sensitive(GTK_WIDGET(handle->speakers_button), has_voice_controls);
+ gtk_widget_set_sensitive(GTK_WIDGET(handle->speakers_button), discourse_has_controls(
+ discourses[0], MESSENGER_DISCOURSE_CTRL_SPEAKERS
+ ));
if (discourses[0])
{
diff --git a/src/ui/discourse_panel.c b/src/ui/discourse_panel.c
@@ -60,8 +60,8 @@ ui_discourse_panel_new(MESSENGER_Application *app)
gtk_builder_get_object(handle->builder, "panel_label")
);
- handle->video_drawing_area = GTK_DRAWING_AREA(
- gtk_builder_get_object(handle->builder, "video_drawing_area")
+ handle->video_box = GTK_WIDGET(
+ gtk_builder_get_object(handle->builder, "video_box")
);
return handle;
diff --git a/src/ui/discourse_panel.h b/src/ui/discourse_panel.h
@@ -43,7 +43,7 @@ typedef struct UI_DISCOURSE_PANEL_Handle
HdyAvatar *panel_avatar;
GtkLabel *panel_label;
- GtkDrawingArea *video_drawing_area;
+ GtkWidget *video_box;
} UI_DISCOURSE_PANEL_Handle;
/**