]> git.sesse.net Git - bmusb/commitdiff
Make drivers capable of delivering a list of modes, and setting them.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 3 Mar 2016 23:21:55 +0000 (00:21 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 3 Mar 2016 23:21:55 +0000 (00:21 +0100)
bmusb.cpp
bmusb.h

index 3e31c01a771a1cbdd62471ee1f86fbd81b32338c..1eeedce846e57530939731d2f5ca4ca41b6620a8 100644 (file)
--- a/bmusb.cpp
+++ b/bmusb.cpp
@@ -1230,3 +1230,18 @@ bool decode_video_format(uint16_t video_format, VideoFormat *decoded_video_forma
        decoded_video_format->frame_rate_den = 1;
        return false;
 }
+
+vector<VideoMode> BMUSBCapture::get_available_video_modes() const
+{
+       // The USB3 cards autodetect, and seem to have no provision for forcing modes.
+       VideoMode auto_mode;
+       auto_mode.id = 0;
+       auto_mode.name = "Autodetect";
+       auto_mode.autodetect = true;
+       return { auto_mode };
+}
+
+void BMUSBCapture::set_video_mode(uint32_t video_mode_id)
+{
+       assert(video_mode_id == 0);  // Matches get_available_video_modes().
+}
diff --git a/bmusb.h b/bmusb.h
index 17b5bc082d7a4dc266d25d80d93dcf1e3123b242..8178ac0ba3e992fd1a6cb350143c9b9cb57ca12f 100644 (file)
--- a/bmusb.h
+++ b/bmusb.h
@@ -78,6 +78,17 @@ private:
        std::stack<std::unique_ptr<uint8_t[]>> freelist;  // All of size <frame_size>.
 };
 
+// Represents an input mode you can tune a card to.
+struct VideoMode {
+       uint32_t id = 0;
+       std::string name;
+       bool autodetect = false;  // If true, all the remaining fields are irrelevant.
+       unsigned width = 0, height = 0;
+       unsigned frame_rate_num = 0, frame_rate_den = 0;
+       bool interlaced = false;
+};
+
+// Represents the format of an actual frame coming in.
 struct VideoFormat {
        uint16_t id = 0;  // For debugging/logging only.
        unsigned width = 0, height = 0, second_field_start = 0;
@@ -102,6 +113,10 @@ class CaptureInterface {
  public:
        virtual ~CaptureInterface() {}
 
+       virtual std::vector<VideoMode> get_available_video_modes() const = 0;
+
+       virtual void set_video_mode(uint32_t video_mode_id) = 0;
+
        // Does not take ownership.
        virtual void set_video_frame_allocator(FrameAllocator *allocator) = 0;
 
@@ -137,6 +152,10 @@ class BMUSBCapture : public CaptureInterface {
 
        ~BMUSBCapture() {}
 
+       std::vector<VideoMode> get_available_video_modes() const override;
+
+       void set_video_mode(uint32_t video_mode_id) override;
+
        // Does not take ownership.
        void set_video_frame_allocator(FrameAllocator *allocator) override
        {