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_handle_header_buffer (GstVorbisDec * vd, GstBuffer * buffer) { ogg_packet *packet; ogg_packet_wrapper packet_wrapper; GstFlowReturn ret; GstMapInfo map; gst_ogg_packet_wrapper_map (&packet_wrapper, buffer, &map); packet = gst_ogg_packet_from_wrapper (&packet_wrapper); ret = vorbis_handle_header_packet (vd, packet); gst_ogg_packet_wrapper_unmap (&packet_wrapper, buffer, &map); return ret; }
static GstFlowReturn vorbis_dec_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer) { ogg_packet *packet; ogg_packet_wrapper packet_wrapper; GstFlowReturn result = GST_FLOW_OK; GstMapInfo map; GstVorbisDec *vd = GST_VORBIS_DEC (dec); /* no draining etc */ if (G_UNLIKELY (!buffer)) return GST_FLOW_OK; GST_LOG_OBJECT (vd, "got buffer %p", buffer); /* make ogg_packet out of the buffer */ gst_ogg_packet_wrapper_map (&packet_wrapper, buffer, &map); 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); if (result != GST_FLOW_OK) goto done; /* consumer header packet/frame */ result = gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (vd), NULL, 1); } else { GstClockTime timestamp, duration; timestamp = GST_BUFFER_TIMESTAMP (buffer); duration = GST_BUFFER_DURATION (buffer); result = vorbis_handle_data_packet (vd, packet, timestamp, duration); } done: GST_LOG_OBJECT (vd, "unmap buffer %p", buffer); gst_ogg_packet_wrapper_unmap (&packet_wrapper, buffer, &map); 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; goto done; } }