]> git.sesse.net Git - bmusb/blobdiff - bmusb.h
Send the video format in directly to the video frame callback, so that we do not...
[bmusb] / bmusb.h
diff --git a/bmusb.h b/bmusb.h
index d47ce8e85c4541be65dcd89c7b10ed727781b153..04d867b009e49cabc4fdcd6cf63a3f3b46b88b1e 100644 (file)
--- a/bmusb.h
+++ b/bmusb.h
@@ -7,6 +7,7 @@
 #include <deque>
 #include <functional>
 #include <mutex>
+#include <string>
 #include <thread>
 #include <vector>
 
@@ -56,8 +57,16 @@ class FrameAllocator {
        virtual void release_frame(Frame frame) = 0;
 };
 
+struct VideoFormat {
+       uint16_t id = 0;  // For debugging/logging only.
+       unsigned width = 0, height = 0, second_field_start = 0;
+       unsigned extra_lines_top = 0, extra_lines_bottom = 0;
+       unsigned frame_rate_nom = 0, frame_rate_den = 0;
+       bool interlaced = false;
+};
+
 typedef std::function<void(uint16_t timecode,
-                           FrameAllocator::Frame video_frame, size_t video_offset, uint16_t video_format,
+                           FrameAllocator::Frame video_frame, size_t video_offset, VideoFormat video_format,
                            FrameAllocator::Frame audio_frame, size_t audio_offset, uint16_t audio_format)>
        frame_callback_t;
 
@@ -104,6 +113,11 @@ class BMUSBCapture {
                has_dequeue_callbacks = true;
        }
 
+       // Only valid after configure_card().
+       std::string get_description() const {
+               return description;
+       }
+
        void configure_card();
        void start_bm_capture();
        void stop_dequeue_thread();
@@ -127,6 +141,8 @@ class BMUSBCapture {
        static void usb_thread_func();
        static void cb_xfr(struct libusb_transfer *xfr);
 
+       std::string description;
+
        FrameAllocator::Frame current_video_frame;
        FrameAllocator::Frame current_audio_frame;
 
@@ -160,8 +176,6 @@ class BMUSBCapture {
 // "second_field_start" is only valid for interlaced modes; it signifies
 // how many lines from the very top of the frame there are before the second field
 // starts (so it will always be >= height/2 + extra_lines_top).
-bool decode_video_format(uint16_t video_format, unsigned *width, unsigned *height, unsigned *second_field_start,
-                         unsigned *extra_lines_top, unsigned *extra_lines_bottom,
-                         unsigned *frame_rate_nom, unsigned *frame_rate_den, bool *interlaced);
+bool decode_video_format(uint16_t video_format, VideoFormat *decoded_video_format);
 
 #endif