*** gst-libs/gst/video/gstvideosink.c	Thu Dec  3 16:01:39 2009
--- /home/user/Development/videoconf/data/bug/gstxvimage/gstvideosink_prototype.c	Thu Dec 30 05:37:19 2010
***************
*** 42,55 ****
  
  enum
  {
!   PROP_SHOW_PREROLL_FRAME = 1
  };
  
! #define DEFAULT_SHOW_PREROLL_FRAME TRUE
  
  struct _GstVideoSinkPrivate
  {
    gboolean show_preroll_frame;  /* ATOMIC */
  };
  
  GST_DEBUG_CATEGORY_STATIC (video_sink_debug);
--- 42,62 ----
  
  enum
  {
!   PROP_SHOW_PREROLL_FRAME = 1,
!   PROP_QOS_FOR_OBSCURED = 2
  };
  
! #define DEFAULT_SHOW_PREROLL_FRAME     TRUE
! #define DEFAULT_QOS_FOR_OBSCURED       FALSE
! #define DEFAULT_QOS_OBSCURED_RATE      1.0
! 
! GST_DEBUG_CATEGORY_STATIC (GST_CAT_QOS);
  
  struct _GstVideoSinkPrivate
  {
    gboolean show_preroll_frame;  /* ATOMIC */
+   gboolean qos_for_obscured; /* ATOMIC */
+   GstClockTime last_qostime;
  };
  
  GST_DEBUG_CATEGORY_STATIC (video_sink_debug);
***************
*** 111,117 ****
        result->w = dst.w;
        result->h = dst.h;
      }
!   }
  
    GST_DEBUG ("source is %dx%d dest is %dx%d, result is %dx%d with x,y %dx%d",
        src.w, src.h, dst.w, dst.h, result->w, result->h, result->x, result->y);
--- 118,124 ----
        result->w = dst.w;
        result->h = dst.h;
      }
! }
  
    GST_DEBUG ("source is %dx%d dest is %dx%d, result is %dx%d with x,y %dx%d",
        src.w, src.h, dst.w, dst.h, result->w, result->h, result->x, result->y);
***************
*** 158,163 ****
--- 165,184 ----
            DEFAULT_SHOW_PREROLL_FRAME,
            G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
  
+   /**
+    * GstVideoSink:qos-for-obscured
+    * 
+    * Whether to generate qos_obscured event to upstream elements during rendering. 
+    * If set to #FALSE, qos_obscured event will not be generated during rendering.
+    * 
+    * Since: 0.10.28
+    */
+   g_object_class_install_property (gobject_class, PROP_QOS_FOR_OBSCURED,
+       g_param_spec_boolean ("qos-for-obscured", "send QoS event for being obscured",
+           "Whether to send QoS event for being obscured",
+           DEFAULT_QOS_FOR_OBSCURED,
+           G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
+ 
    basesink_class->render = GST_DEBUG_FUNCPTR (gst_video_sink_show_frame);
    basesink_class->preroll =
        GST_DEBUG_FUNCPTR (gst_video_sink_show_preroll_frame);
***************
*** 202,213 ****
--- 223,255 ----
    return klass->show_frame (GST_VIDEO_SINK_CAST (bsink), buf);
  }
  
+ static gboolean
+ gst_video_sink_send_qos (GstVideoSink * vsink, gdouble rate)
+ {
+   GstEvent * event;
+   GstClockTime current = gst_util_get_timestamp();
+   /* generate at most one event for every second */
+   if (GST_CLOCK_TIME_IS_VALID (vsink->priv->last_qostime) &&
+       GST_CLOCK_DIFF (vsink->priv->last_qostime, current) < GST_SECOND) {
+       return FALSE;
+   }
+   vsink->priv->last_qostime = current;
+   /* generate qos-obscured event */
+   GST_CAT_LOG_OBJECT (GST_CAT_QOS, vsink, "qos-obscured ");
+   event = gst_event_new_qos_obscured (rate);
+   /* send upstream */
+   return gst_pad_push_event (GST_BASE_SINK (vsink)->sinkpad, event);
+ }
+ 
  static GstFlowReturn
  gst_video_sink_show_frame (GstBaseSink * bsink, GstBuffer * buf)
  {
    GstVideoSinkClass *klass;
+   GstFlowReturn result; 
+   GstVideoSink *vsink;
  
    klass = GST_VIDEO_SINK_GET_CLASS (bsink);
+   vsink = GST_VIDEO_SINK_CAST (bsink);
  
    if (klass->show_frame == NULL) {
      if (parent_class->render != NULL)
***************
*** 219,225 ****
    GST_LOG_OBJECT (bsink, "rendering frame, ts=%" GST_TIME_FORMAT,
        GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
  
!   return klass->show_frame (GST_VIDEO_SINK_CAST (bsink), buf);
  }
  
  static void
--- 261,272 ----
    GST_LOG_OBJECT (bsink, "rendering frame, ts=%" GST_TIME_FORMAT,
        GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
  
!   result = klass->show_frame (vsink, buf);
! 
!   if (vsink->priv->qos_for_obscured &&
!       gst_base_sink_is_qos_enabled (GST_BASE_SINK (vsink))) 
!     gst_video_sink_send_qos (vsink, DEFAULT_QOS_OBSCURED_RATE);
!   return result;
  }
  
  static void
***************
*** 235,240 ****
--- 282,291 ----
        g_atomic_int_set (&vsink->priv->show_preroll_frame,
            g_value_get_boolean (value));
        break;
+     case PROP_QOS_FOR_OBSCURED:
+       g_atomic_int_set (&vsink->priv->qos_for_obscured,
+           g_value_get_boolean (value));
+       break;
      default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
        break;
***************
*** 254,259 ****
--- 305,314 ----
        g_value_set_boolean (value,
            g_atomic_int_get (&vsink->priv->show_preroll_frame));
        break;
+     case PROP_QOS_FOR_OBSCURED:
+       g_value_set_boolean (value, 
+           g_atomic_int_get (&vsink->priv->qos_for_obscured));
+       break;
      default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
        break;
