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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 _packetSizeSamples = packetSizeSamples; | 61 _packetSizeSamples = packetSizeSamples; |
62 return 0; | 62 return 0; |
63 } | 63 } |
64 | 64 |
65 int32_t RTPSenderAudio::RegisterAudioPayload( | 65 int32_t RTPSenderAudio::RegisterAudioPayload( |
66 const char payloadName[RTP_PAYLOAD_NAME_SIZE], | 66 const char payloadName[RTP_PAYLOAD_NAME_SIZE], |
67 const int8_t payloadType, | 67 const int8_t payloadType, |
68 const uint32_t frequency, | 68 const uint32_t frequency, |
69 const uint8_t channels, | 69 const uint8_t channels, |
70 const uint32_t rate, | 70 const uint32_t rate, |
71 RtpUtility::Payload*& payload) { | 71 RtpUtility::Payload** payload) { |
72 if (RtpUtility::StringCompare(payloadName, "cn", 2)) { | 72 if (RtpUtility::StringCompare(payloadName, "cn", 2)) { |
73 CriticalSectionScoped cs(_sendAudioCritsect.get()); | 73 CriticalSectionScoped cs(_sendAudioCritsect.get()); |
74 // we can have multiple CNG payload types | 74 // we can have multiple CNG payload types |
75 switch (frequency) { | 75 switch (frequency) { |
76 case 8000: | 76 case 8000: |
77 _cngNBPayloadType = payloadType; | 77 _cngNBPayloadType = payloadType; |
78 break; | 78 break; |
79 case 16000: | 79 case 16000: |
80 _cngWBPayloadType = payloadType; | 80 _cngWBPayloadType = payloadType; |
81 break; | 81 break; |
82 case 32000: | 82 case 32000: |
83 _cngSWBPayloadType = payloadType; | 83 _cngSWBPayloadType = payloadType; |
84 break; | 84 break; |
85 case 48000: | 85 case 48000: |
86 _cngFBPayloadType = payloadType; | 86 _cngFBPayloadType = payloadType; |
87 break; | 87 break; |
88 default: | 88 default: |
89 return -1; | 89 return -1; |
90 } | 90 } |
91 } else if (RtpUtility::StringCompare(payloadName, "telephone-event", 15)) { | 91 } else if (RtpUtility::StringCompare(payloadName, "telephone-event", 15)) { |
92 CriticalSectionScoped cs(_sendAudioCritsect.get()); | 92 CriticalSectionScoped cs(_sendAudioCritsect.get()); |
93 // Don't add it to the list | 93 // Don't add it to the list |
94 // we dont want to allow send with a DTMF payloadtype | 94 // we dont want to allow send with a DTMF payloadtype |
95 _dtmfPayloadType = payloadType; | 95 _dtmfPayloadType = payloadType; |
96 return 0; | 96 return 0; |
97 // The default timestamp rate is 8000 Hz, but other rates may be defined. | 97 // The default timestamp rate is 8000 Hz, but other rates may be defined. |
98 } | 98 } |
99 payload = new RtpUtility::Payload; | 99 *payload = new RtpUtility::Payload; |
100 payload->typeSpecific.Audio.frequency = frequency; | 100 (*payload)->typeSpecific.Audio.frequency = frequency; |
101 payload->typeSpecific.Audio.channels = channels; | 101 (*payload)->typeSpecific.Audio.channels = channels; |
102 payload->typeSpecific.Audio.rate = rate; | 102 (*payload)->typeSpecific.Audio.rate = rate; |
103 payload->audio = true; | 103 (*payload)->audio = true; |
104 payload->name[RTP_PAYLOAD_NAME_SIZE - 1] = '\0'; | 104 (*payload)->name[RTP_PAYLOAD_NAME_SIZE - 1] = '\0'; |
105 strncpy(payload->name, payloadName, RTP_PAYLOAD_NAME_SIZE - 1); | 105 strncpy((*payload)->name, payloadName, RTP_PAYLOAD_NAME_SIZE - 1); |
106 return 0; | 106 return 0; |
107 } | 107 } |
108 | 108 |
109 bool RTPSenderAudio::MarkerBit(FrameType frameType, int8_t payload_type) { | 109 bool RTPSenderAudio::MarkerBit(FrameType frameType, int8_t payload_type) { |
110 CriticalSectionScoped cs(_sendAudioCritsect.get()); | 110 CriticalSectionScoped cs(_sendAudioCritsect.get()); |
111 // for audio true for first packet in a speech burst | 111 // for audio true for first packet in a speech burst |
112 bool markerBit = false; | 112 bool markerBit = false; |
113 if (_lastPayloadType != payload_type) { | 113 if (_lastPayloadType != payload_type) { |
114 if (payload_type != -1 && (_cngNBPayloadType == payload_type || | 114 if (payload_type != -1 && (_cngNBPayloadType == payload_type || |
115 _cngWBPayloadType == payload_type || | 115 _cngWBPayloadType == payload_type || |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 int32_t RTPSenderAudio::SetRED(int8_t payloadType) { | 377 int32_t RTPSenderAudio::SetRED(int8_t payloadType) { |
378 if (payloadType < -1) { | 378 if (payloadType < -1) { |
379 return -1; | 379 return -1; |
380 } | 380 } |
381 CriticalSectionScoped cs(_sendAudioCritsect.get()); | 381 CriticalSectionScoped cs(_sendAudioCritsect.get()); |
382 _REDPayloadType = payloadType; | 382 _REDPayloadType = payloadType; |
383 return 0; | 383 return 0; |
384 } | 384 } |
385 | 385 |
386 // Get payload type for Redundant Audio Data RFC 2198 | 386 // Get payload type for Redundant Audio Data RFC 2198 |
387 int32_t RTPSenderAudio::RED(int8_t& payloadType) const { | 387 int32_t RTPSenderAudio::RED(int8_t* payloadType) const { |
388 CriticalSectionScoped cs(_sendAudioCritsect.get()); | 388 CriticalSectionScoped cs(_sendAudioCritsect.get()); |
389 if (_REDPayloadType == -1) { | 389 if (_REDPayloadType == -1) { |
390 // not configured | 390 // not configured |
391 return -1; | 391 return -1; |
392 } | 392 } |
393 payloadType = _REDPayloadType; | 393 *payloadType = _REDPayloadType; |
394 return 0; | 394 return 0; |
395 } | 395 } |
396 | 396 |
397 // Send a TelephoneEvent tone using RFC 2833 (4733) | 397 // Send a TelephoneEvent tone using RFC 2833 (4733) |
398 int32_t RTPSenderAudio::SendTelephoneEvent(uint8_t key, | 398 int32_t RTPSenderAudio::SendTelephoneEvent(uint8_t key, |
399 uint16_t time_ms, | 399 uint16_t time_ms, |
400 uint8_t level) { | 400 uint8_t level) { |
401 { | 401 { |
402 CriticalSectionScoped lock(_sendAudioCritsect.get()); | 402 CriticalSectionScoped lock(_sendAudioCritsect.get()); |
403 if (_dtmfPayloadType < 0) { | 403 if (_dtmfPayloadType < 0) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 dtmfTimeStamp, "seqnum", _rtpSender->SequenceNumber()); | 455 dtmfTimeStamp, "seqnum", _rtpSender->SequenceNumber()); |
456 retVal = _rtpSender->SendToNetwork( | 456 retVal = _rtpSender->SendToNetwork( |
457 dtmfbuffer, 4, 12, TickTime::MillisecondTimestamp(), | 457 dtmfbuffer, 4, 12, TickTime::MillisecondTimestamp(), |
458 kAllowRetransmission, RtpPacketSender::kHighPriority); | 458 kAllowRetransmission, RtpPacketSender::kHighPriority); |
459 sendCount--; | 459 sendCount--; |
460 } while (sendCount > 0 && retVal == 0); | 460 } while (sendCount > 0 && retVal == 0); |
461 | 461 |
462 return retVal; | 462 return retVal; |
463 } | 463 } |
464 } // namespace webrtc | 464 } // namespace webrtc |
OLD | NEW |