Chromium Code Reviews| 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 8fadc188bee68ef063951f0283a149c39c576af8..6dba6b217cf6211ab7e8cb098cf8a6b441e0b0f1 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_; |
|
tommi (sloooow) - chröme
2014/09/05 09:24:21
why do you need this?
mcasas
2014/09/09 11:05:00
Subtemplating a template is a bit special, meaning
tommi (sloooow) - chröme
2014/09/22 20:26:38
Ah, sorry, I was actually more thinking why you're
|
| + |
| + 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. |
| @@ -37,7 +71,38 @@ class MEDIA_EXPORT VideoCaptureDeviceDeckLinkMac : public VideoCaptureDevice { |
| scoped_ptr<VideoCaptureDevice::Client> client) OVERRIDE; |
| virtual void StopAndDeAllocate() OVERRIDE; |
| + // IDeckLinkInputCallback interface implementation. |
|
tommi (sloooow) - chröme
2014/09/05 09:24:20
should this be private/protected? (same for the Vi
mcasas
2014/09/09 11:05:00
Had a second look at the inheritance qualifiers an
|
| + 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; |
|
tommi (sloooow) - chröme
2014/09/05 09:24:21
Since this implements reference counting and Video
mcasas
2014/09/09 11:05:00
I created a DeckLinkCaptureDelegate class that hol
|
| + 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_; |
|
tommi (sloooow) - chröme
2014/09/05 09:24:20
is this a circular dependency to an object that al
mcasas
2014/09/09 11:05:00
Yes, should I turn it into a weak pointer?
|
| + // |decklink_| represents a physical device attached to the host. |
| + ScopedDeckLinkPtr<IDeckLink> decklink_; |
| + |
| + // Internal counter for IUnknown interface implementation. |
| + int32_t ref_count_; |
|
tommi (sloooow) - chröme
2014/09/05 09:24:20
see comment above - I think this should be in a se
mcasas
2014/09/09 11:05:00
Acknowledged.
|
| + const Name device_name_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceDeckLinkMac); |
| }; |