зеркало из https://github.com/mozilla/gecko-dev.git
Bug 808099 - Write the correct rotational meta-data to the video stream. r=cjones
This commit is contained in:
Родитель
3a0845deea
Коммит
39bf4c9296
|
@ -191,7 +191,6 @@ nsGonkCameraControl::nsGonkCameraControl(uint32_t aCameraId, nsIThread* aCameraT
|
|||
, mDiscardedFrameCount(0)
|
||||
, mMediaProfiles(nullptr)
|
||||
, mRecorder(nullptr)
|
||||
, mVideoRotation(0)
|
||||
, mVideoFile()
|
||||
, mProfileManager(nullptr)
|
||||
, mRecorderProfile(nullptr)
|
||||
|
@ -1172,7 +1171,7 @@ nsGonkCameraControl::HandleRecorderEvent(int msg, int ext1, int ext2)
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsGonkCameraControl::SetupRecording(int aFd, int64_t aMaxFileSizeBytes, int64_t aMaxVideoLengthMs)
|
||||
nsGonkCameraControl::SetupRecording(int aFd, int aRotation, int64_t aMaxFileSizeBytes, int64_t aMaxVideoLengthMs)
|
||||
{
|
||||
// choosing a size big enough to hold the params
|
||||
const size_t SIZE = 256;
|
||||
|
@ -1200,7 +1199,15 @@ nsGonkCameraControl::SetupRecording(int aFd, int64_t aMaxFileSizeBytes, int64_t
|
|||
snprintf(buffer, SIZE, "max-filesize=%lld", aMaxFileSizeBytes);
|
||||
CHECK_SETARG(mRecorder->setParameters(String8(buffer)));
|
||||
|
||||
snprintf(buffer, SIZE, "video-param-rotation-angle-degrees=%d", mVideoRotation);
|
||||
// adjust rotation by camera sensor offset
|
||||
int r = aRotation;
|
||||
r += GonkCameraHardware::GetSensorOrientation(mHwHandle, GonkCameraHardware::RAW_SENSOR_ORIENTATION);
|
||||
r %= 360;
|
||||
r += 45;
|
||||
r /= 90;
|
||||
r *= 90;
|
||||
DOM_CAMERA_LOGI("setting video rotation to %d degrees (mapped from %d)\n", r, aRotation);
|
||||
snprintf(buffer, SIZE, "video-param-rotation-angle-degrees=%d", r);
|
||||
CHECK_SETARG(mRecorder->setParameters(String8(buffer)));
|
||||
|
||||
CHECK_SETARG(mRecorder->setListener(new GonkRecorderListener(this)));
|
||||
|
@ -1218,7 +1225,6 @@ nsGonkCameraControl::GetPreviewStreamVideoModeImpl(GetPreviewStreamVideoModeTask
|
|||
StopPreviewInternal(true /* forced */);
|
||||
|
||||
// setup the video mode
|
||||
mVideoRotation = aGetPreviewStreamVideoMode->mOptions.rotation;
|
||||
nsresult rv = SetupVideoMode(aGetPreviewStreamVideoMode->mOptions.profile);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -1226,7 +1232,7 @@ nsGonkCameraControl::GetPreviewStreamVideoModeImpl(GetPreviewStreamVideoModeTask
|
|||
int width = video->GetWidth();
|
||||
int height = video->GetHeight();
|
||||
int fps = video->GetFramerate();
|
||||
DOM_CAMERA_LOGI("recording preview format: %d x %d (rotated %d degrees)\n", width, height, fps);
|
||||
DOM_CAMERA_LOGI("recording preview format: %d x %d (%d fps)\n", width, height, fps);
|
||||
|
||||
// create and return new preview stream object
|
||||
nsCOMPtr<GetPreviewStreamResult> getPreviewStreamResult = new GetPreviewStreamResult(this, width, height, fps, aGetPreviewStreamVideoMode->mOnSuccessCb, mWindowId);
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
nsresult GetVideoSizes(nsTArray<CameraSize>& aVideoSizes);
|
||||
nsresult PushParameters();
|
||||
|
||||
nsresult SetupRecording(int aFd, int64_t aMaxFileSizeBytes = -1, int64_t aMaxVideoLengthMs = -1);
|
||||
nsresult SetupRecording(int aFd, int aRotation = 0, int64_t aMaxFileSizeBytes = -1, int64_t aMaxVideoLengthMs = -1);
|
||||
nsresult SetupVideoMode(const nsAString& aProfile);
|
||||
|
||||
void AutoFocusComplete(bool aSuccess);
|
||||
|
@ -107,7 +107,6 @@ protected:
|
|||
android::MediaProfiles* mMediaProfiles;
|
||||
android::GonkRecorder* mRecorder;
|
||||
|
||||
uint32_t mVideoRotation;
|
||||
nsString mVideoFile;
|
||||
|
||||
// camcorder profile settings for the desired quality level
|
||||
|
|
|
@ -193,18 +193,21 @@ GonkCameraHardware::Init()
|
|||
if (rv != 0) {
|
||||
return;
|
||||
}
|
||||
mSensorOrientation = info.orientation;
|
||||
mRawSensorOrientation = info.orientation;
|
||||
mSensorOrientation = mRawSensorOrientation;
|
||||
|
||||
// Some kernels report the wrong sensor orientation through
|
||||
// get_camera_info()...
|
||||
char propname[PROP_NAME_MAX];
|
||||
char prop[PROP_VALUE_MAX];
|
||||
int offset = 0;
|
||||
snprintf(propname, sizeof(propname), "ro.moz.cam.%d.sensor_offset", mCamera);
|
||||
if (__system_property_get(propname, prop) > 0) {
|
||||
int offset = clamped(atoi(prop), 0, 270);
|
||||
offset = clamped(atoi(prop), 0, 270);
|
||||
mSensorOrientation += offset;
|
||||
mSensorOrientation %= 360;
|
||||
}
|
||||
DOM_CAMERA_LOGI("Sensor orientation: base=%d, offset=%d, final=%d\n", info.orientation, offset, mSensorOrientation);
|
||||
|
||||
if (sHwHandle == 0) {
|
||||
sHwHandle = 1; // don't use 0
|
||||
|
@ -271,14 +274,24 @@ GonkCameraHardware::GetHandle(GonkCamera* aTarget, uint32_t aCamera)
|
|||
}
|
||||
|
||||
int
|
||||
GonkCameraHardware::GetSensorOrientation(uint32_t aHwHandle)
|
||||
GonkCameraHardware::GetSensorOrientation(uint32_t aHwHandle, uint32_t aType)
|
||||
{
|
||||
DOM_CAMERA_LOGI("%s: aHwHandle = %d\n", __func__, aHwHandle);
|
||||
GonkCameraHardware* hw = GetHardware(aHwHandle);
|
||||
if (!hw) {
|
||||
return 0;
|
||||
}
|
||||
return hw->mSensorOrientation;
|
||||
switch (aType) {
|
||||
case OFFSET_SENSOR_ORIENTATION:
|
||||
return hw->mSensorOrientation;
|
||||
|
||||
case RAW_SENSOR_ORIENTATION:
|
||||
return hw->mRawSensorOrientation;
|
||||
|
||||
default:
|
||||
DOM_CAMERA_LOGE("%s:%d : unknown aType=%d\n", __func__, __LINE__, aType);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -65,8 +65,16 @@ public:
|
|||
* right edge of the screen in natural orientation, the value should be
|
||||
* 90. If the top side of a front-facing camera sensor is aligned with the
|
||||
* right of the screen, the value should be 270.
|
||||
*
|
||||
* RAW_SENSOR_ORIENTATION is the uncorrected orientation returned directly
|
||||
* by get_camera_info(); OFFSET_SENSOR_ORIENTATION is the offset adjusted
|
||||
* orientation.
|
||||
*/
|
||||
static int GetSensorOrientation(uint32_t aHwHandle);
|
||||
enum {
|
||||
RAW_SENSOR_ORIENTATION,
|
||||
OFFSET_SENSOR_ORIENTATION
|
||||
};
|
||||
static int GetSensorOrientation(uint32_t aHwHandle, uint32_t aType = OFFSET_SENSOR_ORIENTATION);
|
||||
|
||||
static int AutoFocus(uint32_t aHwHandle);
|
||||
static void CancelAutoFocus(uint32_t aHwHandle);
|
||||
|
@ -116,6 +124,7 @@ protected:
|
|||
#endif
|
||||
sp<GonkCameraListener> mListener;
|
||||
bool mInitialized;
|
||||
int mRawSensorOrientation;
|
||||
int mSensorOrientation;
|
||||
|
||||
bool IsInitialized()
|
||||
|
|
Загрузка…
Ссылка в новой задаче