1 Header files to include:
2 ========================
3 #include "outputs/internal.hpp"
7 This is the superclass of all output drivers. Subclass this class for output driver.
9 Constructor: output_driver():
10 -----------------------------
11 Create your own constructor. Don't call get_*_settings() functions in the constructor as those values are not set
12 yet, and as result, the return value would be garbage.
14 Destructor: ~output_driver():
15 -----------------------------
16 Do your cleanups here.
18 Pure virtual method: void ready():
19 ----------------------------------
20 This method is called after settings are set, so get_*_settings() returns sane values, but before any callbacks
23 Method: const audio_settings& get_audio_settings():
24 ---------------------------------------------------
25 Get the audio settings. The following methods are valid on the returned object:
27 - uint32_t get_rate() const: Returns the rate of audio output in samples per second.
29 Method: const video_settings& get_video_settings():
30 ---------------------------------------------------
31 Get the video settings. The following methods are valid on the returned object:
33 - uint32_t get_width() const: Returns the width of the output in pixels.
34 - uint32_t get_height() const: Returns the height of the output in pixels.
35 - uint32_t get_rate_num() const: Returns numerator of the frame rate if in CFR mode, 0 if in VFR mode.
36 - uint32_t get_rate_denum() const: Returns denumerator of the frame rate if in CFR mode, 0 if in VFR mode.
38 WARNING: get_rate_denum() can return zero (VFR mode)!
40 Method: void set_audio_callback(bound_method<void, short, short> fn):
41 ---------------------------------------------------------------------
42 Set the callback that occurs on each audio sample. The callback prototype is:
44 void fn_or_method(short left, short right);
46 Where left is left channel sample (16 bit signed) and right is right channel sample (again, 16 bit signed).
48 Method: void set_audio_end_callback(bound_method<void> fn):
49 -----------------------------------------------------------
50 Set the callback that occurs after all other callbacks have been sent. The callback prototype is:
54 Method: void set_video_callback(bound_method<void, uint64_t, const uint8_t*> fn):
55 ---------------------------------------------------------------------------------
56 Set the callback that occurs on each video frame. The callback prototype is:
58 void fn_or_method(uint64_t ts, uint8_t* data);
60 ts is timestamp of the frame in nanoseconds after stream began. data is sequence of 4-byte pixel values, in
61 left to right, top to down order. First of pixel bytes is red component, the second is green component and the
62 third is the blue component. The fourth byte is unused.
65 Method: void set_subtitle_callback(bound_method<void, uint64_t, uint64_t, const uint8_t*> fn):
66 ----------------------------------------------------------------------------------------------
67 Set the callback that occurs on each softsub. The callback prototype is:
69 void fn_or_method(uint64_t ts, uint64_t duration, uint8_t* text);
71 ts is the timestamp subtitle begins (in nanoseconds). duration is the duration in nanoseconds. Text is the text
72 of the subtitle (in UTF-8, terminated by ASCII NUL).
75 Method: void set_gmidi_callback(bound_method<void, uint64_t, uint8_t> fn):
76 --------------------------------------------------------------------------
77 Set the callback that occurs on each sent GMIDI byte. The callback prototype is:
79 void fn_or_method(uint64_t ts, uint8_t byte);
81 Ts is the timestamp byte is sent at, and byte is the byte itself.
85 class output_driver_factory:
86 ============================
87 Each output driver type has instance of some subclass of this. Subclass this in each output driver (one or more
88 times) and then create instances of it in private namespace for each output driver type.
90 constructor: output_driver_factory(const std::string& type):
91 ------------------------------------------------------------
92 Associate this object with output driver type with given name.
94 destructor: ~output_driver_factory():
95 -------------------------------------
98 pure virtual method: output_driver& make(const std::string& type, const std::string& name,
99 const std::string& parameters):
100 ------------------------------------------------------------------------------------------
101 Called to instantiate output driver of type described by object. Type is the type of driver to instantitate,
102 name is name of output file, and parameters is parameters passed to output driver if any.
106 template bound_method<rettype, args...>:
107 ========================================
108 This is pointer to either some method of some object or to some function.
110 These things can be copied and assigned.
113 bound_method<ret, args...> make_bound_method(T& _object, ret (T::*_fun)(args... arg)):
114 --------------------------------------------------------------------------------------
115 Make bound method out of object and member pointer.
117 bound_method<ret, args...> make_bound_method(ret (*_fun)(args... arg)):
118 -----------------------------------------------------------------------
119 Make bound method out of function.
121 bound_method<ret, args...> bind_last(bound_method<ret, args..., tail> fn, tail t):
122 ----------------------------------------------------------------------------------
123 Fix last argument of bound method and return a new bound method.