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 VideoRenderCallback; | |
46 class VoEVideoSync; | |
47 | |
48 namespace vcm { | |
49 class VideoReceiver; | |
50 } // namespace vcm | |
51 | |
52 enum StreamType { | |
53 kViEStreamTypeNormal = 0, // Normal media stream | |
54 kViEStreamTypeRtx = 1 // Retransmission media stream | |
55 }; | |
56 | |
57 class ViEChannel : public VCMFrameTypeCallback, | |
58 public VCMReceiveCallback, | |
59 public VCMReceiveStatisticsCallback, | |
60 public VCMDecoderTimingCallback, | |
61 public VCMPacketRequestCallback { | |
62 public: | |
63 friend class ChannelStatsObserver; | |
64 | |
65 ViEChannel(vcm::VideoReceiver* video_receiver, | |
66 RtpStreamReceiver* rtp_stream_receiver); | |
67 ~ViEChannel(); | |
68 | |
69 int32_t Init(); | |
70 | |
71 RtpRtcp* rtp_rtcp() const { return rtp_rtcp_; } | |
72 | |
73 void SetProtectionMode(bool enable_nack, | |
74 bool enable_fec, | |
75 int payload_type_red, | |
76 int payload_type_fec); | |
77 | |
78 RtpState GetRtpStateForSsrc(uint32_t ssrc) const; | |
79 | |
80 | |
81 CallStatsObserver* GetStatsObserver(); | |
82 | |
83 // Implements VCMReceiveCallback. | |
84 virtual int32_t FrameToRender(VideoFrame& video_frame); // NOLINT | |
85 | |
86 // Implements VCMReceiveCallback. | |
87 virtual int32_t ReceivedDecodedReferenceFrame( | |
88 const uint64_t picture_id); | |
89 | |
90 // Implements VCMReceiveCallback. | |
91 void OnIncomingPayloadType(int payload_type) override; | |
92 void OnDecoderImplementationName(const char* implementation_name) override; | |
93 | |
94 // Implements VCMReceiveStatisticsCallback. | |
95 void OnReceiveRatesUpdated(uint32_t bit_rate, uint32_t frame_rate) override; | |
96 void OnDiscardedPacketsUpdated(int discarded_packets) override; | |
97 void OnFrameCountsUpdated(const FrameCounts& frame_counts) override; | |
98 | |
99 // Implements VCMDecoderTimingCallback. | |
100 virtual void OnDecoderTiming(int decode_ms, | |
101 int max_decode_ms, | |
102 int current_delay_ms, | |
103 int target_delay_ms, | |
104 int jitter_buffer_ms, | |
105 int min_playout_delay_ms, | |
106 int render_delay_ms); | |
107 | |
108 // Implements FrameTypeCallback. | |
109 virtual int32_t RequestKeyFrame(); | |
110 | |
111 // Implements FrameTypeCallback. | |
112 virtual int32_t SliceLossIndicationRequest( | |
113 const uint64_t picture_id); | |
114 | |
115 // Implements VideoPacketRequestCallback. | |
116 int32_t ResendPackets(const uint16_t* sequence_numbers, | |
117 uint16_t length) override; | |
118 | |
119 void RegisterPreRenderCallback(I420FrameCallback* pre_render_callback); | |
120 | |
121 void RegisterRtcpPacketTypeCounterObserver( | |
122 RtcpPacketTypeCounterObserver* observer); | |
123 void RegisterReceiveStatisticsProxy( | |
124 ReceiveStatisticsProxy* receive_statistics_proxy); | |
125 void SetIncomingVideoStream(IncomingVideoStream* incoming_video_stream); | |
126 | |
127 protected: | |
128 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms); | |
129 | |
130 private: | |
131 // Assumed to be protected. | |
132 void StartDecodeThread(); | |
133 void StopDecodeThread(); | |
134 | |
135 void ProcessNACKRequest(const bool enable); | |
136 // Compute NACK list parameters for the buffering mode. | |
137 int GetRequiredNackListSize(int target_delay_ms); | |
138 | |
139 // Used for all registered callbacks except rendering. | |
140 rtc::CriticalSection crit_; | |
141 | |
142 vcm::VideoReceiver* const video_receiver_; | |
143 RtpStreamReceiver* const rtp_stream_receiver_; | |
144 RtpRtcp* const rtp_rtcp_; | |
145 | |
146 // Helper to report call statistics. | |
147 std::unique_ptr<ChannelStatsObserver> stats_observer_; | |
148 | |
149 // Not owned. | |
150 ReceiveStatisticsProxy* receive_stats_callback_ GUARDED_BY(crit_); | |
151 FrameCounts receive_frame_counts_ GUARDED_BY(crit_); | |
152 IncomingVideoStream* incoming_video_stream_ GUARDED_BY(crit_); | |
153 | |
154 int max_nack_reordering_threshold_; | |
155 I420FrameCallback* pre_render_callback_ GUARDED_BY(crit_); | |
156 | |
157 int64_t last_rtt_ms_ GUARDED_BY(crit_); | |
158 }; | |
159 | |
160 } // namespace webrtc | |
161 | |
162 #endif // WEBRTC_VIDEO_VIE_CHANNEL_H_ | |
OLD | NEW |