[M130 Migration] Add desktop sharing patches 10/324510/2
authoryangzw <zw714.yang@samsung.com>
Tue, 20 May 2025 03:12:40 +0000 (11:12 +0800)
committerBot Blink <blinkbot@samsung.com>
Wed, 21 May 2025 01:31:07 +0000 (01:31 +0000)
1.fixup! [WebRTC] Tizen system output audio capture for screen share feature
fix wrong usage of vector erase function

ref:
https://archive.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/319465/

2.[ScreenSharing] Block tizen forwarding device enumeration result
tizen forwarding device is used for capturing all system audio,
it should not be listed in audio input enumeration result list,
otherwise it may break the w3c web standard and cause the tct test
to fail.

ref:
https://archive.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/320037/

3.Add privilege check for audio capturer
any app that wants to capture system audio should have the
corresponding privilege, so before opening the corresponding
device we check it by the cynara module.

ref:
https://archive.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/321134/

Change-Id: I1b387c0de742ba6d02eeb2a9e1464d7b666958f4
Signed-off-by: yangzw <zw714.yang@samsung.com>
content/browser/renderer_host/media/media_capture_devices_impl.cc
third_party/blink/renderer/modules/mediastream/media_devices.cc
tizen_src/chromium_impl/media/audio/tizen/capi_usb_audio_input_stream.cc

index 597ed5d1cfb3d33dee190950b1ebe6680784e4ea..246d5d096a773f90b13ae7a8ebf4748c484bb5f2 100644 (file)
@@ -127,11 +127,13 @@ blink::MediaStreamDevices MediaCaptureDevicesImpl::ExtractAudioForwardDevices(
   // Find out tizen forwarding device, and classify it as
   // |DISPLAY_AUDIO_CAPTURE| device.
   blink::MediaStreamDevices forward_devices;
-  for (auto device = devices.begin(); device != devices.end(); device++) {
+  for (auto device = devices.begin(); device != devices.end();) {
     if (is_forwarding_device(device->name)) {
       device->type = blink::mojom::MediaStreamType::DISPLAY_AUDIO_CAPTURE;
       forward_devices.push_back(*device);
-      devices.erase(device);
+      device = devices.erase(device);
+    } else {
+      device++;
     }
   }
   return forward_devices;
index ab555a8b4e846ca69ebfdf433b378ffa3101f316..1015971665593fa71a02a3a92ebd47780bd6a8c6 100644 (file)
@@ -1154,6 +1154,14 @@ void MediaDevices::DevicesEnumerated(
           static_cast<mojom::blink::MediaDeviceType>(i);
       WebMediaDeviceInfo device_info = enumeration[i][j];
       String device_label = String::FromUTF8(device_info.label);
+#if BUILDFLAG(IS_TIZEN_TV)
+      // Block tizen forwarding device, refer to:
+      // https://review.tizen.org/gerrit/319068/
+      if (device_label.Find("forwarding") != kNotFound) {
+        continue;
+      }
+#endif
+
       if (device_type == mojom::blink::MediaDeviceType::kMediaAudioInput ||
           device_type == mojom::blink::MediaDeviceType::kMediaVideoInput) {
         InputDeviceInfo* input_device_info =
index 6b684937d8ee06a844aa7a1592cb7f550886e3bc..525960b72af894a8e114bd2726839da44978b35b 100644 (file)
 #include "base/logging.h"
 #include "media/audio/tizen/audio_manager_capi.h"
 
+#if BUILDFLAG(IS_TIZEN_TV)
+#include "wrt/src/common/privilege.h"
+#endif
+
 #include <sound_manager_internal.h>
 namespace media {
 
+#if BUILDFLAG(IS_TIZEN_TV)
+constexpr char kMediaCapturePrivilege[] =
+    "http://tizen.org/privilege/mediacapture";
+#endif
+
 CapiUsbAudioInputStream::CapiUsbAudioInputStream(
     AudioManagerCapi* audio_manager,
     const std::string& device_name,
@@ -97,6 +106,19 @@ bool CapiUsbAudioInputStream::OpenMic() {
     return false;
   }
 
+#if BUILDFLAG(IS_TIZEN_TV)
+  // Check privilege for audio forwarding device used to capture system
+  // output audio.
+  if (device_type == SOUND_DEVICE_FORWARDING) {
+    auto has_privilege =
+        wrt::privilege::FindPrivilegeFromCynara(kMediaCapturePrivilege);
+    if (!has_privilege) {
+      LOG(ERROR) << "No system audio capture privilege.";
+      return false;
+    }
+  }
+#endif
+
   stream_info_ = nullptr;
 
   ret = sound_manager_create_stream_information(stream_type, nullptr, nullptr,