| 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 | #ifndef PC_DATA_CHANNEL_UTILS_H_ |
| 12 | #define PC_DATA_CHANNEL_UTILS_H_ |
| 13 |
| 14 | #include <stddef.h> |
| 15 | #include <stdint.h> |
| 16 |
| 17 | #include <deque> |
| 18 | #include <memory> |
| 19 | #include <string> |
| 20 | #include <utility> |
| 21 |
| 22 | #include "api/data_channel_interface.h" |
| 23 | #include "media/base/media_engine.h" |
| 24 |
| 25 | namespace webrtc { |
| 26 |
| 27 | // A packet queue which tracks the total queued bytes. Queued packets are |
| 28 | // owned by this class. |
| 29 | class PacketQueue final { |
| 30 | public: |
| 31 | size_t byte_count() const { return byte_count_; } |
| 32 |
| 33 | bool Empty() const; |
| 34 |
| 35 | std::unique_ptr<DataBuffer> PopFront(); |
| 36 |
| 37 | void PushFront(std::unique_ptr<DataBuffer> packet); |
| 38 | void PushBack(std::unique_ptr<DataBuffer> packet); |
| 39 |
| 40 | void Clear(); |
| 41 |
| 42 | void Swap(PacketQueue* other); |
| 43 |
| 44 | private: |
| 45 | std::deque<std::unique_ptr<DataBuffer>> packets_; |
| 46 | size_t byte_count_ = 0; |
| 47 | }; |
| 48 |
| 49 | struct DataChannelStats { |
| 50 | int internal_id; |
| 51 | int id; |
| 52 | std::string label; |
| 53 | std::string protocol; |
| 54 | DataChannelInterface::DataState state; |
| 55 | uint32_t messages_sent; |
| 56 | uint32_t messages_received; |
| 57 | uint64_t bytes_sent; |
| 58 | uint64_t bytes_received; |
| 59 | }; |
| 60 |
| 61 | } // namespace webrtc |
| 62 |
| 63 | #endif // PC_DATA_CHANNEL_UTILS_H_ |
| 64 |