Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 break; | 212 break; |
| 213 | 213 |
| 214 start_index = start_index > 0 ? start_index - 1 : size_ - 1; | 214 start_index = start_index > 0 ? start_index - 1 : size_ - 1; |
| 215 start_seq_num--; | 215 start_seq_num--; |
| 216 } | 216 } |
| 217 | 217 |
| 218 std::unique_ptr<RtpFrameObject> frame( | 218 std::unique_ptr<RtpFrameObject> frame( |
| 219 new RtpFrameObject(this, start_seq_num, seq_num, frame_size, | 219 new RtpFrameObject(this, start_seq_num, seq_num, frame_size, |
| 220 max_nack_count, clock_->TimeInMilliseconds())); | 220 max_nack_count, clock_->TimeInMilliseconds())); |
| 221 | 221 |
| 222 crit_.Leave(); | |
| 222 received_frame_callback_->OnReceivedFrame(std::move(frame)); | 223 received_frame_callback_->OnReceivedFrame(std::move(frame)); |
| 224 crit_.Enter(); | |
|
stefan-webrtc
2016/11/08 10:41:34
I think we should rewrite the code so that we can
philipel
2016/11/08 12:28:39
Done.
| |
| 223 } | 225 } |
| 224 | 226 |
| 225 ++seq_num; | 227 ++seq_num; |
| 226 } | 228 } |
| 227 } | 229 } |
| 228 | 230 |
| 229 void PacketBuffer::ReturnFrame(RtpFrameObject* frame) { | 231 void PacketBuffer::ReturnFrame(RtpFrameObject* frame) { |
| 230 rtc::CritScope lock(&crit_); | 232 rtc::CritScope lock(&crit_); |
| 231 size_t index = frame->first_seq_num() % size_; | 233 size_t index = frame->first_seq_num() % size_; |
| 232 size_t end = (frame->last_seq_num() + 1) % size_; | 234 size_t end = (frame->last_seq_num() + 1) % size_; |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 260 size_t length = data_buffer_[index].sizeBytes; | 262 size_t length = data_buffer_[index].sizeBytes; |
| 261 memcpy(destination, source, length); | 263 memcpy(destination, source, length); |
| 262 destination += length; | 264 destination += length; |
| 263 index = (index + 1) % size_; | 265 index = (index + 1) % size_; |
| 264 ++seq_num; | 266 ++seq_num; |
| 265 } | 267 } |
| 266 return true; | 268 return true; |
| 267 } | 269 } |
| 268 | 270 |
| 269 VCMPacket* PacketBuffer::GetPacket(uint16_t seq_num) { | 271 VCMPacket* PacketBuffer::GetPacket(uint16_t seq_num) { |
| 270 rtc::CritScope lock(&crit_); | |
| 271 size_t index = seq_num % size_; | 272 size_t index = seq_num % size_; |
| 272 if (!sequence_buffer_[index].used || | 273 if (!sequence_buffer_[index].used || |
| 273 seq_num != sequence_buffer_[index].seq_num) { | 274 seq_num != sequence_buffer_[index].seq_num) { |
| 274 return nullptr; | 275 return nullptr; |
| 275 } | 276 } |
| 276 return &data_buffer_[index]; | 277 return &data_buffer_[index]; |
| 277 } | 278 } |
| 278 | 279 |
| 279 int PacketBuffer::AddRef() const { | 280 int PacketBuffer::AddRef() const { |
| 280 return rtc::AtomicOps::Increment(&ref_count_); | 281 return rtc::AtomicOps::Increment(&ref_count_); |
| 281 } | 282 } |
| 282 | 283 |
| 283 int PacketBuffer::Release() const { | 284 int PacketBuffer::Release() const { |
| 284 int count = rtc::AtomicOps::Decrement(&ref_count_); | 285 int count = rtc::AtomicOps::Decrement(&ref_count_); |
| 285 if (!count) { | 286 if (!count) { |
| 286 delete this; | 287 delete this; |
| 287 } | 288 } |
| 288 return count; | 289 return count; |
| 289 } | 290 } |
| 290 | 291 |
| 291 } // namespace video_coding | 292 } // namespace video_coding |
| 292 } // namespace webrtc | 293 } // namespace webrtc |
| OLD | NEW |