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
This commit is contained in:
guoweis@webrtc.org 2015-02-13 14:31:26 +00:00
parent a8cc3440b1
commit 5a7dc39277
29 changed files with 110 additions and 181 deletions

View File

@ -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(

View File

@ -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 {

View File

@ -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));

View File

@ -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<jint>(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<webrtc::RotateCapturedFrame>(degrees));
return vie_data->capture->SetVideoRotation(
capture_id, static_cast<webrtc::VideoRotation>(degrees));
}
JOWW(jint, VideoEngine_setNackStatus)(JNIEnv* jni, jobject j_vie, jint channel,

View File

@ -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);
}
}

View File

@ -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) {

View File

@ -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,

View File

@ -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|.

View File

@ -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;

View File

@ -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;
};

View File

@ -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

View File

@ -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*/

View File

@ -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,

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -23,7 +23,7 @@
@interface RTCVideoCaptureIosObjC
: NSObject<AVCaptureVideoDataOutputSampleBufferDelegate>
@property webrtc::VideoCaptureRotation frameRotation;
@property webrtc::VideoRotation frameRotation;
// custom initializer. Instance of VideoCaptureIos is needed
// for callback purposes.

View File

@ -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));
}

View File

@ -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:

View File

@ -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_;

View File

@ -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,

View File

@ -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));

View File

@ -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<int>(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) {

View File

@ -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);

View File

@ -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,

View File

@ -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);

View File

@ -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(

View File

@ -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.