Index: media/video/capture/mac/video_capture_device_decklink_mac.h |
diff --git a/media/video/capture/mac/video_capture_device_decklink_mac.h b/media/video/capture/mac/video_capture_device_decklink_mac.h |
index 17f6b2775d7bda2c2a83ee4383bd073705b8b08f..d77227ddb7eaa97e1904fa7b8596a296e2647f8e 100644 |
--- a/media/video/capture/mac/video_capture_device_decklink_mac.h |
+++ b/media/video/capture/mac/video_capture_device_decklink_mac.h |
@@ -12,11 +12,45 @@ |
#import <Foundation/Foundation.h> |
+#include "third_party/decklink/mac/include/DeckLinkAPI.h" |
+ |
+namespace { |
+ |
+// DeckLink SDK uses ScopedComPtr-style APIs. Chrome ScopedComPtr is only |
+// available for Windows builds. This is a verbatim knock-off of the needed |
+// parts of base::win::ScopedComPtr<> for ref counting. |
+template <class T> |
+class ScopedDeckLinkPtr : public scoped_refptr<T> { |
+ public: |
+ using scoped_refptr<T>::ptr_; |
+ |
+ T** Receive() { |
+ DCHECK(!ptr_) << "Object leak. Pointer must be NULL"; |
+ return &ptr_; |
+ } |
+ |
+ void** ReceiveVoid() { |
+ return reinterpret_cast<void**>(Receive()); |
+ } |
+ |
+ void Release() { |
+ if (ptr_ != NULL) { |
+ ptr_->Release(); |
+ ptr_ = NULL; |
+ } |
+ } |
+}; |
+ |
+} // namespace |
+ |
+ |
namespace media { |
// Extension of VideoCaptureDevice to create and manipulate Blackmagic devices |
// via DeckLink SDK. |
-class MEDIA_EXPORT VideoCaptureDeviceDeckLinkMac : public VideoCaptureDevice { |
+class MEDIA_EXPORT VideoCaptureDeviceDeckLinkMac : |
+ public VideoCaptureDevice, |
+ public IDeckLinkInputCallback { |
public: |
// Gets the names of all DeckLink video capture devices connected to this |
// computer, as enumerated by the DeckLink SDK. |
@@ -36,7 +70,38 @@ class MEDIA_EXPORT VideoCaptureDeviceDeckLinkMac : public VideoCaptureDevice { |
scoped_ptr<VideoCaptureDevice::Client> client) OVERRIDE; |
virtual void StopAndDeAllocate() OVERRIDE; |
+ // IDeckLinkInputCallback interface implementation. |
+ virtual HRESULT VideoInputFormatChanged ( |
+ BMDVideoInputFormatChangedEvents notification_events, |
+ IDeckLinkDisplayMode *new_display_mode, |
+ BMDDetectedVideoInputFormatFlags detected_signal_flags) OVERRIDE; |
+ virtual HRESULT VideoInputFrameArrived ( |
+ IDeckLinkVideoInputFrame* video_frame, |
+ IDeckLinkAudioInputPacket* audio_packet) OVERRIDE; |
+ |
+ // IUnknown interface implementation. |
+ virtual HRESULT QueryInterface (REFIID iid, LPVOID *ppv) OVERRIDE; |
+ virtual ULONG AddRef() OVERRIDE; |
+ virtual ULONG Release() OVERRIDE; |
+ |
+ // Forwarder to VideoCaptureDevice::Client::OnError(). |
+ void SetErrorState(const std::string& reason); |
+ |
+ // Forwarder to VideoCaptureDevice::Client::OnLog(). |
+ void LogMessage(const std::string& message); |
+ |
private: |
+ scoped_ptr<VideoCaptureDevice::Client> client_; |
+ |
+ // This is used to control the video capturing device input interface. |
+ ScopedDeckLinkPtr<IDeckLinkInput> decklink_input_; |
+ // |decklink_| represents a physical device attached to the host. |
+ ScopedDeckLinkPtr<IDeckLink> decklink_; |
+ |
+ // Internal counter for IUnknown interface implementation. |
+ int32_t ref_count_; |
+ const Name device_name_; |
+ |
DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceDeckLinkMac); |
}; |