niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
stefan@webrtc.org | 1ea4b50 | 2013-01-07 08:49:41 +0000 | [diff] [blame] | 11 | #ifndef WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_RECEIVER_H_ |
| 12 | #define WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_RECEIVER_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
stefan@webrtc.org | 1ea4b50 | 2013-01-07 08:49:41 +0000 | [diff] [blame] | 14 | #include "webrtc/modules/video_coding/main/source/jitter_buffer.h" |
| 15 | #include "webrtc/modules/video_coding/main/source/packet.h" |
stefan@webrtc.org | 1ea4b50 | 2013-01-07 08:49:41 +0000 | [diff] [blame] | 16 | #include "webrtc/modules/video_coding/main/source/timing.h" |
pbos@webrtc.org | a440732 | 2013-07-16 12:32:05 +0000 | [diff] [blame] | 17 | #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
agalusza@google.com | a7e360e | 2013-08-01 03:15:08 +0000 | [diff] [blame] | 18 | #include "webrtc/modules/video_coding/main/interface/video_coding.h" |
| 19 | #include "webrtc/modules/video_coding/main/interface/video_coding_defines.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 20 | |
stefan@webrtc.org | 1ea4b50 | 2013-01-07 08:49:41 +0000 | [diff] [blame] | 21 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 22 | |
stefan@webrtc.org | a678a3b | 2013-01-21 07:42:11 +0000 | [diff] [blame] | 23 | class Clock; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 24 | class VCMEncodedFrame; |
| 25 | |
stefan@webrtc.org | 1ea4b50 | 2013-01-07 08:49:41 +0000 | [diff] [blame] | 26 | enum VCMNackStatus { |
| 27 | kNackOk, |
stefan@webrtc.org | 1ea4b50 | 2013-01-07 08:49:41 +0000 | [diff] [blame] | 28 | kNackKeyFrameRequest |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 29 | }; |
| 30 | |
stefan@webrtc.org | 1ea4b50 | 2013-01-07 08:49:41 +0000 | [diff] [blame] | 31 | enum VCMReceiverState { |
| 32 | kReceiving, |
| 33 | kPassive, |
| 34 | kWaitForPrimaryDecode |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 35 | }; |
| 36 | |
stefan@webrtc.org | 1ea4b50 | 2013-01-07 08:49:41 +0000 | [diff] [blame] | 37 | class VCMReceiver { |
| 38 | public: |
| 39 | VCMReceiver(VCMTiming* timing, |
stefan@webrtc.org | a678a3b | 2013-01-21 07:42:11 +0000 | [diff] [blame] | 40 | Clock* clock, |
stefan@webrtc.org | 2baf5f5 | 2013-03-13 08:46:25 +0000 | [diff] [blame] | 41 | EventFactory* event_factory, |
stefan@webrtc.org | 2baf5f5 | 2013-03-13 08:46:25 +0000 | [diff] [blame] | 42 | bool master); |
stefan@webrtc.org | 1ea4b50 | 2013-01-07 08:49:41 +0000 | [diff] [blame] | 43 | ~VCMReceiver(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 44 | |
stefan@webrtc.org | 1ea4b50 | 2013-01-07 08:49:41 +0000 | [diff] [blame] | 45 | void Reset(); |
| 46 | int32_t Initialize(); |
pkasting@chromium.org | 16825b1 | 2015-01-12 21:51:21 +0000 | [diff] [blame] | 47 | void UpdateRtt(int64_t rtt); |
stefan@webrtc.org | 1ea4b50 | 2013-01-07 08:49:41 +0000 | [diff] [blame] | 48 | int32_t InsertPacket(const VCMPacket& packet, |
| 49 | uint16_t frame_width, |
| 50 | uint16_t frame_height); |
| 51 | VCMEncodedFrame* FrameForDecoding(uint16_t max_wait_time_ms, |
| 52 | int64_t& next_render_time_ms, |
pbos@webrtc.org | 4f16c87 | 2014-11-24 09:06:48 +0000 | [diff] [blame] | 53 | bool render_timing = true); |
stefan@webrtc.org | 1ea4b50 | 2013-01-07 08:49:41 +0000 | [diff] [blame] | 54 | void ReleaseFrame(VCMEncodedFrame* frame); |
| 55 | void ReceiveStatistics(uint32_t* bitrate, uint32_t* framerate); |
stefan@webrtc.org | 1ea4b50 | 2013-01-07 08:49:41 +0000 | [diff] [blame] | 56 | uint32_t DiscardedPackets() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 57 | |
stefan@webrtc.org | 1ea4b50 | 2013-01-07 08:49:41 +0000 | [diff] [blame] | 58 | // NACK. |
stefan@webrtc.org | a64300a | 2013-03-04 15:24:40 +0000 | [diff] [blame] | 59 | void SetNackMode(VCMNackMode nackMode, |
pkasting@chromium.org | 16825b1 | 2015-01-12 21:51:21 +0000 | [diff] [blame] | 60 | int64_t low_rtt_nack_threshold_ms, |
| 61 | int64_t high_rtt_nack_threshold_ms); |
stefan@webrtc.org | becf9c8 | 2013-02-01 15:09:57 +0000 | [diff] [blame] | 62 | void SetNackSettings(size_t max_nack_list_size, |
stefan@webrtc.org | ef14488 | 2013-05-07 19:16:33 +0000 | [diff] [blame] | 63 | int max_packet_age_to_nack, |
| 64 | int max_incomplete_time_ms); |
stefan@webrtc.org | 1ea4b50 | 2013-01-07 08:49:41 +0000 | [diff] [blame] | 65 | VCMNackMode NackMode() const; |
stefan@webrtc.org | a64300a | 2013-03-04 15:24:40 +0000 | [diff] [blame] | 66 | VCMNackStatus NackList(uint16_t* nackList, uint16_t size, |
| 67 | uint16_t* nack_list_length); |
stefan@webrtc.org | 1ea4b50 | 2013-01-07 08:49:41 +0000 | [diff] [blame] | 68 | VCMReceiverState State() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 69 | |
mikhal@webrtc.org | ef9f76a | 2013-02-15 23:22:18 +0000 | [diff] [blame] | 70 | // Receiver video delay. |
| 71 | int SetMinReceiverDelay(int desired_delay_ms); |
| 72 | |
mikhal@webrtc.org | dc3cd21 | 2013-04-25 20:27:04 +0000 | [diff] [blame] | 73 | // Decoding with errors. |
agalusza@google.com | a7e360e | 2013-08-01 03:15:08 +0000 | [diff] [blame] | 74 | void SetDecodeErrorMode(VCMDecodeErrorMode decode_error_mode); |
| 75 | VCMDecodeErrorMode DecodeErrorMode() const; |
mikhal@webrtc.org | dc3cd21 | 2013-04-25 20:27:04 +0000 | [diff] [blame] | 76 | |
mikhal@webrtc.org | 381da4b | 2013-04-25 21:45:29 +0000 | [diff] [blame] | 77 | // Returns size in time (milliseconds) of complete continuous frames in the |
mikhal@webrtc.org | 759b041 | 2013-05-07 16:36:00 +0000 | [diff] [blame] | 78 | // jitter buffer. The render time is estimated based on the render delay at |
| 79 | // the time this function is called. |
mikhal@webrtc.org | 381da4b | 2013-04-25 21:45:29 +0000 | [diff] [blame] | 80 | int RenderBufferSizeMs(); |
| 81 | |
pbos@webrtc.org | 5570769 | 2014-12-19 15:45:03 +0000 | [diff] [blame] | 82 | void RegisterStatsCallback(VCMReceiveStatisticsCallback* callback); |
pbos@webrtc.org | ce4e9a3 | 2014-12-18 13:50:16 +0000 | [diff] [blame] | 83 | |
pbos@webrtc.org | 4dd40d6 | 2015-02-17 13:22:43 +0000 | [diff] [blame^] | 84 | void TriggerDecoderShutdown(); |
| 85 | |
stefan@webrtc.org | 1ea4b50 | 2013-01-07 08:49:41 +0000 | [diff] [blame] | 86 | private: |
stefan@webrtc.org | 1ea4b50 | 2013-01-07 08:49:41 +0000 | [diff] [blame] | 87 | static int32_t GenerateReceiverId(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 88 | |
stefan@webrtc.org | 1ea4b50 | 2013-01-07 08:49:41 +0000 | [diff] [blame] | 89 | CriticalSectionWrapper* crit_sect_; |
pbos@webrtc.org | 4dd40d6 | 2015-02-17 13:22:43 +0000 | [diff] [blame^] | 90 | Clock* const clock_; |
stefan@webrtc.org | 1ea4b50 | 2013-01-07 08:49:41 +0000 | [diff] [blame] | 91 | VCMJitterBuffer jitter_buffer_; |
| 92 | VCMTiming* timing_; |
stefan@webrtc.org | 2baf5f5 | 2013-03-13 08:46:25 +0000 | [diff] [blame] | 93 | scoped_ptr<EventWrapper> render_wait_event_; |
stefan@webrtc.org | 1ea4b50 | 2013-01-07 08:49:41 +0000 | [diff] [blame] | 94 | VCMReceiverState state_; |
mikhal@webrtc.org | ef9f76a | 2013-02-15 23:22:18 +0000 | [diff] [blame] | 95 | int max_video_delay_ms_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 96 | |
stefan@webrtc.org | 1ea4b50 | 2013-01-07 08:49:41 +0000 | [diff] [blame] | 97 | static int32_t receiver_id_counter_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 98 | }; |
| 99 | |
stefan@webrtc.org | 1ea4b50 | 2013-01-07 08:49:41 +0000 | [diff] [blame] | 100 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 101 | |
stefan@webrtc.org | 1ea4b50 | 2013-01-07 08:49:41 +0000 | [diff] [blame] | 102 | #endif // WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_RECEIVER_H_ |