2
0

ivorbisfile.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /********************************************************************
  2. * *
  3. * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
  4. * *
  5. * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
  6. * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
  7. * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
  8. * *
  9. * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
  10. * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
  11. * *
  12. ********************************************************************
  13. function: stdio-based convenience library for opening/seeking/decoding
  14. ********************************************************************/
  15. #ifndef _OV_FILE_H_
  16. #define _OV_FILE_H_
  17. #ifdef __cplusplus
  18. extern "C"
  19. {
  20. #endif /* __cplusplus */
  21. #include <stdio.h>
  22. #include "ivorbiscodec.h"
  23. #define CHUNKSIZE 65535
  24. #define READSIZE 1024
  25. /* The function prototypes for the callbacks are basically the same as for
  26. * the stdio functions fread, fseek, fclose, ftell.
  27. * The one difference is that the FILE * arguments have been replaced with
  28. * a void * - this is to be used as a pointer to whatever internal data these
  29. * functions might need. In the stdio case, it's just a FILE * cast to a void *
  30. *
  31. * If you use other functions, check the docs for these functions and return
  32. * the right values. For seek_func(), you *MUST* return -1 if the stream is
  33. * unseekable
  34. */
  35. typedef struct {
  36. size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource);
  37. int (*seek_func) (void *datasource, ogg_int64_t offset, int whence);
  38. int (*close_func) (void *datasource);
  39. long (*tell_func) (void *datasource);
  40. } ov_callbacks;
  41. #define NOTOPEN 0
  42. #define PARTOPEN 1
  43. #define OPENED 2
  44. #define STREAMSET 3
  45. #define INITSET 4
  46. typedef struct OggVorbis_File {
  47. void *datasource; /* Pointer to a FILE *, etc. */
  48. int seekable;
  49. ogg_int64_t offset;
  50. ogg_int64_t end;
  51. ogg_sync_state oy;
  52. /* If the FILE handle isn't seekable (eg, a pipe), only the current
  53. stream appears */
  54. int links;
  55. ogg_int64_t *offsets;
  56. ogg_int64_t *dataoffsets;
  57. ogg_uint32_t *serialnos;
  58. ogg_int64_t *pcmlengths;
  59. vorbis_info *vi;
  60. vorbis_comment *vc;
  61. /* Decoding working state local storage */
  62. ogg_int64_t pcm_offset;
  63. int ready_state;
  64. ogg_uint32_t current_serialno;
  65. int current_link;
  66. ogg_int64_t bittrack;
  67. ogg_int64_t samptrack;
  68. ogg_stream_state os; /* take physical pages, weld into a logical
  69. stream of packets */
  70. vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
  71. vorbis_block vb; /* local working space for packet->PCM decode */
  72. ov_callbacks callbacks;
  73. } OggVorbis_File;
  74. extern int ov_clear(OggVorbis_File *vf);
  75. extern int ov_open(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes);
  76. extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf,
  77. const char *initial, long ibytes, ov_callbacks callbacks);
  78. extern int ov_test(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes);
  79. extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf,
  80. const char *initial, long ibytes, ov_callbacks callbacks);
  81. extern int ov_test_open(OggVorbis_File *vf);
  82. extern long ov_bitrate(OggVorbis_File *vf,int i);
  83. extern long ov_bitrate_instant(OggVorbis_File *vf);
  84. extern long ov_streams(OggVorbis_File *vf);
  85. extern long ov_seekable(OggVorbis_File *vf);
  86. extern long ov_serialnumber(OggVorbis_File *vf,int i);
  87. extern ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i);
  88. extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i);
  89. extern ogg_int64_t ov_time_total(OggVorbis_File *vf,int i);
  90. extern int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos);
  91. extern int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos);
  92. extern int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos);
  93. extern int ov_time_seek(OggVorbis_File *vf,ogg_int64_t pos);
  94. extern int ov_time_seek_page(OggVorbis_File *vf,ogg_int64_t pos);
  95. extern ogg_int64_t ov_raw_tell(OggVorbis_File *vf);
  96. extern ogg_int64_t ov_pcm_tell(OggVorbis_File *vf);
  97. extern ogg_int64_t ov_time_tell(OggVorbis_File *vf);
  98. extern vorbis_info *ov_info(OggVorbis_File *vf,int link);
  99. extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link);
  100. extern long ov_read(OggVorbis_File *vf,char *buffer,int length,
  101. int *bitstream);
  102. #ifdef __cplusplus
  103. }
  104. #endif /* __cplusplus */
  105. #endif