2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-01-24 17:16:59 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_RTP_RTCP_SOURCE_RTP_SENDER_AUDIO_H_
|
|
|
|
|
#define MODULES_RTP_RTCP_SOURCE_RTP_SENDER_AUDIO_H_
|
|
|
|
|
|
2018-10-23 12:03:01 +02:00
|
|
|
#include <stddef.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
2019-02-06 22:48:11 +01:00
|
|
|
#include <memory>
|
|
|
|
|
|
2018-11-05 13:27:35 +01:00
|
|
|
#include "absl/strings/string_view.h"
|
2020-08-20 16:18:31 +02:00
|
|
|
#include "api/transport/field_trial_based_config.h"
|
2019-03-19 14:10:16 +01:00
|
|
|
#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
|
2020-01-07 16:40:17 +03:00
|
|
|
#include "modules/rtp_rtcp/source/absolute_capture_time_sender.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/rtp_rtcp/source/dtmf_queue.h"
|
|
|
|
|
#include "modules/rtp_rtcp/source/rtp_sender.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "rtc_base/one_time_event.h"
|
2020-07-07 11:44:28 +02:00
|
|
|
#include "rtc_base/synchronization/mutex.h"
|
2018-10-23 12:03:01 +02:00
|
|
|
#include "rtc_base/thread_annotations.h"
|
|
|
|
|
#include "system_wrappers/include/clock.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2016-07-28 15:19:10 -07:00
|
|
|
|
2016-09-23 13:10:46 -07:00
|
|
|
class RTPSenderAudio {
|
2015-12-10 02:39:40 -08:00
|
|
|
public:
|
2016-07-28 15:19:10 -07:00
|
|
|
RTPSenderAudio(Clock* clock, RTPSender* rtp_sender);
|
2020-09-29 09:46:21 +02:00
|
|
|
|
|
|
|
|
RTPSenderAudio() = delete;
|
|
|
|
|
RTPSenderAudio(const RTPSenderAudio&) = delete;
|
|
|
|
|
RTPSenderAudio& operator=(const RTPSenderAudio&) = delete;
|
|
|
|
|
|
2016-09-23 13:10:46 -07:00
|
|
|
~RTPSenderAudio();
|
2015-12-10 02:39:40 -08:00
|
|
|
|
2018-11-05 13:27:35 +01:00
|
|
|
int32_t RegisterAudioPayload(absl::string_view payload_name,
|
2016-07-28 15:19:10 -07:00
|
|
|
int8_t payload_type,
|
2015-12-10 02:39:40 -08:00
|
|
|
uint32_t frequency,
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
size_t channels,
|
2019-01-24 09:44:14 +01:00
|
|
|
uint32_t rate);
|
2015-12-10 02:39:40 -08:00
|
|
|
|
2019-03-07 10:18:23 +01:00
|
|
|
bool SendAudio(AudioFrameType frame_type,
|
2016-08-02 17:46:41 -07:00
|
|
|
int8_t payload_type,
|
2020-01-07 16:40:17 +03:00
|
|
|
uint32_t rtp_timestamp,
|
2016-08-02 17:46:41 -07:00
|
|
|
const uint8_t* payload_data,
|
2017-10-27 10:51:20 +02:00
|
|
|
size_t payload_size);
|
2015-12-10 02:39:40 -08:00
|
|
|
|
2020-01-07 16:40:17 +03:00
|
|
|
bool SendAudio(AudioFrameType frame_type,
|
|
|
|
|
int8_t payload_type,
|
|
|
|
|
uint32_t rtp_timestamp,
|
|
|
|
|
const uint8_t* payload_data,
|
|
|
|
|
size_t payload_size,
|
|
|
|
|
int64_t absolute_capture_timestamp_ms);
|
|
|
|
|
|
2015-12-10 02:39:40 -08:00
|
|
|
// Store the audio level in dBov for
|
|
|
|
|
// header-extension-for-audio-level-indication.
|
|
|
|
|
// Valid range is [0,100]. Actual value is negative.
|
2016-07-28 15:19:10 -07:00
|
|
|
int32_t SetAudioLevel(uint8_t level_dbov);
|
2015-12-10 02:39:40 -08:00
|
|
|
|
|
|
|
|
// Send a DTMF tone using RFC 2833 (4733)
|
|
|
|
|
int32_t SendTelephoneEvent(uint8_t key, uint16_t time_ms, uint8_t level);
|
|
|
|
|
|
|
|
|
|
protected:
|
2016-08-02 17:46:41 -07:00
|
|
|
bool SendTelephoneEventPacket(
|
2015-12-10 02:39:40 -08:00
|
|
|
bool ended,
|
2016-07-28 15:19:10 -07:00
|
|
|
uint32_t dtmf_timestamp,
|
2015-12-10 02:39:40 -08:00
|
|
|
uint16_t duration,
|
2016-07-28 15:19:10 -07:00
|
|
|
bool marker_bit); // set on first packet in talk burst
|
2015-12-10 02:39:40 -08:00
|
|
|
|
2019-03-07 10:18:23 +01:00
|
|
|
bool MarkerBit(AudioFrameType frame_type, int8_t payload_type);
|
2015-12-10 02:39:40 -08:00
|
|
|
|
|
|
|
|
private:
|
2016-11-17 05:25:37 -08:00
|
|
|
Clock* const clock_ = nullptr;
|
|
|
|
|
RTPSender* const rtp_sender_ = nullptr;
|
2016-07-28 15:19:10 -07:00
|
|
|
|
2020-07-07 11:44:28 +02:00
|
|
|
Mutex send_audio_mutex_;
|
2016-07-28 15:19:10 -07:00
|
|
|
|
|
|
|
|
// DTMF.
|
2016-11-17 05:25:37 -08:00
|
|
|
bool dtmf_event_is_on_ = false;
|
|
|
|
|
bool dtmf_event_first_packet_sent_ = false;
|
2020-07-07 11:44:28 +02:00
|
|
|
int8_t dtmf_payload_type_ RTC_GUARDED_BY(send_audio_mutex_) = -1;
|
|
|
|
|
uint32_t dtmf_payload_freq_ RTC_GUARDED_BY(send_audio_mutex_) = 8000;
|
2016-11-17 05:25:37 -08:00
|
|
|
uint32_t dtmf_timestamp_ = 0;
|
|
|
|
|
uint32_t dtmf_length_samples_ = 0;
|
|
|
|
|
int64_t dtmf_time_last_sent_ = 0;
|
|
|
|
|
uint32_t dtmf_timestamp_last_sent_ = 0;
|
|
|
|
|
DtmfQueue::Event dtmf_current_event_;
|
|
|
|
|
DtmfQueue dtmf_queue_;
|
2016-07-28 15:19:10 -07:00
|
|
|
|
|
|
|
|
// VAD detection, used for marker bit.
|
2020-07-07 11:44:28 +02:00
|
|
|
bool inband_vad_active_ RTC_GUARDED_BY(send_audio_mutex_) = false;
|
|
|
|
|
int8_t cngnb_payload_type_ RTC_GUARDED_BY(send_audio_mutex_) = -1;
|
|
|
|
|
int8_t cngwb_payload_type_ RTC_GUARDED_BY(send_audio_mutex_) = -1;
|
|
|
|
|
int8_t cngswb_payload_type_ RTC_GUARDED_BY(send_audio_mutex_) = -1;
|
|
|
|
|
int8_t cngfb_payload_type_ RTC_GUARDED_BY(send_audio_mutex_) = -1;
|
|
|
|
|
int8_t last_payload_type_ RTC_GUARDED_BY(send_audio_mutex_) = -1;
|
2016-07-28 15:19:10 -07:00
|
|
|
|
|
|
|
|
// Audio level indication.
|
2015-12-10 02:39:40 -08:00
|
|
|
// (https://datatracker.ietf.org/doc/draft-lennox-avt-rtp-audio-level-exthdr/)
|
2020-07-07 11:44:28 +02:00
|
|
|
uint8_t audio_level_dbov_ RTC_GUARDED_BY(send_audio_mutex_) = 0;
|
2016-04-07 15:36:45 -07:00
|
|
|
OneTimeEvent first_packet_sent_;
|
2016-09-23 13:10:46 -07:00
|
|
|
|
2020-01-07 16:40:17 +03:00
|
|
|
absl::optional<uint32_t> encoder_rtp_timestamp_frequency_
|
2020-07-07 11:44:28 +02:00
|
|
|
RTC_GUARDED_BY(send_audio_mutex_);
|
2020-01-07 16:40:17 +03:00
|
|
|
|
|
|
|
|
AbsoluteCaptureTimeSender absolute_capture_time_sender_;
|
|
|
|
|
|
2020-08-20 16:18:31 +02:00
|
|
|
const FieldTrialBasedConfig field_trials_;
|
|
|
|
|
const bool include_capture_clock_offset_;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
2016-07-28 15:19:10 -07:00
|
|
|
|
2013-07-03 15:12:26 +00:00
|
|
|
} // namespace webrtc
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_RTP_RTCP_SOURCE_RTP_SENDER_AUDIO_H_
|