Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_MEDIA_CAPTURE_ID_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_MEDIA_CAPTURE_ID_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_MEDIA_CAPTURE_ID_H_ | 6 #define CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_MEDIA_CAPTURE_ID_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| 11 #include "ipc/ipc_message.h" | 11 #include "ipc/ipc_message.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 | 14 |
| 15 struct CONTENT_EXPORT WebContentsMediaCaptureId { | 15 struct CONTENT_EXPORT WebContentsMediaCaptureId { |
| 16 public: | 16 public: |
| 17 WebContentsMediaCaptureId() = default; | 17 WebContentsMediaCaptureId() = default; |
| 18 WebContentsMediaCaptureId(int render_process_id, int main_render_frame_id) | 18 WebContentsMediaCaptureId(int render_process_id, int main_render_frame_id) |
| 19 : render_process_id(render_process_id), | 19 : render_process_id(render_process_id), |
| 20 main_render_frame_id(main_render_frame_id) {} | 20 main_render_frame_id(main_render_frame_id) {} |
| 21 | 21 |
| 22 WebContentsMediaCaptureId(int render_process_id, | 22 WebContentsMediaCaptureId(int render_process_id, |
| 23 int main_render_frame_id, | 23 int main_render_frame_id, |
| 24 bool enable_auto_throttling) | 24 bool enable_auto_throttling, |
| 25 bool mute_source) | |
| 25 : render_process_id(render_process_id), | 26 : render_process_id(render_process_id), |
| 26 main_render_frame_id(main_render_frame_id), | 27 main_render_frame_id(main_render_frame_id), |
| 27 enable_auto_throttling(enable_auto_throttling) {} | 28 enable_auto_throttling(enable_auto_throttling), |
| 29 mute_source(mute_source) {} | |
| 28 | 30 |
| 29 bool operator<(const WebContentsMediaCaptureId& other) const; | 31 bool operator<(const WebContentsMediaCaptureId& other) const; |
| 30 bool operator==(const WebContentsMediaCaptureId& other) const; | 32 bool operator==(const WebContentsMediaCaptureId& other) const; |
| 31 | 33 |
| 32 // Return true if render_process_id or main_render_frame_id is invalid. | 34 // Return true if render_process_id or main_render_frame_id is invalid. |
| 33 bool is_null() const; | 35 bool is_null() const; |
| 34 | 36 |
| 35 std::string ToString() const; | 37 std::string ToString() const; |
| 36 | 38 |
| 37 // Tab video and audio capture need render process id and render frame id. | 39 // Tab video and audio capture need render process id and render frame id. |
| 38 int render_process_id = MSG_ROUTING_NONE; | 40 int render_process_id = MSG_ROUTING_NONE; |
| 39 int main_render_frame_id = MSG_ROUTING_NONE; | 41 int main_render_frame_id = MSG_ROUTING_NONE; |
| 40 | 42 |
| 41 bool enable_auto_throttling = false; | 43 bool enable_auto_throttling = false; |
| 44 bool mute_source = false; | |
| 42 | 45 |
| 43 // Create WebContentsMediaCaptureId based on a string. | 46 // Create WebContentsMediaCaptureId based on a string. |
| 44 static WebContentsMediaCaptureId Parse(const std::string& str); | 47 static WebContentsMediaCaptureId Parse(const std::string& str); |
| 45 | 48 |
| 46 // Check whether the device id indicates that this is a web contents stream. | 49 // Check whether the device id indicates that this is a web contents stream. |
| 47 static bool IsWebContentsDeviceId(const std::string& device_id); | 50 static bool IsWebContentsDeviceId(const std::string& device_id); |
| 48 | 51 |
| 49 // Function to extract the target render frame id's from a media stream | 52 // Function to extract the target render frame id's from a media stream |
| 50 // request's device id. | 53 // request's device id. |
| 51 static bool ExtractTabCaptureTarget(const std::string& device_id, | 54 static bool ExtractTabCaptureTarget(const std::string& device_id, |
| 52 int* render_process_id, | 55 int* render_process_id, |
| 53 int* main_render_frame_id); | 56 int* main_render_frame_id); |
| 54 | 57 |
| 55 // Parses the media stream request |device_id| and returns true if both 1) the | 58 // Parses the media stream request |device_id| and returns true if the |
| 56 // format is valid, and 2) the throttling option is set to auto. | 59 // format is valid. |*auto_throttling| will be stored whether the |device_id| |
| 57 static bool IsAutoThrottlingOptionSet(const std::string& device_id); | 60 // indicated auto throttling. |*mute_source| will stored whether |device_id| |
| 61 // requests us to mute the source audio during sharing. | |
| 62 // The caller can pass nullptr for either |auto_throttling| or |mute_source|, | |
| 63 // if the value is uninteresting. | |
| 64 static bool ExtractOptions(const std::string& device_id, | |
|
miu
2016/09/07 21:10:03
Looking at the calls to this function, only one of
qiangchen
2016/09/09 23:32:08
Done.
| |
| 65 bool* auto_throttling, | |
| 66 bool* mute_source); | |
| 58 }; | 67 }; |
| 59 | 68 |
| 60 } // namespace content | 69 } // namespace content |
| 61 | 70 |
| 62 #endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_MEDIA_CAPTURE_ID_H_ | 71 #endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_MEDIA_CAPTURE_ID_H_ |
| OLD | NEW |