commit faec86244032335e37586082db62c4ee7de1f1c9 parent 2d8770a3a9e6b2628a7fa5642bb0d9c1765209b1 Author: Dan Baker <dbaker@mozilla.com> Date: Mon, 1 Dec 2025 15:22:35 -0700 Bug 2000941 (MOZ) - Support libwebrtc change of adding clock into video_capture_impl. Diffstat:
8 files changed, 36 insertions(+), 24 deletions(-)
diff --git a/dom/media/systemservices/android_video_capture/video_capture_android.cc b/dom/media/systemservices/android_video_capture/video_capture_android.cc @@ -118,9 +118,9 @@ int32_t SetCaptureAndroidVM(JavaVM* javaVM) { namespace videocapturemodule { webrtc::scoped_refptr<VideoCaptureModule> VideoCaptureImpl::Create( - const char* deviceUniqueIdUTF8) { + Clock* clock, const char* deviceUniqueIdUTF8) { webrtc::scoped_refptr<VideoCaptureAndroid> implementation( - new webrtc::RefCountedObject<VideoCaptureAndroid>()); + new webrtc::RefCountedObject<VideoCaptureAndroid>(clock)); if (implementation->Init(deviceUniqueIdUTF8) != 0) { implementation = nullptr; } @@ -146,8 +146,8 @@ void VideoCaptureAndroid::OnIncomingFrame( DeliverCapturedFrame(captureFrame); } -VideoCaptureAndroid::VideoCaptureAndroid() - : VideoCaptureImpl(), +VideoCaptureAndroid::VideoCaptureAndroid(Clock* clock) + : VideoCaptureImpl(clock), _deviceInfo(), _jCapturer(NULL), _captureStarted(false) {} diff --git a/dom/media/systemservices/android_video_capture/video_capture_android.h b/dom/media/systemservices/android_video_capture/video_capture_android.h @@ -16,13 +16,14 @@ #include "api/video/i420_buffer.h" #include "device_info_android.h" #include "modules/video_capture/video_capture_impl.h" +#include "system_wrappers/include/clock.h" namespace webrtc { namespace videocapturemodule { class VideoCaptureAndroid : public VideoCaptureImpl { public: - VideoCaptureAndroid(); + VideoCaptureAndroid(Clock* clock); virtual int32_t Init(const char* deviceUniqueIdUTF8); virtual int32_t StartCapture(const VideoCaptureCapability& capability); diff --git a/dom/media/systemservices/fake_video_capture/video_capture_fake.cc b/dom/media/systemservices/fake_video_capture/video_capture_fake.cc @@ -20,11 +20,14 @@ using mozilla::layers::Image; namespace webrtc::videocapturemodule { webrtc::scoped_refptr<webrtc::VideoCaptureModule> VideoCaptureFake::Create( nsISerialEventTarget* aTarget) { - return webrtc::make_ref_counted<VideoCaptureFake>(aTarget); + return webrtc::make_ref_counted<VideoCaptureFake>( + Clock::GetRealTimeClockRaw(), aTarget); } -VideoCaptureFake::VideoCaptureFake(nsISerialEventTarget* aTarget) - : mTarget(aTarget), mSource(MakeRefPtr<FakeVideoSource>(aTarget)) { +VideoCaptureFake::VideoCaptureFake(Clock* clock, nsISerialEventTarget* aTarget) + : VideoCaptureImpl(clock), + mTarget(aTarget), + mSource(MakeRefPtr<FakeVideoSource>(aTarget)) { size_t len = strlen(DeviceInfoFake::kId); _deviceUniqueId = new (std::nothrow) char[len + 1]; if (_deviceUniqueId) { diff --git a/dom/media/systemservices/fake_video_capture/video_capture_fake.h b/dom/media/systemservices/fake_video_capture/video_capture_fake.h @@ -13,6 +13,7 @@ #include "mozilla/RefPtr.h" #include "mozilla/ThreadSafety.h" #include "mozilla/TimeStamp.h" +#include "system_wrappers/include/clock.h" class nsISerialEventTarget; @@ -26,7 +27,7 @@ class Image; namespace webrtc::videocapturemodule { class VideoCaptureFake : public webrtc::videocapturemodule::VideoCaptureImpl { public: - explicit VideoCaptureFake(nsISerialEventTarget* aTarget); + explicit VideoCaptureFake(Clock* clock, nsISerialEventTarget* aTarget); ~VideoCaptureFake() override; static webrtc::scoped_refptr<webrtc::VideoCaptureModule> Create( diff --git a/dom/media/systemservices/objc_video_capture/video_capture.h b/dom/media/systemservices/objc_video_capture/video_capture.h @@ -13,17 +13,19 @@ #include "api/scoped_refptr.h" #include "modules/video_capture/video_capture_impl.h" +#include "system_wrappers/include/clock.h" @class RTCVideoCaptureIosObjC; namespace webrtc::videocapturemodule { class VideoCaptureIos : public VideoCaptureImpl { public: - VideoCaptureIos(); + VideoCaptureIos(Clock* _Nonnull clock); virtual ~VideoCaptureIos(); static webrtc::scoped_refptr<VideoCaptureModule> Create( - const char* device_unique_id_utf8); + Clock* _Nonnull clock, + const char* _Null_unspecified device_unique_id_utf8); // Implementation of VideoCaptureImpl. int32_t StartCapture(const VideoCaptureCapability& capability) override; @@ -32,7 +34,7 @@ class VideoCaptureIos : public VideoCaptureImpl { int32_t CaptureSettings(VideoCaptureCapability& settings) override; private: - RTCVideoCaptureIosObjC* capture_device_; + RTCVideoCaptureIosObjC* _Null_unspecified capture_device_; bool is_capturing_; VideoCaptureCapability capability_; }; diff --git a/dom/media/systemservices/objc_video_capture/video_capture.mm b/dom/media/systemservices/objc_video_capture/video_capture.mm @@ -24,14 +24,15 @@ using namespace webrtc; using namespace videocapturemodule; webrtc::scoped_refptr<VideoCaptureModule> VideoCaptureImpl::Create( - const char* deviceUniqueIdUTF8) { + Clock* _Nonnull clock, const char* _Null_unspecified deviceUniqueIdUTF8) { if (StaticPrefs::media_getusermedia_camera_macavf_enabled_AtStartup()) { - return VideoCaptureAvFoundation::Create(deviceUniqueIdUTF8); + return VideoCaptureAvFoundation::Create(clock, deviceUniqueIdUTF8); } - return VideoCaptureIos::Create(deviceUniqueIdUTF8); + return VideoCaptureIos::Create(clock, deviceUniqueIdUTF8); } -VideoCaptureIos::VideoCaptureIos() : is_capturing_(false) { +VideoCaptureIos::VideoCaptureIos(Clock* _Nonnull clock) + : VideoCaptureImpl(clock), is_capturing_(false) { capability_.width = kDefaultWidth; capability_.height = kDefaultHeight; capability_.maxFPS = kDefaultFrameRate; @@ -46,13 +47,13 @@ VideoCaptureIos::~VideoCaptureIos() { } webrtc::scoped_refptr<VideoCaptureModule> VideoCaptureIos::Create( - const char* deviceUniqueIdUTF8) { + Clock* _Nonnull clock, const char* _Null_unspecified deviceUniqueIdUTF8) { if (!deviceUniqueIdUTF8[0]) { return NULL; } webrtc::scoped_refptr<VideoCaptureIos> capture_module( - new webrtc::RefCountedObject<VideoCaptureIos>()); + new webrtc::RefCountedObject<VideoCaptureIos>(clock)); const int32_t name_length = strlen(deviceUniqueIdUTF8); if (name_length >= kVideoCaptureUniqueNameLength) return nullptr; diff --git a/dom/media/systemservices/objc_video_capture/video_capture_avfoundation.h b/dom/media/systemservices/objc_video_capture/video_capture_avfoundation.h @@ -14,6 +14,7 @@ #include "api/sequence_checker.h" #include "modules/video_capture/video_capture_impl.h" #include "mozilla/Maybe.h" +#include "system_wrappers/include/clock.h" @class VideoCaptureAdapter; @@ -26,11 +27,12 @@ namespace webrtc::videocapturemodule { */ class VideoCaptureAvFoundation : public VideoCaptureImpl { public: - VideoCaptureAvFoundation(AVCaptureDevice* _Nonnull aDevice); + VideoCaptureAvFoundation(Clock* _Nonnull clock, + AVCaptureDevice* _Nonnull aDevice); virtual ~VideoCaptureAvFoundation(); static webrtc::scoped_refptr<VideoCaptureModule> Create( - const char* _Nullable aDeviceUniqueIdUTF8); + Clock* _Nonnull clock, const char* _Nullable aDeviceUniqueIdUTF8); // Implementation of VideoCaptureImpl. Single threaded. diff --git a/dom/media/systemservices/objc_video_capture/video_capture_avfoundation.mm b/dom/media/systemservices/objc_video_capture/video_capture_avfoundation.mm @@ -100,8 +100,9 @@ AVCaptureDeviceFormat* _Nullable FindFormat( namespace webrtc::videocapturemodule { VideoCaptureAvFoundation::VideoCaptureAvFoundation( - AVCaptureDevice* _Nonnull aDevice) - : mDevice(aDevice), + Clock* _Nonnull clock, AVCaptureDevice* _Nonnull aDevice) + : VideoCaptureImpl(clock), + mDevice(aDevice), mAdapter([[VideoCaptureAdapter alloc] init]), mCapturer([[RTC_OBJC_TYPE(RTCCameraVideoCapturer) alloc] initWithDelegate:mAdapter]), @@ -121,7 +122,7 @@ VideoCaptureAvFoundation::~VideoCaptureAvFoundation() { /* static */ webrtc::scoped_refptr<VideoCaptureModule> VideoCaptureAvFoundation::Create( - const char* _Nullable aDeviceUniqueIdUTF8) { + Clock* _Nonnull clock, const char* _Nullable aDeviceUniqueIdUTF8) { std::string uniqueId(aDeviceUniqueIdUTF8); for (AVCaptureDevice* device in [RTCCameraVideoCapturer @@ -129,7 +130,8 @@ webrtc::scoped_refptr<VideoCaptureModule> VideoCaptureAvFoundation::Create( defaultCaptureDeviceTypes]]) { if ([NSString stdStringForString:device.uniqueID] == uniqueId) { webrtc::scoped_refptr<VideoCaptureModule> module( - new webrtc::RefCountedObject<VideoCaptureAvFoundation>(device)); + new webrtc::RefCountedObject<VideoCaptureAvFoundation>(clock, + device)); return module; } }