2015-05-19 12:45:47 -07:00
|
|
|
/*
|
2016-02-07 20:46:45 -08:00
|
|
|
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
|
2015-05-19 12:45:47 -07:00
|
|
|
*
|
2016-02-07 20:46:45 -08:00
|
|
|
* 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.
|
2015-05-19 12:45:47 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2016-02-26 03:00:35 -08:00
|
|
|
#include <memory>
|
|
|
|
|
|
Move talk/media to webrtc/media
I removed the 'libjingle' target in talk/libjingle.gyp and replaced
all users of it with base/base.gyp:rtc_base. It seems the jsoncpp
and expat dependencies were not used by it's previous references.
The files in talk/media/testdata were uploaded to Google Storage and
added .sha1 files in resources/media instead of simply moving them.
The previously disabled warnings that were inherited from
talk/build/common.gypi are now replaced by target-specific disabling
of only the failing warnings. Additional disabling was needed since the stricter
compilation warnings that applies to code in webrtc/.
License headers will be updated in a follow-up CL in order to not
break Git history.
Other modifications:
* Updated the header guards.
* Sorted the includes using chromium/src/tools/sort-headers.py
except for these files:
talk/app/webrtc/peerconnectionendtoend_unittest.cc
talk/app/webrtc/java/jni/androidmediadecoder_jni.cc
talk/app/webrtc/java/jni/androidmediaencoder_jni.cc
webrtc/media/devices/win32devicemanager.cc.
* Unused GYP reference to libjingle_tests_additional_deps was removed.
* Removed duplicated GYP entries of
webrtc/base/testutils.cc
webrtc/base/testutils.h
The HAVE_WEBRTC_VIDEO and HAVE_WEBRTC_VOICE defines were used by only talk/media,
so they were moved to the media.gyp.
I also checked that none of
EXPAT_RELATIVE_PATH,
FEATURE_ENABLE_VOICEMAIL,
GTEST_RELATIVE_PATH,
JSONCPP_RELATIVE_PATH,
LOGGING=1,
SRTP_RELATIVE_PATH,
FEATURE_ENABLE_SSL,
FEATURE_ENABLE_VOICEMAIL,
FEATURE_ENABLE_PSTN,
HAVE_SCTP,
HAVE_SRTP,
are used by the talk/media code.
For Chromium, the following changes will need to be applied to the roll CL that updates the
DEPS for WebRTC and libjingle: https://codereview.chromium.org/1604303002/
BUG=webrtc:5420
NOPRESUBMIT=True
TBR=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/1587193006
Cr-Commit-Position: refs/heads/master@{#11495}
2016-02-04 23:52:28 -08:00
|
|
|
#include "webrtc/media/base/videoframe_unittest.h"
|
2016-02-12 06:39:40 +01:00
|
|
|
#include "webrtc/media/engine/webrtcvideoframe.h"
|
|
|
|
|
#include "webrtc/media/engine/webrtcvideoframefactory.h"
|
2015-05-19 12:45:47 -07:00
|
|
|
|
|
|
|
|
class WebRtcVideoFrameFactoryTest
|
|
|
|
|
: public VideoFrameTest<cricket::WebRtcVideoFrameFactory> {
|
|
|
|
|
public:
|
|
|
|
|
WebRtcVideoFrameFactoryTest() {}
|
|
|
|
|
|
|
|
|
|
void InitFrame(webrtc::VideoRotation frame_rotation) {
|
|
|
|
|
const int frame_width = 1920;
|
|
|
|
|
const int frame_height = 1080;
|
|
|
|
|
|
|
|
|
|
// Build the CapturedFrame.
|
|
|
|
|
captured_frame_.fourcc = cricket::FOURCC_I420;
|
|
|
|
|
captured_frame_.pixel_width = 1;
|
|
|
|
|
captured_frame_.pixel_height = 1;
|
|
|
|
|
captured_frame_.time_stamp = 5678;
|
|
|
|
|
captured_frame_.rotation = frame_rotation;
|
|
|
|
|
captured_frame_.width = frame_width;
|
|
|
|
|
captured_frame_.height = frame_height;
|
|
|
|
|
captured_frame_.data_size =
|
|
|
|
|
(frame_width * frame_height) +
|
|
|
|
|
((frame_width + 1) / 2) * ((frame_height + 1) / 2) * 2;
|
Use suffixed {uint,int}{8,16,32,64}_t types.
Removes the use of uint8, etc. in favor of uint8_t.
BUG=webrtc:5024
R=henrik.lundin@webrtc.org, henrikg@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1362503003 .
Cr-Commit-Position: refs/heads/master@{#10196}
2015-10-07 12:23:21 +02:00
|
|
|
captured_frame_buffer_.reset(new uint8_t[captured_frame_.data_size]);
|
2015-05-19 12:45:47 -07:00
|
|
|
// Initialize memory to satisfy DrMemory tests.
|
|
|
|
|
memset(captured_frame_buffer_.get(), 0, captured_frame_.data_size);
|
|
|
|
|
captured_frame_.data = captured_frame_buffer_.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VerifyFrame(cricket::VideoFrame* dest_frame,
|
|
|
|
|
webrtc::VideoRotation src_rotation,
|
|
|
|
|
int src_width,
|
|
|
|
|
int src_height,
|
|
|
|
|
bool apply_rotation) {
|
|
|
|
|
if (!apply_rotation) {
|
2016-02-12 01:01:11 -08:00
|
|
|
EXPECT_EQ(dest_frame->GetVideoRotation(), src_rotation);
|
2016-04-04 00:57:29 -07:00
|
|
|
EXPECT_EQ(dest_frame->width(), src_width);
|
|
|
|
|
EXPECT_EQ(dest_frame->height(), src_height);
|
2015-05-19 12:45:47 -07:00
|
|
|
} else {
|
2016-02-12 01:01:11 -08:00
|
|
|
EXPECT_EQ(dest_frame->GetVideoRotation(), webrtc::kVideoRotation_0);
|
2015-05-19 12:45:47 -07:00
|
|
|
if (src_rotation == webrtc::kVideoRotation_90 ||
|
|
|
|
|
src_rotation == webrtc::kVideoRotation_270) {
|
2016-04-04 00:57:29 -07:00
|
|
|
EXPECT_EQ(dest_frame->width(), src_height);
|
|
|
|
|
EXPECT_EQ(dest_frame->height(), src_width);
|
2015-05-19 12:45:47 -07:00
|
|
|
} else {
|
2016-04-04 00:57:29 -07:00
|
|
|
EXPECT_EQ(dest_frame->width(), src_width);
|
|
|
|
|
EXPECT_EQ(dest_frame->height(), src_height);
|
2015-05-19 12:45:47 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestCreateAliasedFrame(bool apply_rotation) {
|
|
|
|
|
cricket::VideoFrameFactory& factory = factory_;
|
|
|
|
|
factory.SetApplyRotation(apply_rotation);
|
|
|
|
|
InitFrame(webrtc::kVideoRotation_270);
|
|
|
|
|
const cricket::CapturedFrame& captured_frame = get_captured_frame();
|
|
|
|
|
// Create the new frame from the CapturedFrame.
|
2016-02-26 03:00:35 -08:00
|
|
|
std::unique_ptr<cricket::VideoFrame> frame;
|
2015-05-19 12:45:47 -07:00
|
|
|
int new_width = captured_frame.width / 2;
|
|
|
|
|
int new_height = captured_frame.height / 2;
|
|
|
|
|
frame.reset(factory.CreateAliasedFrame(&captured_frame, new_width,
|
|
|
|
|
new_height, new_width, new_height));
|
|
|
|
|
VerifyFrame(frame.get(), webrtc::kVideoRotation_270, new_width, new_height,
|
|
|
|
|
apply_rotation);
|
|
|
|
|
|
|
|
|
|
frame.reset(factory.CreateAliasedFrame(
|
|
|
|
|
&captured_frame, new_width, new_height, new_width / 2, new_height / 2));
|
|
|
|
|
VerifyFrame(frame.get(), webrtc::kVideoRotation_270, new_width / 2,
|
|
|
|
|
new_height / 2, apply_rotation);
|
|
|
|
|
|
|
|
|
|
// Reset the frame first so it's exclusive hence we could go through the
|
|
|
|
|
// StretchToFrame code path in CreateAliasedFrame.
|
|
|
|
|
frame.reset();
|
|
|
|
|
frame.reset(factory.CreateAliasedFrame(
|
|
|
|
|
&captured_frame, new_width, new_height, new_width / 2, new_height / 2));
|
|
|
|
|
VerifyFrame(frame.get(), webrtc::kVideoRotation_270, new_width / 2,
|
|
|
|
|
new_height / 2, apply_rotation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const cricket::CapturedFrame& get_captured_frame() { return captured_frame_; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
cricket::CapturedFrame captured_frame_;
|
2016-02-26 03:00:35 -08:00
|
|
|
std::unique_ptr<uint8_t[]> captured_frame_buffer_;
|
2015-05-19 12:45:47 -07:00
|
|
|
cricket::WebRtcVideoFrameFactory factory_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TEST_F(WebRtcVideoFrameFactoryTest, NoApplyRotation) {
|
|
|
|
|
TestCreateAliasedFrame(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(WebRtcVideoFrameFactoryTest, ApplyRotation) {
|
|
|
|
|
TestCreateAliasedFrame(true);
|
|
|
|
|
}
|