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 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_AUDIO_H_ | 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_AUDIO_H_ |
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_AUDIO_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_AUDIO_H_ |
13 | 13 |
14 #include "webrtc/common_types.h" | 14 #include "webrtc/common_types.h" |
15 #include "webrtc/modules/rtp_rtcp/source/dtmf_queue.h" | 15 #include "webrtc/modules/rtp_rtcp/source/dtmf_queue.h" |
16 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" | 16 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h" |
17 #include "webrtc/modules/rtp_rtcp/source/rtp_sender.h" | 17 #include "webrtc/modules/rtp_rtcp/source/rtp_sender.h" |
18 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" | 18 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" |
19 #include "webrtc/typedefs.h" | 19 #include "webrtc/typedefs.h" |
20 | 20 |
21 namespace webrtc { | 21 namespace webrtc { |
22 class RTPSenderAudio: public DTMFqueue | 22 class RTPSenderAudio : public DTMFqueue { |
23 { | 23 public: |
24 public: | 24 RTPSenderAudio(Clock* clock, |
25 RTPSenderAudio(Clock* clock, | 25 RTPSender* rtpSender, |
26 RTPSender* rtpSender, | 26 RtpAudioFeedback* audio_feedback); |
27 RtpAudioFeedback* audio_feedback); | 27 virtual ~RTPSenderAudio(); |
28 virtual ~RTPSenderAudio(); | |
29 | 28 |
30 int32_t RegisterAudioPayload(const char payloadName[RTP_PAYLOAD_NAME_SIZE], | 29 int32_t RegisterAudioPayload(const char payloadName[RTP_PAYLOAD_NAME_SIZE], |
31 const int8_t payloadType, | 30 int8_t payloadType, |
32 const uint32_t frequency, | 31 uint32_t frequency, |
33 const uint8_t channels, | 32 uint8_t channels, |
34 const uint32_t rate, | 33 uint32_t rate, |
35 RtpUtility::Payload*& payload); | 34 RtpUtility::Payload*& payload); |
36 | 35 |
37 int32_t SendAudio(const FrameType frameType, | 36 int32_t SendAudio(FrameType frameType, |
38 const int8_t payloadType, | 37 int8_t payloadType, |
39 const uint32_t captureTimeStamp, | 38 uint32_t captureTimeStamp, |
40 const uint8_t* payloadData, | 39 const uint8_t* payloadData, |
41 const size_t payloadSize, | 40 size_t payloadSize, |
42 const RTPFragmentationHeader* fragmentation); | 41 const RTPFragmentationHeader* fragmentation); |
43 | 42 |
44 // set audio packet size, used to determine when it's time to send a DTMF pa
cket in silence (CNG) | 43 // set audio packet size, used to determine when it's time to send a DTMF |
45 int32_t SetAudioPacketSize(const uint16_t packetSizeSamples); | 44 // packet in silence (CNG) |
| 45 int32_t SetAudioPacketSize(uint16_t packetSizeSamples); |
46 | 46 |
47 // Store the audio level in dBov for header-extension-for-audio-level-indica
tion. | 47 // Store the audio level in dBov for |
48 // Valid range is [0,100]. Actual value is negative. | 48 // header-extension-for-audio-level-indication. |
49 int32_t SetAudioLevel(const uint8_t level_dBov); | 49 // Valid range is [0,100]. Actual value is negative. |
| 50 int32_t SetAudioLevel(uint8_t level_dBov); |
50 | 51 |
51 // Send a DTMF tone using RFC 2833 (4733) | 52 // Send a DTMF tone using RFC 2833 (4733) |
52 int32_t SendTelephoneEvent(const uint8_t key, | 53 int32_t SendTelephoneEvent(uint8_t key, uint16_t time_ms, uint8_t level); |
53 const uint16_t time_ms, | |
54 const uint8_t level); | |
55 | 54 |
56 int AudioFrequency() const; | 55 int AudioFrequency() const; |
57 | 56 |
58 // Set payload type for Redundant Audio Data RFC 2198 | 57 // Set payload type for Redundant Audio Data RFC 2198 |
59 int32_t SetRED(const int8_t payloadType); | 58 int32_t SetRED(int8_t payloadType); |
60 | 59 |
61 // Get payload type for Redundant Audio Data RFC 2198 | 60 // Get payload type for Redundant Audio Data RFC 2198 |
62 int32_t RED(int8_t& payloadType) const; | 61 int32_t RED(int8_t& payloadType) const; |
63 | 62 |
64 protected: | 63 protected: |
65 int32_t SendTelephoneEventPacket(bool ended, | 64 int32_t SendTelephoneEventPacket( |
66 int8_t dtmf_payload_type, | 65 bool ended, |
67 uint32_t dtmfTimeStamp, | 66 int8_t dtmf_payload_type, |
68 uint16_t duration, | 67 uint32_t dtmfTimeStamp, |
69 bool markerBit); // set on first packet in
talk burst | 68 uint16_t duration, |
| 69 bool markerBit); // set on first packet in talk burst |
70 | 70 |
71 bool MarkerBit(const FrameType frameType, | 71 bool MarkerBit(const FrameType frameType, const int8_t payloadType); |
72 const int8_t payloadType); | |
73 | 72 |
74 private: | 73 private: |
75 Clock* const _clock; | 74 Clock* const _clock; |
76 RTPSender* const _rtpSender; | 75 RTPSender* const _rtpSender; |
77 RtpAudioFeedback* const _audioFeedback; | 76 RtpAudioFeedback* const _audioFeedback; |
78 | 77 |
79 rtc::scoped_ptr<CriticalSectionWrapper> _sendAudioCritsect; | 78 rtc::scoped_ptr<CriticalSectionWrapper> _sendAudioCritsect; |
80 | 79 |
81 uint16_t _packetSizeSamples GUARDED_BY(_sendAudioCritsect); | 80 uint16_t _packetSizeSamples GUARDED_BY(_sendAudioCritsect); |
82 | 81 |
83 // DTMF | 82 // DTMF |
84 bool _dtmfEventIsOn; | 83 bool _dtmfEventIsOn; |
85 bool _dtmfEventFirstPacketSent; | 84 bool _dtmfEventFirstPacketSent; |
86 int8_t _dtmfPayloadType GUARDED_BY(_sendAudioCritsect); | 85 int8_t _dtmfPayloadType GUARDED_BY(_sendAudioCritsect); |
87 uint32_t _dtmfTimestamp; | 86 uint32_t _dtmfTimestamp; |
88 uint8_t _dtmfKey; | 87 uint8_t _dtmfKey; |
89 uint32_t _dtmfLengthSamples; | 88 uint32_t _dtmfLengthSamples; |
90 uint8_t _dtmfLevel; | 89 uint8_t _dtmfLevel; |
91 int64_t _dtmfTimeLastSent; | 90 int64_t _dtmfTimeLastSent; |
92 uint32_t _dtmfTimestampLastSent; | 91 uint32_t _dtmfTimestampLastSent; |
93 | 92 |
94 int8_t _REDPayloadType GUARDED_BY(_sendAudioCritsect); | 93 int8_t _REDPayloadType GUARDED_BY(_sendAudioCritsect); |
95 | 94 |
96 // VAD detection, used for markerbit | 95 // VAD detection, used for markerbit |
97 bool _inbandVADactive GUARDED_BY(_sendAudioCritsect); | 96 bool _inbandVADactive GUARDED_BY(_sendAudioCritsect); |
98 int8_t _cngNBPayloadType GUARDED_BY(_sendAudioCritsect); | 97 int8_t _cngNBPayloadType GUARDED_BY(_sendAudioCritsect); |
99 int8_t _cngWBPayloadType GUARDED_BY(_sendAudioCritsect); | 98 int8_t _cngWBPayloadType GUARDED_BY(_sendAudioCritsect); |
100 int8_t _cngSWBPayloadType GUARDED_BY(_sendAudioCritsect); | 99 int8_t _cngSWBPayloadType GUARDED_BY(_sendAudioCritsect); |
101 int8_t _cngFBPayloadType GUARDED_BY(_sendAudioCritsect); | 100 int8_t _cngFBPayloadType GUARDED_BY(_sendAudioCritsect); |
102 int8_t _lastPayloadType GUARDED_BY(_sendAudioCritsect); | 101 int8_t _lastPayloadType GUARDED_BY(_sendAudioCritsect); |
103 | 102 |
104 // Audio level indication | 103 // Audio level indication |
105 // (https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/) | 104 // (https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/) |
106 uint8_t _audioLevel_dBov GUARDED_BY(_sendAudioCritsect); | 105 uint8_t _audioLevel_dBov GUARDED_BY(_sendAudioCritsect); |
107 }; | 106 }; |
108 } // namespace webrtc | 107 } // namespace webrtc |
109 | 108 |
110 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_AUDIO_H_ | 109 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_SENDER_AUDIO_H_ |
OLD | NEW |