From 4ddc98ee1433d0dee2757a86460d6753b82bdbab Mon Sep 17 00:00:00 2001 From: vspader Date: Sun, 10 Jun 2007 21:34:20 +0000 Subject: [PATCH] Added Quicktime plugin. --- Cog.xcodeproj/project.pbxproj | 6 +- Plugins/Quicktime/Info.plist | 26 ++ .../Quicktime.xcodeproj/project.pbxproj | 270 ++++++++++++++++++ Plugins/Quicktime/QuicktimeDecoder.h | 29 ++ Plugins/Quicktime/QuicktimeDecoder.m | 181 ++++++++++++ Plugins/Quicktime/QuicktimePlugin.h | 16 ++ Plugins/Quicktime/QuicktimePlugin.m | 24 ++ Plugins/Quicktime/QuicktimePropertiesReader.h | 16 ++ Plugins/Quicktime/QuicktimePropertiesReader.m | 40 +++ Plugins/Quicktime/Quicktime_Prefix.pch | 7 + 10 files changed, 613 insertions(+), 2 deletions(-) create mode 100644 Plugins/Quicktime/Info.plist create mode 100644 Plugins/Quicktime/Quicktime.xcodeproj/project.pbxproj create mode 100644 Plugins/Quicktime/QuicktimeDecoder.h create mode 100644 Plugins/Quicktime/QuicktimeDecoder.m create mode 100644 Plugins/Quicktime/QuicktimePlugin.h create mode 100644 Plugins/Quicktime/QuicktimePlugin.m create mode 100644 Plugins/Quicktime/QuicktimePropertiesReader.h create mode 100644 Plugins/Quicktime/QuicktimePropertiesReader.m create mode 100644 Plugins/Quicktime/Quicktime_Prefix.pch diff --git a/Cog.xcodeproj/project.pbxproj b/Cog.xcodeproj/project.pbxproj index 9597385ed..34b222c83 100644 --- a/Cog.xcodeproj/project.pbxproj +++ b/Cog.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ 171B57DE0C091F2B00F6AFAF /* m4a.icns in Resources */ = {isa = PBXBuildFile; fileRef = 171B57DA0C091F2B00F6AFAF /* m4a.icns */; }; 171B57DF0C091F2B00F6AFAF /* mp3.icns in Resources */ = {isa = PBXBuildFile; fileRef = 171B57DB0C091F2B00F6AFAF /* mp3.icns */; }; 171B57E00C091F2B00F6AFAF /* ogg.icns in Resources */ = {isa = PBXBuildFile; fileRef = 171B57DC0C091F2B00F6AFAF /* ogg.icns */; }; + 1727C1940C1CA0EF0084363D /* Quicktime.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1727C1710C1CA0D40084363D /* Quicktime.bundle */; }; 1755E1F90BA0D2B600CA3560 /* PlaylistLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 1755E1F70BA0D2B600CA3560 /* PlaylistLoader.m */; }; 1766C6930B911DF1004A7AE4 /* AudioScrobbler.m in Sources */ = {isa = PBXBuildFile; fileRef = 1766C68F0B911DF1004A7AE4 /* AudioScrobbler.m */; }; 1766C6950B911DF1004A7AE4 /* AudioScrobblerClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 1766C6910B911DF1004A7AE4 /* AudioScrobblerClient.m */; }; @@ -72,7 +73,6 @@ 17818A990C0B27AC001C4916 /* shn.icns in Resources */ = {isa = PBXBuildFile; fileRef = 17818A920C0B27AC001C4916 /* shn.icns */; }; 17818A9A0C0B27AC001C4916 /* wav.icns in Resources */ = {isa = PBXBuildFile; fileRef = 17818A930C0B27AC001C4916 /* wav.icns */; }; 17818A9B0C0B27AC001C4916 /* wv.icns in Resources */ = {isa = PBXBuildFile; fileRef = 17818A940C0B27AC001C4916 /* wv.icns */; }; - 179790E00C087AB7001D6996 /* OpenURLPanel.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 179790DE0C087AB7001D6996 /* OpenURLPanel.h */; }; 179790E10C087AB7001D6996 /* OpenURLPanel.m in Sources */ = {isa = PBXBuildFile; fileRef = 179790DF0C087AB7001D6996 /* OpenURLPanel.m */; }; 179790F20C087B46001D6996 /* OpenURLPanel.nib in Resources */ = {isa = PBXBuildFile; fileRef = 179790F00C087B46001D6996 /* OpenURLPanel.nib */; }; 17ADB4580B979C7C00257CA2 /* FileSource.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = 17ADB4450B979C5700257CA2 /* FileSource.bundle */; }; @@ -140,6 +140,7 @@ 177FD1090B90CB5F0011C3B5 /* MAD.bundle in CopyFiles */, 177FD10A0B90CB5F0011C3B5 /* Flac.bundle in CopyFiles */, 177FD10B0B90CB5F0011C3B5 /* CoreAudio.bundle in CopyFiles */, + 1727C1940C1CA0EF0084363D /* Quicktime.bundle in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -152,7 +153,6 @@ 17E94E560C03B09A00D92B9B /* CogAudio.framework in CopyFiles */, 170680840B950164006BA573 /* Growl.framework in CopyFiles */, 17F94CCD0B8D090800A34E87 /* Sparkle.framework in CopyFiles */, - 179790E00C087AB7001D6996 /* OpenURLPanel.h in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -169,6 +169,7 @@ 171B57DA0C091F2B00F6AFAF /* m4a.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = m4a.icns; sourceTree = ""; }; 171B57DB0C091F2B00F6AFAF /* mp3.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = mp3.icns; sourceTree = ""; }; 171B57DC0C091F2B00F6AFAF /* ogg.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = ogg.icns; sourceTree = ""; }; + 1727C1710C1CA0D40084363D /* Quicktime.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = Quicktime.bundle; path = Plugins/Quicktime/build/Debug/Quicktime.bundle; sourceTree = ""; }; 1755E1F60BA0D2B600CA3560 /* PlaylistLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PlaylistLoader.h; sourceTree = ""; }; 1755E1F70BA0D2B600CA3560 /* PlaylistLoader.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = PlaylistLoader.m; sourceTree = ""; }; 1766C68E0B911DF1004A7AE4 /* AudioScrobbler.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = AudioScrobbler.h; sourceTree = ""; }; @@ -547,6 +548,7 @@ 17B619FF0B909ED400BC003F /* PlugIns */ = { isa = PBXGroup; children = ( + 1727C1710C1CA0D40084363D /* Quicktime.bundle */, 8E2B8F5E0B9B62F800F2D9E8 /* WavPack.bundle */, 17ADB65C0B97A96400257CA2 /* HTTPSource.bundle */, 17ADB4450B979C5700257CA2 /* FileSource.bundle */, diff --git a/Plugins/Quicktime/Info.plist b/Plugins/Quicktime/Info.plist new file mode 100644 index 000000000..17159d330 --- /dev/null +++ b/Plugins/Quicktime/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleName + ${PRODUCT_NAME} + CFBundleIconFile + + CFBundleIdentifier + com.yourcompany.yourcocoabundle + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleSignature + ???? + CFBundleVersion + 1.0 + NSPrincipalClass + QuicktimePlugin + + diff --git a/Plugins/Quicktime/Quicktime.xcodeproj/project.pbxproj b/Plugins/Quicktime/Quicktime.xcodeproj/project.pbxproj new file mode 100644 index 000000000..076ba0be2 --- /dev/null +++ b/Plugins/Quicktime/Quicktime.xcodeproj/project.pbxproj @@ -0,0 +1,270 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 42; + objects = { + +/* Begin PBXBuildFile section */ + 1727BFD10C1C94FD0084363D /* QuicktimePlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 1727BFD00C1C94FD0084363D /* QuicktimePlugin.m */; }; + 1727BFDD0C1C95350084363D /* QuicktimeDecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 1727BFDC0C1C95350084363D /* QuicktimeDecoder.m */; }; + 1727BFE60C1C956F0084363D /* QuicktimePropertiesReader.m in Sources */ = {isa = PBXBuildFile; fileRef = 1727BFE50C1C956F0084363D /* QuicktimePropertiesReader.m */; }; + 1727C0670C1C97A00084363D /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1727C0660C1C97A00084363D /* AudioToolbox.framework */; }; + 1727C0BE0C1C9E180084363D /* QuickTime.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1727C0BD0C1C9E180084363D /* QuickTime.framework */; }; + 8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 089C1672FE841209C02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; + 089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; + 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; + 1727BFCE0C1C94E90084363D /* Plugin.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Plugin.h; path = ../../Audio/Plugin.h; sourceTree = SOURCE_ROOT; }; + 1727BFCF0C1C94FD0084363D /* QuicktimePlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuicktimePlugin.h; sourceTree = ""; }; + 1727BFD00C1C94FD0084363D /* QuicktimePlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QuicktimePlugin.m; sourceTree = ""; }; + 1727BFDB0C1C95350084363D /* QuicktimeDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuicktimeDecoder.h; sourceTree = ""; }; + 1727BFDC0C1C95350084363D /* QuicktimeDecoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QuicktimeDecoder.m; sourceTree = ""; }; + 1727BFE40C1C956F0084363D /* QuicktimePropertiesReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuicktimePropertiesReader.h; sourceTree = ""; }; + 1727BFE50C1C956F0084363D /* QuicktimePropertiesReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QuicktimePropertiesReader.m; sourceTree = ""; }; + 1727C0660C1C97A00084363D /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = /System/Library/Frameworks/AudioToolbox.framework; sourceTree = ""; }; + 1727C0BD0C1C9E180084363D /* QuickTime.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickTime.framework; path = /System/Library/Frameworks/QuickTime.framework; sourceTree = ""; }; + 32DBCF630370AF2F00C91783 /* Quicktime_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Quicktime_Prefix.pch; sourceTree = ""; }; + 8D5B49B6048680CD000E48DA /* Quicktime.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Quicktime.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; + 8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = Info.plist; sourceTree = ""; }; + D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8D5B49B3048680CD000E48DA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */, + 1727C0670C1C97A00084363D /* AudioToolbox.framework in Frameworks */, + 1727C0BE0C1C9E180084363D /* QuickTime.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 089C166AFE841209C02AAC07 /* Quicktime */ = { + isa = PBXGroup; + children = ( + 08FB77AFFE84173DC02AAC07 /* Classes */, + 32C88E010371C26100C91783 /* Other Sources */, + 089C167CFE841241C02AAC07 /* Resources */, + 089C1671FE841209C02AAC07 /* Frameworks and Libraries */, + 19C28FB8FE9D52D311CA2CBB /* Products */, + ); + name = Quicktime; + sourceTree = ""; + }; + 089C1671FE841209C02AAC07 /* Frameworks and Libraries */ = { + isa = PBXGroup; + children = ( + 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */, + 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */, + ); + name = "Frameworks and Libraries"; + sourceTree = ""; + }; + 089C167CFE841241C02AAC07 /* Resources */ = { + isa = PBXGroup; + children = ( + 8D5B49B7048680CD000E48DA /* Info.plist */, + ); + name = Resources; + sourceTree = ""; + }; + 08FB77AFFE84173DC02AAC07 /* Classes */ = { + isa = PBXGroup; + children = ( + 1727BFCE0C1C94E90084363D /* Plugin.h */, + 1727BFCF0C1C94FD0084363D /* QuicktimePlugin.h */, + 1727BFD00C1C94FD0084363D /* QuicktimePlugin.m */, + 1727BFDB0C1C95350084363D /* QuicktimeDecoder.h */, + 1727BFDC0C1C95350084363D /* QuicktimeDecoder.m */, + 1727BFE40C1C956F0084363D /* QuicktimePropertiesReader.h */, + 1727BFE50C1C956F0084363D /* QuicktimePropertiesReader.m */, + ); + name = Classes; + sourceTree = ""; + }; + 1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = { + isa = PBXGroup; + children = ( + 1727C0BD0C1C9E180084363D /* QuickTime.framework */, + 1727C0660C1C97A00084363D /* AudioToolbox.framework */, + 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */, + ); + name = "Linked Frameworks"; + sourceTree = ""; + }; + 1058C7AEFEA557BF11CA2CBB /* Other Frameworks */ = { + isa = PBXGroup; + children = ( + 089C167FFE841241C02AAC07 /* AppKit.framework */, + D2F7E65807B2D6F200F64583 /* CoreData.framework */, + 089C1672FE841209C02AAC07 /* Foundation.framework */, + ); + name = "Other Frameworks"; + sourceTree = ""; + }; + 19C28FB8FE9D52D311CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + 8D5B49B6048680CD000E48DA /* Quicktime.bundle */, + ); + name = Products; + sourceTree = ""; + }; + 32C88E010371C26100C91783 /* Other Sources */ = { + isa = PBXGroup; + children = ( + 32DBCF630370AF2F00C91783 /* Quicktime_Prefix.pch */, + ); + name = "Other Sources"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 8D5B49AC048680CD000E48DA /* Quicktime */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1DEB913A08733D840010E9CD /* Build configuration list for PBXNativeTarget "Quicktime" */; + buildPhases = ( + 8D5B49AF048680CD000E48DA /* Resources */, + 8D5B49B1048680CD000E48DA /* Sources */, + 8D5B49B3048680CD000E48DA /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Quicktime; + productInstallPath = "$(HOME)/Library/Bundles"; + productName = Quicktime; + productReference = 8D5B49B6048680CD000E48DA /* Quicktime.bundle */; + productType = "com.apple.product-type.bundle"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 089C1669FE841209C02AAC07 /* Project object */ = { + isa = PBXProject; + buildConfigurationList = 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "Quicktime" */; + hasScannedForEncodings = 1; + mainGroup = 089C166AFE841209C02AAC07 /* Quicktime */; + projectDirPath = ""; + targets = ( + 8D5B49AC048680CD000E48DA /* Quicktime */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8D5B49AF048680CD000E48DA /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 8D5B49B1048680CD000E48DA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1727BFD10C1C94FD0084363D /* QuicktimePlugin.m in Sources */, + 1727BFDD0C1C95350084363D /* QuicktimeDecoder.m in Sources */, + 1727BFE60C1C956F0084363D /* QuicktimePropertiesReader.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 1DEB913B08733D840010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_MODEL_TUNING = G5; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = Quicktime_Prefix.pch; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(HOME)/Library/Bundles"; + PRODUCT_NAME = Quicktime; + WRAPPER_EXTENSION = bundle; + ZERO_LINK = YES; + }; + name = Debug; + }; + 1DEB913C08733D840010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = ( + ppc, + i386, + ); + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_MODEL_TUNING = G5; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = Quicktime_Prefix.pch; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(HOME)/Library/Bundles"; + PRODUCT_NAME = Quicktime; + WRAPPER_EXTENSION = bundle; + }; + name = Release; + }; + 1DEB913F08733D840010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + PREBINDING = NO; + SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; + }; + name = Debug; + }; + 1DEB914008733D840010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + PREBINDING = NO; + SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1DEB913A08733D840010E9CD /* Build configuration list for PBXNativeTarget "Quicktime" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB913B08733D840010E9CD /* Debug */, + 1DEB913C08733D840010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1DEB913E08733D840010E9CD /* Build configuration list for PBXProject "Quicktime" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB913F08733D840010E9CD /* Debug */, + 1DEB914008733D840010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 089C1669FE841209C02AAC07 /* Project object */; +} diff --git a/Plugins/Quicktime/QuicktimeDecoder.h b/Plugins/Quicktime/QuicktimeDecoder.h new file mode 100644 index 000000000..8f5df9f28 --- /dev/null +++ b/Plugins/Quicktime/QuicktimeDecoder.h @@ -0,0 +1,29 @@ +// +// QuicktimeDecoder.h +// Quicktime +// +// Created by Vincent Spader on 6/10/07. +// Copyright 2007 __MyCompanyName__. All rights reserved. +// + +#import + +#import +#import "Quicktime/Movies.h" + +#import "Plugin.h" + +@interface QuicktimeDecoder : NSObject { + AudioStreamBasicDescription _asbd; + MovieAudioExtractionRef _extractionSessionRef; + + int bitrate; + int bitsPerSample; + int channels; + float frequency; + double length; + + unsigned long _totalFrames; +} + +@end diff --git a/Plugins/Quicktime/QuicktimeDecoder.m b/Plugins/Quicktime/QuicktimeDecoder.m new file mode 100644 index 000000000..cc375c678 --- /dev/null +++ b/Plugins/Quicktime/QuicktimeDecoder.m @@ -0,0 +1,181 @@ +// +// QuicktimeDecoder.m +// Quicktime +// +// Created by Vincent Spader on 6/10/07. +// Copyright 2007 __MyCompanyName__. All rights reserved. +// + +#import "QuicktimeDecoder.h" + + +@implementation QuicktimeDecoder + +- (BOOL)open:(id)source +{ + NSLog(@"Opening!"); + + NSURL *url = [source url]; + OSErr error; + Handle dataRef; + OSType dataRefType; + Movie soundToPlay; + AudioChannelLayout* layout = nil; + UInt32 size = 0; + + NSLog(@"EnterMovies..."); + EnterMovies(); + + + NSLog(@"Creating new data reference..."); + error = QTNewDataReferenceFromCFURL((CFURLRef)url, 0, &dataRef, &dataRefType); + NSLog(@" %d",error); + + NSLog(@"Creating new movie..."); + short fileID = movieInDataForkResID; + short flags = 0; + error = NewMovieFromDataRef(&soundToPlay, flags, &fileID, dataRef, dataRefType); + NSLog(@" %d",error); + + NSLog(@"Setting movie active..."); + SetMovieActive(soundToPlay, TRUE); + + NSLog(@"Beginning extraction session..."); + error = MovieAudioExtractionBegin(soundToPlay, 0, &_extractionSessionRef); + NSLog(@" %d",error); + + NSLog(@"Getting property info..."); + error = MovieAudioExtractionGetPropertyInfo(_extractionSessionRef, + kQTPropertyClass_MovieAudioExtraction_Audio, + kQTMovieAudioExtractionAudioPropertyID_AudioChannelLayout, + NULL, &size, NULL); + NSLog(@" %d",error); + + if (error == noErr) { + // Allocate memory for the channel layout + layout = (AudioChannelLayout *) calloc(1, size); + if (layout == nil) { + error = memFullErr; + NSLog(@"Oops, out of memory"); + } + // Get the layout for the current extraction configuration. + // This will have already been expanded into channel descriptions. + NSLog(@"Getting property..."); + error = MovieAudioExtractionGetProperty(_extractionSessionRef, + kQTPropertyClass_MovieAudioExtraction_Audio, + kQTMovieAudioExtractionAudioPropertyID_AudioChannelLayout, + size, layout, nil); + NSLog(@" %d",error); + } + + NSLog(@"Getting audio stream basic description (absd)..."); + error = MovieAudioExtractionGetProperty(_extractionSessionRef, + kQTPropertyClass_MovieAudioExtraction_Audio, + kQTMovieAudioExtractionAudioPropertyID_AudioStreamBasicDescription, + sizeof (_asbd), &_asbd, nil); + NSLog(@" %d",error); + + NSLog(@" format flags = %d",_asbd.mFormatFlags); + NSLog(@" sample rate = %f",_asbd.mSampleRate); + NSLog(@" b/packet = %d",_asbd.mBytesPerPacket); + NSLog(@" f/packet = %d",_asbd.mFramesPerPacket); + NSLog(@" b/frame = %d",_asbd.mBytesPerFrame); + NSLog(@" channels/frame = %d",_asbd.mChannelsPerFrame); + NSLog(@" b/channel = %d",_asbd.mBitsPerChannel); + + if (_asbd.mChannelsPerFrame != 2) { + NSLog(@"Cannot import non-stereo audio!"); + } + + _asbd.mFormatID = kAudioFormatLinearPCM; + _asbd.mFormatFlags = kAudioFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsBigEndian; +// _asbd.mChannelsPerFrame = 2; + _asbd.mBitsPerChannel = 8*sizeof(int); + _asbd.mBytesPerFrame = (_asbd.mBitsPerChannel/8) * _asbd.mChannelsPerFrame; + _asbd.mBytesPerPacket = _asbd.mBytesPerFrame; + _asbd.mFramesPerPacket = 1; + + NSLog(@"Setting new _asbd..."); + error = MovieAudioExtractionSetProperty(_extractionSessionRef, + kQTPropertyClass_MovieAudioExtraction_Audio, + kQTMovieAudioExtractionAudioPropertyID_AudioStreamBasicDescription, + sizeof (_asbd), &_asbd); + NSLog(@" %d",error); + + + NSLog(@" format flags = %d",_asbd.mFormatFlags); + NSLog(@" sample rate = %f",_asbd.mSampleRate); + NSLog(@" b/packet = %d",_asbd.mBytesPerPacket); + NSLog(@" f/packet = %d",_asbd.mFramesPerPacket); + NSLog(@" b/frame = %d",_asbd.mBytesPerFrame); + NSLog(@" channels/frame = %d",_asbd.mChannelsPerFrame); + NSLog(@" b/channel = %d",_asbd.mBitsPerChannel); + + _totalFrames = _asbd.mSampleRate * ((float) GetMovieDuration(soundToPlay) / (float) GetMovieTimeScale(soundToPlay)); + + [self willChangeValueForKey:@"properties"]; + [self didChangeValueForKey:@"properties"]; + + return YES; +} + +- (int) fillBuffer:(void *)buf ofSize:(UInt32)size +{ + OSErr error; + UInt32 extractionFlags = 0; + AudioBufferList buffer; + UInt32 numFrames = size / _asbd.mBytesPerFrame; + + buffer.mNumberBuffers = 1; + buffer.mBuffers[0].mNumberChannels = _asbd.mChannelsPerFrame; + buffer.mBuffers[0].mDataByteSize = size; + + buffer.mBuffers[0].mData = buf; + + error = MovieAudioExtractionFillBuffer(_extractionSessionRef, &numFrames, &buffer, &extractionFlags); + if (error) { + NSLog(@" %d",error); + NSLog(@" Extraction flags = %d (complete? %d)",extractionFlags,kQTMovieAudioExtractionComplete); + } + + return numFrames * _asbd.mBytesPerFrame; +} + +- (void)close +{ + OSErr error; + + NSLog(@"Ending extraction session..."); + error = MovieAudioExtractionEnd(_extractionSessionRef); + NSLog(@" %d",error); + + NSLog(@"ExitMovies..."); + ExitMovies(); +} + +- (double) seekToTime:(double)milliseconds +{ + return 0.0; +} + ++ (NSArray *)fileTypes +{ + return [NSArray arrayWithObjects:@"m4a",nil]; +} + +- (NSDictionary *)properties +{ + return [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithInt:_asbd.mChannelsPerFrame],@"channels", + [NSNumber numberWithInt:_asbd.mBitsPerChannel],@"bitsPerSample", + [NSNumber numberWithInt:0],@"bitrate", + [NSNumber numberWithFloat:_asbd.mSampleRate],@"sampleRate", + [NSNumber numberWithDouble:_totalFrames/(_asbd.mSampleRate/1000.0)],@"length", + [NSNumber numberWithBool:NO], @"seekable", + @"big", @"endian", + nil]; +} + + + +@end diff --git a/Plugins/Quicktime/QuicktimePlugin.h b/Plugins/Quicktime/QuicktimePlugin.h new file mode 100644 index 000000000..0dc5019cc --- /dev/null +++ b/Plugins/Quicktime/QuicktimePlugin.h @@ -0,0 +1,16 @@ +// +// QuicktimePlugin.h +// Quicktime +// +// Created by Vincent Spader on 6/10/07. +// Copyright 2007 __MyCompanyName__. All rights reserved. +// + +#import +#import "Plugin.h" + +@interface QuicktimePlugin : NSObject { + +} + +@end diff --git a/Plugins/Quicktime/QuicktimePlugin.m b/Plugins/Quicktime/QuicktimePlugin.m new file mode 100644 index 000000000..639e238c7 --- /dev/null +++ b/Plugins/Quicktime/QuicktimePlugin.m @@ -0,0 +1,24 @@ +// +// QuicktimePlugin.m +// Quicktime +// +// Created by Vincent Spader on 6/10/07. +// Copyright 2007 __MyCompanyName__. All rights reserved. +// + +#import "QuicktimePlugin.h" +#import "QuicktimeDecoder.h" +#import "QuicktimePropertiesReader.h" + +@implementation QuicktimePlugin + ++ (NSDictionary *)pluginInfo +{ + return [NSDictionary dictionaryWithObjectsAndKeys: + kCogDecoder, [QuicktimeDecoder className], + kCogPropertiesReader, [QuicktimePropertiesReader className], + nil + ]; +} + +@end diff --git a/Plugins/Quicktime/QuicktimePropertiesReader.h b/Plugins/Quicktime/QuicktimePropertiesReader.h new file mode 100644 index 000000000..9a457c24f --- /dev/null +++ b/Plugins/Quicktime/QuicktimePropertiesReader.h @@ -0,0 +1,16 @@ +// +// QuicktimePropertiesReader.h +// Quicktime +// +// Created by Vincent Spader on 6/10/07. +// Copyright 2007 __MyCompanyName__. All rights reserved. +// + +#import +#import "Plugin.h" + +@interface QuicktimePropertiesReader : NSObject { + +} + +@end diff --git a/Plugins/Quicktime/QuicktimePropertiesReader.m b/Plugins/Quicktime/QuicktimePropertiesReader.m new file mode 100644 index 000000000..ffa952bcd --- /dev/null +++ b/Plugins/Quicktime/QuicktimePropertiesReader.m @@ -0,0 +1,40 @@ +// +// QuicktimePropertiesReader.m +// Quicktime +// +// Created by Vincent Spader on 6/10/07. +// Copyright 2007 __MyCompanyName__. All rights reserved. +// + +#import "QuicktimePropertiesReader.h" +#import "QuicktimeDecoder.h" + +@implementation QuicktimePropertiesReader + + ++ (NSDictionary *)propertiesForSource:(id)source +{ + NSDictionary *properties; + QuicktimeDecoder *decoder; + + decoder = [[QuicktimeDecoder alloc] init]; + if (![decoder open:source]) + { + return nil; + } + + properties = [decoder properties]; + + [decoder close]; + + return properties; +} + + ++ (NSArray *)fileTypes +{ + return [QuicktimeDecoder fileTypes]; +} + + +@end diff --git a/Plugins/Quicktime/Quicktime_Prefix.pch b/Plugins/Quicktime/Quicktime_Prefix.pch new file mode 100644 index 000000000..9ff5f96e9 --- /dev/null +++ b/Plugins/Quicktime/Quicktime_Prefix.pch @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'Quicktime' target in the 'Quicktime' project. +// + +#ifdef __OBJC__ + #import +#endif