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

Unified Diff: webrtc/media/base/capturemanager.cc

Issue 1740963002: Revert of Removed unused cricket::VideoCapturer methods (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/media/base/capturemanager.h ('k') | webrtc/media/base/capturemanager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/media/base/capturemanager.cc
diff --git a/webrtc/media/base/capturemanager.cc b/webrtc/media/base/capturemanager.cc
index 0e724773c7d3ca883688cf9ba5bf1322c3858adb..3628fb306d8663a0f18f5b30224a9bc4751777df 100644
--- a/webrtc/media/base/capturemanager.cc
+++ b/webrtc/media/base/capturemanager.cc
@@ -194,6 +194,62 @@
if (capture_state->DecCaptureStartRef() == 0) {
// Unregistering cannot fail as capture_state is not NULL.
UnregisterVideoCapturer(capture_state);
+ }
+ return true;
+}
+
+bool CaptureManager::RestartVideoCapture(
+ VideoCapturer* video_capturer,
+ const VideoFormat& previous_format,
+ const VideoFormat& desired_format,
+ CaptureManager::RestartOptions options) {
+ RTC_DCHECK(thread_checker_.CalledOnValidThread());
+ if (!IsCapturerRegistered(video_capturer)) {
+ LOG(LS_ERROR) << "RestartVideoCapture: video_capturer is not registered.";
+ return false;
+ }
+ // Start the new format first. This keeps the capturer running.
+ if (!StartVideoCapture(video_capturer, desired_format)) {
+ LOG(LS_ERROR) << "RestartVideoCapture: unable to start video capture with "
+ "desired_format=" << desired_format.ToString();
+ return false;
+ }
+ // Stop the old format.
+ if (!StopVideoCapture(video_capturer, previous_format)) {
+ LOG(LS_ERROR) << "RestartVideoCapture: unable to stop video capture with "
+ "previous_format=" << previous_format.ToString();
+ // Undo the start request we just performed.
+ StopVideoCapture(video_capturer, desired_format);
+ return false;
+ }
+
+ switch (options) {
+ case kForceRestart: {
+ VideoCapturerState* capture_state = GetCaptureState(video_capturer);
+ ASSERT(capture_state && capture_state->start_count() > 0);
+ // Try a restart using the new best resolution.
+ VideoFormat highest_asked_format =
+ capture_state->GetHighestFormat(video_capturer);
+ VideoFormat capture_format;
+ if (video_capturer->GetBestCaptureFormat(highest_asked_format,
+ &capture_format)) {
+ if (!video_capturer->Restart(capture_format)) {
+ LOG(LS_ERROR) << "RestartVideoCapture: Restart failed.";
+ }
+ } else {
+ LOG(LS_WARNING)
+ << "RestartVideoCapture: Couldn't find a best capture format for "
+ << highest_asked_format.ToString();
+ }
+ break;
+ }
+ case kRequestRestart:
+ // TODO(ryanpetrie): Support restart requests. Should this
+ // to-be-implemented logic be used for {Start,Stop}VideoCapture as well?
+ break;
+ default:
+ LOG(LS_ERROR) << "Unknown/unimplemented RestartOption";
+ break;
}
return true;
}
« no previous file with comments | « webrtc/media/base/capturemanager.h ('k') | webrtc/media/base/capturemanager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698