Video avatar fixes

This commit is contained in:
Ilya Laktyushin 2020-06-25 22:28:00 +03:00
parent 43d6e01658
commit dcf1217fbf
7 changed files with 22 additions and 7 deletions

View File

@ -7,6 +7,7 @@
@property (nonatomic, strong) UIImage *image;
@property (nonatomic, strong) AVPlayer *player;
@property (nonatomic, readonly) CGSize originalSize;
@property (nonatomic, assign) CGRect cropRect;
@property (nonatomic, assign) UIImageOrientation cropOrientation;
@property (nonatomic, assign) bool cropMirrored;
@ -36,6 +37,8 @@
- (void)invalidateCropRect;
- (void)invalidateVideoView;
- (UIImage *)currentImage;
- (void)hideImageForCustomTransition;
- (CGRect)contentFrameForView:(UIView *)view;

View File

@ -405,14 +405,14 @@
{
__strong TGMediaAssetsController *strongController = weakController;
if (strongController != nil) {
[strongController dismissViewControllerAnimated:true completion:nil];
[strongController dismissViewControllerAnimated:false completion:nil];
}
__strong TGMediaAvatarMenuMixin *strongSelf = weakSelf;
if (strongSelf == nil)
return;
[strongSelf->_parentController dismissViewControllerAnimated:true completion:nil];
[strongSelf->_parentController dismissViewControllerAnimated:false completion:nil];
if (strongSelf.didDismiss != nil)
strongSelf.didDismiss();

View File

@ -37,6 +37,7 @@
- (void)reloadDataAndReset:(bool)reset;
- (void)reloadThumbnails;
- (void)reloadThumbnailsAnimated;
- (void)ignoreThumbnails;
- (void)resetThumbnails;

View File

@ -311,6 +311,12 @@ const CGFloat TGPhotoAvatarCropButtonsWrapperSize = 61.0f;
if (self.finishedPhotoProcessing != nil)
self.finishedPhotoProcessing();
} else {
UIImage *image = _cropView.currentImage;
CGRect cropRect = _cropView.cropRect;
UIImageOrientation cropOrientation = _cropView.cropOrientation;
bool cropMirrored = _cropView.cropMirrored;
CGSize originalSize = _cropView.originalSize;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^
{
if (dispatch_semaphore_wait(_waitSemaphore, dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC))))
@ -319,8 +325,8 @@ const CGFloat TGPhotoAvatarCropButtonsWrapperSize = 61.0f;
return;
}
UIImage *croppedImage = [_cropView croppedImageWithMaxSize:TGPhotoEditorScreenImageMaxSize()];
[photoEditor setImage:croppedImage forCropRect:_cropView.cropRect cropRotation:0.0f cropOrientation:_cropView.cropOrientation cropMirrored:_cropView.cropMirrored fullSize:false];
UIImage *croppedImage = TGPhotoEditorCrop(image, nil, cropOrientation, 0.0f, cropRect, false, TGPhotoEditorScreenImageMaxSize(), originalSize, true);
[photoEditor setImage:croppedImage forCropRect:cropRect cropRotation:0.0f cropOrientation:cropOrientation cropMirrored:cropMirrored fullSize:false];
[photoEditor processAnimated:false completion:^
{

View File

@ -440,6 +440,10 @@ const CGFloat TGPhotoAvatarCropViewOverscreenSize = 1000;
return snapshotView;
}
- (UIImage *)currentImage {
return _imageView.image;
}
- (UIImage *)croppedImageWithMaxSize:(CGSize)maxSize
{
return TGPhotoEditorCrop(_imageView.image, nil, self.cropOrientation, 0.0f, self.cropRect, false, maxSize, _originalSize, true);

View File

@ -1333,7 +1333,8 @@
case TGPhotoEditorPreviewTab:
{
if ([_currentTabController isKindOfClass:[TGPhotoToolsController class]]) {
[_scrubberView reloadThumbnails];
[_scrubberView reloadDataAndReset:false];
[self updateDotImage];
}
TGPhotoAvatarPreviewController *previewController = [[TGPhotoAvatarPreviewController alloc] initWithContext:_context photoEditor:_photoEditor previewView:_previewView scrubberView:_scrubberView];

View File

@ -374,8 +374,8 @@ const NSInteger TGVideoCameraRetainedBufferCount = 16;
if (self.outputVideoFormatDescription == NULL)
[self setupVideoPipelineWithInputFormatDescription:formatDescription];
else {
[_recorder appendVideoSampleBuffer:sampleBuffer];
// [self renderVideoSampleBuffer:sampleBuffer];
// [_recorder appendVideoSampleBuffer:sampleBuffer];
[self renderVideoSampleBuffer:sampleBuffer];
}
}
else if (connection == _audioConnection)