1 #ifndef _output_drv__hpp__included__
2 #define _output_drv__hpp__included__
8 #include "digital-filter.hpp"
13 audio_settings(uint32_t _rate
);
14 uint32_t get_rate() const;
19 class audio_dyncall_base
22 virtual ~audio_dyncall_base();
23 virtual void operator()(short left
, short right
) = 0;
26 class audio_end_dyncall_base
29 virtual ~audio_end_dyncall_base();
30 virtual void operator()() = 0;
34 class audio_dyncall
: public audio_dyncall_base
37 audio_dyncall(T
& _object
, void (T::*_ptr
)(short left
, short right
))
47 void operator()(short left
, short right
)
49 (object
.*ptr
)(left
, right
);
53 void (T::*ptr
)(short left
, short right
);
57 class audio_end_dyncall
: public audio_end_dyncall_base
60 audio_end_dyncall(T
& _object
, void (T::*_ptr
)())
82 video_settings(uint32_t _width
, uint32_t _height
, uint32_t _rate_num
, uint32_t _rate_denum
);
83 uint32_t get_width() const;
84 uint32_t get_height() const;
85 uint32_t get_rate_num() const;
86 uint32_t get_rate_denum() const; //WARNING: Zero if framerate is variable!
94 class video_dyncall_base
97 virtual ~video_dyncall_base();
98 virtual void operator()(uint64_t timestamp
, const uint8_t* raw_rgbx_data
) = 0;
102 class video_dyncall
: public video_dyncall_base
105 video_dyncall(T
& _object
, void (T::*_ptr
)(uint64_t timestamp
, const uint8_t* raw_rgbx_data
))
115 void operator()(uint64_t timestamp
, const uint8_t* raw_rgbx_data
)
117 (object
.*ptr
)(timestamp
, raw_rgbx_data
);
121 void (T::*ptr
)(uint64_t timestamp
, const uint8_t* raw_rgbx_data
);
124 class subtitle_settings
131 class subtitle_dyncall_base
134 virtual ~subtitle_dyncall_base();
135 virtual void operator()(uint64_t basetime
, uint64_t duration
, const uint8_t* text
) = 0;
139 class subtitle_dyncall
: public subtitle_dyncall_base
142 subtitle_dyncall(T
& _object
, void (T::*_ptr
)(uint64_t basetime
, uint64_t duration
, const uint8_t* text
))
152 void operator()(uint64_t basetime
, uint64_t duration
, const uint8_t* text
)
154 (object
.*ptr
)(basetime
, duration
, text
);
158 void (T::*ptr
)(uint64_t basetime
, uint64_t duration
, const uint8_t* text
);
166 virtual ~output_driver();
167 virtual void ready() = 0;
168 void set_audio_settings(audio_settings a
);
169 void set_video_settings(video_settings v
);
170 void set_subtitle_settings(subtitle_settings s
);
171 const audio_settings
& get_audio_settings();
172 const video_settings
& get_video_settings();
173 const subtitle_settings
& get_subtitle_settings();
174 template<class T
> void set_audio_callback(T
& object
, void (T::*ptr
)(short left
, short right
))
176 audio_dyncall_base
* old
= audio_handler
;
177 audio_handler
= new audio_dyncall
<T
>(object
, ptr
);
181 template<class T
> void set_audio_end_callback(T
& object
, void (T::*ptr
)())
183 audio_end_dyncall_base
* old
= audio_end_handler
;
184 audio_end_handler
= new audio_end_dyncall
<T
>(object
, ptr
);
188 template<class T
> void set_video_callback(T
& object
, void (T::*ptr
)(uint64_t timestamp
, const uint8_t* raw_rgbx_data
))
190 video_dyncall_base
* old
= video_handler
;
191 video_handler
= new video_dyncall
<T
>(object
, ptr
);
195 template<class T
> void set_subtitle_callback(T
& object
, void (T::*ptr
)(uint64_t basetime
, uint64_t duration
,
196 const uint8_t* text
))
198 audio_dyncall_base
* old
= audio_handler
;
199 audio_handler
= new audio_dyncall
<T
>(object
, ptr
);
203 void do_audio_callback(short left
, short right
);
204 void do_audio_end_callback();
205 void do_video_callback(uint64_t timestamp
, const uint8_t* raw_rgbx_data
);
206 void do_subtitle_callback(uint64_t basetime
, uint64_t duration
, const uint8_t* text
);
208 output_driver(const output_driver
&);
209 output_driver
& operator=(const output_driver
&);
210 audio_dyncall_base
* audio_handler
;
211 audio_end_dyncall_base
* audio_end_handler
;
212 video_dyncall_base
* video_handler
;
213 subtitle_dyncall_base
* subtitle_handler
;
214 audio_settings asettings
;
215 video_settings vsettings
;
216 subtitle_settings ssettings
;
219 void distribute_audio_callback(short left
, short right
);
220 void distribute_audio_callback(npair
<short> sample
);
221 void distribute_video_callback(uint64_t timestamp
, const uint8_t* raw_rgbx_data
);
222 void distribute_subtitle_callback(uint64_t basetime
, uint64_t duration
, const uint8_t* text
);
223 void distribute_subtitle_callback(struct packet
& p
);
224 void set_audio_parameters(audio_settings a
);
225 void set_video_parameters(video_settings v
);
226 void set_subtitle_parameters(subtitle_settings s
);
227 void add_output_driver(const std::string
& type
, const std::string
& name
, const std::string
& parameters
);
228 void close_output_drivers();
230 std::string
get_output_driver_list();
232 class output_driver_factory
235 output_driver_factory(const std::string
& type
);
236 virtual ~output_driver_factory();
237 static output_driver
& make_by_type(const std::string
& type
, const std::string
& name
,
238 const std::string
& parameters
);
239 virtual output_driver
& make(const std::string
& type
, const std::string
& name
,
240 const std::string
& parameters
) = 0;
242 static std::map
<std::string
, output_driver_factory
*>* factories
;
243 friend std::string
get_output_driver_list();