More secure coding work.
This commit is contained in:
1 parent
fba0ca3d3a
commit
0f2057c64d
9 files changed
+49
-65
No files matched your search
@@ -9,7 +9,7 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "MP42Track.h"
|
#import "MP42Track.h"
|
||||||
|
|
||||||
@interface MP42AudioTrack : MP42Track <NSCoding, NSCopying>
|
@interface MP42AudioTrack : MP42Track <NSSecureCoding, NSCopying>
|
||||||
|
|
||||||
@property(nonatomic, readwrite) float volume;
|
@property(nonatomic, readwrite) float volume;
|
||||||
@property(nonatomic, readwrite) UInt32 channels;
|
@property(nonatomic, readwrite) UInt32 channels;
|
||||||
|
|||||||
@@ -251,12 +251,7 @@ extern u_int8_t MP4AV_AacConfigGetChannels(u_int8_t* pConfig);
|
|||||||
return [[super description] stringByAppendingFormat:@", %u ch", (unsigned int)_channels];
|
return [[super description] stringByAppendingFormat:@", %u ch", (unsigned int)_channels];
|
||||||
}
|
}
|
||||||
|
|
||||||
@synthesize channels = _channels;
|
#pragma mark - NSSecureCoding
|
||||||
@synthesize sourceChannels = _sourceChannels;
|
|
||||||
@synthesize mixdownType = _mixdownType;
|
|
||||||
@synthesize channelLayoutTag = _channelLayoutTag;
|
|
||||||
@synthesize fallbackTrackId = _fallbackTrackId;
|
|
||||||
@synthesize followsTrackId = _followsTrackId;
|
|
||||||
|
|
||||||
- (void)encodeWithCoder:(NSCoder *)coder
|
- (void)encodeWithCoder:(NSCoder *)coder
|
||||||
{
|
{
|
||||||
@@ -285,7 +280,7 @@ extern u_int8_t MP4AV_AacConfigGetChannels(u_int8_t* pConfig);
|
|||||||
|
|
||||||
_fallbackTrackId = [decoder decodeInt64ForKey:@"fallbackTrackId"];
|
_fallbackTrackId = [decoder decodeInt64ForKey:@"fallbackTrackId"];
|
||||||
|
|
||||||
_mixdownType = [[decoder decodeObjectForKey:@"mixdownType"] retain];
|
_mixdownType = [[decoder decodeObjectOfClass:[NSString class] forKey:@"mixdownType"] retain];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface MP42TextSample : NSObject <NSCoding>
|
@interface MP42TextSample : NSObject <NSSecureCoding>
|
||||||
|
|
||||||
@property (nonatomic, readwrite, copy) NSString *title;
|
@property (nonatomic, readwrite, copy) NSString *title;
|
||||||
@property (nonatomic, readwrite, retain, nullable) MP42Image *image;
|
@property (nonatomic, readwrite, retain, nullable) MP42Image *image;
|
||||||
|
|||||||
+7
-18
@@ -8,12 +8,7 @@
|
|||||||
|
|
||||||
#import "MP42TextSample.h"
|
#import "MP42TextSample.h"
|
||||||
|
|
||||||
@implementation MP42TextSample {
|
@implementation MP42TextSample
|
||||||
@private
|
|
||||||
MP42Duration _timestamp;
|
|
||||||
MP42Image *_image;
|
|
||||||
NSString *_title;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSComparisonResult)compare:(MP42TextSample *)otherObject
|
- (NSComparisonResult)compare:(MP42TextSample *)otherObject
|
||||||
{
|
{
|
||||||
@@ -27,17 +22,6 @@
|
|||||||
return NSOrderedSame;
|
return NSOrderedSame;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
|
||||||
{
|
|
||||||
[_image release];
|
|
||||||
[_title release];
|
|
||||||
[super dealloc];
|
|
||||||
}
|
|
||||||
|
|
||||||
@synthesize timestamp = _timestamp;
|
|
||||||
@synthesize title = _title;
|
|
||||||
@synthesize image = _image;
|
|
||||||
|
|
||||||
- (void)setTitle:(NSString *)title
|
- (void)setTitle:(NSString *)title
|
||||||
{
|
{
|
||||||
if (title == nil) {
|
if (title == nil) {
|
||||||
@@ -47,6 +31,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (BOOL)supportsSecureCoding
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)encodeWithCoder:(NSCoder *)coder
|
- (void)encodeWithCoder:(NSCoder *)coder
|
||||||
{
|
{
|
||||||
[coder encodeInt64:_timestamp forKey:@"timestamp"];
|
[coder encodeInt64:_timestamp forKey:@"timestamp"];
|
||||||
@@ -58,7 +47,7 @@
|
|||||||
self = [super init];
|
self = [super init];
|
||||||
|
|
||||||
_timestamp = [decoder decodeInt64ForKey:@"timestamp"];
|
_timestamp = [decoder decodeInt64ForKey:@"timestamp"];
|
||||||
_title = [[decoder decodeObjectForKey:@"title"] retain];
|
_title = [decoder decodeObjectOfClass:[NSString class] forKey:@"title"];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
/**
|
/**
|
||||||
* MP42Track
|
* MP42Track
|
||||||
*/
|
*/
|
||||||
@interface MP42Track : NSObject <NSCoding, NSCopying> {
|
@interface MP42Track : NSObject <NSSecureCoding, NSCopying> {
|
||||||
@protected
|
@protected
|
||||||
MP42TrackId _trackId;
|
MP42TrackId _trackId;
|
||||||
|
|
||||||
|
|||||||
+33
-35
@@ -141,6 +141,23 @@
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSString *)description {
|
||||||
|
return [NSString stringWithFormat:@"Track: %d, %@, %@, %llu kbit/s, %@", self.trackId, self.name, self.timeString, self.dataLength / self.duration * 8, localizedDisplayName(self.mediaType, self.format)];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)dealloc {
|
||||||
|
free(_helper);
|
||||||
|
|
||||||
|
[_updatedProperty release];
|
||||||
|
[_mediaCharacteristicTags release];
|
||||||
|
[_sourceURL release];
|
||||||
|
[_name release];
|
||||||
|
[_language release];
|
||||||
|
[_extendedLanguageTag release];
|
||||||
|
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
- (instancetype)copyWithZone:(NSZone *)zone
|
- (instancetype)copyWithZone:(NSZone *)zone
|
||||||
{
|
{
|
||||||
MP42Track *copy = [[[self class] alloc] init];
|
MP42Track *copy = [[[self class] alloc] init];
|
||||||
@@ -349,6 +366,13 @@
|
|||||||
return localizedDisplayName(_mediaType, _format);
|
return localizedDisplayName(_mediaType, _format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSSecureCoding
|
||||||
|
|
||||||
|
+ (BOOL)supportsSecureCoding
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)encodeWithCoder:(NSCoder *)coder
|
- (void)encodeWithCoder:(NSCoder *)coder
|
||||||
{
|
{
|
||||||
[coder encodeInt:3 forKey:@"MP42TrackVersion"];
|
[coder encodeInt:3 forKey:@"MP42TrackVersion"];
|
||||||
@@ -411,7 +435,7 @@
|
|||||||
_trackId = (MP4TrackId)[decoder decodeInt64ForKey:@"Id"];
|
_trackId = (MP4TrackId)[decoder decodeInt64ForKey:@"Id"];
|
||||||
_sourceId = (MP4TrackId)[decoder decodeInt64ForKey:@"sourceId"];
|
_sourceId = (MP4TrackId)[decoder decodeInt64ForKey:@"sourceId"];
|
||||||
|
|
||||||
NSData *bookmarkData = [decoder decodeObjectForKey:@"bookmark"];
|
NSData *bookmarkData = [decoder decodeObjectOfClass:[NSData class] forKey:@"bookmark"];
|
||||||
if (bookmarkData) {
|
if (bookmarkData) {
|
||||||
BOOL bookmarkDataIsStale;
|
BOOL bookmarkDataIsStale;
|
||||||
NSError *error;
|
NSError *error;
|
||||||
@@ -422,14 +446,14 @@
|
|||||||
bookmarkDataIsStale:&bookmarkDataIsStale
|
bookmarkDataIsStale:&bookmarkDataIsStale
|
||||||
error:&error] retain];
|
error:&error] retain];
|
||||||
} else {
|
} else {
|
||||||
_sourceURL = [[decoder decodeObjectForKey:@"sourceURL"] retain];
|
_sourceURL = [[decoder decodeObjectOfClass:[NSURL class] forKey:@"sourceURL"] retain];
|
||||||
}
|
}
|
||||||
|
|
||||||
_sourceFormat = [decoder decodeIntegerForKey:@"sourceFormat"];
|
_sourceFormat = [decoder decodeIntegerForKey:@"sourceFormat"];
|
||||||
_format = [decoder decodeIntegerForKey:@"format"];
|
_format = [decoder decodeIntegerForKey:@"format"];
|
||||||
_name = [[decoder decodeObjectForKey:@"name"] retain];
|
_name = [[decoder decodeObjectOfClass:[NSString class] forKey:@"name"] retain];
|
||||||
_language = [[decoder decodeObjectForKey:@"language"] retain];
|
_language = [[decoder decodeObjectOfClass:[NSString class] forKey:@"language"] retain];
|
||||||
_extendedLanguageTag = [[decoder decodeObjectForKey:@"extendedLanguageTag"] retain];
|
_extendedLanguageTag = [[decoder decodeObjectOfClass:[NSString class] forKey:@"extendedLanguageTag"] retain];
|
||||||
|
|
||||||
_enabled = [decoder decodeBoolForKey:@"enabled"];
|
_enabled = [decoder decodeBoolForKey:@"enabled"];
|
||||||
|
|
||||||
@@ -444,40 +468,14 @@
|
|||||||
_bitrate = [decoder decodeInt32ForKey:@"bitrate"];
|
_bitrate = [decoder decodeInt32ForKey:@"bitrate"];
|
||||||
_duration = [decoder decodeInt64ForKey:@"duration"];
|
_duration = [decoder decodeInt64ForKey:@"duration"];
|
||||||
|
|
||||||
if (version == 2)
|
if (version == 2) {
|
||||||
_size = [decoder decodeInt64ForKey:@"dataLength"];
|
_size = [decoder decodeInt64ForKey:@"dataLength"];
|
||||||
|
}
|
||||||
|
|
||||||
_updatedProperty = [[decoder decodeObjectForKey:@"updatedProperty"] retain];
|
_updatedProperty = [[decoder decodeObjectOfClass:[NSMutableDictionary class] forKey:@"updatedProperty"] retain];
|
||||||
_mediaCharacteristicTags = [[decoder decodeObjectForKey:@"mediaCharacteristicTags"] retain];
|
_mediaCharacteristicTags = [[decoder decodeObjectOfClass:[NSSet class] forKey:@"mediaCharacteristicTags"] retain];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)description {
|
|
||||||
return [NSString stringWithFormat:@"Track: %d, %@, %@, %llu kbit/s, %@", self.trackId, self.name, self.timeString, self.dataLength / self.duration * 8, localizedDisplayName(self.mediaType, self.format)];
|
|
||||||
}
|
|
||||||
|
|
||||||
@synthesize timescale = _timescale;
|
|
||||||
@synthesize bitrate = _bitrate;
|
|
||||||
@synthesize duration = _duration;
|
|
||||||
@synthesize isEdited = _isEdited;
|
|
||||||
@synthesize muxed = _muxed;
|
|
||||||
@synthesize needConversion = _needConversion;
|
|
||||||
@synthesize dataLength = _size;
|
|
||||||
@synthesize mediaType = _mediaType;
|
|
||||||
@synthesize mediaCharacteristicTags = _mediaCharacteristicTags;
|
|
||||||
|
|
||||||
- (void)dealloc {
|
|
||||||
free(_helper);
|
|
||||||
|
|
||||||
[_updatedProperty release];
|
|
||||||
[_mediaCharacteristicTags release];
|
|
||||||
[_sourceURL release];
|
|
||||||
[_name release];
|
|
||||||
[_language release];
|
|
||||||
[_extendedLanguageTag release];
|
|
||||||
|
|
||||||
[super dealloc];
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "MP42Track.h"
|
#import "MP42Track.h"
|
||||||
|
|
||||||
@interface MP42VideoTrack : MP42Track <NSCoding>
|
@interface MP42VideoTrack : MP42Track <NSSecureCoding>
|
||||||
|
|
||||||
@property(nonatomic, readwrite) uint64_t width;
|
@property(nonatomic, readwrite) uint64_t width;
|
||||||
@property(nonatomic, readwrite) uint64_t height;
|
@property(nonatomic, readwrite) uint64_t height;
|
||||||
|
|||||||
@@ -247,6 +247,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - NSSecureCoding
|
||||||
|
|
||||||
- (void)encodeWithCoder:(NSCoder *)coder
|
- (void)encodeWithCoder:(NSCoder *)coder
|
||||||
{
|
{
|
||||||
[super encodeWithCoder:coder];
|
[super encodeWithCoder:coder];
|
||||||
|
|||||||
@@ -106,7 +106,7 @@
|
|||||||
A97EA7CA1D4B8A2D00257CEA /* FFmpegUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = A97EA7C61D4B8A2D00257CEA /* FFmpegUtils.m */; };
|
A97EA7CA1D4B8A2D00257CEA /* FFmpegUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = A97EA7C61D4B8A2D00257CEA /* FFmpegUtils.m */; };
|
||||||
A989F1001823AB2E0070AD8C /* MP42Track+Muxer.h in Headers */ = {isa = PBXBuildFile; fileRef = A989F0FF1823AB2E0070AD8C /* MP42Track+Muxer.h */; };
|
A989F1001823AB2E0070AD8C /* MP42Track+Muxer.h in Headers */ = {isa = PBXBuildFile; fileRef = A989F0FF1823AB2E0070AD8C /* MP42Track+Muxer.h */; };
|
||||||
A989F10F1823B3B40070AD8C /* MP42TextSample.h in Headers */ = {isa = PBXBuildFile; fileRef = A989F10D1823B3B40070AD8C /* MP42TextSample.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
A989F10F1823B3B40070AD8C /* MP42TextSample.h in Headers */ = {isa = PBXBuildFile; fileRef = A989F10D1823B3B40070AD8C /* MP42TextSample.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
A989F1101823B3B40070AD8C /* MP42TextSample.m in Sources */ = {isa = PBXBuildFile; fileRef = A989F10E1823B3B40070AD8C /* MP42TextSample.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
A989F1101823B3B40070AD8C /* MP42TextSample.m in Sources */ = {isa = PBXBuildFile; fileRef = A989F10E1823B3B40070AD8C /* MP42TextSample.m */; };
|
||||||
A991714C195AAAEF005AD68E /* MP42Track+Muxer.m in Sources */ = {isa = PBXBuildFile; fileRef = A991714B195AAAEF005AD68E /* MP42Track+Muxer.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
A991714C195AAAEF005AD68E /* MP42Track+Muxer.m in Sources */ = {isa = PBXBuildFile; fileRef = A991714B195AAAEF005AD68E /* MP42Track+Muxer.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||||
A991714D195AAAEF005AD68E /* MP42Track+Muxer.m in Sources */ = {isa = PBXBuildFile; fileRef = A991714B195AAAEF005AD68E /* MP42Track+Muxer.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
A991714D195AAAEF005AD68E /* MP42Track+Muxer.m in Sources */ = {isa = PBXBuildFile; fileRef = A991714B195AAAEF005AD68E /* MP42Track+Muxer.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||||
A991714E195AAAEF005AD68E /* MP42Track+Muxer.m in Sources */ = {isa = PBXBuildFile; fileRef = A991714B195AAAEF005AD68E /* MP42Track+Muxer.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
A991714E195AAAEF005AD68E /* MP42Track+Muxer.m in Sources */ = {isa = PBXBuildFile; fileRef = A991714B195AAAEF005AD68E /* MP42Track+Muxer.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
|
||||||
|
|||||||
Reference in new issue
Block a user