static GstFlowReturn vorbis_dec_handle_header_buffer (GstVorbisDec * vd, GstBuffer * buffer) { ogg_packet *packet; ogg_packet_wrapper packet_wrapper; gst_ogg_packet_wrapper_from_buffer (&packet_wrapper, buffer); packet = gst_ogg_packet_from_wrapper (&packet_wrapper); return vorbis_handle_header_packet (vd, packet); }
static GstFlowReturn vorbis_dec_decode_buffer (GstVorbisDec * vd, GstBuffer * buffer) { ogg_packet *packet; ogg_packet_wrapper packet_wrapper; GstFlowReturn result = GST_FLOW_OK; /* make ogg_packet out of the buffer */ gst_ogg_packet_wrapper_from_buffer (&packet_wrapper, buffer); packet = gst_ogg_packet_from_wrapper (&packet_wrapper); /* set some more stuff */ packet->granulepos = -1; packet->packetno = 0; /* we don't care */ /* EOS does not matter, it is used in vorbis to implement clipping the last * block of samples based on the granulepos. We clip based on segments. */ packet->e_o_s = 0; GST_LOG_OBJECT (vd, "decode buffer of size %ld", packet->bytes); /* error out on empty header packets, but just skip empty data packets */ if (G_UNLIKELY (packet->bytes == 0)) { if (vd->initialized) goto empty_buffer; else goto empty_header; } /* switch depending on packet type */ if ((gst_ogg_packet_data (packet))[0] & 1) { if (vd->initialized) { GST_WARNING_OBJECT (vd, "Already initialized, so ignoring header packet"); goto done; } result = vorbis_handle_header_packet (vd, packet); } else { GstClockTime timestamp, duration; timestamp = GST_BUFFER_TIMESTAMP (buffer); duration = GST_BUFFER_DURATION (buffer); result = vorbis_handle_data_packet (vd, packet, timestamp, duration); } done: return result; empty_buffer: { /* don't error out here, just ignore the buffer, it's invalid for vorbis * but not fatal. */ GST_WARNING_OBJECT (vd, "empty buffer received, ignoring"); result = GST_FLOW_OK; goto done; } /* ERRORS */ empty_header: { GST_ELEMENT_ERROR (vd, STREAM, DECODE, (NULL), ("empty header received")); result = GST_FLOW_ERROR; vd->discont = TRUE; goto done; } }