Miscellaneous cleanups in VCMReceiver and its unit tests.
The most important change is to prevent a potential buffer overflow in NackList(). It cannot happen if the |size| argument passed to NackList() is consistent with the |max_nack_list_size| argument passed to SetNackSettings(), and there is an assertion to check that. But it is good to defend against this in the release build because assert() is compiled away in the release build. Remove the unused |master| parameter to the VCMReceiver constructor. Remove the unused State() getter method and the corresponding state_ member. Remove the declarations for the nonexistent GenerateReceiverId() method and the receiver_id_counter_ member. Remove the unneeded data_buffer_ member of TestVCMReceiver. It was assigned to packet.dataPtr and then immediately overwritten by stream_generator_->GetPacket() or stream_generator_->PopPacket(). R=stefan@webrtc.org BUG=none TEST=none Review URL: https://webrtc-codereview.appspot.com/51119004 Cr-Commit-Position: refs/heads/master@{#9318}
This commit is contained in:
@ -27,14 +27,12 @@ enum { kMaxReceiverDelayMs = 10000 };
|
||||
|
||||
VCMReceiver::VCMReceiver(VCMTiming* timing,
|
||||
Clock* clock,
|
||||
EventFactory* event_factory,
|
||||
bool master)
|
||||
EventFactory* event_factory)
|
||||
: crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
clock_(clock),
|
||||
jitter_buffer_(clock_, event_factory),
|
||||
timing_(timing),
|
||||
render_wait_event_(event_factory->CreateEvent()),
|
||||
state_(kPassive),
|
||||
max_video_delay_ms_(kMaxVideoDelayMs) {
|
||||
Reset();
|
||||
}
|
||||
@ -51,7 +49,6 @@ void VCMReceiver::Reset() {
|
||||
} else {
|
||||
jitter_buffer_.Flush();
|
||||
}
|
||||
state_ = kReceiving;
|
||||
}
|
||||
|
||||
void VCMReceiver::UpdateRtt(int64_t rtt) {
|
||||
@ -219,6 +216,9 @@ VCMNackStatus VCMReceiver::NackList(uint16_t* nack_list,
|
||||
uint16_t* internal_nack_list = jitter_buffer_.GetNackList(
|
||||
nack_list_length, &request_key_frame);
|
||||
assert(*nack_list_length <= size);
|
||||
if (*nack_list_length > size) {
|
||||
*nack_list_length = size;
|
||||
}
|
||||
if (internal_nack_list != NULL && *nack_list_length > 0) {
|
||||
memcpy(nack_list, internal_nack_list, *nack_list_length * sizeof(uint16_t));
|
||||
}
|
||||
@ -228,11 +228,6 @@ VCMNackStatus VCMReceiver::NackList(uint16_t* nack_list,
|
||||
return kNackOk;
|
||||
}
|
||||
|
||||
VCMReceiverState VCMReceiver::State() const {
|
||||
CriticalSectionScoped cs(crit_sect_);
|
||||
return state_;
|
||||
}
|
||||
|
||||
void VCMReceiver::SetDecodeErrorMode(VCMDecodeErrorMode decode_error_mode) {
|
||||
jitter_buffer_.SetDecodeErrorMode(decode_error_mode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user