X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=decklink_output.h;h=5581c392860f67c89576e788ee59976b919d875a;hb=0556d8cb8416bdc7b432a432c3d58239a94358d2;hp=0aba5063839502ce77815a8af7c62ba5c138f816;hpb=138c12c13443d39f8b1168b5d54b36d9835c6405;p=nageru diff --git a/decklink_output.h b/decklink_output.h index 0aba506..5581c39 100644 --- a/decklink_output.h +++ b/decklink_output.h @@ -2,8 +2,10 @@ #define _DECKLINK_OUTPUT_H 1 #include +#include #include #include +#include #include #include #include @@ -39,13 +41,28 @@ public: void start_output(uint32_t mode, int64_t base_pts); // Mode comes from get_available_video_modes(). void end_output(); - void send_frame(GLuint y_tex, GLuint cbcr_tex, const std::vector &input_frames, int64_t pts, int64_t duration); + void send_frame(GLuint y_tex, GLuint cbcr_tex, movit::YCbCrLumaCoefficients ycbcr_coefficients, const std::vector &input_frames, int64_t pts, int64_t duration); void send_audio(int64_t pts, const std::vector &samples); - void wait_for_frame(int64_t pts, int *dropped_frames, int64_t *frame_duration); + + // NOTE: The returned timestamp is undefined for preroll. + // Otherwise, it is the timestamp of the output frame as it should have been, + // even if we're overshooting. E.g. at 50 fps (0.02 spf), assuming the + // last frame was at t=0.980: + // + // If we're at t=0.999, we wait until t=1.000 and return that. + // If we're at t=1.001, we return t=1.000 immediately (small overshoot). + // If we're at t=1.055, we drop two frames and return t=1.040 immediately. + void wait_for_frame(int64_t pts, int *dropped_frames, int64_t *frame_duration, bool *is_preroll, std::chrono::steady_clock::time_point *frame_timestamp); // Analogous to CaptureInterface. Will only return modes that have the right width/height. std::map get_available_video_modes() const { return video_modes; } + // If the given mode is supported, return it. If not, pick some “best” valid mode. + uint32_t pick_video_mode(uint32_t mode) const; + + // Desired Y'CbCr coefficients for the current mode. Undefined before start_output(). + movit::YCbCrLumaCoefficients preferred_ycbcr_coefficients() const; + // IUnknown. HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv) override; ULONG STDMETHODCALLTYPE AddRef() override; @@ -117,11 +134,14 @@ private: std::queue> frame_freelist; // Under . int num_frames_in_flight = 0; // Number of frames allocated but not on the freelist. Under . std::condition_variable frame_queues_changed; - bool playback_started = false; + bool playback_initiated = false, playback_started = false; int64_t base_pts, frame_duration; + BMDDisplayModeFlags current_mode_flags = 0; + bool last_frame_had_mode_mismatch = false; movit::ResourcePool *resource_pool; IDeckLinkOutput *output = nullptr; + BMDVideoConnection video_connection; QSurface *surface; unsigned width, height; unsigned card_index;