• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2012 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_INCLUDE_MODULE_COMMON_TYPES_H_
12 #define MODULES_INCLUDE_MODULE_COMMON_TYPES_H_
13 
14 #include <stddef.h>
15 #include <stdint.h>
16 
17 #include <vector>
18 
19 #include "rtc_base/system/rtc_export.h"
20 
21 namespace webrtc {
22 
23 class RTC_EXPORT RTPFragmentationHeader {
24  public:
25   RTPFragmentationHeader();
26   RTPFragmentationHeader(const RTPFragmentationHeader&) = delete;
27   RTPFragmentationHeader(RTPFragmentationHeader&& other);
28   RTPFragmentationHeader& operator=(const RTPFragmentationHeader& other) =
29       delete;
30   RTPFragmentationHeader& operator=(RTPFragmentationHeader&& other);
31   ~RTPFragmentationHeader();
32 
33   friend void swap(RTPFragmentationHeader& a, RTPFragmentationHeader& b);
34 
35   void CopyFrom(const RTPFragmentationHeader& src);
VerifyAndAllocateFragmentationHeader(size_t size)36   void VerifyAndAllocateFragmentationHeader(size_t size) { Resize(size); }
37 
38   void Resize(size_t size);
Size()39   size_t Size() const { return fragmentationVectorSize; }
40 
Offset(size_t index)41   size_t Offset(size_t index) const { return fragmentationOffset[index]; }
Length(size_t index)42   size_t Length(size_t index) const { return fragmentationLength[index]; }
43 
44   // TODO(danilchap): Move all members to private section,
45   // simplify by replacing raw arrays with single std::vector<Fragment>
46   uint16_t fragmentationVectorSize;  // Number of fragmentations
47   size_t* fragmentationOffset;       // Offset of pointer to data for each
48                                      // fragmentation
49   size_t* fragmentationLength;       // Data size for each fragmentation
50 };
51 
52 // Interface used by the CallStats class to distribute call statistics.
53 // Callbacks will be triggered as soon as the class has been registered to a
54 // CallStats object using RegisterStatsObserver.
55 class CallStatsObserver {
56  public:
57   virtual void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) = 0;
58 
~CallStatsObserver()59   virtual ~CallStatsObserver() {}
60 };
61 
62 // Interface used by NackModule and JitterBuffer.
63 class NackSender {
64  public:
65   // If |buffering_allowed|, other feedback messages (e.g. key frame requests)
66   // may be added to the same outgoing feedback message. In that case, it's up
67   // to the user of the interface to ensure that when all buffer-able messages
68   // have been added, the feedback message is triggered.
69   virtual void SendNack(const std::vector<uint16_t>& sequence_numbers,
70                         bool buffering_allowed) = 0;
71 
72  protected:
~NackSender()73   virtual ~NackSender() {}
74 };
75 
76 // Interface used by NackModule and JitterBuffer.
77 class KeyFrameRequestSender {
78  public:
79   virtual void RequestKeyFrame() = 0;
80 
81  protected:
~KeyFrameRequestSender()82   virtual ~KeyFrameRequestSender() {}
83 };
84 
85 // Interface used by LossNotificationController to communicate to RtpRtcp.
86 class LossNotificationSender {
87  public:
~LossNotificationSender()88   virtual ~LossNotificationSender() {}
89 
90   virtual void SendLossNotification(uint16_t last_decoded_seq_num,
91                                     uint16_t last_received_seq_num,
92                                     bool decodability_flag,
93                                     bool buffering_allowed) = 0;
94 };
95 
96 }  // namespace webrtc
97 
98 #endif  // MODULES_INCLUDE_MODULE_COMMON_TYPES_H_
99