Fix simulcast_encoder_adapter giving full target_bitrate to the 2nd layer of any simulcast setup during InitEncode.
BUG= R=stefan@webrtc.org Review URL: https://webrtc-codereview.appspot.com/51069004 Cr-Commit-Position: refs/heads/master@{#9265}
This commit is contained in:
parent
e4cb4e9aae
commit
67b635a47e
@ -206,8 +206,9 @@ int SimulcastEncoderAdapter::InitEncode(const VideoCodec* inst,
|
||||
stream_codec.numberOfSimulcastStreams = 1;
|
||||
} else {
|
||||
bool highest_resolution_stream = (i == (number_of_streams - 1));
|
||||
PopulateStreamCodec(&codec_, i, highest_resolution_stream,
|
||||
&stream_codec, &send_stream);
|
||||
PopulateStreamCodec(&codec_, i, number_of_streams,
|
||||
highest_resolution_stream, &stream_codec,
|
||||
&send_stream);
|
||||
}
|
||||
|
||||
// TODO(ronghuawu): Remove once this is handled in VP8EncoderImpl.
|
||||
@ -354,9 +355,8 @@ int SimulcastEncoderAdapter::SetRates(uint32_t new_bitrate_kbit,
|
||||
bool send_stream = true;
|
||||
uint32_t stream_bitrate = 0;
|
||||
for (size_t stream_idx = 0; stream_idx < streaminfos_.size(); ++stream_idx) {
|
||||
stream_bitrate = GetStreamBitrate(stream_idx,
|
||||
new_bitrate_kbit,
|
||||
&send_stream);
|
||||
stream_bitrate = GetStreamBitrate(stream_idx, streaminfos_.size(),
|
||||
new_bitrate_kbit, &send_stream);
|
||||
// Need a key frame if we have not sent this stream before.
|
||||
if (send_stream && !streaminfos_[stream_idx].send_stream) {
|
||||
streaminfos_[stream_idx].key_frame_request = true;
|
||||
@ -412,10 +412,12 @@ int32_t SimulcastEncoderAdapter::Encoded(
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t SimulcastEncoderAdapter::GetStreamBitrate(int stream_idx,
|
||||
uint32_t new_bitrate_kbit,
|
||||
bool* send_stream) const {
|
||||
if (streaminfos_.size() == 1) {
|
||||
uint32_t SimulcastEncoderAdapter::GetStreamBitrate(
|
||||
int stream_idx,
|
||||
size_t total_number_of_streams,
|
||||
uint32_t new_bitrate_kbit,
|
||||
bool* send_stream) const {
|
||||
if (total_number_of_streams == 1) {
|
||||
*send_stream = true;
|
||||
return new_bitrate_kbit;
|
||||
}
|
||||
@ -460,6 +462,7 @@ uint32_t SimulcastEncoderAdapter::GetStreamBitrate(int stream_idx,
|
||||
void SimulcastEncoderAdapter::PopulateStreamCodec(
|
||||
const webrtc::VideoCodec* inst,
|
||||
int stream_index,
|
||||
size_t total_number_of_streams,
|
||||
bool highest_resolution_stream,
|
||||
webrtc::VideoCodec* stream_codec,
|
||||
bool* send_stream) {
|
||||
@ -491,9 +494,8 @@ void SimulcastEncoderAdapter::PopulateStreamCodec(
|
||||
}
|
||||
// TODO(ronghuawu): what to do with targetBitrate.
|
||||
|
||||
int stream_bitrate = GetStreamBitrate(stream_index,
|
||||
inst->startBitrate,
|
||||
send_stream);
|
||||
int stream_bitrate = GetStreamBitrate(stream_index, total_number_of_streams,
|
||||
inst->startBitrate, send_stream);
|
||||
stream_codec->startBitrate = stream_bitrate;
|
||||
}
|
||||
|
||||
|
@ -87,15 +87,18 @@ class SimulcastEncoderAdapter : public VP8Encoder {
|
||||
};
|
||||
|
||||
// Get the stream bitrate, for the stream |stream_idx|, given the bitrate
|
||||
// |new_bitrate_kbit|. The function also returns whether there's enough
|
||||
// |new_bitrate_kbit| and the actual configured stream count in
|
||||
// |total_number_of_streams|. The function also returns whether there's enough
|
||||
// bandwidth to send this stream via |send_stream|.
|
||||
uint32_t GetStreamBitrate(int stream_idx,
|
||||
size_t total_number_of_streams,
|
||||
uint32_t new_bitrate_kbit,
|
||||
bool* send_stream) const;
|
||||
|
||||
// Populate the codec settings for each stream.
|
||||
void PopulateStreamCodec(const webrtc::VideoCodec* inst,
|
||||
int stream_index,
|
||||
size_t total_number_of_streams,
|
||||
bool highest_resolution_stream,
|
||||
webrtc::VideoCodec* stream_codec,
|
||||
bool* send_stream);
|
||||
|
@ -310,11 +310,16 @@ class TestSimulcastEncoderAdapterFake : public ::testing::Test,
|
||||
// stream 1
|
||||
InitRefCodec(1, &ref_codec);
|
||||
ref_codec.codecSpecific.VP8.denoisingOn = false;
|
||||
ref_codec.startBitrate = 300;
|
||||
// The start bitrate (300kbit) minus what we have for the lower layers
|
||||
// (100kbit).
|
||||
ref_codec.startBitrate = 200;
|
||||
VerifyCodec(ref_codec, 1);
|
||||
|
||||
// stream 2, the biggest resolution stream.
|
||||
InitRefCodec(2, &ref_codec);
|
||||
// We don't have enough bits to send this, so the adapter should have
|
||||
// configured it to use the min bitrate for this layer (600kbit) but turn
|
||||
// off sending.
|
||||
ref_codec.startBitrate = 600;
|
||||
VerifyCodec(ref_codec, 2);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user