diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2017-12-19 13:48:09 -0500 |
---|---|---|
committer | Joel Fischer <joeljfischer@gmail.com> | 2017-12-19 13:48:09 -0500 |
commit | 37382e4b80ae9a8142729c5b1a492674e0dc5bb9 (patch) | |
tree | 8b083c5d47efe995ec299623689b68cf6dbfd1f4 /SmartDeviceLink/SDLAudioFile.m | |
parent | 5a97adf2717df6f885acde31919c583e53c6b77b (diff) | |
parent | 11a29617004e7a114b9927374617b6ae60d7bd23 (diff) | |
download | sdl_ios-37382e4b80ae9a8142729c5b1a492674e0dc5bb9.tar.gz |
Merge branch 'develop' into feature/issue_794_CarWindow
# Conflicts:
# SmartDeviceLink-iOS.xcodeproj/project.pbxproj
# SmartDeviceLink/SDLStreamingMediaLifecycleManager.h
# SmartDeviceLink/SDLStreamingMediaLifecycleManager.m
# SmartDeviceLink/SDLStreamingMediaManager.m
# SmartDeviceLink/SmartDeviceLink.h
Diffstat (limited to 'SmartDeviceLink/SDLAudioFile.m')
-rwxr-xr-x | SmartDeviceLink/SDLAudioFile.m | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/SmartDeviceLink/SDLAudioFile.m b/SmartDeviceLink/SDLAudioFile.m new file mode 100755 index 000000000..1d0e2ef98 --- /dev/null +++ b/SmartDeviceLink/SDLAudioFile.m @@ -0,0 +1,62 @@ +// +// SDLAudioFile.m +// SmartDeviceLink-Example +// +// Created by Joel Fischer on 10/24/17. +// Copyright © 2017 smartdevicelink. All rights reserved. +// + +#import "SDLAudioFile.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface SDLAudioFile () + +@property (copy, nonatomic, readwrite) NSURL *inputFileURL; +@property (copy, nonatomic, readwrite) NSURL *outputFileURL; +@property (copy, nonatomic, readwrite) NSData *data; +@property (copy, nonatomic, readwrite) NSString *name; + +@end + +@implementation SDLAudioFile + +- (instancetype)initWithInputFileURL:(NSURL *)inputURL outputFileURL:(NSURL *)outputURL estimatedDuration:(UInt32)duration { + self = [super init]; + if (!self) { return nil; } + + _inputFileURL = inputURL; + _outputFileURL = outputURL; + _estimatedDuration = duration; + + return self; +} + +- (NSData *)data { + if (_data.length == 0) { + return [NSData dataWithContentsOfURL:_outputFileURL]; + } + + return _data; +} + +/** + Gets the size of the data. The data may be stored on disk or it may already be in the application's memory. + + @return The size of the data. + */ +- (unsigned long long)fileSize { + if (_outputFileURL != nil) { + // Data in file + NSString *path = [_outputFileURL path]; + return [[NSFileManager defaultManager] attributesOfItemAtPath:path error:nil].fileSize; + } else if (_data) { + // Data in memory + return _data.length; + } + return 0; +} + +@end + +NS_ASSUME_NONNULL_END |