Remove cricket::VideoCodec with, height and framerate properties

Since WebRtcVideoSendStream have reconfigures the send codec to match the incoming captured frames widht and height they have not been used.
Framerate has just been set when parsing sdp to 60fps and not changed elsewhere.

This cl require some upstream projects to change first.

BUG=webrtc:5332

Review-Url: https://codereview.webrtc.org/2408153002
Cr-Commit-Position: refs/heads/master@{#14733}
This commit is contained in:
perkj 2016-10-24 01:21:16 -07:00 committed by Commit bot
parent d3c40089fa
commit 267527459b
17 changed files with 151 additions and 413 deletions

View File

@ -43,21 +43,7 @@ const char SessionDescriptionInterface::kPrAnswer[] = "pranswer";
const char SessionDescriptionInterface::kAnswer[] = "answer";
const int JsepSessionDescription::kDefaultVideoCodecId = 100;
// This is effectively a max value of the frame rate. 30 is default from camera.
const int JsepSessionDescription::kDefaultVideoCodecFramerate = 60;
const char JsepSessionDescription::kDefaultVideoCodecName[] = "VP8";
// Used as default max video codec size before we have it in signaling.
#if defined(ANDROID) || defined(WEBRTC_IOS)
// Limit default max video codec size for Android to avoid
// HW VP8 codec initialization failure for resolutions higher
// than 1280x720 or 720x1280.
// Same patch for iOS to support 720P in portrait mode.
const int JsepSessionDescription::kMaxVideoCodecWidth = 1280;
const int JsepSessionDescription::kMaxVideoCodecHeight = 1280;
#else
const int JsepSessionDescription::kMaxVideoCodecWidth = 1920;
const int JsepSessionDescription::kMaxVideoCodecHeight = 1080;
#endif
SessionDescriptionInterface* CreateSessionDescription(const std::string& type,
const std::string& sdp,

View File

@ -66,13 +66,8 @@ class JsepSessionDescription : public SessionDescriptionInterface {
size_t mediasection_index) const;
virtual bool ToString(std::string* out) const;
// Default video encoder settings. The resolution is the max resolution.
// TODO(perkj): Implement proper negotiation of video resolution.
static const int kDefaultVideoCodecId;
static const int kDefaultVideoCodecFramerate;
static const char kDefaultVideoCodecName[];
static const int kMaxVideoCodecWidth;
static const int kMaxVideoCodecHeight;
private:
std::unique_ptr<cricket::SessionDescription> description_;

View File

@ -51,7 +51,7 @@ static cricket::SessionDescription* CreateCricketSessionDescription() {
desc->AddContent(cricket::CN_AUDIO, cricket::NS_JINGLE_RTP,
audio.release());
video->AddCodec(cricket::VideoCodec(120, "VP8", 640, 480, 30));
video->AddCodec(cricket::VideoCodec(120, "VP8"));
desc->AddContent(cricket::CN_VIDEO, cricket::NS_JINGLE_RTP,
video.release());

View File

@ -2965,18 +2965,12 @@ void UpdateCodec(int payload_type,
// |name|, |width|, |height|, and |framerate|.
void UpdateCodec(int payload_type,
const std::string& name,
int width,
int height,
int framerate,
VideoContentDescription* video_desc) {
// Codec may already be populated with (only) optional parameters
// (from an fmtp).
cricket::VideoCodec codec =
GetCodecWithPayloadType(video_desc->codecs(), payload_type);
codec.name = name;
codec.width = width;
codec.height = height;
codec.framerate = framerate;
AddOrReplaceCodec<VideoContentDescription, cricket::VideoCodec>(video_desc,
codec);
}
@ -3030,12 +3024,7 @@ bool ParseRtpmapAttribute(const std::string& line,
if (media_type == cricket::MEDIA_TYPE_VIDEO) {
VideoContentDescription* video_desc =
static_cast<VideoContentDescription*>(media_desc);
// TODO: We will send resolution in SDP. For now use
// JsepSessionDescription::kMaxVideoCodecWidth and kMaxVideoCodecHeight.
UpdateCodec(payload_type, encoding_name,
JsepSessionDescription::kMaxVideoCodecWidth,
JsepSessionDescription::kMaxVideoCodecHeight,
JsepSessionDescription::kDefaultVideoCodecFramerate,
video_desc);
} else if (media_type == cricket::MEDIA_TYPE_AUDIO) {
// RFC 4566

View File

@ -1046,10 +1046,7 @@ class WebRtcSdpTest : public testing::Test {
"inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj|2^20|1:32", ""));
video->set_protocol(cricket::kMediaProtocolSavpf);
video->AddCodec(
VideoCodec(120, JsepSessionDescription::kDefaultVideoCodecName,
JsepSessionDescription::kMaxVideoCodecWidth,
JsepSessionDescription::kMaxVideoCodecHeight,
JsepSessionDescription::kDefaultVideoCodecFramerate));
VideoCodec(120, JsepSessionDescription::kDefaultVideoCodecName));
return video;
}

View File

@ -218,28 +218,14 @@ std::string AudioCodec::ToString() const {
std::string VideoCodec::ToString() const {
std::ostringstream os;
os << "VideoCodec[" << id << ":" << name << ":" << width << ":" << height
<< ":" << framerate << "]";
os << "VideoCodec[" << id << ":" << name << "]";
return os.str();
}
VideoCodec::VideoCodec(int id,
const std::string& name,
int width,
int height,
int framerate)
: Codec(id, name, kVideoCodecClockrate),
width(width),
height(height),
framerate(framerate) {}
VideoCodec::VideoCodec(int id, const std::string& name)
: Codec(id, name, kVideoCodecClockrate),
width(0),
height(0),
framerate(0) {}
: Codec(id, name, kVideoCodecClockrate) {}
VideoCodec::VideoCodec() : Codec(), width(0), height(0), framerate(0) {
VideoCodec::VideoCodec() : Codec() {
clockrate = kVideoCodecClockrate;
}
@ -247,15 +233,11 @@ VideoCodec::VideoCodec(const VideoCodec& c) = default;
VideoCodec& VideoCodec::operator=(const VideoCodec& c) {
Codec::operator=(c);
width = c.width;
height = c.height;
framerate = c.framerate;
return *this;
}
bool VideoCodec::operator==(const VideoCodec& c) const {
return width == c.width && height == c.height && framerate == c.framerate &&
Codec::operator==(c);
return Codec::operator==(c);
}
bool VideoCodec::Matches(const VideoCodec& codec) const {
@ -285,7 +267,7 @@ bool VideoCodec::Matches(const VideoCodec& codec) const {
VideoCodec VideoCodec::CreateRtxCodec(int rtx_payload_type,
int associated_payload_type) {
VideoCodec rtx_codec(rtx_payload_type, kRtxCodecName, 0, 0, 0);
VideoCodec rtx_codec(rtx_payload_type, kRtxCodecName);
rtx_codec.SetParam(kCodecParamAssociatedPayloadType, associated_payload_type);
return rtx_codec;
}

View File

@ -139,16 +139,7 @@ struct AudioCodec : public Codec {
};
struct VideoCodec : public Codec {
int width;
int height;
int framerate;
// Creates a codec with the given parameters.
VideoCodec(int id,
const std::string& name,
int width,
int height,
int framerate);
VideoCodec(int id, const std::string& name);
// Creates an empty codec.
VideoCodec();

View File

@ -131,20 +131,15 @@ TEST(CodecTest, TestAudioCodecMatches) {
}
TEST(CodecTest, TestVideoCodecOperators) {
VideoCodec c0(96, "V", 320, 200, 30);
VideoCodec c1(95, "V", 320, 200, 30);
VideoCodec c2(96, "x", 320, 200, 30);
VideoCodec c3(96, "V", 120, 200, 30);
VideoCodec c4(96, "V", 320, 100, 30);
VideoCodec c5(96, "V", 320, 200, 10);
VideoCodec c0(96, "V");
VideoCodec c1(95, "V");
VideoCodec c2(96, "x");
EXPECT_TRUE(c0 != c1);
EXPECT_TRUE(c0 != c2);
EXPECT_TRUE(c0 != c3);
EXPECT_TRUE(c0 != c4);
EXPECT_TRUE(c0 != c5);
VideoCodec c7;
VideoCodec c8(0, "", 0, 0, 0);
VideoCodec c8(0, "");
VideoCodec c9 = c0;
EXPECT_TRUE(c8 == c7);
EXPECT_TRUE(c9 != c7);
@ -169,24 +164,24 @@ TEST(CodecTest, TestVideoCodecOperators) {
TEST(CodecTest, TestVideoCodecMatches) {
// Test a codec with a static payload type.
VideoCodec c0(95, "V", 320, 200, 30);
EXPECT_TRUE(c0.Matches(VideoCodec(95, "", 640, 400, 15)));
EXPECT_FALSE(c0.Matches(VideoCodec(96, "", 320, 200, 30)));
VideoCodec c0(95, "V");
EXPECT_TRUE(c0.Matches(VideoCodec(95, "")));
EXPECT_FALSE(c0.Matches(VideoCodec(96, "")));
// Test a codec with a dynamic payload type.
VideoCodec c1(96, "V", 320, 200, 30);
EXPECT_TRUE(c1.Matches(VideoCodec(96, "V", 640, 400, 15)));
EXPECT_TRUE(c1.Matches(VideoCodec(97, "V", 640, 400, 15)));
EXPECT_TRUE(c1.Matches(VideoCodec(96, "v", 640, 400, 15)));
EXPECT_TRUE(c1.Matches(VideoCodec(97, "v", 640, 400, 15)));
EXPECT_FALSE(c1.Matches(VideoCodec(96, "", 320, 200, 30)));
EXPECT_FALSE(c1.Matches(VideoCodec(95, "V", 640, 400, 15)));
VideoCodec c1(96, "V");
EXPECT_TRUE(c1.Matches(VideoCodec(96, "V")));
EXPECT_TRUE(c1.Matches(VideoCodec(97, "V")));
EXPECT_TRUE(c1.Matches(VideoCodec(96, "v")));
EXPECT_TRUE(c1.Matches(VideoCodec(97, "v")));
EXPECT_FALSE(c1.Matches(VideoCodec(96, "")));
EXPECT_FALSE(c1.Matches(VideoCodec(95, "V")));
}
TEST(CodecTest, TestVideoCodecMatchesH264Baseline) {
const VideoCodec no_params(96, cricket::kH264CodecName, 640, 480, 30);
const VideoCodec no_params(96, cricket::kH264CodecName);
VideoCodec baseline(96, cricket::kH264CodecName, 640, 480, 30);
VideoCodec baseline(96, cricket::kH264CodecName);
baseline.SetParam(cricket::kH264FmtpProfileLevelId,
cricket::kH264FmtpDefaultProfileLevelId);
@ -197,12 +192,12 @@ TEST(CodecTest, TestVideoCodecMatchesH264Baseline) {
}
TEST(CodecTest, TestVideoCodecMatchesH264Profiles) {
VideoCodec baseline(96, cricket::kH264CodecName, 640, 480, 30);
VideoCodec baseline(96, cricket::kH264CodecName);
baseline.SetParam(cricket::kH264FmtpProfileLevelId,
cricket::kH264FmtpDefaultProfileLevelId);
baseline.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, "1");
VideoCodec constrained_baseline(96, cricket::kH264CodecName, 640, 480, 30);
VideoCodec constrained_baseline(96, cricket::kH264CodecName);
constrained_baseline.SetParam(cricket::kH264FmtpProfileLevelId,
cricket::kH264ProfileLevelConstrainedBaseline);
constrained_baseline.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, "1");
@ -215,7 +210,7 @@ TEST(CodecTest, TestVideoCodecMatchesH264Profiles) {
TEST(CodecTest, TestVideoCodecMatchesH264LevelAsymmetry) {
// Constrained Baseline Profile Level 1.0.
VideoCodec cbp_1_0(96, cricket::kH264CodecName, 640, 480, 30);
VideoCodec cbp_1_0(96, cricket::kH264CodecName);
cbp_1_0.SetParam(cricket::kH264FmtpProfileLevelId,
"42e00a");
@ -224,7 +219,7 @@ TEST(CodecTest, TestVideoCodecMatchesH264LevelAsymmetry) {
"1");
// Constrained Baseline Profile Level 3.1.
VideoCodec cbp_3_1(96, cricket::kH264CodecName, 640, 480, 30);
VideoCodec cbp_3_1(96, cricket::kH264CodecName);
cbp_3_1.SetParam(cricket::kH264FmtpProfileLevelId, "42e01f");
VideoCodec cbp_3_1_asymmetry_allowed = cbp_3_1;
@ -306,10 +301,10 @@ TEST(CodecTest, TestIntersectFeedbackParams) {
TEST(CodecTest, TestGetCodecType) {
// Codec type comparison should be case insenstive on names.
const VideoCodec codec(96, "V", 320, 200, 30);
const VideoCodec rtx_codec(96, "rTx", 320, 200, 30);
const VideoCodec ulpfec_codec(96, "ulpFeC", 320, 200, 30);
const VideoCodec red_codec(96, "ReD", 320, 200, 30);
const VideoCodec codec(96, "V");
const VideoCodec rtx_codec(96, "rTx");
const VideoCodec ulpfec_codec(96, "ulpFeC");
const VideoCodec red_codec(96, "ReD");
EXPECT_EQ(VideoCodec::CODEC_VIDEO, codec.GetCodecType());
EXPECT_EQ(VideoCodec::CODEC_RTX, rtx_codec.GetCodecType());
EXPECT_EQ(VideoCodec::CODEC_ULPFEC, ulpfec_codec.GetCodecType());
@ -327,7 +322,7 @@ TEST(CodecTest, TestCreateRtxCodec) {
}
TEST(CodecTest, TestValidateCodecFormat) {
const VideoCodec codec(96, "V", 320, 200, 30);
const VideoCodec codec(96, "V");
ASSERT_TRUE(codec.ValidateCodecFormat());
// Accept 0-127 as payload types.
@ -348,11 +343,6 @@ TEST(CodecTest, TestValidateCodecFormat) {
too_high_payload_type.id = 128;
EXPECT_FALSE(too_high_payload_type.ValidateCodecFormat());
// Accept non-video codecs with zero dimensions.
VideoCodec zero_width_rtx_codec = VideoCodec::CreateRtxCodec(96, 120);
zero_width_rtx_codec.width = 0;
EXPECT_TRUE(zero_width_rtx_codec.ValidateCodecFormat());
// Reject codecs with min bitrate > max bitrate.
VideoCodec incorrect_bitrates = codec;
incorrect_bitrates.params[kCodecParamMinBitrate] = "100";
@ -373,7 +363,7 @@ TEST(CodecTest, TestValidateCodecFormat) {
}
TEST(CodecTest, TestToCodecParameters) {
const VideoCodec v(96, "V", 320, 200, 30);
const VideoCodec v(96, "V");
webrtc::RtpCodecParameters codec_params_1 = v.ToCodecParameters();
EXPECT_EQ(96, codec_params_1.payload_type);
EXPECT_EQ("V", codec_params_1.mime_type);

View File

@ -806,7 +806,7 @@ class FakeVideoEngine : public FakeBaseEngine {
FakeVideoEngine() : capture_(false) {
// Add a fake video codec. Note that the name must not be "" as there are
// sanity checks against that.
codecs_.push_back(VideoCodec(0, "fake_video_codec", 0, 0, 0));
codecs_.push_back(VideoCodec(0, "fake_video_codec"));
}
void Init() {}
bool SetOptions(const VideoOptions& options) {

View File

@ -114,7 +114,5 @@ const int kDefaultRtxVp9PlType = 97;
const int kDefaultRtxRedPlType = 98;
const int kDefaultRtxH264PlType = 99;
const int kDefaultVideoMaxWidth = 640;
const int kDefaultVideoMaxHeight = 400;
const int kDefaultVideoMaxFramerate = 30;
const int kDefaultVideoMaxFramerate = 60;
} // namespace cricket

View File

@ -138,8 +138,6 @@ extern const int kDefaultRtxVp9PlType;
extern const int kDefaultRtxRedPlType;
extern const int kDefaultRtxH264PlType;
extern const int kDefaultVideoMaxWidth;
extern const int kDefaultVideoMaxHeight;
extern const int kDefaultVideoMaxFramerate;
} // namespace cricket

View File

@ -50,31 +50,23 @@ static const uint32_t kDefaultReceiveSsrc = 0;
static const uint32_t kSsrc = 1234u;
static const uint32_t kRtxSsrc = 4321u;
static const uint32_t kSsrcs4[] = {1, 2, 3, 4};
inline bool IsEqualRes(const cricket::VideoCodec& a, int w, int h, int fps) {
return a.width == w && a.height == h && a.framerate == fps;
}
static const int kVideoWidth = 640;
static const int kVideoHeight = 360;
static const int kFramerate = 30;
inline bool IsEqualCodec(const cricket::VideoCodec& a,
const cricket::VideoCodec& b) {
return a.id == b.id && a.name == b.name &&
IsEqualRes(a, b.width, b.height, b.framerate);
return a.id == b.id && a.name == b.name;
}
namespace std {
inline std::ostream& operator<<(std::ostream& s, const cricket::VideoCodec& c) {
s << "{" << c.name << "(" << c.id << "), "
<< c.width << "x" << c.height << "x" << c.framerate << "}";
s << "{" << c.name << "(" << c.id << ")"
<< "}";
return s;
}
} // namespace std
inline int TimeBetweenSend(const cricket::VideoCodec& codec) {
return static_cast<int>(
cricket::VideoFormat::FpsToInterval(codec.framerate) /
rtc::kNumNanosecsPerMillisec);
}
template<class E, class C>
class VideoMediaChannelTest : public testing::Test,
public sigslot::has_slots<> {
@ -102,7 +94,7 @@ class VideoMediaChannelTest : public testing::Test,
EXPECT_TRUE(channel_->AddSendStream(DefaultSendStreamParams()));
video_capturer_.reset(CreateFakeVideoCapturer());
cricket::VideoFormat format(640, 480,
cricket::VideoFormat::FpsToInterval(30),
cricket::VideoFormat::FpsToInterval(kFramerate),
cricket::FOURCC_I420);
EXPECT_EQ(cricket::CS_RUNNING, video_capturer_->Start(format));
EXPECT_TRUE(
@ -139,7 +131,7 @@ class VideoMediaChannelTest : public testing::Test,
// Setup the receive and renderer for second stream after send.
video_capturer_2_.reset(CreateFakeVideoCapturer());
cricket::VideoFormat format(640, 480,
cricket::VideoFormat::FpsToInterval(30),
cricket::VideoFormat::FpsToInterval(kFramerate),
cricket::FOURCC_I420);
EXPECT_EQ(cricket::CS_RUNNING, video_capturer_2_->Start(format));
@ -153,13 +145,13 @@ class VideoMediaChannelTest : public testing::Test,
return SetOneCodec(DefaultCodec());
}
bool SetOneCodec(int pt, const char* name, int w, int h, int fr) {
return SetOneCodec(cricket::VideoCodec(pt, name, w, h, fr));
bool SetOneCodec(int pt, const char* name) {
return SetOneCodec(cricket::VideoCodec(pt, name));
}
bool SetOneCodec(const cricket::VideoCodec& codec) {
cricket::VideoFormat capture_format(codec.width, codec.height,
cricket::VideoFormat::FpsToInterval(codec.framerate),
cricket::FOURCC_I420);
cricket::VideoFormat capture_format(
kVideoWidth, kVideoHeight,
cricket::VideoFormat::FpsToInterval(kFramerate), cricket::FOURCC_I420);
if (video_capturer_) {
EXPECT_EQ(cricket::CS_RUNNING, video_capturer_->Start(capture_format));
@ -396,7 +388,7 @@ class VideoMediaChannelTest : public testing::Test,
EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_));
EXPECT_EQ(0, renderer_.num_rendered_frames());
EXPECT_TRUE(SendFrame());
EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout);
EXPECT_FRAME_WAIT(1, kVideoWidth, kVideoHeight, kTimeout);
std::unique_ptr<const rtc::CopyOnWriteBuffer> p(GetRtpPacket(0));
EXPECT_EQ(codec.id, GetPayloadType(p.get()));
}
@ -409,7 +401,7 @@ class VideoMediaChannelTest : public testing::Test,
for (int i = 0; i < duration_sec; ++i) {
for (int frame = 1; frame <= fps; ++frame) {
EXPECT_TRUE(WaitAndSendFrame(1000 / fps));
EXPECT_FRAME_WAIT(frame + i * fps, codec.width, codec.height, kTimeout);
EXPECT_FRAME_WAIT(frame + i * fps, kVideoWidth, kVideoHeight, kTimeout);
}
}
std::unique_ptr<const rtc::CopyOnWriteBuffer> p(GetRtpPacket(0));
@ -434,8 +426,8 @@ class VideoMediaChannelTest : public testing::Test,
EXPECT_EQ(0, info.senders[0].firs_rcvd);
EXPECT_EQ(0, info.senders[0].plis_rcvd);
EXPECT_EQ(0, info.senders[0].nacks_rcvd);
EXPECT_EQ(DefaultCodec().width, info.senders[0].send_frame_width);
EXPECT_EQ(DefaultCodec().height, info.senders[0].send_frame_height);
EXPECT_EQ(kVideoWidth, info.senders[0].send_frame_width);
EXPECT_EQ(kVideoHeight, info.senders[0].send_frame_height);
EXPECT_GT(info.senders[0].framerate_input, 0);
EXPECT_GT(info.senders[0].framerate_sent, 0);
@ -452,8 +444,8 @@ class VideoMediaChannelTest : public testing::Test,
EXPECT_EQ(0, info.receivers[0].firs_sent);
EXPECT_EQ(0, info.receivers[0].plis_sent);
EXPECT_EQ(0, info.receivers[0].nacks_sent);
EXPECT_EQ(DefaultCodec().width, info.receivers[0].frame_width);
EXPECT_EQ(DefaultCodec().height, info.receivers[0].frame_height);
EXPECT_EQ(kVideoWidth, info.receivers[0].frame_width);
EXPECT_EQ(kVideoHeight, info.receivers[0].frame_height);
EXPECT_GT(info.receivers[0].framerate_rcvd, 0);
EXPECT_GT(info.receivers[0].framerate_decoded, 0);
EXPECT_GT(info.receivers[0].framerate_output, 0);
@ -493,10 +485,10 @@ class VideoMediaChannelTest : public testing::Test,
ssrcs.push_back(2);
network_interface_.SetConferenceMode(true, ssrcs);
EXPECT_TRUE(SendFrame());
EXPECT_FRAME_ON_RENDERER_WAIT(
renderer1, 1, DefaultCodec().width, DefaultCodec().height, kTimeout);
EXPECT_FRAME_ON_RENDERER_WAIT(
renderer2, 1, DefaultCodec().width, DefaultCodec().height, kTimeout);
EXPECT_FRAME_ON_RENDERER_WAIT(renderer1, 1, kVideoWidth, kVideoHeight,
kTimeout);
EXPECT_FRAME_ON_RENDERER_WAIT(renderer2, 1, kVideoWidth, kVideoHeight,
kTimeout);
EXPECT_TRUE(channel_->SetSend(false));
@ -507,8 +499,8 @@ class VideoMediaChannelTest : public testing::Test,
// For webrtc, bytes_sent does not include the RTP header length.
EXPECT_GT(GetSenderStats(0).bytes_sent, 0);
EXPECT_EQ_WAIT(NumRtpPackets(), GetSenderStats(0).packets_sent, kTimeout);
EXPECT_EQ(DefaultCodec().width, GetSenderStats(0).send_frame_width);
EXPECT_EQ(DefaultCodec().height, GetSenderStats(0).send_frame_height);
EXPECT_EQ(kVideoWidth, GetSenderStats(0).send_frame_width);
EXPECT_EQ(kVideoHeight, GetSenderStats(0).send_frame_height);
ASSERT_EQ(2U, info.receivers.size());
for (size_t i = 0; i < info.receivers.size(); ++i) {
@ -517,10 +509,8 @@ class VideoMediaChannelTest : public testing::Test,
EXPECT_EQ_WAIT(NumRtpBytes(), GetReceiverStats(i).bytes_rcvd, kTimeout);
EXPECT_EQ_WAIT(NumRtpPackets(), GetReceiverStats(i).packets_rcvd,
kTimeout);
EXPECT_EQ_WAIT(DefaultCodec().width, GetReceiverStats(i).frame_width,
kTimeout);
EXPECT_EQ_WAIT(DefaultCodec().height, GetReceiverStats(i).frame_height,
kTimeout);
EXPECT_EQ_WAIT(kVideoWidth, GetReceiverStats(i).frame_width, kTimeout);
EXPECT_EQ_WAIT(kVideoHeight, GetReceiverStats(i).frame_height, kTimeout);
}
}
// Test that stats work properly for a conf call with multiple send streams.
@ -538,7 +528,7 @@ class VideoMediaChannelTest : public testing::Test,
EXPECT_TRUE(SetSend(true));
EXPECT_TRUE(SendFrame());
EXPECT_TRUE_WAIT(NumRtpPackets() > 0, kTimeout);
EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout);
EXPECT_FRAME_WAIT(1, kVideoWidth, kVideoHeight, kTimeout);
// Add an additional capturer, and hook up a renderer to receive it.
cricket::FakeVideoRenderer renderer2;
@ -581,8 +571,8 @@ class VideoMediaChannelTest : public testing::Test,
<< "Timed out while waiting for packet counts for all sent packets.";
EXPECT_EQ(1U, info.senders[0].ssrcs().size());
EXPECT_EQ(1234U, info.senders[0].ssrcs()[0]);
EXPECT_EQ(DefaultCodec().width, info.senders[0].send_frame_width);
EXPECT_EQ(DefaultCodec().height, info.senders[0].send_frame_height);
EXPECT_EQ(kVideoWidth, info.senders[0].send_frame_width);
EXPECT_EQ(kVideoHeight, info.senders[0].send_frame_height);
EXPECT_EQ(1U, info.senders[1].ssrcs().size());
EXPECT_EQ(5678U, info.senders[1].ssrcs()[0]);
EXPECT_EQ(kTestWidth, info.senders[1].send_frame_width);
@ -657,7 +647,7 @@ class VideoMediaChannelTest : public testing::Test,
channel_->OnPacketReceived(&packet1, rtc::PacketTime());
EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_));
EXPECT_TRUE(SendFrame());
EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout);
EXPECT_FRAME_WAIT(1, kVideoWidth, kVideoHeight, kTimeout);
}
// Tests empty StreamParams is rejected.
@ -677,7 +667,7 @@ class VideoMediaChannelTest : public testing::Test,
EXPECT_TRUE(SetSend(true));
EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_));
EXPECT_TRUE(SendFrame());
EXPECT_FRAME_WAIT(1, DefaultCodec().width, DefaultCodec().height, kTimeout);
EXPECT_FRAME_WAIT(1, kVideoWidth, kVideoHeight, kTimeout);
EXPECT_GT(NumRtpPackets(), 0);
uint32_t ssrc = 0;
size_t last_packet = NumRtpPackets() - 1;
@ -727,17 +717,17 @@ class VideoMediaChannelTest : public testing::Test,
ssrcs.push_back(2);
network_interface_.SetConferenceMode(true, ssrcs);
EXPECT_TRUE(SendFrame());
EXPECT_FRAME_ON_RENDERER_WAIT(
renderer1, 1, DefaultCodec().width, DefaultCodec().height, kTimeout);
EXPECT_FRAME_ON_RENDERER_WAIT(
renderer2, 1, DefaultCodec().width, DefaultCodec().height, kTimeout);
EXPECT_FRAME_ON_RENDERER_WAIT(renderer1, 1, kVideoWidth, kVideoHeight,
kTimeout);
EXPECT_FRAME_ON_RENDERER_WAIT(renderer2, 1, kVideoWidth, kVideoHeight,
kTimeout);
std::unique_ptr<const rtc::CopyOnWriteBuffer> p(GetRtpPacket(0));
EXPECT_EQ(DefaultCodec().id, GetPayloadType(p.get()));
EXPECT_EQ(DefaultCodec().width, renderer1.width());
EXPECT_EQ(DefaultCodec().height, renderer1.height());
EXPECT_EQ(DefaultCodec().width, renderer2.width());
EXPECT_EQ(DefaultCodec().height, renderer2.height());
EXPECT_EQ(kVideoWidth, renderer1.width());
EXPECT_EQ(kVideoHeight, renderer1.height());
EXPECT_EQ(kVideoWidth, renderer2.width());
EXPECT_EQ(kVideoHeight, renderer2.height());
EXPECT_TRUE(channel_->RemoveRecvStream(2));
EXPECT_TRUE(channel_->RemoveRecvStream(1));
}
@ -745,15 +735,14 @@ class VideoMediaChannelTest : public testing::Test,
// Tests that we can add and remove capturers and frames are sent out properly
void AddRemoveCapturer() {
cricket::VideoCodec codec = DefaultCodec();
codec.width = 320;
codec.height = 240;
const int time_between_send = TimeBetweenSend(codec);
const int time_between_send_ms =
cricket::VideoFormat::FpsToInterval(kFramerate);
EXPECT_TRUE(SetOneCodec(codec));
EXPECT_TRUE(SetSend(true));
EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_));
EXPECT_EQ(0, renderer_.num_rendered_frames());
EXPECT_TRUE(SendFrame());
EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout);
EXPECT_FRAME_WAIT(1, kVideoWidth, kVideoHeight, kTimeout);
std::unique_ptr<cricket::FakeVideoCapturer> capturer(
CreateFakeVideoCapturer());
@ -777,7 +766,7 @@ class VideoMediaChannelTest : public testing::Test,
int captured_frames = 1;
for (int iterations = 0; iterations < 2; ++iterations) {
EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr, capturer.get()));
rtc::Thread::Current()->ProcessMessages(time_between_send);
rtc::Thread::Current()->ProcessMessages(time_between_send_ms);
EXPECT_TRUE(capturer->CaptureCustomFrame(format.width, format.height,
cricket::FOURCC_I420));
++captured_frames;
@ -822,14 +811,14 @@ class VideoMediaChannelTest : public testing::Test,
EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_));
EXPECT_EQ(0, renderer_.num_rendered_frames());
EXPECT_TRUE(SendFrame());
EXPECT_FRAME_WAIT(1, 640, 400, kTimeout);
EXPECT_FRAME_WAIT(1, kVideoWidth, kVideoHeight, kTimeout);
// Wait for one frame so they don't get dropped because we send frames too
// tightly.
rtc::Thread::Current()->ProcessMessages(30);
// Remove the capturer.
EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr, nullptr));
// Wait for one black frame for removing the capturer.
EXPECT_FRAME_WAIT(2, 640, 400, kTimeout);
EXPECT_FRAME_WAIT(2, kVideoWidth, kVideoHeight, kTimeout);
// No capturer was added, so this SetVideoSend shouldn't do anything.
EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr, nullptr));
@ -849,7 +838,7 @@ class VideoMediaChannelTest : public testing::Test,
cricket::StreamParams::CreateLegacy(kSsrc)));
EXPECT_TRUE(channel_->SetSink(kSsrc, &renderer_));
cricket::VideoFormat capture_format; // default format
capture_format.interval = cricket::VideoFormat::FpsToInterval(30);
capture_format.interval = cricket::VideoFormat::FpsToInterval(kFramerate);
// Set up additional stream 1.
cricket::FakeVideoRenderer renderer1;
EXPECT_FALSE(channel_->SetSink(1, &renderer1));
@ -900,153 +889,6 @@ class VideoMediaChannelTest : public testing::Test,
EXPECT_TRUE(channel_->SetVideoSend(2, true, nullptr, nullptr));
}
void HighAspectHighHeightCapturer() {
const int kWidth = 80;
const int kHeight = 10000;
const int kScaledWidth = 20;
const int kScaledHeight = 2500;
cricket::VideoCodec codec(DefaultCodec());
EXPECT_TRUE(SetOneCodec(codec));
EXPECT_TRUE(SetSend(true));
cricket::FakeVideoRenderer renderer;
EXPECT_TRUE(channel_->AddRecvStream(
cricket::StreamParams::CreateLegacy(kSsrc)));
EXPECT_TRUE(channel_->SetSink(kSsrc, &renderer));
EXPECT_EQ(0, renderer.num_rendered_frames());
EXPECT_TRUE(SendFrame());
EXPECT_GT_FRAME_ON_RENDERER_WAIT(
renderer, 1, codec.width, codec.height, kTimeout);
// Registering an external capturer is currently the same as screen casting
// (update the test when this changes).
std::unique_ptr<cricket::FakeVideoCapturer> capturer(
CreateFakeVideoCapturer());
const std::vector<cricket::VideoFormat>* formats =
capturer->GetSupportedFormats();
cricket::VideoFormat capture_format = (*formats)[0];
EXPECT_EQ(cricket::CS_RUNNING, capturer->Start(capture_format));
// Capture frame to not get same frame timestamps as previous capturer.
capturer->CaptureFrame();
EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr, capturer.get()));
EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(30));
EXPECT_TRUE(capturer->CaptureCustomFrame(kWidth, kHeight,
cricket::FOURCC_ARGB));
EXPECT_GT_FRAME_ON_RENDERER_WAIT(
renderer, 2, kScaledWidth, kScaledHeight, kTimeout);
EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr, nullptr));
}
// Tests that we can adapt video resolution with 16:10 aspect ratio properly.
void AdaptResolution16x10() {
EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_));
cricket::VideoCodec codec(DefaultCodec());
codec.width = 640;
codec.height = 400;
SendAndReceive(codec);
codec.width /= 2;
codec.height /= 2;
// Adapt the resolution.
EXPECT_TRUE(SetOneCodec(codec));
EXPECT_TRUE(WaitAndSendFrame(30));
EXPECT_FRAME_WAIT(2, codec.width, codec.height, kTimeout);
}
// Tests that we can adapt video resolution with 4:3 aspect ratio properly.
void AdaptResolution4x3() {
EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_));
cricket::VideoCodec codec(DefaultCodec());
codec.width = 640;
codec.height = 400;
SendAndReceive(codec);
codec.width /= 2;
codec.height /= 2;
// Adapt the resolution.
EXPECT_TRUE(SetOneCodec(codec));
EXPECT_TRUE(WaitAndSendFrame(30));
EXPECT_FRAME_WAIT(2, codec.width, codec.height, kTimeout);
}
// Tests that we can drop all frames properly.
void AdaptDropAllFrames() {
// Set the channel codec's resolution to 0, which will require the adapter
// to drop all frames.
cricket::VideoCodec codec(DefaultCodec());
codec.width = codec.height = codec.framerate = 0;
EXPECT_TRUE(SetOneCodec(codec));
EXPECT_TRUE(SetSend(true));
EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_));
EXPECT_EQ(0, renderer_.num_rendered_frames());
EXPECT_TRUE(SendFrame());
EXPECT_TRUE(SendFrame());
rtc::Thread::Current()->ProcessMessages(500);
EXPECT_EQ(0, renderer_.num_rendered_frames());
}
// Tests that we can reduce the frame rate on demand properly.
// TODO(fbarchard): This test is flakey on pulse. Fix and re-enable
void AdaptFramerate() {
cricket::VideoCodec codec(DefaultCodec());
int frame_count = 0;
// The capturer runs at 30 fps. The channel requires 30 fps.
EXPECT_TRUE(SetOneCodec(codec));
EXPECT_TRUE(SetSend(true));
EXPECT_EQ(frame_count, renderer_.num_rendered_frames());
EXPECT_TRUE(WaitAndSendFrame(0)); // Should be rendered.
EXPECT_TRUE(WaitAndSendFrame(30)); // Should be rendered.
frame_count += 2;
EXPECT_FRAME_WAIT(frame_count, codec.width, codec.height, kTimeout);
std::unique_ptr<const rtc::CopyOnWriteBuffer> p(GetRtpPacket(0));
EXPECT_EQ(codec.id, GetPayloadType(p.get()));
// The channel requires 15 fps.
codec.framerate = 15;
EXPECT_TRUE(SetOneCodec(codec));
EXPECT_TRUE(WaitAndSendFrame(0)); // Should be rendered.
EXPECT_TRUE(WaitAndSendFrame(30)); // Should be dropped.
EXPECT_TRUE(WaitAndSendFrame(30)); // Should be rendered.
frame_count += 2;
EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout);
// The channel requires 10 fps.
codec.framerate = 10;
EXPECT_TRUE(SetOneCodec(codec));
EXPECT_TRUE(WaitAndSendFrame(0)); // Should be rendered.
EXPECT_TRUE(WaitAndSendFrame(30)); // Should be dropped.
EXPECT_TRUE(WaitAndSendFrame(30)); // Should be dropped.
EXPECT_TRUE(WaitAndSendFrame(30)); // Should be rendered.
frame_count += 2;
EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout);
// The channel requires 8 fps. The adapter adapts to 10 fps, which is the
// closest factor of 30.
codec.framerate = 8;
EXPECT_TRUE(SetOneCodec(codec));
EXPECT_TRUE(WaitAndSendFrame(0)); // Should be rendered.
EXPECT_TRUE(WaitAndSendFrame(30)); // Should be dropped.
EXPECT_TRUE(WaitAndSendFrame(30)); // Should be dropped.
EXPECT_TRUE(WaitAndSendFrame(30)); // Should be rendered.
frame_count += 2;
EXPECT_EQ_WAIT(frame_count, renderer_.num_rendered_frames(), kTimeout);
}
// Tests that adapted frames won't be upscaled to a higher resolution.
void SendsLowerResolutionOnSmallerFrames() {
cricket::VideoCodec codec = DefaultCodec();
codec.width = 320;
codec.height = 240;
EXPECT_TRUE(SetOneCodec(codec));
EXPECT_TRUE(SetSend(true));
EXPECT_TRUE(channel_->SetSink(kDefaultReceiveSsrc, &renderer_));
EXPECT_EQ(0, renderer_.num_rendered_frames());
EXPECT_TRUE(SendFrame());
EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout);
// Check that we send smaller frames at the new resolution.
EXPECT_TRUE(rtc::Thread::Current()->ProcessMessages(33));
EXPECT_TRUE(video_capturer_->CaptureCustomFrame(
codec.width / 2, codec.height / 2, cricket::FOURCC_I420));
EXPECT_FRAME_WAIT(2, codec.width / 2, codec.height / 2, kTimeout);
}
// Test that multiple send streams can be created and deleted properly.
void MultipleSendStreams() {
// Remove stream added in Setup. I.e. remove stream corresponding to default

View File

@ -182,8 +182,7 @@ void AddDefaultFeedbackParams(VideoCodec* codec) {
static VideoCodec MakeVideoCodecWithDefaultFeedbackParams(int payload_type,
const char* name) {
VideoCodec codec(payload_type, name, kDefaultVideoMaxWidth,
kDefaultVideoMaxHeight, kDefaultVideoMaxFramerate);
VideoCodec codec(payload_type, name);
AddDefaultFeedbackParams(&codec);
return codec;
}
@ -674,9 +673,7 @@ std::vector<VideoCodec> WebRtcVideoEngine2::GetSupportedCodecs() const {
const int kExternalVideoPayloadTypeBase = 120;
size_t payload_type = kExternalVideoPayloadTypeBase + i;
RTC_DCHECK(payload_type < 128);
VideoCodec codec(static_cast<int>(payload_type), codecs[i].name,
codecs[i].max_width, codecs[i].max_height,
codecs[i].max_fps);
VideoCodec codec(static_cast<int>(payload_type), codecs[i].name);
AddDefaultFeedbackParams(&codec);
AddCodecAndMaybeRtxCodec(codec, &supported_codecs);
@ -2005,12 +2002,9 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig(
int max_qp = kDefaultQpMax;
codec.GetParam(kCodecParamMaxQuantization, &max_qp);
int max_framerate =
codec.framerate != 0 ? codec.framerate : kDefaultVideoMaxFramerate;
encoder_config.video_stream_factory =
new rtc::RefCountedObject<EncoderStreamFactory>(
codec.name, max_qp, max_framerate, is_screencast,
codec.name, max_qp, kDefaultVideoMaxFramerate, is_screencast,
parameters_.conference_mode);
return encoder_config;
}

View File

@ -31,18 +31,13 @@ using webrtc::RtpExtension;
namespace {
static const int kDefaultQpMax = 56;
static const int kDefaultFramerate = 30;
static const cricket::VideoCodec kVp8Codec720p(100, "VP8", 1280, 720, 30);
static const cricket::VideoCodec kVp8Codec360p(100, "VP8", 640, 360, 30);
static const cricket::VideoCodec kVp8Codec270p(100, "VP8", 480, 270, 30);
static const cricket::VideoCodec kVp8Codec(100, "VP8");
static const cricket::VideoCodec kVp9Codec(101, "VP9");
static const cricket::VideoCodec kH264Codec(102, "H264");
static const cricket::VideoCodec kVp8Codec(100, "VP8", 640, 400, 30);
static const cricket::VideoCodec kVp9Codec(101, "VP9", 640, 400, 30);
static const cricket::VideoCodec kH264Codec(102, "H264", 640, 400, 30);
static const cricket::VideoCodec kRedCodec(116, "red", 0, 0, 0);
static const cricket::VideoCodec kUlpfecCodec(117, "ulpfec", 0, 0, 0);
static const cricket::VideoCodec kRedCodec(116, "red");
static const cricket::VideoCodec kUlpfecCodec(117, "ulpfec");
static const uint8_t kRedRtxPayloadType = 125;
@ -833,34 +828,20 @@ WEBRTC_BASE_TEST(RemoveCapturerWithoutAdd);
WEBRTC_BASE_TEST(AddRemoveCapturerMultipleSources);
// TODO(pbos): Figure out why this fails so often.
WEBRTC_DISABLED_BASE_TEST(HighAspectHighHeightCapturer);
WEBRTC_BASE_TEST(RejectEmptyStreamParams);
WEBRTC_BASE_TEST(AdaptResolution16x10);
WEBRTC_BASE_TEST(AdaptResolution4x3);
// TODO(juberti): Restore this test once we support sending 0 fps.
WEBRTC_DISABLED_BASE_TEST(AdaptDropAllFrames);
// TODO(juberti): Understand why we get decode errors on this test.
WEBRTC_DISABLED_BASE_TEST(AdaptFramerate);
WEBRTC_BASE_TEST(SendsLowerResolutionOnSmallerFrames);
WEBRTC_BASE_TEST(MultipleSendStreams);
TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8Vga) {
SendAndReceive(cricket::VideoCodec(100, "VP8", 640, 400, 30));
SendAndReceive(cricket::VideoCodec(100, "VP8"));
}
TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8Qvga) {
SendAndReceive(cricket::VideoCodec(100, "VP8", 320, 200, 30));
SendAndReceive(cricket::VideoCodec(100, "VP8"));
}
TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8SvcQqvga) {
SendAndReceive(cricket::VideoCodec(100, "VP8", 160, 100, 30));
SendAndReceive(cricket::VideoCodec(100, "VP8"));
}
TEST_F(WebRtcVideoChannel2BaseTest, TwoStreamsSendAndReceive) {
@ -1508,7 +1489,7 @@ TEST_F(WebRtcVideoChannel2Test, NackCanBeEnabledAndDisabled) {
// earlier.
TEST_F(WebRtcVideoChannel2Test, ReconfiguresEncodersWhenNotSending) {
cricket::VideoSendParameters parameters;
parameters.codecs.push_back(kVp8Codec720p);
parameters.codecs.push_back(kVp8Codec);
ASSERT_TRUE(channel_->SetSendParameters(parameters));
channel_->SetSend(false);
@ -1521,21 +1502,21 @@ TEST_F(WebRtcVideoChannel2Test, ReconfiguresEncodersWhenNotSending) {
cricket::FakeVideoCapturer capturer;
EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
EXPECT_EQ(cricket::CS_RUNNING,
capturer.Start(capturer.GetSupportedFormats()->front()));
VideoFormat capture_format = capturer.GetSupportedFormats()->front();
EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format));
EXPECT_TRUE(capturer.CaptureFrame());
// Frame entered, should be reconfigured to new dimensions.
streams = stream->GetVideoStreams();
EXPECT_EQ(kVp8Codec720p.width, streams[0].width);
EXPECT_EQ(kVp8Codec720p.height, streams[0].height);
EXPECT_EQ(capture_format.width, streams[0].width);
EXPECT_EQ(capture_format.height, streams[0].height);
EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
}
TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) {
static const int kScreenshareMinBitrateKbps = 800;
cricket::VideoCodec codec = kVp8Codec360p;
cricket::VideoCodec codec = kVp8Codec;
cricket::VideoSendParameters parameters;
parameters.codecs.push_back(codec);
EXPECT_TRUE(channel_->SetSendParameters(parameters));
@ -1724,7 +1705,7 @@ TEST_F(WebRtcVideoChannel2Test, Vp8DenoisingEnabledByDefault) {
TEST_F(WebRtcVideoChannel2Test, VerifyVp8SpecificSettings) {
cricket::VideoSendParameters parameters;
parameters.codecs.push_back(kVp8Codec720p);
parameters.codecs.push_back(kVp8Codec);
ASSERT_TRUE(channel_->SetSendParameters(parameters));
// Single-stream settings should apply with RTX as well (verifies that we
@ -1805,7 +1786,7 @@ TEST_F(WebRtcVideoChannel2Test, SetIdenticalOptionsDoesntReconfigureEncoder) {
EXPECT_EQ(cricket::CS_RUNNING,
capturer.Start(capturer.GetSupportedFormats()->front()));
cricket::VideoSendParameters parameters;
parameters.codecs.push_back(kVp8Codec720p);
parameters.codecs.push_back(kVp8Codec);
ASSERT_TRUE(channel_->SetSendParameters(parameters));
FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front();
@ -1985,7 +1966,7 @@ TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenScreensharing) {
}
TEST_F(WebRtcVideoChannel2Test, AdaptsOnOveruseAndChangeResolution) {
cricket::VideoCodec codec = kVp8Codec720p;
cricket::VideoCodec codec = kVp8Codec;
cricket::VideoSendParameters parameters;
parameters.codecs.push_back(codec);
@ -2059,7 +2040,7 @@ TEST_F(WebRtcVideoChannel2Test, AdaptsOnOveruseAndChangeResolution) {
}
TEST_F(WebRtcVideoChannel2Test, PreviousAdaptationDoesNotApplyToScreenshare) {
cricket::VideoCodec codec = kVp8Codec720p;
cricket::VideoCodec codec = kVp8Codec;
cricket::VideoSendParameters parameters;
parameters.codecs.push_back(codec);
@ -2122,7 +2103,7 @@ TEST_F(WebRtcVideoChannel2Test, PreviousAdaptationDoesNotApplyToScreenshare) {
void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse,
bool is_screenshare) {
cricket::VideoCodec codec = kVp8Codec720p;
cricket::VideoCodec codec = kVp8Codec;
cricket::VideoSendParameters parameters;
parameters.codecs.push_back(codec);
@ -2141,8 +2122,8 @@ void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse,
VideoOptions options;
options.is_screencast = rtc::Optional<bool>(is_screenshare);
EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
EXPECT_EQ(cricket::CS_RUNNING,
capturer.Start(capturer.GetSupportedFormats()->front()));
cricket::VideoFormat capture_format = capturer.GetSupportedFormats()->front();
EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format));
EXPECT_TRUE(channel_->SetSend(true));
@ -2158,8 +2139,8 @@ void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse,
EXPECT_TRUE(capturer.CaptureFrame());
EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames());
EXPECT_EQ(codec.width, send_stream->GetLastWidth());
EXPECT_EQ(codec.height, send_stream->GetLastHeight());
EXPECT_EQ(capture_format.width, send_stream->GetLastWidth());
EXPECT_EQ(capture_format.height, send_stream->GetLastHeight());
EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
return;
@ -2175,11 +2156,11 @@ void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse,
if (is_screenshare) {
// Do not adapt screen share.
EXPECT_EQ(codec.width, send_stream->GetLastWidth());
EXPECT_EQ(codec.height, send_stream->GetLastHeight());
EXPECT_EQ(capture_format.width, send_stream->GetLastWidth());
EXPECT_EQ(capture_format.height, send_stream->GetLastHeight());
} else {
EXPECT_LT(send_stream->GetLastWidth(), codec.width);
EXPECT_LT(send_stream->GetLastHeight(), codec.height);
EXPECT_LT(send_stream->GetLastWidth(), capture_format.width);
EXPECT_LT(send_stream->GetLastHeight(), capture_format.height);
}
// Trigger underuse which should go back to normal resolution.
@ -2187,8 +2168,8 @@ void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse,
EXPECT_TRUE(capturer.CaptureFrame());
EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames());
EXPECT_EQ(codec.width, send_stream->GetLastWidth());
EXPECT_EQ(codec.height, send_stream->GetLastHeight());
EXPECT_EQ(capture_format.width, send_stream->GetLastWidth());
EXPECT_EQ(capture_format.height, send_stream->GetLastHeight());
EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
}
@ -2269,7 +2250,7 @@ TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFec) {
TEST_F(WebRtcVideoChannel2Test,
SetSendCodecRejectsRtxWithoutAssociatedPayloadType) {
cricket::VideoSendParameters parameters;
cricket::VideoCodec rtx_codec(96, "rtx", 0, 0, 0);
cricket::VideoCodec rtx_codec(96, "rtx");
parameters.codecs.push_back(rtx_codec);
EXPECT_FALSE(channel_->SetSendParameters(parameters))
<< "RTX codec without associated payload type should be rejected.";
@ -2314,9 +2295,9 @@ TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFecDisablesFec) {
TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) {
cricket::VideoSendParameters parameters;
cricket::VideoCodec codec720p(100, "VP8", 1280, 720, 30);
codec720p.SetParam(kCodecParamMaxQuantization, kDefaultQpMax);
parameters.codecs.push_back(codec720p);
cricket::VideoCodec codec(100, "VP8");
codec.SetParam(kCodecParamMaxQuantization, kDefaultQpMax);
parameters.codecs.push_back(codec);
ASSERT_TRUE(channel_->SetSendParameters(parameters));
channel_->SetSend(true);
@ -2329,8 +2310,8 @@ TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) {
EXPECT_EQ(kDefaultQpMax, streams[0].max_qp);
parameters.codecs.clear();
codec720p.SetParam(kCodecParamMaxQuantization, kDefaultQpMax + 1);
parameters.codecs.push_back(codec720p);
codec.SetParam(kCodecParamMaxQuantization, kDefaultQpMax + 1);
parameters.codecs.push_back(codec);
ASSERT_TRUE(channel_->SetSendParameters(parameters));
streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams();
EXPECT_EQ(kDefaultQpMax + 1, streams[0].max_qp);
@ -2446,7 +2427,7 @@ TEST_F(WebRtcVideoChannel2Test, SetMaxSendBandwidthAndAddSendStream) {
TEST_F(WebRtcVideoChannel2Test, SetMaxSendBitrateCanIncreaseSenderBitrate) {
cricket::VideoSendParameters parameters;
parameters.codecs.push_back(kVp8Codec720p);
parameters.codecs.push_back(kVp8Codec);
ASSERT_TRUE(channel_->SetSendParameters(parameters));
channel_->SetSend(true);
@ -2473,7 +2454,7 @@ TEST_F(WebRtcVideoChannel2Test, SetMaxSendBitrateCanIncreaseSenderBitrate) {
TEST_F(WebRtcVideoChannel2Test,
SetMaxSendBitrateCanIncreaseSimulcastSenderBitrate) {
cricket::VideoSendParameters parameters;
parameters.codecs.push_back(kVp8Codec720p);
parameters.codecs.push_back(kVp8Codec);
ASSERT_TRUE(channel_->SetSendParameters(parameters));
channel_->SetSend(true);
@ -2570,7 +2551,7 @@ TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithOnlyVp8) {
TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithRtx) {
cricket::VideoRecvParameters parameters;
parameters.codecs.push_back(kVp8Codec);
cricket::VideoCodec rtx_codec(96, "rtx", 0, 0, 0);
cricket::VideoCodec rtx_codec(96, "rtx");
parameters.codecs.push_back(rtx_codec);
EXPECT_FALSE(channel_->SetRecvParameters(parameters))
<< "RTX codec without associated payload should be rejected.";
@ -2582,7 +2563,7 @@ TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithRtx) {
parameters.codecs[1].SetParam("apt", kVp8Codec.id);
EXPECT_TRUE(channel_->SetRecvParameters(parameters));
cricket::VideoCodec rtx_codec2(97, "rtx", 0, 0, 0);
cricket::VideoCodec rtx_codec2(97, "rtx");
rtx_codec2.SetParam("apt", rtx_codec.id);
parameters.codecs.push_back(rtx_codec2);
@ -2612,7 +2593,7 @@ TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsAcceptDefaultCodecs) {
TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectUnsupportedCodec) {
cricket::VideoRecvParameters parameters;
parameters.codecs.push_back(kVp8Codec);
parameters.codecs.push_back(VideoCodec(101, "WTF3", 640, 400, 30));
parameters.codecs.push_back(VideoCodec(101, "WTF3"));
EXPECT_FALSE(channel_->SetRecvParameters(parameters));
}
@ -2923,7 +2904,7 @@ TEST_F(WebRtcVideoChannel2Test, GetStatsTracksAdaptationStats) {
channel_->SetVideoSend(kSsrcs3[0], true, nullptr, &video_capturer_vga));
EXPECT_TRUE(video_capturer_vga.CaptureFrame());
cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30);
cricket::VideoCodec send_codec(100, "VP8");
cricket::VideoSendParameters parameters;
parameters.codecs.push_back(send_codec);
EXPECT_TRUE(channel_->SetSendParameters(parameters));
@ -2998,7 +2979,7 @@ TEST_F(WebRtcVideoChannel2Test, GetStatsTracksAdaptationAndBandwidthStats) {
channel_->SetVideoSend(kSsrcs3[0], true, nullptr, &video_capturer_vga));
EXPECT_TRUE(video_capturer_vga.CaptureFrame());
cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30);
cricket::VideoCodec send_codec(100, "VP8");
cricket::VideoSendParameters parameters;
parameters.codecs.push_back(send_codec);
EXPECT_TRUE(channel_->SetSendParameters(parameters));
@ -3593,10 +3574,10 @@ TEST_F(WebRtcVideoChannel2Test, GetRtpReceiveFmtpSprop) {
TEST_F(WebRtcVideoChannel2Test, DISABLED_GetRtpReceiveFmtpSprop) {
#endif
cricket::VideoRecvParameters parameters;
cricket::VideoCodec kH264sprop1(101, "H264", 640, 400, 15);
cricket::VideoCodec kH264sprop1(101, "H264");
kH264sprop1.SetParam("sprop-parameter-sets", "uvw");
parameters.codecs.push_back(kH264sprop1);
cricket::VideoCodec kH264sprop2(102, "H264", 640, 400, 15);
cricket::VideoCodec kH264sprop2(102, "H264");
kH264sprop2.SetParam("sprop-parameter-sets", "xyz");
parameters.codecs.push_back(kH264sprop2);
EXPECT_TRUE(channel_->SetRecvParameters(parameters));
@ -3722,6 +3703,8 @@ class WebRtcVideoChannel2SimulcastTest : public testing::Test {
protected:
void VerifySimulcastSettings(const VideoCodec& codec,
int capture_width,
int capture_height,
size_t num_configured_streams,
size_t expected_num_streams) {
cricket::VideoSendParameters parameters;
@ -3740,7 +3723,7 @@ class WebRtcVideoChannel2SimulcastTest : public testing::Test {
EXPECT_TRUE(
channel_->SetVideoSend(ssrcs.front(), true, nullptr, &capturer));
EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(cricket::VideoFormat(
codec.width, codec.height,
capture_width, capture_height,
cricket::VideoFormat::FpsToInterval(30),
cricket::FOURCC_I420)));
channel_->SetSend(true);
@ -3750,8 +3733,8 @@ class WebRtcVideoChannel2SimulcastTest : public testing::Test {
ASSERT_EQ(expected_num_streams, video_streams.size());
std::vector<webrtc::VideoStream> expected_streams = GetSimulcastConfig(
num_configured_streams, codec.width, codec.height, 0, kDefaultQpMax,
codec.framerate != 0 ? codec.framerate : kDefaultFramerate);
num_configured_streams, capture_width, capture_height, 0, kDefaultQpMax,
kDefaultVideoMaxFramerate);
ASSERT_EQ(expected_streams.size(), video_streams.size());
@ -3834,18 +3817,16 @@ class WebRtcVideoChannel2SimulcastTest : public testing::Test {
};
TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith2SimulcastStreams) {
VerifySimulcastSettings(kVp8Codec, 2, 2);
VerifySimulcastSettings(kVp8Codec, 640, 360, 2, 2);
}
TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) {
VerifySimulcastSettings(kVp8Codec720p, 3, 3);
VerifySimulcastSettings(kVp8Codec, 1280, 720, 3, 3);
}
// Test that we normalize send codec format size in simulcast.
TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) {
cricket::VideoCodec codec(kVp8Codec270p);
codec.width += 1;
codec.height += 1;
VerifySimulcastSettings(codec, 2, 2);
cricket::VideoCodec codec(kVp8Codec);
VerifySimulcastSettings(codec, 541, 271, 2, 2);
}
} // namespace cricket

View File

@ -42,8 +42,8 @@ namespace {
const cricket::AudioCodec kPcmuCodec(0, "PCMU", 64000, 8000, 1);
const cricket::AudioCodec kPcmaCodec(8, "PCMA", 64000, 8000, 1);
const cricket::AudioCodec kIsacCodec(103, "ISAC", 40000, 16000, 1);
const cricket::VideoCodec kH264Codec(97, "H264", 640, 400, 30);
const cricket::VideoCodec kH264SvcCodec(99, "H264-SVC", 320, 200, 15);
const cricket::VideoCodec kH264Codec(97, "H264");
const cricket::VideoCodec kH264SvcCodec(99, "H264-SVC");
const cricket::DataCodec kGoogleDataCodec(101, "google-data");
const uint32_t kSsrc1 = 0x1111;
const uint32_t kSsrc2 = 0x2222;
@ -2113,8 +2113,7 @@ void ChannelTest<VideoTraits>::CopyContent(
template<>
bool ChannelTest<VideoTraits>::CodecMatches(const cricket::VideoCodec& c1,
const cricket::VideoCodec& c2) {
return c1.name == c2.name && c1.width == c2.width && c1.height == c2.height &&
c1.framerate == c2.framerate;
return c1.name == c2.name;
}
template <>

View File

@ -27,8 +27,7 @@ static const AudioCodec kAudioCodecs[] = {
};
static const VideoCodec kVideoCodecs[] = {
VideoCodec(99, "H264", 100, 200, 300),
VideoCodec(100, "VP8", 100, 200, 300), VideoCodec(96, "rtx", 100, 200, 300),
VideoCodec(99, "H264"), VideoCodec(100, "VP8"), VideoCodec(96, "rtx"),
};
class ChannelManagerTest : public testing::Test {
@ -171,7 +170,7 @@ TEST_F(ChannelManagerTest, NoTransportChannelTest) {
TEST_F(ChannelManagerTest, SetVideoRtxEnabled) {
std::vector<VideoCodec> codecs;
const VideoCodec rtx_codec(96, "rtx", 0, 0, 0);
const VideoCodec rtx_codec(96, "rtx");
// By default RTX is disabled.
cm_->GetSupportedVideoCodecs(&codecs);

View File

@ -96,16 +96,13 @@ static const AudioCodec kAudioCodecsAnswer[] = {
AudioCodec(0, "PCMU", 8000, 64000, 1),
};
static const VideoCodec kVideoCodecs1[] = {
VideoCodec(96, "H264-SVC", 320, 200, 30),
VideoCodec(97, "H264", 320, 200, 30)};
static const VideoCodec kVideoCodecs1[] = {VideoCodec(96, "H264-SVC"),
VideoCodec(97, "H264")};
static const VideoCodec kVideoCodecs2[] = {
VideoCodec(126, "H264", 320, 200, 30),
VideoCodec(127, "H263", 320, 200, 30)};
static const VideoCodec kVideoCodecs2[] = {VideoCodec(126, "H264"),
VideoCodec(127, "H263")};
static const VideoCodec kVideoCodecsAnswer[] = {
VideoCodec(97, "H264", 320, 200, 30)};
static const VideoCodec kVideoCodecsAnswer[] = {VideoCodec(97, "H264")};
static const DataCodec kDataCodecs1[] = {DataCodec(98, "binary-data"),
DataCodec(99, "utf8-text")};
@ -1842,7 +1839,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, RtxWithoutApt) {
opts.recv_audio = false;
std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1);
// This creates RTX without associated payload type parameter.
AddRtxCodec(VideoCodec(126, cricket::kRtxCodecName, 0, 0, 0), &f1_codecs);
AddRtxCodec(VideoCodec(126, cricket::kRtxCodecName), &f1_codecs);
f1_.set_video_codecs(f1_codecs);
std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2);
@ -1990,7 +1987,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateMultipleRtxSsrcs) {
// Use a single real codec, and then add RTX for it.
std::vector<VideoCodec> f1_codecs;
f1_codecs.push_back(VideoCodec(97, "H264", 320, 200, 30));
f1_codecs.push_back(VideoCodec(97, "H264"));
AddRtxCodec(VideoCodec::CreateRtxCodec(125, 97), &f1_codecs);
f1_.set_video_codecs(f1_codecs);