OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 #include "webrtc/call/flexfec_receive_stream_impl.h" | 11 #include "webrtc/call/flexfec_receive_stream_impl.h" |
12 | 12 |
13 #include <utility> | 13 #include <string> |
14 | 14 |
15 #include "webrtc/base/checks.h" | 15 #include "webrtc/base/checks.h" |
16 #include "webrtc/base/logging.h" | 16 #include "webrtc/base/logging.h" |
17 #include "webrtc/modules/rtp_rtcp/include/flexfec_receiver.h" | |
18 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" | |
19 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | |
20 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" | |
21 #include "webrtc/modules/utility/include/process_thread.h" | |
22 #include "webrtc/system_wrappers/include/clock.h" | |
17 | 23 |
18 namespace webrtc { | 24 namespace webrtc { |
19 | 25 |
20 std::string FlexfecReceiveStream::Stats::ToString(int64_t time_ms) const { | 26 std::string FlexfecReceiveStream::Stats::ToString(int64_t time_ms) const { |
21 std::stringstream ss; | 27 std::stringstream ss; |
22 ss << "FlexfecReceiveStream stats: " << time_ms | 28 ss << "FlexfecReceiveStream stats: " << time_ms |
23 << ", {flexfec_bitrate_bps: " << flexfec_bitrate_bps << "}"; | 29 << ", {flexfec_bitrate_bps: " << flexfec_bitrate_bps << "}"; |
24 return ss.str(); | 30 return ss.str(); |
25 } | 31 } |
26 | 32 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 "supports protecting a single media stream. " | 96 "supports protecting a single media stream. " |
91 "To avoid confusion, disabling FlexFEC completely."; | 97 "To avoid confusion, disabling FlexFEC completely."; |
92 return nullptr; | 98 return nullptr; |
93 } | 99 } |
94 RTC_DCHECK_EQ(1U, config.protected_media_ssrcs.size()); | 100 RTC_DCHECK_EQ(1U, config.protected_media_ssrcs.size()); |
95 return std::unique_ptr<FlexfecReceiver>( | 101 return std::unique_ptr<FlexfecReceiver>( |
96 new FlexfecReceiver(config.remote_ssrc, config.protected_media_ssrcs[0], | 102 new FlexfecReceiver(config.remote_ssrc, config.protected_media_ssrcs[0], |
97 recovered_packet_receiver)); | 103 recovered_packet_receiver)); |
98 } | 104 } |
99 | 105 |
106 std::unique_ptr<RtpRtcp> CreateRtpRtcpModule( | |
107 ReceiveStatistics* receive_statistics, | |
108 Transport* rtcp_send_transport, | |
109 RtcpRttStats* rtt_stats) { | |
110 RtpRtcp::Configuration configuration; | |
111 configuration.audio = false; | |
danilchap
2017/01/10 13:48:17
add configuration.clock = Clock::GetRealTimeClock(
brandtr
2017/01/11 09:55:24
Done.
| |
112 configuration.receiver_only = true; | |
113 configuration.receive_statistics = receive_statistics; | |
114 configuration.outgoing_transport = rtcp_send_transport; | |
115 configuration.rtt_stats = rtt_stats; | |
116 std::unique_ptr<RtpRtcp> rtp_rtcp(RtpRtcp::CreateRtpRtcp(configuration)); | |
117 | |
118 return rtp_rtcp; | |
119 } | |
120 | |
100 } // namespace | 121 } // namespace |
101 | 122 |
102 FlexfecReceiveStreamImpl::FlexfecReceiveStreamImpl( | 123 FlexfecReceiveStreamImpl::FlexfecReceiveStreamImpl( |
103 const Config& config, | 124 const Config& config, |
104 RecoveredPacketReceiver* recovered_packet_receiver) | 125 RecoveredPacketReceiver* recovered_packet_receiver, |
105 : started_(false), | 126 RtcpRttStats* rtt_stats, |
106 config_(config), | 127 ProcessThread* process_thread) |
107 receiver_( | 128 : config_(config), |
108 MaybeCreateFlexfecReceiver(config_, recovered_packet_receiver)) { | 129 started_(false), |
130 receiver_(MaybeCreateFlexfecReceiver(config_, recovered_packet_receiver)), | |
131 rtp_receive_statistics_( | |
132 ReceiveStatistics::Create(Clock::GetRealTimeClock())), | |
133 rtp_rtcp_(CreateRtpRtcpModule(rtp_receive_statistics_.get(), | |
134 config_.rtcp_send_transport, | |
135 rtt_stats)), | |
136 process_thread_(process_thread) { | |
109 LOG(LS_INFO) << "FlexfecReceiveStreamImpl: " << config_.ToString(); | 137 LOG(LS_INFO) << "FlexfecReceiveStreamImpl: " << config_.ToString(); |
138 | |
139 // RTCP reporting. | |
140 rtp_rtcp_->SetSendingMediaStatus(false); | |
141 rtp_rtcp_->SetRTCPStatus(config_.rtcp_mode); | |
142 rtp_rtcp_->SetSSRC(config_.local_ssrc); | |
143 process_thread_->RegisterModule(rtp_rtcp_.get()); | |
110 } | 144 } |
111 | 145 |
112 FlexfecReceiveStreamImpl::~FlexfecReceiveStreamImpl() { | 146 FlexfecReceiveStreamImpl::~FlexfecReceiveStreamImpl() { |
113 LOG(LS_INFO) << "~FlexfecReceiveStreamImpl: " << config_.ToString(); | 147 LOG(LS_INFO) << "~FlexfecReceiveStreamImpl: " << config_.ToString(); |
114 Stop(); | 148 Stop(); |
149 process_thread_->DeRegisterModule(rtp_rtcp_.get()); | |
115 } | 150 } |
116 | 151 |
117 bool FlexfecReceiveStreamImpl::AddAndProcessReceivedPacket( | 152 bool FlexfecReceiveStreamImpl::AddAndProcessReceivedPacket( |
118 RtpPacketReceived packet) { | 153 const RtpPacketReceived& packet) { |
119 { | 154 { |
120 rtc::CritScope cs(&crit_); | 155 rtc::CritScope cs(&crit_); |
121 if (!started_) | 156 if (!started_) |
122 return false; | 157 return false; |
123 } | 158 } |
159 | |
124 if (!receiver_) | 160 if (!receiver_) |
125 return false; | 161 return false; |
126 return receiver_->AddAndProcessReceivedPacket(std::move(packet)); | 162 |
163 if (!receiver_->AddAndProcessReceivedPacket(packet)) | |
164 return false; | |
165 | |
166 // Do not report media packets in the RTCP RRs generated by |rtp_rtcp_|. | |
167 if (packet.Ssrc() == config_.remote_ssrc) { | |
168 RTPHeader header; | |
169 packet.GetHeader(&header); | |
170 // FlexFEC packets are never retransmitted. | |
171 const bool kNotRetransmitted = false; | |
172 rtp_receive_statistics_->IncomingPacket(header, packet.size(), | |
173 kNotRetransmitted); | |
174 } | |
175 | |
176 return true; | |
127 } | 177 } |
128 | 178 |
129 void FlexfecReceiveStreamImpl::Start() { | 179 void FlexfecReceiveStreamImpl::Start() { |
130 rtc::CritScope cs(&crit_); | 180 rtc::CritScope cs(&crit_); |
131 started_ = true; | 181 started_ = true; |
132 } | 182 } |
133 | 183 |
134 void FlexfecReceiveStreamImpl::Stop() { | 184 void FlexfecReceiveStreamImpl::Stop() { |
135 rtc::CritScope cs(&crit_); | 185 rtc::CritScope cs(&crit_); |
136 started_ = false; | 186 started_ = false; |
137 } | 187 } |
138 | 188 |
139 // TODO(brandtr): Implement this member function when we have designed the | 189 // TODO(brandtr): Implement this member function when we have designed the |
140 // stats for FlexFEC. | 190 // stats for FlexFEC. |
141 FlexfecReceiveStreamImpl::Stats FlexfecReceiveStreamImpl::GetStats() const { | 191 FlexfecReceiveStreamImpl::Stats FlexfecReceiveStreamImpl::GetStats() const { |
142 return FlexfecReceiveStream::Stats(); | 192 return FlexfecReceiveStream::Stats(); |
143 } | 193 } |
144 | 194 |
145 } // namespace webrtc | 195 } // namespace webrtc |
OLD | NEW |