From 5a7dc39277999cbfa0da053da5eacc7fee5cd307 Mon Sep 17 00:00:00 2001 From: "guoweis@webrtc.org" Date: Fri, 13 Feb 2015 14:31:26 +0000 Subject: [PATCH] This is a code clean up. No functional change intended. Consolidate the enum for capturer/frame rotation we use through out the code base. BUG=4145 R=mflodman@webrtc.org, perkj@webrtc.org Review URL: https://webrtc-codereview.appspot.com/39859004 Cr-Commit-Position: refs/heads/master@{#8365} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8365 4adac7df-926f-26a2-2b94-8c16560cd09d --- talk/media/webrtc/fakewebrtcdeviceinfo.h | 2 +- .../webrtc/fakewebrtcvideocapturemodule.h | 3 +- talk/media/webrtc/fakewebrtcvideoengine.h | 5 ++- .../media_demo/jni/video_engine_jni.cc | 12 ++++--- .../org/webrtc/webrtcdemo/MediaEngine.java | 7 ++-- .../org/webrtc/webrtcdemo/VideoEngine.java | 2 +- .../android/device_info_android.cc | 5 ++- .../android/device_info_android.h | 2 +- .../android/video_capture_android.cc | 17 +++++---- .../android/video_capture_android.h | 4 +-- .../modules/video_capture/device_info_impl.cc | 5 ++- .../modules/video_capture/device_info_impl.h | 5 ++- .../include/mock/mock_video_capture.h | 2 +- .../video_capture/include/video_capture.h | 8 ++--- .../include/video_capture_defines.h | 9 ----- .../video_capture/ios/device_info_ios.h | 2 +- .../video_capture/ios/device_info_ios.mm | 6 ++-- .../ios/rtc_video_capture_ios_objc.h | 2 +- .../test/video_capture_unittest.cc | 35 +++++++++---------- .../video_capture/video_capture_impl.cc | 30 ++++++++-------- .../video_capture/video_capture_impl.h | 10 +++--- webrtc/video_engine/include/vie_capture.h | 14 +++----- .../auto_test/source/vie_autotest_capture.cc | 22 ++++++------ webrtc/video_engine/vie_capture_impl.cc | 28 ++++----------- webrtc/video_engine/vie_capture_impl.h | 6 ++-- webrtc/video_engine/vie_capturer.cc | 20 ++--------- webrtc/video_engine/vie_capturer.h | 2 +- webrtc/video_engine/vie_input_manager.cc | 23 ++---------- webrtc/video_engine/vie_input_manager.h | 3 +- 29 files changed, 110 insertions(+), 181 deletions(-) diff --git a/talk/media/webrtc/fakewebrtcdeviceinfo.h b/talk/media/webrtc/fakewebrtcdeviceinfo.h index 3f7ace1715..ad5d5f50a6 100644 --- a/talk/media/webrtc/fakewebrtcdeviceinfo.h +++ b/talk/media/webrtc/fakewebrtcdeviceinfo.h @@ -91,7 +91,7 @@ class FakeWebRtcDeviceInfo : public webrtc::VideoCaptureModule::DeviceInfo { return 0; } virtual int32_t GetOrientation(const char* device_id, - webrtc::VideoCaptureRotation& rotation) { + webrtc::VideoRotation& rotation) { return -1; // not implemented } virtual int32_t GetBestMatchedCapability( diff --git a/talk/media/webrtc/fakewebrtcvideocapturemodule.h b/talk/media/webrtc/fakewebrtcvideocapturemodule.h index 55a5157dce..e86b4234be 100644 --- a/talk/media/webrtc/fakewebrtcvideocapturemodule.h +++ b/talk/media/webrtc/fakewebrtcvideocapturemodule.h @@ -96,8 +96,7 @@ class FakeWebRtcVideoCaptureModule : public webrtc::VideoCaptureModule { return 0; } - virtual int32_t SetCaptureRotation( - webrtc::VideoCaptureRotation rotation) OVERRIDE { + virtual int32_t SetCaptureRotation(webrtc::VideoRotation rotation) OVERRIDE { return -1; // not implemented } virtual bool SetApplyRotation(bool enable) OVERRIDE { diff --git a/talk/media/webrtc/fakewebrtcvideoengine.h b/talk/media/webrtc/fakewebrtcvideoengine.h index 470a887ee3..551bee5475 100644 --- a/talk/media/webrtc/fakewebrtcvideoengine.h +++ b/talk/media/webrtc/fakewebrtcvideoengine.h @@ -876,15 +876,14 @@ class FakeWebRtcVideoEngine } WEBRTC_STUB(StartCapture, (const int, const webrtc::CaptureCapability&)); WEBRTC_STUB(StopCapture, (const int)); - WEBRTC_STUB(SetRotateCapturedFrames, (const int, - const webrtc::RotateCapturedFrame)); + WEBRTC_STUB(SetVideoRotation, (const int, const webrtc::VideoRotation)); WEBRTC_STUB(SetCaptureDelay, (const int, const unsigned int)); WEBRTC_STUB(NumberOfCapabilities, (const char*, const unsigned int)); WEBRTC_STUB(GetCaptureCapability, (const char*, const unsigned int, const unsigned int, webrtc::CaptureCapability&)); WEBRTC_STUB(ShowCaptureSettingsDialogBox, (const char*, const unsigned int, const char*, void*, const unsigned int, const unsigned int)); - WEBRTC_STUB(GetOrientation, (const char*, webrtc::RotateCapturedFrame&)); + WEBRTC_STUB(GetOrientation, (const char*, webrtc::VideoRotation&)); WEBRTC_STUB(EnableBrightnessAlarm, (const int, const bool)); WEBRTC_STUB(RegisterObserver, (const int, webrtc::ViECaptureObserver&)); WEBRTC_STUB(DeregisterObserver, (const int)); diff --git a/webrtc/examples/android/media_demo/jni/video_engine_jni.cc b/webrtc/examples/android/media_demo/jni/video_engine_jni.cc index 412a516696..bb61a4632c 100644 --- a/webrtc/examples/android/media_demo/jni/video_engine_jni.cc +++ b/webrtc/examples/android/media_demo/jni/video_engine_jni.cc @@ -560,7 +560,7 @@ JOWW(jint, VideoEngine_getOrientation)(JNIEnv* jni, jobject j_vie, jobject j_camera) { VideoEngineData* vie_data = GetVideoEngineData(jni, j_vie); CameraDesc* camera_info = GetCameraDesc(jni, j_camera); - webrtc::RotateCapturedFrame orientation; + webrtc::VideoRotation orientation; if (vie_data->capture->GetOrientation(camera_info->unique_id, orientation) != 0) { return -1; @@ -568,11 +568,13 @@ JOWW(jint, VideoEngine_getOrientation)(JNIEnv* jni, jobject j_vie, return static_cast(orientation); } -JOWW(jint, VideoEngine_setRotateCapturedFrames)(JNIEnv* jni, jobject j_vie, - jint capture_id, jint degrees) { +JOWW(jint, VideoEngine_setVideoRotations)(JNIEnv* jni, + jobject j_vie, + jint capture_id, + jint degrees) { VideoEngineData* vie_data = GetVideoEngineData(jni, j_vie); - return vie_data->capture->SetRotateCapturedFrames( - capture_id, static_cast(degrees)); + return vie_data->capture->SetVideoRotation( + capture_id, static_cast(degrees)); } JOWW(jint, VideoEngine_setNackStatus)(JNIEnv* jni, jobject j_vie, jint channel, diff --git a/webrtc/examples/android/media_demo/src/org/webrtc/webrtcdemo/MediaEngine.java b/webrtc/examples/android/media_demo/src/org/webrtc/webrtcdemo/MediaEngine.java index f55bcccfb6..bed4b30963 100644 --- a/webrtc/examples/android/media_demo/src/org/webrtc/webrtcdemo/MediaEngine.java +++ b/webrtc/examples/android/media_demo/src/org/webrtc/webrtcdemo/MediaEngine.java @@ -742,9 +742,8 @@ public class MediaEngine implements VideoDecodeEncodeObserver { int cameraRotation = rotationFromRealWorldUp( cameras[getCameraIndex()], deviceOrientation); // Egress streams should have real world up as up. - check( - vie.setRotateCapturedFrames(currentCameraHandle, cameraRotation) == 0, - "Failed setRotateCapturedFrames: camera " + currentCameraHandle + - "rotation " + cameraRotation); + check(vie.setVideoRotations(currentCameraHandle, cameraRotation) == 0, + "Failed setVideoRotations: camera " + currentCameraHandle + + "rotation " + cameraRotation); } } diff --git a/webrtc/examples/android/media_demo/src/org/webrtc/webrtcdemo/VideoEngine.java b/webrtc/examples/android/media_demo/src/org/webrtc/webrtcdemo/VideoEngine.java index 677ff42fb5..086fe304e2 100644 --- a/webrtc/examples/android/media_demo/src/org/webrtc/webrtcdemo/VideoEngine.java +++ b/webrtc/examples/android/media_demo/src/org/webrtc/webrtcdemo/VideoEngine.java @@ -88,7 +88,7 @@ public class VideoEngine { public native int stopCapture(int cameraId); public native int releaseCaptureDevice(int cameraId); public native int getOrientation(CameraDesc camera); - public native int setRotateCapturedFrames(int cameraId, int degrees); + public native int setVideoRotations(int cameraId, int degrees); public native int setNackStatus(int channel, boolean enable); public int setKeyFrameRequestMethod(int channel, VieKeyFrameRequestMethod requestMethod) { diff --git a/webrtc/modules/video_capture/android/device_info_android.cc b/webrtc/modules/video_capture/android/device_info_android.cc index bc04da86d5..29c510ea54 100644 --- a/webrtc/modules/video_capture/android/device_info_android.cc +++ b/webrtc/modules/video_capture/android/device_info_android.cc @@ -217,9 +217,8 @@ int32_t DeviceInfoAndroid::CreateCapabilityMap( return _captureCapabilities.size(); } -int32_t DeviceInfoAndroid::GetOrientation( - const char* deviceUniqueIdUTF8, - VideoCaptureRotation& orientation) { +int32_t DeviceInfoAndroid::GetOrientation(const char* deviceUniqueIdUTF8, + VideoRotation& orientation) { const AndroidCameraInfo* info = FindCameraInfoByName(deviceUniqueIdUTF8); if (info == NULL || VideoCaptureImpl::RotationFromDegrees(info->orientation, diff --git a/webrtc/modules/video_capture/android/device_info_android.h b/webrtc/modules/video_capture/android/device_info_android.h index 542cbba088..581312bcb3 100644 --- a/webrtc/modules/video_capture/android/device_info_android.h +++ b/webrtc/modules/video_capture/android/device_info_android.h @@ -52,7 +52,7 @@ class DeviceInfoAndroid : public DeviceInfoImpl { uint32_t /*positionX*/, uint32_t /*positionY*/) { return -1; } virtual int32_t GetOrientation(const char* deviceUniqueIdUTF8, - VideoCaptureRotation& orientation); + VideoRotation& orientation); // Populate |min_mfps| and |max_mfps| with the closest supported range of the // device to |max_fps_to_match|. diff --git a/webrtc/modules/video_capture/android/video_capture_android.cc b/webrtc/modules/video_capture/android/video_capture_android.cc index fa4dcdaa60..272cec42f9 100644 --- a/webrtc/modules/video_capture/android/video_capture_android.cc +++ b/webrtc/modules/video_capture/android/video_capture_android.cc @@ -111,12 +111,12 @@ int32_t VideoCaptureAndroid::OnIncomingFrame(uint8_t* videoFrame, int64_t captureTime) { if (!_captureStarted) return 0; - VideoCaptureRotation current_rotation = - (degrees <= 45 || degrees > 315) ? kCameraRotate0 : - (degrees > 45 && degrees <= 135) ? kCameraRotate90 : - (degrees > 135 && degrees <= 225) ? kCameraRotate180 : - (degrees > 225 && degrees <= 315) ? kCameraRotate270 : - kCameraRotate0; // Impossible. + VideoRotation current_rotation = + (degrees <= 45 || degrees > 315) ? kVideoRotation_0 : + (degrees > 45 && degrees <= 135) ? kVideoRotation_90 : + (degrees > 135 && degrees <= 225) ? kVideoRotation_180 : + (degrees > 225 && degrees <= 315) ? kVideoRotation_270 : + kVideoRotation_0; // Impossible. if (_rotation != current_rotation) { LOG(LS_INFO) << "New camera rotation: " << degrees; _rotation = current_rotation; @@ -157,7 +157,7 @@ int32_t VideoCaptureAndroid::Init(const int32_t id, _jCapturer = env->NewGlobalRef( env->NewObject(g_java_capturer_class, ctor, camera_id, j_this)); assert(_jCapturer); - _rotation = kCameraRotate0; + _rotation = kVideoRotation_0; return 0; } @@ -232,8 +232,7 @@ int32_t VideoCaptureAndroid::CaptureSettings( return 0; } -int32_t VideoCaptureAndroid::SetCaptureRotation( - VideoCaptureRotation rotation) { +int32_t VideoCaptureAndroid::SetCaptureRotation(VideoRotation rotation) { int32_t status = VideoCaptureImpl::SetCaptureRotation(rotation); if (status != 0) return status; diff --git a/webrtc/modules/video_capture/android/video_capture_android.h b/webrtc/modules/video_capture/android/video_capture_android.h index 74de7a9ba0..8c1e7d3c8b 100644 --- a/webrtc/modules/video_capture/android/video_capture_android.h +++ b/webrtc/modules/video_capture/android/video_capture_android.h @@ -28,7 +28,7 @@ class VideoCaptureAndroid : public VideoCaptureImpl { virtual int32_t StopCapture(); virtual bool CaptureStarted(); virtual int32_t CaptureSettings(VideoCaptureCapability& settings); - virtual int32_t SetCaptureRotation(VideoCaptureRotation rotation); + virtual int32_t SetCaptureRotation(VideoRotation rotation); int32_t OnIncomingFrame(uint8_t* videoFrame, size_t videoFrameLength, @@ -41,7 +41,7 @@ class VideoCaptureAndroid : public VideoCaptureImpl { DeviceInfoAndroid _deviceInfo; jobject _jCapturer; // Global ref to Java VideoCaptureAndroid object. VideoCaptureCapability _captureCapability; - VideoCaptureRotation _rotation; + VideoRotation _rotation; bool _captureStarted; }; diff --git a/webrtc/modules/video_capture/device_info_impl.cc b/webrtc/modules/video_capture/device_info_impl.cc index 7db6103fec..3ad8790628 100644 --- a/webrtc/modules/video_capture/device_info_impl.cc +++ b/webrtc/modules/video_capture/device_info_impl.cc @@ -351,9 +351,8 @@ int32_t DeviceInfoImpl::GetExpectedCaptureDelay( //Default implementation. This should be overridden by Mobile implementations. int32_t DeviceInfoImpl::GetOrientation(const char* deviceUniqueIdUTF8, - VideoCaptureRotation& orientation) -{ - orientation = kCameraRotate0; + VideoRotation& orientation) { + orientation = kVideoRotation_0; return -1; } } // namespace videocapturemodule diff --git a/webrtc/modules/video_capture/device_info_impl.h b/webrtc/modules/video_capture/device_info_impl.h index f0e66f44de..2573b2ef98 100644 --- a/webrtc/modules/video_capture/device_info_impl.h +++ b/webrtc/modules/video_capture/device_info_impl.h @@ -36,9 +36,8 @@ public: const char* deviceUniqueIdUTF8, const VideoCaptureCapability& requested, VideoCaptureCapability& resulting); - virtual int32_t GetOrientation( - const char* deviceUniqueIdUTF8, - VideoCaptureRotation& orientation); + virtual int32_t GetOrientation(const char* deviceUniqueIdUTF8, + VideoRotation& orientation); protected: /* Initialize this object*/ diff --git a/webrtc/modules/video_capture/include/mock/mock_video_capture.h b/webrtc/modules/video_capture/include/mock/mock_video_capture.h index 9013820090..0a15c445ed 100644 --- a/webrtc/modules/video_capture/include/mock/mock_video_capture.h +++ b/webrtc/modules/video_capture/include/mock/mock_video_capture.h @@ -38,7 +38,7 @@ class MockVideoCaptureModule : public VideoCaptureModule { MOCK_METHOD1(CaptureSettings, int32_t(VideoCaptureCapability& settings)); MOCK_METHOD1(SetCaptureDelay, void(int32_t delayMS)); MOCK_METHOD0(CaptureDelay, int32_t()); - MOCK_METHOD1(SetCaptureRotation, int32_t(VideoCaptureRotation rotation)); + MOCK_METHOD1(SetCaptureRotation, int32_t(VideoRotation rotation)); MOCK_METHOD1(SetApplyRotation, bool(bool)); MOCK_METHOD0(GetApplyRotation, bool()); MOCK_METHOD1(GetEncodeInterface, diff --git a/webrtc/modules/video_capture/include/video_capture.h b/webrtc/modules/video_capture/include/video_capture.h index 4f943177f6..09b4502115 100644 --- a/webrtc/modules/video_capture/include/video_capture.h +++ b/webrtc/modules/video_capture/include/video_capture.h @@ -11,6 +11,7 @@ #ifndef WEBRTC_MODULES_VIDEO_CAPTURE_INCLUDE_VIDEO_CAPTURE_H_ #define WEBRTC_MODULES_VIDEO_CAPTURE_INCLUDE_VIDEO_CAPTURE_H_ +#include "webrtc/common_video/rotation.h" #include "webrtc/modules/interface/module.h" #include "webrtc/modules/video_capture/include/video_capture_defines.h" @@ -52,9 +53,8 @@ class VideoCaptureModule: public RefCountedModule { // Gets clockwise angle the captured frames should be rotated in order // to be displayed correctly on a normally rotated display. - virtual int32_t GetOrientation( - const char* deviceUniqueIdUTF8, - VideoCaptureRotation& orientation) = 0; + virtual int32_t GetOrientation(const char* deviceUniqueIdUTF8, + VideoRotation& orientation) = 0; // Gets the capability that best matches the requested width, height and // frame rate. @@ -133,7 +133,7 @@ class VideoCaptureModule: public RefCountedModule { // If the rotation is set to the same as returned by // DeviceInfo::GetOrientation the captured frames are // displayed correctly if rendered. - virtual int32_t SetCaptureRotation(VideoCaptureRotation rotation) = 0; + virtual int32_t SetCaptureRotation(VideoRotation rotation) = 0; // Tells the capture module whether to apply the pending rotation. By default, // the rotation is applied and the generated frame is up right. When set to diff --git a/webrtc/modules/video_capture/include/video_capture_defines.h b/webrtc/modules/video_capture/include/video_capture_defines.h index ea7939d5a7..93a03f331d 100644 --- a/webrtc/modules/video_capture/include/video_capture_defines.h +++ b/webrtc/modules/video_capture/include/video_capture_defines.h @@ -26,15 +26,6 @@ enum {kVideoCaptureUniqueNameLength =1024}; //Max unique capture device name len enum {kVideoCaptureDeviceNameLength =256}; //Max capture device name lenght enum {kVideoCaptureProductIdLength =128}; //Max product id length -// Enums -enum VideoCaptureRotation -{ - kCameraRotate0 = 0, - kCameraRotate90 = 5, - kCameraRotate180 = 10, - kCameraRotate270 = 15 -}; - struct VideoCaptureCapability { int32_t width; diff --git a/webrtc/modules/video_capture/ios/device_info_ios.h b/webrtc/modules/video_capture/ios/device_info_ios.h index bb2ec8c600..476e919833 100644 --- a/webrtc/modules/video_capture/ios/device_info_ios.h +++ b/webrtc/modules/video_capture/ios/device_info_ios.h @@ -51,7 +51,7 @@ class DeviceInfoIos : public DeviceInfoImpl { uint32_t positionY) OVERRIDE; virtual int32_t GetOrientation(const char* deviceUniqueIdUTF8, - VideoCaptureRotation& orientation) OVERRIDE; + VideoRotation& orientation) OVERRIDE; virtual int32_t CreateCapabilityMap( const char* device_unique_id_utf8) OVERRIDE; diff --git a/webrtc/modules/video_capture/ios/device_info_ios.mm b/webrtc/modules/video_capture/ios/device_info_ios.mm index dea9fc34a4..21206ea50c 100644 --- a/webrtc/modules/video_capture/ios/device_info_ios.mm +++ b/webrtc/modules/video_capture/ios/device_info_ios.mm @@ -98,11 +98,11 @@ int32_t DeviceInfoIos::DisplayCaptureSettingsDialogBox( } int32_t DeviceInfoIos::GetOrientation(const char* deviceUniqueIdUTF8, - VideoCaptureRotation& orientation) { + VideoRotation& orientation) { if (strcmp(deviceUniqueIdUTF8, "Front Camera") == 0) { - orientation = kCameraRotate0; + orientation = kVideoRotation_0; } else { - orientation = kCameraRotate90; + orientation = kVideoRotation_90; } return orientation; } diff --git a/webrtc/modules/video_capture/ios/rtc_video_capture_ios_objc.h b/webrtc/modules/video_capture/ios/rtc_video_capture_ios_objc.h index 7d4147b430..2653958130 100644 --- a/webrtc/modules/video_capture/ios/rtc_video_capture_ios_objc.h +++ b/webrtc/modules/video_capture/ios/rtc_video_capture_ios_objc.h @@ -23,7 +23,7 @@ @interface RTCVideoCaptureIosObjC : NSObject -@property webrtc::VideoCaptureRotation frameRotation; +@property webrtc::VideoRotation frameRotation; // custom initializer. Instance of VideoCaptureIos is needed // for callback purposes. diff --git a/webrtc/modules/video_capture/test/video_capture_unittest.cc b/webrtc/modules/video_capture/test/video_capture_unittest.cc index 2909fe2d66..974b1c93b4 100644 --- a/webrtc/modules/video_capture/test/video_capture_unittest.cc +++ b/webrtc/modules/video_capture/test/video_capture_unittest.cc @@ -92,13 +92,12 @@ static bool CompareFrames(const webrtc::I420VideoFrame& frame1, class TestVideoCaptureCallback : public VideoCaptureDataCallback { public: TestVideoCaptureCallback() - : capture_cs_(CriticalSectionWrapper::CreateCriticalSection()), - capture_delay_(-1), - last_render_time_ms_(0), - incoming_frames_(0), - timing_warnings_(0), - rotate_frame_(webrtc::kCameraRotate0){ - } + : capture_cs_(CriticalSectionWrapper::CreateCriticalSection()), + capture_delay_(-1), + last_render_time_ms_(0), + incoming_frames_(0), + timing_warnings_(0), + rotate_frame_(webrtc::kVideoRotation_0) {} ~TestVideoCaptureCallback() { if (timing_warnings_ > 0) @@ -116,8 +115,8 @@ class TestVideoCaptureCallback : public VideoCaptureDataCallback { EXPECT_TRUE(height == capability_.height || height == capability_.width); EXPECT_TRUE(width == capability_.width || width == capability_.height); #else - if (rotate_frame_ == webrtc::kCameraRotate90 || - rotate_frame_ == webrtc::kCameraRotate270) { + if (rotate_frame_ == webrtc::kVideoRotation_90 || + rotate_frame_ == webrtc::kVideoRotation_270) { EXPECT_EQ(width, capability_.height); EXPECT_EQ(height, capability_.width); } else { @@ -186,7 +185,7 @@ class TestVideoCaptureCallback : public VideoCaptureDataCallback { return CompareFrames(last_frame_, frame); } - void SetExpectedCaptureRotation(webrtc::VideoCaptureRotation rotation) { + void SetExpectedCaptureRotation(webrtc::VideoRotation rotation) { CriticalSectionScoped cs(capture_cs_.get()); rotate_frame_ = rotation; } @@ -199,7 +198,7 @@ class TestVideoCaptureCallback : public VideoCaptureDataCallback { int incoming_frames_; int timing_warnings_; webrtc::I420VideoFrame last_frame_; - webrtc::VideoCaptureRotation rotate_frame_; + webrtc::VideoRotation rotate_frame_; }; class TestVideoCaptureFeedBack : public VideoCaptureFeedBack { @@ -595,7 +594,7 @@ TEST_F(VideoCaptureExternalTest, DISABLED_ON_WIN(FrameRate)) { } TEST_F(VideoCaptureExternalTest, Rotation) { - EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kCameraRotate0)); + EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_0)); size_t length = webrtc::CalcBufferSize(webrtc::kI420, test_frame_.width(), test_frame_.height()); @@ -603,16 +602,16 @@ TEST_F(VideoCaptureExternalTest, Rotation) { webrtc::ExtractBuffer(test_frame_, length, test_buffer.get()); EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), length, capture_callback_.capability(), 0)); - EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kCameraRotate90)); - capture_callback_.SetExpectedCaptureRotation(webrtc::kCameraRotate90); + EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_90)); + capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_90); EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), length, capture_callback_.capability(), 0)); - EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kCameraRotate180)); - capture_callback_.SetExpectedCaptureRotation(webrtc::kCameraRotate180); + EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_180)); + capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_180); EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), length, capture_callback_.capability(), 0)); - EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kCameraRotate270)); - capture_callback_.SetExpectedCaptureRotation(webrtc::kCameraRotate270); + EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_270)); + capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_270); EXPECT_EQ(0, capture_input_interface_->IncomingFrame(test_buffer.get(), length, capture_callback_.capability(), 0)); } diff --git a/webrtc/modules/video_capture/video_capture_impl.cc b/webrtc/modules/video_capture/video_capture_impl.cc index ec88ecd6ee..1b780c4cba 100644 --- a/webrtc/modules/video_capture/video_capture_impl.cc +++ b/webrtc/modules/video_capture/video_capture_impl.cc @@ -60,19 +60,19 @@ const char* VideoCaptureImpl::CurrentDeviceName() const // static int32_t VideoCaptureImpl::RotationFromDegrees(int degrees, - VideoCaptureRotation* rotation) { + VideoRotation* rotation) { switch (degrees) { case 0: - *rotation = kCameraRotate0; + *rotation = kVideoRotation_0; return 0; case 90: - *rotation = kCameraRotate90; + *rotation = kVideoRotation_90; return 0; case 180: - *rotation = kCameraRotate180; + *rotation = kVideoRotation_180; return 0; case 270: - *rotation = kCameraRotate270; + *rotation = kVideoRotation_270; return 0; default: return -1;; @@ -80,19 +80,19 @@ int32_t VideoCaptureImpl::RotationFromDegrees(int degrees, } // static -int32_t VideoCaptureImpl::RotationInDegrees(VideoCaptureRotation rotation, +int32_t VideoCaptureImpl::RotationInDegrees(VideoRotation rotation, int* degrees) { switch (rotation) { - case kCameraRotate0: + case kVideoRotation_0: *degrees = 0; return 0; - case kCameraRotate90: + case kVideoRotation_90: *degrees = 90; return 0; - case kCameraRotate180: + case kVideoRotation_180: *degrees = 180; return 0; - case kCameraRotate270: + case kVideoRotation_270: *degrees = 270; return 0; } @@ -359,20 +359,20 @@ int32_t VideoCaptureImpl::IncomingI420VideoFrame(I420VideoFrame* video_frame, return 0; } -int32_t VideoCaptureImpl::SetCaptureRotation(VideoCaptureRotation rotation) { +int32_t VideoCaptureImpl::SetCaptureRotation(VideoRotation rotation) { CriticalSectionScoped cs(&_apiCs); CriticalSectionScoped cs2(&_callBackCs); switch (rotation){ - case kCameraRotate0: + case kVideoRotation_0: _rotateFrame = kRotateNone; break; - case kCameraRotate90: + case kVideoRotation_90: _rotateFrame = kRotate90; break; - case kCameraRotate180: + case kVideoRotation_180: _rotateFrame = kRotate180; break; - case kCameraRotate270: + case kVideoRotation_270: _rotateFrame = kRotate270; break; default: diff --git a/webrtc/modules/video_capture/video_capture_impl.h b/webrtc/modules/video_capture/video_capture_impl.h index aba15f2ac0..1ec13c8228 100644 --- a/webrtc/modules/video_capture/video_capture_impl.h +++ b/webrtc/modules/video_capture/video_capture_impl.h @@ -52,11 +52,9 @@ public: static DeviceInfo* CreateDeviceInfo(const int32_t id); // Helpers for converting between (integral) degrees and - // VideoCaptureRotation values. Return 0 on success. - static int32_t RotationFromDegrees(int degrees, - VideoCaptureRotation* rotation); - static int32_t RotationInDegrees(VideoCaptureRotation rotation, - int* degrees); + // VideoRotation values. Return 0 on success. + static int32_t RotationFromDegrees(int degrees, VideoRotation* rotation); + static int32_t RotationInDegrees(VideoRotation rotation, int* degrees); //Call backs virtual void RegisterCaptureDataCallback( @@ -67,7 +65,7 @@ public: virtual void SetCaptureDelay(int32_t delayMS); virtual int32_t CaptureDelay(); - virtual int32_t SetCaptureRotation(VideoCaptureRotation rotation); + virtual int32_t SetCaptureRotation(VideoRotation rotation); virtual bool SetApplyRotation(bool enable); virtual bool GetApplyRotation() { return apply_rotation_; diff --git a/webrtc/video_engine/include/vie_capture.h b/webrtc/video_engine/include/vie_capture.h index a602a5b74e..caaeacef2f 100644 --- a/webrtc/video_engine/include/vie_capture.h +++ b/webrtc/video_engine/include/vie_capture.h @@ -20,6 +20,7 @@ #include "webrtc/common_types.h" #include "webrtc/common_video/interface/i420_video_frame.h" +#include "webrtc/common_video/rotation.h" namespace webrtc { @@ -60,13 +61,6 @@ enum CaptureAlarm { AlarmCleared = 1 }; -enum RotateCapturedFrame { - RotateCapturedFrame_0 = 0, - RotateCapturedFrame_90 = 90, - RotateCapturedFrame_180 = 180, - RotateCapturedFrame_270 = 270 -}; - struct ViEVideoFrameI420 { ViEVideoFrameI420() { y_plane = NULL; @@ -203,8 +197,8 @@ class WEBRTC_DLLEXPORT ViECapture { // Rotates captured frames before encoding and sending. // Used on mobile devices with rotates cameras. - virtual int SetRotateCapturedFrames(const int capture_id, - const RotateCapturedFrame rotation) = 0; + virtual int SetVideoRotation(const int capture_id, + const VideoRotation rotation) = 0; // This function sets the expected delay from when a video frame is captured // to when that frame is delivered to VideoEngine. @@ -237,7 +231,7 @@ class WEBRTC_DLLEXPORT ViECapture { // order to display the frames correctly if the display is rotated in its // natural orientation. virtual int GetOrientation(const char* unique_id_utf8, - RotateCapturedFrame& orientation) = 0; + VideoRotation& orientation) = 0; // Enables brightness alarm detection and the brightness alarm callback. virtual int EnableBrightnessAlarm(const int capture_id, diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_capture.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_capture.cc index 3f3c3a614b..68b1afda02 100644 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_capture.cc +++ b/webrtc/video_engine/test/auto_test/source/vie_autotest_capture.cc @@ -360,26 +360,26 @@ void ViEAutoTest::ViECaptureAPITest() { EXPECT_EQ(kViECaptureDeviceDoesNotExist, video_engine.LastError()); // Test GetOrientation. - webrtc::VideoCaptureRotation orientation; + webrtc::VideoRotation orientation; char dummy_name[5]; EXPECT_NE(0, dev_info->GetOrientation(dummy_name, orientation)); // Test SetRotation. - EXPECT_NE(0, video_engine.capture->SetRotateCapturedFrames( - capture_id, webrtc::RotateCapturedFrame_90)); + EXPECT_NE(0, video_engine.capture->SetVideoRotation( + capture_id, webrtc::kVideoRotation_90)); EXPECT_EQ(kViECaptureDeviceDoesNotExist, video_engine.LastError()); // Allocate capture device. EXPECT_EQ(0, video_engine.capture->AllocateCaptureDevice(*vcpm, capture_id)); - EXPECT_EQ(0, video_engine.capture->SetRotateCapturedFrames( - capture_id, webrtc::RotateCapturedFrame_0)); - EXPECT_EQ(0, video_engine.capture->SetRotateCapturedFrames( - capture_id, webrtc::RotateCapturedFrame_90)); - EXPECT_EQ(0, video_engine.capture->SetRotateCapturedFrames( - capture_id, webrtc::RotateCapturedFrame_180)); - EXPECT_EQ(0, video_engine.capture->SetRotateCapturedFrames( - capture_id, webrtc::RotateCapturedFrame_270)); + EXPECT_EQ(0, video_engine.capture->SetVideoRotation( + capture_id, webrtc::kVideoRotation_0)); + EXPECT_EQ(0, video_engine.capture->SetVideoRotation( + capture_id, webrtc::kVideoRotation_90)); + EXPECT_EQ(0, video_engine.capture->SetVideoRotation( + capture_id, webrtc::kVideoRotation_180)); + EXPECT_EQ(0, video_engine.capture->SetVideoRotation( + capture_id, webrtc::kVideoRotation_270)); // Release the capture device EXPECT_EQ(0, video_engine.capture->ReleaseCaptureDevice(capture_id)); diff --git a/webrtc/video_engine/vie_capture_impl.cc b/webrtc/video_engine/vie_capture_impl.cc index 9581fb7f2c..171d646c95 100644 --- a/webrtc/video_engine/vie_capture_impl.cc +++ b/webrtc/video_engine/vie_capture_impl.cc @@ -252,26 +252,10 @@ int ViECaptureImpl::StopCapture(const int capture_id) { return 0; } -int ViECaptureImpl::SetRotateCapturedFrames( - const int capture_id, - const RotateCapturedFrame rotation) { - int i_rotation = -1; - switch (rotation) { - case RotateCapturedFrame_0: - i_rotation = 0; - break; - case RotateCapturedFrame_90: - i_rotation = 90; - break; - case RotateCapturedFrame_180: - i_rotation = 180; - break; - case RotateCapturedFrame_270: - i_rotation = 270; - break; - } - LOG(LS_INFO) << "SetRotateCaptureFrames for " << capture_id - << ", rotation " << i_rotation; +int ViECaptureImpl::SetVideoRotation(const int capture_id, + const VideoRotation rotation) { + LOG(LS_INFO) << "SetRotateCaptureFrames for " << capture_id << ", rotation " + << static_cast(rotation); ViEInputManagerScoped is(*(shared_data_->input_manager())); ViECapturer* vie_capture = is.Capture(capture_id); @@ -279,7 +263,7 @@ int ViECaptureImpl::SetRotateCapturedFrames( shared_data_->SetLastError(kViECaptureDeviceDoesNotExist); return -1; } - if (vie_capture->SetRotateCapturedFrames(rotation) != 0) { + if (vie_capture->SetVideoRotation(rotation) != 0) { shared_data_->SetLastError(kViECaptureDeviceUnknownError); return -1; } @@ -367,7 +351,7 @@ int ViECaptureImpl::ShowCaptureSettingsDialogBox( } int ViECaptureImpl::GetOrientation(const char* unique_idUTF8, - RotateCapturedFrame& orientation) { + VideoRotation& orientation) { if (shared_data_->input_manager()->GetOrientation( unique_idUTF8, orientation) != 0) { diff --git a/webrtc/video_engine/vie_capture_impl.h b/webrtc/video_engine/vie_capture_impl.h index 541f7a2473..99be9366b6 100644 --- a/webrtc/video_engine/vie_capture_impl.h +++ b/webrtc/video_engine/vie_capture_impl.h @@ -47,8 +47,8 @@ class ViECaptureImpl const int capture_id, const CaptureCapability& capture_capability = CaptureCapability()); virtual int StopCapture(const int capture_id); - virtual int SetRotateCapturedFrames(const int capture_id, - const RotateCapturedFrame rotation); + virtual int SetVideoRotation(const int capture_id, + const VideoRotation rotation); virtual int SetCaptureDelay(const int capture_id, const unsigned int capture_delay_ms); virtual int NumberOfCapabilities(const char* unique_idUTF8, @@ -62,7 +62,7 @@ class ViECaptureImpl const char* dialog_title, void* parent_window = NULL, const unsigned int x = 200, const unsigned int y = 200); virtual int GetOrientation(const char* unique_idUTF8, - RotateCapturedFrame& orientation); + VideoRotation& orientation); virtual int EnableBrightnessAlarm(const int capture_id, const bool enable); virtual int RegisterObserver(const int capture_id, ViECaptureObserver& observer); diff --git a/webrtc/video_engine/vie_capturer.cc b/webrtc/video_engine/vie_capturer.cc index 0a2de137ab..76aef1f4dd 100644 --- a/webrtc/video_engine/vie_capturer.cc +++ b/webrtc/video_engine/vie_capturer.cc @@ -255,24 +255,8 @@ int32_t ViECapturer::SetCaptureDelay(int32_t delay_ms) { return 0; } -int32_t ViECapturer::SetRotateCapturedFrames( - const RotateCapturedFrame rotation) { - VideoCaptureRotation converted_rotation = kCameraRotate0; - switch (rotation) { - case RotateCapturedFrame_0: - converted_rotation = kCameraRotate0; - break; - case RotateCapturedFrame_90: - converted_rotation = kCameraRotate90; - break; - case RotateCapturedFrame_180: - converted_rotation = kCameraRotate180; - break; - case RotateCapturedFrame_270: - converted_rotation = kCameraRotate270; - break; - } - return capture_module_->SetCaptureRotation(converted_rotation); +int32_t ViECapturer::SetVideoRotation(const VideoRotation rotation) { + return capture_module_->SetCaptureRotation(rotation); } int ViECapturer::IncomingFrame(unsigned char* video_frame, diff --git a/webrtc/video_engine/vie_capturer.h b/webrtc/video_engine/vie_capturer.h index 401db79650..35f2278170 100644 --- a/webrtc/video_engine/vie_capturer.h +++ b/webrtc/video_engine/vie_capturer.h @@ -90,7 +90,7 @@ class ViECapturer int32_t SetCaptureDelay(int32_t delay_ms); // Sets rotation of the incoming captured frame. - int32_t SetRotateCapturedFrames(const RotateCapturedFrame rotation); + int32_t SetVideoRotation(const VideoRotation rotation); // Effect filter. int32_t RegisterEffectFilter(ViEEffectFilter* effect_filter); diff --git a/webrtc/video_engine/vie_input_manager.cc b/webrtc/video_engine/vie_input_manager.cc index 68570e51cf..c790e3866e 100644 --- a/webrtc/video_engine/vie_input_manager.cc +++ b/webrtc/video_engine/vie_input_manager.cc @@ -116,31 +116,14 @@ int ViEInputManager::GetCaptureCapability( } int ViEInputManager::GetOrientation(const char* device_unique_idUTF8, - RotateCapturedFrame& orientation) { + VideoRotation& orientation) { CriticalSectionScoped cs(device_info_cs_.get()); if (capture_device_info_ == NULL) capture_device_info_ = VideoCaptureFactory::CreateDeviceInfo( ViEModuleId(engine_id_)); assert(capture_device_info_); - VideoCaptureRotation module_orientation; - int result = capture_device_info_->GetOrientation(device_unique_idUTF8, - module_orientation); - // Copy from module type to public type. - switch (module_orientation) { - case kCameraRotate0: - orientation = RotateCapturedFrame_0; - break; - case kCameraRotate90: - orientation = RotateCapturedFrame_90; - break; - case kCameraRotate180: - orientation = RotateCapturedFrame_180; - break; - case kCameraRotate270: - orientation = RotateCapturedFrame_270; - break; - } - return result; + return capture_device_info_->GetOrientation(device_unique_idUTF8, + orientation); } int ViEInputManager::DisplayCaptureSettingsDialogBox( diff --git a/webrtc/video_engine/vie_input_manager.h b/webrtc/video_engine/vie_input_manager.h index a4db9a70fe..f55a2926d0 100644 --- a/webrtc/video_engine/vie_input_manager.h +++ b/webrtc/video_engine/vie_input_manager.h @@ -16,6 +16,7 @@ #include "webrtc/modules/video_capture/include/video_capture.h" #include "webrtc/system_wrappers/interface/scoped_ptr.h" #include "webrtc/typedefs.h" +#include "webrtc/common_video/rotation.h" #include "webrtc/video_engine/include/vie_capture.h" #include "webrtc/video_engine/vie_defines.h" #include "webrtc/video_engine/vie_frame_provider_base.h" @@ -64,7 +65,7 @@ class ViEInputManager : private ViEManagerBase { uint32_t positionX, uint32_t positionY); int GetOrientation(const char* device_unique_idUTF8, - RotateCapturedFrame& orientation); + VideoRotation& orientation); // Creates a capture module for the specified capture device and assigns // a capture device id for the device.