some macos related changes

This commit is contained in:
Mike Renoir
2022-11-01 18:23:30 +04:00
parent 07b225568f
commit 4df7a62a24
5 changed files with 31 additions and 27 deletions
@@ -7,7 +7,7 @@
<key>TgVoipWebrtc.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>41</integer>
<integer>40</integer>
</dict>
</dict>
</dict>
@@ -204,7 +204,7 @@ typedef NS_ENUM(int32_t, OngoingCallDataSavingWebrtc) {
@property (nonatomic, copy) void (^ _Nullable signalBarsChanged)(int32_t);
@property (nonatomic, copy) void (^ _Nullable audioLevelUpdated)(float);
- (instancetype _Nonnull)initWithVersion:(NSString * _Nonnull)version queue:(id<OngoingCallThreadLocalContextQueueWebrtc> _Nonnull)queue proxy:(VoipProxyServerWebrtc * _Nullable)proxy networkType:(OngoingCallNetworkTypeWebrtc)networkType dataSaving:(OngoingCallDataSavingWebrtc)dataSaving derivedState:(NSData * _Nonnull)derivedState key:(NSData * _Nonnull)key isOutgoing:(bool)isOutgoing connections:(NSArray<OngoingCallConnectionDescriptionWebrtc *> * _Nonnull)connections maxLayer:(int32_t)maxLayer allowP2P:(BOOL)allowP2P allowTCP:(BOOL)allowTCP enableStunMarking:(BOOL)enableStunMarking logPath:(NSString * _Nonnull)logPath statsLogPath:(NSString * _Nonnull)statsLogPath sendSignalingData:(void (^ _Nonnull)(NSData * _Nonnull))sendSignalingData videoCapturer:(OngoingCallThreadLocalContextVideoCapturer * _Nullable)videoCapturer preferredVideoCodec:(NSString * _Nullable)preferredVideoCodec audioInputDeviceId: (NSString * _Nonnull)audioInputDeviceId;
- (instancetype _Nonnull)initWithVersion:(NSString * _Nonnull)version queue:(id<OngoingCallThreadLocalContextQueueWebrtc> _Nonnull)queue proxy:(VoipProxyServerWebrtc * _Nullable)proxy networkType:(OngoingCallNetworkTypeWebrtc)networkType dataSaving:(OngoingCallDataSavingWebrtc)dataSaving derivedState:(NSData * _Nonnull)derivedState key:(NSData * _Nonnull)key isOutgoing:(bool)isOutgoing connections:(NSArray<OngoingCallConnectionDescriptionWebrtc *> * _Nonnull)connections maxLayer:(int32_t)maxLayer allowP2P:(BOOL)allowP2P allowTCP:(BOOL)allowTCP enableStunMarking:(BOOL)enableStunMarking logPath:(NSString * _Nonnull)logPath statsLogPath:(NSString * _Nonnull)statsLogPath sendSignalingData:(void (^ _Nonnull)(NSData * _Nonnull))sendSignalingData videoCapturer:(OngoingCallThreadLocalContextVideoCapturer * _Nullable)videoCapturer preferredVideoCodec:(NSString * _Nullable)preferredVideoCodec inputDeviceId: (NSString * _Nonnull)inputDeviceId outputDeviceId: (NSString * _Nonnull)outputDeviceId;
- (void)beginTermination;
- (void)stop:(void (^_Nullable)(NSString * _Nullable debugLog, int64_t bytesSentWifi, int64_t bytesReceivedWifi, int64_t bytesSentMobile, int64_t bytesReceivedMobile))completion;
+12 -6
View File
@@ -831,14 +831,14 @@ static void (*InternalVoipLoggingFunction)(NSString *) = NULL;
+ (tgcalls::ProtocolVersion)protocolVersionFromLibraryVersion:(NSString *)version {
if ([version isEqualToString:@"2.7.7"]) {
return tgcalls::ProtocolVersion::V0;
} else if ([version isEqualToString:@"3.0.0"]) {
} else if ([version isEqualToString:@"5.0.0"]) {
return tgcalls::ProtocolVersion::V1;
} else {
return tgcalls::ProtocolVersion::V0;
}
}
- (instancetype _Nonnull)initWithVersion:(NSString * _Nonnull)version queue:(id<OngoingCallThreadLocalContextQueueWebrtc> _Nonnull)queue proxy:(VoipProxyServerWebrtc * _Nullable)proxy networkType:(OngoingCallNetworkTypeWebrtc)networkType dataSaving:(OngoingCallDataSavingWebrtc)dataSaving derivedState:(NSData * _Nonnull)derivedState key:(NSData * _Nonnull)key isOutgoing:(bool)isOutgoing connections:(NSArray<OngoingCallConnectionDescriptionWebrtc *> * _Nonnull)connections maxLayer:(int32_t)maxLayer allowP2P:(BOOL)allowP2P allowTCP:(BOOL)allowTCP enableStunMarking:(BOOL)enableStunMarking logPath:(NSString * _Nonnull)logPath statsLogPath:(NSString * _Nonnull)statsLogPath sendSignalingData:(void (^)(NSData * _Nonnull))sendSignalingData videoCapturer:(OngoingCallThreadLocalContextVideoCapturer * _Nullable)videoCapturer preferredVideoCodec:(NSString * _Nullable)preferredVideoCodec audioInputDeviceId: (NSString * _Nonnull)audioInputDeviceId {
- (instancetype _Nonnull)initWithVersion:(NSString * _Nonnull)version queue:(id<OngoingCallThreadLocalContextQueueWebrtc> _Nonnull)queue proxy:(VoipProxyServerWebrtc * _Nullable)proxy networkType:(OngoingCallNetworkTypeWebrtc)networkType dataSaving:(OngoingCallDataSavingWebrtc)dataSaving derivedState:(NSData * _Nonnull)derivedState key:(NSData * _Nonnull)key isOutgoing:(bool)isOutgoing connections:(NSArray<OngoingCallConnectionDescriptionWebrtc *> * _Nonnull)connections maxLayer:(int32_t)maxLayer allowP2P:(BOOL)allowP2P allowTCP:(BOOL)allowTCP enableStunMarking:(BOOL)enableStunMarking logPath:(NSString * _Nonnull)logPath statsLogPath:(NSString * _Nonnull)statsLogPath sendSignalingData:(void (^)(NSData * _Nonnull))sendSignalingData videoCapturer:(OngoingCallThreadLocalContextVideoCapturer * _Nullable)videoCapturer preferredVideoCodec:(NSString * _Nullable)preferredVideoCodec inputDeviceId: (NSString * _Nonnull)inputDeviceId outputDeviceId: (NSString * _Nonnull)outputDeviceId {
self = [super init];
if (self != nil) {
_version = version;
@@ -949,8 +949,8 @@ static void (*InternalVoipLoggingFunction)(NSString *) = NULL;
.initialNetworkType = callControllerNetworkTypeForType(networkType),
.encryptionKey = encryptionKey,
.mediaDevicesConfig = tgcalls::MediaDevicesConfig {
.audioInputId = [audioInputDeviceId UTF8String],
.audioOutputId = [@"" UTF8String]
.audioInputId = [inputDeviceId UTF8String],
.audioOutputId = [outputDeviceId UTF8String]
},
.videoCapture = [_videoCapturer getInterface],
.stateUpdated = [weakSelf, queue](tgcalls::State state) {
@@ -1062,6 +1062,8 @@ static void (*InternalVoipLoggingFunction)(NSString *) = NULL;
}
}];
},
.initialInputDeviceId = inputDeviceId.UTF8String,
.initialOutputDeviceId = outputDeviceId.UTF8String,
// .createAudioDeviceModule = [](webrtc::TaskQueueFactory *taskQueueFactory) -> rtc::scoped_refptr<webrtc::AudioDeviceModule> {
// return rtc::make_ref_counted<webrtc::tgcalls_ios_adm::AudioDeviceModuleIOS>(false, false, 1);
// }
@@ -1306,10 +1308,14 @@ static void (*InternalVoipLoggingFunction)(NSString *) = NULL;
}
- (void)switchAudioOutput:(NSString * _Nonnull)deviceId {
_tgVoip->setAudioOutputDevice(deviceId.UTF8String);
if (_tgVoip) {
_tgVoip->setAudioOutputDevice(deviceId.UTF8String);
}
}
- (void)switchAudioInput:(NSString * _Nonnull)deviceId {
_tgVoip->setAudioInputDevice(deviceId.UTF8String);
if (_tgVoip) {
_tgVoip->setAudioInputDevice(deviceId.UTF8String);
}
}
- (void)addExternalAudioData:(NSData * _Nonnull)data {
+2
View File
@@ -234,6 +234,8 @@ struct Descriptor {
std::function<void(float)> remotePrefferedAspectRatioUpdated;
std::function<void(const std::vector<uint8_t> &)> signalingDataEmitted;
std::function<rtc::scoped_refptr<webrtc::AudioDeviceModule>(webrtc::TaskQueueFactory*)> createAudioDeviceModule;
std::string initialInputDeviceId;
std::string initialOutputDeviceId;
};
class Meta {
+15 -19
View File
@@ -191,7 +191,7 @@ public:
_outgoingAudioChannel->SetLocalContent(outgoingAudioDescription.get(), webrtc::SdpType::kOffer, errorDesc);
_outgoingAudioChannel->SetRemoteContent(incomingAudioDescription.get(), webrtc::SdpType::kAnswer, errorDesc);
});
setIsMuted(false);
}
@@ -329,20 +329,6 @@ public:
outgoingAudioDescription.reset();
incomingAudioDescription.reset();
cricket::AudioSendParameters audioSendPrameters;
audioSendPrameters.codecs = codecs;
audioSendPrameters.extensions.emplace_back(webrtc::RtpExtension::kTransportSequenceNumberUri, 1);
audioSendPrameters.options.echo_cancellation = true;
//audioSendPrameters.options.experimental_ns = false;
audioSendPrameters.options.noise_suppression = true;
audioSendPrameters.options.auto_gain_control = true;
//audioSendPrameters.options.highpass_filter = false;
audioSendPrameters.options.typing_detection = false;
//audioSendPrameters.max_bandwidth_bps = 16000;
audioSendPrameters.rtcp.reduced_size = true;
audioSendPrameters.rtcp.remote_estimate = true;
_audioChannel->media_channel()->SetSendParameters(audioSendPrameters);
//std::unique_ptr<AudioSinkImpl> audioLevelSink(new AudioSinkImpl(onAudioLevelUpdated, _ssrc, std::move(onAudioFrame)));
//_audioChannel->media_channel()->SetRawAudioSink(ssrc.networkSsrc, std::move(audioLevelSink));
@@ -881,6 +867,8 @@ public:
_remotePrefferedAspectRatioUpdated(descriptor.remotePrefferedAspectRatioUpdated),
_signalingDataEmitted(descriptor.signalingDataEmitted),
_createAudioDeviceModule(descriptor.createAudioDeviceModule),
_initialInputDeviceId(std::move(descriptor.initialInputDeviceId)),
_initialOutputDeviceId(std::move(descriptor.initialOutputDeviceId)),
_statsLogPath(descriptor.config.statsLogPath),
_eventLog(std::make_unique<webrtc::RtcEventLogNull>()),
_taskQueueFactory(webrtc::CreateDefaultTaskQueueFactory()),
@@ -1030,8 +1018,6 @@ public:
PlatformInterface::SharedInstance()->configurePlatformAudio();
//setAudioInputDevice(_initialInputDeviceId);
//setAudioOutputDevice(_initialOutputDeviceId);
_threads->getWorkerThread()->Invoke<void>(RTC_FROM_HERE, [&]() {
_audioDeviceModule = createAudioDeviceModule();
@@ -1046,6 +1032,8 @@ public:
mediaDeps.video_decoder_factory = PlatformInterface::SharedInstance()->makeVideoDecoderFactory();
mediaDeps.adm = _audioDeviceModule;
_availableVideoFormats = mediaDeps.video_encoder_factory->GetSupportedFormats();
@@ -1094,6 +1082,8 @@ public:
beginQualityTimer(0);
beginLogTimer(0);
}
void beginQualityTimer(int delayMs) {
@@ -1945,11 +1935,15 @@ public:
}
void setAudioInputDevice(std::string id) {
_threads->getWorkerThread()->Invoke<void>(RTC_FROM_HERE, [&]() {
SetAudioInputDeviceById(_audioDeviceModule.get(), id);
});
}
void setAudioOutputDevice(std::string id) {
_threads->getWorkerThread()->Invoke<void>(RTC_FROM_HERE, [&]() {
SetAudioOutputDeviceById(_audioDeviceModule.get(), id);
});
}
void setIsLowBatteryLevel(bool isLowBatteryLevel) {
@@ -2113,6 +2107,8 @@ private:
webrtc::RtpTransport *_rtpTransport = nullptr;
std::unique_ptr<cricket::ChannelManager> _channelManager;
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory> _videoBitrateAllocatorFactory;
std::string _initialInputDeviceId;
std::string _initialOutputDeviceId;
std::unique_ptr<ContentNegotiationContext> _contentNegotiationContext;