Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: webrtc/media/engine/webrtcvideoengine2_unittest.cc

Issue 2497773003: Use different RTX payload types for different H264 profiles (Closed)
Patch Set: Fix bug and add test. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <algorithm> 11 #include <algorithm>
12 #include <map> 12 #include <map>
13 #include <memory> 13 #include <memory>
14 #include <vector> 14 #include <vector>
15 15
16 #include "webrtc/base/arraysize.h" 16 #include "webrtc/base/arraysize.h"
17 #include "webrtc/base/gunit.h" 17 #include "webrtc/base/gunit.h"
18 #include "webrtc/base/stringutils.h" 18 #include "webrtc/base/stringutils.h"
19 #include "webrtc/common_video/h264/profile_level_id.h"
19 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" 20 #include "webrtc/logging/rtc_event_log/rtc_event_log.h"
20 #include "webrtc/media/base/testutils.h" 21 #include "webrtc/media/base/testutils.h"
21 #include "webrtc/media/base/videoengine_unittest.h" 22 #include "webrtc/media/base/videoengine_unittest.h"
22 #include "webrtc/media/engine/fakewebrtccall.h" 23 #include "webrtc/media/engine/fakewebrtccall.h"
23 #include "webrtc/media/engine/fakewebrtcvideoengine.h" 24 #include "webrtc/media/engine/fakewebrtcvideoengine.h"
24 #include "webrtc/media/engine/simulcast.h" 25 #include "webrtc/media/engine/simulcast.h"
25 #include "webrtc/media/engine/webrtcvideoengine2.h" 26 #include "webrtc/media/engine/webrtcvideoengine2.h"
26 #include "webrtc/media/engine/webrtcvoiceengine.h" 27 #include "webrtc/media/engine/webrtcvoiceengine.h"
27 #include "webrtc/test/field_trial.h" 28 #include "webrtc/test/field_trial.h"
28 #include "webrtc/video_encoder.h" 29 #include "webrtc/video_encoder.h"
(...skipping 25 matching lines...) Expand all
54 EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam( 55 EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam(
55 cricket::kRtcpFbParamNack, cricket::kRtcpFbNackParamPli))); 56 cricket::kRtcpFbParamNack, cricket::kRtcpFbNackParamPli)));
56 EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam( 57 EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam(
57 cricket::kRtcpFbParamRemb, cricket::kParamValueEmpty))); 58 cricket::kRtcpFbParamRemb, cricket::kParamValueEmpty)));
58 EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam( 59 EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam(
59 cricket::kRtcpFbParamTransportCc, cricket::kParamValueEmpty))); 60 cricket::kRtcpFbParamTransportCc, cricket::kParamValueEmpty)));
60 EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam( 61 EXPECT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam(
61 cricket::kRtcpFbParamCcm, cricket::kRtcpFbCcmParamFir))); 62 cricket::kRtcpFbParamCcm, cricket::kRtcpFbCcmParamFir)));
62 } 63 }
63 64
65 // Return true if any codec in |codecs| is an RTX codec with associated payload
66 // type |payload_type|.
67 bool HasRtxCodec(const std::vector<cricket::VideoCodec>& codecs,
68 int payload_type) {
69 for (const cricket::VideoCodec& codec : codecs) {
70 int associated_payload_type;
71 if (cricket::CodecNamesEq(codec.name.c_str(), "rtx") &&
72 codec.GetParam(cricket::kCodecParamAssociatedPayloadType,
73 &associated_payload_type) &&
74 associated_payload_type == payload_type) {
75 return true;
76 }
77 }
78 return false;
79 }
80
64 static rtc::scoped_refptr<webrtc::VideoFrameBuffer> CreateBlackFrameBuffer( 81 static rtc::scoped_refptr<webrtc::VideoFrameBuffer> CreateBlackFrameBuffer(
65 int width, 82 int width,
66 int height) { 83 int height) {
67 rtc::scoped_refptr<webrtc::I420Buffer> buffer = 84 rtc::scoped_refptr<webrtc::I420Buffer> buffer =
68 webrtc::I420Buffer::Create(width, height); 85 webrtc::I420Buffer::Create(width, height);
69 buffer->SetToBlack(); 86 buffer->SetToBlack();
70 return buffer; 87 return buffer;
71 } 88 }
72 89
73 void VerifySendStreamHasRtxTypes(const webrtc::VideoSendStream::Config& config, 90 void VerifySendStreamHasRtxTypes(const webrtc::VideoSendStream::Config& config,
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); 385 EXPECT_TRUE(channel->RemoveSendStream(kSsrc));
369 EXPECT_EQ(0u, encoder_factory.encoders().size()); 386 EXPECT_EQ(0u, encoder_factory.encoders().size());
370 } 387 }
371 388
372 // Test that when an external encoder factory supports a codec we don't 389 // Test that when an external encoder factory supports a codec we don't
373 // internally support, we still add an RTX codec for it. 390 // internally support, we still add an RTX codec for it.
374 // TODO(deadbeef): Currently this test is only effective if WebRTC is 391 // TODO(deadbeef): Currently this test is only effective if WebRTC is
375 // built with no internal H264 support. This test should be updated 392 // built with no internal H264 support. This test should be updated
376 // if/when we start adding RTX codecs for unrecognized codec names. 393 // if/when we start adding RTX codecs for unrecognized codec names.
377 TEST_F(WebRtcVideoEngine2Test, RtxCodecAddedForExternalCodec) { 394 TEST_F(WebRtcVideoEngine2Test, RtxCodecAddedForExternalCodec) {
395 using webrtc::H264::ProfileLevelIdToString;
396 using webrtc::H264::ProfileLevelId;
397 using webrtc::H264::kLevel1;
398 cricket::VideoCodec h264_constrained_baseline("H264");
399 h264_constrained_baseline.params[kH264FmtpProfileLevelId] =
400 *ProfileLevelIdToString(
401 ProfileLevelId(webrtc::H264::kProfileConstrainedBaseline, kLevel1));
402 cricket::VideoCodec h264_constrained_high("H264");
403 h264_constrained_high.params[kH264FmtpProfileLevelId] =
404 *ProfileLevelIdToString(
405 ProfileLevelId(webrtc::H264::kProfileConstrainedHigh, kLevel1));
406 cricket::VideoCodec h264_high("H264");
407 h264_high.params[kH264FmtpProfileLevelId] = *ProfileLevelIdToString(
408 ProfileLevelId(webrtc::H264::kProfileHigh, kLevel1));
409
378 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 410 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
379 encoder_factory.AddSupportedVideoCodecType("H264"); 411 encoder_factory.AddSupportedVideoCodec(h264_constrained_baseline);
412 encoder_factory.AddSupportedVideoCodec(h264_constrained_high);
413 encoder_factory.AddSupportedVideoCodec(h264_high);
380 engine_.SetExternalEncoderFactory(&encoder_factory); 414 engine_.SetExternalEncoderFactory(&encoder_factory);
381 engine_.Init(); 415 engine_.Init();
382 416
383 auto codecs = engine_.codecs(); 417 // First figure out what payload types the test codecs got assigned.
384 // First figure out what payload type the test codec got assigned. 418 const std::vector<cricket::VideoCodec> codecs = engine_.codecs();
385 auto test_codec_it = 419 // Now search for RTX codecs for them. Expect that Constrained Baseline and
386 std::find_if(codecs.begin(), codecs.end(), 420 // Constrained High got an associated RTX codec, but not High.
387 [](const VideoCodec& c) { return c.name == "H264"; }); 421 EXPECT_TRUE(HasRtxCodec(
388 ASSERT_NE(codecs.end(), test_codec_it); 422 codecs, FindMatchingCodec(codecs, h264_constrained_baseline)->id));
389 // Now search for an RTX codec for it. 423 EXPECT_TRUE(HasRtxCodec(
390 EXPECT_TRUE(std::any_of(codecs.begin(), codecs.end(), 424 codecs, FindMatchingCodec(codecs, h264_constrained_high)->id));
391 [&test_codec_it](const VideoCodec& c) { 425 EXPECT_FALSE(HasRtxCodec(
392 int associated_payload_type; 426 codecs, FindMatchingCodec(codecs, h264_high)->id));
393 return c.name == "rtx" &&
394 c.GetParam(kCodecParamAssociatedPayloadType,
395 &associated_payload_type) &&
396 associated_payload_type == test_codec_it->id;
397 }));
398 } 427 }
399 428
400 void WebRtcVideoEngine2Test::TestExtendedEncoderOveruse( 429 void WebRtcVideoEngine2Test::TestExtendedEncoderOveruse(
401 bool use_external_encoder) { 430 bool use_external_encoder) {
402 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; 431 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
403 encoder_factory.AddSupportedVideoCodecType("VP8"); 432 encoder_factory.AddSupportedVideoCodecType("VP8");
404 cricket::VideoSendParameters parameters; 433 cricket::VideoSendParameters parameters;
405 parameters.codecs.push_back(kVp8Codec); 434 parameters.codecs.push_back(kVp8Codec);
406 std::unique_ptr<VideoMediaChannel> channel; 435 std::unique_ptr<VideoMediaChannel> channel;
407 FakeCall* fake_call = new FakeCall(webrtc::Call::Config(&event_log_)); 436 FakeCall* fake_call = new FakeCall(webrtc::Call::Config(&event_log_));
(...skipping 3330 matching lines...) Expand 10 before | Expand all | Expand 10 after
3738 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) { 3767 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) {
3739 VerifySimulcastSettings(kVp8Codec, 1280, 720, 3, 3); 3768 VerifySimulcastSettings(kVp8Codec, 1280, 720, 3, 3);
3740 } 3769 }
3741 3770
3742 // Test that we normalize send codec format size in simulcast. 3771 // Test that we normalize send codec format size in simulcast.
3743 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { 3772 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) {
3744 cricket::VideoCodec codec(kVp8Codec); 3773 cricket::VideoCodec codec(kVp8Codec);
3745 VerifySimulcastSettings(codec, 541, 271, 2, 2); 3774 VerifySimulcastSettings(codec, 541, 271, 2, 2);
3746 } 3775 }
3747 } // namespace cricket 3776 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698