blob: 503cae7c8deedd67e9c4ddb0c21a59660ade26d1 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_VIDEO_CODING_RECEIVER_H_
12#define MODULES_VIDEO_CODING_RECEIVER_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
kwiberg3f55dea2016-02-29 05:51:59 -080014#include <memory>
philipel9d3ab612015-12-21 04:12:39 -080015#include <vector>
16
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "modules/video_coding/include/video_coding.h"
18#include "modules/video_coding/include/video_coding_defines.h"
19#include "modules/video_coding/jitter_buffer.h"
20#include "modules/video_coding/packet.h"
21#include "modules/video_coding/timing.h"
22#include "rtc_base/criticalsection.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000023
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000024namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000025
stefan@webrtc.orga678a3b2013-01-21 07:42:11 +000026class Clock;
niklase@google.com470e71d2011-07-07 08:21:25 +000027class VCMEncodedFrame;
28
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000029class VCMReceiver {
30 public:
philipel83f831a2016-03-12 03:30:23 -080031 // Constructor for current interface, will be removed when the
32 // new jitter buffer is in place.
Niels Möller689983f2018-11-07 16:36:22 +010033 VCMReceiver(VCMTiming* timing, Clock* clock);
Qiang Chend4cec152015-06-19 09:17:00 -070034
philipel83f831a2016-03-12 03:30:23 -080035 // Create method for the new jitter buffer.
36 VCMReceiver(VCMTiming* timing,
37 Clock* clock,
philipel83f831a2016-03-12 03:30:23 -080038 NackSender* nack_sender,
39 KeyFrameRequestSender* keyframe_request_sender);
40
Niels Möller689983f2018-11-07 16:36:22 +010041 // Using this constructor, you can specify a different event implemetation for
42 // the jitter buffer. Useful for unit tests when you want to simulate incoming
Qiang Chend4cec152015-06-19 09:17:00 -070043 // packets, in which case the jitter buffer's wait event is different from
44 // that of VCMReceiver itself.
philipel83f831a2016-03-12 03:30:23 -080045 //
46 // Constructor for current interface, will be removed when the
47 // new jitter buffer is in place.
Qiang Chend4cec152015-06-19 09:17:00 -070048 VCMReceiver(VCMTiming* timing,
49 Clock* clock,
kwiberg3f55dea2016-02-29 05:51:59 -080050 std::unique_ptr<EventWrapper> receiver_event,
51 std::unique_ptr<EventWrapper> jitter_buffer_event);
Qiang Chend4cec152015-06-19 09:17:00 -070052
philipel83f831a2016-03-12 03:30:23 -080053 // Create method for the new jitter buffer.
54 VCMReceiver(VCMTiming* timing,
55 Clock* clock,
56 std::unique_ptr<EventWrapper> receiver_event,
57 std::unique_ptr<EventWrapper> jitter_buffer_event,
58 NackSender* nack_sender,
59 KeyFrameRequestSender* keyframe_request_sender);
60
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000061 ~VCMReceiver();
niklase@google.com470e71d2011-07-07 08:21:25 +000062
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000063 void Reset();
pkasting@chromium.org16825b12015-01-12 21:51:21 +000064 void UpdateRtt(int64_t rtt);
Johan Ahlers95348f72016-06-28 11:11:28 +020065 int32_t InsertPacket(const VCMPacket& packet);
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000066 VCMEncodedFrame* FrameForDecoding(uint16_t max_wait_time_ms,
perkj796cfaf2015-12-10 09:27:38 -080067 bool prefer_late_decoding);
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000068 void ReleaseFrame(VCMEncodedFrame* frame);
69 void ReceiveStatistics(uint32_t* bitrate, uint32_t* framerate);
niklase@google.com470e71d2011-07-07 08:21:25 +000070
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000071 // NACK.
stefan@webrtc.orga64300a2013-03-04 15:24:40 +000072 void SetNackMode(VCMNackMode nackMode,
pkasting@chromium.org16825b12015-01-12 21:51:21 +000073 int64_t low_rtt_nack_threshold_ms,
74 int64_t high_rtt_nack_threshold_ms);
stefan@webrtc.orgbecf9c82013-02-01 15:09:57 +000075 void SetNackSettings(size_t max_nack_list_size,
stefan@webrtc.orgef144882013-05-07 19:16:33 +000076 int max_packet_age_to_nack,
77 int max_incomplete_time_ms);
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000078 VCMNackMode NackMode() const;
Wan-Teh Changb1825a42015-06-03 15:03:35 -070079 std::vector<uint16_t> NackList(bool* request_key_frame);
niklase@google.com470e71d2011-07-07 08:21:25 +000080
mikhal@webrtc.orgdc3cd212013-04-25 20:27:04 +000081 // Decoding with errors.
agalusza@google.coma7e360e2013-08-01 03:15:08 +000082 void SetDecodeErrorMode(VCMDecodeErrorMode decode_error_mode);
83 VCMDecodeErrorMode DecodeErrorMode() const;
mikhal@webrtc.orgdc3cd212013-04-25 20:27:04 +000084
pbos@webrtc.org55707692014-12-19 15:45:03 +000085 void RegisterStatsCallback(VCMReceiveStatisticsCallback* callback);
pbos@webrtc.orgce4e9a32014-12-18 13:50:16 +000086
pbos@webrtc.org4dd40d62015-02-17 13:22:43 +000087 void TriggerDecoderShutdown();
88
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000089 private:
kthelgasond701dfd2017-03-27 07:24:57 -070090 rtc::CriticalSection crit_sect_;
pbos@webrtc.org4dd40d62015-02-17 13:22:43 +000091 Clock* const clock_;
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000092 VCMJitterBuffer jitter_buffer_;
93 VCMTiming* timing_;
kwiberg3f55dea2016-02-29 05:51:59 -080094 std::unique_ptr<EventWrapper> render_wait_event_;
mikhal@webrtc.orgef9f76a2013-02-15 23:22:18 +000095 int max_video_delay_ms_;
niklase@google.com470e71d2011-07-07 08:21:25 +000096};
97
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000098} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000099
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200100#endif // MODULES_VIDEO_CODING_RECEIVER_H_