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 // Implementation of VideoCaptureDevice class for Blackmagic video capture | 5 // Implementation of VideoCaptureDevice class for Blackmagic video capture |
6 // devices by using the DeckLink SDK. | 6 // devices by using the DeckLink SDK. |
7 | 7 |
8 #ifndef MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_DECKLINK_MAC_H_ | 8 #ifndef MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_DECKLINK_MAC_H_ |
9 #define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_DECKLINK_MAC_H_ | 9 #define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_DECKLINK_MAC_H_ |
10 | 10 |
11 #include "media/video/capture/video_capture_device.h" | 11 #include "media/video/capture/video_capture_device.h" |
12 | 12 |
13 #import <Foundation/Foundation.h> | 13 #import <Foundation/Foundation.h> |
14 | 14 |
15 #include "base/synchronization/lock.h" | |
16 #include "base/threading/thread_checker.h" | |
17 | |
18 namespace { | |
19 class DeckLinkCaptureDelegate; | |
20 } // namespace | |
21 | |
15 namespace media { | 22 namespace media { |
16 | 23 |
17 // Extension of VideoCaptureDevice to create and manipulate Blackmagic devices | 24 // Extension of VideoCaptureDevice to create and manipulate Blackmagic devices. |
18 // via DeckLink SDK. | 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. | |
19 class MEDIA_EXPORT VideoCaptureDeviceDeckLinkMac : public VideoCaptureDevice { | 28 class MEDIA_EXPORT VideoCaptureDeviceDeckLinkMac : public VideoCaptureDevice { |
20 public: | 29 public: |
21 // Gets the names of all DeckLink video capture devices connected to this | 30 // Gets the names of all DeckLink video capture devices connected to this |
22 // computer, as enumerated by the DeckLink SDK. | 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 | |
33 // capture formats. | |
23 static void EnumerateDevices(VideoCaptureDevice::Names* device_names); | 34 static void EnumerateDevices(VideoCaptureDevice::Names* device_names); |
24 | 35 |
25 // Gets the supported formats of a particular device attached to the system, | 36 // Gets the supported formats of a particular device attached to the system, |
26 // identified by |device|. Formats are retrieved from the DeckLink SDK. | 37 // identified by |device|. Formats are retrieved from the DeckLink SDK. |
38 // Following the enumeration, each camera will have only one capability. | |
27 static void EnumerateDeviceCapabilities( | 39 static void EnumerateDeviceCapabilities( |
28 const VideoCaptureDevice::Name& device, | 40 const VideoCaptureDevice::Name& device, |
29 VideoCaptureFormats* supported_formats); | 41 VideoCaptureFormats* supported_formats); |
30 | 42 |
31 explicit VideoCaptureDeviceDeckLinkMac(const Name& device_name); | 43 explicit VideoCaptureDeviceDeckLinkMac(const Name& device_name); |
32 virtual ~VideoCaptureDeviceDeckLinkMac(); | 44 virtual ~VideoCaptureDeviceDeckLinkMac(); |
33 | 45 |
46 // Copy of VideoCaptureDevice::Client::OnIncomingCapturedData(). Used by | |
47 // |decklink_capture_delegate_| to forward captured frames. | |
48 void OnIncomingCapturedData(const uint8* data, | |
49 int length, | |
Robert Sesek
2014/09/24 17:06:14
Lengths of buffers should really be measured in si
mcasas
2014/09/24 19:39:56
Done.
| |
50 const VideoCaptureFormat& frame_format, | |
51 int rotation, // Clockwise. | |
52 base::TimeTicks timestamp); | |
53 | |
54 // Forwarder to VideoCaptureDevice::Client::OnError(). | |
55 void SendErrorString(const std::string& reason); | |
56 | |
57 // Forwarder to VideoCaptureDevice::Client::OnLog(). | |
58 void SendLogString(const std::string& message); | |
59 | |
60 private: | |
34 // VideoCaptureDevice implementation. | 61 // VideoCaptureDevice implementation. |
35 virtual void AllocateAndStart( | 62 virtual void AllocateAndStart( |
36 const VideoCaptureParams& params, | 63 const VideoCaptureParams& params, |
37 scoped_ptr<VideoCaptureDevice::Client> client) OVERRIDE; | 64 scoped_ptr<VideoCaptureDevice::Client> client) OVERRIDE; |
38 virtual void StopAndDeAllocate() OVERRIDE; | 65 virtual void StopAndDeAllocate() OVERRIDE; |
39 | 66 |
40 private: | 67 // Protects concurrent setting and using of |client_|. |
68 base::Lock lock_; | |
69 scoped_ptr<VideoCaptureDevice::Client> client_; | |
70 // Reference counted handle to the DeckLink capture delegate, ref counted by | |
Robert Sesek
2014/09/24 17:06:14
Is this also protected by |lock_|? If not, put a b
mcasas
2014/09/24 19:39:56
Done.
| |
71 // the DeckLink SDK as well. | |
72 scoped_refptr<DeckLinkCaptureDelegate> decklink_capture_delegate_; | |
73 | |
74 base::ThreadChecker thread_checker_; | |
75 | |
41 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceDeckLinkMac); | 76 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceDeckLinkMac); |
42 }; | 77 }; |
43 | 78 |
44 } // namespace media | 79 } // namespace media |
45 | 80 |
46 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_DECKLINK_MAC_H_ | 81 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_DECKLINK_MAC_H_ |
OLD | NEW |