commit ae854f4c5bad7f5ba59de895b058227d31d369e7
parent 0e8d216b6ee7ae9ff406dc1d001e4f06e3ff94f9
Author: Andreas Pehrson <apehrson@mozilla.com>
Date: Tue, 11 Nov 2025 08:20:25 +0000
Bug 1771789 - In PCameras rename captureId with streamId for consistency. r=jib
Differential Revision: https://phabricator.services.mozilla.com/D266402
Diffstat:
3 files changed, 48 insertions(+), 48 deletions(-)
diff --git a/dom/media/systemservices/CamerasParent.cpp b/dom/media/systemservices/CamerasParent.cpp
@@ -917,33 +917,33 @@ ipc::IPCResult CamerasParent::RecvAllocateCapture(
}
int CamerasParent::ReleaseCapture(const CaptureEngine& aCapEngine,
- int aCaptureId) {
+ int aStreamId) {
MOZ_ASSERT(mVideoCaptureThread->IsOnCurrentThread());
int error = -1;
if (auto* engine = EnsureInitialized(aCapEngine)) {
- error = engine->ReleaseVideoCapture(aCaptureId);
+ error = engine->ReleaseVideoCapture(aStreamId);
}
return error;
}
ipc::IPCResult CamerasParent::RecvReleaseCapture(
- const CaptureEngine& aCapEngine, const int& aCaptureId) {
+ const CaptureEngine& aCapEngine, const int& aStreamId) {
MOZ_ASSERT(mPBackgroundEventTarget->IsOnCurrentThread());
MOZ_ASSERT(!mDestroyed);
LOG_FUNCTION();
- LOG("RecvReleaseCamera device nr %d", aCaptureId);
+ LOG("RecvReleaseCapture stream nr %d", aStreamId);
using Promise = MozPromise<int, bool, true>;
InvokeAsync(mVideoCaptureThread, __func__,
- [this, self = RefPtr(this), aCapEngine, aCaptureId] {
+ [this, self = RefPtr(this), aCapEngine, aStreamId] {
return Promise::CreateAndResolve(
- ReleaseCapture(aCapEngine, aCaptureId),
+ ReleaseCapture(aCapEngine, aStreamId),
"CamerasParent::RecvReleaseCapture");
})
->Then(mPBackgroundEventTarget, __func__,
[this, self = RefPtr(this),
- aCaptureId](Promise::ResolveOrRejectValue&& aValue) {
+ aStreamId](Promise::ResolveOrRejectValue&& aValue) {
int error = aValue.ResolveValue();
if (mDestroyed) {
@@ -953,19 +953,19 @@ ipc::IPCResult CamerasParent::RecvReleaseCapture(
if (error != 0) {
(void)SendReplyFailure();
- LOG("RecvReleaseCapture: Failed to free device nr %d",
- aCaptureId);
+ LOG("RecvReleaseCapture: Failed to free stream nr %d",
+ aStreamId);
return;
}
(void)SendReplySuccess();
- LOG("Freed device nr %d", aCaptureId);
+ LOG("Freed stream nr %d", aStreamId);
});
return IPC_OK();
}
ipc::IPCResult CamerasParent::RecvStartCapture(
- const CaptureEngine& aCapEngine, const int& aCaptureId,
+ const CaptureEngine& aCapEngine, const int& aStreamId,
const VideoCaptureCapability& aIpcCaps,
const NormalizedConstraints& aConstraints,
const dom::VideoResizeModeEnum& aResizeMode) {
@@ -977,8 +977,8 @@ ipc::IPCResult CamerasParent::RecvStartCapture(
using Promise = MozPromise<int, bool, true>;
InvokeAsync(
mVideoCaptureThread, __func__,
- [this, self = RefPtr(this), aCapEngine, aCaptureId, aIpcCaps,
- aConstraints, aResizeMode] {
+ [this, self = RefPtr(this), aCapEngine, aStreamId, aIpcCaps, aConstraints,
+ aResizeMode] {
LOG_FUNCTION();
int error = -1;
@@ -988,7 +988,7 @@ ipc::IPCResult CamerasParent::RecvStartCapture(
}
mEngines->ElementAt(aCapEngine)
- ->WithEntry(aCaptureId, [&](VideoEngine::CaptureEntry& cap) {
+ ->WithEntry(aStreamId, [&](VideoEngine::CaptureEntry& cap) {
webrtc::VideoCaptureCapability capability;
capability.width = aIpcCaps.width();
capability.height = aIpcCaps.height();
@@ -997,20 +997,20 @@ ipc::IPCResult CamerasParent::RecvStartCapture(
static_cast<webrtc::VideoType>(aIpcCaps.videoType());
capability.interlaced = aIpcCaps.interlaced();
- if (sDeviceUniqueIDs.find(aCaptureId) == sDeviceUniqueIDs.end()) {
+ if (sDeviceUniqueIDs.find(aStreamId) == sDeviceUniqueIDs.end()) {
sDeviceUniqueIDs.emplace(
- aCaptureId, cap.VideoCapture()->CurrentDeviceName());
- sAllRequestedCapabilities.emplace(aCaptureId, capability);
+ aStreamId, cap.VideoCapture()->CurrentDeviceName());
+ sAllRequestedCapabilities.emplace(aStreamId, capability);
} else {
// Starting capture for an id that already exists. Update its
// requested capability.
MOZ_DIAGNOSTIC_ASSERT(
- strcmp(sDeviceUniqueIDs[aCaptureId],
+ strcmp(sDeviceUniqueIDs[aStreamId],
cap.VideoCapture()->CurrentDeviceName()) == 0);
MOZ_DIAGNOSTIC_ASSERT(
- sAllRequestedCapabilities.find(aCaptureId) !=
+ sAllRequestedCapabilities.find(aStreamId) !=
sAllRequestedCapabilities.end());
- sAllRequestedCapabilities[aCaptureId] = capability;
+ sAllRequestedCapabilities[aStreamId] = capability;
}
if (aCapEngine == CameraEngine) {
@@ -1078,7 +1078,7 @@ ipc::IPCResult CamerasParent::RecvStartCapture(
CallbackHelper* cbh = nullptr;
for (auto& cb : mCallbacks) {
if (cb->mCapEngine == aCapEngine &&
- cb->mStreamId == aCaptureId) {
+ cb->mStreamId == aStreamId) {
cbh = cb.get();
break;
}
@@ -1087,8 +1087,8 @@ ipc::IPCResult CamerasParent::RecvStartCapture(
if (!cbh) {
cbh = mCallbacks
.AppendElement(MakeUnique<CallbackHelper>(
- static_cast<CaptureEngine>(aCapEngine),
- aCaptureId, this))
+ static_cast<CaptureEngine>(aCapEngine), aStreamId,
+ this))
->get();
cap.VideoCapture()->SetTrackingId(
cbh->mTrackingId.mUniqueInProcId);
@@ -1112,8 +1112,8 @@ ipc::IPCResult CamerasParent::RecvStartCapture(
}
}
} else {
- sDeviceUniqueIDs.erase(aCaptureId);
- sAllRequestedCapabilities.erase(aCaptureId);
+ sDeviceUniqueIDs.erase(aStreamId);
+ sAllRequestedCapabilities.erase(aStreamId);
}
});
@@ -1142,7 +1142,7 @@ ipc::IPCResult CamerasParent::RecvStartCapture(
}
ipc::IPCResult CamerasParent::RecvFocusOnSelectedSource(
- const CaptureEngine& aCapEngine, const int& aCaptureId) {
+ const CaptureEngine& aCapEngine, const int& aStreamId) {
MOZ_ASSERT(mPBackgroundEventTarget->IsOnCurrentThread());
MOZ_ASSERT(!mDestroyed);
@@ -1150,11 +1150,11 @@ ipc::IPCResult CamerasParent::RecvFocusOnSelectedSource(
using Promise = MozPromise<bool, bool, true>;
InvokeAsync(mVideoCaptureThread, __func__,
- [this, self = RefPtr(this), aCapEngine, aCaptureId] {
+ [this, self = RefPtr(this), aCapEngine, aStreamId] {
bool result = false;
if (auto* engine = EnsureInitialized(aCapEngine)) {
engine->WithEntry(
- aCaptureId, [&](VideoEngine::CaptureEntry& cap) {
+ aStreamId, [&](VideoEngine::CaptureEntry& cap) {
if (cap.VideoCapture()) {
result = cap.VideoCapture()->FocusOnSelectedSource();
}
@@ -1184,24 +1184,24 @@ ipc::IPCResult CamerasParent::RecvFocusOnSelectedSource(
}
void CamerasParent::StopCapture(const CaptureEngine& aCapEngine,
- int aCaptureId) {
+ int aStreamId) {
MOZ_ASSERT(mVideoCaptureThread->IsOnCurrentThread());
if (auto* engine = EnsureInitialized(aCapEngine)) {
// we're removing elements, iterate backwards
for (size_t i = mCallbacks.Length(); i > 0; i--) {
if (mCallbacks[i - 1]->mCapEngine == aCapEngine &&
- mCallbacks[i - 1]->mStreamId == aCaptureId) {
+ mCallbacks[i - 1]->mStreamId == aStreamId) {
CallbackHelper* cbh = mCallbacks[i - 1].get();
- engine->WithEntry(aCaptureId, [cbh, &aCaptureId](
- VideoEngine::CaptureEntry& cap) {
+ engine->WithEntry(aStreamId, [cbh, &aStreamId](
+ VideoEngine::CaptureEntry& cap) {
if (cap.VideoCapture()) {
cap.VideoCapture()->DeRegisterCaptureDataCallback(
static_cast<webrtc::VideoSinkInterface<webrtc::VideoFrame>*>(
cbh));
cap.VideoCapture()->StopCaptureIfAllClientsClose();
- sDeviceUniqueIDs.erase(aCaptureId);
- sAllRequestedCapabilities.erase(aCaptureId);
+ sDeviceUniqueIDs.erase(aStreamId);
+ sAllRequestedCapabilities.erase(aStreamId);
}
});
cbh->mCaptureEndedListener.DisconnectIfExists();
@@ -1213,15 +1213,15 @@ void CamerasParent::StopCapture(const CaptureEngine& aCapEngine,
}
ipc::IPCResult CamerasParent::RecvStopCapture(const CaptureEngine& aCapEngine,
- const int& aCaptureId) {
+ const int& aStreamId) {
MOZ_ASSERT(mPBackgroundEventTarget->IsOnCurrentThread());
MOZ_ASSERT(!mDestroyed);
LOG_FUNCTION();
nsresult rv = mVideoCaptureThread->Dispatch(NS_NewRunnableFunction(
- __func__, [this, self = RefPtr(this), aCapEngine, aCaptureId] {
- StopCapture(aCapEngine, aCaptureId);
+ __func__, [this, self = RefPtr(this), aCapEngine, aStreamId] {
+ StopCapture(aCapEngine, aStreamId);
}));
if (mDestroyed) {
diff --git a/dom/media/systemservices/CamerasParent.h b/dom/media/systemservices/CamerasParent.h
@@ -102,7 +102,7 @@ class CamerasParent final : public PCamerasParent {
const CaptureEngine& aCapEngine, const nsACString& aUniqueIdUTF8,
const uint64_t& aWindowID) override;
mozilla::ipc::IPCResult RecvReleaseCapture(const CaptureEngine& aCapEngine,
- const int& aCaptureId) override;
+ const int& aStreamId) override;
mozilla::ipc::IPCResult RecvNumberOfCaptureDevices(
const CaptureEngine& aCapEngine) override;
mozilla::ipc::IPCResult RecvNumberOfCapabilities(
@@ -113,14 +113,14 @@ class CamerasParent final : public PCamerasParent {
mozilla::ipc::IPCResult RecvGetCaptureDevice(
const CaptureEngine& aCapEngine, const int& aDeviceIndex) override;
mozilla::ipc::IPCResult RecvStartCapture(
- const CaptureEngine& aCapEngine, const int& aCaptureId,
+ const CaptureEngine& aCapEngine, const int& aStreamId,
const VideoCaptureCapability& aIpcCaps,
const NormalizedConstraints& aConstraints,
const dom::VideoResizeModeEnum& aResizeMode) override;
mozilla::ipc::IPCResult RecvFocusOnSelectedSource(
- const CaptureEngine& aCapEngine, const int& aCaptureId) override;
+ const CaptureEngine& aCapEngine, const int& aStreamId) override;
mozilla::ipc::IPCResult RecvStopCapture(const CaptureEngine& aCapEngine,
- const int& aCaptureId) override;
+ const int& aStreamId) override;
mozilla::ipc::IPCResult RecvReleaseFrame(
mozilla::ipc::Shmem&& aShmem) override;
void ActorDestroy(ActorDestroyReason aWhy) override;
@@ -149,8 +149,8 @@ class CamerasParent final : public PCamerasParent {
virtual ~CamerasParent();
// We use these helpers for shutdown and for the respective IPC commands.
- void StopCapture(const CaptureEngine& aCapEngine, int aCaptureId);
- int ReleaseCapture(const CaptureEngine& aCapEngine, int aCaptureId);
+ void StopCapture(const CaptureEngine& aCapEngine, int aStreamId);
+ int ReleaseCapture(const CaptureEngine& aCapEngine, int aStreamId);
void OnDeviceChange();
diff --git a/dom/media/systemservices/PCameras.ipdl b/dom/media/systemservices/PCameras.ipdl
@@ -67,7 +67,7 @@ child:
async DeviceChange();
async ReplyNumberOfCaptureDevices(int deviceCount);
async ReplyNumberOfCapabilities(int capabilityCount);
- async ReplyAllocateCapture(int captureId);
+ async ReplyAllocateCapture(int streamId);
async ReplyGetCaptureCapability(VideoCaptureCapability cap);
async ReplyGetCaptureDevice(nsCString device_name, nsCString device_id, bool scary);
async ReplyFailure();
@@ -84,13 +84,13 @@ parent:
async AllocateCapture(CaptureEngine engine, nsCString unique_idUTF8,
uint64_t windowID);
- async ReleaseCapture(CaptureEngine engine, int captureId);
- async StartCapture(CaptureEngine engine, int captureId,
+ async ReleaseCapture(CaptureEngine engine, int streamId);
+ async StartCapture(CaptureEngine engine, int streamId,
VideoCaptureCapability capability,
NormalizedConstraints constraints,
VideoResizeModeEnum resizeMode);
- async FocusOnSelectedSource(CaptureEngine engine, int captureId);
- async StopCapture(CaptureEngine engine, int captureId);
+ async FocusOnSelectedSource(CaptureEngine engine, int streamId);
+ async StopCapture(CaptureEngine engine, int streamId);
// transfers frame back
async ReleaseFrame(Shmem s);