-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMICMSampleBuffer.m
86 lines (71 loc) · 1.56 KB
/
MICMSampleBuffer.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// MICMSampleBuffer.m
// MovieMaker
//
// Copyright (c) 2015 Zukini Ltd. All rights reserved.
#import "MICMSampleBuffer.h"
@implementation MICMSampleBuffer
{
CMSampleBufferRef _ownedBuffer;
}
#pragma mark MICGImage initialization, copying and dealloc methods
-(instancetype)initWithMICMSampleBuffer:(MICMSampleBuffer *)sampleBuffer
{
self = [super init];
if (self)
{
CMSampleBufferRef inbuf = sampleBuffer.CMSampleBuffer;
if (inbuf)
{
self->_ownedBuffer = (CMSampleBufferRef)CFRetain(inbuf);
}
}
return self;
}
-(instancetype)initWithCMSampleBuffer:(CMSampleBufferRef)buffer
{
self = [super init];
if (self)
{
if (buffer)
{
self->_ownedBuffer = (CMSampleBufferRef)CFRetain(buffer);
}
}
return self;
}
-(instancetype)copy
{
return [[MICMSampleBuffer alloc] initWithMICMSampleBuffer:self];
}
-(void)dealloc
{
if (self->_ownedBuffer)
{
CFRelease(self->_ownedBuffer);
}
}
# pragma mark Manual property implementation
-(CMSampleBufferRef)CMSampleBuffer
{
return self->_ownedBuffer;
}
-(void)setCMSampleBuffer:(CMSampleBufferRef)buffer
{
if (buffer == self->_ownedBuffer)
return;
if (self->_ownedBuffer)
{
CFRelease(self->_ownedBuffer);
}
self->_ownedBuffer = NULL;
if (buffer)
{
self->_ownedBuffer = (CMSampleBufferRef)CFRetain(buffer);
}
}
#pragma mark Conforming to NSCopying protocol methods
-(instancetype)copyWithZone:(NSZone *)zone
{
return [self copy];
}
@end