mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Temp
This commit is contained in:
parent
a422fac01f
commit
20246f9b2f
@ -14,6 +14,7 @@ swift_library(
|
||||
"//submodules/TelegramUIPreferences:TelegramUIPreferences",
|
||||
"//submodules/TgVoip:TgVoip",
|
||||
"//submodules/TgVoipWebrtcCustom:TgVoipWebrtcCustom",
|
||||
"//submodules/TgVoipWebrtc:TgVoipWebrtc",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
@ -7,16 +7,16 @@ import Postbox
|
||||
import TelegramUIPreferences
|
||||
|
||||
import TgVoip
|
||||
//import TgVoipWebrtc
|
||||
import TgVoipWebrtc
|
||||
import TgVoipWebrtcCustom
|
||||
|
||||
private func callConnectionDescription(_ connection: CallSessionConnection) -> OngoingCallConnectionDescription {
|
||||
return OngoingCallConnectionDescription(connectionId: connection.id, ip: connection.ip, ipv6: connection.ipv6, port: connection.port, peerTag: connection.peerTag)
|
||||
}
|
||||
|
||||
/*private func callConnectionDescriptionWebrtc(_ connection: CallSessionConnection) -> OngoingCallConnectionDescriptionWebrtc {
|
||||
private func callConnectionDescriptionWebrtc(_ connection: CallSessionConnection) -> OngoingCallConnectionDescriptionWebrtc {
|
||||
return OngoingCallConnectionDescriptionWebrtc(connectionId: connection.id, ip: connection.ip, ipv6: connection.ipv6, port: connection.port, peerTag: connection.peerTag)
|
||||
}*/
|
||||
}
|
||||
|
||||
private func callConnectionDescriptionWebrtcCustom(_ connection: CallSessionConnection) -> OngoingCallConnectionDescriptionWebrtcCustom {
|
||||
return OngoingCallConnectionDescriptionWebrtcCustom(connectionId: connection.id, ip: connection.ip, ipv6: connection.ipv6, port: connection.port, peerTag: connection.peerTag)
|
||||
@ -80,11 +80,11 @@ private let setupLogs: Bool = {
|
||||
Logger.shared.log("TGVOIP", value)
|
||||
}
|
||||
})
|
||||
/*OngoingCallThreadLocalContextWebrtc.setupLoggingFunction({ value in
|
||||
OngoingCallThreadLocalContextWebrtc.setupLoggingFunction({ value in
|
||||
if let value = value {
|
||||
Logger.shared.log("TGVOIP", value)
|
||||
}
|
||||
})*/
|
||||
})
|
||||
OngoingCallThreadLocalContextWebrtcCustom.setupLoggingFunction({ value in
|
||||
if let value = value {
|
||||
Logger.shared.log("TGVOIP", value)
|
||||
@ -100,7 +100,7 @@ public enum OngoingCallContextState {
|
||||
case failed
|
||||
}
|
||||
|
||||
private final class OngoingCallThreadLocalContextQueueImpl: NSObject, OngoingCallThreadLocalContextQueue/*, OngoingCallThreadLocalContextQueueWebrtc*/ , OngoingCallThreadLocalContextQueueWebrtcCustom {
|
||||
private final class OngoingCallThreadLocalContextQueueImpl: NSObject, OngoingCallThreadLocalContextQueue, OngoingCallThreadLocalContextQueueWebrtc , OngoingCallThreadLocalContextQueueWebrtcCustom {
|
||||
private let queue: Queue
|
||||
|
||||
init(queue: Queue) {
|
||||
@ -144,7 +144,7 @@ private func ongoingNetworkTypeForType(_ type: NetworkType) -> OngoingCallNetwor
|
||||
}
|
||||
}
|
||||
|
||||
/*private func ongoingNetworkTypeForTypeWebrtc(_ type: NetworkType) -> OngoingCallNetworkTypeWebrtc {
|
||||
private func ongoingNetworkTypeForTypeWebrtc(_ type: NetworkType) -> OngoingCallNetworkTypeWebrtc {
|
||||
switch type {
|
||||
case .none:
|
||||
return .wifi
|
||||
@ -162,7 +162,7 @@ private func ongoingNetworkTypeForType(_ type: NetworkType) -> OngoingCallNetwor
|
||||
return .cellularLte
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private func ongoingNetworkTypeForTypeWebrtcCustom(_ type: NetworkType) -> OngoingCallNetworkTypeWebrtcCustom {
|
||||
switch type {
|
||||
@ -197,7 +197,7 @@ private func ongoingDataSavingForType(_ type: VoiceCallDataSaving) -> OngoingCal
|
||||
}
|
||||
}
|
||||
|
||||
/*private func ongoingDataSavingForTypeWebrtc(_ type: VoiceCallDataSaving) -> OngoingCallDataSavingWebrtc {
|
||||
private func ongoingDataSavingForTypeWebrtc(_ type: VoiceCallDataSaving) -> OngoingCallDataSavingWebrtc {
|
||||
switch type {
|
||||
case .never:
|
||||
return .never
|
||||
@ -208,7 +208,7 @@ private func ongoingDataSavingForType(_ type: VoiceCallDataSaving) -> OngoingCal
|
||||
default:
|
||||
return .never
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private func ongoingDataSavingForTypeWebrtcCustom(_ type: VoiceCallDataSaving) -> OngoingCallDataSavingWebrtcCustom {
|
||||
switch type {
|
||||
@ -266,7 +266,7 @@ extension OngoingCallThreadLocalContext: OngoingCallThreadLocalContextProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
/*extension OngoingCallThreadLocalContextWebrtc: OngoingCallThreadLocalContextProtocol {
|
||||
extension OngoingCallThreadLocalContextWebrtc: OngoingCallThreadLocalContextProtocol {
|
||||
func nativeSetNetworkType(_ type: NetworkType) {
|
||||
self.setNetworkType(ongoingNetworkTypeForTypeWebrtc(type))
|
||||
}
|
||||
@ -290,7 +290,7 @@ extension OngoingCallThreadLocalContext: OngoingCallThreadLocalContextProtocol {
|
||||
func nativeGetDerivedState() -> Data {
|
||||
return self.getDerivedState()
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
extension OngoingCallThreadLocalContextWebrtcCustom: OngoingCallThreadLocalContextProtocol {
|
||||
func nativeSetNetworkType(_ type: NetworkType) {
|
||||
@ -335,7 +335,7 @@ private extension OngoingCallContextState {
|
||||
}
|
||||
}
|
||||
|
||||
/*private extension OngoingCallContextState {
|
||||
private extension OngoingCallContextState {
|
||||
init(_ state: OngoingCallStateWebrtc) {
|
||||
switch state {
|
||||
case .initializing:
|
||||
@ -350,7 +350,7 @@ private extension OngoingCallContextState {
|
||||
self = .failed
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private extension OngoingCallContextState {
|
||||
init(_ state: OngoingCallStateWebrtcCustom) {
|
||||
@ -401,7 +401,8 @@ public final class OngoingCallContext {
|
||||
public static func versions(includeExperimental: Bool) -> [String] {
|
||||
var result: [String] = [OngoingCallThreadLocalContext.version()]
|
||||
if includeExperimental {
|
||||
result.append(OngoingCallThreadLocalContextWebrtcCustom.version())
|
||||
result.append(OngoingCallThreadLocalContextWebrtc.version())
|
||||
//result.append(OngoingCallThreadLocalContextWebrtcCustom.version())
|
||||
}
|
||||
return result
|
||||
}
|
||||
@ -453,7 +454,7 @@ public final class OngoingCallContext {
|
||||
context.nativeSetNetworkType(networkType)
|
||||
}
|
||||
})
|
||||
}/* else if version == OngoingCallThreadLocalContextWebrtc.version() {
|
||||
} else if version == OngoingCallThreadLocalContextWebrtc.version() {
|
||||
var voipProxyServer: VoipProxyServerWebrtc?
|
||||
if let proxyServer = proxyServer {
|
||||
switch proxyServer.connection {
|
||||
@ -479,7 +480,7 @@ public final class OngoingCallContext {
|
||||
context.nativeSetNetworkType(networkType)
|
||||
}
|
||||
})
|
||||
}*/ else {
|
||||
} else {
|
||||
var voipProxyServer: VoipProxyServer?
|
||||
if let proxyServer = proxyServer {
|
||||
switch proxyServer.connection {
|
||||
|
@ -41,6 +41,23 @@ replace_symbols = [
|
||||
"WebRtcAgc_CalculateGainTable",
|
||||
"WebRtcAgc_InitVad",
|
||||
"WebRtcAgc_ProcessVad",
|
||||
"TimeDiff",
|
||||
"TimeAfter",
|
||||
"TimeMicros",
|
||||
"TimeUTCMicros",
|
||||
"SystemTimeNanos",
|
||||
"TimeNanos",
|
||||
"SystemTimeMillis",
|
||||
"TimeMillis",
|
||||
"TimeUTCMillis",
|
||||
"GetClockForTesting",
|
||||
"TimestampWrapAroundHandler",
|
||||
"Time32",
|
||||
"TmToSeconds",
|
||||
"TimeDiff32",
|
||||
"TimestampWrapAroundHandler",
|
||||
"g_clock",
|
||||
"SetClockForTesting",
|
||||
]
|
||||
|
||||
objc_library(
|
||||
|
@ -25,6 +25,7 @@ objc_library(
|
||||
"-DWEBRTC_IOS",
|
||||
"-DWEBRTC_MAC",
|
||||
"-DWEBRTC_POSIX",
|
||||
"-std=c++14",
|
||||
],
|
||||
includes = [
|
||||
"PublicHeaders",
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "Layer92.h"
|
||||
|
||||
#include "modules/rtp_rtcp/source/rtp_utility.h"
|
||||
#include "rtc_base/time_utils.cc"
|
||||
#include "rtc_base/time_utils.h"
|
||||
#include "rtc_base/message_handler.h"
|
||||
|
||||
#include <memory>
|
||||
@ -89,13 +89,7 @@ void Controller::NewMessage(const message::Base& msg) {
|
||||
state = State::Established;
|
||||
SignalNewState(state);
|
||||
thread->PostTask(RTC_FROM_HERE, [this]() {
|
||||
#ifdef TGVOIP_PREPROCESSED_OUTPUT
|
||||
preproc = std::make_unique<MediaEngineWebrtc>(not is_outgoing, false, true);
|
||||
preproc->Play.connect(this, &Controller::Preprocessed);
|
||||
#endif
|
||||
media = std::make_unique<MediaEngineWebrtc>(is_outgoing);
|
||||
media->Record.connect(this, &Controller::Record);
|
||||
media->Play.connect(this, &Controller::Play);
|
||||
media->Send.connect(this, &Controller::SendRtp);
|
||||
});
|
||||
StartRepeating([this]() {
|
||||
@ -144,9 +138,6 @@ void Controller::StopRepeating() {
|
||||
void Controller::SetFail() {
|
||||
thread->PostTask(RTC_FROM_HERE, [this]() {
|
||||
media = nullptr;
|
||||
#ifdef TGVOIP_PREPROCESSED_OUTPUT
|
||||
preproc = nullptr;
|
||||
#endif
|
||||
});
|
||||
if (state != State::Failed) {
|
||||
state = State::Failed;
|
||||
@ -155,29 +146,7 @@ void Controller::SetFail() {
|
||||
StopRepeating();
|
||||
}
|
||||
|
||||
void Controller::Play(const int16_t *data, size_t size) {
|
||||
SignalPlay(data, size);
|
||||
}
|
||||
|
||||
void Controller::Record(int16_t *data, size_t size) {
|
||||
SignalRecord(data, size);
|
||||
last_send_time = rtc::TimeMillis();
|
||||
}
|
||||
|
||||
#ifdef TGVOIP_PREPROCESSED_OUTPUT
|
||||
void Controller::Preprocessed(const int16_t *data, size_t size) {
|
||||
if (rtc::TimeMillis() - last_send_time < 100)
|
||||
SignalPreprocessed(data, size);
|
||||
}
|
||||
#endif
|
||||
|
||||
void Controller::SendRtp(rtc::CopyOnWriteBuffer packet) {
|
||||
#ifdef TGVOIP_PREPROCESSED_OUTPUT
|
||||
thread->PostTask(RTC_FROM_HERE, [this, packet]() {
|
||||
if (preproc)
|
||||
preproc->Receive(packet);
|
||||
});
|
||||
#endif
|
||||
message::RtpStream msg;
|
||||
msg.data = packet;
|
||||
msg.network_type = local_network_type;
|
||||
|
@ -41,20 +41,12 @@ public:
|
||||
static std::map<message::NetworkType, MediaEngineWebrtc::NetworkParams> network_params;
|
||||
static MediaEngineWebrtc::NetworkParams default_network_params;
|
||||
static MediaEngineWebrtc::NetworkParams datasaving_network_params;
|
||||
sigslot::signal2<int16_t *, size_t> SignalRecord;
|
||||
#ifdef TGVOIP_PREPROCESSED_OUTPUT
|
||||
sigslot::signal2<const int16_t *, size_t> SignalPreprocessed;
|
||||
#endif
|
||||
sigslot::signal2<const int16_t *, size_t> SignalPlay;
|
||||
sigslot::signal1<State> SignalNewState;
|
||||
|
||||
private:
|
||||
std::unique_ptr<rtc::Thread> thread;
|
||||
std::unique_ptr<Connector> connector;
|
||||
std::unique_ptr<MediaEngineWebrtc> media;
|
||||
#ifdef TGVOIP_PREPROCESSED_OUTPUT
|
||||
std::unique_ptr<MediaEngineWebrtc> preproc;
|
||||
#endif
|
||||
State state;
|
||||
webrtc::RepeatingTaskHandle repeatable;
|
||||
int64_t last_recv_time;
|
||||
@ -73,9 +65,6 @@ private:
|
||||
void SetFail();
|
||||
void Play(const int16_t *data, size_t size);
|
||||
void Record(int16_t *data, size_t size);
|
||||
#ifdef TGVOIP_PREPROCESSED_OUTPUT
|
||||
void Preprocessed(const int16_t *data, size_t size);
|
||||
#endif
|
||||
void SendRtp(rtc::CopyOnWriteBuffer packet);
|
||||
void UpdateNetworkParams(const message::RtpStream& rtp);
|
||||
};
|
||||
|
@ -14,8 +14,6 @@ public:
|
||||
|
||||
sigslot::signal1<rtc::CopyOnWriteBuffer> Send;
|
||||
virtual void Receive(rtc::CopyOnWriteBuffer) = 0;
|
||||
sigslot::signal2<const int16_t *, size_t> Play;
|
||||
sigslot::signal2<int16_t *, size_t> Record;
|
||||
};
|
||||
|
||||
#endif //DEMO_MEDIAENGINEBASE_H
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "modules/audio_device/include/audio_device_default.h"
|
||||
#include "rtc_base/task_utils/repeating_task.h"
|
||||
#include "system_wrappers/include/field_trial.h"
|
||||
#include "api/video/builtin_video_bitrate_allocator_factory.h"
|
||||
|
||||
#if WEBRTC_ENABLE_PROTOBUF
|
||||
#include "modules/audio_coding/audio_network_adaptor/config.pb.h"
|
||||
@ -28,12 +29,16 @@ const uint8_t sdp_channels = 2;
|
||||
const uint32_t sdp_bitrate = 0;
|
||||
const uint32_t caller_ssrc = 1;
|
||||
const uint32_t called_ssrc = 2;
|
||||
const uint32_t caller_ssrc_video = 1;
|
||||
const uint32_t called_ssrc_video = 2;
|
||||
const int extension_sequence = 1;
|
||||
}
|
||||
|
||||
MediaEngineWebrtc::MediaEngineWebrtc(bool outgoing, bool send, bool recv)
|
||||
: ssrc_send(outgoing ? caller_ssrc : called_ssrc)
|
||||
, ssrc_recv(outgoing ? called_ssrc : caller_ssrc)
|
||||
, ssrc_send_video(outgoing ? caller_ssrc_video : called_ssrc_video)
|
||||
, ssrc_recv_video(outgoing ? called_ssrc_video : caller_ssrc_video)
|
||||
, event_log(std::make_unique<webrtc::RtcEventLogNull>())
|
||||
, task_queue_factory(webrtc::CreateDefaultTaskQueueFactory())
|
||||
, data_sender(*this) {
|
||||
@ -41,17 +46,10 @@ MediaEngineWebrtc::MediaEngineWebrtc(bool outgoing, bool send, bool recv)
|
||||
"WebRTC-Audio-SendSideBwe/Enabled/"
|
||||
"WebRTC-Audio-Allocation/min:6kbps,max:32kbps/"
|
||||
"WebRTC-Audio-OpusMinPacketLossRate/Enabled-1/"
|
||||
// "WebRTC-Audio-OpusPlcUsePrevDecodedSamples/Enabled/"
|
||||
// "WebRTC-Audio-NewOpusPacketLossRateOptimization/Enabled-1-20-1.0/"
|
||||
// "WebRTC-SendSideBwe-WithOverhead/Enabled/"
|
||||
// "WebRTC-Bwe-SeparateAudioPackets/enabled:true,packet_threshold:15,time_threshold:1000ms/"
|
||||
// "WebRTC-Audio-AlrProbing/Disabled/"
|
||||
);
|
||||
video_bitrate_allocator_factory = webrtc::CreateBuiltinVideoBitrateAllocatorFactory();
|
||||
cricket::MediaEngineDependencies media_deps;
|
||||
media_deps.task_queue_factory = task_queue_factory.get();
|
||||
#ifdef TGVOIP_USE_CALLBACK_AUDIO_IO
|
||||
media_deps.adm = new rtc::RefCountedObject<webrtc::webrtc_impl::AudioDeviceModuleDefault<webrtc::AudioDeviceModule>>();
|
||||
#endif
|
||||
media_deps.audio_encoder_factory = webrtc::CreateAudioEncoderFactory<webrtc::AudioEncoderOpus>();
|
||||
media_deps.audio_decoder_factory = webrtc::CreateAudioDecoderFactory<webrtc::AudioDecoderOpus>();
|
||||
media_deps.audio_processing = webrtc::AudioProcessingBuilder().Create();
|
||||
@ -62,12 +60,9 @@ MediaEngineWebrtc::MediaEngineWebrtc(bool outgoing, bool send, bool recv)
|
||||
call_config.trials = &field_trials;
|
||||
call_config.audio_state = media_engine->voice().GetAudioState();
|
||||
call.reset(webrtc::Call::Create(call_config));
|
||||
#ifdef TGVOIP_USE_CALLBACK_AUDIO_IO
|
||||
audio_processor = std::make_unique<AudioProcessor>(call_config.audio_state->audio_transport(),
|
||||
task_queue_factory.get(), *this, send, recv);
|
||||
#endif
|
||||
voice_channel.reset(media_engine->voice().CreateMediaChannel(
|
||||
call.get(), cricket::MediaConfig(), cricket::AudioOptions(), webrtc::CryptoOptions::NoGcm()));
|
||||
video_channel.reset(media_engine->video().CreateMediaChannel(call.get(), cricket::MediaConfig(), cricket::VideoOptions(), webrtc::CryptoOptions::NoGcm(), video_bitrate_allocator_factory.get()));
|
||||
if (send) {
|
||||
voice_channel->AddSendStream(cricket::StreamParams::CreateLegacy(ssrc_send));
|
||||
SetNetworkParams({6, 32, 6, 120, false, false, false});
|
||||
@ -76,6 +71,12 @@ MediaEngineWebrtc::MediaEngineWebrtc(bool outgoing, bool send, bool recv)
|
||||
voice_channel->OnReadyToSend(true);
|
||||
voice_channel->SetSend(true);
|
||||
}
|
||||
if (false && send) {
|
||||
video_channel->AddSendStream(cricket::StreamParams::CreateLegacy(ssrc_send_video));
|
||||
video_channel->SetInterface(&data_sender, webrtc::MediaTransportConfig());
|
||||
video_channel->OnReadyToSend(true);
|
||||
video_channel->SetSend(true);
|
||||
}
|
||||
if (recv) {
|
||||
cricket::AudioRecvParameters recv_parameters;
|
||||
recv_parameters.codecs.emplace_back(sdp_payload, sdp_name, clockrate, sdp_bitrate, sdp_channels);
|
||||
@ -86,6 +87,16 @@ MediaEngineWebrtc::MediaEngineWebrtc(bool outgoing, bool send, bool recv)
|
||||
voice_channel->SetRecvParameters(recv_parameters);
|
||||
voice_channel->SetPlayout(true);
|
||||
}
|
||||
if (false && recv) {
|
||||
cricket::VideoRecvParameters recv_parameters;
|
||||
//recv_parameters.codecs.emplace_back(sdp_payload, sdp_name, clockrate, sdp_bitrate, sdp_channels);
|
||||
recv_parameters.extensions.emplace_back(webrtc::RtpExtension::kTransportSequenceNumberUri, extension_sequence);
|
||||
recv_parameters.rtcp.reduced_size = true;
|
||||
recv_parameters.rtcp.remote_estimate = true;
|
||||
video_channel->AddRecvStream(cricket::StreamParams::CreateLegacy(ssrc_recv_video));
|
||||
video_channel->SetRecvParameters(recv_parameters);
|
||||
//video_channel->SetPlayout(true);
|
||||
}
|
||||
}
|
||||
|
||||
MediaEngineWebrtc::~MediaEngineWebrtc() = default;
|
||||
@ -107,19 +118,8 @@ void MediaEngineWebrtc::SetNetworkParams(const MediaEngineWebrtc::NetworkParams&
|
||||
opus_codec.SetParam(cricket::kCodecParamMaxBitrate, params.max_bitrate_kbps);
|
||||
opus_codec.SetParam(cricket::kCodecParamUseInbandFec, 1);
|
||||
opus_codec.SetParam(cricket::kCodecParamPTime, params.ptime_ms);
|
||||
// opus_codec.SetParam(cricket::kCodecParamUseDtx, "1");
|
||||
// opus_codec.SetParam(cricket::kCodecParamMaxAverageBitrate, 6);
|
||||
std::string config_string;
|
||||
#if WEBRTC_ENABLE_PROTOBUF
|
||||
webrtc::audio_network_adaptor::config::ControllerManager cont_conf;
|
||||
// cont_conf.add_controllers()->mutable_bitrate_controller();
|
||||
config_string = cont_conf.SerializeAsString();
|
||||
#endif
|
||||
|
||||
cricket::AudioSendParameters send_parameters;
|
||||
if (!config_string.empty()) {
|
||||
send_parameters.options.audio_network_adaptor_config = config_string;
|
||||
send_parameters.options.audio_network_adaptor = true;
|
||||
}
|
||||
send_parameters.codecs.push_back(opus_codec);
|
||||
send_parameters.extensions.emplace_back(webrtc::RtpExtension::kTransportSequenceNumberUri, extension_sequence);
|
||||
send_parameters.options.echo_cancellation = params.echo_cancellation;
|
||||
@ -157,48 +157,3 @@ int MediaEngineWebrtc::Sender::SetOption(cricket::MediaChannel::NetworkInterface
|
||||
}
|
||||
|
||||
MediaEngineWebrtc::Sender::Sender(MediaEngineWebrtc& engine) : engine(engine) {}
|
||||
|
||||
MediaEngineWebrtc::AudioProcessor::AudioProcessor(webrtc::AudioTransport *transport_,
|
||||
webrtc::TaskQueueFactory *task_queue_factory, MediaEngineBase& engine_, bool send_, bool recv_)
|
||||
: send(send_)
|
||||
, recv(recv_)
|
||||
, transport(transport_)
|
||||
, delay_us(frame_samples * 1000000 / clockrate)
|
||||
, buf_send(nullptr)
|
||||
, buf_recv(nullptr)
|
||||
, engine(engine_)
|
||||
, task_queue_send(std::make_unique<rtc::TaskQueue>(task_queue_factory->CreateTaskQueue(
|
||||
"AudioProcessorSend", webrtc::TaskQueueFactory::Priority::NORMAL)))
|
||||
, task_queue_recv(std::make_unique<rtc::TaskQueue>(task_queue_factory->CreateTaskQueue(
|
||||
"AudioProcessorRecv", webrtc::TaskQueueFactory::Priority::NORMAL))) {
|
||||
if (send) {
|
||||
buf_send = new int16_t[frame_samples * channels];
|
||||
webrtc::RepeatingTaskHandle::Start(task_queue_send->Get(), [this]() {
|
||||
static uint32_t new_mic_level = 0;
|
||||
memset(buf_send, 0, frame_samples * channels * sample_bytes);
|
||||
engine.Record(buf_send, frame_samples * channels);
|
||||
transport->RecordedDataIsAvailable(buf_send, frame_samples, sample_bytes, channels, clockrate,
|
||||
0, 0, 0, false, new_mic_level);
|
||||
return webrtc::TimeDelta::us(delay_us);
|
||||
});
|
||||
}
|
||||
if (recv) {
|
||||
buf_recv = new int16_t[frame_samples * channels];
|
||||
webrtc::RepeatingTaskHandle::Start(task_queue_recv->Get(), [this]() {
|
||||
static int64_t elapsed_time_ms = -1;
|
||||
static int64_t ntp_time_ms = -1;
|
||||
size_t samples_out = 0;
|
||||
transport->NeedMorePlayData(frame_samples, sample_bytes, channels, clockrate, buf_recv,
|
||||
samples_out, &elapsed_time_ms, &ntp_time_ms);
|
||||
engine.Play(buf_recv, samples_out * channels);
|
||||
return webrtc::TimeDelta::us(delay_us);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
MediaEngineWebrtc::AudioProcessor::~AudioProcessor() {
|
||||
task_queue_send = nullptr;
|
||||
task_queue_recv = nullptr;
|
||||
delete[] buf_send;
|
||||
delete[] buf_recv;
|
||||
}
|
||||
|
@ -61,6 +61,8 @@ private:
|
||||
|
||||
const uint32_t ssrc_send;
|
||||
const uint32_t ssrc_recv;
|
||||
const uint32_t ssrc_send_video;
|
||||
const uint32_t ssrc_recv_video;
|
||||
std::unique_ptr<webrtc::Call> call;
|
||||
std::unique_ptr<cricket::MediaEngineInterface> media_engine;
|
||||
std::unique_ptr<webrtc::RtcEventLogNull> event_log;
|
||||
@ -69,9 +71,8 @@ private:
|
||||
webrtc::LocalAudioSinkAdapter audio_source;
|
||||
Sender data_sender;
|
||||
std::unique_ptr<cricket::VoiceMediaChannel> voice_channel;
|
||||
#ifdef TGVOIP_USE_CALLBACK_AUDIO_IO
|
||||
std::unique_ptr<AudioProcessor> audio_processor;
|
||||
#endif
|
||||
std::unique_ptr<cricket::VideoMediaChannel> video_channel;
|
||||
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory> video_bitrate_allocator_factory;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user