| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef WEBRTC_VIDEO_VIE_CHANNEL_H_ | 11 #ifndef WEBRTC_VIDEO_VIDEO_STREAM_DECODER_H_ |
| 12 #define WEBRTC_VIDEO_VIE_CHANNEL_H_ | 12 #define WEBRTC_VIDEO_VIDEO_STREAM_DECODER_H_ |
| 13 | 13 |
| 14 #include <list> | 14 #include <list> |
| 15 #include <map> | 15 #include <map> |
| 16 #include <memory> | 16 #include <memory> |
| 17 #include <vector> | 17 #include <vector> |
| 18 | 18 |
| 19 #include "webrtc/base/criticalsection.h" | 19 #include "webrtc/base/criticalsection.h" |
| 20 #include "webrtc/base/platform_thread.h" | 20 #include "webrtc/base/platform_thread.h" |
| 21 #include "webrtc/base/scoped_ref_ptr.h" | 21 #include "webrtc/base/scoped_ref_ptr.h" |
| 22 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
or.h" | 22 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat
or.h" |
| 23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | |
| 24 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | |
| 25 #include "webrtc/modules/video_coding/include/video_coding_defines.h" | 23 #include "webrtc/modules/video_coding/include/video_coding_defines.h" |
| 26 #include "webrtc/system_wrappers/include/tick_util.h" | 24 #include "webrtc/system_wrappers/include/tick_util.h" |
| 27 #include "webrtc/typedefs.h" | 25 #include "webrtc/typedefs.h" |
| 28 #include "webrtc/video/rtp_stream_receiver.h" | |
| 29 #include "webrtc/video/vie_sync_module.h" | 26 #include "webrtc/video/vie_sync_module.h" |
| 30 | 27 |
| 31 namespace webrtc { | 28 namespace webrtc { |
| 32 | 29 |
| 33 class CallStatsObserver; | 30 class CallStatsObserver; |
| 34 class ChannelStatsObserver; | 31 class ChannelStatsObserver; |
| 35 class Config; | 32 class Config; |
| 36 class EncodedImageCallback; | 33 class EncodedImageCallback; |
| 37 class I420FrameCallback; | 34 class I420FrameCallback; |
| 38 class IncomingVideoStream; | 35 class IncomingVideoStream; |
| 39 class PacedSender; | |
| 40 class PacketRouter; | |
| 41 class PayloadRouter; | |
| 42 class ReceiveStatisticsProxy; | 36 class ReceiveStatisticsProxy; |
| 43 class RtcpRttStats; | 37 class VideoRenderCallback; |
| 44 class ViERTPObserver; | |
| 45 class VoEVideoSync; | 38 class VoEVideoSync; |
| 46 | 39 |
| 47 namespace vcm { | 40 namespace vcm { |
| 48 class VideoReceiver; | 41 class VideoReceiver; |
| 49 } // namespace vcm | 42 } // namespace vcm |
| 50 | 43 |
| 51 enum StreamType { | 44 enum StreamType { |
| 52 kViEStreamTypeNormal = 0, // Normal media stream | 45 kViEStreamTypeNormal = 0, // Normal media stream |
| 53 kViEStreamTypeRtx = 1 // Retransmission media stream | 46 kViEStreamTypeRtx = 1 // Retransmission media stream |
| 54 }; | 47 }; |
| 55 | 48 |
| 56 class ViEChannel : public VCMFrameTypeCallback, | 49 class VideoStreamDecoder : public VCMReceiveCallback, |
| 57 public VCMReceiveCallback, | 50 public VCMReceiveStatisticsCallback, |
| 58 public VCMReceiveStatisticsCallback, | 51 public VCMDecoderTimingCallback, |
| 59 public VCMDecoderTimingCallback, | 52 public CallStatsObserver { |
| 60 public VCMPacketRequestCallback { | |
| 61 public: | 53 public: |
| 62 friend class ChannelStatsObserver; | 54 friend class ChannelStatsObserver; |
| 63 | 55 |
| 64 ViEChannel(vcm::VideoReceiver* video_receiver, | 56 VideoStreamDecoder(vcm::VideoReceiver* video_receiver, |
| 65 RtpStreamReceiver* rtp_stream_receiver); | 57 VCMFrameTypeCallback* vcm_frame_type_callback, |
| 66 ~ViEChannel(); | 58 VCMPacketRequestCallback* vcm_packet_request_callback, |
| 67 | 59 bool enable_nack, |
| 68 int32_t Init(); | 60 ReceiveStatisticsProxy* receive_statistics_proxy, |
| 69 | 61 IncomingVideoStream* incoming_video_stream, |
| 70 RtpRtcp* rtp_rtcp() const { return rtp_rtcp_; } | 62 I420FrameCallback* pre_render_callback); |
| 71 | 63 ~VideoStreamDecoder(); |
| 72 void SetProtectionMode(bool enable_nack, | |
| 73 bool enable_fec, | |
| 74 int payload_type_red, | |
| 75 int payload_type_fec); | |
| 76 | |
| 77 RtpState GetRtpStateForSsrc(uint32_t ssrc) const; | |
| 78 | |
| 79 | |
| 80 CallStatsObserver* GetStatsObserver(); | |
| 81 | 64 |
| 82 // Implements VCMReceiveCallback. | 65 // Implements VCMReceiveCallback. |
| 83 int32_t FrameToRender(VideoFrame& video_frame) override; // NOLINT | 66 int32_t FrameToRender(VideoFrame& video_frame) override; // NOLINT |
| 84 | |
| 85 // Implements VCMReceiveCallback. | |
| 86 int32_t ReceivedDecodedReferenceFrame(const uint64_t picture_id) override; | 67 int32_t ReceivedDecodedReferenceFrame(const uint64_t picture_id) override; |
| 87 | |
| 88 // Implements VCMReceiveCallback. | |
| 89 void OnIncomingPayloadType(int payload_type) override; | 68 void OnIncomingPayloadType(int payload_type) override; |
| 90 void OnDecoderImplementationName(const char* implementation_name) override; | 69 void OnDecoderImplementationName(const char* implementation_name) override; |
| 91 | 70 |
| 92 // Implements VCMReceiveStatisticsCallback. | 71 // Implements VCMReceiveStatisticsCallback. |
| 93 void OnReceiveRatesUpdated(uint32_t bit_rate, uint32_t frame_rate) override; | 72 void OnReceiveRatesUpdated(uint32_t bit_rate, uint32_t frame_rate) override; |
| 94 void OnDiscardedPacketsUpdated(int discarded_packets) override; | 73 void OnDiscardedPacketsUpdated(int discarded_packets) override; |
| 95 void OnFrameCountsUpdated(const FrameCounts& frame_counts) override; | 74 void OnFrameCountsUpdated(const FrameCounts& frame_counts) override; |
| 96 | 75 |
| 97 // Implements VCMDecoderTimingCallback. | 76 // Implements VCMDecoderTimingCallback. |
| 98 void OnDecoderTiming(int decode_ms, | 77 void OnDecoderTiming(int decode_ms, |
| 99 int max_decode_ms, | 78 int max_decode_ms, |
| 100 int current_delay_ms, | 79 int current_delay_ms, |
| 101 int target_delay_ms, | 80 int target_delay_ms, |
| 102 int jitter_buffer_ms, | 81 int jitter_buffer_ms, |
| 103 int min_playout_delay_ms, | 82 int min_playout_delay_ms, |
| 104 int render_delay_ms) override; | 83 int render_delay_ms) override; |
| 105 | 84 |
| 106 // Implements FrameTypeCallback. | |
| 107 int32_t RequestKeyFrame() override; | |
| 108 | 85 |
| 109 // Implements FrameTypeCallback. | |
| 110 int32_t SliceLossIndicationRequest( | |
| 111 const uint64_t picture_id) override; | |
| 112 | |
| 113 // Implements VideoPacketRequestCallback. | |
| 114 int32_t ResendPackets(const uint16_t* sequence_numbers, | |
| 115 uint16_t length) override; | |
| 116 | |
| 117 void RegisterPreRenderCallback(I420FrameCallback* pre_render_callback); | |
| 118 | |
| 119 void RegisterRtcpPacketTypeCounterObserver( | |
| 120 RtcpPacketTypeCounterObserver* observer); | |
| 121 void RegisterReceiveStatisticsProxy( | 86 void RegisterReceiveStatisticsProxy( |
| 122 ReceiveStatisticsProxy* receive_statistics_proxy); | 87 ReceiveStatisticsProxy* receive_statistics_proxy); |
| 123 void SetIncomingVideoStream(IncomingVideoStream* incoming_video_stream); | |
| 124 | 88 |
| 125 protected: | 89 // Implements StatsObserver. |
| 126 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms); | 90 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override; |
| 127 | 91 |
| 128 private: | 92 private: |
| 129 // Assumed to be protected. | 93 // Assumed to be protected. |
| 130 void StartDecodeThread(); | 94 void StartDecodeThread(); |
| 131 void StopDecodeThread(); | 95 void StopDecodeThread(); |
| 132 | 96 |
| 133 void ProcessNACKRequest(const bool enable); | |
| 134 // Compute NACK list parameters for the buffering mode. | |
| 135 int GetRequiredNackListSize(int target_delay_ms); | |
| 136 | |
| 137 // Used for all registered callbacks except rendering. | 97 // Used for all registered callbacks except rendering. |
| 138 rtc::CriticalSection crit_; | 98 rtc::CriticalSection crit_; |
| 139 | 99 |
| 140 vcm::VideoReceiver* const video_receiver_; | 100 vcm::VideoReceiver* const video_receiver_; |
| 141 RtpStreamReceiver* const rtp_stream_receiver_; | |
| 142 RtpRtcp* const rtp_rtcp_; | |
| 143 | 101 |
| 144 // Helper to report call statistics. | 102 ReceiveStatisticsProxy* const receive_stats_callback_; |
| 145 std::unique_ptr<ChannelStatsObserver> stats_observer_; | 103 IncomingVideoStream* const incoming_video_stream_; |
| 146 | 104 |
| 147 // Not owned. | 105 I420FrameCallback* const pre_render_callback_; |
| 148 ReceiveStatisticsProxy* receive_stats_callback_ GUARDED_BY(crit_); | |
| 149 FrameCounts receive_frame_counts_ GUARDED_BY(crit_); | |
| 150 IncomingVideoStream* incoming_video_stream_ GUARDED_BY(crit_); | |
| 151 | |
| 152 int max_nack_reordering_threshold_; | |
| 153 I420FrameCallback* pre_render_callback_ GUARDED_BY(crit_); | |
| 154 | 106 |
| 155 int64_t last_rtt_ms_ GUARDED_BY(crit_); | 107 int64_t last_rtt_ms_ GUARDED_BY(crit_); |
| 156 }; | 108 }; |
| 157 | 109 |
| 158 } // namespace webrtc | 110 } // namespace webrtc |
| 159 | 111 |
| 160 #endif // WEBRTC_VIDEO_VIE_CHANNEL_H_ | 112 #endif // WEBRTC_VIDEO_VIDEO_STREAM_DECODER_H_ |
| OLD | NEW |