OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2012 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 WEBRTC_VIDEO_VIE_CHANNEL_H_ | |
12 #define WEBRTC_VIDEO_VIE_CHANNEL_H_ | |
13 | |
14 #include <list> | |
15 #include <map> | |
16 #include <memory> | |
17 #include <vector> | |
18 | |
19 #include "webrtc/base/criticalsection.h" | |
20 #include "webrtc/base/platform_thread.h" | |
21 #include "webrtc/base/scoped_ref_ptr.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" | |
26 #include "webrtc/system_wrappers/include/tick_util.h" | |
27 #include "webrtc/typedefs.h" | |
28 #include "webrtc/video/rtp_stream_receiver.h" | |
29 #include "webrtc/video/vie_sync_module.h" | |
30 | |
31 namespace webrtc { | |
32 | |
33 class CallStatsObserver; | |
34 class ChannelStatsObserver; | |
35 class Config; | |
36 class EncodedImageCallback; | |
37 class I420FrameCallback; | |
38 class IncomingVideoStream; | |
39 class PacedSender; | |
40 class PacketRouter; | |
41 class PayloadRouter; | |
42 class ReceiveStatisticsProxy; | |
43 class RtcpRttStats; | |
44 class ViERTPObserver; | |
45 class VoEVideoSync; | |
46 | |
47 namespace vcm { | |
48 class VideoReceiver; | |
49 } // namespace vcm | |
50 | |
51 enum StreamType { | |
52 kViEStreamTypeNormal = 0, // Normal media stream | |
53 kViEStreamTypeRtx = 1 // Retransmission media stream | |
54 }; | |
55 | |
56 class ViEChannel : public VCMFrameTypeCallback, | |
57 public VCMReceiveCallback, | |
58 public VCMReceiveStatisticsCallback, | |
59 public VCMDecoderTimingCallback, | |
60 public VCMPacketRequestCallback { | |
61 public: | |
62 friend class ChannelStatsObserver; | |
63 | |
64 ViEChannel(vcm::VideoReceiver* video_receiver, | |
65 RtpStreamReceiver* rtp_stream_receiver); | |
66 ~ViEChannel(); | |
67 | |
68 int32_t Init(); | |
69 | |
70 RtpRtcp* rtp_rtcp() const { return rtp_rtcp_; } | |
71 | |
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 | |
82 // Implements VCMReceiveCallback. | |
83 int32_t FrameToRender(VideoFrame& video_frame) override; // NOLINT | |
84 | |
85 // Implements VCMReceiveCallback. | |
86 int32_t ReceivedDecodedReferenceFrame(const uint64_t picture_id) override; | |
87 | |
88 // Implements VCMReceiveCallback. | |
89 void OnIncomingPayloadType(int payload_type) override; | |
90 void OnDecoderImplementationName(const char* implementation_name) override; | |
91 | |
92 // Implements VCMReceiveStatisticsCallback. | |
93 void OnReceiveRatesUpdated(uint32_t bit_rate, uint32_t frame_rate) override; | |
94 void OnDiscardedPacketsUpdated(int discarded_packets) override; | |
95 void OnFrameCountsUpdated(const FrameCounts& frame_counts) override; | |
96 | |
97 // Implements VCMDecoderTimingCallback. | |
98 void OnDecoderTiming(int decode_ms, | |
99 int max_decode_ms, | |
100 int current_delay_ms, | |
101 int target_delay_ms, | |
102 int jitter_buffer_ms, | |
103 int min_playout_delay_ms, | |
104 int render_delay_ms) override; | |
105 | |
106 // Implements FrameTypeCallback. | |
107 int32_t RequestKeyFrame() override; | |
108 | |
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( | |
122 ReceiveStatisticsProxy* receive_statistics_proxy); | |
123 void SetIncomingVideoStream(IncomingVideoStream* incoming_video_stream); | |
124 | |
125 protected: | |
126 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms); | |
127 | |
128 private: | |
129 // Assumed to be protected. | |
130 void StartDecodeThread(); | |
131 void StopDecodeThread(); | |
132 | |
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. | |
138 rtc::CriticalSection crit_; | |
139 | |
140 vcm::VideoReceiver* const video_receiver_; | |
141 RtpStreamReceiver* const rtp_stream_receiver_; | |
142 RtpRtcp* const rtp_rtcp_; | |
143 | |
144 // Helper to report call statistics. | |
145 std::unique_ptr<ChannelStatsObserver> stats_observer_; | |
146 | |
147 // Not owned. | |
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 | |
155 int64_t last_rtt_ms_ GUARDED_BY(crit_); | |
156 }; | |
157 | |
158 } // namespace webrtc | |
159 | |
160 #endif // WEBRTC_VIDEO_VIE_CHANNEL_H_ | |
OLD | NEW |