forked from webrtc-sdk/webrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_channel_utils.cc
54 lines (43 loc) · 1.41 KB
/
data_channel_utils.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* Copyright 2020 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "pc/data_channel_utils.h"
namespace webrtc {
bool PacketQueue::Empty() const {
return packets_.empty();
}
std::unique_ptr<DataBuffer> PacketQueue::PopFront() {
RTC_DCHECK(!packets_.empty());
byte_count_ -= packets_.front()->size();
std::unique_ptr<DataBuffer> packet = std::move(packets_.front());
packets_.pop_front();
return packet;
}
void PacketQueue::PushFront(std::unique_ptr<DataBuffer> packet) {
byte_count_ += packet->size();
packets_.push_front(std::move(packet));
}
void PacketQueue::PushBack(std::unique_ptr<DataBuffer> packet) {
byte_count_ += packet->size();
packets_.push_back(std::move(packet));
}
void PacketQueue::Clear() {
packets_.clear();
byte_count_ = 0;
}
void PacketQueue::Swap(PacketQueue* other) {
size_t other_byte_count = other->byte_count_;
other->byte_count_ = byte_count_;
byte_count_ = other_byte_count;
other->packets_.swap(packets_);
}
bool IsSctpLike(cricket::DataChannelType type) {
return type == cricket::DCT_SCTP;
}
} // namespace webrtc