mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-01-17 09:51:20 +00:00
Merge branch 'master' of bitbucket.org:iakovlevpeterp/legacycomponents
This commit is contained in:
@@ -133,6 +133,8 @@ const CGFloat TGGifConverterMaximumSide = 720.0f;
|
||||
[videoWriter startWriting];
|
||||
[videoWriter startSessionAtSourceTime:CMTimeMakeWithSeconds(totalFrameDelay, TGGifConverterFPS)];
|
||||
|
||||
__block UIImage *previewImage = nil;
|
||||
|
||||
while (!cancelled)
|
||||
{
|
||||
if (videoWriterInput.isReadyForMoreMediaData)
|
||||
@@ -149,6 +151,9 @@ const CGFloat TGGifConverterMaximumSide = 720.0f;
|
||||
CVPixelBufferRef pxBuffer = [self newBufferFrom:imgRef withPixelBufferPool:adaptor.pixelBufferPool andAttributes:adaptor.sourcePixelBufferAttributes];
|
||||
if (pxBuffer != NULL)
|
||||
{
|
||||
if (previewImage == nil) {
|
||||
previewImage = TGScaleImageToPixelSize([[UIImage alloc] initWithCGImage:imgRef], targetSize);
|
||||
}
|
||||
float frameDuration = 0.1f;
|
||||
NSNumber *delayTimeUnclampedProp = CFDictionaryGetValue(gifProperties, kCGImagePropertyGIFUnclampedDelayTime);
|
||||
if (delayTimeUnclampedProp != nil)
|
||||
@@ -194,7 +199,16 @@ const CGFloat TGGifConverterMaximumSide = 720.0f;
|
||||
|
||||
[videoWriter finishWritingWithCompletionHandler:^
|
||||
{
|
||||
[subscriber putNext:[outFilePath path]];
|
||||
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
|
||||
if ([outFilePath path] != nil) {
|
||||
dict[@"path"] = [outFilePath path];
|
||||
}
|
||||
dict[@"dimensions"] = [NSValue valueWithCGSize:targetSize];
|
||||
dict[@"duration"] = @((double)totalFrameDelay);
|
||||
if (previewImage != nil) {
|
||||
dict[@"previewImage"] = previewImage;
|
||||
}
|
||||
[subscriber putNext:dict];
|
||||
[subscriber putCompletion];
|
||||
}];
|
||||
break;
|
||||
|
||||
@@ -909,6 +909,7 @@ const CGPoint TGLocationPickerPinOffset = { 0.0f, 33.0f };
|
||||
tableView.dataSource = self;
|
||||
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
tableView.tableFooterView = [[UIView alloc] init];
|
||||
tableView.backgroundColor = self.pallete != nil ? self.pallete.backgroundColor : [UIColor whiteColor];
|
||||
|
||||
return tableView;
|
||||
}
|
||||
|
||||
@@ -857,14 +857,25 @@
|
||||
const char *gif89Header = "GIF89";
|
||||
if (data.length >= 5 && (!memcmp(data.bytes, gif87Header, 5) || !memcmp(data.bytes, gif89Header, 5)))
|
||||
{
|
||||
return [[TGGifConverter convertGifToMp4:data] map:^id(NSString *filePath)
|
||||
return [[TGGifConverter convertGifToMp4:data] map:^id(NSDictionary *result)
|
||||
{
|
||||
NSString *filePath = result[@"path"];
|
||||
|
||||
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
|
||||
dict[@"type"] = @"file";
|
||||
dict[@"tempFileUrl"] = [NSURL fileURLWithPath:filePath];
|
||||
dict[@"fileName"] = @"animation.mp4";
|
||||
dict[@"mimeType"] = @"video/mp4";
|
||||
dict[@"isAnimation"] = @true;
|
||||
if (result[@"dimensions"] != nil) {
|
||||
dict[@"dimensions"] = result[@"dimensions"];
|
||||
}
|
||||
if (result[@"duration"] != nil) {
|
||||
dict[@"duration"] = result[@"duration"];
|
||||
}
|
||||
if (result[@"previewImage"] != nil) {
|
||||
dict[@"previewImage"] = result[@"previewImage"];
|
||||
}
|
||||
|
||||
id generatedItem = descriptionGenerator(dict, caption, entities, nil);
|
||||
return generatedItem;
|
||||
|
||||
@@ -160,11 +160,6 @@ typedef enum
|
||||
self.isImportant = true;
|
||||
_controlsFrame = controlsFrame;
|
||||
|
||||
TGVideoMessageCaptureControllerWindow *window = [[TGVideoMessageCaptureControllerWindow alloc] initWithManager:[_context makeOverlayWindowManager] parentController:parentController contentController:self keepKeyboard:true];
|
||||
window.windowLevel = 1000000000.0f - 0.001f;
|
||||
window.hidden = false;
|
||||
window.controlsFrame = controlsFrame;
|
||||
|
||||
_gpuAvailable = true;
|
||||
|
||||
_activityDisposable = [[SMetaDisposable alloc] init];
|
||||
@@ -183,6 +178,11 @@ typedef enum
|
||||
}];
|
||||
|
||||
_thumbnailsDisposable = [[SMetaDisposable alloc] init];
|
||||
|
||||
TGVideoMessageCaptureControllerWindow *window = [[TGVideoMessageCaptureControllerWindow alloc] initWithManager:[_context makeOverlayWindowManager] parentController:parentController contentController:self keepKeyboard:true];
|
||||
window.windowLevel = 1000000000.0f - 0.001f;
|
||||
window.hidden = false;
|
||||
window.controlsFrame = controlsFrame;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -1067,17 +1067,17 @@ typedef enum
|
||||
_otherAudioPlaying = [[AVAudioSession sharedInstance] isOtherAudioPlaying];
|
||||
|
||||
__weak TGVideoMessageCaptureController *weakSelf = self;
|
||||
[_currentAudioSession setDisposable:[[LegacyComponentsGlobals provider] requestAudioSession:speaker ? TGAudioSessionTypePlayAndRecordHeadphones : TGAudioSessionTypePlayAndRecord interrupted:^
|
||||
id<SDisposable> disposable = [[LegacyComponentsGlobals provider] requestAudioSession:speaker ? TGAudioSessionTypePlayAndRecordHeadphones : TGAudioSessionTypePlayAndRecord interrupted:^
|
||||
{
|
||||
TGDispatchOnMainThread(^{
|
||||
__strong TGVideoMessageCaptureController *strongSelf = weakSelf;
|
||||
if (strongSelf != nil)
|
||||
{
|
||||
if (strongSelf != nil) {
|
||||
strongSelf->_automaticDismiss = true;
|
||||
[strongSelf complete];
|
||||
}
|
||||
});
|
||||
}]];
|
||||
}];
|
||||
[_currentAudioSession setDisposable:disposable];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user