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

Side by Side Diff: talk/media/webrtc/webrtcvideocapturer.cc

Issue 1655793003: Make cricket::VideoCapturer implement VideoSourceInterface (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixed Android 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 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 if (!module_) { 213 if (!module_) {
214 LOG(LS_ERROR) << "Failed to create capturer for id: " << device.id; 214 LOG(LS_ERROR) << "Failed to create capturer for id: " << device.id;
215 return false; 215 return false;
216 } 216 }
217 217
218 // It is safe to change member attributes now. 218 // It is safe to change member attributes now.
219 module_->AddRef(); 219 module_->AddRef();
220 SetId(device.id); 220 SetId(device.id);
221 SetSupportedFormats(supported); 221 SetSupportedFormats(supported);
222 222
223 // Ensure these 2 have the same value.
224 SetApplyRotation(module_->GetApplyRotation());
225
226 return true; 223 return true;
227 } 224 }
228 225
229 bool WebRtcVideoCapturer::Init(webrtc::VideoCaptureModule* module) { 226 bool WebRtcVideoCapturer::Init(webrtc::VideoCaptureModule* module) {
230 RTC_DCHECK(!start_thread_); 227 RTC_DCHECK(!start_thread_);
231 if (module_) { 228 if (module_) {
232 LOG(LS_ERROR) << "The capturer is already initialized"; 229 LOG(LS_ERROR) << "The capturer is already initialized";
233 return false; 230 return false;
234 } 231 }
235 if (!module) { 232 if (!module) {
(...skipping 17 matching lines...) Expand all
253 best_format->width = desired.width; 250 best_format->width = desired.width;
254 best_format->height = desired.height; 251 best_format->height = desired.height;
255 best_format->fourcc = FOURCC_I420; 252 best_format->fourcc = FOURCC_I420;
256 best_format->interval = desired.interval; 253 best_format->interval = desired.interval;
257 LOG(LS_INFO) << "Failed to find best capture format," 254 LOG(LS_INFO) << "Failed to find best capture format,"
258 << " fall back to the requested format " 255 << " fall back to the requested format "
259 << best_format->ToString(); 256 << best_format->ToString();
260 } 257 }
261 return true; 258 return true;
262 } 259 }
263 bool WebRtcVideoCapturer::SetApplyRotation(bool enable) { 260 void WebRtcVideoCapturer::OnSinkCapabilitiesChanged(
261 const rtc::VideoSinkCapabilities& capabilities) {
264 // Can't take lock here as this will cause deadlock with 262 // Can't take lock here as this will cause deadlock with
265 // OnIncomingCapturedFrame. In fact, the whole method, including methods it 263 // OnIncomingCapturedFrame. In fact, the whole method, including methods it
266 // calls, can't take lock. 264 // calls, can't take lock.
267 RTC_DCHECK(module_); 265 RTC_DCHECK(module_);
268 266
269 const std::string group_name = 267 const std::string group_name =
270 webrtc::field_trial::FindFullName("WebRTC-CVO"); 268 webrtc::field_trial::FindFullName("WebRTC-CVO");
271 269
272 if (group_name == "Disabled") { 270 if (group_name == "Disabled") {
273 return true; 271 return;
274 } 272 }
275 273
276 if (!VideoCapturer::SetApplyRotation(enable)) { 274 VideoCapturer::OnSinkCapabilitiesChanged(capabilities);
277 return false; 275 bool result = module_->SetApplyRotation(!capabilities.can_apply_rotation);
278 } 276 RTC_CHECK(result);
279 return module_->SetApplyRotation(enable); 277
278 return;
280 } 279 }
281 280
282 CaptureState WebRtcVideoCapturer::Start(const VideoFormat& capture_format) { 281 CaptureState WebRtcVideoCapturer::Start(const VideoFormat& capture_format) {
283 if (!module_) { 282 if (!module_) {
284 LOG(LS_ERROR) << "The capturer has not been initialized"; 283 LOG(LS_ERROR) << "The capturer has not been initialized";
285 return CS_NO_DEVICE; 284 return CS_NO_DEVICE;
286 } 285 }
287 if (start_thread_) { 286 if (start_thread_) {
288 LOG(LS_ERROR) << "The capturer is already running"; 287 LOG(LS_ERROR) << "The capturer is already running";
289 RTC_DCHECK(start_thread_->IsCurrent()) 288 RTC_DCHECK(start_thread_->IsCurrent())
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 // Convert units from VideoFrame RenderTimeMs to CapturedFrame (nanoseconds). 438 // Convert units from VideoFrame RenderTimeMs to CapturedFrame (nanoseconds).
440 time_stamp = sample.render_time_ms() * rtc::kNumNanosecsPerMillisec; 439 time_stamp = sample.render_time_ms() * rtc::kNumNanosecsPerMillisec;
441 data_size = rtc::checked_cast<uint32_t>(length); 440 data_size = rtc::checked_cast<uint32_t>(length);
442 data = buffer; 441 data = buffer;
443 rotation = sample.rotation(); 442 rotation = sample.rotation();
444 } 443 }
445 444
446 } // namespace cricket 445 } // namespace cricket
447 446
448 #endif // HAVE_WEBRTC_VIDEO 447 #endif // HAVE_WEBRTC_VIDEO
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698