| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 |
| 11 | #include "pc/data_channel_utils.h" |
| 12 |
| 13 | namespace webrtc { |
| 14 |
| 15 | bool PacketQueue::Empty() const { |
| 16 | return packets_.empty(); |
| 17 | } |
| 18 |
| 19 | std::unique_ptr<DataBuffer> PacketQueue::PopFront() { |
| 20 | RTC_DCHECK(!packets_.empty()); |
| 21 | byte_count_ -= packets_.front()->size(); |
| 22 | std::unique_ptr<DataBuffer> packet = std::move(packets_.front()); |
| 23 | packets_.pop_front(); |
| 24 | return packet; |
| 25 | } |
| 26 |
| 27 | void PacketQueue::PushFront(std::unique_ptr<DataBuffer> packet) { |
| 28 | byte_count_ += packet->size(); |
| 29 | packets_.push_front(std::move(packet)); |
| 30 | } |
| 31 |
| 32 | void PacketQueue::PushBack(std::unique_ptr<DataBuffer> packet) { |
| 33 | byte_count_ += packet->size(); |
| 34 | packets_.push_back(std::move(packet)); |
| 35 | } |
| 36 |
| 37 | void PacketQueue::Clear() { |
| 38 | packets_.clear(); |
| 39 | byte_count_ = 0; |
| 40 | } |
| 41 |
| 42 | void PacketQueue::Swap(PacketQueue* other) { |
| 43 | size_t other_byte_count = other->byte_count_; |
| 44 | other->byte_count_ = byte_count_; |
| 45 | byte_count_ = other_byte_count; |
| 46 |
| 47 | other->packets_.swap(packets_); |
| 48 | } |
| 49 |
| 50 | bool IsSctpLike(cricket::DataChannelType type) { |
| 51 | return type == cricket::DCT_SCTP; |
| 52 | } |
| 53 |
| 54 | } // namespace webrtc |
| 55 |