Example #1
0
static GstFlowReturn
vorbis_parse_queue_buffer (GstVorbisParse * parse, GstBuffer * buf)
{
    GstFlowReturn ret = GST_FLOW_OK;
    long blocksize;
    ogg_packet packet;

    buf = gst_buffer_make_metadata_writable (buf);

    packet.packet = GST_BUFFER_DATA (buf);
    packet.bytes = GST_BUFFER_SIZE (buf);
    packet.granulepos = GST_BUFFER_OFFSET_END (buf);
    packet.packetno = parse->packetno + parse->buffer_queue->length;
    packet.e_o_s = 0;

    blocksize = vorbis_packet_blocksize (&parse->vi, &packet);

    /* temporarily store the sample count in OFFSET -- we overwrite this later */

    if (parse->prev_blocksize < 0)
        GST_BUFFER_OFFSET (buf) = 0;
    else
        GST_BUFFER_OFFSET (buf) = (blocksize + parse->prev_blocksize) / 4;

    parse->prev_blocksize = blocksize;

    g_queue_push_tail (parse->buffer_queue, buf);

    if (GST_BUFFER_OFFSET_END_IS_VALID (buf))
        ret = vorbis_parse_drain_queue (parse, GST_BUFFER_OFFSET_END (buf));

    return ret;
}
static GstFlowReturn
vorbis_parse_queue_buffer (GstVorbisParse * parse, GstBuffer * buf)
{
  GstFlowReturn ret = GST_FLOW_OK;
  long blocksize;
  ogg_packet packet;
  GstMapInfo map;

  buf = gst_buffer_make_writable (buf);

  gst_buffer_map (buf, &map, GST_MAP_READ);
  packet.packet = map.data;
  packet.bytes = map.size;
  GST_DEBUG ("%p, %" G_GSIZE_FORMAT, map.data, map.size);
  packet.granulepos = GST_BUFFER_OFFSET_END (buf);
  packet.packetno = parse->packetno + parse->buffer_queue->length;
  packet.e_o_s = 0;

  blocksize = vorbis_packet_blocksize (&parse->vi, &packet);
  gst_buffer_unmap (buf, &map);

  /* temporarily store the sample count in OFFSET -- we overwrite this later */

  if (parse->prev_blocksize < 0)
    GST_BUFFER_OFFSET (buf) = 0;
  else
    GST_BUFFER_OFFSET (buf) = (blocksize + parse->prev_blocksize) / 4;

  parse->prev_blocksize = blocksize;

  g_queue_push_tail (parse->buffer_queue, buf);

  if (GST_BUFFER_OFFSET_END_IS_VALID (buf))
    ret = vorbis_parse_drain_queue (parse, GST_BUFFER_OFFSET_END (buf));

  return ret;
}