Set number of temporal layers for VideoSendStream.

Introduces a mapping between EncoderConfig and VideoCodec. More
specifically it also removes an assert that there should be no set
temporal layers in the new API, which is wrong and was temporary.

R=stefan@webrtc.org
BUG=1788

Review URL: https://webrtc-codereview.appspot.com/25619004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7256 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
pbos@webrtc.org 2014-09-22 09:32:46 +00:00
parent 612171527e
commit 759982d357
2 changed files with 24 additions and 2 deletions

View File

@ -330,6 +330,8 @@ bool VideoSendStream::ReconfigureVideoEncoder(
video_codec.codecSpecific.VP8 = *reinterpret_cast<const VideoCodecVP8*>(
config.encoder_specific_settings);
}
video_codec.codecSpecific.VP8.numberOfTemporalLayers =
static_cast<unsigned char>(streams.back().temporal_layers.size());
} else {
// TODO(pbos): Support encoder_settings codec-agnostically.
assert(config.encoder_specific_settings == NULL);
@ -362,8 +364,8 @@ bool VideoSendStream::ReconfigureVideoEncoder(
sim_stream->targetBitrate = streams[i].target_bitrate_bps / 1000;
sim_stream->maxBitrate = streams[i].max_bitrate_bps / 1000;
sim_stream->qpMax = streams[i].max_qp;
// TODO(pbos): Implement mapping for temporal layers.
assert(streams[i].temporal_layers.empty());
sim_stream->numberOfTemporalLayers =
static_cast<unsigned char>(streams[i].temporal_layers.size());
video_codec.width = std::max(video_codec.width,
static_cast<unsigned short>(streams[i].width));

View File

@ -1420,6 +1420,7 @@ TEST_F(VideoSendStreamTest, EncoderSetupPropagatesCommonEncoderConfigValues) {
}
TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp8Config) {
static const size_t kNumberOfTemporalLayers = 4;
class VideoCodecConfigObserver : public test::SendTest,
public test::FakeEncoder {
public:
@ -1438,6 +1439,11 @@ TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp8Config) {
send_config->encoder_settings.encoder = this;
send_config->encoder_settings.payload_name = "VP8";
for (size_t i = 0; i < encoder_config->streams.size(); ++i) {
encoder_config->streams[i].temporal_layers.resize(
kNumberOfTemporalLayers);
}
encoder_config->encoder_specific_settings = &vp8_settings_;
encoder_config_ = *encoder_config;
}
@ -1452,6 +1458,20 @@ TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp8Config) {
int32_t number_of_cores,
uint32_t max_payload_size) OVERRIDE {
EXPECT_EQ(kVideoCodecVP8, config->codecType);
// Check that the number of temporal layers has propagated properly to
// VideoCodec.
EXPECT_EQ(kNumberOfTemporalLayers,
config->codecSpecific.VP8.numberOfTemporalLayers);
for (unsigned char i = 0; i < config->numberOfSimulcastStreams; ++i) {
EXPECT_EQ(kNumberOfTemporalLayers,
config->simulcastStream[i].numberOfTemporalLayers);
}
// Set expected temporal layers as they should have been set when
// reconfiguring the encoder and not match the set config.
vp8_settings_.numberOfTemporalLayers = kNumberOfTemporalLayers;
EXPECT_EQ(0,
memcmp(&config->codecSpecific.VP8,
&vp8_settings_,