Thanks to visit codestin.com
Credit goes to webrtc.googlesource.com

blob: 2558fcd6d4734406c6473f40d10c3b3ae9546fd8 [file] [log] [blame]
Taylor Brandstetter3a034e12020-07-09 22:32:341/*
2 * Copyright 2020 The WebRTC project authors. All Rights Reserved.
3 *
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
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
Harald Alvestrand5761e7b2021-01-29 14:45:0814#include <stddef.h>
15#include <stdint.h>
Jared Siskinbceec842023-04-20 21:10:5116
Taylor Brandstetter3a034e12020-07-09 22:32:3417#include <deque>
18#include <memory>
19#include <string>
Taylor Brandstetter3a034e12020-07-09 22:32:3420
21#include "api/data_channel_interface.h"
Taylor Brandstetter3a034e12020-07-09 22:32:3422
23namespace webrtc {
24
25// A packet queue which tracks the total queued bytes. Queued packets are
26// owned by this class.
27class PacketQueue final {
28 public:
29 size_t byte_count() const { return byte_count_; }
30
31 bool Empty() const;
32
33 std::unique_ptr<DataBuffer> PopFront();
34
35 void PushFront(std::unique_ptr<DataBuffer> packet);
36 void PushBack(std::unique_ptr<DataBuffer> packet);
37
38 void Clear();
39
40 void Swap(PacketQueue* other);
41
42 private:
43 std::deque<std::unique_ptr<DataBuffer>> packets_;
44 size_t byte_count_ = 0;
45};
46
47struct DataChannelStats {
48 int internal_id;
49 int id;
50 std::string label;
51 std::string protocol;
52 DataChannelInterface::DataState state;
53 uint32_t messages_sent;
54 uint32_t messages_received;
55 uint64_t bytes_sent;
56 uint64_t bytes_received;
57};
58
Taylor Brandstetter3a034e12020-07-09 22:32:3459} // namespace webrtc
60
61#endif // PC_DATA_CHANNEL_UTILS_H_