diff --git a/ChangeLog b/ChangeLog index 54473e5ea4..89fd810496 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2004-12-28 David Schleef + + 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 * ext/cairo/gsttextoverlay.c: (gst_textoverlay_render_text), diff --git a/ext/cairo/gstcairo.c b/ext/cairo/gstcairo.c index 9d6a5f23c4..43af1ca165 100644 --- a/ext/cairo/gstcairo.c +++ b/ext/cairo/gstcairo.c @@ -28,6 +28,8 @@ #include #include +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; } diff --git a/ext/cairo/gsttextoverlay.c b/ext/cairo/gsttextoverlay.c index b2c1e8753b..dd34c13e80 100644 --- a/ext/cairo/gsttextoverlay.c +++ b/ext/cairo/gsttextoverlay.c @@ -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; diff --git a/ext/cairo/gsttextoverlay.h b/ext/cairo/gsttextoverlay.h index 00862f786f..6d572c67ed 100644 --- a/ext/cairo/gsttextoverlay.h +++ b/ext/cairo/gsttextoverlay.h @@ -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))