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