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

Unified Diff: content/public/browser/web_contents_media_capture_id.cc

Issue 2291893002: Let Contraints Controll Mute/Unmute Audio Local Playback For Desktop Sharing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove Debug Code Created 4 years, 3 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
Index: content/public/browser/web_contents_media_capture_id.cc
diff --git a/content/public/browser/web_contents_media_capture_id.cc b/content/public/browser/web_contents_media_capture_id.cc
index d9b107b922241e12f4ba636042e62134c20a04d1..d527abebbe55c8897913eceea69d4840cedbaed6 100644
--- a/content/public/browser/web_contents_media_capture_id.cc
+++ b/content/public/browser/web_contents_media_capture_id.cc
@@ -12,22 +12,25 @@
namespace content {
const char kWebContentsCaptureScheme[] = "web-contents-media-stream://";
-static char kEnableThrottlingFlag[] = "?throttling=auto";
+static char kEnableThrottlingFlag[] = "throttling=auto";
+static char kMuteSourceFlag[] = "mute_source=true";
+static char kOptionStart[] = "?";
+static char kOptionSeparator[] = "&";
bool WebContentsMediaCaptureId::operator<(
const WebContentsMediaCaptureId& other) const {
return std::tie(render_process_id, main_render_frame_id,
- enable_auto_throttling) <
+ enable_auto_throttling, mute_source) <
std::tie(other.render_process_id, other.main_render_frame_id,
- other.enable_auto_throttling);
+ other.enable_auto_throttling, other.mute_source);
}
bool WebContentsMediaCaptureId::operator==(
const WebContentsMediaCaptureId& other) const {
return std::tie(render_process_id, main_render_frame_id,
- enable_auto_throttling) ==
+ enable_auto_throttling, mute_source) ==
std::tie(other.render_process_id, other.main_render_frame_id,
- other.enable_auto_throttling);
+ other.enable_auto_throttling, other.mute_source);
}
bool WebContentsMediaCaptureId::is_null() const {
@@ -40,8 +43,18 @@ std::string WebContentsMediaCaptureId::ToString() const {
s.append(":");
s.append(base::Int64ToString(main_render_frame_id));
- if (enable_auto_throttling)
+ char* connector = kOptionStart;
+ if (enable_auto_throttling) {
+ s.append(connector);
s.append(kEnableThrottlingFlag);
+ connector = kOptionSeparator;
+ }
+
+ if (mute_source) {
+ s.append(connector);
+ s.append(kMuteSourceFlag);
+ connector = kOptionSeparator;
+ }
return s;
}
@@ -54,8 +67,10 @@ WebContentsMediaCaptureId WebContentsMediaCaptureId::Parse(
if (!ExtractTabCaptureTarget(str, &render_process_id, &main_render_frame_id))
return WebContentsMediaCaptureId();
+ bool auto_throttling, mute_source;
+ ExtractOptions(str, &auto_throttling, &mute_source);
return WebContentsMediaCaptureId(render_process_id, main_render_frame_id,
- IsAutoThrottlingOptionSet(str));
+ auto_throttling, mute_source);
}
// static
@@ -93,20 +108,40 @@ bool WebContentsMediaCaptureId::ExtractTabCaptureTarget(
}
// static
-bool WebContentsMediaCaptureId::IsAutoThrottlingOptionSet(
- const std::string& device_id) {
+bool WebContentsMediaCaptureId::ExtractOptions(const std::string& device_id,
+ bool* auto_throttling,
+ bool* mute_source) {
if (!IsWebContentsDeviceId(device_id))
return false;
// Find the option part of the string and just do a naive string compare since
// there are no other options in the |device_id| to account for (at the time
// of this writing).
- const size_t option_pos = device_id.find('?');
- if (option_pos == std::string::npos)
- return false;
- const base::StringPiece component(device_id.data() + option_pos,
- device_id.length() - option_pos);
- return component.compare(kEnableThrottlingFlag) == 0;
+ size_t option_pos = device_id.find(kOptionStart);
+ if (option_pos == std::string::npos) {
+ if (auto_throttling)
+ *auto_throttling = false;
+ if (mute_source)
+ *mute_source = false;
+ return true;
+ }
+
+ size_t option_pos_end;
+ while (option_pos < device_id.length()) {
+ option_pos_end = device_id.find(kOptionSeparator, option_pos + 1);
+ if (option_pos_end == std::string::npos)
+ option_pos_end = device_id.length();
+ const base::StringPiece component(device_id.data() + option_pos + 1,
+ option_pos_end - option_pos - 1);
+
+ if (auto_throttling && component.compare(kEnableThrottlingFlag) == 0)
+ *auto_throttling = true;
+ if (mute_source && component.compare(kMuteSourceFlag) == 0)
+ *mute_source = true;
+
+ option_pos = option_pos_end;
+ }
+ return true;
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698