OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/video/capture/mac/video_capture_device_decklink_mac.h" | 5 #include "media/video/capture/mac/video_capture_device_decklink_mac.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 media::VideoCaptureDeviceDeckLinkMac* frame_receiver); | 50 media::VideoCaptureDeviceDeckLinkMac* frame_receiver); |
51 | 51 |
52 void AllocateAndStart(const media::VideoCaptureParams& params); | 52 void AllocateAndStart(const media::VideoCaptureParams& params); |
53 void StopAndDeAllocate(); | 53 void StopAndDeAllocate(); |
54 | 54 |
55 // Remove the VideoCaptureDeviceDeckLinkMac's weak reference. | 55 // Remove the VideoCaptureDeviceDeckLinkMac's weak reference. |
56 void ResetVideoCaptureDeviceReference(); | 56 void ResetVideoCaptureDeviceReference(); |
57 | 57 |
58 private: | 58 private: |
59 // IDeckLinkInputCallback interface implementation. | 59 // IDeckLinkInputCallback interface implementation. |
60 virtual HRESULT VideoInputFormatChanged( | 60 HRESULT VideoInputFormatChanged( |
61 BMDVideoInputFormatChangedEvents notification_events, | 61 BMDVideoInputFormatChangedEvents notification_events, |
62 IDeckLinkDisplayMode *new_display_mode, | 62 IDeckLinkDisplayMode* new_display_mode, |
63 BMDDetectedVideoInputFormatFlags detected_signal_flags) override; | 63 BMDDetectedVideoInputFormatFlags detected_signal_flags) override; |
64 virtual HRESULT VideoInputFrameArrived( | 64 HRESULT VideoInputFrameArrived( |
65 IDeckLinkVideoInputFrame* video_frame, | 65 IDeckLinkVideoInputFrame* video_frame, |
66 IDeckLinkAudioInputPacket* audio_packet) override; | 66 IDeckLinkAudioInputPacket* audio_packet) override; |
67 | 67 |
68 // IUnknown interface implementation. | 68 // IUnknown interface implementation. |
69 virtual HRESULT QueryInterface(REFIID iid, void** ppv) override; | 69 HRESULT QueryInterface(REFIID iid, void** ppv) override; |
70 virtual ULONG AddRef() override; | 70 ULONG AddRef() override; |
71 virtual ULONG Release() override; | 71 ULONG Release() override; |
72 | 72 |
73 // Forwarder to VideoCaptureDeviceDeckLinkMac::SendErrorString(). | 73 // Forwarder to VideoCaptureDeviceDeckLinkMac::SendErrorString(). |
74 void SendErrorString(const std::string& reason); | 74 void SendErrorString(const std::string& reason); |
75 | 75 |
76 // Forwarder to VideoCaptureDeviceDeckLinkMac::SendLogString(). | 76 // Forwarder to VideoCaptureDeviceDeckLinkMac::SendLogString(). |
77 void SendLogString(const std::string& message); | 77 void SendLogString(const std::string& message); |
78 | 78 |
79 const media::VideoCaptureDevice::Name device_name_; | 79 const media::VideoCaptureDevice::Name device_name_; |
80 | 80 |
81 // Protects concurrent setting and using of |frame_receiver_|. | 81 // Protects concurrent setting and using of |frame_receiver_|. |
82 base::Lock lock_; | 82 base::Lock lock_; |
83 // Weak reference to the captured frames client, used also for error messages | 83 // Weak reference to the captured frames client, used also for error messages |
84 // and logging. Initialized on construction and used until cleared by calling | 84 // and logging. Initialized on construction and used until cleared by calling |
85 // ResetVideoCaptureDeviceReference(). | 85 // ResetVideoCaptureDeviceReference(). |
86 media::VideoCaptureDeviceDeckLinkMac* frame_receiver_; | 86 media::VideoCaptureDeviceDeckLinkMac* frame_receiver_; |
87 | 87 |
88 // This is used to control the video capturing device input interface. | 88 // This is used to control the video capturing device input interface. |
89 ScopedDeckLinkPtr<IDeckLinkInput> decklink_input_; | 89 ScopedDeckLinkPtr<IDeckLinkInput> decklink_input_; |
90 // |decklink_| represents a physical device attached to the host. | 90 // |decklink_| represents a physical device attached to the host. |
91 ScopedDeckLinkPtr<IDeckLink> decklink_; | 91 ScopedDeckLinkPtr<IDeckLink> decklink_; |
92 | 92 |
93 // Checks for Device (a.k.a. Audio) thread. | 93 // Checks for Device (a.k.a. Audio) thread. |
94 base::ThreadChecker thread_checker_; | 94 base::ThreadChecker thread_checker_; |
95 | 95 |
96 friend class scoped_refptr<DeckLinkCaptureDelegate>; | 96 friend class scoped_refptr<DeckLinkCaptureDelegate>; |
97 friend class base::RefCountedThreadSafe<DeckLinkCaptureDelegate>; | 97 friend class base::RefCountedThreadSafe<DeckLinkCaptureDelegate>; |
98 | 98 |
99 virtual ~DeckLinkCaptureDelegate(); | 99 ~DeckLinkCaptureDelegate() override; |
100 | 100 |
101 DISALLOW_COPY_AND_ASSIGN(DeckLinkCaptureDelegate); | 101 DISALLOW_COPY_AND_ASSIGN(DeckLinkCaptureDelegate); |
102 }; | 102 }; |
103 | 103 |
104 static float GetDisplayModeFrameRate( | 104 static float GetDisplayModeFrameRate( |
105 const ScopedDeckLinkPtr<IDeckLinkDisplayMode>& display_mode) { | 105 const ScopedDeckLinkPtr<IDeckLinkDisplayMode>& display_mode) { |
106 BMDTimeValue time_value, time_scale; | 106 BMDTimeValue time_value, time_scale; |
107 float display_mode_frame_rate = 0.0f; | 107 float display_mode_frame_rate = 0.0f; |
108 if (display_mode->GetFrameRate(&time_value, &time_scale) == S_OK && | 108 if (display_mode->GetFrameRate(&time_value, &time_scale) == S_OK && |
109 time_value > 0) { | 109 time_value > 0) { |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 if (decklink_capture_delegate_.get()) | 474 if (decklink_capture_delegate_.get()) |
475 decklink_capture_delegate_->AllocateAndStart(params); | 475 decklink_capture_delegate_->AllocateAndStart(params); |
476 } | 476 } |
477 | 477 |
478 void VideoCaptureDeviceDeckLinkMac::StopAndDeAllocate() { | 478 void VideoCaptureDeviceDeckLinkMac::StopAndDeAllocate() { |
479 if (decklink_capture_delegate_.get()) | 479 if (decklink_capture_delegate_.get()) |
480 decklink_capture_delegate_->StopAndDeAllocate(); | 480 decklink_capture_delegate_->StopAndDeAllocate(); |
481 } | 481 } |
482 | 482 |
483 } // namespace media | 483 } // namespace media |
OLD | NEW |