Update MP4Dump.

This commit is contained in:
Damiano Galassi committed 2016-09-09 17:10:28 +02:00
1 parent 7a2e773d85
commit d7982171fd
5 files changed
+87 -91

No files matched your search

+28 -27
View File
@@ -13,23 +13,17 @@ extern NSString *libraryPath;
@implementation MyDocument
- (id)init
- (instancetype)init
{
self = [super init];
if (self) {
// Add your subclass-specific initialization here.
// If an error occurs here, send a [self release] message and return nil.
}
return self;
}
- (NSString *)windowNibName
{
// Override returning the nib file name of the document
// If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers,
// you should remove this method and override -makeWindowControllers instead.
return @"MyDocument";
}
@@ -38,58 +32,65 @@ extern NSString *libraryPath;
if ([[NSUserDefaults standardUserDefaults] valueForKey:@"LogLevel"])
[logLevelButton selectItemWithTag:[[NSUserDefaults standardUserDefaults] integerForKey:@"LogLevel"]];
[super windowControllerDidLoadNib:aController];
[textView setFont:[NSFont fontWithName:@"Monaco" size:10]];
[textView setString:@""];
[textView insertText:result];
[self _resetTextView];
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:result];
[textView.textStorage appendAttributedString:attributedString];
}
- (void)_resetTextView
{
textView.font = [NSFont fontWithName:@"Monaco" size:10];
textView.string = @"";
[textView setContinuousSpellCheckingEnabled:NO];
}
- (BOOL) loadFileDump:(NSURL *)absoluteURL error:(NSError **)outError
- (BOOL)_loadFileDump:(NSURL *)absoluteURL error:(NSError **)outError
{
MP4FileHandle fileHandle = MP4Read([[absoluteURL path] UTF8String]);
MP4FileHandle fileHandle = MP4Read(absoluteURL.fileSystemRepresentation);
MP4Dump(fileHandle, 0);
MP4Close(fileHandle, 0);
result = [NSString stringWithContentsOfFile:libraryPath encoding:NSASCIIStringEncoding error:outError];
if([[NSFileManager defaultManager] isDeletableFileAtPath:libraryPath])
if ([[NSFileManager defaultManager] isDeletableFileAtPath:libraryPath])
[[NSFileManager defaultManager] removeItemAtPath:libraryPath error:nil];
if (result)
if (result) {
return YES;
else
}
else {
return NO;
}
}
- (BOOL)readFromURL:(NSURL *)absoluteURL ofType:(NSString *)typeName error:(NSError **)outError
{
if ( outError != NULL && ![self loadFileDump:absoluteURL error:outError]) {
if (outError != NULL && ![self _loadFileDump:absoluteURL error:outError]) {
*outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:unimpErr userInfo:NULL];
return NO;
}
if([[NSFileManager defaultManager] isDeletableFileAtPath:libraryPath])
if ([[NSFileManager defaultManager] isDeletableFileAtPath:libraryPath]) {
[[NSFileManager defaultManager] removeItemAtPath:libraryPath error:nil];
}
return YES;
}
- (IBAction) setLogLevel: (id) sender
- (IBAction)setLogLevel:(id)sender
{
NSInteger level = [sender tag];
MP4LogLevel level = (MP4LogLevel)[sender tag];
[[NSUserDefaults standardUserDefaults] setInteger:level forKey:@"LogLevel"];
MP4LogSetLevel(level);
if ([self loadFileDump:[self fileURL] error:nil]) {
[textView setString:@""];
[textView insertText:result];
if ([self _loadFileDump:self.fileURL error:nil]) {
[self _resetTextView];
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:result];
[textView.textStorage appendAttributedString:attributedString];
}
}
- (void)updateChangeCount:(NSDocumentChangeType)changeType
{
}
@end