blob: 81a8b05b1b9f9306d7fd563bf17f6bc5c360736d [file] [log] [blame]
Sebastian Janssonb5374962018-02-07 13:26:38 +01001/*
2 * Copyright (c) 2018 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 MODULES_PACING_PACKET_QUEUE_INTERFACE_H_
12#define MODULES_PACING_PACKET_QUEUE_INTERFACE_H_
13
14#include <stdint.h>
15
16#include <list>
17#include <queue>
18#include <set>
19
20#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
21
22namespace webrtc {
23
24class PacketQueueInterface {
25 public:
26 PacketQueueInterface() = default;
27 virtual ~PacketQueueInterface() = default;
28
29 struct Packet {
30 Packet(RtpPacketSender::Priority priority,
31 uint32_t ssrc,
32 uint16_t seq_number,
33 int64_t capture_time_ms,
34 int64_t enqueue_time_ms,
35 size_t length_in_bytes,
36 bool retransmission,
37 uint64_t enqueue_order);
38 Packet(const Packet& other);
39 virtual ~Packet();
40 bool operator<(const Packet& other) const;
41
42 RtpPacketSender::Priority priority;
43 uint32_t ssrc;
44 uint16_t sequence_number;
45 int64_t capture_time_ms; // Absolute time of frame capture.
46 int64_t enqueue_time_ms; // Absolute time of pacer queue entry.
47 int64_t sum_paused_ms;
48 size_t bytes;
49 bool retransmission;
50 uint64_t enqueue_order;
51 std::list<Packet>::iterator this_it;
52 std::multiset<int64_t>::iterator enqueue_time_it;
53 };
54
55 virtual void Push(const Packet& packet) = 0;
56 virtual const Packet& BeginPop() = 0;
57 virtual void CancelPop(const Packet& packet) = 0;
58 virtual void FinalizePop(const Packet& packet) = 0;
59 virtual bool Empty() const = 0;
60 virtual size_t SizeInPackets() const = 0;
61 virtual uint64_t SizeInBytes() const = 0;
62 virtual int64_t OldestEnqueueTimeMs() const = 0;
63 virtual void UpdateQueueTime(int64_t timestamp_ms) = 0;
64 virtual void SetPauseState(bool paused, int64_t timestamp_ms) = 0;
65 virtual int64_t AverageQueueTimeMs() const = 0;
66};
67} // namespace webrtc
68
69#endif // MODULES_PACING_PACKET_QUEUE_INTERFACE_H_