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
3 // found in the LICENSE file.
5 // Implementation of VideoCaptureDevice class for Blackmagic video capture
6 // devices by using the DeckLink SDK.
8 #ifndef MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_DECKLINK_MAC_H_
9 #define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_DECKLINK_MAC_H_
11 #include "media/capture/video/video_capture_device.h"
13 #import <Foundation/Foundation.h>
15 #include "base/synchronization/lock.h"
16 #include "base/threading/thread_checker.h"
19 class DeckLinkCaptureDelegate
;
24 // Extension of VideoCaptureDevice to create and manipulate Blackmagic devices.
25 // Creates a reference counted |decklink_capture_delegate_| that does all the
26 // DeckLink SDK configuration and capture work while holding a weak reference to
27 // us for sending back frames, logs and error messages.
28 class MEDIA_EXPORT VideoCaptureDeviceDeckLinkMac
: public VideoCaptureDevice
{
30 // Gets the names of all DeckLink video capture devices connected to this
31 // computer, as enumerated by the DeckLink SDK. To allow the user to choose
32 // exactly which capture format she wants, we enumerate as many cameras as
34 static void EnumerateDevices(VideoCaptureDevice::Names
* device_names
);
36 // Gets the supported formats of a particular device attached to the system,
37 // identified by |device|. Formats are retrieved from the DeckLink SDK.
38 // Following the enumeration, each camera will have only one capability.
39 static void EnumerateDeviceCapabilities(
40 const VideoCaptureDevice::Name
& device
,
41 VideoCaptureFormats
* supported_formats
);
43 explicit VideoCaptureDeviceDeckLinkMac(const Name
& device_name
);
44 ~VideoCaptureDeviceDeckLinkMac() override
;
46 // Copy of VideoCaptureDevice::Client::OnIncomingCapturedData(). Used by
47 // |decklink_capture_delegate_| to forward captured frames.
48 void OnIncomingCapturedData(const uint8
* data
,
50 const VideoCaptureFormat
& frame_format
,
51 int rotation
, // Clockwise.
52 base::TimeTicks timestamp
);
54 // Forwarder to VideoCaptureDevice::Client::OnError().
55 void SendErrorString(const std::string
& reason
);
57 // Forwarder to VideoCaptureDevice::Client::OnLog().
58 void SendLogString(const std::string
& message
);
61 // VideoCaptureDevice implementation.
62 void AllocateAndStart(const VideoCaptureParams
& params
,
63 scoped_ptr
<VideoCaptureDevice::Client
> client
) override
;
64 void StopAndDeAllocate() override
;
66 // Protects concurrent setting and using of |client_|.
68 scoped_ptr
<VideoCaptureDevice::Client
> client_
;
70 // Reference counted handle to the DeckLink capture delegate, ref counted by
71 // the DeckLink SDK as well.
72 scoped_refptr
<DeckLinkCaptureDelegate
> decklink_capture_delegate_
;
74 // Checks for Device (a.k.a. Audio) thread.
75 base::ThreadChecker thread_checker_
;
77 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceDeckLinkMac
);
82 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_DECKLINK_MAC_H_