From b4823562a2fc783387c1ce1e54fb2c6771b5e4a2 Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Fri, 8 Mar 2024 11:40:50 +0400 Subject: [PATCH] Make it work --- submodules/TgVoipWebrtc/BUILD | 145 ++++++++++++---- .../Sources/OngoingCallThreadLocalContext.mm | 163 ++++-------------- submodules/TgVoipWebrtc/tgcalls | 2 +- third-party/webrtc/BUILD | 31 ++++ third-party/webrtc/webrtc | 2 +- 5 files changed, 178 insertions(+), 165 deletions(-) diff --git a/submodules/TgVoipWebrtc/BUILD b/submodules/TgVoipWebrtc/BUILD index b019c63148..be9f8d91a2 100644 --- a/submodules/TgVoipWebrtc/BUILD +++ b/submodules/TgVoipWebrtc/BUILD @@ -15,40 +15,124 @@ optimization_flags = select({ enable_x264 = False +sources = glob([ + "Sources/**/*.m", + "Sources/**/*.mm", + "Sources/**/*.h", + "tgcalls/tgcalls/**/*.h", + "tgcalls/tgcalls/**/*.hpp", + "tgcalls/tgcalls/**/*.cpp", + "tgcalls/tgcalls/**/*.mm", + "tgcalls/tgcalls/**/*.m", +], exclude = [ + "tgcalls/tgcalls/legacy/**", + "tgcalls/tgcalls/platform/tdesktop/**", + "tgcalls/tgcalls/platform/android/**", + "tgcalls/tgcalls/platform/windows/**", + "tgcalls/tgcalls/platform/uwp/**", + "tgcalls/tgcalls/platform/darwin/SQueue*", + "tgcalls/tgcalls/platform/darwin/macOS/**", + "tgcalls/tgcalls/platform/darwin/VideoCameraCapturerMac.*", + "tgcalls/tgcalls/platform/darwin/VideoMetalViewMac.*", + "tgcalls/tgcalls/platform/darwin/VideoSampleBufferViewMac.*", + "tgcalls/tgcalls/platform/darwin/GLVideoView.*", + "tgcalls/tgcalls/platform/darwin/GLVideoViewMac.*", + "tgcalls/tgcalls/platform/darwin/ScreenCapturer.*", + "tgcalls/tgcalls/platform/darwin/DesktopSharingCapturer.*", + "tgcalls/tgcalls/platform/darwin/DesktopCaptureSourceViewMac.*", + "tgcalls/tgcalls/platform/darwin/DesktopCaptureSourceView.*", + "tgcalls/tgcalls/platform/darwin/TGCMIODevice.*", + "tgcalls/tgcalls/platform/darwin/TGCMIOCapturer.*", + "tgcalls/tgcalls/platform/darwin/VideoCMIOCapture.*", + "tgcalls/tgcalls/desktop_capturer/**", +]) + +sources = glob([ + "Sources/**/*.m", + "Sources/**/*.mm", + "Sources/**/*.h", + "tgcalls/tgcalls/**/*.h", + "tgcalls/tgcalls/**/*.hpp", + "tgcalls/tgcalls/platform/darwin/**/*.cpp", + "tgcalls/tgcalls/platform/darwin/**/*.m", + "tgcalls/tgcalls/platform/darwin/**/*.mm", + "tgcalls/tgcalls/platform/darwin/**/*.cc", + "tgcalls/tgcalls/platform/darwin/**/*.c", + "tgcalls/tgcalls/third-party/**/*.cpp", + "tgcalls/tgcalls/utils/**/*.cpp", +], exclude = [ + "tgcalls/tgcalls/legacy/**", + "tgcalls/tgcalls/platform/tdesktop/**", + "tgcalls/tgcalls/platform/android/**", + "tgcalls/tgcalls/platform/windows/**", + "tgcalls/tgcalls/platform/uwp/**", + "tgcalls/tgcalls/platform/darwin/SQueue*", + "tgcalls/tgcalls/platform/darwin/macOS/**", + "tgcalls/tgcalls/platform/darwin/VideoCameraCapturerMac.*", + "tgcalls/tgcalls/platform/darwin/VideoMetalViewMac.*", + "tgcalls/tgcalls/platform/darwin/VideoSampleBufferViewMac.*", + "tgcalls/tgcalls/platform/darwin/GLVideoView.*", + "tgcalls/tgcalls/platform/darwin/GLVideoViewMac.*", + "tgcalls/tgcalls/platform/darwin/ScreenCapturer.*", + "tgcalls/tgcalls/platform/darwin/DesktopSharingCapturer.*", + "tgcalls/tgcalls/platform/darwin/DesktopCaptureSourceViewMac.*", + "tgcalls/tgcalls/platform/darwin/DesktopCaptureSourceView.*", + "tgcalls/tgcalls/platform/darwin/TGCMIODevice.*", + "tgcalls/tgcalls/platform/darwin/TGCMIOCapturer.*", + "tgcalls/tgcalls/platform/darwin/VideoCMIOCapture.*", + "tgcalls/tgcalls/desktop_capturer/**", +]) + [ + "tgcalls/tgcalls/Manager.cpp", + "tgcalls/tgcalls/MediaManager.cpp", + "tgcalls/tgcalls/AudioDeviceHelper.cpp", + "tgcalls/tgcalls/ChannelManager.cpp", + "tgcalls/tgcalls/CodecSelectHelper.cpp", + "tgcalls/tgcalls/CryptoHelper.cpp", + "tgcalls/tgcalls/EncryptedConnection.cpp", + "tgcalls/tgcalls/FakeAudioDeviceModule.cpp", + "tgcalls/tgcalls/FakeVideoTrackSource.cpp", + "tgcalls/tgcalls/FieldTrialsConfig.cpp", + "tgcalls/tgcalls/Instance.cpp", + "tgcalls/tgcalls/InstanceImpl.cpp", + "tgcalls/tgcalls/LogSinkImpl.cpp", + "tgcalls/tgcalls/Message.cpp", + "tgcalls/tgcalls/NetworkManager.cpp", + "tgcalls/tgcalls/SctpDataChannelProviderInterfaceImpl.cpp", + "tgcalls/tgcalls/StaticThreads.cpp", + "tgcalls/tgcalls/ThreadLocalObject.cpp", + "tgcalls/tgcalls/TurnCustomizerImpl.cpp", + "tgcalls/tgcalls/VideoCaptureInterface.cpp", + "tgcalls/tgcalls/VideoCaptureInterfaceImpl.cpp", + + "tgcalls/tgcalls/group/AudioStreamingPart.cpp", + "tgcalls/tgcalls/group/AudioStreamingPartInternal.cpp", + "tgcalls/tgcalls/group/AudioStreamingPartPersistentDecoder.cpp", + "tgcalls/tgcalls/group/AVIOContextImpl.cpp", + "tgcalls/tgcalls/group/GroupInstanceCustomImpl.cpp", + "tgcalls/tgcalls/group/GroupJoinPayloadInternal.cpp", + "tgcalls/tgcalls/group/GroupNetworkManager.cpp", + "tgcalls/tgcalls/group/StreamingMediaContext.cpp", + "tgcalls/tgcalls/group/VideoStreamingPart.cpp", + + "tgcalls/tgcalls/v2/ContentNegotiation.cpp", + "tgcalls/tgcalls/v2/DirectNetworkingImpl.cpp", + "tgcalls/tgcalls/v2/ExternalSignalingConnection.cpp", + "tgcalls/tgcalls/v2/InstanceV2Impl.cpp", + "tgcalls/tgcalls/v2/InstanceV2ReferenceImpl.cpp", + "tgcalls/tgcalls/v2/NativeNetworkingImpl.cpp", + "tgcalls/tgcalls/v2/ReflectorPort.cpp", + "tgcalls/tgcalls/v2/ReflectorRelayPortFactory.cpp", + "tgcalls/tgcalls/v2/Signaling.cpp", + "tgcalls/tgcalls/v2/SignalingConnection.cpp", + "tgcalls/tgcalls/v2/SignalingEncryption.cpp", + "tgcalls/tgcalls/v2/SignalingSctpConnection.cpp", +] + objc_library( name = "TgVoipWebrtc", enable_modules = True, module_name = "TgVoipWebrtc", - srcs = glob([ - "Sources/**/*.m", - "Sources/**/*.mm", - "Sources/**/*.h", - "tgcalls/tgcalls/**/*.h", - "tgcalls/tgcalls/**/*.hpp", - "tgcalls/tgcalls/**/*.cpp", - "tgcalls/tgcalls/**/*.mm", - "tgcalls/tgcalls/**/*.m", - ], exclude = [ - "tgcalls/tgcalls/legacy/**", - "tgcalls/tgcalls/platform/tdesktop/**", - "tgcalls/tgcalls/platform/android/**", - "tgcalls/tgcalls/platform/windows/**", - "tgcalls/tgcalls/platform/uwp/**", - "tgcalls/tgcalls/platform/darwin/SQueue*", - "tgcalls/tgcalls/platform/darwin/macOS/**", - "tgcalls/tgcalls/platform/darwin/VideoCameraCapturerMac.*", - "tgcalls/tgcalls/platform/darwin/VideoMetalViewMac.*", - "tgcalls/tgcalls/platform/darwin/VideoSampleBufferViewMac.*", - "tgcalls/tgcalls/platform/darwin/GLVideoViewMac.*", - "tgcalls/tgcalls/platform/darwin/ScreenCapturer.*", - "tgcalls/tgcalls/platform/darwin/DesktopSharingCapturer.*", - "tgcalls/tgcalls/platform/darwin/DesktopCaptureSourceViewMac.*", - "tgcalls/tgcalls/platform/darwin/DesktopCaptureSourceView.*", - "tgcalls/tgcalls/platform/darwin/TGCMIODevice.*", - "tgcalls/tgcalls/platform/darwin/TGCMIOCapturer.*", - "tgcalls/tgcalls/platform/darwin/VideoCMIOCapture.*", - "tgcalls/tgcalls/desktop_capturer/**", - ]), + srcs = sources, hdrs = glob([ "PublicHeaders/**/*.h", ]), @@ -123,6 +207,7 @@ objc_library( "-DWEBRTC_MAC", "-DWEBRTC_POSIX", "-DRTC_ENABLE_VP9", + "-DRTC_ENABLE_H265", "-DTGVOIP_NAMESPACE=tgvoip_webrtc", "-std=c++17", ], diff --git a/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm b/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm index f0e739f150..f70cdff0f8 100644 --- a/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm +++ b/submodules/TgVoipWebrtc/Sources/OngoingCallThreadLocalContext.mm @@ -6,7 +6,7 @@ #import "InstanceImpl.h" #import "v2/InstanceV2Impl.h" #import "v2/InstanceV2ReferenceImpl.h" -#import "v2_4_0_0/InstanceV2_4_0_0Impl.h" +//#import "v2_4_0_0/InstanceV2_4_0_0Impl.h" #include "StaticThreads.h" #import "VideoCaptureInterface.h" @@ -21,7 +21,6 @@ #else #import "platform/darwin/VideoMetalView.h" -#import "platform/darwin/GLVideoView.h" #import "platform/darwin/VideoSampleBufferView.h" #import "platform/darwin/VideoCaptureView.h" #import "platform/darwin/CustomExternalCapturer.h" @@ -281,52 +280,6 @@ private: @end -@interface GLVideoView (VideoViewImpl) - -@property (nonatomic, readwrite) OngoingCallVideoOrientationWebrtc orientation; -@property (nonatomic, readonly) CGFloat aspect; - -@end - -@implementation GLVideoView (VideoViewImpl) - -- (OngoingCallVideoOrientationWebrtc)orientation { - return (OngoingCallVideoOrientationWebrtc)self.internalOrientation; -} - -- (CGFloat)aspect { - return self.internalAspect; -} - -- (void)setOrientation:(OngoingCallVideoOrientationWebrtc)orientation { - [self setInternalOrientation:(int)orientation]; -} - -- (void)setOnOrientationUpdated:(void (^ _Nullable)(OngoingCallVideoOrientationWebrtc, CGFloat))onOrientationUpdated { - if (onOrientationUpdated) { - [self internalSetOnOrientationUpdated:^(int value, CGFloat aspect) { - onOrientationUpdated((OngoingCallVideoOrientationWebrtc)value, aspect); - }]; - } else { - [self internalSetOnOrientationUpdated:nil]; - } -} - -- (void)setOnIsMirroredUpdated:(void (^ _Nullable)(bool))onIsMirroredUpdated { - if (onIsMirroredUpdated) { - [self internalSetOnIsMirroredUpdated:^(bool value) { - onIsMirroredUpdated(value); - }]; - } else { - [self internalSetOnIsMirroredUpdated:nil]; - } -} - -- (void)updateIsEnabled:(bool)__unused isEnabled { -} - -@end - @interface VideoSampleBufferView (VideoViewImpl) @property (nonatomic, readwrite) OngoingCallVideoOrientationWebrtc orientation; @@ -828,54 +781,25 @@ tgcalls::VideoCaptureInterfaceObject *GetVideoCaptureAssumingSameThread(tgcalls: } std::shared_ptr interface = strongSelf->_interface; - /*if (false && requestClone) { - VideoSampleBufferView *remoteRenderer = [[VideoSampleBufferView alloc] initWithFrame:CGRectZero]; - remoteRenderer.videoContentMode = UIViewContentModeScaleAspectFill; + VideoMetalView *remoteRenderer = [[VideoMetalView alloc] initWithFrame:CGRectZero]; + remoteRenderer.videoContentMode = UIViewContentModeScaleAspectFill; - std::shared_ptr> sink = [remoteRenderer getSink]; - interface->setOutput(sink); - - VideoSampleBufferView *cloneRenderer = nil; - if (requestClone) { - cloneRenderer = [[VideoSampleBufferView alloc] initWithFrame:CGRectZero]; - cloneRenderer.videoContentMode = UIViewContentModeScaleAspectFill; + VideoMetalView *cloneRenderer = nil; + if (requestClone) { + cloneRenderer = [[VideoMetalView alloc] initWithFrame:CGRectZero]; #ifdef WEBRTC_IOS - [remoteRenderer setCloneTarget:cloneRenderer]; -#endif - } - - completion(remoteRenderer, cloneRenderer); - } else */if ([VideoMetalView isSupported]) { - VideoMetalView *remoteRenderer = [[VideoMetalView alloc] initWithFrame:CGRectZero]; - remoteRenderer.videoContentMode = UIViewContentModeScaleAspectFill; - - VideoMetalView *cloneRenderer = nil; - if (requestClone) { - cloneRenderer = [[VideoMetalView alloc] initWithFrame:CGRectZero]; -#ifdef WEBRTC_IOS - cloneRenderer.videoContentMode = UIViewContentModeScaleToFill; - [remoteRenderer setClone:cloneRenderer]; + cloneRenderer.videoContentMode = UIViewContentModeScaleToFill; + [remoteRenderer setClone:cloneRenderer]; #else - cloneRenderer.videoContentMode = kCAGravityResizeAspectFill; + cloneRenderer.videoContentMode = kCAGravityResizeAspectFill; #endif - } - - std::shared_ptr> sink = [remoteRenderer getSink]; - - interface->setOutput(sink); - - completion(remoteRenderer, cloneRenderer); - } else { - GLVideoView *remoteRenderer = [[GLVideoView alloc] initWithFrame:CGRectZero]; - #ifndef WEBRTC_IOS - remoteRenderer.videoContentMode = UIViewContentModeScaleAspectFill; - #endif - - std::shared_ptr> sink = [remoteRenderer getSink]; - interface->setOutput(sink); - - completion(remoteRenderer, nil); } + + std::shared_ptr> sink = [remoteRenderer getSink]; + + interface->setOutput(sink); + + completion(remoteRenderer, cloneRenderer); }); }; @@ -1039,7 +963,7 @@ static void (*InternalVoipLoggingFunction)(NSString *) = NULL; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ tgcalls::Register(); - tgcalls::Register(); + //tgcalls::Register(); tgcalls::Register(); tgcalls::Register(); }); @@ -1612,36 +1536,22 @@ static void (*InternalVoipLoggingFunction)(NSString *) = NULL; if (_tgVoip) { __weak OngoingCallThreadLocalContextWebrtc *weakSelf = self; dispatch_async(dispatch_get_main_queue(), ^{ - if ([VideoMetalView isSupported]) { - VideoMetalView *remoteRenderer = [[VideoMetalView alloc] initWithFrame:CGRectZero]; + VideoMetalView *remoteRenderer = [[VideoMetalView alloc] initWithFrame:CGRectZero]; #if TARGET_OS_IPHONE - remoteRenderer.videoContentMode = UIViewContentModeScaleToFill; + remoteRenderer.videoContentMode = UIViewContentModeScaleToFill; #else - remoteRenderer.videoContentMode = UIViewContentModeScaleAspect; + remoteRenderer.videoContentMode = UIViewContentModeScaleAspect; #endif - - std::shared_ptr> sink = [remoteRenderer getSink]; - __strong OngoingCallThreadLocalContextWebrtc *strongSelf = weakSelf; - if (strongSelf) { - [remoteRenderer setOrientation:strongSelf->_remoteVideoOrientation]; - strongSelf->_currentRemoteVideoRenderer = remoteRenderer; - strongSelf->_tgVoip->setIncomingVideoOutput(sink); - } - - completion(remoteRenderer); - } else { - GLVideoView *remoteRenderer = [[GLVideoView alloc] initWithFrame:CGRectZero]; - - std::shared_ptr> sink = [remoteRenderer getSink]; - __strong OngoingCallThreadLocalContextWebrtc *strongSelf = weakSelf; - if (strongSelf) { - [remoteRenderer setOrientation:strongSelf->_remoteVideoOrientation]; - strongSelf->_currentRemoteVideoRenderer = remoteRenderer; - strongSelf->_tgVoip->setIncomingVideoOutput(sink); - } - - completion(remoteRenderer); + + std::shared_ptr> sink = [remoteRenderer getSink]; + __strong OngoingCallThreadLocalContextWebrtc *strongSelf = weakSelf; + if (strongSelf) { + [remoteRenderer setOrientation:strongSelf->_remoteVideoOrientation]; + strongSelf->_currentRemoteVideoRenderer = remoteRenderer; + strongSelf->_tgVoip->setIncomingVideoOutput(sink); } + + completion(remoteRenderer); }); } } @@ -2248,14 +2158,14 @@ audioDevice:(SharedCallAudioDevice * _Nullable)audioDevice { }]; completion(remoteRenderer, cloneRenderer); - } else if ([VideoMetalView isSupported]) { + } else { VideoMetalView *remoteRenderer = [[VideoMetalView alloc] initWithFrame:CGRectZero]; #ifdef WEBRTC_IOS remoteRenderer.videoContentMode = UIViewContentModeScaleToFill; #else remoteRenderer.videoContentMode = kCAGravityResizeAspectFill; #endif - + VideoMetalView *cloneRenderer = nil; if (requestClone) { cloneRenderer = [[VideoMetalView alloc] initWithFrame:CGRectZero]; @@ -2280,19 +2190,6 @@ audioDevice:(SharedCallAudioDevice * _Nullable)audioDevice { }]; completion(remoteRenderer, cloneRenderer); - } else { - GLVideoView *remoteRenderer = [[GLVideoView alloc] initWithFrame:CGRectZero]; - // [remoteRenderer setVideoContentMode:kCAGravityResizeAspectFill]; - std::shared_ptr> sink = [remoteRenderer getSink]; - - [queue dispatch:^{ - __strong GroupCallThreadLocalContext *strongSelf = weakSelf; - if (strongSelf && strongSelf->_instance) { - strongSelf->_instance->addIncomingVideoOutput(endpointId.UTF8String, sink); - } - }]; - - completion(remoteRenderer, nil); } }); } diff --git a/submodules/TgVoipWebrtc/tgcalls b/submodules/TgVoipWebrtc/tgcalls index 564c632f93..8ec8837f16 160000 --- a/submodules/TgVoipWebrtc/tgcalls +++ b/submodules/TgVoipWebrtc/tgcalls @@ -1 +1 @@ -Subproject commit 564c632f9368409870631d3cef75a7fc4070d45b +Subproject commit 8ec8837f169a3594ad457c8ee47f9ecb4d576275 diff --git a/third-party/webrtc/BUILD b/third-party/webrtc/BUILD index 6a9f0b5bc4..2fc4db27e5 100644 --- a/third-party/webrtc/BUILD +++ b/third-party/webrtc/BUILD @@ -2816,22 +2816,51 @@ webrtc_sources = [ "modules/rtp_rtcp/include/recovered_packet_receiver.h", "modules/rtp_rtcp/source/flexfec_03_header_reader_writer.h", "modules/rtp_rtcp/source/leb128.h", + "modules/rtp_rtcp/source/leb128.cc", "modules/video_capture/raw_video_sink_interface.h", "modules/video_coding/timing/decode_time_percentile_filter.h", "rtc_base/bitrate_tracker.h", + "rtc_base/bitrate_tracker.cc", "rtc_base/numerics/sequence_number_unwrapper.h", "rtc_base/strings/str_join.h", "video/frame_dumping_encoder.h", "api/enable_media.h", + "api/enable_media.cc", "logging/rtc_event_log/events/rtc_event_neteq_set_minimum_delay.h", "modules/audio_processing/agc2/speech_level_estimator.h", "p2p/base/stun_dictionary.h", "pc/media_factory.h", "rtc_base/frequency_tracker.h", + "rtc_base/frequency_tracker.cc", "api/environment/environment_factory.h", + "api/environment/environment_factory.cc", "modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.h", "modules/video_coding/timing/inter_frame_delay_variation_calculator.h", "video/receive_statistics_proxy.h", + "api/video_codecs/h265_profile_tier_level.cc", + "modules/rtp_rtcp/source/rtp_packetizer_h265.cc", + "api/rtp_sender_interface.cc", + "modules/audio_processing/agc2/speech_level_estimator.cc", + "modules/rtp_rtcp/source/flexfec_03_header_reader_writer.cc", + "modules/audio_processing/agc2/input_volume_controller.cc", + "modules/audio_processing/agc2/input_volume_stats_reporter.cc", + "media/base/media_channel_impl.cc", + "p2p/base/stun_dictionary.cc", + "call/create_call.cc", + "modules/rtp_rtcp/source/frame_object.cc", + "modules/video_coding/timing/decode_time_percentile_filter.cc", + "logging/rtc_event_log/events/rtc_event_neteq_set_minimum_delay.cc", + "modules/video_coding/timing/inter_frame_delay_variation_calculator.cc", + "video/frame_dumping_encoder.cc", + "modules/rtp_rtcp/source/rtp_video_stream_receiver_frame_transformer_delegate.cc", + "video/receive_statistics_proxy.cc", + "modules/rtp_rtcp/source/video_rtp_depacketizer_h265.h", + "modules/rtp_rtcp/source/video_rtp_depacketizer_h265.cc", + "modules/video_coding/codecs/h265/include/h265_globals.h", + "modules/rtp_rtcp/source/rtp_format_h265.h", + "modules/rtp_rtcp/source/rtp_format_h265.cc", + "modules/video_coding/h265_vps_sps_pps_tracker.h", + "modules/video_coding/h265_vps_sps_pps_tracker.cc", ] ios_objc_sources = [ @@ -3120,6 +3149,7 @@ common_flags = [ "-DWEBRTC_POSIX", "-DHAVE_WEBRTC_VIDEO", "-DRTC_ENABLE_VP9", + "-DRTC_ENABLE_H265", "-DWEBRTC_USE_H264", "-DHAVE_SCTP", "-DWEBRTC_HAVE_DCSCTP", @@ -3328,6 +3358,7 @@ dcsctp_sources = [ "webrtc/net/dcsctp/" + path for path in [ "packet/chunk/data_common.h", "packet/chunk/forward_tsn_common.h", "packet/parameter/zero_checksum_acceptable_chunk_parameter.h", + "packet/parameter/zero_checksum_acceptable_chunk_parameter.cc", "rx/data_tracker.cc", "rx/reassembly_queue.cc", diff --git a/third-party/webrtc/webrtc b/third-party/webrtc/webrtc index 6b419a0536..94a1503c3d 160000 --- a/third-party/webrtc/webrtc +++ b/third-party/webrtc/webrtc @@ -1 +1 @@ -Subproject commit 6b419a0536b1a0ccfff3682f997c6f19bcbd9bd8 +Subproject commit 94a1503c3d426e29ec8676a0caa994e98ed61205