Merge patch from Ronald fixing problems with streaming text.

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:
This commit is contained in:
Ronald 2004-12-28 09:26:32 +00:00 committed by David Schleef
parent 3065ec53ca
commit cf81f02e10
4 changed files with 60 additions and 6 deletions

View file

@ -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> 2004-12-27 David Schleef <ds@schleef.org>
* ext/cairo/gsttextoverlay.c: (gst_textoverlay_render_text), * ext/cairo/gsttextoverlay.c: (gst_textoverlay_render_text),

View file

@ -28,6 +28,8 @@
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
GST_DEBUG_CATEGORY (cairo_debug);
static gboolean static gboolean
plugin_init (GstPlugin * plugin) plugin_init (GstPlugin * plugin)
{ {
@ -39,6 +41,8 @@ plugin_init (GstPlugin * plugin)
gst_element_register (plugin, "cairotimeoverlay", GST_RANK_NONE, gst_element_register (plugin, "cairotimeoverlay", GST_RANK_NONE,
GST_TYPE_TIMEOVERLAY); GST_TYPE_TIMEOVERLAY);
GST_DEBUG_CATEGORY_INIT (cairo_debug, "cairo", 0, "Cairo elements");
return TRUE; return TRUE;
} }

View file

@ -425,8 +425,22 @@ gst_textoverlay_loop (GstElement * element)
g_return_if_fail (GST_IS_TEXTOVERLAY (element)); g_return_if_fail (GST_IS_TEXTOVERLAY (element));
overlay = GST_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); 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. * 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) * 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"); GST_DEBUG ("attempting to pull a buffer");
/* read all text buffers until we get one "in the future" */ /* read all text buffers until we get one "in the future" */
if (!GST_PAD_IS_USABLE (overlay->text_sinkpad)) { if (!GST_PAD_IS_USABLE (overlay->text_sinkpad)) {
break; break;
} }
overlay->next_buffer = GST_BUFFER (gst_pad_pull (overlay->text_sinkpad)); do {
if (!overlay->next_buffer) overlay->next_buffer = GST_BUFFER (gst_pad_pull (overlay->text_sinkpad));
break; 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)) { 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); gst_buffer_unref (overlay->next_buffer);
overlay->next_buffer = NULL; 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->halign = GST_TEXT_OVERLAY_HALIGN_CENTER;
overlay->valign = GST_TEXT_OVERLAY_VALIGN_BASELINE; overlay->valign = GST_TEXT_OVERLAY_VALIGN_BASELINE;
overlay->x0 = overlay->y0 = 0; overlay->x0 = overlay->y0 = 25;
overlay->default_text = g_strdup (""); overlay->default_text = g_strdup ("");
overlay->need_render = TRUE; overlay->need_render = TRUE;

View file

@ -7,6 +7,9 @@
G_BEGIN_DECLS 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_TYPE_TEXTOVERLAY (gst_textoverlay_get_type())
#define GST_TEXTOVERLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\ #define GST_TEXTOVERLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
GST_TYPE_TEXTOVERLAY, GstTextOverlay)) GST_TYPE_TEXTOVERLAY, GstTextOverlay))