Example #1
0
gint
gstspu_exec_pgs_buffer (GstDVDSpu * dvdspu, GstBuffer * buf)
{
  GstMapInfo map;
  guint8 *pos, *end;
  guint8 type;
  guint16 packet_len;

  gst_buffer_map (buf, &map, GST_MAP_READ);

  pos = map.data;
  end = pos + map.size;

  /* Need at least 3 bytes */
  if (pos + 3 > end) {
    PGS_DUMP ("Not enough bytes to be a PGS packet\n");
    goto error;
  }

  PGS_DUMP ("Begin dumping command buffer of size %u ts %" GST_TIME_FORMAT "\n",
      end - pos, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
  do {
    type = *pos++;
    packet_len = GST_READ_UINT16_BE (pos);
    pos += 2;

    if (pos + packet_len > end) {
      gst_buffer_unmap (buf, &map);
      PGS_DUMP ("Invalid packet length %u (only have %u bytes)\n", packet_len,
          end - pos);
      goto error;
    }

    if (parse_pgs_packet (dvdspu, type, pos, packet_len))
      goto error;

    pos += packet_len;
  } while (pos + 3 <= end);

  PGS_DUMP ("End dumping command buffer with %u bytes remaining\n", end - pos);
  return (pos - map.data);

  /* ERRORS */
error:
  {
    gst_buffer_unmap (buf, &map);
    return -1;
  }
}
Example #2
0
gint
gstspu_exec_pgs_buffer (GstDVDSpu * dvdspu, GstBuffer * buf)
{
  guint8 *pos, *end;
  guint8 type;
  guint16 packet_len;

  pos = GST_BUFFER_DATA (buf);
  end = pos + GST_BUFFER_SIZE (buf);

  /* Need at least 3 bytes */
  if (pos + 3 > end) {
    PGS_DUMP ("Not enough bytes to be a PGS packet\n");
    return -1;
  }

  PGS_DUMP ("Begin dumping command buffer of size %u ts %" GST_TIME_FORMAT "\n",
      end - pos, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
  do {
    type = *pos++;
    packet_len = GST_READ_UINT16_BE (pos);
    pos += 2;

    if (pos + packet_len > end) {
      PGS_DUMP ("Invalid packet length %u (only have %u bytes)\n", packet_len,
          end - pos);
      return -1;
    }

    if (parse_pgs_packet (dvdspu, type, pos, packet_len))
      return -1;

    pos += packet_len;
  } while (pos + 3 <= end);

  PGS_DUMP ("End dumping command buffer with %u bytes remaining\n", end - pos);
  return (pos - GST_BUFFER_DATA (buf));
}