diff options
author | Snir Sheriber <ssheribe@redhat.com> | 2018-11-08 17:32:06 +0200 |
---|---|---|
committer | Frediano Ziglio <freddy77@gmail.com> | 2022-03-06 14:53:30 +0000 |
commit | 04a663f7d7b8ec4a237d588b212d480a9f6e5bb1 (patch) | |
tree | b7e8ec345b4f2909edd4aaa66480bdda4b3956fe | |
parent | 5229a16a67b73a5c6b7065960e4784f209b3526c (diff) |
Use same sink settings for direct rendering
Set "sync" and "drop" as normal streaming.
-rw-r--r-- | src/channel-display-gst.c | 67 |
1 files changed, 15 insertions, 52 deletions
diff --git a/src/channel-display-gst.c b/src/channel-display-gst.c index 36db3a3..f508771 100644 --- a/src/channel-display-gst.c +++ b/src/channel-display-gst.c @@ -426,67 +426,30 @@ static void app_source_setup(GstElement *pipeline G_GNUC_UNUSED, decoder->appsrc = GST_APP_SRC(gst_object_ref(source)); } -static GstPadProbeReturn -sink_event_probe(GstPad *pad, GstPadProbeInfo *info, gpointer data) -{ - SpiceGstDecoder *decoder = (SpiceGstDecoder*)data; - - if (info->type & GST_PAD_PROBE_TYPE_BUFFER) { // Buffer arrived - GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER(info); - g_mutex_lock(&decoder->queues_mutex); - - GList *l = find_frame_entry(decoder, buffer); - if (l) { - SpiceGstFrame *gstframe = l->data; - const SpiceFrame *frame = gstframe->encoded_frame; - /* Note that queue_len (the length of the queue prior to adding - * this frame) is crucial to correctly interpret the decoding time: - * - Less than MAX_DECODED_FRAMES means nothing blocked the - * decoding of that frame. - * - More than MAX_DECODED_FRAMES means decoding was delayed by one - * or more frame intervals. - */ - record(frames_stats, - "frame mm_time %u size %u creation time %" PRId64 - " decoded time %" PRId64 " queue %u before %u", - frame->mm_time, frame->size, frame->creation_time, - g_get_monotonic_time() - frame->creation_time, - decoder->decoding_queue->length, gstframe->queue_len); - - if (!decoder->appsink) { - /* The sink will display the frame directly so this - * SpiceGstFrame and those of any dropped frame are no longer - * needed. - */ - pop_up_to_frame(decoder, gstframe); - free_gst_frame(gstframe); - } - } - - g_mutex_unlock(&decoder->queues_mutex); - } - return GST_PAD_PROBE_OK; -} - static inline const char *gst_element_name(GstElement *element) { GstElementFactory *f = gst_element_get_factory(element); return f ? GST_OBJECT_NAME(f) : GST_OBJECT_NAME(element); } -/* This function is used to set a probe on the sink */ +// This function is used to set properties in dynamically added sink (if overlay is used) static void -deep_element_added_cb(GstBin *pipeline, GstBin *bin, GstElement *element, - SpiceGstDecoder *decoder) +add_elem_cb(GstBin * pipeline, GstBin * bin, GstElement * element, SpiceGstDecoder *decoder) { - SPICE_DEBUG("A new element was added to Gstreamer's pipeline (%s)", - gst_element_name(element)); - /* Attach a probe to the sink to update the statistics */ + SPICE_DEBUG("A new element was added to Gstreamer's pipeline (%s)", + gst_element_name(element)); + char *name = gst_element_get_name(element); + + spice_debug("Adding element: %s", name); + if (GST_IS_BASE_SINK(element)) { - GstPad *pad = gst_element_get_static_pad(element, "sink"); - gst_pad_add_probe(pad, GST_PAD_PROBE_TYPE_BUFFER, sink_event_probe, decoder, NULL); - gst_object_unref(pad); + g_object_set(element, + "sync", FALSE, + "drop", FALSE, + NULL); + spice_debug("^^^^SINK^^^^"); } + g_free(name); } static gboolean create_pipeline(SpiceGstDecoder *decoder) @@ -550,7 +513,7 @@ static gboolean create_pipeline(SpiceGstDecoder *decoder) #endif } - g_signal_connect(playbin, "deep-element-added", G_CALLBACK(deep_element_added_cb), decoder); + g_signal_connect(playbin, "deep-element-added", G_CALLBACK(add_elem_cb), decoder); g_signal_connect(playbin, "source-setup", G_CALLBACK(app_source_setup), decoder); g_object_set(playbin, |