2 #include "outputs/internal.hpp"
3 #include "outputs/argexpand.hpp"
14 class output_driver_cscd
: public output_driver
17 output_driver_cscd(const std::string
& _filename
, unsigned _level
, unsigned long _maxsegframes
)
21 maxsegframes
= _maxsegframes
;
22 set_video_callback(make_bound_method(*this, &output_driver_cscd::video_callback
));
23 set_audio_callback(make_bound_method(*this, &output_driver_cscd::audio_callback
));
34 const video_settings
& v
= get_video_settings();
35 const audio_settings
& a
= get_audio_settings();
36 avi_cscd_dumper::global_parameters gp
;
37 avi_cscd_dumper::segment_parameters sp
;
38 gp
.sampling_rate
= a
.get_rate();
40 gp
.audio_16bit
= true;
41 sp
.fps_n
= v
.get_rate_num();
42 sp
.fps_d
= v
.get_rate_denum();
43 if(!sp
.fps_n
|| !sp
.fps_d
) {
47 sp
.dataformat
= avi_cscd_dumper::PIXFMT_RGBX
;
48 sp
.width
= v
.get_width();
49 sp
.height
= v
.get_height();
50 sp
.default_stride
= true;
51 sp
.stride
= 4 * v
.get_width();
52 sp
.keyframe_distance
= (level
> 9) ? 300 : 1;
53 sp
.deflate_level
= (level
> 9) ? (1+ level
% 10) : level
;
54 sp
.max_segment_frames
= maxsegframes
;
55 dumper
= new avi_cscd_dumper(filename
, gp
, sp
);
58 void video_callback(uint64_t timestamp
, const uint8_t* raw_rgbx_data
)
60 dumper
->video(raw_rgbx_data
);
61 dumper
->wait_frame_processing();
64 void audio_callback(short left
, short right
)
66 dumper
->audio(&left
, &right
, 1, avi_cscd_dumper::SNDFMT_SIGNED_16NE
);
72 avi_cscd_dumper
* dumper
;
73 unsigned long maxsegframes
;
76 class output_driver_cscd_factory
: output_driver_factory
79 output_driver_cscd_factory()
80 : output_driver_factory("cscd")
84 output_driver
& make(const std::string
& type
, const std::string
& name
, const std::string
& parameters
)
87 unsigned long maxsegframes
= 0;
88 std::string p
= parameters
;
90 size_t s
= p
.find_first_of(",");
101 if(x
.substr(0, 6) == "level=") {
102 std::string y
= x
.substr(6);
104 level
= strtoul(y
.c_str(), &e
, 10);
106 throw std::runtime_error("Bad compression level");
108 if(x
.substr(0, 13) == "maxsegframes=") {
109 std::string y
= x
.substr(13);
111 maxsegframes
= strtoul(y
.c_str(), &e
, 10);
113 throw std::runtime_error("Bad maxsegframes");
116 return *new output_driver_cscd(name
, level
, maxsegframes
);