xref: /aosp_15_r20/external/webrtc/modules/video_coding/receiver.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright (c) 2011 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_VIDEO_CODING_RECEIVER_H_
12 #define MODULES_VIDEO_CODING_RECEIVER_H_
13 
14 #include <memory>
15 #include <vector>
16 
17 #include "api/field_trials_view.h"
18 #include "modules/video_coding/event_wrapper.h"
19 #include "modules/video_coding/include/video_coding.h"
20 #include "modules/video_coding/include/video_coding_defines.h"
21 #include "modules/video_coding/jitter_buffer.h"
22 #include "modules/video_coding/packet.h"
23 #include "modules/video_coding/timing/timing.h"
24 
25 namespace webrtc {
26 
27 class Clock;
28 class VCMEncodedFrame;
29 
30 class VCMReceiver {
31  public:
32   VCMReceiver(VCMTiming* timing,
33               Clock* clock,
34               const FieldTrialsView& field_trials);
35 
36   // Using this constructor, you can specify a different event implemetation for
37   // the jitter buffer. Useful for unit tests when you want to simulate incoming
38   // packets, in which case the jitter buffer's wait event is different from
39   // that of VCMReceiver itself.
40   VCMReceiver(VCMTiming* timing,
41               Clock* clock,
42               std::unique_ptr<EventWrapper> receiver_event,
43               std::unique_ptr<EventWrapper> jitter_buffer_event,
44               const FieldTrialsView& field_trials);
45 
46   ~VCMReceiver();
47 
48   int32_t InsertPacket(const VCMPacket& packet);
49   VCMEncodedFrame* FrameForDecoding(uint16_t max_wait_time_ms,
50                                     bool prefer_late_decoding);
51   void ReleaseFrame(VCMEncodedFrame* frame);
52 
53   // NACK.
54   void SetNackSettings(size_t max_nack_list_size,
55                        int max_packet_age_to_nack,
56                        int max_incomplete_time_ms);
57   std::vector<uint16_t> NackList(bool* request_key_frame);
58 
59  private:
60   Clock* const clock_;
61   VCMJitterBuffer jitter_buffer_;
62   VCMTiming* timing_;
63   std::unique_ptr<EventWrapper> render_wait_event_;
64   int max_video_delay_ms_;
65 };
66 
67 }  // namespace webrtc
68 
69 #endif  // MODULES_VIDEO_CODING_RECEIVER_H_
70