How to disable media stream in M128

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

How to disable media stream in M128

Postby linuxcef07 » Mon Sep 30, 2024 8:05 am

Looks like starting from M128 (chrome runtime style), if the "--enable-media-stream" command-line switch is not passed then default handling shows permission handling UI and if allowed it shows camera stream.
Earlier, camera stream was allowed only if "--enable-media-stream" switch is passed.

Do we have any switch or flag available to disable media stream explicitly in M128? Basically, I am looking for earlier behaviour with chrome style in M128.
TIA.


Details below:

I updated cef libs from 126.0.6478.127 to 128.0.6613.120
I am using customized cefsimple app in windows. I have conditionally handled “enable-media-stream” in OnBeforeCommandLineProcessing(), something like this:

Code: Select all
void CefPlayerApp::OnBeforeCommandLineProcessing() {
    if (CEFCMDLINE_ENABLE_MEDIA_STREAM) {
        commandLine->AppendSwitch("enable-media-stream");
    }
}


After CEF upgrade to 128.0.6613.120 libs, I am able to access camera stream, even if I test https://webrtc.github.io/samples/src/co ... media/gum/ without ‘—enable-media-stream” switch to cefsimple.
This is not expected. We are supposed to get local camera stream only if “‘—enable-media-stream” switch is passed.

Before upgrade, it was working properly with 126.0.6478.127 libs, and throwing below error if “‘—enable-media-stream” switch is not passed to cefsimple.

NotAllowedError: Permissions have not been granted to use your camera and microphone, you need to allow the page access to your devices in order for the demo to work.
getUserMedia error: NotAllowedError



Is there any change in M128 related to ‘—enable-media-stream” switch that I need to incorporate in my cefsimple?
Or do we have any switch/flag to explicitly disable media stream?


Also, I tested with 128.0.6613.120 cefsimple and cefclient. I am seeing same problematic behaviour with cefsimple, however cefclient works fine.
Cefclient allows to access camera stream only if “‘—enable-media-stream” switch is passed to it, otherwise it gives “NotAllowedError”
Looks like, this is handled in cefclient but not in cefsimple. Can someone please help with required changes to fix this issue in cefsimple?
linuxcef07
Expert
 
Posts: 108
Joined: Wed Dec 20, 2023 11:57 am

Re: How to disable media stream in M128

Postby magreenblatt » Mon Sep 30, 2024 10:27 am

You should implement OnRequestMediaAccessPermission
magreenblatt
Site Admin
 
Posts: 12968
Joined: Fri May 29, 2009 6:57 pm

Re: How to disable media stream in M128

Postby linuxcef07 » Tue Oct 01, 2024 5:13 am

Thanks @magreenblatt for your reply.
I implemented OnRequestMediaAccessPermission callback in SimpleApp (cefsimple from M128) but still seeing same behaviour (camera stream is still available):

simple_app.h

Code: Select all
class SimpleApp : public CefApp, public CefBrowserProcessHandler, public CefPermissionHandler {
 public:

  virtual bool OnRequestMediaAccessPermission(CefRefPtr< CefBrowser> browser,
                                              CefRefPtr<CefFrame> frame,
                                              const CefString& requesting_origin,
                                              uint32_t requested_permissions,
                                              CefRefPtr<CefMediaAccessCallback> callback
                                              ) override;
};


simple_app.cc

Code: Select all
bool
SimpleApp::OnRequestMediaAccessPermission(CefRefPtr< CefBrowser> browser,
                                          CefRefPtr<CefFrame> frame,
                                          const CefString& requesting_origin,
                                          uint32_t requested_permissions,
                                          CefRefPtr<CefMediaAccessCallback> callback
                                          )
   {
      callback->Continue(CEF_MEDIA_PERMISSION_NONE);
      return true;
   }


Am I missing anything here?

As per OnRequestMediaAccessPermission(), I am returning true and calling CefMediaAccessCallback::Continue() method with CEF_MEDIA_PERMISSION_NONE to deny permission. But somehow, I am still seeing camera stream with above changes. I referred the cefclient code for above changes.
Just to add, I am not passing "--enable-media-stream" command-line switch as mentioned in documentation.
linuxcef07
Expert
 
Posts: 108
Joined: Wed Dec 20, 2023 11:57 am

Re: How to disable media stream in M128

Postby linuxcef07 » Tue Oct 01, 2024 6:35 am

I added breakpoint in OnRequestMediaAccessPermission(), which is not getting hit while accessing GetUserMedia.
I have also tried similar code in my customized cefsimple app and seeing similar behavior.
Any idea, what is missing here?
TIA.
linuxcef07
Expert
 
Posts: 108
Joined: Wed Dec 20, 2023 11:57 am

Re: How to disable media stream in M128

Postby linuxcef07 » Tue Oct 01, 2024 6:55 am

Issue is fixed now. Overriding GetPermissionHandler() was missing.
Thanks a lot @magreenblatt.
linuxcef07
Expert
 
Posts: 108
Joined: Wed Dec 20, 2023 11:57 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 58 guests