mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-07-25 12:40:36 +00:00

git-subtree-dir: submodules/ffmpeg git-subtree-mainline: 8f5a4f7dc119599d326c72d9a6115973e825491b git-subtree-split: 53fc3dcb6022f35015afd2605ead32bfd7417144
40 lines
967 B
Objective-C
40 lines
967 B
Objective-C
#import "FFMpegAVIOContext.h"
|
|
|
|
#import "libavformat/avformat.h"
|
|
|
|
@interface FFMpegAVIOContext () {
|
|
AVIOContext *_impl;
|
|
}
|
|
|
|
@end
|
|
|
|
@implementation FFMpegAVIOContext
|
|
|
|
- (instancetype _Nullable)initWithBufferSize:(int32_t)bufferSize opaqueContext:(void * const)opaqueContext readPacket:(int (*)(void * _Nullable opaque, uint8_t * _Nullable buf, int buf_size))readPacket seek:(int64_t (*)(void * _Nullable opaque, int64_t offset, int whence))seek {
|
|
self = [super init];
|
|
if (self != nil) {
|
|
void *avIoBuffer = av_malloc(bufferSize);
|
|
_impl = avio_alloc_context(avIoBuffer, bufferSize, 0, opaqueContext, readPacket, nil, seek);
|
|
if (_impl == nil) {
|
|
av_free(avIoBuffer);
|
|
return nil;
|
|
}
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)dealloc {
|
|
if (_impl != nil) {
|
|
if (_impl->buffer != nil) {
|
|
av_free(_impl->buffer);
|
|
}
|
|
av_free(_impl);
|
|
}
|
|
}
|
|
|
|
- (void *)impl {
|
|
return _impl;
|
|
}
|
|
|
|
@end
|