Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: device/capture/video/mac/video_capture_device_decklink_mac.mm

Issue 2214533002: move //media/capture to //device/capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "media/capture/video/mac/video_capture_device_decklink_mac.h" 5 #include "device/capture/video/mac/video_capture_device_decklink_mac.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
13 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
14 #include "third_party/decklink/mac/include/DeckLinkAPI.h" 14 #include "third_party/decklink/mac/include/DeckLinkAPI.h"
15 15
(...skipping 25 matching lines...) Expand all
41 41
42 // This class is used to interact directly with DeckLink SDK for video capture. 42 // This class is used to interact directly with DeckLink SDK for video capture.
43 // Implements the reference counted interface IUnknown. Has a weak reference to 43 // Implements the reference counted interface IUnknown. Has a weak reference to
44 // VideoCaptureDeviceDeckLinkMac for sending captured frames, error messages and 44 // VideoCaptureDeviceDeckLinkMac for sending captured frames, error messages and
45 // logs. 45 // logs.
46 class DeckLinkCaptureDelegate 46 class DeckLinkCaptureDelegate
47 : public IDeckLinkInputCallback, 47 : public IDeckLinkInputCallback,
48 public base::RefCountedThreadSafe<DeckLinkCaptureDelegate> { 48 public base::RefCountedThreadSafe<DeckLinkCaptureDelegate> {
49 public: 49 public:
50 DeckLinkCaptureDelegate( 50 DeckLinkCaptureDelegate(
51 const media::VideoCaptureDeviceDescriptor& device_descriptor, 51 const device::VideoCaptureDeviceDescriptor& device_descriptor,
52 media::VideoCaptureDeviceDeckLinkMac* frame_receiver); 52 device::VideoCaptureDeviceDeckLinkMac* frame_receiver);
53 53
54 void AllocateAndStart(const media::VideoCaptureParams& params); 54 void AllocateAndStart(const media::VideoCaptureParams& params);
55 void StopAndDeAllocate(); 55 void StopAndDeAllocate();
56 56
57 // Remove the VideoCaptureDeviceDeckLinkMac's weak reference. 57 // Remove the VideoCaptureDeviceDeckLinkMac's weak reference.
58 void ResetVideoCaptureDeviceReference(); 58 void ResetVideoCaptureDeviceReference();
59 59
60 private: 60 private:
61 // IDeckLinkInputCallback interface implementation. 61 // IDeckLinkInputCallback interface implementation.
62 HRESULT VideoInputFormatChanged( 62 HRESULT VideoInputFormatChanged(
63 BMDVideoInputFormatChangedEvents notification_events, 63 BMDVideoInputFormatChangedEvents notification_events,
64 IDeckLinkDisplayMode* new_display_mode, 64 IDeckLinkDisplayMode* new_display_mode,
65 BMDDetectedVideoInputFormatFlags detected_signal_flags) override; 65 BMDDetectedVideoInputFormatFlags detected_signal_flags) override;
66 HRESULT VideoInputFrameArrived( 66 HRESULT VideoInputFrameArrived(
67 IDeckLinkVideoInputFrame* video_frame, 67 IDeckLinkVideoInputFrame* video_frame,
68 IDeckLinkAudioInputPacket* audio_packet) override; 68 IDeckLinkAudioInputPacket* audio_packet) override;
69 69
70 // IUnknown interface implementation. 70 // IUnknown interface implementation.
71 HRESULT QueryInterface(REFIID iid, void** ppv) override; 71 HRESULT QueryInterface(REFIID iid, void** ppv) override;
72 ULONG AddRef() override; 72 ULONG AddRef() override;
73 ULONG Release() override; 73 ULONG Release() override;
74 74
75 // Forwarder to VideoCaptureDeviceDeckLinkMac::SendErrorString(). 75 // Forwarder to VideoCaptureDeviceDeckLinkMac::SendErrorString().
76 void SendErrorString(const tracked_objects::Location& from_here, 76 void SendErrorString(const tracked_objects::Location& from_here,
77 const std::string& reason); 77 const std::string& reason);
78 78
79 // Forwarder to VideoCaptureDeviceDeckLinkMac::SendLogString(). 79 // Forwarder to VideoCaptureDeviceDeckLinkMac::SendLogString().
80 void SendLogString(const std::string& message); 80 void SendLogString(const std::string& message);
81 81
82 const media::VideoCaptureDeviceDescriptor device_descriptor_; 82 const device::VideoCaptureDeviceDescriptor device_descriptor_;
83 83
84 // Protects concurrent setting and using of |frame_receiver_|. 84 // Protects concurrent setting and using of |frame_receiver_|.
85 base::Lock lock_; 85 base::Lock lock_;
86 // Weak reference to the captured frames client, used also for error messages 86 // Weak reference to the captured frames client, used also for error messages
87 // and logging. Initialized on construction and used until cleared by calling 87 // and logging. Initialized on construction and used until cleared by calling
88 // ResetVideoCaptureDeviceReference(). 88 // ResetVideoCaptureDeviceReference().
89 media::VideoCaptureDeviceDeckLinkMac* frame_receiver_; 89 device::VideoCaptureDeviceDeckLinkMac* frame_receiver_;
90 90
91 // This is used to control the video capturing device input interface. 91 // This is used to control the video capturing device input interface.
92 ScopedDeckLinkPtr<IDeckLinkInput> decklink_input_; 92 ScopedDeckLinkPtr<IDeckLinkInput> decklink_input_;
93 // |decklink_| represents a physical device attached to the host. 93 // |decklink_| represents a physical device attached to the host.
94 ScopedDeckLinkPtr<IDeckLink> decklink_; 94 ScopedDeckLinkPtr<IDeckLink> decklink_;
95 95
96 base::TimeTicks first_ref_time_; 96 base::TimeTicks first_ref_time_;
97 97
98 // Checks for Device (a.k.a. Audio) thread. 98 // Checks for Device (a.k.a. Audio) thread.
99 base::ThreadChecker thread_checker_; 99 base::ThreadChecker thread_checker_;
(...skipping 17 matching lines...) Expand all
117 // Interlaced formats are going to be marked as double the frame rate, 117 // Interlaced formats are going to be marked as double the frame rate,
118 // which follows the general naming convention. 118 // which follows the general naming convention.
119 if (display_mode->GetFieldDominance() == bmdLowerFieldFirst || 119 if (display_mode->GetFieldDominance() == bmdLowerFieldFirst ||
120 display_mode->GetFieldDominance() == bmdUpperFieldFirst) { 120 display_mode->GetFieldDominance() == bmdUpperFieldFirst) {
121 display_mode_frame_rate *= 2.0f; 121 display_mode_frame_rate *= 2.0f;
122 } 122 }
123 return display_mode_frame_rate; 123 return display_mode_frame_rate;
124 } 124 }
125 125
126 DeckLinkCaptureDelegate::DeckLinkCaptureDelegate( 126 DeckLinkCaptureDelegate::DeckLinkCaptureDelegate(
127 const media::VideoCaptureDeviceDescriptor& device_descriptor, 127 const device::VideoCaptureDeviceDescriptor& device_descriptor,
128 media::VideoCaptureDeviceDeckLinkMac* frame_receiver) 128 device::VideoCaptureDeviceDeckLinkMac* frame_receiver)
129 : device_descriptor_(device_descriptor), frame_receiver_(frame_receiver) {} 129 : device_descriptor_(device_descriptor), frame_receiver_(frame_receiver) {}
130 130
131 DeckLinkCaptureDelegate::~DeckLinkCaptureDelegate() { 131 DeckLinkCaptureDelegate::~DeckLinkCaptureDelegate() {
132 } 132 }
133 133
134 void DeckLinkCaptureDelegate::AllocateAndStart( 134 void DeckLinkCaptureDelegate::AllocateAndStart(
135 const media::VideoCaptureParams& params) { 135 const media::VideoCaptureParams& params) {
136 DCHECK(thread_checker_.CalledOnValidThread()); 136 DCHECK(thread_checker_.CalledOnValidThread());
137 scoped_refptr<IDeckLinkIterator> decklink_iter( 137 scoped_refptr<IDeckLinkIterator> decklink_iter(
138 CreateDeckLinkIteratorInstance()); 138 CreateDeckLinkIteratorInstance());
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 } 323 }
324 324
325 void DeckLinkCaptureDelegate::ResetVideoCaptureDeviceReference() { 325 void DeckLinkCaptureDelegate::ResetVideoCaptureDeviceReference() {
326 DCHECK(thread_checker_.CalledOnValidThread()); 326 DCHECK(thread_checker_.CalledOnValidThread());
327 base::AutoLock lock(lock_); 327 base::AutoLock lock(lock_);
328 frame_receiver_ = NULL; 328 frame_receiver_ = NULL;
329 } 329 }
330 330
331 } // namespace 331 } // namespace
332 332
333 namespace media { 333 namespace device {
334 334
335 static std::string JoinDeviceNameAndFormat(CFStringRef name, 335 static std::string JoinDeviceNameAndFormat(CFStringRef name,
336 CFStringRef format) { 336 CFStringRef format) {
337 return base::SysCFStringRefToUTF8(name) + " - " + 337 return base::SysCFStringRefToUTF8(name) + " - " +
338 base::SysCFStringRefToUTF8(format); 338 base::SysCFStringRefToUTF8(format);
339 } 339 }
340 340
341 // static 341 // static
342 void VideoCaptureDeviceDeckLinkMac::EnumerateDevices( 342 void VideoCaptureDeviceDeckLinkMac::EnumerateDevices(
343 VideoCaptureDeviceDescriptors* device_descriptors) { 343 VideoCaptureDeviceDescriptors* device_descriptors) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 JoinDeviceNameAndFormat(device_model_name, format_name)) { 438 JoinDeviceNameAndFormat(device_model_name, format_name)) {
439 display_mode.Release(); 439 display_mode.Release();
440 continue; 440 continue;
441 } 441 }
442 442
443 // IDeckLinkDisplayMode does not have information on pixel format, this 443 // IDeckLinkDisplayMode does not have information on pixel format, this
444 // is only available on capture. 444 // is only available on capture.
445 const media::VideoCaptureFormat format( 445 const media::VideoCaptureFormat format(
446 gfx::Size(display_mode->GetWidth(), display_mode->GetHeight()), 446 gfx::Size(display_mode->GetWidth(), display_mode->GetHeight()),
447 GetDisplayModeFrameRate(display_mode), 447 GetDisplayModeFrameRate(display_mode),
448 PIXEL_FORMAT_UNKNOWN); 448 media::PIXEL_FORMAT_UNKNOWN);
449 supported_formats->push_back(format); 449 supported_formats->push_back(format);
450 DVLOG(2) << device.display_name << " " 450 DVLOG(2) << device.display_name << " "
451 << VideoCaptureFormat::ToString(format); 451 << VideoCaptureFormat::ToString(format);
452 display_mode.Release(); 452 display_mode.Release();
453 } 453 }
454 return; 454 return;
455 } 455 }
456 } 456 }
457 457
458 VideoCaptureDeviceDeckLinkMac::VideoCaptureDeviceDeckLinkMac( 458 VideoCaptureDeviceDeckLinkMac::VideoCaptureDeviceDeckLinkMac(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 client_ = std::move(client); 501 client_ = std::move(client);
502 if (decklink_capture_delegate_.get()) 502 if (decklink_capture_delegate_.get())
503 decklink_capture_delegate_->AllocateAndStart(params); 503 decklink_capture_delegate_->AllocateAndStart(params);
504 } 504 }
505 505
506 void VideoCaptureDeviceDeckLinkMac::StopAndDeAllocate() { 506 void VideoCaptureDeviceDeckLinkMac::StopAndDeAllocate() {
507 if (decklink_capture_delegate_.get()) 507 if (decklink_capture_delegate_.get())
508 decklink_capture_delegate_->StopAndDeAllocate(); 508 decklink_capture_delegate_->StopAndDeAllocate();
509 } 509 }
510 510
511 } // namespace media 511 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698