コード例 #1
0
/* Called with lock held */
static gchar *
gst_time_overlay_get_text (GstTextOverlay * overlay, GstBuffer * video_frame)
{
  GstClockTime time = GST_BUFFER_TIMESTAMP (video_frame);
  gchar *time_str, *txt, *ret;

  overlay->need_render = TRUE;

  if (!GST_CLOCK_TIME_IS_VALID (time)) {
    GST_DEBUG ("buffer without valid timestamp");
    return g_strdup ("");
  }

  GST_DEBUG ("buffer with timestamp %" GST_TIME_FORMAT, GST_TIME_ARGS (time));

  txt = g_strdup (overlay->default_text);

  time_str = gst_time_overlay_render_time (GST_TIME_OVERLAY (overlay), time);
  if (txt != NULL && *txt != '\0') {
    ret = g_strdup_printf ("%s %s", txt, time_str);
  } else {
    ret = time_str;
    time_str = NULL;
  }

  g_free (txt);
  g_free (time_str);

  return ret;
}
コード例 #2
0
/* Called with lock held */
static gchar *
gst_time_overlay_get_text (GstBaseTextOverlay * overlay,
    GstBuffer * video_frame)
{
  GstTimeOverlayTimeLine time_line;
  GstClockTime ts, ts_buffer;
  GstSegment *segment = &overlay->segment;
  gchar *time_str, *txt, *ret;

  overlay->need_render = TRUE;

  ts_buffer = GST_BUFFER_TIMESTAMP (video_frame);

  if (!GST_CLOCK_TIME_IS_VALID (ts_buffer)) {
    GST_DEBUG ("buffer without valid timestamp");
    return g_strdup ("");
  }

  GST_DEBUG ("buffer with timestamp %" GST_TIME_FORMAT,
      GST_TIME_ARGS (ts_buffer));

  time_line = g_atomic_int_get (&GST_TIME_OVERLAY_CAST (overlay)->time_line);
  switch (time_line) {
    case GST_TIME_OVERLAY_TIME_LINE_STREAM_TIME:
      ts = gst_segment_to_stream_time (segment, GST_FORMAT_TIME, ts_buffer);
      break;
    case GST_TIME_OVERLAY_TIME_LINE_RUNNING_TIME:
      ts = gst_segment_to_running_time (segment, GST_FORMAT_TIME, ts_buffer);
      break;
    case GST_TIME_OVERLAY_TIME_LINE_BUFFER_TIME:
    default:
      ts = ts_buffer;
      break;
  }

  txt = g_strdup (overlay->default_text);

  time_str = gst_time_overlay_render_time (GST_TIME_OVERLAY (overlay), ts);
  if (txt != NULL && *txt != '\0') {
    ret = g_strdup_printf ("%s %s", txt, time_str);
  } else {
    ret = time_str;
    time_str = NULL;
  }

  g_free (txt);
  g_free (time_str);

  return ret;
}