gst_wayland_sink_render_flush_buffer (GstBaseSink * bsink)
{
GstWaylandSink *sink;
- GstBuffer *buffer;
sink = GST_WAYLAND_SINK (bsink);
FUNCTION;
g_return_if_fail (sink != NULL);
g_return_if_fail (sink->last_buffer != NULL);
- buffer = gst_buffer_copy_deep (sink->last_buffer);
-
- gst_wayland_sink_render (bsink, buffer);
- if (buffer)
- gst_buffer_unref (buffer);
-}
-
-static void
-gst_wayland_sink_gapless_render (GstBaseSink * bsink)
-{
- g_return_if_fail (bsink != NULL);
- FUNCTION;
- gst_wayland_sink_render_flush_buffer (bsink);
-}
-
-static void
-gst_wayland_sink_keep_camera_preview (GstBaseSink * bsink)
-{
- g_return_if_fail (bsink != NULL);
- FUNCTION;
- gst_wayland_sink_render_flush_buffer (bsink);
+ gst_wayland_sink_render (bsink, sink->last_buffer);
}
#endif
sink->got_costum_event = TRUE;
if (gst_wayland_sink_check_use_gapless (sink)) {
- gst_wayland_sink_gapless_render (bsink);
+ gst_wayland_sink_render_flush_buffer (bsink);
sink->got_costum_event = FALSE;
}
sink->got_costum_event = FALSE;
if (sink->window) {
if (!gst_wl_window_is_toplevel (sink->window)) {
GstBaseSink *bsink = GST_BASE_SINK (element);
- if (sink->USE_TBM) {
+ if (sink->USE_TBM && sink->display->is_native_format
+ && !sink->display->flush_buffer) {
+ /* To avoid duplicate request by App, check flush_buffer by flush_request of MMVideoBuffer */
sink->request_camera_flush_buf = TRUE;
- gst_wayland_sink_keep_camera_preview (bsink);
+ gst_wayland_sink_render_flush_buffer (bsink);
sink->request_camera_flush_buf = FALSE;
}
break;
{
GstWaylandSink *sink = GST_WAYLAND_SINK (bsink);
GstBuffer *to_render;
+ GstBuffer *flush_gstbuf = NULL;
GstWlBuffer *wlbuffer;
GstFlowReturn ret = GST_FLOW_OK;
FUNCTION;
wlbuffer = gst_buffer_get_wl_buffer (buffer);
/* last_buffer from gaplasee have wlbuffer */
- if (G_UNLIKELY (!wlbuffer)
- || (gst_wayland_sink_check_use_gapless (sink))
- || sink->request_camera_flush_buf) {
+ if (G_UNLIKELY (!wlbuffer) || sink->display->flush_request) {
wbuf =
gst_wl_shm_memory_construct_wl_buffer (mem, sink->display,
&sink->video_info);
if (G_UNLIKELY (!wbuf))
goto no_wl_buffer;
- gst_buffer_add_wl_buffer (buffer, wbuf, sink->display);
+ if (sink->display->flush_request) {
+ flush_gstbuf = gst_buffer_new ();
+ GST_LOG ("To flush, new gstBuffer(%p)", flush_gstbuf);
+ gst_buffer_add_wl_buffer (flush_gstbuf, wbuf, sink->display);
+
+ } else {
+ gst_buffer_add_wl_buffer (buffer, wbuf, sink->display);
+ }
}
} else if (sink->USE_TBM && !sink->display->is_native_format) {
if (sink->USE_TBM && sink->display->is_native_format) {
if ((G_UNLIKELY (buffer == sink->last_buffer)
- && !(gst_wayland_sink_check_use_gapless (sink)))
- || (G_UNLIKELY (buffer == sink->last_buffer)
- && !sink->request_camera_flush_buf)) {
+ && !(sink->display->flush_request))) {
GST_LOG_OBJECT (sink, "Buffer already being rendered");
goto done;
}
- GST_LOG_OBJECT (sink, "replace last_buffer: (%p) -> (%p)",
- sink->last_buffer, buffer);
- gst_buffer_replace (&sink->last_buffer, buffer);
-
- GST_LOG_OBJECT (sink, "after gst_buffer_replace buffer %p, ref_count(%d)",
- buffer, GST_OBJECT_REFCOUNT_VALUE (buffer));
-
+ if (flush_gstbuf && sink->display->flush_request) {
+
+ GST_LOG_OBJECT (sink, "replace last_buffer: (%p) -> (%p)",
+ sink->last_buffer, flush_gstbuf);
+ /* increase ref count of flush_gstbuf
+ decrease ref count of sink->last_buffer */
+ gst_buffer_replace (&sink->last_buffer, flush_gstbuf);
+ GST_LOG_OBJECT (sink, "after gst_buffer_replace buffer %p, ref_count(%d)",
+ flush_gstbuf, GST_OBJECT_REFCOUNT_VALUE (flush_gstbuf));
+ /* decrease ref count of flush_buffer */
+ gst_buffer_unref (flush_gstbuf);
+
+ } else { //normal case
+
+ GST_LOG_OBJECT (sink, "replace last_buffer: (%p) -> (%p)",
+ sink->last_buffer, buffer);
+ /* increase ref count of buffer
+ decrease ref count of sink->last_buffer */
+ gst_buffer_replace (&sink->last_buffer, buffer);
+ GST_LOG_OBJECT (sink, "after gst_buffer_replace buffer %p, ref_count(%d)",
+ buffer, GST_OBJECT_REFCOUNT_VALUE (buffer));
+ }
if (sink->visible) {
render_last_buffer (sink);
} else {
GST_LOG ("skip rendering");
}
-
goto done;
} else { /* USE SHM or normal format */