From 08a992d58c34da8d8bbd70226f7e85c9f30d9514 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 25 Jul 2016 13:58:01 +0200 Subject: [PATCH] Upgrade to newer bmusb, with namespacing. --- bmusb | 2 +- decklink_capture.cpp | 1 + decklink_capture.h | 26 +++++++++++++------------- fake_capture.cpp | 3 +++ fake_capture.h | 4 ++++ glwidget.cpp | 2 +- mixer.cpp | 1 + mixer.h | 10 +++++----- pbo_frame_allocator.cpp | 2 +- pbo_frame_allocator.h | 2 +- ref_counted_frame.cpp | 2 +- ref_counted_frame.h | 8 ++++---- 12 files changed, 36 insertions(+), 27 deletions(-) diff --git a/bmusb b/bmusb index ec5eaa5..c66728f 160000 --- a/bmusb +++ b/bmusb @@ -1 +1 @@ -Subproject commit ec5eaa5e319e91f89db15dcbccdf64a056f710ae +Subproject commit c66728fa32fc79abd5c4fb9188750cccf9039dee diff --git a/decklink_capture.cpp b/decklink_capture.cpp index e57b5d4..81566cb 100644 --- a/decklink_capture.cpp +++ b/decklink_capture.cpp @@ -20,6 +20,7 @@ using namespace std; using namespace std::placeholders; +using namespace bmusb; namespace { diff --git a/decklink_capture.h b/decklink_capture.h index bfb6d0e..0a9c37b 100644 --- a/decklink_capture.h +++ b/decklink_capture.h @@ -14,7 +14,7 @@ class IDeckLinkDisplayMode; // TODO: Adjust CaptureInterface to be a little less bmusb-centric. // There are too many member functions here that don't really do anything. -class DeckLinkCapture : public CaptureInterface, IDeckLinkInputCallback +class DeckLinkCapture : public bmusb::CaptureInterface, IDeckLinkInputCallback { public: DeckLinkCapture(IDeckLink *card, int card_index); // Takes ownership of . @@ -33,7 +33,7 @@ public: IDeckLinkAudioInputPacket *audio_frame) override; // CaptureInterface. - void set_video_frame_allocator(FrameAllocator *allocator) override + void set_video_frame_allocator(bmusb::FrameAllocator *allocator) override { video_frame_allocator = allocator; if (owned_video_frame_allocator.get() != allocator) { @@ -41,13 +41,13 @@ public: } } - FrameAllocator *get_video_frame_allocator() override + bmusb::FrameAllocator *get_video_frame_allocator() override { return video_frame_allocator; } // Does not take ownership. - void set_audio_frame_allocator(FrameAllocator *allocator) override + void set_audio_frame_allocator(bmusb::FrameAllocator *allocator) override { audio_frame_allocator = allocator; if (owned_audio_frame_allocator.get() != allocator) { @@ -55,12 +55,12 @@ public: } } - FrameAllocator *get_audio_frame_allocator() override + bmusb::FrameAllocator *get_audio_frame_allocator() override { return audio_frame_allocator; } - void set_frame_callback(frame_callback_t callback) override + void set_frame_callback(bmusb::frame_callback_t callback) override { frame_callback = callback; } @@ -84,7 +84,7 @@ public: // TODO: Can the API communicate this to us somehow, for e.g. Thunderbolt cards? bool get_disconnected() const override { return false; } - std::map get_available_video_modes() const override { return video_modes; } + std::map get_available_video_modes() const override { return video_modes; } void set_video_mode(uint32_t video_mode_id) override; uint32_t get_current_video_mode() const override { return current_video_mode; } @@ -109,11 +109,11 @@ private: std::function dequeue_init_callback = nullptr; std::function dequeue_cleanup_callback = nullptr; - FrameAllocator *video_frame_allocator = nullptr; - FrameAllocator *audio_frame_allocator = nullptr; - std::unique_ptr owned_video_frame_allocator; - std::unique_ptr owned_audio_frame_allocator; - frame_callback_t frame_callback = nullptr; + bmusb::FrameAllocator *video_frame_allocator = nullptr; + bmusb::FrameAllocator *audio_frame_allocator = nullptr; + std::unique_ptr owned_video_frame_allocator; + std::unique_ptr owned_audio_frame_allocator; + bmusb::frame_callback_t frame_callback = nullptr; IDeckLinkConfiguration *config = nullptr; @@ -122,7 +122,7 @@ private: BMDTimeValue frame_duration; BMDTimeScale time_scale; - std::map video_modes; + std::map video_modes; BMDDisplayMode current_video_mode; std::map video_inputs; diff --git a/fake_capture.cpp b/fake_capture.cpp index b767d8f..7d23d8c 100644 --- a/fake_capture.cpp +++ b/fake_capture.cpp @@ -29,6 +29,7 @@ constexpr uint8_t crs[NUM_COLORS] = { 240, 34, 110, 128 }; using namespace std; +namespace bmusb { namespace { void memset2(uint8_t *s, const uint8_t c[2], size_t n) @@ -263,3 +264,5 @@ void FakeCapture::producer_thread_func() dequeue_cleanup_callback(); } } + +} // namespace bmusb diff --git a/fake_capture.h b/fake_capture.h index c517257..84a8953 100644 --- a/fake_capture.h +++ b/fake_capture.h @@ -7,6 +7,8 @@ #include "bmusb/bmusb.h" +namespace bmusb { + class FakeCapture : public CaptureInterface { public: @@ -96,4 +98,6 @@ private: std::thread producer_thread; }; +} // namespace bmusb + #endif // !defined(_FAKE_CAPTURE_H) diff --git a/glwidget.cpp b/glwidget.cpp index 82d702f..6409a13 100644 --- a/glwidget.cpp +++ b/glwidget.cpp @@ -190,7 +190,7 @@ void GLWidget::show_context_menu(unsigned signal_num, const QPoint &pos) // The same for resolution. QMenu mode_submenu; QActionGroup mode_group(&mode_submenu); - std::map video_modes = global_mixer->get_available_video_modes(current_card); + std::map video_modes = global_mixer->get_available_video_modes(current_card); uint32_t current_video_mode = global_mixer->get_current_video_mode(current_card); bool has_auto_mode = false; for (const auto &mode : video_modes) { diff --git a/mixer.cpp b/mixer.cpp index e24d0bb..6bc8780 100644 --- a/mixer.cpp +++ b/mixer.cpp @@ -46,6 +46,7 @@ class QOpenGLContext; using namespace movit; using namespace std; using namespace std::placeholders; +using namespace bmusb; Mixer *global_mixer = nullptr; bool uses_mlock = false; diff --git a/mixer.h b/mixer.h index a092689..05471d6 100644 --- a/mixer.h +++ b/mixer.h @@ -352,7 +352,7 @@ public: return cards[card_index].capture->get_description(); } - std::map get_available_video_modes(unsigned card_index) const { + std::map get_available_video_modes(unsigned card_index) const { assert(card_index < num_cards); return cards[card_index].capture->get_available_video_modes(); } @@ -404,10 +404,10 @@ public: } private: - void configure_card(unsigned card_index, CaptureInterface *capture, bool is_fake_capture); + void configure_card(unsigned card_index, bmusb::CaptureInterface *capture, bool is_fake_capture); void bm_frame(unsigned card_index, uint16_t timecode, - FrameAllocator::Frame video_frame, size_t video_offset, VideoFormat video_format, - FrameAllocator::Frame audio_frame, size_t audio_offset, AudioFormat audio_format); + bmusb::FrameAllocator::Frame video_frame, size_t video_offset, bmusb::VideoFormat video_format, + bmusb::FrameAllocator::Frame audio_frame, size_t audio_offset, bmusb::AudioFormat audio_format); void bm_hotplug_add(libusb_device *dev); void bm_hotplug_remove(unsigned card_index); void place_rectangle(movit::Effect *resample_effect, movit::Effect *padding_effect, float x0, float y0, float x1, float y1); @@ -444,7 +444,7 @@ private: std::mutex bmusb_mutex; bool has_bmusb_thread = false; struct CaptureCard { - CaptureInterface *capture = nullptr; + bmusb::CaptureInterface *capture = nullptr; bool is_fake_capture; std::unique_ptr frame_allocator; diff --git a/pbo_frame_allocator.cpp b/pbo_frame_allocator.cpp index 74f54fd..34b2c7b 100644 --- a/pbo_frame_allocator.cpp +++ b/pbo_frame_allocator.cpp @@ -104,7 +104,7 @@ PBOFrameAllocator::~PBOFrameAllocator() } //static int sumsum = 0; -FrameAllocator::Frame PBOFrameAllocator::alloc_frame() +bmusb::FrameAllocator::Frame PBOFrameAllocator::alloc_frame() { Frame vf; diff --git a/pbo_frame_allocator.h b/pbo_frame_allocator.h index 891806a..9220491 100644 --- a/pbo_frame_allocator.h +++ b/pbo_frame_allocator.h @@ -12,7 +12,7 @@ // An allocator that allocates straight into OpenGL pinned memory. // Meant for video frames only. We use a queue rather than a stack, // since we want to maximize pipelineability. -class PBOFrameAllocator : public FrameAllocator { +class PBOFrameAllocator : public bmusb::FrameAllocator { public: // Note: You need to have an OpenGL context when calling // the constructor. diff --git a/ref_counted_frame.cpp b/ref_counted_frame.cpp index 0478581..3a30eac 100644 --- a/ref_counted_frame.cpp +++ b/ref_counted_frame.cpp @@ -1,6 +1,6 @@ #include "ref_counted_frame.h" -void release_refcounted_frame(FrameAllocator::Frame *frame) +void release_refcounted_frame(bmusb::FrameAllocator::Frame *frame) { if (frame->owner) { frame->owner->release_frame(*frame); diff --git a/ref_counted_frame.h b/ref_counted_frame.h index 67787ef..881d0d5 100644 --- a/ref_counted_frame.h +++ b/ref_counted_frame.h @@ -11,16 +11,16 @@ #include "bmusb/bmusb.h" -void release_refcounted_frame(FrameAllocator::Frame *frame); +void release_refcounted_frame(bmusb::FrameAllocator::Frame *frame); -typedef std::shared_ptr RefCountedFrameBase; +typedef std::shared_ptr RefCountedFrameBase; class RefCountedFrame : public RefCountedFrameBase { public: RefCountedFrame() {} - RefCountedFrame(const FrameAllocator::Frame &frame) - : RefCountedFrameBase(new FrameAllocator::Frame(frame), release_refcounted_frame) {} + RefCountedFrame(const bmusb::FrameAllocator::Frame &frame) + : RefCountedFrameBase(new bmusb::FrameAllocator::Frame(frame), release_refcounted_frame) {} }; #endif // !defined(_REF_COUNTED_FRAME_H) -- 2.39.2