static void
gst_progress_report_post_progress (GstProgressReport * filter,
    GstFormat format, gint64 current, gint64 total)
{
  GstStructure *s = NULL;

  if (current >= 0 && total > 0) {
    gdouble perc;

    perc = gst_util_guint64_to_gdouble (current) * 100.0 /
        gst_util_guint64_to_gdouble (total);
    perc = CLAMP (perc, 0.0, 100.0);

    /* we provide a "percent" field of integer type to stay compatible
     * with qtdemux, but add a second "percent-double" field for those who
     * want more precision and are too lazy to calculate it themselves */
    s = gst_structure_new ("progress", "percent", G_TYPE_INT, (gint) perc,
        "percent-double", G_TYPE_DOUBLE, perc, "current", G_TYPE_INT64, current,
        "total", G_TYPE_INT64, total, NULL);
  } else if (current >= 0) {
    s = gst_structure_new ("progress", "current", G_TYPE_INT64, current, NULL);
  }

  if (s) {
    GST_LOG_OBJECT (filter, "posting progress message: %" GST_PTR_FORMAT, s);
    gst_structure_set (s, "format", GST_TYPE_FORMAT, format, NULL);
    /* can't post it right here because we're holding the object lock */
    filter->pending_msg = gst_message_new_element (GST_OBJECT_CAST (filter), s);
  }
}
예제 #2
0
void test_guint64_to_gdouble()
{ 
   guint64 from[] = { 0, 1, 100, 10000, (guint64) (1) << 63,
    ((guint64) (1) << 63) + 1,
    ((guint64) (1) << 63) + (G_GINT64_CONSTANT (1) << 62)
  };
  gdouble to[] = { 0., 1., 100., 10000., 9223372036854775808.,
    9223372036854775809., 13835058055282163712.
  };
  gdouble tolerance[] = { 0., 0., 0., 0., 0., 1., 1. };
  gint i;
  gdouble result;
  gdouble delta;
  
  xmlfile = "gstutils_test_guint64_to_gdouble";
    std_log(LOG_FILENAME_LINE, "Test Started gstutils_test_guint64_to_gdouble");
   

  for (i = 0; i < G_N_ELEMENTS (from); ++i) {
    result = gst_util_guint64_to_gdouble (from[i]);
    delta = ABS (to[i] - result);
    fail_unless (delta <= tolerance[i],
        "Could not convert %d: %" G_GUINT64_FORMAT
        " -> %f, got %f instead, delta of %e with tolerance of %e",
        i, from[i], to[i], result, delta, tolerance[i]);
  }
  std_log(LOG_FILENAME_LINE, "Test Successful");
  create_xml(0);
}
예제 #3
0
static char *
gst_cairo_time_overlay_print_smpte_time (guint64 time)
{
  int hours;
  int minutes;
  int seconds;
  int ms;
  double x;

  x = rint (gst_util_guint64_to_gdouble (time + 500000) * 1e-6);

  hours = floor (x / (60 * 60 * 1000));
  x -= hours * 60 * 60 * 1000;
  minutes = floor (x / (60 * 1000));
  x -= minutes * 60 * 1000;
  seconds = floor (x / (1000));
  x -= seconds * 1000;
  ms = rint (x);

  return g_strdup_printf ("%02d:%02d:%02d.%03d", hours, minutes, seconds, ms);
}