| 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/logging.h" |
| 16 #include "webrtc/base/timeutils.h" |
| 16 #include "webrtc/base/trace_event.h" | 17 #include "webrtc/base/trace_event.h" |
| 17 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 18 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 18 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 19 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
| 19 #include "webrtc/system_wrappers/include/tick_util.h" | |
| 20 | 20 |
| 21 namespace webrtc { | 21 namespace webrtc { |
| 22 | 22 |
| 23 static const int kDtmfFrequencyHz = 8000; | 23 static const int kDtmfFrequencyHz = 8000; |
| 24 | 24 |
| 25 RTPSenderAudio::RTPSenderAudio(Clock* clock, RTPSender* rtpSender) | 25 RTPSenderAudio::RTPSenderAudio(Clock* clock, RTPSender* rtpSender) |
| 26 : _clock(clock), | 26 : _clock(clock), |
| 27 _rtpSender(rtpSender), | 27 _rtpSender(rtpSender), |
| 28 _packetSizeSamples(160), | 28 _packetSizeSamples(160), |
| 29 _dtmfEventIsOn(false), | 29 _dtmfEventIsOn(false), |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 RTPHeader rtp_header; | 344 RTPHeader rtp_header; |
| 345 rtp_parser.Parse(&rtp_header); | 345 rtp_parser.Parse(&rtp_header); |
| 346 _rtpSender->UpdateAudioLevel(dataBuffer, packetSize, rtp_header, | 346 _rtpSender->UpdateAudioLevel(dataBuffer, packetSize, rtp_header, |
| 347 (frameType == kAudioFrameSpeech), | 347 (frameType == kAudioFrameSpeech), |
| 348 audio_level_dbov); | 348 audio_level_dbov); |
| 349 TRACE_EVENT_ASYNC_END2("webrtc", "Audio", captureTimeStamp, "timestamp", | 349 TRACE_EVENT_ASYNC_END2("webrtc", "Audio", captureTimeStamp, "timestamp", |
| 350 _rtpSender->Timestamp(), "seqnum", | 350 _rtpSender->Timestamp(), "seqnum", |
| 351 _rtpSender->SequenceNumber()); | 351 _rtpSender->SequenceNumber()); |
| 352 int32_t send_result = _rtpSender->SendToNetwork( | 352 int32_t send_result = _rtpSender->SendToNetwork( |
| 353 dataBuffer, payloadSize, rtpHeaderLength, | 353 dataBuffer, payloadSize, rtpHeaderLength, |
| 354 TickTime::MillisecondTimestamp(), kAllowRetransmission, | 354 rtc::TimeMillis(), kAllowRetransmission, |
| 355 RtpPacketSender::kHighPriority); | 355 RtpPacketSender::kHighPriority); |
| 356 if (first_packet_sent_()) { | 356 if (first_packet_sent_()) { |
| 357 LOG(LS_INFO) << "First audio RTP packet sent to pacer"; | 357 LOG(LS_INFO) << "First audio RTP packet sent to pacer"; |
| 358 } | 358 } |
| 359 return send_result; | 359 return send_result; |
| 360 } | 360 } |
| 361 | 361 |
| 362 // Audio level magnitude and voice activity flag are set for each RTP packet | 362 // Audio level magnitude and voice activity flag are set for each RTP packet |
| 363 int32_t RTPSenderAudio::SetAudioLevel(uint8_t level_dBov) { | 363 int32_t RTPSenderAudio::SetAudioLevel(uint8_t level_dBov) { |
| 364 if (level_dBov > 127) { | 364 if (level_dBov > 127) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 | 443 |
| 444 // First byte is Event number, equals key number | 444 // First byte is Event number, equals key number |
| 445 dtmfbuffer[12] = _dtmfKey; | 445 dtmfbuffer[12] = _dtmfKey; |
| 446 dtmfbuffer[13] = E | R | volume; | 446 dtmfbuffer[13] = E | R | volume; |
| 447 ByteWriter<uint16_t>::WriteBigEndian(dtmfbuffer + 14, duration); | 447 ByteWriter<uint16_t>::WriteBigEndian(dtmfbuffer + 14, duration); |
| 448 | 448 |
| 449 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), | 449 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), |
| 450 "Audio::SendTelephoneEvent", "timestamp", | 450 "Audio::SendTelephoneEvent", "timestamp", |
| 451 dtmfTimeStamp, "seqnum", _rtpSender->SequenceNumber()); | 451 dtmfTimeStamp, "seqnum", _rtpSender->SequenceNumber()); |
| 452 retVal = _rtpSender->SendToNetwork( | 452 retVal = _rtpSender->SendToNetwork( |
| 453 dtmfbuffer, 4, 12, TickTime::MillisecondTimestamp(), | 453 dtmfbuffer, 4, 12, rtc::TimeMillis(), |
| 454 kAllowRetransmission, RtpPacketSender::kHighPriority); | 454 kAllowRetransmission, RtpPacketSender::kHighPriority); |
| 455 sendCount--; | 455 sendCount--; |
| 456 } while (sendCount > 0 && retVal == 0); | 456 } while (sendCount > 0 && retVal == 0); |
| 457 | 457 |
| 458 return retVal; | 458 return retVal; |
| 459 } | 459 } |
| 460 } // namespace webrtc | 460 } // namespace webrtc |
| OLD | NEW |