static GstFlowReturn vorbis_handle_header_packet (GstVorbisDec * vd, ogg_packet * packet) { GstFlowReturn res; gint ret; GST_DEBUG_OBJECT (vd, "parsing header packet"); /* Packetno = 0 if the first byte is exactly 0x01 */ packet->b_o_s = ((gst_ogg_packet_data (packet))[0] == 0x1) ? 1 : 0; #ifdef USE_TREMOLO if ((ret = vorbis_dsp_headerin (&vd->vi, &vd->vc, packet))) #else if ((ret = vorbis_synthesis_headerin (&vd->vi, &vd->vc, packet))) #endif goto header_read_error; switch ((gst_ogg_packet_data (packet))[0]) { case 0x01: res = vorbis_handle_identification_packet (vd); break; case 0x03: res = vorbis_handle_comment_packet (vd, packet); break; case 0x05: res = vorbis_handle_type_packet (vd); break; default: /* ignore */ g_warning ("unknown vorbis header packet found"); res = GST_FLOW_OK; break; } return res; /* ERRORS */ header_read_error: { GST_ELEMENT_ERROR (GST_ELEMENT (vd), STREAM, DECODE, (NULL), ("couldn't read header packet (%d)", ret)); return GST_FLOW_ERROR; } }
static int _fetch_headers(OggVorbis_File *vf, vorbis_info *vi, vorbis_comment *vc, ogg_uint32_t *serialno, ogg_page *og_ptr){ ogg_page og={0,0,0,0}; ogg_packet op={0,0,0,0,0,0}; int i,ret; if(vf->ready_state>OPENED)_decode_clear(vf); if(!og_ptr){ ogg_int64_t llret=_get_next_page(vf,&og,CHUNKSIZE); if(llret==OV_EREAD)return OV_EREAD; if(llret<0)return OV_ENOTVORBIS; og_ptr=&og; } ogg_stream_reset_serialno(vf->os,ogg_page_serialno(og_ptr)); if(serialno)*serialno=vf->os->serialno; /* extract the initial header from the first page and verify that the Ogg bitstream is in fact Vorbis data */ vorbis_info_init(vi); vorbis_comment_init(vc); i=0; while(i<3){ ogg_stream_pagein(vf->os,og_ptr); while(i<3){ int result=ogg_stream_packetout(vf->os,&op); if(result==0)break; if(result==-1){ ret=OV_EBADHEADER; goto bail_header; } if((ret=vorbis_dsp_headerin(vi,vc,&op))){ goto bail_header; } i++; } if(i<3) if(_get_next_page(vf,og_ptr,CHUNKSIZE)<0){ ret=OV_EBADHEADER; goto bail_header; } } ogg_packet_release(&op); ogg_page_release(&og); vf->ready_state=LINKSET; return 0; bail_header: ogg_packet_release(&op); ogg_page_release(&og); vorbis_info_clear(vi); vorbis_comment_clear(vc); vf->ready_state=OPENED; return ret; }