| 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/modules/rtp_rtcp/source/rtp_sender_audio.h" | 11 #include "webrtc/modules/rtp_rtcp/source/rtp_sender_audio.h" |
| 12 | 12 |
| 13 #include <string.h> | 13 #include <string.h> |
| 14 | 14 |
| 15 #include "webrtc/base/logging.h" |
| 15 #include "webrtc/base/trace_event.h" | 16 #include "webrtc/base/trace_event.h" |
| 16 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 17 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 17 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 18 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
| 18 #include "webrtc/system_wrappers/include/tick_util.h" | 19 #include "webrtc/system_wrappers/include/tick_util.h" |
| 19 | 20 |
| 20 namespace webrtc { | 21 namespace webrtc { |
| 21 | 22 |
| 22 static const int kDtmfFrequencyHz = 8000; | 23 static const int kDtmfFrequencyHz = 8000; |
| 23 | 24 |
| 24 RTPSenderAudio::RTPSenderAudio(Clock* clock, RTPSender* rtpSender) | 25 RTPSenderAudio::RTPSenderAudio(Clock* clock, RTPSender* rtpSender) |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 dataBuffer[rtpHeaderLength++] = fragmentation->fragmentationPlType[0]; | 327 dataBuffer[rtpHeaderLength++] = fragmentation->fragmentationPlType[0]; |
| 327 memcpy(dataBuffer + rtpHeaderLength, | 328 memcpy(dataBuffer + rtpHeaderLength, |
| 328 payloadData + fragmentation->fragmentationOffset[0], | 329 payloadData + fragmentation->fragmentationOffset[0], |
| 329 fragmentation->fragmentationLength[0]); | 330 fragmentation->fragmentationLength[0]); |
| 330 | 331 |
| 331 payloadSize = fragmentation->fragmentationLength[0]; | 332 payloadSize = fragmentation->fragmentationLength[0]; |
| 332 } else { | 333 } else { |
| 333 memcpy(dataBuffer + rtpHeaderLength, payloadData, payloadSize); | 334 memcpy(dataBuffer + rtpHeaderLength, payloadData, payloadSize); |
| 334 } | 335 } |
| 335 } | 336 } |
| 337 |
| 336 { | 338 { |
| 337 CriticalSectionScoped cs(_sendAudioCritsect.get()); | 339 CriticalSectionScoped cs(_sendAudioCritsect.get()); |
| 338 _lastPayloadType = payloadType; | 340 _lastPayloadType = payloadType; |
| 339 } | 341 } |
| 340 // Update audio level extension, if included. | 342 // Update audio level extension, if included. |
| 341 size_t packetSize = payloadSize + rtpHeaderLength; | 343 size_t packetSize = payloadSize + rtpHeaderLength; |
| 342 RtpUtility::RtpHeaderParser rtp_parser(dataBuffer, packetSize); | 344 RtpUtility::RtpHeaderParser rtp_parser(dataBuffer, packetSize); |
| 343 RTPHeader rtp_header; | 345 RTPHeader rtp_header; |
| 344 rtp_parser.Parse(&rtp_header); | 346 rtp_parser.Parse(&rtp_header); |
| 345 _rtpSender->UpdateAudioLevel(dataBuffer, packetSize, rtp_header, | 347 _rtpSender->UpdateAudioLevel(dataBuffer, packetSize, rtp_header, |
| 346 (frameType == kAudioFrameSpeech), | 348 (frameType == kAudioFrameSpeech), |
| 347 audio_level_dbov); | 349 audio_level_dbov); |
| 348 TRACE_EVENT_ASYNC_END2("webrtc", "Audio", captureTimeStamp, "timestamp", | 350 TRACE_EVENT_ASYNC_END2("webrtc", "Audio", captureTimeStamp, "timestamp", |
| 349 _rtpSender->Timestamp(), "seqnum", | 351 _rtpSender->Timestamp(), "seqnum", |
| 350 _rtpSender->SequenceNumber()); | 352 _rtpSender->SequenceNumber()); |
| 351 return _rtpSender->SendToNetwork(dataBuffer, payloadSize, rtpHeaderLength, | 353 int32_t send_result = _rtpSender->SendToNetwork( |
| 352 TickTime::MillisecondTimestamp(), | 354 dataBuffer, payloadSize, rtpHeaderLength, |
| 353 kAllowRetransmission, | 355 TickTime::MillisecondTimestamp(), kAllowRetransmission, |
| 354 RtpPacketSender::kHighPriority); | 356 RtpPacketSender::kHighPriority); |
| 357 if (first_packet_sent_()) { |
| 358 LOG(LS_INFO) << "First audio RTP packet sent to pacer"; |
| 359 } |
| 360 return send_result; |
| 355 } | 361 } |
| 356 | 362 |
| 357 // Audio level magnitude and voice activity flag are set for each RTP packet | 363 // Audio level magnitude and voice activity flag are set for each RTP packet |
| 358 int32_t RTPSenderAudio::SetAudioLevel(uint8_t level_dBov) { | 364 int32_t RTPSenderAudio::SetAudioLevel(uint8_t level_dBov) { |
| 359 if (level_dBov > 127) { | 365 if (level_dBov > 127) { |
| 360 return -1; | 366 return -1; |
| 361 } | 367 } |
| 362 CriticalSectionScoped cs(_sendAudioCritsect.get()); | 368 CriticalSectionScoped cs(_sendAudioCritsect.get()); |
| 363 _audioLevel_dBov = level_dBov; | 369 _audioLevel_dBov = level_dBov; |
| 364 return 0; | 370 return 0; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 dtmfTimeStamp, "seqnum", _rtpSender->SequenceNumber()); | 452 dtmfTimeStamp, "seqnum", _rtpSender->SequenceNumber()); |
| 447 retVal = _rtpSender->SendToNetwork( | 453 retVal = _rtpSender->SendToNetwork( |
| 448 dtmfbuffer, 4, 12, TickTime::MillisecondTimestamp(), | 454 dtmfbuffer, 4, 12, TickTime::MillisecondTimestamp(), |
| 449 kAllowRetransmission, RtpPacketSender::kHighPriority); | 455 kAllowRetransmission, RtpPacketSender::kHighPriority); |
| 450 sendCount--; | 456 sendCount--; |
| 451 } while (sendCount > 0 && retVal == 0); | 457 } while (sendCount > 0 && retVal == 0); |
| 452 | 458 |
| 453 return retVal; | 459 return retVal; |
| 454 } | 460 } |
| 455 } // namespace webrtc | 461 } // namespace webrtc |
| OLD | NEW |