diff options
-rw-r--r-- | decoder.cpp | 4 | ||||
-rw-r--r-- | decoder.h | 4 | ||||
-rw-r--r-- | encoder.cpp | 4 | ||||
-rw-r--r-- | encoder.h | 4 |
4 files changed, 12 insertions, 4 deletions
diff --git a/decoder.cpp b/decoder.cpp index f01215b..c362745 100644 --- a/decoder.cpp +++ b/decoder.cpp @@ -10,7 +10,7 @@ DecoderFilter::DecoderFilter(DecoderBase::p decoder_) { decoder = decoder_; } -typedef boost::function<boost::shared_ptr<DecoderBase>()> DecoderFactory; +typedef boost::function<DecoderBase::p ()> DecoderFactory; std::map<std::string, DecoderFactory> decoder_factories; void decoder::init() { @@ -20,5 +20,5 @@ void decoder::init() { //! Construct a filter with the given decoder. DecoderFilter::p decoder::get_decoder(const std::string& name) { - return DecoderFilter::p(new DecoderFilter(DecoderBase::p(decoder_factories[name]()))); + return DecoderFilter::p(new DecoderFilter(decoder_factories[name]())); } @@ -11,15 +11,19 @@ class DecoderBase { public: typedef boost::shared_ptr<DecoderBase> p; virtual size_t decode(const uint8_t *input, size_t input_size, uint8_t *output, size_t output_size) = 0; + virtual ~DecoderBase() {} + }; //! Input filter to hold a decoder in a filter chain. class DecoderFilter : public boost::iostreams::multichar_input_filter { private: DecoderBase::p decoder; + public: typedef boost::shared_ptr<DecoderFilter> p; DecoderFilter(DecoderBase::p decoder_); + template<typename Source> std::streamsize read(Source& src, char *s, std::streamsize n) { char src_data[0x2000]; diff --git a/encoder.cpp b/encoder.cpp index cd37daa..0f2a5fe 100644 --- a/encoder.cpp +++ b/encoder.cpp @@ -10,7 +10,7 @@ EncoderFilter::EncoderFilter(EncoderBase::p encoder_) { encoder = encoder_; } -typedef boost::function<boost::shared_ptr<EncoderBase>()> EncoderFactory; +typedef boost::function<EncoderBase::p ()> EncoderFactory; std::map<std::string, EncoderFactory> encoder_factories; void encoder::init() { @@ -19,5 +19,5 @@ void encoder::init() { //! Construct a filter with the given encoder. EncoderFilter::p encoder::get_encoder(const std::string& name) { - return EncoderFilter::p(new EncoderFilter(EncoderBase::p(encoder_factories[name]()))); + return EncoderFilter::p(new EncoderFilter(encoder_factories[name]())); } @@ -11,6 +11,8 @@ class EncoderBase { public: typedef boost::shared_ptr<EncoderBase> p; + virtual ~EncoderBase() {} + virtual size_t encode(const uint8_t *input, size_t input_size, uint8_t *output, size_t output_size) = 0; virtual size_t flush(uint8_t *output, size_t output_size) = 0; }; @@ -19,9 +21,11 @@ class EncoderBase { class EncoderFilter : public boost::iostreams::multichar_input_filter { private: EncoderBase::p encoder; + public: typedef boost::shared_ptr<EncoderFilter> p; EncoderFilter(EncoderBase::p encoder_); + template<typename Source> std::streamsize read(Source& src, char *s, std::streamsize n) { char src_data[0x2000]; |