Bug 1441145 - Signal the capture-to-render rotation from parent to child. r?jib
MozReview-Commit-ID: 7JkJOedq9wm
--- a/dom/media/systemservices/CamerasParent.cpp
+++ b/dom/media/systemservices/CamerasParent.cpp
@@ -158,16 +158,36 @@ public:
, mProperties(aProperties){};
NS_IMETHOD Run() override {
if (mParent->IsShuttingDown()) {
// Communication channel is being torn down
mResult = 0;
return NS_OK;
}
+ // Figure out if this frame had already applied rotation. If so, we pass this
+ // information to the child so it can scale to the proper dimensions.
+ MOZ_DIAGNOSTIC_ASSERT(sAllRequestedCapabilities.count(mStreamId) == 1);
+ const webrtc::VideoCaptureCapability& cap =
+ sAllRequestedCapabilities[mStreamId];
+ MOZ_ASSERT(mProperties.rotation() == 0, "Rotation is always applied");
+ MOZ_ASSERT(mProperties.width() == cap.width ||
+ mProperties.width() == cap.height, "Width must match cap");
+ MOZ_ASSERT(mProperties.height() == cap.width ||
+ mProperties.height() == cap.height, "Height must match cap");
+ if (mProperties.width() == cap.height && mProperties.height() == cap.width) {
+ // The capability is for the sensor, and the device's rotation was such
+ // that this frame had to be rotated. We signal this to the child so
+ // it can rescale to the proper dimensions.
+ //
+ // It doesn't matter if we pass 90 or 270 as the frame has already been
+ // rotated and we just want to get the target width and height right.
+ mProperties.rotation() = 90;
+ }
+
if (!mParent->DeliverFrameOverIPC(mCapEngine, mStreamId, Move(mBuffer),
mAlternateBuffer.get(), mProperties)) {
mResult = -1;
} else {
mResult = 0;
}
return NS_OK;
}
--- a/dom/media/systemservices/PCameras.ipdl
+++ b/dom/media/systemservices/PCameras.ipdl
@@ -32,17 +32,18 @@ struct VideoFrameProperties
{
// Size of image data within the ShMem,
// the ShMem is at least this large
size_t bufferSize;
// From webrtc::VideoFrame
uint32_t timeStamp;
int64_t ntpTimeMs;
int64_t renderTimeMs;
- // See webrtc/**/rotation.h
+ // Rotation of the frame in degrees compared to the requested capability.
+ // Note that the buffer is already upright.
int rotation;
int yAllocatedSize;
int uAllocatedSize;
int vAllocatedSize;
// From webrtc::VideoFrameBuffer
int width;
int height;
int yStride;