[Spice-devel] [spice-gtk v2 2/3] display-gst: rely on SpiceSession init of GStreamer
Victor Toso
victortoso at redhat.com
Mon Sep 9 10:29:48 UTC 2019
From: Victor Toso <me at victortoso.com>
This means we can drop gstvideo_init() function and replace its calls
with gst_is_initialized().
A small rework on create_gstreamer_decoder() was done to make
gst_is_initialized() return early with proper debug message related to
lack of GStreamer initialization.
Signed-off-by: Victor Toso <victortoso at redhat.com>
---
src/channel-display-gst.c | 55 ++++++++++++++++-----------------------
1 file changed, 22 insertions(+), 33 deletions(-)
diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c
index 6fccf62..c88788f 100644
--- a/src/channel-display-gst.c
+++ b/src/channel-display-gst.c
@@ -748,44 +748,30 @@ static gboolean spice_gst_decoder_queue_frame(VideoDecoder *video_decoder,
return TRUE;
}
-static gboolean gstvideo_init(void)
-{
- static int success = 0;
- if (!success) {
- GError *err = NULL;
- if (gst_init_check(NULL, NULL, &err)) {
- success = 1;
- } else {
- spice_warning("Disabling GStreamer video support: %s", err->message);
- g_clear_error(&err);
- success = -1;
- }
- }
- return success > 0;
-}
-
G_GNUC_INTERNAL
VideoDecoder* create_gstreamer_decoder(int codec_type, display_stream *stream)
{
- SpiceGstDecoder *decoder = NULL;
g_return_val_if_fail(VALID_VIDEO_CODEC_TYPE(codec_type), NULL);
- if (gstvideo_init()) {
- decoder = g_new0(SpiceGstDecoder, 1);
- decoder->base.destroy = spice_gst_decoder_destroy;
- decoder->base.reschedule = spice_gst_decoder_reschedule;
- decoder->base.queue_frame = spice_gst_decoder_queue_frame;
- decoder->base.codec_type = codec_type;
- decoder->base.stream = stream;
- decoder->last_mm_time = stream_get_time(stream);
- g_mutex_init(&decoder->queues_mutex);
- decoder->decoding_queue = g_queue_new();
-
- if (!create_pipeline(decoder)) {
- decoder->base.destroy((VideoDecoder*)decoder);
- decoder = NULL;
- }
+ if (!gst_is_initialized()) {
+ spice_debug("GStreamer is not initialized: No decoder for codec-type: %u", codec_type);
+ return NULL;
+ }
+
+ SpiceGstDecoder *decoder = g_new0(SpiceGstDecoder, 1);
+ decoder->base.destroy = spice_gst_decoder_destroy;
+ decoder->base.reschedule = spice_gst_decoder_reschedule;
+ decoder->base.queue_frame = spice_gst_decoder_queue_frame;
+ decoder->base.codec_type = codec_type;
+ decoder->base.stream = stream;
+ decoder->last_mm_time = stream_get_time(stream);
+ g_mutex_init(&decoder->queues_mutex);
+ decoder->decoding_queue = g_queue_new();
+
+ if (!create_pipeline(decoder)) {
+ decoder->base.destroy((VideoDecoder*)decoder);
+ return NULL;
}
return (VideoDecoder*)decoder;
@@ -820,7 +806,10 @@ gboolean gstvideo_has_codec(int codec_type)
GstCaps *caps;
GstElementFactoryListType type;
- g_return_val_if_fail(gstvideo_init(), FALSE);
+ if (!gst_is_initialized()) {
+ return FALSE;
+ }
+
g_return_val_if_fail(VALID_VIDEO_CODEC_TYPE(codec_type), FALSE);
type = GST_ELEMENT_FACTORY_TYPE_DECODER |
--
2.21.0
More information about the Spice-devel
mailing list