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

Side by Side Diff: media/capture/video/linux/video_capture_device_linux.cc

Issue 1685713003: Remove V4L2CaptureDelegate{Single,Multi}Plane, VCD::Client::OnIncomingCapturedYuvData() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase -- hubbe@ added more VideoPixelFormats Created 4 years, 10 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/linux/video_capture_device_linux.h" 5 #include "media/capture/video/linux/video_capture_device_linux.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <list> 9 #include <list>
10 10
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 if (!ReadIdFile(vidPath, &usb_id)) 74 if (!ReadIdFile(vidPath, &usb_id))
75 return ""; 75 return "";
76 usb_id.append(":"); 76 usb_id.append(":");
77 if (!ReadIdFile(pidPath, &usb_id)) 77 if (!ReadIdFile(pidPath, &usb_id))
78 return ""; 78 return "";
79 79
80 return usb_id; 80 return usb_id;
81 } 81 }
82 82
83 VideoCaptureDeviceLinux::VideoCaptureDeviceLinux(const Name& device_name) 83 VideoCaptureDeviceLinux::VideoCaptureDeviceLinux(const Name& device_name)
84 : v4l2_thread_("V4L2CaptureThread"), device_name_(device_name) { 84 : capture_impl_(nullptr),
85 } 85 v4l2_thread_("V4L2CaptureThread"),
86 device_name_(device_name) {}
86 87
87 VideoCaptureDeviceLinux::~VideoCaptureDeviceLinux() { 88 VideoCaptureDeviceLinux::~VideoCaptureDeviceLinux() {
88 // Check if the thread is running. 89 // Check if the thread is running.
89 // This means that the device has not been StopAndDeAllocate()d properly. 90 // This means that the device has not been StopAndDeAllocate()d properly.
90 DCHECK(!v4l2_thread_.IsRunning()); 91 DCHECK(!v4l2_thread_.IsRunning());
91 v4l2_thread_.Stop(); 92 v4l2_thread_.Stop();
92 } 93 }
93 94
94 void VideoCaptureDeviceLinux::AllocateAndStart( 95 void VideoCaptureDeviceLinux::AllocateAndStart(
95 const VideoCaptureParams& params, 96 const VideoCaptureParams& params,
96 scoped_ptr<VideoCaptureDevice::Client> client) { 97 scoped_ptr<VideoCaptureDevice::Client> client) {
97 DCHECK(!capture_impl_); 98 DCHECK(!capture_impl_);
98 if (v4l2_thread_.IsRunning()) 99 if (v4l2_thread_.IsRunning())
99 return; // Wrong state. 100 return; // Wrong state.
100 v4l2_thread_.Start(); 101 v4l2_thread_.Start();
101 102
102 const int line_frequency = 103 const int line_frequency =
103 TranslatePowerLineFrequencyToV4L2(GetPowerLineFrequency(params)); 104 TranslatePowerLineFrequencyToV4L2(GetPowerLineFrequency(params));
104 capture_impl_ = V4L2CaptureDelegate::CreateV4L2CaptureDelegate( 105 capture_impl_ = new V4L2CaptureDelegate(
105 device_name_, v4l2_thread_.task_runner(), line_frequency); 106 device_name_, v4l2_thread_.task_runner(), line_frequency);
106 if (!capture_impl_) { 107 if (!capture_impl_) {
107 client->OnError(FROM_HERE, "Failed to create VideoCaptureDelegate"); 108 client->OnError(FROM_HERE, "Failed to create VideoCaptureDelegate");
108 return; 109 return;
109 } 110 }
110 v4l2_thread_.message_loop()->PostTask( 111 v4l2_thread_.message_loop()->PostTask(
111 FROM_HERE, 112 FROM_HERE,
112 base::Bind(&V4L2CaptureDelegate::AllocateAndStart, capture_impl_, 113 base::Bind(&V4L2CaptureDelegate::AllocateAndStart,
114 capture_impl_->AsWeakPtr(),
113 params.requested_format.frame_size.width(), 115 params.requested_format.frame_size.width(),
114 params.requested_format.frame_size.height(), 116 params.requested_format.frame_size.height(),
115 params.requested_format.frame_rate, base::Passed(&client))); 117 params.requested_format.frame_rate, base::Passed(&client)));
116 } 118 }
117 119
118 void VideoCaptureDeviceLinux::StopAndDeAllocate() { 120 void VideoCaptureDeviceLinux::StopAndDeAllocate() {
119 if (!v4l2_thread_.IsRunning()) 121 if (!v4l2_thread_.IsRunning())
120 return; // Wrong state. 122 return; // Wrong state.
121 v4l2_thread_.message_loop()->PostTask( 123 v4l2_thread_.message_loop()->PostTask(
122 FROM_HERE, 124 FROM_HERE, base::Bind(&V4L2CaptureDelegate::StopAndDeAllocate,
123 base::Bind(&V4L2CaptureDelegate::StopAndDeAllocate, capture_impl_)); 125 capture_impl_->AsWeakPtr()));
124 v4l2_thread_.Stop(); 126 v4l2_thread_.Stop();
perkj_chrome 2016/02/12 11:01:40 actually - since this own the thread where delegat
mcasas 2016/02/12 21:32:43 Acknowledged.
125 127
126 capture_impl_ = NULL; 128 capture_impl_ = NULL;
127 } 129 }
128 130
129 void VideoCaptureDeviceLinux::SetRotation(int rotation) { 131 void VideoCaptureDeviceLinux::SetRotation(int rotation) {
130 if (v4l2_thread_.IsRunning()) { 132 if (v4l2_thread_.IsRunning()) {
131 v4l2_thread_.message_loop()->PostTask( 133 v4l2_thread_.message_loop()->PostTask(
132 FROM_HERE, 134 FROM_HERE, base::Bind(&V4L2CaptureDelegate::SetRotation,
133 base::Bind(&V4L2CaptureDelegate::SetRotation, capture_impl_, rotation)); 135 capture_impl_->AsWeakPtr(), rotation));
134 } 136 }
135 } 137 }
136 138
137 // static 139 // static
138 int VideoCaptureDeviceLinux::TranslatePowerLineFrequencyToV4L2( 140 int VideoCaptureDeviceLinux::TranslatePowerLineFrequencyToV4L2(
139 PowerLineFrequency frequency) { 141 PowerLineFrequency frequency) {
140 switch (frequency) { 142 switch (frequency) {
141 case media::PowerLineFrequency::FREQUENCY_50HZ: 143 case media::PowerLineFrequency::FREQUENCY_50HZ:
142 return V4L2_CID_POWER_LINE_FREQUENCY_50HZ; 144 return V4L2_CID_POWER_LINE_FREQUENCY_50HZ;
143 case media::PowerLineFrequency::FREQUENCY_60HZ: 145 case media::PowerLineFrequency::FREQUENCY_60HZ:
144 return V4L2_CID_POWER_LINE_FREQUENCY_60HZ; 146 return V4L2_CID_POWER_LINE_FREQUENCY_60HZ;
145 default: 147 default:
146 // If we have no idea of the frequency, at least try and set it to AUTO. 148 // If we have no idea of the frequency, at least try and set it to AUTO.
147 return V4L2_CID_POWER_LINE_FREQUENCY_AUTO; 149 return V4L2_CID_POWER_LINE_FREQUENCY_AUTO;
148 } 150 }
149 } 151 }
150 152
151 } // namespace media 153 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698