blob: 049fb84af7c8463b946f4bb9d56f2b2efaff62ce [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
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000011#ifndef WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_RECEIVER_H_
12#define WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_RECEIVER_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000014#include "webrtc/modules/video_coding/main/source/jitter_buffer.h"
15#include "webrtc/modules/video_coding/main/source/packet.h"
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000016#include "webrtc/modules/video_coding/main/source/timing.h"
pbos@webrtc.orga4407322013-07-16 12:32:05 +000017#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
agalusza@google.coma7e360e2013-08-01 03:15:08 +000018#include "webrtc/modules/video_coding/main/interface/video_coding.h"
19#include "webrtc/modules/video_coding/main/interface/video_coding_defines.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000020
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000021namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000022
stefan@webrtc.orga678a3b2013-01-21 07:42:11 +000023class Clock;
niklase@google.com470e71d2011-07-07 08:21:25 +000024class VCMEncodedFrame;
25
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000026enum VCMNackStatus {
27 kNackOk,
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000028 kNackKeyFrameRequest
niklase@google.com470e71d2011-07-07 08:21:25 +000029};
30
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000031class VCMReceiver {
32 public:
33 VCMReceiver(VCMTiming* timing,
stefan@webrtc.orga678a3b2013-01-21 07:42:11 +000034 Clock* clock,
Wan-Teh Chang92d94892015-05-28 13:36:06 -070035 EventFactory* event_factory);
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000036 ~VCMReceiver();
niklase@google.com470e71d2011-07-07 08:21:25 +000037
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000038 void Reset();
pkasting@chromium.org16825b12015-01-12 21:51:21 +000039 void UpdateRtt(int64_t rtt);
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000040 int32_t InsertPacket(const VCMPacket& packet,
41 uint16_t frame_width,
42 uint16_t frame_height);
43 VCMEncodedFrame* FrameForDecoding(uint16_t max_wait_time_ms,
44 int64_t& next_render_time_ms,
pbos@webrtc.org4f16c872014-11-24 09:06:48 +000045 bool render_timing = true);
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000046 void ReleaseFrame(VCMEncodedFrame* frame);
47 void ReceiveStatistics(uint32_t* bitrate, uint32_t* framerate);
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000048 uint32_t DiscardedPackets() const;
niklase@google.com470e71d2011-07-07 08:21:25 +000049
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000050 // NACK.
stefan@webrtc.orga64300a2013-03-04 15:24:40 +000051 void SetNackMode(VCMNackMode nackMode,
pkasting@chromium.org16825b12015-01-12 21:51:21 +000052 int64_t low_rtt_nack_threshold_ms,
53 int64_t high_rtt_nack_threshold_ms);
stefan@webrtc.orgbecf9c82013-02-01 15:09:57 +000054 void SetNackSettings(size_t max_nack_list_size,
stefan@webrtc.orgef144882013-05-07 19:16:33 +000055 int max_packet_age_to_nack,
56 int max_incomplete_time_ms);
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000057 VCMNackMode NackMode() const;
stefan@webrtc.orga64300a2013-03-04 15:24:40 +000058 VCMNackStatus NackList(uint16_t* nackList, uint16_t size,
59 uint16_t* nack_list_length);
niklase@google.com470e71d2011-07-07 08:21:25 +000060
mikhal@webrtc.orgef9f76a2013-02-15 23:22:18 +000061 // Receiver video delay.
62 int SetMinReceiverDelay(int desired_delay_ms);
63
mikhal@webrtc.orgdc3cd212013-04-25 20:27:04 +000064 // Decoding with errors.
agalusza@google.coma7e360e2013-08-01 03:15:08 +000065 void SetDecodeErrorMode(VCMDecodeErrorMode decode_error_mode);
66 VCMDecodeErrorMode DecodeErrorMode() const;
mikhal@webrtc.orgdc3cd212013-04-25 20:27:04 +000067
mikhal@webrtc.org381da4b2013-04-25 21:45:29 +000068 // Returns size in time (milliseconds) of complete continuous frames in the
mikhal@webrtc.org759b0412013-05-07 16:36:00 +000069 // jitter buffer. The render time is estimated based on the render delay at
70 // the time this function is called.
mikhal@webrtc.org381da4b2013-04-25 21:45:29 +000071 int RenderBufferSizeMs();
72
pbos@webrtc.org55707692014-12-19 15:45:03 +000073 void RegisterStatsCallback(VCMReceiveStatisticsCallback* callback);
pbos@webrtc.orgce4e9a32014-12-18 13:50:16 +000074
pbos@webrtc.org4dd40d62015-02-17 13:22:43 +000075 void TriggerDecoderShutdown();
76
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000077 private:
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000078 CriticalSectionWrapper* crit_sect_;
pbos@webrtc.org4dd40d62015-02-17 13:22:43 +000079 Clock* const clock_;
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000080 VCMJitterBuffer jitter_buffer_;
81 VCMTiming* timing_;
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +000082 rtc::scoped_ptr<EventWrapper> render_wait_event_;
mikhal@webrtc.orgef9f76a2013-02-15 23:22:18 +000083 int max_video_delay_ms_;
niklase@google.com470e71d2011-07-07 08:21:25 +000084};
85
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000086} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000087
stefan@webrtc.org1ea4b502013-01-07 08:49:41 +000088#endif // WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_RECEIVER_H_