Commit 1b2bdfec authored by Andreas Pehrson's avatar Andreas Pehrson Committed by Richard Pospesel
Browse files

Bug 1786502 - Lock access to DeviceInfo devicechange callbacks. r=webrtc-reviewers,jib a=RyanVM

parent aae8a38c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ class InputObserver : public webrtc::VideoInputFeedBack {
 private:
  ~InputObserver() = default;

  RefPtr<CamerasParent> mParent;
  const RefPtr<CamerasParent> mParent;
};

class CamerasParent final : public PCamerasParent,
+7 −1
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@
#include "media/base/videosinkinterface.h"
#include "modules/include/module.h"
#include "modules/video_capture/video_capture_defines.h"
#include "rtc_base/synchronization/mutex.h"
#include "rtc_base/thread_annotations.h"
#include <set>

#if defined(ANDROID)
@@ -81,15 +83,18 @@ class VideoCaptureModule: public rtc::RefCountInterface {
    virtual uint32_t NumberOfDevices() = 0;
    virtual int32_t Refresh() = 0;
    virtual void DeviceChange() {
      MutexLock lock(&_inputCallbacksMutex);
      for (auto inputCallBack : _inputCallBacks) {
        inputCallBack->OnDeviceChange();
      }
    }
    virtual void RegisterVideoInputFeedBack(VideoInputFeedBack* callBack) {
      MutexLock lock(&_inputCallbacksMutex);
      _inputCallBacks.insert(callBack);
    }

    virtual void DeRegisterVideoInputFeedBack(VideoInputFeedBack* callBack) {
      MutexLock lock(&_inputCallbacksMutex);
      auto it = _inputCallBacks.find(callBack);
      if (it != _inputCallBacks.end()) {
        _inputCallBacks.erase(it);
@@ -147,7 +152,8 @@ class VideoCaptureModule: public rtc::RefCountInterface {

    virtual ~DeviceInfo() {}
   private:
    std::set<VideoInputFeedBack*> _inputCallBacks;
    Mutex _inputCallbacksMutex;
    std::set<VideoInputFeedBack*> _inputCallBacks RTC_GUARDED_BY(_inputCallbacksMutex);
  };

  //   Register capture data callback