Merge branch 'beta'

This commit is contained in:
Ali 2021-06-23 17:05:50 +04:00
commit 821d04c38a
5 changed files with 30 additions and 21 deletions

View File

@ -435,10 +435,6 @@ public final class OngoingCallVideoCapturer {
self.impl.setIsVideoEnabled(value)
}
public func injectSampleBuffer(_ sampleBuffer: CMSampleBuffer) {
self.impl.submitSampleBuffer(sampleBuffer)
}
public func injectPixelBuffer(_ pixelBuffer: CVPixelBuffer, rotation: CGImagePropertyOrientation) {
var videoRotation: OngoingCallVideoOrientation = .rotation0
switch rotation {

View File

@ -26,6 +26,9 @@ objc_library(
"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/**",
]),
hdrs = glob([

View File

@ -126,7 +126,6 @@ typedef NS_ENUM(int32_t, OngoingCallDataSavingWebrtc) {
- (void)setOnIsActiveUpdated:(void (^_Nonnull)(bool))onIsActiveUpdated;
#if TARGET_OS_IOS
- (void)submitSampleBuffer:(CMSampleBufferRef _Nonnull)sampleBuffer;
- (void)submitPixelBuffer:(CVPixelBufferRef _Nonnull)pixelBuffer rotation:(OngoingCallVideoOrientationWebrtc)rotation;
#endif

View File

@ -50,8 +50,26 @@
@end
@interface IsProcessingCustomSampleBufferFlag : NSObject
@property (nonatomic) bool value;
@end
@implementation IsProcessingCustomSampleBufferFlag
- (instancetype)init {
self = [super init];
if (self != nil) {
}
return self;
}
@end
@interface OngoingCallThreadLocalContextVideoCapturer () {
std::shared_ptr<tgcalls::VideoCaptureInterface> _interface;
IsProcessingCustomSampleBufferFlag *_isProcessingCustomSampleBuffer;
}
@end
@ -217,6 +235,7 @@
self = [super init];
if (self != nil) {
_interface = interface;
_isProcessingCustomSampleBuffer = [[IsProcessingCustomSampleBufferFlag alloc] init];
_croppingBuffer = std::make_shared<std::vector<uint8_t>>();
}
return self;
@ -254,20 +273,6 @@ tgcalls::VideoCaptureInterfaceObject *GetVideoCaptureAssumingSameThread(tgcalls:
}
#if TARGET_OS_IOS
- (void)submitSampleBuffer:(CMSampleBufferRef _Nonnull)sampleBuffer {
if (!sampleBuffer) {
return;
}
tgcalls::StaticThreads::getThreads()->getMediaThread()->PostTask(RTC_FROM_HERE, [interface = _interface, sampleBuffer = CFRetain(sampleBuffer)]() {
auto capture = GetVideoCaptureAssumingSameThread(interface.get());
auto source = capture->source();
if (source) {
[CustomExternalCapturer passSampleBuffer:(CMSampleBufferRef)sampleBuffer toSource:source];
}
CFRelease(sampleBuffer);
});
}
- (void)submitPixelBuffer:(CVPixelBufferRef _Nonnull)pixelBuffer rotation:(OngoingCallVideoOrientationWebrtc)rotation {
if (!pixelBuffer) {
return;
@ -289,13 +294,19 @@ tgcalls::VideoCaptureInterfaceObject *GetVideoCaptureAssumingSameThread(tgcalls:
break;
}
tgcalls::StaticThreads::getThreads()->getMediaThread()->PostTask(RTC_FROM_HERE, [interface = _interface, pixelBuffer = CFRetain(pixelBuffer), croppingBuffer = _croppingBuffer, videoRotation = videoRotation]() {
if (_isProcessingCustomSampleBuffer.value) {
return;
}
_isProcessingCustomSampleBuffer.value = true;
tgcalls::StaticThreads::getThreads()->getMediaThread()->PostTask(RTC_FROM_HERE, [interface = _interface, pixelBuffer = CFRetain(pixelBuffer), croppingBuffer = _croppingBuffer, videoRotation = videoRotation, isProcessingCustomSampleBuffer = _isProcessingCustomSampleBuffer]() {
auto capture = GetVideoCaptureAssumingSameThread(interface.get());
auto source = capture->source();
if (source) {
[CustomExternalCapturer passPixelBuffer:(CVPixelBufferRef)pixelBuffer rotation:videoRotation toSource:source croppingBuffer:*croppingBuffer];
}
CFRelease(pixelBuffer);
isProcessingCustomSampleBuffer.value = false;
});
}

@ -1 +1 @@
Subproject commit 91b711e620f7043113a40496f9dddc0ccea16d52
Subproject commit 51a2c86469971c98f516579b509d56b856981e56