diff --git a/talk/media/base/nullvideoframe.h b/talk/media/base/nullvideoframe.h index fce8545d8..26741ad46 100644 --- a/talk/media/base/nullvideoframe.h +++ b/talk/media/base/nullvideoframe.h @@ -35,18 +35,10 @@ namespace cricket { // Simple subclass for use in mocks. class NullVideoFrame : public VideoFrame { public: - virtual bool Reset(uint32 format, - int w, - int h, - int dw, - int dh, - uint8* sample, - size_t sample_size, - size_t pixel_width, - size_t pixel_height, - int64 elapsed_time, - int64 time_stamp, - webrtc::kVideoRotation rotation) { + virtual bool Reset(uint32 format, int w, int h, int dw, int dh, uint8 *sample, + size_t sample_size, size_t pixel_width, + size_t pixel_height, int64 elapsed_time, int64 time_stamp, + int rotation) { return false; } virtual bool InitToBlack(int w, int h, size_t pixel_width, @@ -73,9 +65,7 @@ class NullVideoFrame : public VideoFrame { virtual int64 GetTimeStamp() const { return 0; } virtual void SetElapsedTime(int64 elapsed_time) {} virtual void SetTimeStamp(int64 time_stamp) {} - virtual webrtc::kVideoRotation GetRotation() const { - return webrtc::kVideoRotation_0; - } + virtual int GetRotation() const { return 0; } virtual VideoFrame *Copy() const { return NULL; } diff --git a/talk/media/base/videocapturer.cc b/talk/media/base/videocapturer.cc index 7a2619809..f26b2ce49 100644 --- a/talk/media/base/videocapturer.cc +++ b/talk/media/base/videocapturer.cc @@ -98,11 +98,6 @@ bool CapturedFrame::GetDataSize(uint32* size) const { return true; } -webrtc::kVideoRotation CapturedFrame::GetRotation() const { - ASSERT(rotation == 0 || rotation == 90 || rotation == 180 || rotation == 270); - return static_cast(rotation); -} - ///////////////////////////////////////////////////////////////////// // Implementation of class VideoCapturer ///////////////////////////////////////////////////////////////////// diff --git a/talk/media/base/videocapturer.h b/talk/media/base/videocapturer.h index d088d3a9f..98d9f764b 100644 --- a/talk/media/base/videocapturer.h +++ b/talk/media/base/videocapturer.h @@ -79,10 +79,6 @@ struct CapturedFrame { // fourcc. Return true if succeeded. bool GetDataSize(uint32* size) const; - // TODO(guoweis): Change the type of |rotation| from int to - // webrtc::kVideoRotation once chromium gets the code. - webrtc::kVideoRotation GetRotation() const; - // The width and height of the captured frame could be different from those // of VideoFormat. Once the first frame is captured, the width, height, // fourcc, pixel_width, and pixel_height should keep the same over frames. @@ -96,11 +92,7 @@ struct CapturedFrame { int64 time_stamp; // timestamp of when the frame was captured, in unix // time with nanosecond units. uint32 data_size; // number of bytes of the frame data - - // TODO(guoweis): This can't be converted to kVideoRotation yet as it's - // used by chrome now. int rotation; // rotation in degrees of the frame (0, 90, 180, 270) - void* data; // pointer to the frame data. This object allocates the // memory or points to an existing memory. diff --git a/talk/media/base/videoframe.h b/talk/media/base/videoframe.h index b44c5f724..1c499e070 100644 --- a/talk/media/base/videoframe.h +++ b/talk/media/base/videoframe.h @@ -30,10 +30,17 @@ #include "webrtc/base/basictypes.h" #include "webrtc/base/stream.h" -#include "webrtc/common_video/rotation.h" namespace cricket { +// Simple rotation constants. +enum { + ROTATION_0 = 0, + ROTATION_90 = 90, + ROTATION_180 = 180, + ROTATION_270 = 270 +}; + // Represents a YUV420 (a.k.a. I420) video frame. class VideoFrame { public: @@ -48,18 +55,10 @@ class VideoFrame { // |dw| is destination width; can be less than |w| if cropping is desired. // |dh| is destination height, like |dw|, but must be a positive number. // Returns whether the function succeeded or failed. - virtual bool Reset(uint32 fourcc, - int w, - int h, - int dw, - int dh, - uint8* sample, - size_t sample_size, - size_t pixel_width, - size_t pixel_height, - int64_t elapsed_time, - int64_t time_stamp, - webrtc::kVideoRotation rotation) = 0; + virtual bool Reset(uint32 fourcc, int w, int h, int dw, int dh, uint8 *sample, + size_t sample_size, size_t pixel_width, + size_t pixel_height, int64_t elapsed_time, + int64_t time_stamp, int rotation) = 0; // Basic accessors. virtual size_t GetWidth() const = 0; @@ -95,7 +94,7 @@ class VideoFrame { virtual void SetTimeStamp(int64_t time_stamp) = 0; // Indicates the rotation angle in degrees. - virtual webrtc::kVideoRotation GetRotation() const = 0; + virtual int GetRotation() const = 0; // Make a shallow copy of the frame. The frame buffer itself is not copied. // Both the current and new VideoFrame will share a single reference-counted diff --git a/talk/media/base/videoframe_unittest.h b/talk/media/base/videoframe_unittest.h index cc6735886..483fc34d8 100644 --- a/talk/media/base/videoframe_unittest.h +++ b/talk/media/base/videoframe_unittest.h @@ -42,7 +42,6 @@ #include "webrtc/base/pathutils.h" #include "webrtc/base/stream.h" #include "webrtc/base/stringutils.h" -#include "webrtc/common_video/rotation.h" #if defined(_MSC_VER) #define ALIGN16(var) __declspec(align(16)) var @@ -84,16 +83,11 @@ class VideoFrameTest : public testing::Test { bool LoadFrame(const std::string& filename, uint32 format, int32 width, int32 height, T* frame) { - return LoadFrame(filename, format, width, height, width, abs(height), - webrtc::kVideoRotation_0, frame); + return LoadFrame(filename, format, width, height, + width, abs(height), 0, frame); } - bool LoadFrame(const std::string& filename, - uint32 format, - int32 width, - int32 height, - int dw, - int dh, - webrtc::kVideoRotation rotation, + bool LoadFrame(const std::string& filename, uint32 format, + int32 width, int32 height, int dw, int dh, int rotation, T* frame) { rtc::scoped_ptr ms(LoadSample(filename)); return LoadFrame(ms.get(), format, width, height, dw, dh, rotation, frame); @@ -101,16 +95,11 @@ class VideoFrameTest : public testing::Test { // Load a video frame from a memory stream. bool LoadFrame(rtc::MemoryStream* ms, uint32 format, int32 width, int32 height, T* frame) { - return LoadFrame(ms, format, width, height, width, abs(height), - webrtc::kVideoRotation_0, frame); + return LoadFrame(ms, format, width, height, + width, abs(height), 0, frame); } - bool LoadFrame(rtc::MemoryStream* ms, - uint32 format, - int32 width, - int32 height, - int dw, - int dh, - webrtc::kVideoRotation rotation, + bool LoadFrame(rtc::MemoryStream* ms, uint32 format, + int32 width, int32 height, int dw, int dh, int rotation, T* frame) { if (!ms) { return false; @@ -127,17 +116,11 @@ class VideoFrameTest : public testing::Test { // Load a frame from a raw buffer. bool LoadFrame(uint8* sample, size_t sample_size, uint32 format, int32 width, int32 height, T* frame) { - return LoadFrame(sample, sample_size, format, width, height, width, - abs(height), webrtc::kVideoRotation_0, frame); + return LoadFrame(sample, sample_size, format, width, height, + width, abs(height), 0, frame); } - bool LoadFrame(uint8* sample, - size_t sample_size, - uint32 format, - int32 width, - int32 height, - int dw, - int dh, - webrtc::kVideoRotation rotation, + bool LoadFrame(uint8* sample, size_t sample_size, uint32 format, + int32 width, int32 height, int dw, int dh, int rotation, T* frame) { bool ret = false; for (int i = 0; i < repeat_; ++i) { @@ -822,30 +805,32 @@ class VideoFrameTest : public testing::Test { // Macro to help test different rotations #define TEST_MIRROR(FOURCC, BPP) \ - void Construct##FOURCC##Mirror() { \ +void Construct##FOURCC##Mirror() { \ T frame1, frame2, frame3; \ - rtc::scoped_ptr ms( \ + rtc::scoped_ptr ms( \ CreateYuvSample(kWidth, kHeight, BPP)); \ ASSERT_TRUE(ms.get() != NULL); \ - EXPECT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_##FOURCC, kWidth, \ - -kHeight, kWidth, kHeight, \ - webrtc::kVideoRotation_180, &frame1)); \ + EXPECT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_##FOURCC, \ + kWidth, -kHeight, kWidth, kHeight, \ + cricket::ROTATION_180, &frame1)); \ size_t data_size; \ bool ret = ms->GetSize(&data_size); \ EXPECT_TRUE(ret); \ - EXPECT_TRUE(frame2.Init(cricket::FOURCC_##FOURCC, kWidth, kHeight, kWidth, \ - kHeight, \ + EXPECT_TRUE(frame2.Init(cricket::FOURCC_##FOURCC, \ + kWidth, kHeight, kWidth, kHeight, \ reinterpret_cast(ms->GetBuffer()), \ - data_size, 1, 1, 0, 0, webrtc::kVideoRotation_0)); \ + data_size, \ + 1, 1, 0, 0, 0)); \ int width_rotate = static_cast(frame1.GetWidth()); \ int height_rotate = static_cast(frame1.GetHeight()); \ EXPECT_TRUE(frame3.InitToBlack(width_rotate, height_rotate, 1, 1, 0, 0)); \ - libyuv::I420Mirror( \ - frame2.GetYPlane(), frame2.GetYPitch(), frame2.GetUPlane(), \ - frame2.GetUPitch(), frame2.GetVPlane(), frame2.GetVPitch(), \ - frame3.GetYPlane(), frame3.GetYPitch(), frame3.GetUPlane(), \ - frame3.GetUPitch(), frame3.GetVPlane(), frame3.GetVPitch(), kWidth, \ - kHeight); \ + libyuv::I420Mirror(frame2.GetYPlane(), frame2.GetYPitch(), \ + frame2.GetUPlane(), frame2.GetUPitch(), \ + frame2.GetVPlane(), frame2.GetVPitch(), \ + frame3.GetYPlane(), frame3.GetYPitch(), \ + frame3.GetUPlane(), frame3.GetUPitch(), \ + frame3.GetVPlane(), frame3.GetVPitch(), \ + kWidth, kHeight); \ EXPECT_TRUE(IsEqual(frame1, frame3, 0)); \ } @@ -853,30 +838,32 @@ class VideoFrameTest : public testing::Test { // Macro to help test different rotations #define TEST_ROTATE(FOURCC, BPP, ROTATE) \ - void Construct##FOURCC##Rotate##ROTATE() { \ +void Construct##FOURCC##Rotate##ROTATE() { \ T frame1, frame2, frame3; \ - rtc::scoped_ptr ms( \ + rtc::scoped_ptr ms( \ CreateYuvSample(kWidth, kHeight, BPP)); \ ASSERT_TRUE(ms.get() != NULL); \ - EXPECT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_##FOURCC, kWidth, kHeight, \ - kWidth, kHeight, webrtc::kVideoRotation_##ROTATE, \ - &frame1)); \ + EXPECT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_##FOURCC, \ + kWidth, kHeight, kWidth, kHeight, \ + cricket::ROTATION_##ROTATE, &frame1)); \ size_t data_size; \ bool ret = ms->GetSize(&data_size); \ EXPECT_TRUE(ret); \ - EXPECT_TRUE(frame2.Init(cricket::FOURCC_##FOURCC, kWidth, kHeight, kWidth, \ - kHeight, \ + EXPECT_TRUE(frame2.Init(cricket::FOURCC_##FOURCC, \ + kWidth, kHeight, kWidth, kHeight, \ reinterpret_cast(ms->GetBuffer()), \ - data_size, 1, 1, 0, 0, webrtc::kVideoRotation_0)); \ + data_size, \ + 1, 1, 0, 0, 0)); \ int width_rotate = static_cast(frame1.GetWidth()); \ int height_rotate = static_cast(frame1.GetHeight()); \ EXPECT_TRUE(frame3.InitToBlack(width_rotate, height_rotate, 1, 1, 0, 0)); \ - libyuv::I420Rotate( \ - frame2.GetYPlane(), frame2.GetYPitch(), frame2.GetUPlane(), \ - frame2.GetUPitch(), frame2.GetVPlane(), frame2.GetVPitch(), \ - frame3.GetYPlane(), frame3.GetYPitch(), frame3.GetUPlane(), \ - frame3.GetUPitch(), frame3.GetVPlane(), frame3.GetVPitch(), kWidth, \ - kHeight, libyuv::kRotate##ROTATE); \ + libyuv::I420Rotate(frame2.GetYPlane(), frame2.GetYPitch(), \ + frame2.GetUPlane(), frame2.GetUPitch(), \ + frame2.GetVPlane(), frame2.GetVPitch(), \ + frame3.GetYPlane(), frame3.GetYPitch(), \ + frame3.GetUPlane(), frame3.GetUPitch(), \ + frame3.GetVPlane(), frame3.GetVPitch(), \ + kWidth, kHeight, libyuv::kRotate##ROTATE); \ EXPECT_TRUE(IsEqual(frame1, frame3, 0)); \ } @@ -912,8 +899,9 @@ class VideoFrameTest : public testing::Test { rtc::scoped_ptr ms( CreateYuv422Sample(cricket::FOURCC_UYVY, kWidth, kHeight)); ASSERT_TRUE(ms.get() != NULL); - EXPECT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_UYVY, kWidth, kHeight, - kWidth, kHeight, webrtc::kVideoRotation_90, &frame2)); + EXPECT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_UYVY, + kWidth, kHeight, kWidth, kHeight, + cricket::ROTATION_90, &frame2)); } // Test constructing an image from a UYVY buffer rotated 180 degrees. @@ -922,9 +910,9 @@ class VideoFrameTest : public testing::Test { rtc::scoped_ptr ms( CreateYuv422Sample(cricket::FOURCC_UYVY, kWidth, kHeight)); ASSERT_TRUE(ms.get() != NULL); - EXPECT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_UYVY, kWidth, kHeight, - kWidth, kHeight, webrtc::kVideoRotation_180, - &frame2)); + EXPECT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_UYVY, + kWidth, kHeight, kWidth, kHeight, + cricket::ROTATION_180, &frame2)); } // Test constructing an image from a UYVY buffer rotated 270 degrees. @@ -933,9 +921,9 @@ class VideoFrameTest : public testing::Test { rtc::scoped_ptr ms( CreateYuv422Sample(cricket::FOURCC_UYVY, kWidth, kHeight)); ASSERT_TRUE(ms.get() != NULL); - EXPECT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_UYVY, kWidth, kHeight, - kWidth, kHeight, webrtc::kVideoRotation_270, - &frame2)); + EXPECT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_UYVY, + kWidth, kHeight, kWidth, kHeight, + cricket::ROTATION_270, &frame2)); } // Test constructing an image from a YUY2 buffer rotated 90 degrees. @@ -944,8 +932,9 @@ class VideoFrameTest : public testing::Test { rtc::scoped_ptr ms( CreateYuv422Sample(cricket::FOURCC_YUY2, kWidth, kHeight)); ASSERT_TRUE(ms.get() != NULL); - EXPECT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_YUY2, kWidth, kHeight, - kWidth, kHeight, webrtc::kVideoRotation_90, &frame2)); + EXPECT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_YUY2, + kWidth, kHeight, kWidth, kHeight, + cricket::ROTATION_90, &frame2)); } // Test constructing an image from a YUY2 buffer rotated 180 degrees. @@ -954,9 +943,9 @@ class VideoFrameTest : public testing::Test { rtc::scoped_ptr ms( CreateYuv422Sample(cricket::FOURCC_YUY2, kWidth, kHeight)); ASSERT_TRUE(ms.get() != NULL); - EXPECT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_YUY2, kWidth, kHeight, - kWidth, kHeight, webrtc::kVideoRotation_180, - &frame2)); + EXPECT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_YUY2, + kWidth, kHeight, kWidth, kHeight, + cricket::ROTATION_180, &frame2)); } // Test constructing an image from a YUY2 buffer rotated 270 degrees. @@ -965,9 +954,9 @@ class VideoFrameTest : public testing::Test { rtc::scoped_ptr ms( CreateYuv422Sample(cricket::FOURCC_YUY2, kWidth, kHeight)); ASSERT_TRUE(ms.get() != NULL); - EXPECT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_YUY2, kWidth, kHeight, - kWidth, kHeight, webrtc::kVideoRotation_270, - &frame2)); + EXPECT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_YUY2, + kWidth, kHeight, kWidth, kHeight, + cricket::ROTATION_270, &frame2)); } // Test 1 pixel edge case image I420 buffer. @@ -975,9 +964,9 @@ class VideoFrameTest : public testing::Test { T frame; uint8 pixel[3] = { 1, 2, 3 }; for (int i = 0; i < repeat_; ++i) { - EXPECT_TRUE(frame.Init(cricket::FOURCC_I420, 1, 1, 1, 1, pixel, - sizeof(pixel), 1, 1, 0, 0, - webrtc::kVideoRotation_0)); + EXPECT_TRUE(frame.Init(cricket::FOURCC_I420, 1, 1, 1, 1, + pixel, sizeof(pixel), + 1, 1, 0, 0, 0)); } const uint8* y = pixel; const uint8* u = y + 1; @@ -992,9 +981,9 @@ class VideoFrameTest : public testing::Test { uint8 pixels5x5[5 * 5 + ((5 + 1) / 2 * (5 + 1) / 2) * 2]; memset(pixels5x5, 1, 5 * 5 + ((5 + 1) / 2 * (5 + 1) / 2) * 2); for (int i = 0; i < repeat_; ++i) { - EXPECT_TRUE(frame.Init(cricket::FOURCC_I420, 5, 5, 5, 5, pixels5x5, - sizeof(pixels5x5), 1, 1, 0, 0, - webrtc::kVideoRotation_0)); + EXPECT_TRUE(frame.Init(cricket::FOURCC_I420, 5, 5, 5, 5, + pixels5x5, sizeof(pixels5x5), + 1, 1, 0, 0, 0)); } EXPECT_EQ(4u, frame.GetWidth()); EXPECT_EQ(4u, frame.GetHeight()); @@ -1008,9 +997,9 @@ class VideoFrameTest : public testing::Test { T frame; uint8 pixel[4] = { 64, 128, 192, 255 }; for (int i = 0; i < repeat_; ++i) { - EXPECT_TRUE(frame.Init(cricket::FOURCC_ARGB, 1, 1, 1, 1, pixel, - sizeof(pixel), 1, 1, 0, 0, - webrtc::kVideoRotation_0)); + EXPECT_TRUE(frame.Init(cricket::FOURCC_ARGB, 1, 1, 1, 1, + pixel, sizeof(pixel), + 1, 1, 0, 0, 0)); } // Convert back to ARGB. size_t out_size = 4; @@ -1045,9 +1034,9 @@ class VideoFrameTest : public testing::Test { 255, 255, 255, 255 }; for (int i = 0; i < repeat_; ++i) { - EXPECT_TRUE(frame.Init(cricket::FOURCC_ARGB, 10, 1, 10, 1, pixel, - sizeof(pixel), 1, 1, 0, 0, - webrtc::kVideoRotation_0)); + EXPECT_TRUE(frame.Init(cricket::FOURCC_ARGB, 10, 1, 10, 1, + pixel, sizeof(pixel), + 1, 1, 0, 0, 0)); } // Convert back to ARGB size_t out_size = 10 * 4; @@ -1068,8 +1057,7 @@ class VideoFrameTest : public testing::Test { T frame1, frame2; ASSERT_TRUE(LoadFrameNoRepeat(&frame1)); ASSERT_TRUE(LoadFrame(kImageFilename, cricket::FOURCC_I420, kWidth, kHeight, - kWidth * 3 / 4, kHeight, webrtc::kVideoRotation_0, - &frame2)); + kWidth * 3 / 4, kHeight, 0, &frame2)); EXPECT_TRUE(IsEqualWithCrop(frame2, frame1, kWidth / 8, 0, 0)); } @@ -1082,8 +1070,7 @@ class VideoFrameTest : public testing::Test { EXPECT_TRUE(ConvertYuv422(ms.get(), cricket::FOURCC_YUY2, kWidth, kHeight, &frame1)); EXPECT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_YUY2, kWidth, kHeight, - kWidth * 3 / 4, kHeight, webrtc::kVideoRotation_0, - &frame2)); + kWidth * 3 / 4, kHeight, 0, &frame2)); EXPECT_TRUE(IsEqualWithCrop(frame2, frame1, kWidth / 8, 0, 0)); } @@ -1096,8 +1083,7 @@ class VideoFrameTest : public testing::Test { EXPECT_TRUE(ConvertRgb(ms.get(), cricket::FOURCC_ARGB, kWidth, kHeight, &frame1)); EXPECT_TRUE(LoadFrame(ms.get(), cricket::FOURCC_ARGB, kWidth, kHeight, - kWidth * 3 / 4, kHeight, webrtc::kVideoRotation_0, - &frame2)); + kWidth * 3 / 4, kHeight, 0, &frame2)); EXPECT_TRUE(IsEqualWithCrop(frame2, frame1, kWidth / 8, 0, 2)); } @@ -1106,8 +1092,7 @@ class VideoFrameTest : public testing::Test { T frame1, frame2; ASSERT_TRUE(LoadFrameNoRepeat(&frame1)); ASSERT_TRUE(LoadFrame(kImageFilename, cricket::FOURCC_I420, kWidth, kHeight, - kWidth, kHeight * 3 / 4, webrtc::kVideoRotation_0, - &frame2)); + kWidth, kHeight * 3 / 4, 0, &frame2)); EXPECT_TRUE(IsEqualWithCrop(frame2, frame1, 0, kHeight / 8, 0)); } @@ -1425,9 +1410,10 @@ class VideoFrameTest : public testing::Test { EXPECT_TRUE(frame2.InitToBlack(kWidth, kHeight, 1, 1, 0, 0)); EXPECT_TRUE(IsBlack(frame1)); EXPECT_TRUE(IsEqual(frame1, frame2, 0)); - EXPECT_TRUE(frame1.Reset(cricket::FOURCC_I420, kWidth, kHeight, kWidth, - kHeight, reinterpret_cast(ms->GetBuffer()), - data_size, 1, 1, 0, 0, webrtc::kVideoRotation_0)); + EXPECT_TRUE(frame1.Reset(cricket::FOURCC_I420, + kWidth, kHeight, kWidth, kHeight, + reinterpret_cast(ms->GetBuffer()), + data_size, 1, 1, 0, 0, 0)); EXPECT_FALSE(IsBlack(frame1)); EXPECT_FALSE(IsEqual(frame1, frame2, 0)); } @@ -1880,9 +1866,10 @@ class VideoFrameTest : public testing::Test { v, kWidth / 2, kWidth, kHeight)); } - EXPECT_TRUE(frame2.Init(cricket::FOURCC_I422, kWidth, kHeight, kWidth, - kHeight, y, out_size, 1, 1, 0, 0, - webrtc::kVideoRotation_0)); + EXPECT_TRUE(frame2.Init(cricket::FOURCC_I422, + kWidth, kHeight, kWidth, kHeight, + y, + out_size, 1, 1, 0, 0, cricket::ROTATION_0)); EXPECT_TRUE(IsEqual(frame1, frame2, 1)); } @@ -2087,9 +2074,9 @@ class VideoFrameTest : public testing::Test { memset(out.get(), 0xfb, out_size + 1); // Fill buffer uint8 pixel[3] = { 1, 2, 3 }; T frame; - EXPECT_TRUE(frame.Init(cricket::FOURCC_I420, 1, 1, 1, 1, pixel, - sizeof(pixel), 1, 1, 0, 0, - webrtc::kVideoRotation_0)); + EXPECT_TRUE(frame.Init(cricket::FOURCC_I420, 1, 1, 1, 1, + pixel, sizeof(pixel), + 1, 1, 0, 0, 0)); for (int i = 0; i < repeat_; ++i) { EXPECT_EQ(out_size, frame.CopyToBuffer(out.get(), out_size)); } diff --git a/talk/media/webrtc/webrtctexturevideoframe.cc b/talk/media/webrtc/webrtctexturevideoframe.cc index d7135cbcc..bf33243d2 100644 --- a/talk/media/webrtc/webrtctexturevideoframe.cc +++ b/talk/media/webrtc/webrtctexturevideoframe.cc @@ -52,18 +52,10 @@ bool WebRtcTextureVideoFrame::InitToBlack( return false; } -bool WebRtcTextureVideoFrame::Reset(uint32 fourcc, - int w, - int h, - int dw, - int dh, - uint8* sample, - size_t sample_size, - size_t pixel_width, - size_t pixel_height, - int64_t elapsed_time, - int64_t time_stamp, - webrtc::kVideoRotation rotation) { +bool WebRtcTextureVideoFrame::Reset( + uint32 fourcc, int w, int h, int dw, int dh, uint8* sample, + size_t sample_size, size_t pixel_width, size_t pixel_height, + int64_t elapsed_time, int64_t time_stamp, int rotation) { UNIMPLEMENTED; return false; } diff --git a/talk/media/webrtc/webrtctexturevideoframe.h b/talk/media/webrtc/webrtctexturevideoframe.h index 511de27f3..8918a8bb2 100644 --- a/talk/media/webrtc/webrtctexturevideoframe.h +++ b/talk/media/webrtc/webrtctexturevideoframe.h @@ -46,18 +46,11 @@ class WebRtcTextureVideoFrame : public VideoFrame { virtual bool InitToBlack(int w, int h, size_t pixel_width, size_t pixel_height, int64_t elapsed_time, int64_t time_stamp); - virtual bool Reset(uint32 fourcc, - int w, - int h, - int dw, - int dh, - uint8* sample, - size_t sample_size, - size_t pixel_width, - size_t pixel_height, - int64_t elapsed_time, + virtual bool Reset(uint32 fourcc, int w, int h, int dw, int dh, uint8* sample, + size_t sample_size, size_t pixel_width, + size_t pixel_height, int64_t elapsed_time, int64_t time_stamp, - webrtc::kVideoRotation rotation); + int rotation); virtual size_t GetWidth() const { return width_; } virtual size_t GetHeight() const { return height_; } virtual const uint8* GetYPlane() const; @@ -77,9 +70,7 @@ class WebRtcTextureVideoFrame : public VideoFrame { elapsed_time_ = elapsed_time; } virtual void SetTimeStamp(int64_t time_stamp) { time_stamp_ = time_stamp; } - virtual webrtc::kVideoRotation GetRotation() const { - return webrtc::kVideoRotation_0; - } + virtual int GetRotation() const { return 0; } virtual VideoFrame* Copy() const; virtual bool MakeExclusive(); virtual size_t CopyToBuffer(uint8* buffer, size_t size) const; diff --git a/talk/media/webrtc/webrtcvideoengine.cc b/talk/media/webrtc/webrtcvideoengine.cc index 2e500df33..e4d6447e6 100644 --- a/talk/media/webrtc/webrtcvideoengine.cc +++ b/talk/media/webrtc/webrtcvideoengine.cc @@ -430,8 +430,8 @@ class WebRtcRenderAdapter : public webrtc::ExternalRenderer { int DeliverBufferFrame(unsigned char* buffer, size_t buffer_size, int64 time_stamp, int64 elapsed_time) { WebRtcVideoFrame video_frame; - video_frame.Alias(buffer, buffer_size, width_, height_, 1, 1, elapsed_time, - time_stamp, webrtc::kVideoRotation_0); + video_frame.Alias(buffer, buffer_size, width_, height_, + 1, 1, elapsed_time, time_stamp, 0); // Sanity check on decoded frame size. if (buffer_size != VideoFrame::SizeOf(width_, height_)) { diff --git a/talk/media/webrtc/webrtcvideoframe.cc b/talk/media/webrtc/webrtcvideoframe.cc index 42b87e065..2dd4799f9 100644 --- a/talk/media/webrtc/webrtcvideoframe.cc +++ b/talk/media/webrtc/webrtcvideoframe.cc @@ -115,18 +115,10 @@ WebRtcVideoFrame::WebRtcVideoFrame() WebRtcVideoFrame::~WebRtcVideoFrame() {} -bool WebRtcVideoFrame::Init(uint32 format, - int w, - int h, - int dw, - int dh, - uint8* sample, - size_t sample_size, - size_t pixel_width, - size_t pixel_height, - int64_t elapsed_time, - int64_t time_stamp, - webrtc::kVideoRotation rotation) { +bool WebRtcVideoFrame::Init( + uint32 format, int w, int h, int dw, int dh, uint8* sample, + size_t sample_size, size_t pixel_width, size_t pixel_height, + int64_t elapsed_time, int64_t time_stamp, int rotation) { return Reset(format, w, h, dw, dh, sample, sample_size, pixel_width, pixel_height, elapsed_time, time_stamp, rotation); } @@ -135,19 +127,24 @@ bool WebRtcVideoFrame::Init(const CapturedFrame* frame, int dw, int dh) { return Reset(frame->fourcc, frame->width, frame->height, dw, dh, static_cast(frame->data), frame->data_size, frame->pixel_width, frame->pixel_height, frame->elapsed_time, - frame->time_stamp, frame->GetRotation()); + frame->time_stamp, frame->rotation); } bool WebRtcVideoFrame::Alias(const CapturedFrame* frame, int dw, int dh) { - if (CanonicalFourCC(frame->fourcc) != FOURCC_I420 || - (frame->GetRotation() != webrtc::kVideoRotation_0) || + if (CanonicalFourCC(frame->fourcc) != FOURCC_I420 || frame->rotation != 0 || frame->width != dw || frame->height != dh) { // TODO(fbarchard): Enable aliasing of more formats. return Init(frame, dw, dh); } else { - Alias(static_cast(frame->data), frame->data_size, frame->width, - frame->height, frame->pixel_width, frame->pixel_height, - frame->elapsed_time, frame->time_stamp, frame->GetRotation()); + Alias(static_cast(frame->data), + frame->data_size, + frame->width, + frame->height, + frame->pixel_width, + frame->pixel_height, + frame->elapsed_time, + frame->time_stamp, + frame->rotation); return true; } } @@ -159,15 +156,10 @@ bool WebRtcVideoFrame::InitToBlack(int w, int h, size_t pixel_width, return SetToBlack(); } -void WebRtcVideoFrame::Alias(uint8* buffer, - size_t buffer_size, - int w, - int h, - size_t pixel_width, - size_t pixel_height, - int64_t elapsed_time, - int64_t time_stamp, - webrtc::kVideoRotation rotation) { +void WebRtcVideoFrame::Alias( + uint8* buffer, size_t buffer_size, int w, int h, size_t pixel_width, + size_t pixel_height, int64_t elapsed_time, int64_t time_stamp, + int rotation) { rtc::scoped_refptr video_buffer( new RefCountedBuffer()); video_buffer->Alias(buffer, buffer_size); @@ -265,15 +257,10 @@ size_t WebRtcVideoFrame::ConvertToRgbBuffer(uint32 to_fourcc, uint8* buffer, return VideoFrame::ConvertToRgbBuffer(to_fourcc, buffer, size, stride_rgb); } -void WebRtcVideoFrame::Attach(RefCountedBuffer* video_buffer, - size_t buffer_size, - int w, - int h, - size_t pixel_width, - size_t pixel_height, - int64_t elapsed_time, - int64_t time_stamp, - webrtc::kVideoRotation rotation) { +void WebRtcVideoFrame::Attach( + RefCountedBuffer* video_buffer, size_t buffer_size, int w, int h, + size_t pixel_width, size_t pixel_height, int64_t elapsed_time, + int64_t time_stamp, int rotation) { if (video_buffer_.get() == video_buffer) { return; } @@ -295,18 +282,10 @@ const webrtc::VideoFrame* WebRtcVideoFrame::frame() const { return video_buffer_->frame(); } -bool WebRtcVideoFrame::Reset(uint32 format, - int w, - int h, - int dw, - int dh, - uint8* sample, - size_t sample_size, - size_t pixel_width, - size_t pixel_height, - int64_t elapsed_time, - int64_t time_stamp, - webrtc::kVideoRotation rotation) { +bool WebRtcVideoFrame::Reset( + uint32 format, int w, int h, int dw, int dh, uint8* sample, + size_t sample_size, size_t pixel_width, size_t pixel_height, + int64_t elapsed_time, int64_t time_stamp, int rotation) { if (!Validate(format, w, h, sample, sample_size)) { return false; } @@ -334,7 +313,7 @@ bool WebRtcVideoFrame::Reset(uint32 format, // Since the libyuv::ConvertToI420 will handle the rotation, so the // new frame's rotation should always be 0. Attach(video_buffer.get(), desired_size, new_width, new_height, pixel_width, - pixel_height, elapsed_time, time_stamp, webrtc::kVideoRotation_0); + pixel_height, elapsed_time, time_stamp, 0); int horiz_crop = ((w - dw) / 2) & ~1; // ARGB on Windows has negative height. @@ -377,7 +356,7 @@ void WebRtcVideoFrame::InitToEmptyBuffer(int w, int h, size_t pixel_width, rtc::scoped_refptr video_buffer( new RefCountedBuffer(buffer_size)); Attach(video_buffer.get(), buffer_size, w, h, pixel_width, pixel_height, - elapsed_time, time_stamp, webrtc::kVideoRotation_0); + elapsed_time, time_stamp, 0); } WebRtcVideoRenderFrame::WebRtcVideoRenderFrame( @@ -407,7 +386,7 @@ bool WebRtcVideoRenderFrame::Reset(uint32 fourcc, size_t pixel_height, int64_t elapsed_time, int64_t time_stamp, - webrtc::kVideoRotation rotation) { + int rotation) { UNIMPLEMENTED; return false; } @@ -476,9 +455,9 @@ void WebRtcVideoRenderFrame::SetTimeStamp(int64_t time_stamp) { UNIMPLEMENTED; } -webrtc::kVideoRotation WebRtcVideoRenderFrame::GetRotation() const { +int WebRtcVideoRenderFrame::GetRotation() const { UNIMPLEMENTED; - return webrtc::kVideoRotation_0; + return ROTATION_0; } // TODO(magjed): Make this copy shallow instead of deep, BUG=1128. There is no diff --git a/talk/media/webrtc/webrtcvideoframe.h b/talk/media/webrtc/webrtcvideoframe.h index 35f80f2a4..f025163db 100644 --- a/talk/media/webrtc/webrtcvideoframe.h +++ b/talk/media/webrtc/webrtcvideoframe.h @@ -52,18 +52,9 @@ class WebRtcVideoFrame : public VideoFrame { // "h" can be negative indicating a vertically flipped image. // "dh" is destination height if cropping is desired and is always positive. // Returns "true" if successful. - bool Init(uint32 format, - int w, - int h, - int dw, - int dh, - uint8* sample, - size_t sample_size, - size_t pixel_width, - size_t pixel_height, - int64_t elapsed_time, - int64_t time_stamp, - webrtc::kVideoRotation rotation); + bool Init(uint32 format, int w, int h, int dw, int dh, uint8* sample, + size_t sample_size, size_t pixel_width, size_t pixel_height, + int64_t elapsed_time, int64_t time_stamp, int rotation); bool Init(const CapturedFrame* frame, int dw, int dh); @@ -79,32 +70,18 @@ class WebRtcVideoFrame : public VideoFrame { // Aliases this WebRtcVideoFrame to a memory buffer. |buffer| must outlive // this WebRtcVideoFrame. - void Alias(uint8* buffer, - size_t buffer_size, - int w, - int h, - size_t pixel_width, - size_t pixel_height, - int64_t elapsed_time, - int64_t time_stamp, - webrtc::kVideoRotation rotation); + void Alias(uint8* buffer, size_t buffer_size, int w, int h, + size_t pixel_width, size_t pixel_height, int64_t elapsed_time, + int64_t time_stamp, int rotation); webrtc::VideoFrame* frame(); const webrtc::VideoFrame* frame() const; // From base class VideoFrame. - virtual bool Reset(uint32 format, - int w, - int h, - int dw, - int dh, - uint8* sample, - size_t sample_size, - size_t pixel_width, - size_t pixel_height, - int64_t elapsed_time, - int64_t time_stamp, - webrtc::kVideoRotation rotation); + virtual bool Reset(uint32 format, int w, int h, int dw, int dh, uint8* sample, + size_t sample_size, size_t pixel_width, + size_t pixel_height, int64_t elapsed_time, + int64_t time_stamp, int rotation); virtual size_t GetWidth() const; virtual size_t GetHeight() const; @@ -128,7 +105,7 @@ class WebRtcVideoFrame : public VideoFrame { } virtual void SetTimeStamp(int64_t time_stamp) { time_stamp_ = time_stamp; } - virtual webrtc::kVideoRotation GetRotation() const { return rotation_; } + virtual int GetRotation() const { return rotation_; } virtual VideoFrame* Copy() const; virtual bool MakeExclusive(); @@ -140,15 +117,9 @@ class WebRtcVideoFrame : public VideoFrame { class FrameBuffer; typedef rtc::RefCountedObject RefCountedBuffer; - void Attach(RefCountedBuffer* video_buffer, - size_t buffer_size, - int w, - int h, - size_t pixel_width, - size_t pixel_height, - int64_t elapsed_time, - int64_t time_stamp, - webrtc::kVideoRotation rotation); + void Attach(RefCountedBuffer* video_buffer, size_t buffer_size, int w, int h, + size_t pixel_width, size_t pixel_height, int64_t elapsed_time, + int64_t time_stamp, int rotation); virtual VideoFrame* CreateEmptyFrame(int w, int h, size_t pixel_width, size_t pixel_height, @@ -160,7 +131,7 @@ class WebRtcVideoFrame : public VideoFrame { size_t pixel_height_; int64_t elapsed_time_; int64_t time_stamp_; - webrtc::kVideoRotation rotation_; + int rotation_; }; // Thin map between VideoFrame and an existing webrtc::I420VideoFrame @@ -189,7 +160,7 @@ class WebRtcVideoRenderFrame : public VideoFrame { size_t pixel_height, int64_t elapsed_time, int64_t time_stamp, - webrtc::kVideoRotation rotation) OVERRIDE; + int rotation) OVERRIDE; virtual size_t GetWidth() const OVERRIDE; virtual size_t GetHeight() const OVERRIDE; virtual const uint8* GetYPlane() const OVERRIDE; @@ -208,7 +179,7 @@ class WebRtcVideoRenderFrame : public VideoFrame { virtual int64_t GetTimeStamp() const OVERRIDE; virtual void SetElapsedTime(int64_t elapsed_time) OVERRIDE; virtual void SetTimeStamp(int64_t time_stamp) OVERRIDE; - virtual webrtc::kVideoRotation GetRotation() const OVERRIDE; + virtual int GetRotation() const OVERRIDE; virtual VideoFrame* Copy() const OVERRIDE; virtual bool MakeExclusive() OVERRIDE; virtual size_t CopyToBuffer(uint8* buffer, size_t size) const OVERRIDE; diff --git a/talk/media/webrtc/webrtcvideoframe_unittest.cc b/talk/media/webrtc/webrtcvideoframe_unittest.cc index 656183c31..5f65c5822 100644 --- a/talk/media/webrtc/webrtcvideoframe_unittest.cc +++ b/talk/media/webrtc/webrtcvideoframe_unittest.cc @@ -44,7 +44,7 @@ class WebRtcVideoFrameTest : public VideoFrameTest { captured_frame.pixel_height = 1; captured_frame.elapsed_time = 1234; captured_frame.time_stamp = 5678; - captured_frame.rotation = webrtc::kVideoRotation_0; + captured_frame.rotation = 0; captured_frame.width = frame_width; captured_frame.height = frame_height; captured_frame.data_size = (frame_width * frame_height) + @@ -62,7 +62,7 @@ class WebRtcVideoFrameTest : public VideoFrameTest { EXPECT_EQ(1u, frame.GetPixelHeight()); EXPECT_EQ(1234, frame.GetElapsedTime()); EXPECT_EQ(5678, frame.GetTimeStamp()); - EXPECT_EQ(webrtc::kVideoRotation_0, frame.GetRotation()); + EXPECT_EQ(0, frame.GetRotation()); // The size of the new frame should have been cropped to multiple of 4. EXPECT_EQ(static_cast(cropped_width & ~3), frame.GetWidth()); EXPECT_EQ(static_cast(cropped_height & ~3), frame.GetHeight()); @@ -266,9 +266,9 @@ TEST_F(WebRtcVideoFrameTest, Alias) { const int64 time_stamp = INT64_C(0x7FFFFFFFFFFFFFF0); frame1.SetTimeStamp(time_stamp); EXPECT_EQ(time_stamp, frame1.GetTimeStamp()); - frame2.Alias(frame1.frame()->Buffer(), frame1.frame()->Size(), kWidth, - kHeight, 1, 1, frame1.GetElapsedTime(), frame1.GetTimeStamp(), - webrtc::kVideoRotation_0); + frame2.Alias(frame1.frame()->Buffer(), frame1.frame()->Size(), + kWidth, kHeight, 1, 1, + frame1.GetElapsedTime(), frame1.GetTimeStamp(), 0); EXPECT_TRUE(IsEqual(frame1, frame2, 0)); } diff --git a/webrtc/common_video/rotation.h b/webrtc/common_video/rotation.h deleted file mode 100644 index ec301ab2c..000000000 --- a/webrtc/common_video/rotation.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_COMMON_VIDEO_ROTATION_H_ -#define WEBRTC_COMMON_VIDEO_ROTATION_H_ - -#include "webrtc/base/common.h" - -namespace webrtc { - -// enum for clockwise rotation. -enum kVideoRotation { - kVideoRotation_0 = 0, - kVideoRotation_90 = 90, - kVideoRotation_180 = 180, - kVideoRotation_270 = 270 -}; - -} // namespace webrtc - -#endif // WEBRTC_COMMON_VIDEO_ROTATION_H_