Added Quicktime plugin.

CQTexperiment
vspader 2007-06-10 21:34:20 +00:00
parent b9671481bf
commit 4ddc98ee14
10 changed files with 613 additions and 2 deletions

View File

@ -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 = "<group>"; };
171B57DB0C091F2B00F6AFAF /* mp3.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = mp3.icns; sourceTree = "<group>"; };
171B57DC0C091F2B00F6AFAF /* ogg.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = ogg.icns; sourceTree = "<group>"; };
1727C1710C1CA0D40084363D /* Quicktime.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = Quicktime.bundle; path = Plugins/Quicktime/build/Debug/Quicktime.bundle; sourceTree = "<group>"; };
1755E1F60BA0D2B600CA3560 /* PlaylistLoader.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PlaylistLoader.h; sourceTree = "<group>"; };
1755E1F70BA0D2B600CA3560 /* PlaylistLoader.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = PlaylistLoader.m; sourceTree = "<group>"; };
1766C68E0B911DF1004A7AE4 /* AudioScrobbler.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = AudioScrobbler.h; sourceTree = "<group>"; };
@ -547,6 +548,7 @@
17B619FF0B909ED400BC003F /* PlugIns */ = {
isa = PBXGroup;
children = (
1727C1710C1CA0D40084363D /* Quicktime.bundle */,
8E2B8F5E0B9B62F800F2D9E8 /* WavPack.bundle */,
17ADB65C0B97A96400257CA2 /* HTTPSource.bundle */,
17ADB4450B979C5700257CA2 /* FileSource.bundle */,

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.yourcocoabundle</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>NSPrincipalClass</key>
<string>QuicktimePlugin</string>
</dict>
</plist>

View File

@ -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 = "<absolute>"; };
089C167FFE841241C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
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 = "<group>"; };
1727BFD00C1C94FD0084363D /* QuicktimePlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QuicktimePlugin.m; sourceTree = "<group>"; };
1727BFDB0C1C95350084363D /* QuicktimeDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuicktimeDecoder.h; sourceTree = "<group>"; };
1727BFDC0C1C95350084363D /* QuicktimeDecoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QuicktimeDecoder.m; sourceTree = "<group>"; };
1727BFE40C1C956F0084363D /* QuicktimePropertiesReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuicktimePropertiesReader.h; sourceTree = "<group>"; };
1727BFE50C1C956F0084363D /* QuicktimePropertiesReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QuicktimePropertiesReader.m; sourceTree = "<group>"; };
1727C0660C1C97A00084363D /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = /System/Library/Frameworks/AudioToolbox.framework; sourceTree = "<absolute>"; };
1727C0BD0C1C9E180084363D /* QuickTime.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickTime.framework; path = /System/Library/Frameworks/QuickTime.framework; sourceTree = "<absolute>"; };
32DBCF630370AF2F00C91783 /* Quicktime_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Quicktime_Prefix.pch; sourceTree = "<group>"; };
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 = "<group>"; };
D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
/* 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 = "<group>";
};
089C1671FE841209C02AAC07 /* Frameworks and Libraries */ = {
isa = PBXGroup;
children = (
1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */,
1058C7AEFEA557BF11CA2CBB /* Other Frameworks */,
);
name = "Frameworks and Libraries";
sourceTree = "<group>";
};
089C167CFE841241C02AAC07 /* Resources */ = {
isa = PBXGroup;
children = (
8D5B49B7048680CD000E48DA /* Info.plist */,
);
name = Resources;
sourceTree = "<group>";
};
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 = "<group>";
};
1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = {
isa = PBXGroup;
children = (
1727C0BD0C1C9E180084363D /* QuickTime.framework */,
1727C0660C1C97A00084363D /* AudioToolbox.framework */,
1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */,
);
name = "Linked Frameworks";
sourceTree = "<group>";
};
1058C7AEFEA557BF11CA2CBB /* Other Frameworks */ = {
isa = PBXGroup;
children = (
089C167FFE841241C02AAC07 /* AppKit.framework */,
D2F7E65807B2D6F200F64583 /* CoreData.framework */,
089C1672FE841209C02AAC07 /* Foundation.framework */,
);
name = "Other Frameworks";
sourceTree = "<group>";
};
19C28FB8FE9D52D311CA2CBB /* Products */ = {
isa = PBXGroup;
children = (
8D5B49B6048680CD000E48DA /* Quicktime.bundle */,
);
name = Products;
sourceTree = "<group>";
};
32C88E010371C26100C91783 /* Other Sources */ = {
isa = PBXGroup;
children = (
32DBCF630370AF2F00C91783 /* Quicktime_Prefix.pch */,
);
name = "Other Sources";
sourceTree = "<group>";
};
/* 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 */;
}

View File

@ -0,0 +1,29 @@
//
// QuicktimeDecoder.h
// Quicktime
//
// Created by Vincent Spader on 6/10/07.
// Copyright 2007 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import <AudioToolbox/AudioToolbox.h>
#import "Quicktime/Movies.h"
#import "Plugin.h"
@interface QuicktimeDecoder : NSObject <CogDecoder> {
AudioStreamBasicDescription _asbd;
MovieAudioExtractionRef _extractionSessionRef;
int bitrate;
int bitsPerSample;
int channels;
float frequency;
double length;
unsigned long _totalFrames;
}
@end

View File

@ -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<CogSource>)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

View File

@ -0,0 +1,16 @@
//
// QuicktimePlugin.h
// Quicktime
//
// Created by Vincent Spader on 6/10/07.
// Copyright 2007 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "Plugin.h"
@interface QuicktimePlugin : NSObject <CogPlugin> {
}
@end

View File

@ -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

View File

@ -0,0 +1,16 @@
//
// QuicktimePropertiesReader.h
// Quicktime
//
// Created by Vincent Spader on 6/10/07.
// Copyright 2007 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "Plugin.h"
@interface QuicktimePropertiesReader : NSObject <CogPropertiesReader> {
}
@end

View File

@ -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<CogSource>)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

View File

@ -0,0 +1,7 @@
//
// Prefix header for all source files of the 'Quicktime' target in the 'Quicktime' project.
//
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif