| /************************************************************************ |
| * Copyright (C) 2002-2009, Xiph.org Foundation |
| * Copyright (C) 2010, Robin Watts for Pinknoise Productions Ltd |
| * All rights reserved. |
| * |
| * Redistribution and use in source and binary forms, with or without |
| * modification, are permitted provided that the following conditions |
| * are met: |
| * |
| * * Redistributions of source code must retain the above copyright |
| * notice, this list of conditions and the following disclaimer. |
| * * Redistributions in binary form must reproduce the above |
| * copyright notice, this list of conditions and the following disclaimer |
| * in the documentation and/or other materials provided with the |
| * distribution. |
| * * Neither the names of the Xiph.org Foundation nor Pinknoise |
| * Productions Ltd nor the names of its contributors may be used to |
| * endorse or promote products derived from this software without |
| * specific prior written permission. |
| * |
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| ************************************************************************ |
| |
| function: stdio-based convenience library for opening/seeking/decoding |
| |
| ************************************************************************/ |
| |
| #ifndef _OV_FILE_H_ |
| #define _OV_FILE_H_ |
| |
| #ifdef __cplusplus |
| extern "C" |
| { |
| #endif /* __cplusplus */ |
| |
| #include <stdio.h> |
| #include "ivorbiscodec.h" |
| |
| /* The function prototypes for the callbacks are basically the same as for |
| * the stdio functions fread, fseek, fclose, ftell. |
| * The one difference is that the FILE * arguments have been replaced with |
| * a void * - this is to be used as a pointer to whatever internal data these |
| * functions might need. In the stdio case, it's just a FILE * cast to a void * |
| * |
| * If you use other functions, check the docs for these functions and return |
| * the right values. For seek_func(), you *MUST* return -1 if the stream is |
| * unseekable |
| */ |
| typedef struct { |
| size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource); |
| int (*seek_func) (void *datasource, ogg_int64_t offset, int whence); |
| int (*close_func) (void *datasource); |
| long (*tell_func) (void *datasource); |
| } ov_callbacks; |
| |
| typedef struct OggVorbis_File { |
| void *datasource; /* Pointer to a FILE *, etc. */ |
| int seekable; |
| ogg_int64_t offset; |
| ogg_int64_t end; |
| ogg_sync_state *oy; |
| |
| /* If the FILE handle isn't seekable (eg, a pipe), only the current |
| stream appears */ |
| int links; |
| ogg_int64_t *offsets; |
| ogg_int64_t *dataoffsets; |
| ogg_uint32_t *serialnos; |
| ogg_int64_t *pcmlengths; |
| vorbis_info vi; |
| vorbis_comment vc; |
| |
| /* Decoding working state local storage */ |
| ogg_int64_t pcm_offset; |
| int ready_state; |
| ogg_uint32_t current_serialno; |
| int current_link; |
| |
| ogg_int64_t bittrack; |
| ogg_int64_t samptrack; |
| |
| ogg_stream_state *os; /* take physical pages, weld into a logical |
| stream of packets */ |
| vorbis_dsp_state *vd; /* central working state for the packet->PCM decoder */ |
| |
| ov_callbacks callbacks; |
| |
| } OggVorbis_File; |
| |
| extern int ov_clear(OggVorbis_File *vf); |
| extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes); |
| extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf, |
| char *initial, long ibytes, ov_callbacks callbacks); |
| |
| extern int ov_test(FILE *f,OggVorbis_File *vf,char *initial,long ibytes); |
| extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf, |
| char *initial, long ibytes, ov_callbacks callbacks); |
| extern int ov_test_open(OggVorbis_File *vf); |
| |
| extern long ov_bitrate(OggVorbis_File *vf,int i); |
| extern long ov_bitrate_instant(OggVorbis_File *vf); |
| extern long ov_streams(OggVorbis_File *vf); |
| extern long ov_seekable(OggVorbis_File *vf); |
| extern long ov_serialnumber(OggVorbis_File *vf,int i); |
| |
| extern ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i); |
| extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i); |
| extern ogg_int64_t ov_time_total(OggVorbis_File *vf,int i); |
| |
| extern int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos); |
| extern int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos); |
| extern int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos); |
| extern int ov_time_seek(OggVorbis_File *vf,ogg_int64_t pos); |
| extern int ov_time_seek_page(OggVorbis_File *vf,ogg_int64_t pos); |
| |
| extern ogg_int64_t ov_raw_tell(OggVorbis_File *vf); |
| extern ogg_int64_t ov_pcm_tell(OggVorbis_File *vf); |
| extern ogg_int64_t ov_time_tell(OggVorbis_File *vf); |
| |
| extern vorbis_info *ov_info(OggVorbis_File *vf,int link); |
| extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link); |
| |
| extern long ov_read(OggVorbis_File *vf,void *buffer,int length, |
| int *bitstream); |
| |
| #ifdef __cplusplus |
| } |
| #endif /* __cplusplus */ |
| |
| #endif |
| |
| |