Add content type extension to capabilities

BUG=webrtc:7420

Review-Url: https://codereview.webrtc.org/2817553004
Cr-Commit-Position: refs/heads/master@{#17839}
This commit is contained in:
ilnik
2017-04-24 05:12:35 -07:00
committed by Commit bot
parent 30cda5ef98
commit a244ec659d
2 changed files with 35 additions and 0 deletions

View File

@ -49,6 +49,13 @@ bool IsFlexfecFieldTrialEnabled() {
return webrtc::field_trial::FindFullName("WebRTC-FlexFEC-03") == "Enabled";
}
// If this field trial is enabled, we will report VideoContentType RTP extension
// in capabilities (thus, it will end up in the default SDP and extension will
// be sent for all key-frames).
bool IsVideoContentTypeExtensionFieldTrialEnabled() {
return webrtc::field_trial::IsEnabled("WebRTC-VideoContentTypeExtension");
}
// Wrap cricket::WebRtcVideoEncoderFactory as a webrtc::VideoEncoderFactory.
class EncoderFactoryAdapter : public webrtc::VideoEncoderFactory {
public:
@ -503,6 +510,11 @@ RtpCapabilities WebRtcVideoEngine2::GetCapabilities() const {
capabilities.header_extensions.push_back(
webrtc::RtpExtension(webrtc::RtpExtension::kPlayoutDelayUri,
webrtc::RtpExtension::kPlayoutDelayDefaultId));
if (IsVideoContentTypeExtensionFieldTrialEnabled()) {
capabilities.header_extensions.push_back(
webrtc::RtpExtension(webrtc::RtpExtension::kVideoContentTypeUri,
webrtc::RtpExtension::kVideoContentTypeDefaultId));
}
return capabilities;
}

View File

@ -273,6 +273,29 @@ TEST_F(WebRtcVideoEngine2Test, CVOSetHeaderExtensionBeforeCapturer) {
EXPECT_TRUE(capturer.apply_rotation());
}
// TODO(ilnik): Remove this test once field trial is gone.
TEST_F(WebRtcVideoEngine2Test, SupportsVideoContentTypeHeaderExtension) {
// Extension shound not be reported outside of the field trial.
RtpCapabilities capabilities = engine_.GetCapabilities();
EXPECT_FALSE(capabilities.header_extensions.empty());
for (const RtpExtension& extension : capabilities.header_extensions) {
EXPECT_NE(extension.uri, RtpExtension::kVideoContentTypeUri);
}
webrtc::test::ScopedFieldTrials override_field_trials_(
"WebRTC-VideoContentTypeExtension/Enabled/");
// Should be reported within field trial.
capabilities = engine_.GetCapabilities();
EXPECT_FALSE(capabilities.header_extensions.empty());
for (const RtpExtension& extension : capabilities.header_extensions) {
if (extension.uri == RtpExtension::kVideoContentTypeUri) {
EXPECT_EQ(RtpExtension::kVideoContentTypeDefaultId, extension.id);
return;
}
}
FAIL() << "Video Content Type extension not in header-extension list.";
}
TEST_F(WebRtcVideoEngine2Test, CVOSetHeaderExtensionBeforeAddSendStream) {
// Allocate the capturer first to prevent early destruction before channel's
// dtor is called.