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 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 uint32_t rate) { | 225 uint32_t rate) { |
226 RTC_DCHECK_LT(strlen(payload_name), RTP_PAYLOAD_NAME_SIZE); | 226 RTC_DCHECK_LT(strlen(payload_name), RTP_PAYLOAD_NAME_SIZE); |
227 rtc::CritScope lock(&send_critsect_); | 227 rtc::CritScope lock(&send_critsect_); |
228 | 228 |
229 std::map<int8_t, RtpUtility::Payload*>::iterator it = | 229 std::map<int8_t, RtpUtility::Payload*>::iterator it = |
230 payload_type_map_.find(payload_number); | 230 payload_type_map_.find(payload_number); |
231 | 231 |
232 if (payload_type_map_.end() != it) { | 232 if (payload_type_map_.end() != it) { |
233 // We already use this payload type. | 233 // We already use this payload type. |
234 RtpUtility::Payload* payload = it->second; | 234 RtpUtility::Payload* payload = it->second; |
235 assert(payload); | 235 RTC_DCHECK(payload); |
236 | 236 |
237 // Check if it's the same as we already have. | 237 // Check if it's the same as we already have. |
238 if (RtpUtility::StringCompare( | 238 if (RtpUtility::StringCompare( |
239 payload->name, payload_name, RTP_PAYLOAD_NAME_SIZE - 1)) { | 239 payload->name, payload_name, RTP_PAYLOAD_NAME_SIZE - 1)) { |
240 if (audio_configured_ && payload->audio && | 240 if (audio_configured_ && payload->audio && |
241 payload->typeSpecific.Audio.frequency == frequency && | 241 payload->typeSpecific.Audio.frequency == frequency && |
242 (payload->typeSpecific.Audio.rate == rate || | 242 (payload->typeSpecific.Audio.rate == rate || |
243 payload->typeSpecific.Audio.rate == 0 || rate == 0)) { | 243 payload->typeSpecific.Audio.rate == 0 || rate == 0)) { |
244 payload->typeSpecific.Audio.rate = rate; | 244 payload->typeSpecific.Audio.rate = rate; |
245 // Ensure that we update the rate if new or old is zero. | 245 // Ensure that we update the rate if new or old is zero. |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 } | 348 } |
349 std::map<int8_t, RtpUtility::Payload*>::iterator it = | 349 std::map<int8_t, RtpUtility::Payload*>::iterator it = |
350 payload_type_map_.find(payload_type); | 350 payload_type_map_.find(payload_type); |
351 if (it == payload_type_map_.end()) { | 351 if (it == payload_type_map_.end()) { |
352 LOG(LS_WARNING) << "Payload type " << static_cast<int>(payload_type) | 352 LOG(LS_WARNING) << "Payload type " << static_cast<int>(payload_type) |
353 << " not registered."; | 353 << " not registered."; |
354 return -1; | 354 return -1; |
355 } | 355 } |
356 SetSendPayloadType(payload_type); | 356 SetSendPayloadType(payload_type); |
357 RtpUtility::Payload* payload = it->second; | 357 RtpUtility::Payload* payload = it->second; |
358 assert(payload); | 358 RTC_DCHECK(payload); |
359 if (!payload->audio && !audio_configured_) { | 359 if (!payload->audio && !audio_configured_) { |
360 video_->SetVideoCodecType(payload->typeSpecific.Video.videoCodecType); | 360 video_->SetVideoCodecType(payload->typeSpecific.Video.videoCodecType); |
361 *video_type = payload->typeSpecific.Video.videoCodecType; | 361 *video_type = payload->typeSpecific.Video.videoCodecType; |
362 } | 362 } |
363 return 0; | 363 return 0; |
364 } | 364 } |
365 | 365 |
366 bool RTPSender::SendOutgoingData(FrameType frame_type, | 366 bool RTPSender::SendOutgoingData(FrameType frame_type, |
367 int8_t payload_type, | 367 int8_t payload_type, |
368 uint32_t capture_timestamp, | 368 uint32_t capture_timestamp, |
369 int64_t capture_time_ms, | 369 int64_t capture_time_ms, |
370 const uint8_t* payload_data, | 370 const uint8_t* payload_data, |
371 size_t payload_size, | 371 size_t payload_size, |
372 const RTPFragmentationHeader* fragmentation, | 372 const RTPFragmentationHeader* fragmentation, |
373 const RTPVideoHeader* rtp_header, | 373 const RTPVideoHeader* rtp_header, |
374 uint32_t* transport_frame_id_out) { | 374 uint32_t* transport_frame_id_out, |
375 int64_t expected_retransmission_time_ms) { | |
375 uint32_t ssrc; | 376 uint32_t ssrc; |
376 uint16_t sequence_number; | 377 uint16_t sequence_number; |
377 uint32_t rtp_timestamp; | 378 uint32_t rtp_timestamp; |
378 { | 379 { |
379 // Drop this packet if we're not sending media packets. | 380 // Drop this packet if we're not sending media packets. |
380 rtc::CritScope lock(&send_critsect_); | 381 rtc::CritScope lock(&send_critsect_); |
381 RTC_DCHECK(ssrc_); | 382 RTC_DCHECK(ssrc_); |
382 | 383 |
383 ssrc = *ssrc_; | 384 ssrc = *ssrc_; |
384 sequence_number = sequence_number_; | 385 sequence_number = sequence_number_; |
385 rtp_timestamp = timestamp_offset_ + capture_timestamp; | 386 rtp_timestamp = timestamp_offset_ + capture_timestamp; |
386 if (transport_frame_id_out) | 387 if (transport_frame_id_out) |
387 *transport_frame_id_out = rtp_timestamp; | 388 *transport_frame_id_out = rtp_timestamp; |
388 if (!sending_media_) | 389 if (!sending_media_) |
389 return true; | 390 return true; |
390 } | 391 } |
391 RtpVideoCodecTypes video_type = kRtpVideoGeneric; | 392 RtpVideoCodecTypes video_type = kRtpVideoGeneric; |
392 if (CheckPayloadType(payload_type, &video_type) != 0) { | 393 if (CheckPayloadType(payload_type, &video_type) != 0) { |
393 LOG(LS_ERROR) << "Don't send data with unknown payload type: " | 394 LOG(LS_ERROR) << "Don't send data with unknown payload type: " |
394 << static_cast<int>(payload_type) << "."; | 395 << static_cast<int>(payload_type) << "."; |
395 return false; | 396 return false; |
396 } | 397 } |
397 | 398 |
399 switch (frame_type) { | |
400 case kAudioFrameSpeech: | |
401 case kAudioFrameCN: | |
402 RTC_CHECK(audio_configured_); | |
403 break; | |
404 case kVideoFrameKey: | |
405 case kVideoFrameDelta: | |
406 RTC_CHECK(!audio_configured_); | |
407 break; | |
408 case kEmptyFrame: | |
409 break; | |
410 default: | |
danilchap
2017/08/29 17:31:19
it is recommended not to have default to get compi
sprang_webrtc
2017/08/31 15:54:28
Done.
| |
411 FATAL() << "Unrecognized frame type."; | |
412 } | |
413 | |
398 bool result; | 414 bool result; |
399 if (audio_configured_) { | 415 if (audio_configured_) { |
400 TRACE_EVENT_ASYNC_STEP1("webrtc", "Audio", rtp_timestamp, "Send", "type", | 416 TRACE_EVENT_ASYNC_STEP1("webrtc", "Audio", rtp_timestamp, "Send", "type", |
401 FrameTypeToString(frame_type)); | 417 FrameTypeToString(frame_type)); |
402 assert(frame_type == kAudioFrameSpeech || frame_type == kAudioFrameCN || | |
403 frame_type == kEmptyFrame); | |
404 | 418 |
405 result = audio_->SendAudio(frame_type, payload_type, rtp_timestamp, | 419 result = audio_->SendAudio(frame_type, payload_type, rtp_timestamp, |
406 payload_data, payload_size, fragmentation); | 420 payload_data, payload_size, fragmentation); |
407 } else { | 421 } else { |
408 TRACE_EVENT_ASYNC_STEP1("webrtc", "Video", capture_time_ms, | 422 TRACE_EVENT_ASYNC_STEP1("webrtc", "Video", capture_time_ms, |
409 "Send", "type", FrameTypeToString(frame_type)); | 423 "Send", "type", FrameTypeToString(frame_type)); |
410 assert(frame_type != kAudioFrameSpeech && frame_type != kAudioFrameCN); | |
411 | |
412 if (frame_type == kEmptyFrame) | 424 if (frame_type == kEmptyFrame) |
413 return true; | 425 return true; |
414 | 426 |
415 if (rtp_header) { | 427 if (rtp_header) { |
416 playout_delay_oracle_.UpdateRequest(ssrc, rtp_header->playout_delay, | 428 playout_delay_oracle_.UpdateRequest(ssrc, rtp_header->playout_delay, |
417 sequence_number); | 429 sequence_number); |
418 } | 430 } |
419 | 431 |
420 result = video_->SendVideo(video_type, frame_type, payload_type, | 432 result = video_->SendVideo(video_type, frame_type, payload_type, |
421 rtp_timestamp, capture_time_ms, payload_data, | 433 rtp_timestamp, capture_time_ms, payload_data, |
422 payload_size, fragmentation, rtp_header); | 434 payload_size, fragmentation, rtp_header, |
435 expected_retransmission_time_ms); | |
423 } | 436 } |
424 | 437 |
425 rtc::CritScope cs(&statistics_crit_); | 438 rtc::CritScope cs(&statistics_crit_); |
426 // Note: This is currently only counting for video. | 439 // Note: This is currently only counting for video. |
427 if (frame_type == kVideoFrameKey) { | 440 if (frame_type == kVideoFrameKey) { |
428 ++frame_counts_.key_frames; | 441 ++frame_counts_.key_frames; |
429 } else if (frame_type == kVideoFrameDelta) { | 442 } else if (frame_type == kVideoFrameDelta) { |
430 ++frame_counts_.delta_frames; | 443 ++frame_counts_.delta_frames; |
431 } | 444 } |
432 if (frame_count_observer_) { | 445 if (frame_count_observer_) { |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1098 } | 1111 } |
1099 | 1112 |
1100 rtc::Optional<uint32_t> RTPSender::FlexfecSsrc() const { | 1113 rtc::Optional<uint32_t> RTPSender::FlexfecSsrc() const { |
1101 if (video_) { | 1114 if (video_) { |
1102 return video_->FlexfecSsrc(); | 1115 return video_->FlexfecSsrc(); |
1103 } | 1116 } |
1104 return rtc::Optional<uint32_t>(); | 1117 return rtc::Optional<uint32_t>(); |
1105 } | 1118 } |
1106 | 1119 |
1107 void RTPSender::SetCsrcs(const std::vector<uint32_t>& csrcs) { | 1120 void RTPSender::SetCsrcs(const std::vector<uint32_t>& csrcs) { |
1108 assert(csrcs.size() <= kRtpCsrcSize); | 1121 RTC_DCHECK_LE(csrcs.size(), kRtpCsrcSize); |
1109 rtc::CritScope lock(&send_critsect_); | 1122 rtc::CritScope lock(&send_critsect_); |
1110 csrcs_ = csrcs; | 1123 csrcs_ = csrcs; |
1111 } | 1124 } |
1112 | 1125 |
1113 void RTPSender::SetSequenceNumber(uint16_t seq) { | 1126 void RTPSender::SetSequenceNumber(uint16_t seq) { |
1114 rtc::CritScope lock(&send_critsect_); | 1127 rtc::CritScope lock(&send_critsect_); |
1115 sequence_number_forced_ = true; | 1128 sequence_number_forced_ = true; |
1116 sequence_number_ = seq; | 1129 sequence_number_ = seq; |
1117 } | 1130 } |
1118 | 1131 |
(...skipping 10 matching lines...) Expand all Loading... | |
1129 return -1; | 1142 return -1; |
1130 } | 1143 } |
1131 return audio_->SendTelephoneEvent(key, time_ms, level); | 1144 return audio_->SendTelephoneEvent(key, time_ms, level); |
1132 } | 1145 } |
1133 | 1146 |
1134 int32_t RTPSender::SetAudioLevel(uint8_t level_d_bov) { | 1147 int32_t RTPSender::SetAudioLevel(uint8_t level_d_bov) { |
1135 return audio_->SetAudioLevel(level_d_bov); | 1148 return audio_->SetAudioLevel(level_d_bov); |
1136 } | 1149 } |
1137 | 1150 |
1138 RtpVideoCodecTypes RTPSender::VideoCodecType() const { | 1151 RtpVideoCodecTypes RTPSender::VideoCodecType() const { |
1139 assert(!audio_configured_ && "Sender is an audio stream!"); | 1152 RTC_DCHECK(!audio_configured_) << "Sender is an audio stream!"; |
1140 return video_->VideoCodecType(); | 1153 return video_->VideoCodecType(); |
1141 } | 1154 } |
1142 | 1155 |
1143 void RTPSender::SetUlpfecConfig(int red_payload_type, int ulpfec_payload_type) { | 1156 void RTPSender::SetUlpfecConfig(int red_payload_type, int ulpfec_payload_type) { |
1144 RTC_DCHECK(!audio_configured_); | 1157 RTC_DCHECK(!audio_configured_); |
1145 video_->SetUlpfecConfig(red_payload_type, ulpfec_payload_type); | 1158 video_->SetUlpfecConfig(red_payload_type, ulpfec_payload_type); |
1146 } | 1159 } |
1147 | 1160 |
1148 bool RTPSender::SetFecParameters(const FecProtectionParams& delta_params, | 1161 bool RTPSender::SetFecParameters(const FecProtectionParams& delta_params, |
1149 const FecProtectionParams& key_params) { | 1162 const FecProtectionParams& key_params) { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1295 rtc::CritScope lock(&send_critsect_); | 1308 rtc::CritScope lock(&send_critsect_); |
1296 packet->SetTimestamp(last_rtp_timestamp_); | 1309 packet->SetTimestamp(last_rtp_timestamp_); |
1297 packet->set_capture_time_ms(capture_time_ms_); | 1310 packet->set_capture_time_ms(capture_time_ms_); |
1298 } | 1311 } |
1299 AssignSequenceNumber(packet.get()); | 1312 AssignSequenceNumber(packet.get()); |
1300 SendToNetwork(std::move(packet), StorageType::kDontRetransmit, | 1313 SendToNetwork(std::move(packet), StorageType::kDontRetransmit, |
1301 RtpPacketSender::Priority::kLowPriority); | 1314 RtpPacketSender::Priority::kLowPriority); |
1302 } | 1315 } |
1303 | 1316 |
1304 } // namespace webrtc | 1317 } // namespace webrtc |
OLD | NEW |