[gnome-shell] shell-recorder-src: only negotiate once



commit f76dd4d6b21d762b3f46653066ce99378be24e15
Author: Wim Taymans <wtaymans redhat com>
Date:   Wed Jun 11 16:36:31 2014 +0200

    shell-recorder-src: only negotiate once
    
    Set the format of the basesrc to the configured caps only once
    during negotiation instead of before pushing each buffer.

 src/shell-recorder-src.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/src/shell-recorder-src.c b/src/shell-recorder-src.c
index dd4b377..af75b21 100644
--- a/src/shell-recorder-src.c
+++ b/src/shell-recorder-src.c
@@ -85,6 +85,19 @@ shell_recorder_src_update_memory_used (ShellRecorderSrc *src,
   g_mutex_unlock (src->mutex);
 }
 
+/* _negotiate() is called when we have to decide on a format. We
+ * use the configured format */
+static gboolean
+shell_recorder_src_negotiate (GstBaseSrc * base_src)
+{
+  ShellRecorderSrc *src = SHELL_RECORDER_SRC (base_src);
+  gboolean result;
+
+  result = gst_base_src_set_caps (base_src, src->caps);
+
+  return result;
+}
+
 /* The create() virtual function is responsible for returning the next buffer.
  * We just pop buffers off of the queue and block if necessary.
  */
@@ -211,6 +224,7 @@ shell_recorder_src_class_init (ShellRecorderSrcClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstBaseSrcClass *base_src_class = GST_BASE_SRC_CLASS (klass);
   GstPushSrcClass *push_src_class = GST_PUSH_SRC_CLASS (klass);
 
   static GstStaticPadTemplate src_template =
@@ -223,8 +237,11 @@ shell_recorder_src_class_init (ShellRecorderSrcClass *klass)
   object_class->set_property = shell_recorder_src_set_property;
   object_class->get_property = shell_recorder_src_get_property;
 
+  base_src_class->negotiate = shell_recorder_src_negotiate;
+
   push_src_class->create = shell_recorder_src_create;
 
+
   g_object_class_install_property (object_class,
                                    PROP_CAPS,
                                    g_param_spec_boxed ("caps",
@@ -264,7 +281,6 @@ shell_recorder_src_add_buffer (ShellRecorderSrc *src,
   g_return_if_fail (SHELL_IS_RECORDER_SRC (src));
   g_return_if_fail (src->caps != NULL);
 
-  gst_base_src_set_caps (GST_BASE_SRC (src), src->caps);
   shell_recorder_src_update_memory_used (src,
                                         (int)(gst_buffer_get_size(buffer) / 1024));
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]