Merge patch from Ronald fixing problems with streaming text.
authorRonald <rbultje@ronald.bitfreak.net>
Tue, 28 Dec 2004 09:26:32 +0000 (09:26 +0000)
committerDavid Schleef <ds@schleef.org>
Tue, 28 Dec 2004 09:26:32 +0000 (09:26 +0000)
Original commit message from CVS:
Merge patch from Ronald fixing problems with streaming
text.
* ext/cairo/gstcairo.c: (plugin_init):
* ext/cairo/gsttextoverlay.c: (gst_textoverlay_render_text),
(gst_text_overlay_blit_1), (gst_text_overlay_blit_sub2x2),
(gst_textoverlay_video_chain), (gst_textoverlay_loop),
(gst_textoverlay_font_init), (gst_textoverlay_init),
(gst_textoverlay_set_property):
* ext/cairo/gsttextoverlay.h:

ChangeLog
ext/cairo/gstcairo.c
ext/cairo/gsttextoverlay.c
ext/cairo/gsttextoverlay.h

index 54473e5..89fd810 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2004-12-28  David Schleef  <ds@schleef.org>
+
+       Merge patch from Ronald fixing problems with streaming
+       text.
+       * ext/cairo/gstcairo.c: (plugin_init):
+       * ext/cairo/gsttextoverlay.c: (gst_textoverlay_render_text),
+       (gst_text_overlay_blit_1), (gst_text_overlay_blit_sub2x2),
+       (gst_textoverlay_video_chain), (gst_textoverlay_loop),
+       (gst_textoverlay_font_init), (gst_textoverlay_init),
+       (gst_textoverlay_set_property):
+       * ext/cairo/gsttextoverlay.h:
+
 2004-12-27  David Schleef  <ds@schleef.org>
 
        * ext/cairo/gsttextoverlay.c: (gst_textoverlay_render_text),
index 9d6a5f2..43af1ca 100644 (file)
@@ -28,6 +28,8 @@
 #include <string.h>
 #include <math.h>
 
+GST_DEBUG_CATEGORY (cairo_debug);
+
 static gboolean
 plugin_init (GstPlugin * plugin)
 {
@@ -39,6 +41,8 @@ plugin_init (GstPlugin * plugin)
   gst_element_register (plugin, "cairotimeoverlay", GST_RANK_NONE,
       GST_TYPE_TIMEOVERLAY);
 
+  GST_DEBUG_CATEGORY_INIT (cairo_debug, "cairo", 0, "Cairo elements");
+
   return TRUE;
 }
 
index b2c1e87..dd34c13 100644 (file)
@@ -425,8 +425,22 @@ gst_textoverlay_loop (GstElement * element)
   g_return_if_fail (GST_IS_TEXTOVERLAY (element));
   overlay = GST_TEXTOVERLAY (element);
 
-  video_frame = GST_BUFFER (gst_pad_pull (overlay->video_sinkpad));
+  do {
+    GST_DEBUG ("Attempting to pull next video frame");
+    video_frame = GST_BUFFER (gst_pad_pull (overlay->video_sinkpad));
+    if (GST_IS_EVENT (video_frame)) {
+      GstEvent *event = GST_EVENT (video_frame);
+      GstEventType type = GST_EVENT_TYPE (event);
+
+      gst_pad_event_default (overlay->video_sinkpad, event);
+      GST_DEBUG ("Received event of type %d", type);
+      if (type == GST_EVENT_EOS || type == GST_EVENT_INTERRUPT)
+        return;
+      video_frame = NULL;
+    }
+  } while (!video_frame);
   now = GST_BUFFER_TIMESTAMP (video_frame);
+  GST_DEBUG ("Got video frame, time=%" GST_TIME_FORMAT, GST_TIME_ARGS (now));
 
   /*
    * This state machine has a bug that can't be resolved easily.
@@ -439,20 +453,41 @@ gst_textoverlay_loop (GstElement * element)
    * buffer timestamps and durations correctly.  (I think)
    */
 
-  while (overlay->next_buffer == NULL) {
+  while ((!overlay->current_buffer ||
+          PAST_END (overlay->current_buffer, now)) &&
+      overlay->next_buffer == NULL) {
     GST_DEBUG ("attempting to pull a buffer");
 
     /* read all text buffers until we get one "in the future" */
     if (!GST_PAD_IS_USABLE (overlay->text_sinkpad)) {
       break;
     }
-    overlay->next_buffer = GST_BUFFER (gst_pad_pull (overlay->text_sinkpad));
-    if (!overlay->next_buffer)
-      break;
+    do {
+      overlay->next_buffer = GST_BUFFER (gst_pad_pull (overlay->text_sinkpad));
+      if (GST_IS_EVENT (overlay->next_buffer)) {
+        GstEvent *event = GST_EVENT (overlay->next_buffer);
+        GstEventType type = GST_EVENT_TYPE (event);
+
+        gst_pad_event_default (overlay->text_sinkpad, event);
+        if (type == GST_EVENT_EOS || type == GST_EVENT_INTERRUPT)
+          return;
+        overlay->next_buffer = NULL;
+      }
+    } while (!overlay->next_buffer);
 
     if (PAST_END (overlay->next_buffer, now)) {
+      GST_DEBUG ("Received buffer is past end (%" GST_TIME_FORMAT " + %"
+          GST_TIME_FORMAT " < %" GST_TIME_FORMAT ")",
+          GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (overlay->next_buffer)),
+          GST_TIME_ARGS (GST_BUFFER_DURATION (overlay->next_buffer)),
+          GST_TIME_ARGS (now));
       gst_buffer_unref (overlay->next_buffer);
       overlay->next_buffer = NULL;
+    } else {
+      GST_DEBUG ("Received new text buffer of time %" GST_TIME_FORMAT
+          "and duration %" GST_TIME_FORMAT,
+          GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (overlay->next_buffer)),
+          GST_TIME_ARGS (GST_BUFFER_DURATION (overlay->next_buffer)));
     }
   }
 
@@ -573,7 +608,7 @@ gst_textoverlay_init (GstTextOverlay * overlay)
 
   overlay->halign = GST_TEXT_OVERLAY_HALIGN_CENTER;
   overlay->valign = GST_TEXT_OVERLAY_VALIGN_BASELINE;
-  overlay->x0 = overlay->y0 = 0;
+  overlay->x0 = overlay->y0 = 25;
 
   overlay->default_text = g_strdup ("");
   overlay->need_render = TRUE;
index 00862f7..6d572c6 100644 (file)
@@ -7,6 +7,9 @@
 
 G_BEGIN_DECLS
 
+GST_DEBUG_CATEGORY_EXTERN (cairo_debug);
+#define GST_CAT_DEFAULT cairo_debug
+
 #define GST_TYPE_TEXTOVERLAY           (gst_textoverlay_get_type())
 #define GST_TEXTOVERLAY(obj)           (G_TYPE_CHECK_INSTANCE_CAST((obj),\
                                         GST_TYPE_TEXTOVERLAY, GstTextOverlay))