2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_AUDIO_H_
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_AUDIO_H_
14 #include "webrtc/common_types.h"
15 #include "webrtc/modules/rtp_rtcp/source/dtmf_queue.h"
16 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h"
17 #include "webrtc/modules/rtp_rtcp/source/rtp_sender.h"
18 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
19 #include "webrtc/typedefs.h"
22 class RTPSenderAudio: public DTMFqueue
25 RTPSenderAudio(const int32_t id, Clock* clock,
26 RTPSender* rtpSender);
27 virtual ~RTPSenderAudio();
29 int32_t RegisterAudioPayload(const char payloadName[RTP_PAYLOAD_NAME_SIZE],
30 const int8_t payloadType,
31 const uint32_t frequency,
32 const uint8_t channels,
34 RtpUtility::Payload*& payload);
36 int32_t SendAudio(const FrameType frameType,
37 const int8_t payloadType,
38 const uint32_t captureTimeStamp,
39 const uint8_t* payloadData,
40 const uint32_t payloadSize,
41 const RTPFragmentationHeader* fragmentation);
43 // set audio packet size, used to determine when it's time to send a DTMF packet in silence (CNG)
44 int32_t SetAudioPacketSize(const uint16_t packetSizeSamples);
46 // Store the audio level in dBov for header-extension-for-audio-level-indication.
47 // Valid range is [0,100]. Actual value is negative.
48 int32_t SetAudioLevel(const uint8_t level_dBov);
50 // Send a DTMF tone using RFC 2833 (4733)
51 int32_t SendTelephoneEvent(const uint8_t key,
52 const uint16_t time_ms,
55 bool SendTelephoneEventActive(int8_t& telephoneEvent) const;
57 void SetAudioFrequency(const uint32_t f);
59 int AudioFrequency() const;
61 // Set payload type for Redundant Audio Data RFC 2198
62 int32_t SetRED(const int8_t payloadType);
64 // Get payload type for Redundant Audio Data RFC 2198
65 int32_t RED(int8_t& payloadType) const;
67 int32_t RegisterAudioCallback(RtpAudioFeedback* messagesCallback);
70 int32_t SendTelephoneEventPacket(const bool ended,
71 const uint32_t dtmfTimeStamp,
72 const uint16_t duration,
73 const bool markerBit); // set on first packet in talk burst
75 bool MarkerBit(const FrameType frameType,
76 const int8_t payloadType);
81 RTPSender* _rtpSender;
82 CriticalSectionWrapper* _audioFeedbackCritsect;
83 RtpAudioFeedback* _audioFeedback;
85 CriticalSectionWrapper* _sendAudioCritsect;
88 uint16_t _packetSizeSamples;
92 bool _dtmfEventFirstPacketSent;
93 int8_t _dtmfPayloadType;
94 uint32_t _dtmfTimestamp;
96 uint32_t _dtmfLengthSamples;
98 int64_t _dtmfTimeLastSent;
99 uint32_t _dtmfTimestampLastSent;
101 int8_t _REDPayloadType;
103 // VAD detection, used for markerbit
104 bool _inbandVADactive;
105 int8_t _cngNBPayloadType;
106 int8_t _cngWBPayloadType;
107 int8_t _cngSWBPayloadType;
108 int8_t _cngFBPayloadType;
109 int8_t _lastPayloadType;
111 // Audio level indication (https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/)
112 uint8_t _audioLevel_dBov;
114 } // namespace webrtc
116 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_AUDIO_H_