Enable CVO by default through webrtc pipeline.
All RTP packets from sender side will carry the rotation info. (will file a bug to track this) On the receiving side, only packets with marker bit set will be examined.
Tests completed:
1. android standalone to android standalone
2. android standalone to chrome (with and without this change)
3. android on chrome
BUG=4145
R=glaznev@webrtc.org, mflodman@webrtc.org, perkj@webrtc.org, pthatcher@webrtc.org
Committed: https://crrev.com/1b1c15cad16de57053bb6aa8a916079e0534bdae
Cr-Commit-Position: refs/heads/master@{#8905}
Review URL: https://webrtc-codereview.appspot.com/47399004
Cr-Commit-Position: refs/heads/master@{#8917}
diff --git a/talk/media/webrtc/webrtcvideoengine2_unittest.cc b/talk/media/webrtc/webrtcvideoengine2_unittest.cc
index cbf516d..aabefd6 100644
--- a/talk/media/webrtc/webrtcvideoengine2_unittest.cc
+++ b/talk/media/webrtc/webrtcvideoengine2_unittest.cc
@@ -530,6 +530,82 @@
FAIL() << "Absolute Sender Time extension not in header-extension list.";
}
+TEST_F(WebRtcVideoEngine2Test, SupportsVideoRotationHeaderExtension) {
+ std::vector<RtpHeaderExtension> extensions = engine_.rtp_header_extensions();
+ ASSERT_FALSE(extensions.empty());
+ for (size_t i = 0; i < extensions.size(); ++i) {
+ if (extensions[i].uri == kRtpVideoRotationHeaderExtension) {
+ EXPECT_EQ(kRtpVideoRotationHeaderExtensionDefaultId, extensions[i].id);
+ return;
+ }
+ }
+ FAIL() << "Video Rotation extension not in header-extension list.";
+}
+
+TEST_F(WebRtcVideoEngine2Test, CVOSetHeaderExtensionBeforeCapturer) {
+ // Allocate the capturer first to prevent early destruction before channel's
+ // dtor is called.
+ cricket::FakeVideoCapturer capturer;
+
+ cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
+ encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8");
+ std::vector<cricket::VideoCodec> codecs;
+ codecs.push_back(kVp8Codec);
+
+ rtc::scoped_ptr<VideoMediaChannel> channel(
+ SetUpForExternalEncoderFactory(&encoder_factory, codecs));
+ EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc)));
+
+ // Add CVO extension.
+ const int id = 1;
+ std::vector<cricket::RtpHeaderExtension> extensions;
+ extensions.push_back(
+ cricket::RtpHeaderExtension(kRtpVideoRotationHeaderExtension, id));
+ EXPECT_TRUE(channel->SetSendRtpHeaderExtensions(extensions));
+
+ // Set capturer.
+ EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer));
+
+ // Verify capturer has turned off applying rotation.
+ EXPECT_FALSE(capturer.GetApplyRotation());
+
+ // Verify removing header extension turns on applying rotation.
+ extensions.clear();
+ EXPECT_TRUE(channel->SetSendRtpHeaderExtensions(extensions));
+ EXPECT_TRUE(capturer.GetApplyRotation());
+}
+
+TEST_F(WebRtcVideoEngine2Test, CVOSetHeaderExtensionAfterCapturer) {
+ cricket::FakeVideoCapturer capturer;
+
+ cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
+ encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8");
+ std::vector<cricket::VideoCodec> codecs;
+ codecs.push_back(kVp8Codec);
+
+ rtc::scoped_ptr<VideoMediaChannel> channel(
+ SetUpForExternalEncoderFactory(&encoder_factory, codecs));
+ EXPECT_TRUE(channel->AddSendStream(StreamParams::CreateLegacy(kSsrc)));
+
+ // Set capturer.
+ EXPECT_TRUE(channel->SetCapturer(kSsrc, &capturer));
+
+ // Add CVO extension.
+ const int id = 1;
+ std::vector<cricket::RtpHeaderExtension> extensions;
+ extensions.push_back(
+ cricket::RtpHeaderExtension(kRtpVideoRotationHeaderExtension, id));
+ EXPECT_TRUE(channel->SetSendRtpHeaderExtensions(extensions));
+
+ // Verify capturer has turned off applying rotation.
+ EXPECT_FALSE(capturer.GetApplyRotation());
+
+ // Verify removing header extension turns on applying rotation.
+ extensions.clear();
+ EXPECT_TRUE(channel->SetSendRtpHeaderExtensions(extensions));
+ EXPECT_TRUE(capturer.GetApplyRotation());
+}
+
TEST_F(WebRtcVideoEngine2Test, SetSendFailsBeforeSettingCodecs) {
engine_.Init(rtc::Thread::Current());
rtc::scoped_ptr<VideoMediaChannel> channel(
@@ -1198,21 +1274,34 @@
webrtc::RtpExtension::kAbsSendTime);
}
+// Test support for video rotation header extension.
+TEST_F(WebRtcVideoChannel2Test, SendVideoRotationHeaderExtensions) {
+ TestSetSendRtpHeaderExtensions(kRtpVideoRotationHeaderExtension,
+ webrtc::RtpExtension::kVideoRotation);
+}
+TEST_F(WebRtcVideoChannel2Test, RecvVideoRotationHeaderExtensions) {
+ TestSetRecvRtpHeaderExtensions(kRtpVideoRotationHeaderExtension,
+ webrtc::RtpExtension::kVideoRotation);
+}
+
TEST_F(WebRtcVideoChannel2Test, IdenticalSendExtensionsDoesntRecreateStream) {
const int kTOffsetId = 1;
const int kAbsSendTimeId = 2;
+ const int kVideoRotationId = 3;
std::vector<cricket::RtpHeaderExtension> extensions;
extensions.push_back(cricket::RtpHeaderExtension(
kRtpAbsoluteSenderTimeHeaderExtension, kAbsSendTimeId));
extensions.push_back(cricket::RtpHeaderExtension(
kRtpTimestampOffsetHeaderExtension, kTOffsetId));
+ extensions.push_back(cricket::RtpHeaderExtension(
+ kRtpVideoRotationHeaderExtension, kVideoRotationId));
EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions));
FakeVideoSendStream* send_stream =
AddSendStream(cricket::StreamParams::CreateLegacy(123));
EXPECT_EQ(1, fake_call_->GetNumCreatedSendStreams());
- ASSERT_EQ(2u, send_stream->GetConfig().rtp.extensions.size());
+ ASSERT_EQ(3u, send_stream->GetConfig().rtp.extensions.size());
// Setting the same extensions (even if in different order) shouldn't
// reallocate the stream.
@@ -1231,18 +1320,21 @@
TEST_F(WebRtcVideoChannel2Test, IdenticalRecvExtensionsDoesntRecreateStream) {
const int kTOffsetId = 1;
const int kAbsSendTimeId = 2;
+ const int kVideoRotationId = 3;
std::vector<cricket::RtpHeaderExtension> extensions;
extensions.push_back(cricket::RtpHeaderExtension(
kRtpAbsoluteSenderTimeHeaderExtension, kAbsSendTimeId));
extensions.push_back(cricket::RtpHeaderExtension(
kRtpTimestampOffsetHeaderExtension, kTOffsetId));
+ extensions.push_back(cricket::RtpHeaderExtension(
+ kRtpVideoRotationHeaderExtension, kVideoRotationId));
EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions));
FakeVideoReceiveStream* send_stream =
AddRecvStream(cricket::StreamParams::CreateLegacy(123));
EXPECT_EQ(1, fake_call_->GetNumCreatedReceiveStreams());
- ASSERT_EQ(2u, send_stream->GetConfig().rtp.extensions.size());
+ ASSERT_EQ(3u, send_stream->GetConfig().rtp.extensions.size());
// Setting the same extensions (even if in different order) shouldn't
// reallocate the stream.