bug 1302935: enable vp9 in webrtc and fix missing gof fields in codecSpecific r=pkerr,drno

Also required fixing tests to handle more codecs
This commit is contained in:
Randell Jesup 2016-09-15 21:17:09 -04:00
parent c34cce3034
commit 6ec5958a84
9 changed files with 63 additions and 49 deletions

View File

@ -439,7 +439,7 @@ PeerConnectionTest.prototype.updateChainSteps = function() {
if (this.testOptions.h264) {
this.chain.insertAfterEach(
'PC_LOCAL_CREATE_OFFER',
[PC_LOCAL_REMOVE_VP8_FROM_OFFER]);
[PC_LOCAL_REMOVE_ALL_BUT_H264_FROM_OFFER]);
}
if (!this.testOptions.bundle) {
this.chain.insertAfterEach(

View File

@ -24,16 +24,14 @@ checkSdpCLineNotDefault: function(sdpStr, label) {
ok(!sdpStr.includes("c=IN IP4 0.0.0.0"), label + ": SDP contains non-zero IP c line");
},
// Also remove mode 0 if it's offered
// Note, we don't bother removing the fmtp lines, which makes a good test
// for some SDP parsing issues.
removeVP8: function(sdp) {
var updated_sdp = sdp.replace("a=rtpmap:120 VP8/90000\r\n","");
updated_sdp = updated_sdp.replace("RTP/SAVPF 120 126 97\r\n","RTP/SAVPF 126 97\r\n");
updated_sdp = updated_sdp.replace("RTP/SAVPF 120 126\r\n","RTP/SAVPF 126\r\n");
updated_sdp = updated_sdp.replace("a=rtcp-fb:120 nack\r\n","");
updated_sdp = updated_sdp.replace("a=rtcp-fb:120 nack pli\r\n","");
updated_sdp = updated_sdp.replace("a=rtcp-fb:120 ccm fir\r\n","");
// for some SDP parsing issues. It would be good to have a "removeAllButCodec(sdp, codec)" too.
removeCodec: function(sdp, codec) {
var updated_sdp = sdp.replace(new RegExp("a=rtpmap:" + codec + ".*\\/90000\\r\\n",""),"");
updated_sdp = updated_sdp.replace(new RegExp("(RTP\\/SAVPF.*)( " + codec + ")(.*\\r\\n)",""),"$1$3");
updated_sdp = updated_sdp.replace(new RegExp("a=rtcp-fb:" + codec + " nack\\r\\n",""),"");
updated_sdp = updated_sdp.replace(new RegExp("a=rtcp-fb:" + codec + " nack pli\\r\\n",""),"");
updated_sdp = updated_sdp.replace(new RegExp("a=rtcp-fb:" + codec + " ccm fir\\r\\n",""),"");
return updated_sdp;
},
@ -125,7 +123,8 @@ verifySdp: function(desc, expectedType, offerConstraintsList, offerOptions,
if (testOptions.h264) {
ok(desc.sdp.includes("a=rtpmap:126 H264/90000"), "H.264 codec is present in SDP");
} else {
ok(desc.sdp.includes("a=rtpmap:120 VP8/90000"), "VP8 codec is present in SDP");
ok(desc.sdp.includes("a=rtpmap:120 VP8/90000") ||
desc.sdp.includes("a=rtpmap:121 VP9/90000"), "VP8 or VP9 codec is present in SDP");
}
is(testOptions.rtcpmux, desc.sdp.includes("a=rtcp-mux"), "RTCP Mux is offered in SDP");
}

View File

@ -507,9 +507,10 @@ var commandsPeerConnectionOfferAnswer = [
}
];
function PC_LOCAL_REMOVE_VP8_FROM_OFFER(test) {
function PC_LOCAL_REMOVE_ALL_BUT_H264_FROM_OFFER(test) {
isnot(test.originalOffer.sdp.search("H264/90000"), -1, "H.264 should be present in the SDP offer");
test.originalOffer.sdp = sdputils.removeVP8(test.originalOffer.sdp);
test.originalOffer.sdp = sdputils.removeCodec(sdputils.removeCodec(sdputils.removeCodec(
test.originalOffer.sdp, 120), 121, 97));
info("Updated H264 only offer: " + JSON.stringify(test.originalOffer));
};

View File

@ -16,7 +16,9 @@
f().then(() => ok(false, msg),
e => is(e.name, reason, msg));
var removeVP8 = d => (d.sdp = d.sdp.replace("a=rtpmap:120 VP8/90000\r\n", ""), d);
var removeAllButCodec = (d, codec) =>
(d.sdp = d.sdp.replace(/m=video (\w) UDP\/TLS\/RTP\/SAVPF \w.*\r\n/,
"m=video $1 UDP/TLS/RTP/SAVPF " + codec + "\r\n"), d);
function testScale(codec) {
var pc1 = new RTCPeerConnection();
@ -30,7 +32,7 @@
pc1.onnegotiationneeded = e =>
pc1.createOffer()
.then(d => pc1.setLocalDescription(codec == "VP8" ? d : removeVP8(d)))
.then(d => pc1.setLocalDescription(codec == "VP8" ? d : removeAllButCodec(d, 126)))
.then(() => pc2.setRemoteDescription(pc1.localDescription))
.then(() => pc2.createAnswer()).then(d => pc2.setLocalDescription(d))
.then(() => pc1.setRemoteDescription(pc2.localDescription))

View File

@ -2142,16 +2142,6 @@ JsepSessionImpl::SetupDefaultCodecs()
// Supported video codecs.
// Note: order here implies priority for building offers!
JsepVideoCodecDescription* vp9 = new JsepVideoCodecDescription(
"121",
"VP9",
90000
);
// Defaults for mandatory params
vp9->mConstraints.maxFs = 12288; // Enough for 2048x1536
vp9->mConstraints.maxFps = 60;
mSupportedCodecs.values.push_back(vp9);
JsepVideoCodecDescription* vp8 = new JsepVideoCodecDescription(
"120",
"VP8",
@ -2162,6 +2152,16 @@ JsepSessionImpl::SetupDefaultCodecs()
vp8->mConstraints.maxFps = 60;
mSupportedCodecs.values.push_back(vp8);
JsepVideoCodecDescription* vp9 = new JsepVideoCodecDescription(
"121",
"VP9",
90000
);
// Defaults for mandatory params
vp9->mConstraints.maxFs = 12288; // Enough for 2048x1536
vp9->mConstraints.maxFps = 60;
mSupportedCodecs.values.push_back(vp9);
JsepVideoCodecDescription* h264_1 = new JsepVideoCodecDescription(
"126",
"H264",

View File

@ -2743,8 +2743,8 @@ TEST_F(JsepSessionTest, ValidateOfferedCodecParams)
ASSERT_EQ(SdpDirectionAttribute::kSendrecv, video_attrs.GetDirection());
ASSERT_EQ(6U, video_section.GetFormats().size());
ASSERT_EQ("121", video_section.GetFormats()[0]);
ASSERT_EQ("120", video_section.GetFormats()[1]);
ASSERT_EQ("120", video_section.GetFormats()[0]);
ASSERT_EQ("121", video_section.GetFormats()[1]);
ASSERT_EQ("126", video_section.GetFormats()[2]);
ASSERT_EQ("97", video_section.GetFormats()[3]);
ASSERT_EQ("122", video_section.GetFormats()[4]);
@ -2839,8 +2839,8 @@ TEST_F(JsepSessionTest, ValidateOfferedCodecParams)
auto& parsed_red_params =
*static_cast<const SdpFmtpAttributeList::RedParameters*>(red_params);
ASSERT_EQ(5U, parsed_red_params.encodings.size());
ASSERT_EQ(121, parsed_red_params.encodings[0]);
ASSERT_EQ(120, parsed_red_params.encodings[1]);
ASSERT_EQ(120, parsed_red_params.encodings[0]);
ASSERT_EQ(121, parsed_red_params.encodings[1]);
ASSERT_EQ(126, parsed_red_params.encodings[2]);
ASSERT_EQ(97, parsed_red_params.encodings[3]);
ASSERT_EQ(123, parsed_red_params.encodings[4]);
@ -2904,24 +2904,26 @@ TEST_F(JsepSessionTest, ValidateAnsweredCodecParams)
// TODO(bug 1099351): Once fixed, this stuff will need to be updated.
ASSERT_EQ(1U, video_section.GetFormats().size());
// ASSERT_EQ(3U, video_section.GetFormats().size());
ASSERT_EQ("121", video_section.GetFormats()[0]);
// ASSERT_EQ("126", video_section.GetFormats()[1]);
// ASSERT_EQ("97", video_section.GetFormats()[2]);
ASSERT_EQ("120", video_section.GetFormats()[0]);
// ASSERT_EQ("121", video_section.GetFormats()[1]);
// ASSERT_EQ("126", video_section.GetFormats()[2]);
// ASSERT_EQ("97", video_section.GetFormats()[3]);
// Validate rtpmap
ASSERT_TRUE(video_attrs.HasAttribute(SdpAttribute::kRtpmapAttribute));
auto& rtpmaps = video_attrs.GetRtpmap();
ASSERT_TRUE(rtpmaps.HasEntry("121"));
ASSERT_TRUE(rtpmaps.HasEntry("120"));
//ASSERT_TRUE(rtpmaps.HasEntry("121"));
// ASSERT_TRUE(rtpmaps.HasEntry("126"));
// ASSERT_TRUE(rtpmaps.HasEntry("97"));
//auto& vp8_entry = rtpmaps.GetEntry("120");
auto& vp9_entry = rtpmaps.GetEntry("121");
auto& vp8_entry = rtpmaps.GetEntry("120");
//auto& vp9_entry = rtpmaps.GetEntry("121");
// auto& h264_1_entry = rtpmaps.GetEntry("126");
// auto& h264_0_entry = rtpmaps.GetEntry("97");
//ASSERT_EQ("VP8", vp8_entry.name);
ASSERT_EQ("VP9", vp9_entry.name);
ASSERT_EQ("VP8", vp8_entry.name);
//ASSERT_EQ("VP9", vp9_entry.name);
// ASSERT_EQ("H264", h264_1_entry.name);
// ASSERT_EQ("H264", h264_0_entry.name);
@ -2932,17 +2934,17 @@ TEST_F(JsepSessionTest, ValidateAnsweredCodecParams)
ASSERT_EQ(1U, fmtps.size());
// ASSERT_EQ(3U, fmtps.size());
// VP9
ASSERT_EQ("121", fmtps[0].format);
// VP8
ASSERT_EQ("120", fmtps[0].format);
ASSERT_TRUE(!!fmtps[0].parameters);
ASSERT_EQ(SdpRtpmapAttributeList::kVP9, fmtps[0].parameters->codec_type);
ASSERT_EQ(SdpRtpmapAttributeList::kVP8, fmtps[0].parameters->codec_type);
auto& parsed_vp9_params =
auto& parsed_vp8_params =
*static_cast<const SdpFmtpAttributeList::VP8Parameters*>(
fmtps[0].parameters.get());
ASSERT_EQ((uint32_t)12288, parsed_vp9_params.max_fs);
ASSERT_EQ((uint32_t)60, parsed_vp9_params.max_fr);
ASSERT_EQ((uint32_t)12288, parsed_vp8_params.max_fs);
ASSERT_EQ((uint32_t)60, parsed_vp8_params.max_fr);
SetLocalAnswer(answer);

View File

@ -4165,9 +4165,11 @@ TEST_P(SignalingTest, ValidateMultipleVideoCodecsInOffer)
std::string offer = a1_->offer();
#ifdef H264_P0_SUPPORTED
ASSERT_NE(offer.find("UDP/TLS/RTP/SAVPF 120 126 97"), std::string::npos);
ASSERT_NE(offer.find("UDP/TLS/RTP/SAVPF 120 126 97") ||
offer.find("UDP/TLS/RTP/SAVPF 120 121 126 97"), std::string::npos);
#else
ASSERT_NE(offer.find("UDP/TLS/RTP/SAVPF 120 126"), std::string::npos);
ASSERT_NE(offer.find("UDP/TLS/RTP/SAVPF 120 126") ||
offer.find("UDP/TLS/RTP/SAVPF 120 121 126"), std::string::npos);
#endif
ASSERT_NE(offer.find("a=rtpmap:120 VP8/90000"), std::string::npos);
ASSERT_NE(offer.find("a=rtpmap:126 H264/90000"), std::string::npos);
@ -4200,8 +4202,15 @@ TEST_P(SignalingTest, RemoveVP8FromOfferWithP1First)
// Remove VP8 from offer
std::string offer = a1_->offer();
match = offer.find("UDP/TLS/RTP/SAVPF 120");
if (match != std::string::npos) {
offer.replace(match, strlen("UDP/TLS/RTP/SAVPF 120"), "UDP/TLS/RTP/SAVPF");
}
match = offer.find("UDP/TLS/RTP/SAVPF 121");
if (match != std::string::npos) {
offer.replace(match, strlen("UDP/TLS/RTP/SAVPF 121"), "UDP/TLS/RTP/SAVPF");
}
match = offer.find("UDP/TLS/RTP/SAVPF 126");
ASSERT_NE(std::string::npos, match);
offer.replace(match, strlen("UDP/TLS/RTP/SAVPF 120"), "UDP/TLS/RTP/SAVPF");
match = offer.find("profile-level-id");
ASSERT_NE(std::string::npos, match);

View File

@ -664,11 +664,11 @@ void VP9EncoderImpl::PopulateCodecSpecific(CodecSpecificInfo* codec_specific,
svc_internal_.svc_params.scaling_factor_num[i] /
svc_internal_.svc_params.scaling_factor_den[i];
}
if (!vp9_info->flexible_mode) {
vp9_info->gof.CopyGofInfoVP9(gof_);
}
}
#endif
if (!vp9_info->flexible_mode) {
vp9_info->gof.CopyGofInfoVP9(gof_);
}
}
int VP9EncoderImpl::GetEncodedLayerFrame(const vpx_codec_cx_pkt* pkt) {

View File

@ -452,6 +452,7 @@ pref("media.navigator.video.h264.level", 31); // 0x42E01f - level 3.1
pref("media.navigator.video.h264.max_br", 0);
pref("media.navigator.video.h264.max_mbps", 0);
pref("media.peerconnection.video.h264_enabled", false);
pref("media.peerconnection.video.vp9_enabled", true);
pref("media.getusermedia.aec", 1);
pref("media.getusermedia.browser.enabled", true);
#endif