Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members

vorbiscc.h

00001 
00008 #ifndef VORBISCC_H
00009 #define VORBISCC_H
00010 
00011 #include "oggcc.h"
00012 #include <string>
00013 #include <vorbis/codec.h>
00014 #include <vorbis/vorbisenc.h>
00015 
00016 namespace ogg {
00018     namespace vorbis {
00022         class comment {
00023             protected:
00024                 void init ( )   { vorbis_comment_init ( &this->data ); }
00025                 void clear ( )  { vorbis_comment_clear ( &this->data ); }
00026 
00027                 int header_out ( ogg_packet *op )  {
00028                     return vorbis_commentheader_out ( &this->data, op ); }
00029 
00030             public:
00031                 vorbis_comment data;
00032                 vorbis_comment *get_data()  { return &this->data; }
00033 
00034                 comment()   { this->init(); }
00035                 ~comment()  { this->clear(); }
00036 
00037                 const char *query ( char *tag , int count )  {
00038                     return vorbis_comment_query ( &this->data, tag, count ); }
00039 
00040                 int query_count ( char *tag )  {
00041                     return vorbis_comment_query_count ( &this->data, tag ); }
00042 
00043                 void add ( char *comment )  {
00044                     vorbis_comment_add ( &this->data, comment ); }
00045 
00046                 void add_tag ( char *tag , char *contents )  {
00047                     vorbis_comment_add_tag ( &this->data, tag, contents ); }
00048 
00049                 int header_out ( packet *op )  {
00050                     return this->header_out ( op->get_data() ); }
00051 
00053                 std::string query_index(unsigned int index) { 
00054                     vorbis_comment *data = this->get_data();
00055                     return (index < (unsigned)(data->comments) ? 
00056                             std::string(data->user_comments[index], data->comment_lengths[index]) : ""); };
00057                 
00058                 int size()  { return this->get_data()->comments; }
00059         };
00060 
00061 
00063         class info {
00064             protected:
00065                 int synthesis_headerin ( vorbis_comment *vc, ogg_packet *op )  {
00066                     return vorbis_synthesis_headerin ( &this->data, vc, op );  }
00067 
00068                 long packet_blocksize ( ogg_packet *op )  {
00069                     return vorbis_packet_blocksize ( &this->data, op );  }
00070 
00071                 void info_init ( )  { return vorbis_info_init ( &this->data );  }
00072                 void info_clear ( )  { return vorbis_info_clear ( &this->data );  }
00073 
00074             public:
00075                 vorbis_info data;
00076                 vorbis_info *get_data() { return &this->data; }
00077 
00078                 info()    { this->info_init(); }
00079                 ~info()   { this->info_clear(); }
00080 
00081                 int encode_init(long channels,
00082                                 long rate, 
00083                                 long max_bitrate, 
00084                                 long nominal_bitrate, 
00085                                 long min_bitrate)
00086 
00087                 { return vorbis_encode_init(&this->data,
00088                                             channels, 
00089                                             rate, 
00090                                             max_bitrate, 
00091                                             nominal_bitrate, 
00092                                             min_bitrate); } 
00093 
00094 
00095                 int encode_setup_managed(long channels, 
00096                                          long rate, 
00097                                          long max_bitrate, 
00098                                          long nominal_bitrate, 
00099                                          long min_bitrate) { 
00100 
00101                     return vorbis_encode_setup_managed(&this->data, 
00102                                                        channels, 
00103                                                        rate, 
00104                                                        max_bitrate,
00105                                                        nominal_bitrate, 
00106                                                        min_bitrate); }
00107 
00109                 int encode_setup_vbr(long channels, 
00110                                      long rate, 
00111                                      float base_quality) {
00112 
00113                     return vorbis_encode_setup_vbr(&this->data, 
00114                                                    channels, 
00115                                                    rate,           
00116                                                    base_quality); }
00117 
00118 
00119                 int encode_init_vbr(long channels, 
00120                                     long rate, 
00121                                     float base_quality) {
00122 
00123                     return vorbis_encode_init_vbr(&this->data, 
00124                                                   channels, 
00125                                                   rate, 
00126                                                   base_quality); }
00127 
00128 
00129                 int encode_ctl(vorbis_info *vi, int number, void *arg) {
00130                     return vorbis_encode_ctl( &this->data, number, arg ); }
00131 
00132 
00133                 int encode_setup_init() {
00134                     return vorbis_encode_setup_init( &this->data ); }
00135 
00136 
00137                 int info_blocksize ( int zo )  {
00138                     return vorbis_info_blocksize ( &this->data, zo );  }
00139 
00140                 int synthesis_halfrate ( int flag )  {
00141                     return vorbis_synthesis_halfrate ( &this->data, flag );  }
00142 
00143                 int synthesis_halfrate_p ( )  {
00144                     return vorbis_synthesis_halfrate_p ( &this->data );  }
00145 
00146                 // packet in, comment out.
00147                 int synthesis_headerin ( comment *vc, packet *op ) {
00148                     return this->synthesis_headerin ( &vc->data, op->get_data() ); }
00149 
00150                 long packet_blocksize ( packet *op )  {
00151                     return this->packet_blocksize ( op->get_data() );  }
00152 
00153                 int  get_version()  { return this->get_data()->version; }
00154                 int  get_channels() { return this->get_data()->channels; }
00155                 long get_rate()     { return this->get_data()->rate; }
00156         };
00157 
00158 
00160         class block {
00161             protected:
00162                 int analysis ( ogg_packet *op )  {
00163                     return vorbis_analysis ( &this->data, op );  }
00164 
00165                 int synthesis ( ogg_packet *op )  {
00166                     return vorbis_synthesis ( &this->data, op ); }
00167 
00168                 int synthesis_trackonly ( ogg_packet *op )  {
00169                     return vorbis_synthesis_trackonly ( &this->data, op ); }
00170 
00171             public:
00172                 vorbis_block data;
00173 
00174                 int analysis ( packet *op )   { return this->analysis(op->get_data()); }
00175                 int bitrate_addblock ( )      { return vorbis_bitrate_addblock ( &this->data ); }
00176                 int block_clear ( )           { return vorbis_block_clear ( &this->data ); }
00177                 int synthesis ( packet *op )  { return this->synthesis(op->get_data()); }
00178                 int synthesis_trackonly ( packet *op )  { return this->synthesis_trackonly(op->get_data()); }
00179         };
00180 
00181 
00183         // may separate into separate synthesis and analysis objects.
00184         class dsp {
00185             protected:
00186                 int bitrate_flushpacket ( ogg_packet *op )  {
00187                     return vorbis_bitrate_flushpacket ( &this->data, op ); }
00188 
00189                 int analysis_init ( vorbis_info *vi )  {
00190                     return vorbis_analysis_init ( &this->data, vi ); }
00191 
00192                 int analysis_blockout ( vorbis_block *vb )  {
00193                     return vorbis_analysis_blockout ( &this->data, vb ); }
00194 
00195                 int analysis_headerout ( vorbis_comment *vc, ogg_packet *op, ogg_packet *op_comm, ogg_packet *op_code )  {
00196                     return vorbis_analysis_headerout ( &this->data, vc , op , op_comm , op_code ); }
00197 
00198                 int synthesis_init ( vorbis_info *vi )  {
00199                     return vorbis_synthesis_init ( &this->data, vi ); }
00200 
00201                 int synthesis_blockin ( vorbis_block *vb )  {
00202                     return vorbis_synthesis_blockin ( &this->data, vb ); }
00203 
00204                 int block_init ( vorbis_block *vb )  {
00205                     return vorbis_block_init ( &this->data, vb ); }
00206 
00207             public:
00209                 vorbis_dsp_state data;
00210                 vorbis_dsp_state *get_data()  { return &this->data; }
00211 
00212                 int block_init ( block *vb )  {
00213                     return this->block_init ( &vb->data ); }
00214 
00215                 double granule_time ( ogg_int64_t granulepos )  {
00216                     return vorbis_granule_time ( &this->data, granulepos ); }
00217 
00218                 int bitrate_flushpacket ( packet *op )  {
00219                     return this->bitrate_flushpacket ( op->get_data() ); }
00220 
00222 
00223                 int analysis_init ( info *vi )  {
00224                     return this->analysis_init ( &vi->data ); }
00225 
00226                 float **analysis_buffer ( int vals )  {
00227                     return vorbis_analysis_buffer ( &this->data, vals ); }
00228 
00229                 int analysis_wrote ( int vals )  {
00230                     return vorbis_analysis_wrote ( &this->data, vals ); }
00231 
00232                 int analysis_blockout ( block *vb )  {
00233                     return this->analysis_blockout ( &vb->data ); }        
00234 
00235                 // spits out three headers.
00236                 int analysis_headerout ( comment *vc, 
00237                                          packet *op, 
00238                                          packet *op_comm, 
00239                                          packet *op_code )  {
00240                     return this->analysis_headerout ( &vc->data , 
00241                                                       op->get_data() , 
00242                                                       op_comm->get_data() , 
00243                                                       op_code->get_data() ); }
00244 
00245 
00247 
00248                 int synthesis_init ( info *vi )  {
00249                     return this->synthesis_init ( &vi->data ); }
00250 
00251                 int synthesis_blockin ( block *vb )  {
00252                     return this->synthesis_blockin ( &vb->data ); }
00253 
00254                 int synthesis_lapout ( float ***pcm )  {
00255                     return vorbis_synthesis_lapout ( &this->data, pcm ); }
00256 
00257                 int synthesis_pcmout ( float ***pcm )  {
00258                     return vorbis_synthesis_pcmout ( &this->data, pcm ); }
00259 
00260                 int synthesis_read ( int samples )  {
00261                     return vorbis_synthesis_read ( &this->data, samples ); }
00262 
00263                 int synthesis_restart ( )  {
00264                     return vorbis_synthesis_restart ( &this->data ); }
00265 
00266 
00267                 void dsp_clear ( )  {
00268                     vorbis_dsp_clear ( &this->data ); }
00269         };
00270     };
00271 };
00272 
00273 #endif
00274 
00275 /* Vorbis ERRORS and return codes **
00276 
00277 #define OV_FALSE      -1  
00278 #define OV_EOF        -2
00279 #define OV_HOLE       -3
00280 
00281 #define OV_EREAD      -128
00282 #define OV_EFAULT     -129
00283 #define OV_EIMPL      -130
00284 #define OV_EINVAL     -131
00285 #define OV_ENOTVORBIS -132
00286 #define OV_EBADHEADER -133
00287 #define OV_EVERSION   -134
00288 #define OV_ENOTAUDIO  -135
00289 #define OV_EBADPACKET -136
00290 #define OV_EBADLINK   -137
00291 #define OV_ENOSEEK    -138
00292 
00293  *************************************/

Generated on Wed Apr 7 03:10:32 2004 for oggpy/oggcc by doxygen 1.3.5