Пример #1
0
static void
rtp_jpeg_do_packet_loss (gdouble prob, gint num_expected)
{
  GstHarness *h;
  gboolean eos = FALSE;
  gchar *s;
  guint i, buffer_count;

  s = g_strdup_printf ("videotestsrc pattern=ball num-buffers=100 ! "
      "jpegenc quality=50 ! rtpjpegpay ! identity drop-probability=%g ! "
      "rtpjpegdepay", prob);
  GST_INFO ("running pipeline %s", s);
  h = gst_harness_new_parse (s);
  g_free (s);

  gst_harness_play (h);

  do {
    GstEvent *event;

    event = gst_harness_pull_event (h);
    eos = (GST_EVENT_TYPE (event) == GST_EVENT_EOS);
    gst_event_unref (event);
  } while (!eos);

  buffer_count = gst_harness_buffers_received (h);
  GST_INFO ("Got %u buffers", buffer_count);

  if (num_expected >= 0) {
    fail_unless_equals_int (num_expected, buffer_count);
  }

  for (i = 0; i < buffer_count; ++i) {
    GstBuffer *buf;
    GstMapInfo map;
    guint16 soi, eoi;

    buf = gst_harness_pull (h);
    fail_unless (buf != NULL);

    fail_unless (gst_buffer_map (buf, &map, GST_MAP_READ));
    GST_MEMDUMP ("jpeg frame", map.data, map.size);
    fail_unless (map.size > 4);
    soi = GST_READ_UINT16_BE (map.data);
    fail_unless (soi == 0xffd8, "expected JPEG frame start FFD8 not %02X", soi);
    eoi = GST_READ_UINT16_BE (map.data + map.size - 2);
    fail_unless (eoi == 0xffd9, "expected JPEG frame end FFD9 not %02X", eoi);
    gst_buffer_unmap (buf, &map);
    gst_buffer_unref (buf);
  }

  gst_harness_teardown (h);
}
Пример #2
0
static GstHarness *
harness_rtpulpfecdec (guint32 ssrc, guint8 lost_pt, guint8 fec_pt)
{
  GstHarness *h =
      gst_harness_new_parse ("rtpstorage ! rtpulpfecdec ! identity");
  GObject *internal_storage;
  gchar *caps_str =
      g_strdup_printf ("application/x-rtp,ssrc=(uint)%u,payload=(int)%u",
      ssrc, lost_pt);

  gst_harness_set (h, "rtpstorage", "size-time", 200 * RTP_PACKET_DUR, NULL);
  gst_harness_get (h, "rtpstorage", "internal-storage", &internal_storage,
      NULL);
  gst_harness_set (h, "rtpulpfecdec", "storage", internal_storage, "pt", fec_pt,
      NULL);
  g_object_unref (internal_storage);

  gst_harness_set_src_caps_str (h, caps_str);
  g_free (caps_str);

  return h;
}