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 <assert.h> //assert | 13 #include <assert.h> //assert |
14 #include <string.h> //memcpy | 14 #include <string.h> //memcpy |
15 | 15 |
16 #include "webrtc/base/trace_event.h" | 16 #include "webrtc/base/trace_event.h" |
17 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 17 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
18 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 18 #include "webrtc/modules/rtp_rtcp/source/byte_io.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, | 25 RTPSenderAudio::RTPSenderAudio(Clock* clock, |
25 RTPSender* rtpSender, | 26 RTPSender* rtpSender, |
26 RtpAudioFeedback* audio_feedback) | 27 RtpAudioFeedback* audio_feedback) |
27 : _clock(clock), | 28 : _clock(clock), |
28 _rtpSender(rtpSender), | 29 _rtpSender(rtpSender), |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 RtpUtility::RtpHeaderParser rtp_parser(dataBuffer, packetSize); | 362 RtpUtility::RtpHeaderParser rtp_parser(dataBuffer, packetSize); |
362 RTPHeader rtp_header; | 363 RTPHeader rtp_header; |
363 rtp_parser.Parse(rtp_header); | 364 rtp_parser.Parse(rtp_header); |
364 _rtpSender->UpdateAudioLevel(dataBuffer, packetSize, rtp_header, | 365 _rtpSender->UpdateAudioLevel(dataBuffer, packetSize, rtp_header, |
365 (frameType == kAudioFrameSpeech), | 366 (frameType == kAudioFrameSpeech), |
366 audio_level_dbov); | 367 audio_level_dbov); |
367 TRACE_EVENT_ASYNC_END2("webrtc", "Audio", captureTimeStamp, "timestamp", | 368 TRACE_EVENT_ASYNC_END2("webrtc", "Audio", captureTimeStamp, "timestamp", |
368 _rtpSender->Timestamp(), "seqnum", | 369 _rtpSender->Timestamp(), "seqnum", |
369 _rtpSender->SequenceNumber()); | 370 _rtpSender->SequenceNumber()); |
370 return _rtpSender->SendToNetwork(dataBuffer, payloadSize, rtpHeaderLength, | 371 return _rtpSender->SendToNetwork(dataBuffer, payloadSize, rtpHeaderLength, |
371 -1, kAllowRetransmission, | 372 TickTime::MillisecondTimestamp(), |
| 373 kAllowRetransmission, |
372 RtpPacketSender::kHighPriority); | 374 RtpPacketSender::kHighPriority); |
373 } | 375 } |
374 | 376 |
375 // Audio level magnitude and voice activity flag are set for each RTP packet | 377 // Audio level magnitude and voice activity flag are set for each RTP packet |
376 int32_t | 378 int32_t |
377 RTPSenderAudio::SetAudioLevel(const uint8_t level_dBov) | 379 RTPSenderAudio::SetAudioLevel(const uint8_t level_dBov) |
378 { | 380 { |
379 if (level_dBov > 127) | 381 if (level_dBov > 127) |
380 { | 382 { |
381 return -1; | 383 return -1; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 | 471 |
470 // First byte is Event number, equals key number | 472 // First byte is Event number, equals key number |
471 dtmfbuffer[12] = _dtmfKey; | 473 dtmfbuffer[12] = _dtmfKey; |
472 dtmfbuffer[13] = E|R|volume; | 474 dtmfbuffer[13] = E|R|volume; |
473 ByteWriter<uint16_t>::WriteBigEndian(dtmfbuffer + 14, duration); | 475 ByteWriter<uint16_t>::WriteBigEndian(dtmfbuffer + 14, duration); |
474 | 476 |
475 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), | 477 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), |
476 "Audio::SendTelephoneEvent", "timestamp", | 478 "Audio::SendTelephoneEvent", "timestamp", |
477 dtmfTimeStamp, "seqnum", | 479 dtmfTimeStamp, "seqnum", |
478 _rtpSender->SequenceNumber()); | 480 _rtpSender->SequenceNumber()); |
479 retVal = _rtpSender->SendToNetwork(dtmfbuffer, 4, 12, -1, | 481 retVal = _rtpSender->SendToNetwork( |
480 kAllowRetransmission, | 482 dtmfbuffer, 4, 12, TickTime::MillisecondTimestamp(), |
481 RtpPacketSender::kHighPriority); | 483 kAllowRetransmission, RtpPacketSender::kHighPriority); |
482 sendCount--; | 484 sendCount--; |
483 | 485 |
484 }while (sendCount > 0 && retVal == 0); | 486 }while (sendCount > 0 && retVal == 0); |
485 | 487 |
486 return retVal; | 488 return retVal; |
487 } | 489 } |
488 } // namespace webrtc | 490 } // namespace webrtc |
OLD | NEW |