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 #include "webrtc/video/rtp_stream_receiver.h" | 11 #include "webrtc/video/rtp_stream_receiver.h" |
12 | 12 |
13 #include <vector> | 13 #include <vector> |
14 #include <utility> | 14 #include <utility> |
15 | 15 |
16 #include "webrtc/base/checks.h" | 16 #include "webrtc/base/checks.h" |
17 #include "webrtc/base/logging.h" | 17 #include "webrtc/base/logging.h" |
18 #include "webrtc/common_types.h" | 18 #include "webrtc/common_types.h" |
19 #include "webrtc/config.h" | 19 #include "webrtc/config.h" |
20 #include "webrtc/media/base/mediaconstants.h" | |
20 #include "webrtc/modules/pacing/packet_router.h" | 21 #include "webrtc/modules/pacing/packet_router.h" |
21 #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" |
22 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" | 23 #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" |
23 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h" | 24 #include "webrtc/modules/rtp_rtcp/include/rtp_cvo.h" |
24 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" | 25 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
25 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" | 26 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" |
26 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 27 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
27 #include "webrtc/modules/rtp_rtcp/include/ulpfec_receiver.h" | 28 #include "webrtc/modules/rtp_rtcp/include/ulpfec_receiver.h" |
28 #include "webrtc/modules/video_coding/frame_object.h" | 29 #include "webrtc/modules/video_coding/frame_object.h" |
30 #include "webrtc/modules/video_coding/h264_sprop_parameter_sets.h" | |
29 #include "webrtc/modules/video_coding/h264_sps_pps_tracker.h" | 31 #include "webrtc/modules/video_coding/h264_sps_pps_tracker.h" |
30 #include "webrtc/modules/video_coding/packet_buffer.h" | 32 #include "webrtc/modules/video_coding/packet_buffer.h" |
31 #include "webrtc/modules/video_coding/video_coding_impl.h" | 33 #include "webrtc/modules/video_coding/video_coding_impl.h" |
32 #include "webrtc/system_wrappers/include/field_trial.h" | 34 #include "webrtc/system_wrappers/include/field_trial.h" |
33 #include "webrtc/system_wrappers/include/metrics.h" | 35 #include "webrtc/system_wrappers/include/metrics.h" |
34 #include "webrtc/system_wrappers/include/timestamp_extrapolator.h" | 36 #include "webrtc/system_wrappers/include/timestamp_extrapolator.h" |
35 #include "webrtc/system_wrappers/include/trace.h" | 37 #include "webrtc/system_wrappers/include/trace.h" |
36 #include "webrtc/video/receive_statistics_proxy.h" | 38 #include "webrtc/video/receive_statistics_proxy.h" |
37 #include "webrtc/video/vie_remb.h" | 39 #include "webrtc/video/vie_remb.h" |
38 | 40 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 | 218 |
217 if (jitter_buffer_experiment_) | 219 if (jitter_buffer_experiment_) |
218 process_thread_->DeRegisterModule(nack_module_.get()); | 220 process_thread_->DeRegisterModule(nack_module_.get()); |
219 | 221 |
220 packet_router_->RemoveRtpModule(rtp_rtcp_.get()); | 222 packet_router_->RemoveRtpModule(rtp_rtcp_.get()); |
221 rtp_rtcp_->SetREMBStatus(false); | 223 rtp_rtcp_->SetREMBStatus(false); |
222 remb_->RemoveReceiveChannel(rtp_rtcp_.get()); | 224 remb_->RemoveReceiveChannel(rtp_rtcp_.get()); |
223 UpdateHistograms(); | 225 UpdateHistograms(); |
224 } | 226 } |
225 | 227 |
228 bool RtpStreamReceiver::AddReceiveCodec( | |
229 const VideoCodec& video_codec, | |
230 const std::map<std::string, std::string>& codec_params) { | |
231 pt_codec_params_.insert(make_pair(video_codec.plType, codec_params)); | |
232 return AddReceiveCodec(video_codec); | |
233 } | |
234 | |
226 bool RtpStreamReceiver::AddReceiveCodec(const VideoCodec& video_codec) { | 235 bool RtpStreamReceiver::AddReceiveCodec(const VideoCodec& video_codec) { |
227 int8_t old_pltype = -1; | 236 int8_t old_pltype = -1; |
228 if (rtp_payload_registry_.ReceivePayloadType(video_codec, &old_pltype) != | 237 if (rtp_payload_registry_.ReceivePayloadType(video_codec, &old_pltype) != |
229 -1) { | 238 -1) { |
230 rtp_payload_registry_.DeRegisterReceivePayload(old_pltype); | 239 rtp_payload_registry_.DeRegisterReceivePayload(old_pltype); |
231 } | 240 } |
232 | |
233 return rtp_payload_registry_.RegisterReceivePayload(video_codec) == 0; | 241 return rtp_payload_registry_.RegisterReceivePayload(video_codec) == 0; |
234 } | 242 } |
235 | 243 |
236 uint32_t RtpStreamReceiver::GetRemoteSsrc() const { | 244 uint32_t RtpStreamReceiver::GetRemoteSsrc() const { |
237 return rtp_receiver_->SSRC(); | 245 return rtp_receiver_->SSRC(); |
238 } | 246 } |
239 | 247 |
240 int RtpStreamReceiver::GetCsrcs(uint32_t* csrcs) const { | 248 int RtpStreamReceiver::GetCsrcs(uint32_t* csrcs) const { |
241 return rtp_receiver_->CSRCs(csrcs); | 249 return rtp_receiver_->CSRCs(csrcs); |
242 } | 250 } |
243 | 251 |
244 RtpReceiver* RtpStreamReceiver::GetRtpReceiver() const { | 252 RtpReceiver* RtpStreamReceiver::GetRtpReceiver() const { |
245 return rtp_receiver_.get(); | 253 return rtp_receiver_.get(); |
246 } | 254 } |
247 | 255 |
248 int32_t RtpStreamReceiver::OnReceivedPayloadData( | 256 int32_t RtpStreamReceiver::OnReceivedPayloadData( |
249 const uint8_t* payload_data, | 257 const uint8_t* payload_data, |
250 size_t payload_size, | 258 size_t payload_size, |
251 const WebRtcRTPHeader* rtp_header) { | 259 const WebRtcRTPHeader* rtp_header) { |
252 RTC_DCHECK(video_receiver_); | 260 RTC_DCHECK(video_receiver_); |
253 WebRtcRTPHeader rtp_header_with_ntp = *rtp_header; | 261 WebRtcRTPHeader rtp_header_with_ntp = *rtp_header; |
254 rtp_header_with_ntp.ntp_time_ms = | 262 rtp_header_with_ntp.ntp_time_ms = |
255 ntp_estimator_.Estimate(rtp_header->header.timestamp); | 263 ntp_estimator_.Estimate(rtp_header->header.timestamp); |
256 if (jitter_buffer_experiment_) { | 264 if (jitter_buffer_experiment_) { |
257 VCMPacket packet(payload_data, payload_size, rtp_header_with_ntp); | 265 VCMPacket packet(payload_data, payload_size, rtp_header_with_ntp); |
258 timing_->IncomingTimestamp(packet.timestamp, clock_->TimeInMilliseconds()); | 266 timing_->IncomingTimestamp(packet.timestamp, clock_->TimeInMilliseconds()); |
259 packet.timesNacked = nack_module_->OnReceivedPacket(packet); | 267 packet.timesNacked = nack_module_->OnReceivedPacket(packet); |
260 | 268 |
261 if (packet.codec == kVideoCodecH264) { | 269 if (packet.codec == kVideoCodecH264) { |
270 // Only when we start to receive packets will we know what payload type | |
271 // that will be used. When we know the payload type insert the correct | |
272 // sps/pps into the tracker. | |
273 if (!received_rtp_packet_) { | |
stefan-webrtc
2016/12/19 12:05:23
Can't the payload type change in theory since we s
johan
2016/12/19 12:27:26
The payload type represents what sender and receiv
philipel
2016/12/19 12:31:27
The assumption is that there is only one VideoRece
| |
274 received_rtp_packet_ = true; | |
275 InsertSpsPpsIntoTracker(packet.payloadType); | |
276 } | |
277 | |
262 switch (tracker_.CopyAndFixBitstream(&packet)) { | 278 switch (tracker_.CopyAndFixBitstream(&packet)) { |
263 case video_coding::H264SpsPpsTracker::kRequestKeyframe: | 279 case video_coding::H264SpsPpsTracker::kRequestKeyframe: |
264 keyframe_request_sender_->RequestKeyFrame(); | 280 keyframe_request_sender_->RequestKeyFrame(); |
265 FALLTHROUGH(); | 281 FALLTHROUGH(); |
266 case video_coding::H264SpsPpsTracker::kDrop: | 282 case video_coding::H264SpsPpsTracker::kDrop: |
267 return 0; | 283 return 0; |
268 case video_coding::H264SpsPpsTracker::kInsert: | 284 case video_coding::H264SpsPpsTracker::kInsert: |
269 break; | 285 break; |
270 } | 286 } |
271 } else { | 287 } else { |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
643 void RtpStreamReceiver::EnableReceiveRtpHeaderExtension( | 659 void RtpStreamReceiver::EnableReceiveRtpHeaderExtension( |
644 const std::string& extension, int id) { | 660 const std::string& extension, int id) { |
645 // One-byte-extension local identifiers are in the range 1-14 inclusive. | 661 // One-byte-extension local identifiers are in the range 1-14 inclusive. |
646 RTC_DCHECK_GE(id, 1); | 662 RTC_DCHECK_GE(id, 1); |
647 RTC_DCHECK_LE(id, 14); | 663 RTC_DCHECK_LE(id, 14); |
648 RTC_DCHECK(RtpExtension::IsSupportedForVideo(extension)); | 664 RTC_DCHECK(RtpExtension::IsSupportedForVideo(extension)); |
649 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension( | 665 RTC_CHECK(rtp_header_parser_->RegisterRtpHeaderExtension( |
650 StringToRtpExtensionType(extension), id)); | 666 StringToRtpExtensionType(extension), id)); |
651 } | 667 } |
652 | 668 |
669 void RtpStreamReceiver::InsertSpsPpsIntoTracker(uint8_t payload_type) { | |
670 auto codec_params_it = pt_codec_params_.find(payload_type); | |
671 if (codec_params_it == pt_codec_params_.end()) | |
672 return; | |
673 | |
674 LOG(LS_INFO) << "Found out of band supplied codec paramters for" | |
stefan-webrtc
2016/12/19 12:05:23
codec parameters
philipel
2016/12/19 12:31:27
Done.
| |
675 << " payload type: " << payload_type; | |
676 | |
677 H264SpropParameterSets sprop_decoder; | |
678 auto sprop_base64_it = | |
679 codec_params_it->second.find(cricket::kH264FmtpSpropParameterSets); | |
680 | |
681 if (sprop_base64_it == codec_params_it->second.end()) | |
682 return; | |
683 | |
684 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second)) | |
685 return; | |
686 | |
687 tracker_.InsertSpsPps(sprop_decoder.sps_nalu(), sprop_decoder.pps_nalu()); | |
688 } | |
689 | |
653 } // namespace webrtc | 690 } // namespace webrtc |
OLD | NEW |