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 } |
| 411 |
398 bool result; | 412 bool result; |
399 if (audio_configured_) { | 413 if (audio_configured_) { |
400 TRACE_EVENT_ASYNC_STEP1("webrtc", "Audio", rtp_timestamp, "Send", "type", | 414 TRACE_EVENT_ASYNC_STEP1("webrtc", "Audio", rtp_timestamp, "Send", "type", |
401 FrameTypeToString(frame_type)); | 415 FrameTypeToString(frame_type)); |
402 assert(frame_type == kAudioFrameSpeech || frame_type == kAudioFrameCN || | |
403 frame_type == kEmptyFrame); | |
404 | 416 |
405 result = audio_->SendAudio(frame_type, payload_type, rtp_timestamp, | 417 result = audio_->SendAudio(frame_type, payload_type, rtp_timestamp, |
406 payload_data, payload_size, fragmentation); | 418 payload_data, payload_size, fragmentation); |
407 } else { | 419 } else { |
408 TRACE_EVENT_ASYNC_STEP1("webrtc", "Video", capture_time_ms, | 420 TRACE_EVENT_ASYNC_STEP1("webrtc", "Video", capture_time_ms, |
409 "Send", "type", FrameTypeToString(frame_type)); | 421 "Send", "type", FrameTypeToString(frame_type)); |
410 assert(frame_type != kAudioFrameSpeech && frame_type != kAudioFrameCN); | |
411 | |
412 if (frame_type == kEmptyFrame) | 422 if (frame_type == kEmptyFrame) |
413 return true; | 423 return true; |
414 | 424 |
415 if (rtp_header) { | 425 if (rtp_header) { |
416 playout_delay_oracle_.UpdateRequest(ssrc, rtp_header->playout_delay, | 426 playout_delay_oracle_.UpdateRequest(ssrc, rtp_header->playout_delay, |
417 sequence_number); | 427 sequence_number); |
418 } | 428 } |
419 | 429 |
420 result = video_->SendVideo(video_type, frame_type, payload_type, | 430 result = video_->SendVideo(video_type, frame_type, payload_type, |
421 rtp_timestamp, capture_time_ms, payload_data, | 431 rtp_timestamp, capture_time_ms, payload_data, |
422 payload_size, fragmentation, rtp_header); | 432 payload_size, fragmentation, rtp_header, |
| 433 expected_retransmission_time_ms); |
423 } | 434 } |
424 | 435 |
425 rtc::CritScope cs(&statistics_crit_); | 436 rtc::CritScope cs(&statistics_crit_); |
426 // Note: This is currently only counting for video. | 437 // Note: This is currently only counting for video. |
427 if (frame_type == kVideoFrameKey) { | 438 if (frame_type == kVideoFrameKey) { |
428 ++frame_counts_.key_frames; | 439 ++frame_counts_.key_frames; |
429 } else if (frame_type == kVideoFrameDelta) { | 440 } else if (frame_type == kVideoFrameDelta) { |
430 ++frame_counts_.delta_frames; | 441 ++frame_counts_.delta_frames; |
431 } | 442 } |
432 if (frame_count_observer_) { | 443 if (frame_count_observer_) { |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 } | 1109 } |
1099 | 1110 |
1100 rtc::Optional<uint32_t> RTPSender::FlexfecSsrc() const { | 1111 rtc::Optional<uint32_t> RTPSender::FlexfecSsrc() const { |
1101 if (video_) { | 1112 if (video_) { |
1102 return video_->FlexfecSsrc(); | 1113 return video_->FlexfecSsrc(); |
1103 } | 1114 } |
1104 return rtc::Optional<uint32_t>(); | 1115 return rtc::Optional<uint32_t>(); |
1105 } | 1116 } |
1106 | 1117 |
1107 void RTPSender::SetCsrcs(const std::vector<uint32_t>& csrcs) { | 1118 void RTPSender::SetCsrcs(const std::vector<uint32_t>& csrcs) { |
1108 assert(csrcs.size() <= kRtpCsrcSize); | 1119 RTC_DCHECK_LE(csrcs.size(), kRtpCsrcSize); |
1109 rtc::CritScope lock(&send_critsect_); | 1120 rtc::CritScope lock(&send_critsect_); |
1110 csrcs_ = csrcs; | 1121 csrcs_ = csrcs; |
1111 } | 1122 } |
1112 | 1123 |
1113 void RTPSender::SetSequenceNumber(uint16_t seq) { | 1124 void RTPSender::SetSequenceNumber(uint16_t seq) { |
1114 rtc::CritScope lock(&send_critsect_); | 1125 rtc::CritScope lock(&send_critsect_); |
1115 sequence_number_forced_ = true; | 1126 sequence_number_forced_ = true; |
1116 sequence_number_ = seq; | 1127 sequence_number_ = seq; |
1117 } | 1128 } |
1118 | 1129 |
(...skipping 10 matching lines...) Expand all Loading... |
1129 return -1; | 1140 return -1; |
1130 } | 1141 } |
1131 return audio_->SendTelephoneEvent(key, time_ms, level); | 1142 return audio_->SendTelephoneEvent(key, time_ms, level); |
1132 } | 1143 } |
1133 | 1144 |
1134 int32_t RTPSender::SetAudioLevel(uint8_t level_d_bov) { | 1145 int32_t RTPSender::SetAudioLevel(uint8_t level_d_bov) { |
1135 return audio_->SetAudioLevel(level_d_bov); | 1146 return audio_->SetAudioLevel(level_d_bov); |
1136 } | 1147 } |
1137 | 1148 |
1138 RtpVideoCodecTypes RTPSender::VideoCodecType() const { | 1149 RtpVideoCodecTypes RTPSender::VideoCodecType() const { |
1139 assert(!audio_configured_ && "Sender is an audio stream!"); | 1150 RTC_DCHECK(!audio_configured_) << "Sender is an audio stream!"; |
1140 return video_->VideoCodecType(); | 1151 return video_->VideoCodecType(); |
1141 } | 1152 } |
1142 | 1153 |
1143 void RTPSender::SetUlpfecConfig(int red_payload_type, int ulpfec_payload_type) { | 1154 void RTPSender::SetUlpfecConfig(int red_payload_type, int ulpfec_payload_type) { |
1144 RTC_DCHECK(!audio_configured_); | 1155 RTC_DCHECK(!audio_configured_); |
1145 video_->SetUlpfecConfig(red_payload_type, ulpfec_payload_type); | 1156 video_->SetUlpfecConfig(red_payload_type, ulpfec_payload_type); |
1146 } | 1157 } |
1147 | 1158 |
1148 bool RTPSender::SetFecParameters(const FecProtectionParams& delta_params, | 1159 bool RTPSender::SetFecParameters(const FecProtectionParams& delta_params, |
1149 const FecProtectionParams& key_params) { | 1160 const FecProtectionParams& key_params) { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1295 rtc::CritScope lock(&send_critsect_); | 1306 rtc::CritScope lock(&send_critsect_); |
1296 packet->SetTimestamp(last_rtp_timestamp_); | 1307 packet->SetTimestamp(last_rtp_timestamp_); |
1297 packet->set_capture_time_ms(capture_time_ms_); | 1308 packet->set_capture_time_ms(capture_time_ms_); |
1298 } | 1309 } |
1299 AssignSequenceNumber(packet.get()); | 1310 AssignSequenceNumber(packet.get()); |
1300 SendToNetwork(std::move(packet), StorageType::kDontRetransmit, | 1311 SendToNetwork(std::move(packet), StorageType::kDontRetransmit, |
1301 RtpPacketSender::Priority::kLowPriority); | 1312 RtpPacketSender::Priority::kLowPriority); |
1302 } | 1313 } |
1303 | 1314 |
1304 } // namespace webrtc | 1315 } // namespace webrtc |
OLD | NEW |