| Index: webrtc/modules/video_coding/packet_buffer.cc
|
| diff --git a/webrtc/modules/video_coding/packet_buffer.cc b/webrtc/modules/video_coding/packet_buffer.cc
|
| index 58ad31e50cefda7c959cdeffb08d22b61e795c94..341fb293268d379776bdab03ca68b47ca1020186 100644
|
| --- a/webrtc/modules/video_coding/packet_buffer.cc
|
| +++ b/webrtc/modules/video_coding/packet_buffer.cc
|
| @@ -188,42 +188,45 @@ bool PacketBuffer::PotentialNewFrame(uint16_t seq_num) const {
|
| }
|
|
|
| void PacketBuffer::FindFrames(uint16_t seq_num) {
|
| - while (PotentialNewFrame(seq_num)) {
|
| - size_t index = seq_num % size_;
|
| - sequence_buffer_[index].continuous = true;
|
| -
|
| - // If all packets of the frame is continuous, find the first packet of the
|
| - // frame and create an RtpFrameObject.
|
| - if (sequence_buffer_[index].frame_end) {
|
| - size_t frame_size = 0;
|
| - int max_nack_count = -1;
|
| - uint16_t start_seq_num = seq_num;
|
| -
|
| - // Find the start index by searching backward until the packet with
|
| - // the |frame_begin| flag is set.
|
| - int start_index = index;
|
| - while (true) {
|
| - frame_size += data_buffer_[start_index].sizeBytes;
|
| - max_nack_count = std::max(
|
| - max_nack_count, data_buffer_[start_index].timesNacked);
|
| - sequence_buffer_[start_index].frame_created = true;
|
| -
|
| - if (sequence_buffer_[start_index].frame_begin)
|
| - break;
|
| -
|
| - start_index = start_index > 0 ? start_index - 1 : size_ - 1;
|
| - start_seq_num--;
|
| + std::vector<std::unique_ptr<RtpFrameObject>> found_frames;
|
| + {
|
| + rtc::CritScope lock(&crit_);
|
| + while (PotentialNewFrame(seq_num)) {
|
| + size_t index = seq_num % size_;
|
| + sequence_buffer_[index].continuous = true;
|
| +
|
| + // If all packets of the frame is continuous, find the first packet of the
|
| + // frame and create an RtpFrameObject.
|
| + if (sequence_buffer_[index].frame_end) {
|
| + size_t frame_size = 0;
|
| + int max_nack_count = -1;
|
| + uint16_t start_seq_num = seq_num;
|
| +
|
| + // Find the start index by searching backward until the packet with
|
| + // the |frame_begin| flag is set.
|
| + int start_index = index;
|
| + while (true) {
|
| + frame_size += data_buffer_[start_index].sizeBytes;
|
| + max_nack_count =
|
| + std::max(max_nack_count, data_buffer_[start_index].timesNacked);
|
| + sequence_buffer_[start_index].frame_created = true;
|
| +
|
| + if (sequence_buffer_[start_index].frame_begin)
|
| + break;
|
| +
|
| + start_index = start_index > 0 ? start_index - 1 : size_ - 1;
|
| + start_seq_num--;
|
| + }
|
| +
|
| + found_frames.emplace_back(
|
| + new RtpFrameObject(this, start_seq_num, seq_num, frame_size,
|
| + max_nack_count, clock_->TimeInMilliseconds()));
|
| }
|
| -
|
| - std::unique_ptr<RtpFrameObject> frame(
|
| - new RtpFrameObject(this, start_seq_num, seq_num, frame_size,
|
| - max_nack_count, clock_->TimeInMilliseconds()));
|
| -
|
| - received_frame_callback_->OnReceivedFrame(std::move(frame));
|
| + ++seq_num;
|
| }
|
| -
|
| - ++seq_num;
|
| }
|
| + for (auto& frame : found_frames)
|
| + received_frame_callback_->OnReceivedFrame(std::move(frame));
|
| }
|
|
|
| void PacketBuffer::ReturnFrame(RtpFrameObject* frame) {
|
| @@ -267,7 +270,6 @@ bool PacketBuffer::GetBitstream(const RtpFrameObject& frame,
|
| }
|
|
|
| VCMPacket* PacketBuffer::GetPacket(uint16_t seq_num) {
|
| - rtc::CritScope lock(&crit_);
|
| size_t index = seq_num % size_;
|
| if (!sequence_buffer_[index].used ||
|
| seq_num != sequence_buffer_[index].seq_num) {
|
|
|