| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 // Implementation of VideoCaptureDevice class for Blackmagic video capture | |
| 6 // devices by using the DeckLink SDK. | |
| 7 | |
| 8 #ifndef MEDIA_CAPTURE_VIDEO_MAC_VIDEO_CAPTURE_DEVICE_DECKLINK_MAC_H_ | |
| 9 #define MEDIA_CAPTURE_VIDEO_MAC_VIDEO_CAPTURE_DEVICE_DECKLINK_MAC_H_ | |
| 10 | |
| 11 #include "media/capture/video/video_capture_device.h" | |
| 12 | |
| 13 #import <Foundation/Foundation.h> | |
| 14 #include <stddef.h> | |
| 15 #include <stdint.h> | |
| 16 | |
| 17 #include "base/macros.h" | |
| 18 #include "base/synchronization/lock.h" | |
| 19 #include "base/threading/thread_checker.h" | |
| 20 | |
| 21 namespace { | |
| 22 class DeckLinkCaptureDelegate; | |
| 23 } // namespace | |
| 24 | |
| 25 namespace tracked_objects { | |
| 26 class Location; | |
| 27 } // namespace tracked_objects | |
| 28 | |
| 29 namespace media { | |
| 30 | |
| 31 // Extension of VideoCaptureDevice to create and manipulate Blackmagic devices. | |
| 32 // Creates a reference counted |decklink_capture_delegate_| that does all the | |
| 33 // DeckLink SDK configuration and capture work while holding a weak reference to | |
| 34 // us for sending back frames, logs and error messages. | |
| 35 class CAPTURE_EXPORT VideoCaptureDeviceDeckLinkMac : public VideoCaptureDevice { | |
| 36 public: | |
| 37 // Gets the names of all DeckLink video capture devices connected to this | |
| 38 // computer, as enumerated by the DeckLink SDK. To allow the user to choose | |
| 39 // exactly which capture format she wants, we enumerate as many cameras as | |
| 40 // capture formats. | |
| 41 static void EnumerateDevices(VideoCaptureDevice::Names* device_names); | |
| 42 | |
| 43 // Gets the supported formats of a particular device attached to the system, | |
| 44 // identified by |device|. Formats are retrieved from the DeckLink SDK. | |
| 45 // Following the enumeration, each camera will have only one capability. | |
| 46 static void EnumerateDeviceCapabilities( | |
| 47 const VideoCaptureDevice::Name& device, | |
| 48 VideoCaptureFormats* supported_formats); | |
| 49 | |
| 50 explicit VideoCaptureDeviceDeckLinkMac(const Name& device_name); | |
| 51 ~VideoCaptureDeviceDeckLinkMac() override; | |
| 52 | |
| 53 // Copy of VideoCaptureDevice::Client::OnIncomingCapturedData(). Used by | |
| 54 // |decklink_capture_delegate_| to forward captured frames. | |
| 55 void OnIncomingCapturedData(const uint8_t* data, | |
| 56 size_t length, | |
| 57 const VideoCaptureFormat& frame_format, | |
| 58 int rotation, // Clockwise. | |
| 59 base::TimeTicks reference_time, | |
| 60 base::TimeDelta timestamp); | |
| 61 | |
| 62 // Forwarder to VideoCaptureDevice::Client::OnError(). | |
| 63 void SendErrorString(const tracked_objects::Location& from_here, | |
| 64 const std::string& reason); | |
| 65 | |
| 66 // Forwarder to VideoCaptureDevice::Client::OnLog(). | |
| 67 void SendLogString(const std::string& message); | |
| 68 | |
| 69 private: | |
| 70 // VideoCaptureDevice implementation. | |
| 71 void AllocateAndStart( | |
| 72 const VideoCaptureParams& params, | |
| 73 std::unique_ptr<VideoCaptureDevice::Client> client) override; | |
| 74 void StopAndDeAllocate() override; | |
| 75 | |
| 76 // Protects concurrent setting and using of |client_|. | |
| 77 base::Lock lock_; | |
| 78 std::unique_ptr<VideoCaptureDevice::Client> client_; | |
| 79 | |
| 80 // Reference counted handle to the DeckLink capture delegate, ref counted by | |
| 81 // the DeckLink SDK as well. | |
| 82 scoped_refptr<DeckLinkCaptureDelegate> decklink_capture_delegate_; | |
| 83 | |
| 84 // Checks for Device (a.k.a. Audio) thread. | |
| 85 base::ThreadChecker thread_checker_; | |
| 86 | |
| 87 DISALLOW_COPY_AND_ASSIGN(VideoCaptureDeviceDeckLinkMac); | |
| 88 }; | |
| 89 | |
| 90 } // namespace media | |
| 91 | |
| 92 #endif // MEDIA_CAPTURE_VIDEO_MAC_VIDEO_CAPTURE_DEVICE_DECKLINK_MAC_H_ | |
| OLD | NEW |