mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Cleanup
This commit is contained in:
parent
38d971149a
commit
344cd37d31
5 changed files with 0 additions and 154 deletions
|
|
@ -22,8 +22,6 @@
|
|||
#import <LegacyComponents/PGCamera.h>
|
||||
#import <LegacyComponents/PGCameraCaptureSession.h>
|
||||
#import <LegacyComponents/PGCameraDeviceAngleSampler.h>
|
||||
#import <LegacyComponents/PGCameraMomentSegment.h>
|
||||
#import <LegacyComponents/PGCameraMomentSession.h>
|
||||
#import <LegacyComponents/PGCameraMovieWriter.h>
|
||||
#import <LegacyComponents/PGCameraShotMetadata.h>
|
||||
#import <LegacyComponents/PGCameraVolumeButtonHandler.h>
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
#import <CoreMedia/CoreMedia.h>
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
|
||||
@interface PGCameraMomentSegment : NSObject
|
||||
|
||||
@property (nonatomic, readonly) NSURL *fileURL;
|
||||
@property (nonatomic, readonly) AVAsset *asset;
|
||||
@property (nonatomic, readonly) NSTimeInterval duration;
|
||||
|
||||
- (instancetype)initWithURL:(NSURL *)url duration:(NSTimeInterval)duration;
|
||||
|
||||
@end
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
#import <LegacyComponents/PGCameraMomentSegment.h>
|
||||
|
||||
@class PGCamera;
|
||||
|
||||
@interface PGCameraMomentSession : NSObject
|
||||
|
||||
@property (nonatomic, copy) void (^beganCapture)(void);
|
||||
@property (nonatomic, copy) void (^finishedCapture)(void);
|
||||
@property (nonatomic, copy) bool (^captureIsAvailable)(void);
|
||||
@property (nonatomic, copy) void (^durationChanged)(NSTimeInterval);
|
||||
|
||||
@property (nonatomic, readonly) bool isCapturing;
|
||||
@property (nonatomic, readonly) UIImage *previewImage;
|
||||
@property (nonatomic, readonly) bool hasSegments;
|
||||
|
||||
@property (nonatomic, readonly) PGCameraMomentSegment *lastSegment;
|
||||
|
||||
- (instancetype)initWithCamera:(PGCamera *)camera;
|
||||
|
||||
- (void)captureSegment;
|
||||
- (void)commitSegment;
|
||||
|
||||
- (void)addSegment:(PGCameraMomentSegment *)segment;
|
||||
- (void)removeSegment:(PGCameraMomentSegment *)segment;
|
||||
- (void)removeLastSegment;
|
||||
- (void)removeAllSegments;
|
||||
|
||||
@end
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
#import "PGCameraMomentSegment.h"
|
||||
|
||||
@interface PGCameraMomentSegment ()
|
||||
{
|
||||
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation PGCameraMomentSegment
|
||||
|
||||
- (instancetype)initWithURL:(NSURL *)url duration:(NSTimeInterval)duration
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
_fileURL = url;
|
||||
_duration = duration;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
#import "PGCameraMomentSession.h"
|
||||
#import "PGCamera.h"
|
||||
|
||||
@interface PGCameraMomentSession ()
|
||||
{
|
||||
NSString *_uniqueIdentifier;
|
||||
NSURL *_segmentsDirectory;
|
||||
|
||||
PGCamera *_camera;
|
||||
NSMutableArray *_segments;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation PGCameraMomentSession
|
||||
|
||||
- (instancetype)initWithCamera:(PGCamera *)camera
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
_camera = camera;
|
||||
_segments = [[NSMutableArray alloc] init];
|
||||
|
||||
int64_t uniqueId = 0;
|
||||
arc4random_buf(&uniqueId, 8);
|
||||
_uniqueIdentifier = [NSString stringWithFormat:@"%x", (int)arc4random()];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSURL *)segmentsDirectory
|
||||
{
|
||||
if (_segmentsDirectory == nil)
|
||||
_segmentsDirectory = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:_uniqueIdentifier]];
|
||||
|
||||
return _segmentsDirectory;
|
||||
}
|
||||
|
||||
- (void)captureSegment
|
||||
{
|
||||
if (self.isCapturing)
|
||||
return;
|
||||
|
||||
_isCapturing = true;
|
||||
|
||||
if (self.beganCapture != nil)
|
||||
self.beganCapture();
|
||||
|
||||
[_camera startVideoRecordingForMoment:true completion:^(NSURL *resultUrl, __unused CGAffineTransform transform, __unused CGSize dimensions, NSTimeInterval duration, bool success)
|
||||
{
|
||||
if (!success)
|
||||
return;
|
||||
|
||||
_isCapturing = false;
|
||||
|
||||
if (self.finishedCapture != nil)
|
||||
self.finishedCapture();
|
||||
|
||||
PGCameraMomentSegment *segment = [[PGCameraMomentSegment alloc] initWithURL:resultUrl duration:duration];
|
||||
[self addSegment:segment];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)commitSegment
|
||||
{
|
||||
[_camera stopVideoRecording];
|
||||
}
|
||||
|
||||
- (void)addSegment:(PGCameraMomentSegment *)segment
|
||||
{
|
||||
[_segments addObject:segment];
|
||||
}
|
||||
|
||||
- (void)removeSegment:(PGCameraMomentSegment *)segment
|
||||
{
|
||||
[_segments removeObject:segment];
|
||||
}
|
||||
|
||||
- (void)removeLastSegment
|
||||
{
|
||||
[_segments removeLastObject];
|
||||
}
|
||||
|
||||
- (void)removeAllSegments
|
||||
{
|
||||
[_segments removeAllObjects];
|
||||
}
|
||||
|
||||
@end
|
||||
Loading…
Add table
Add a link
Reference in a new issue