cannam@86: cannam@86: cannam@86: FLAC: include/FLAC++/encoder.h Source File cannam@86: cannam@86: cannam@86: cannam@86:
Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members
cannam@86: cannam@86:

encoder.h

Go to the documentation of this file.
00001 /* libFLAC++ - Free Lossless Audio Codec library
cannam@86: 00002  * Copyright (C) 2002,2003,2004,2005,2006,2007  Josh Coalson
cannam@86: 00003  *
cannam@86: 00004  * Redistribution and use in source and binary forms, with or without
cannam@86: 00005  * modification, are permitted provided that the following conditions
cannam@86: 00006  * are met:
cannam@86: 00007  *
cannam@86: 00008  * - Redistributions of source code must retain the above copyright
cannam@86: 00009  * notice, this list of conditions and the following disclaimer.
cannam@86: 00010  *
cannam@86: 00011  * - Redistributions in binary form must reproduce the above copyright
cannam@86: 00012  * notice, this list of conditions and the following disclaimer in the
cannam@86: 00013  * documentation and/or other materials provided with the distribution.
cannam@86: 00014  *
cannam@86: 00015  * - Neither the name of the Xiph.org Foundation nor the names of its
cannam@86: 00016  * contributors may be used to endorse or promote products derived from
cannam@86: 00017  * this software without specific prior written permission.
cannam@86: 00018  *
cannam@86: 00019  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
cannam@86: 00020  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
cannam@86: 00021  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
cannam@86: 00022  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
cannam@86: 00023  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
cannam@86: 00024  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
cannam@86: 00025  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
cannam@86: 00026  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
cannam@86: 00027  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
cannam@86: 00028  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
cannam@86: 00029  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cannam@86: 00030  */
cannam@86: 00031 
cannam@86: 00032 #ifndef FLACPP__ENCODER_H
cannam@86: 00033 #define FLACPP__ENCODER_H
cannam@86: 00034 
cannam@86: 00035 #include "export.h"
cannam@86: 00036 
cannam@86: 00037 #include "FLAC/stream_encoder.h"
cannam@86: 00038 #include "decoder.h"
cannam@86: 00039 #include "metadata.h"
cannam@86: 00040 
cannam@86: 00041 
cannam@86: 00078 namespace FLAC {
cannam@86: 00079     namespace Encoder {
cannam@86: 00080 
cannam@86: 00101         class FLACPP_API Stream {
cannam@86: 00102         public:
cannam@86: 00105             class FLACPP_API State {
cannam@86: 00106             public:
cannam@86: 00107                 inline State(::FLAC__StreamEncoderState state): state_(state) { }
cannam@86: 00108                 inline operator ::FLAC__StreamEncoderState() const { return state_; }
cannam@86: 00109                 inline const char *as_cstring() const { return ::FLAC__StreamEncoderStateString[state_]; }
cannam@86: 00110                 inline const char *resolved_as_cstring(const Stream &encoder) const { return ::FLAC__stream_encoder_get_resolved_state_string(encoder.encoder_); }
cannam@86: 00111             protected:
cannam@86: 00112 				::FLAC__StreamEncoderState state_;
cannam@86: 00113             };
cannam@86: 00114 
cannam@86: 00115             Stream();
cannam@86: 00116             virtual ~Stream();
cannam@86: 00117 
cannam@86: 00119 
cannam@86: 00123             virtual bool is_valid() const;
cannam@86: 00124             inline operator bool() const { return is_valid(); } 
cannam@86: 00125 
cannam@86: 00126 
cannam@86: 00127             virtual bool set_ogg_serial_number(long value);                 
cannam@86: 00128             virtual bool set_verify(bool value);                            
cannam@86: 00129             virtual bool set_streamable_subset(bool value);                 
cannam@86: 00130             virtual bool set_channels(unsigned value);                      
cannam@86: 00131             virtual bool set_bits_per_sample(unsigned value);               
cannam@86: 00132             virtual bool set_sample_rate(unsigned value);                   
cannam@86: 00133             virtual bool set_compression_level(unsigned value);             
cannam@86: 00134             virtual bool set_blocksize(unsigned value);                     
cannam@86: 00135             virtual bool set_do_mid_side_stereo(bool value);                
cannam@86: 00136             virtual bool set_loose_mid_side_stereo(bool value);             
cannam@86: 00137             virtual bool set_apodization(const char *specification);        
cannam@86: 00138             virtual bool set_max_lpc_order(unsigned value);                 
cannam@86: 00139             virtual bool set_qlp_coeff_precision(unsigned value);           
cannam@86: 00140             virtual bool set_do_qlp_coeff_prec_search(bool value);          
cannam@86: 00141             virtual bool set_do_escape_coding(bool value);                  
cannam@86: 00142             virtual bool set_do_exhaustive_model_search(bool value);        
cannam@86: 00143             virtual bool set_min_residual_partition_order(unsigned value);  
cannam@86: 00144             virtual bool set_max_residual_partition_order(unsigned value);  
cannam@86: 00145             virtual bool set_rice_parameter_search_dist(unsigned value);    
cannam@86: 00146             virtual bool set_total_samples_estimate(FLAC__uint64 value);    
cannam@86: 00147             virtual bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);    
cannam@86: 00148             virtual bool set_metadata(FLAC::Metadata::Prototype **metadata, unsigned num_blocks); 
cannam@86: 00149 
cannam@86: 00150             /* get_state() is not virtual since we want subclasses to be able to return their own state */
cannam@86: 00151             State get_state() const;                                   
cannam@86: 00152             virtual Decoder::Stream::State get_verify_decoder_state() const; 
cannam@86: 00153             virtual void get_verify_decoder_error_stats(FLAC__uint64 *absolute_sample, unsigned *frame_number, unsigned *channel, unsigned *sample, FLAC__int32 *expected, FLAC__int32 *got); 
cannam@86: 00154             virtual bool     get_verify() const;                       
cannam@86: 00155             virtual bool     get_streamable_subset() const;            
cannam@86: 00156             virtual bool     get_do_mid_side_stereo() const;           
cannam@86: 00157             virtual bool     get_loose_mid_side_stereo() const;        
cannam@86: 00158             virtual unsigned get_channels() const;                     
cannam@86: 00159             virtual unsigned get_bits_per_sample() const;              
cannam@86: 00160             virtual unsigned get_sample_rate() const;                  
cannam@86: 00161             virtual unsigned get_blocksize() const;                    
cannam@86: 00162             virtual unsigned get_max_lpc_order() const;                
cannam@86: 00163             virtual unsigned get_qlp_coeff_precision() const;          
cannam@86: 00164             virtual bool     get_do_qlp_coeff_prec_search() const;     
cannam@86: 00165             virtual bool     get_do_escape_coding() const;             
cannam@86: 00166             virtual bool     get_do_exhaustive_model_search() const;   
cannam@86: 00167             virtual unsigned get_min_residual_partition_order() const; 
cannam@86: 00168             virtual unsigned get_max_residual_partition_order() const; 
cannam@86: 00169             virtual unsigned get_rice_parameter_search_dist() const;   
cannam@86: 00170             virtual FLAC__uint64 get_total_samples_estimate() const;   
cannam@86: 00171 
cannam@86: 00172             virtual ::FLAC__StreamEncoderInitStatus init();            
cannam@86: 00173             virtual ::FLAC__StreamEncoderInitStatus init_ogg();        
cannam@86: 00174 
cannam@86: 00175             virtual bool finish(); 
cannam@86: 00176 
cannam@86: 00177             virtual bool process(const FLAC__int32 * const buffer[], unsigned samples);     
cannam@86: 00178             virtual bool process_interleaved(const FLAC__int32 buffer[], unsigned samples); 
cannam@86: 00179         protected:
cannam@86: 00181             virtual ::FLAC__StreamEncoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes);
cannam@86: 00182 
cannam@86: 00184             virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame) = 0;
cannam@86: 00185 
cannam@86: 00187             virtual ::FLAC__StreamEncoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset);
cannam@86: 00188 
cannam@86: 00190             virtual ::FLAC__StreamEncoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset);
cannam@86: 00191 
cannam@86: 00193             virtual void metadata_callback(const ::FLAC__StreamMetadata *metadata);
cannam@86: 00194 
cannam@86: 00195 #if (defined _MSC_VER) || (defined __BORLANDC__) || (defined __GNUG__ && (__GNUG__ < 2 || (__GNUG__ == 2 && __GNUC_MINOR__ < 96))) || (defined __SUNPRO_CC)
cannam@86: 00196             // lame hack: some MSVC/GCC versions can't see a protected encoder_ from nested State::resolved_as_cstring()
cannam@86: 00197             friend State;
cannam@86: 00198 #endif
cannam@86: 00199             ::FLAC__StreamEncoder *encoder_;
cannam@86: 00200 
cannam@86: 00201             static ::FLAC__StreamEncoderReadStatus read_callback_(const ::FLAC__StreamEncoder *encoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
cannam@86: 00202             static ::FLAC__StreamEncoderWriteStatus write_callback_(const ::FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, void *client_data);
cannam@86: 00203             static ::FLAC__StreamEncoderSeekStatus seek_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 absolute_byte_offset, void *client_data);
cannam@86: 00204             static ::FLAC__StreamEncoderTellStatus tell_callback_(const FLAC__StreamEncoder *encoder, FLAC__uint64 *absolute_byte_offset, void *client_data);
cannam@86: 00205             static void metadata_callback_(const ::FLAC__StreamEncoder *encoder, const ::FLAC__StreamMetadata *metadata, void *client_data);
cannam@86: 00206         private:
cannam@86: 00207             // Private and undefined so you can't use them:
cannam@86: 00208             Stream(const Stream &);
cannam@86: 00209             void operator=(const Stream &);
cannam@86: 00210         };
cannam@86: 00211 
cannam@86: 00232         class FLACPP_API File: public Stream {
cannam@86: 00233         public:
cannam@86: 00234             File();
cannam@86: 00235             virtual ~File();
cannam@86: 00236 
cannam@86: 00237             virtual ::FLAC__StreamEncoderInitStatus init(FILE *file);                      
cannam@86: 00238             virtual ::FLAC__StreamEncoderInitStatus init(const char *filename);            
cannam@86: 00239             virtual ::FLAC__StreamEncoderInitStatus init(const std::string &filename);     
cannam@86: 00240             virtual ::FLAC__StreamEncoderInitStatus init_ogg(FILE *file);                  
cannam@86: 00241             virtual ::FLAC__StreamEncoderInitStatus init_ogg(const char *filename);        
cannam@86: 00242             virtual ::FLAC__StreamEncoderInitStatus init_ogg(const std::string &filename); 
cannam@86: 00243         protected:
cannam@86: 00245             virtual void progress_callback(FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate);
cannam@86: 00246 
cannam@86: 00248             virtual ::FLAC__StreamEncoderWriteStatus write_callback(const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame);
cannam@86: 00249         private:
cannam@86: 00250             static void progress_callback_(const ::FLAC__StreamEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data);
cannam@86: 00251 
cannam@86: 00252             // Private and undefined so you can't use them:
cannam@86: 00253             File(const Stream &);
cannam@86: 00254             void operator=(const Stream &);
cannam@86: 00255         };
cannam@86: 00256 
cannam@86: 00257     }
cannam@86: 00258 }
cannam@86: 00259 
cannam@86: 00260 #endif
cannam@86: 
cannam@86:
cannam@86: cannam@86: cannam@86: cannam@86: cannam@86: cannam@86: cannam@86: cannam@86: cannam@86: