Compare commits

...

5 Commits

Author SHA1 Message Date
Thong Nguyen 93e6f4b6d9 Fix namings of DataSources (added STK prefixes) 2014-01-20 22:30:35 +00:00
Thong Nguyen 9ed755cda4 Added kAudioFileAAC_ADTSType support 2014-01-20 21:11:00 +00:00
Thong Nguyen 7cc3f85a59 Fix README wiki link 2014-01-20 20:54:34 +00:00
Thong Nguyen a93d6867c5 Made the SampleApp support background playback. Updated README to point to wiki for background playbackr 2014-01-20 20:53:55 +00:00
Thong Nguyen 4660f0ce80 Fixed hard coded library search path in ExampleApp project 2014-01-20 19:22:48 +00:00
18 changed files with 92 additions and 90 deletions
@@ -402,10 +402,6 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "ExampleApp/ExampleApp-Prefix.pch";
INFOPLIST_FILE = "ExampleApp/ExampleApp-Info.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/StreamingKit-dabtccqthoyywldsgcvllbcjcmma/Build/Products/Debug-iphoneos",
);
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
@@ -419,10 +415,6 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "ExampleApp/ExampleApp-Prefix.pch";
INFOPLIST_FILE = "ExampleApp/ExampleApp-Info.plist";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/StreamingKit-dabtccqthoyywldsgcvllbcjcmma/Build/Products/Debug-iphoneos",
);
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
+5
View File
@@ -10,6 +10,7 @@
#import "STKAudioPlayer.h"
#import "AudioPlayerView.h"
#import "SampleQueueId.h"
#import <AVFoundation/AVFoundation.h>
@interface AppDelegate()
{
@@ -22,6 +23,10 @@
-(BOOL) application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
NSError* error;
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&error];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
@@ -24,6 +24,10 @@
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
+2 -2
View File
@@ -36,9 +36,9 @@ audioPlayer.delegate = self;
```
## Background Playback
## More
Background playback on iOS is easily added to your application by calling the `AudioSessionInitialize` in your AppDelegate and adding audio to the `UIBackgroundModes` key in your plist file.
More documentation is available on the project [wiki](https://github.com/tumtumtum/StreamingKit/wiki)
### Authors and Contributors
Copyright (c) 2012-2014, Thong Nguyen (@tumtumtum)
@@ -5,36 +5,36 @@
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>A5188B80-95E0-46CF-BEC9-273724D5616A</string>
<string>64C9BE2D-7DAD-476A-B9AC-1C4603CD4124</string>
<key>IDESourceControlProjectName</key>
<string>StreamingKit</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>821E27F3-2BD4-4B06-BB39-F4C3ECC1BBAD</key>
<string>https://github.com/tumtumtum/audjustable.git</string>
<key>DD310C30-B3D0-4BD7-9565-9F29F09CC4F8</key>
<string>https://github.com/tumtumtum/StreamingKit.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>StreamingKit.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>821E27F3-2BD4-4B06-BB39-F4C3ECC1BBAD</key>
<key>DD310C30-B3D0-4BD7-9565-9F29F09CC4F8</key>
<string>..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>https://github.com/tumtumtum/audjustable.git</string>
<string>https://github.com/tumtumtum/StreamingKit.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>821E27F3-2BD4-4B06-BB39-F4C3ECC1BBAD</string>
<string>DD310C30-B3D0-4BD7-9565-9F29F09CC4F8</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>821E27F3-2BD4-4B06-BB39-F4C3ECC1BBAD</string>
<string>DD310C30-B3D0-4BD7-9565-9F29F09CC4F8</string>
<key>IDESourceControlWCCName</key>
<string>audjustable</string>
<string>StreamingKit</string>
</dict>
</array>
</dict>
+3 -3
View File
@@ -194,10 +194,10 @@ AudioQueueBufferRefLookupEntry;
-(id) init;
-(id) initWithNumberOfAudioQueueBuffers:(int)numberOfAudioQueueBuffers andReadBufferSize:(int)readBufferSizeIn;
-(DataSource*) dataSourceFromURL:(NSURL*)url;
-(STKDataSource*) dataSourceFromURL:(NSURL*)url;
-(void) play:(NSURL*)url;
-(void) queueDataSource:(DataSource*)dataSource withQueueItemId:(NSObject*)queueItemId;
-(void) setDataSource:(DataSource*)dataSourceIn withQueueItemId:(NSObject*)queueItemId;
-(void) queueDataSource:(STKDataSource*)dataSource withQueueItemId:(NSObject*)queueItemId;
-(void) setDataSource:(STKDataSource*)dataSourceIn withQueueItemId:(NSObject*)queueItemId;
-(void) seekToTime:(double)value;
-(void) pause;
-(void) resume;
+15 -15
View File
@@ -114,7 +114,7 @@
AudioStreamBasicDescription audioStreamBasicDescription;
}
@property (readwrite, retain) NSObject* queueItemId;
@property (readwrite, retain) DataSource* dataSource;
@property (readwrite, retain) STKDataSource* dataSource;
@property (readwrite) int bufferIndex;
@property (readonly) UInt64 audioDataLengthInBytes;
@@ -122,20 +122,20 @@
-(double) calculatedBitRate;
-(double) progress;
-(id) initWithDataSource:(DataSource*)dataSource andQueueItemId:(NSObject*)queueItemId;
-(id) initWithDataSource:(DataSource*)dataSource andQueueItemId:(NSObject*)queueItemId andBufferIndex:(int)bufferIndex;
-(id) initWithDataSource:(STKDataSource*)dataSource andQueueItemId:(NSObject*)queueItemId;
-(id) initWithDataSource:(STKDataSource*)dataSource andQueueItemId:(NSObject*)queueItemId andBufferIndex:(int)bufferIndex;
@end
@implementation QueueEntry
@synthesize dataSource, queueItemId, bufferIndex;
-(id) initWithDataSource:(DataSource*)dataSourceIn andQueueItemId:(NSObject*)queueItemIdIn
-(id) initWithDataSource:(STKDataSource*)dataSourceIn andQueueItemId:(NSObject*)queueItemIdIn
{
return [self initWithDataSource:dataSourceIn andQueueItemId:queueItemIdIn andBufferIndex:-1];
}
-(id) initWithDataSource:(DataSource*)dataSourceIn andQueueItemId:(NSObject*)queueItemIdIn andBufferIndex:(int)bufferIndexIn
-(id) initWithDataSource:(STKDataSource*)dataSourceIn andQueueItemId:(NSObject*)queueItemIdIn andBufferIndex:(int)bufferIndexIn
{
if (self = [super init])
{
@@ -500,17 +500,17 @@ static void AudioQueueIsRunningCallbackProc(void* userData, AudioQueueRef audioQ
#endif
}
-(DataSource*) dataSourceFromURL:(NSURL*)url
-(STKDataSource*) dataSourceFromURL:(NSURL*)url
{
DataSource* retval;
STKDataSource* retval;
if ([url.scheme isEqualToString:@"file"])
{
retval = [[LocalFileDataSource alloc] initWithFilePath:url.path];
retval = [[STKLocalFileDataSource alloc] initWithFilePath:url.path];
}
else
{
retval = [[HttpDataSource alloc] initWithURL:url];
retval = [[STKHttpDataSource alloc] initWithURL:url];
}
return retval;
@@ -557,7 +557,7 @@ static void AudioQueueIsRunningCallbackProc(void* userData, AudioQueueRef audioQ
[self setDataSource:[self dataSourceFromURL:url] withQueueItemId:url];
}
-(void) setDataSource:(DataSource*)dataSourceIn withQueueItemId:(NSObject*)queueItemId
-(void) setDataSource:(STKDataSource*)dataSourceIn withQueueItemId:(NSObject*)queueItemId
{
[fastApiQueue cancelAllOperations];
@@ -578,7 +578,7 @@ static void AudioQueueIsRunningCallbackProc(void* userData, AudioQueueRef audioQ
}];
}
-(void) queueDataSource:(DataSource*)dataSourceIn withQueueItemId:(NSObject*)queueItemId
-(void) queueDataSource:(STKDataSource*)dataSourceIn withQueueItemId:(NSObject*)queueItemId
{
[fastApiQueue addOperationWithBlock:^
{
@@ -774,7 +774,7 @@ static void AudioQueueIsRunningCallbackProc(void* userData, AudioQueueRef audioQ
}
AudioQueueBufferRef bufferToFill = audioQueueBuffer[fillBufferIndex];
memcpy((char*)bufferToFill->mAudioData + bytesFilled, (const char*)inputData + packetOffset, packetSize);
memcpy((char*)bufferToFill->mAudioData + bytesFilled, (const char*)inputData + packetOffset, (unsigned long)packetSize);
packetDescs[packetsFilled] = packetDescriptionsIn[i];
packetDescs[packetsFilled].mStartOffset = bytesFilled;
@@ -1926,7 +1926,7 @@ static void AudioQueueIsRunningCallbackProc(void* userData, AudioQueueRef audioQ
pthread_mutex_unlock(&queueBuffersMutex);
}
-(void) dataSourceDataAvailable:(DataSource*)dataSourceIn
-(void) dataSourceDataAvailable:(STKDataSource*)dataSourceIn
{
OSStatus error;
@@ -1989,7 +1989,7 @@ static void AudioQueueIsRunningCallbackProc(void* userData, AudioQueueRef audioQ
}
}
-(void) dataSourceErrorOccured:(DataSource*)dataSourceIn
-(void) dataSourceErrorOccured:(STKDataSource*)dataSourceIn
{
if (currentlyReadingEntry.dataSource != dataSourceIn)
{
@@ -1999,7 +1999,7 @@ static void AudioQueueIsRunningCallbackProc(void* userData, AudioQueueRef audioQ
[self didEncounterError:AudioPlayerErrorDataNotFound];
}
-(void) dataSourceEof:(DataSource*)dataSourceIn
-(void) dataSourceEof:(STKDataSource*)dataSourceIn
{
if (currentlyReadingEntry.dataSource != dataSourceIn)
{
@@ -36,10 +36,10 @@
#import "STKHttpDataSource.h"
#import "STKDataSourceWrapper.h"
@interface STKAutoRecoveringHttpDataSource : DataSourceWrapper
@interface STKAutoRecoveringHttpDataSource : STKDataSourceWrapper
-(id) initWithHttpDataSource:(HttpDataSource*)innerDataSource;
-(id) initWithHttpDataSource:(STKHttpDataSource*)innerDataSource;
@property (readonly) HttpDataSource* innerDataSource;
@property (readonly) STKHttpDataSource* innerDataSource;
@end
@@ -68,12 +68,12 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach
@implementation STKAutoRecoveringHttpDataSource
-(HttpDataSource*) innerHttpDataSource
-(STKHttpDataSource*) innerHttpDataSource
{
return (HttpDataSource*)self.innerDataSource;
return (STKHttpDataSource*)self.innerDataSource;
}
-(id) initWithHttpDataSource:(HttpDataSource*)innerDataSourceIn
-(id) initWithHttpDataSource:(STKHttpDataSource*)innerDataSourceIn
{
if (self = [super initWithDataSource:innerDataSourceIn])
{
@@ -165,7 +165,7 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach
}
}
-(void) dataSourceDataAvailable:(DataSource*)dataSource
-(void) dataSourceDataAvailable:(STKDataSource*)dataSource
{
reconnectAttempts = 0;
@@ -202,7 +202,7 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach
}
}
-(void) dataSourceEof:(DataSource*)dataSource
-(void) dataSourceEof:(STKDataSource*)dataSource
{
if ([self position] != [self length])
{
@@ -214,7 +214,7 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach
[self.delegate dataSourceEof:self];
}
-(void) dataSourceErrorOccured:(DataSource*)dataSource
-(void) dataSourceErrorOccured:(STKDataSource*)dataSource
{
if (self.innerDataSource.httpStatusCode == 416 /* Range out of bounds */)
{
@@ -41,7 +41,7 @@
@property (readwrite, retain) STKCoreFoundationDataSource* datasource;
@end
@interface STKCoreFoundationDataSource : DataSource
@interface STKCoreFoundationDataSource : STKDataSource
{
@protected
CFReadStreamRef stream;
+5 -5
View File
@@ -35,12 +35,12 @@
#import <Foundation/Foundation.h>
#include <AudioToolbox/AudioToolbox.h>
@class DataSource;
@class STKDataSource;
@protocol STKDataSourceDelegate<NSObject>
-(void) dataSourceDataAvailable:(DataSource*)dataSource;
-(void) dataSourceErrorOccured:(DataSource*)dataSource;
-(void) dataSourceEof:(DataSource*)dataSource;
-(void) dataSourceDataAvailable:(STKDataSource*)dataSource;
-(void) dataSourceErrorOccured:(STKDataSource*)dataSource;
-(void) dataSourceEof:(STKDataSource*)dataSource;
@end
@protocol AudioDataSource<NSObject>
@@ -48,7 +48,7 @@
@property (readwrite) long long audioDataOffset;
@end
@interface DataSource : NSObject
@interface STKDataSource : NSObject
@property (readonly) long long position;
@property (readonly) long long length;
+1 -1
View File
@@ -34,7 +34,7 @@
#import "STKDataSource.h"
@implementation DataSource
@implementation STKDataSource
@synthesize delegate;
-(long long) length
@@ -34,10 +34,10 @@
#import "STKDataSource.h"
@interface DataSourceWrapper : DataSource<STKDataSourceDelegate>
@interface STKDataSourceWrapper : STKDataSource<STKDataSourceDelegate>
-(id) initWithDataSource:(DataSource*)innerDataSource;
-(id) initWithDataSource:(STKDataSource*)innerDataSource;
@property (readonly) DataSource* innerDataSource;
@property (readonly) STKDataSource* innerDataSource;
@end
@@ -34,13 +34,13 @@
#import "STKDataSourceWrapper.h"
@interface DataSourceWrapper()
@property (readwrite) DataSource* innerDataSource;
@interface STKDataSourceWrapper()
@property (readwrite) STKDataSource* innerDataSource;
@end
@implementation DataSourceWrapper
@implementation STKDataSourceWrapper
-(id) initWithDataSource:(DataSource*)innerDataSourceIn
-(id) initWithDataSource:(STKDataSource*)innerDataSourceIn
{
if (self = [super init])
{
@@ -102,17 +102,17 @@
return self.innerDataSource.hasBytesAvailable;
}
-(void) dataSourceDataAvailable:(DataSource*)dataSource
-(void) dataSourceDataAvailable:(STKDataSource*)dataSource
{
[self.delegate dataSourceDataAvailable:self];
}
-(void) dataSourceErrorOccured:(DataSource*)dataSource
-(void) dataSourceErrorOccured:(STKDataSource*)dataSource
{
[self.delegate dataSourceErrorOccured:self];
}
-(void) dataSourceEof:(DataSource*)dataSource
-(void) dataSourceEof:(STKDataSource*)dataSource
{
[self.delegate dataSourceEof:self];
}
@@ -34,7 +34,7 @@
#import "STKCoreFoundationDataSource.h"
@interface HttpDataSource : STKCoreFoundationDataSource
@interface STKHttpDataSource : STKCoreFoundationDataSource
{
@private
int seekStart;
+24 -23
View File
@@ -35,11 +35,11 @@
#import "STKHttpDataSource.h"
#import "STKLocalFileDataSource.h"
@interface HttpDataSource()
@interface STKHttpDataSource()
-(void) open;
@end
@implementation HttpDataSource
@implementation STKHttpDataSource
@synthesize url;
-(id) initWithURL:(NSURL*)urlIn
@@ -54,7 +54,7 @@
[self open];
audioFileTypeHint = [LocalFileDataSource audioFileTypeHintFromFileExtension:urlIn.pathExtension];
audioFileTypeHint = [STKLocalFileDataSource audioFileTypeHintFromFileExtension:urlIn.pathExtension];
}
return self;
@@ -66,25 +66,26 @@
static NSDictionary* fileTypesByMimeType;
dispatch_once(&onceToken, ^
{
fileTypesByMimeType =
@{
@"audio/mp3": @(kAudioFileMP3Type),
@"audio/mpg": @(kAudioFileMP3Type),
@"audio/mpeg": @(kAudioFileMP3Type),
@"audio/wav": @(kAudioFileWAVEType),
@"audio/aifc": @(kAudioFileAIFCType),
@"audio/aiff": @(kAudioFileAIFFType),
@"audio/x-m4a": @(kAudioFileM4AType),
@"audio/x-mp4": @(kAudioFileMPEG4Type),
@"audio/m4a": @(kAudioFileM4AType),
@"audio/mp4": @(kAudioFileMPEG4Type),
@"audio/caf": @(kAudioFileCAFType),
@"audio/aac": @(kAudioFileAAC_ADTSType),
@"audio/ac3": @(kAudioFileAC3Type),
@"audio/3gp": @(kAudioFile3GPType)
};
});
{
fileTypesByMimeType =
@{
@"audio/mp3": @(kAudioFileMP3Type),
@"audio/mpg": @(kAudioFileMP3Type),
@"audio/mpeg": @(kAudioFileMP3Type),
@"audio/wav": @(kAudioFileWAVEType),
@"audio/aifc": @(kAudioFileAIFCType),
@"audio/aiff": @(kAudioFileAIFFType),
@"audio/x-m4a": @(kAudioFileM4AType),
@"audio/x-mp4": @(kAudioFileMPEG4Type),
@"audio/aacp": @(kAudioFileAAC_ADTSType),
@"audio/m4a": @(kAudioFileM4AType),
@"audio/mp4": @(kAudioFileMPEG4Type),
@"audio/caf": @(kAudioFileCAFType),
@"audio/aac": @(kAudioFileAAC_ADTSType),
@"audio/ac3": @(kAudioFileAC3Type),
@"audio/3gp": @(kAudioFile3GPType)
};
});
NSNumber* number = [fileTypesByMimeType objectForKey:mimeType];
@@ -121,7 +122,7 @@
}
NSString* contentType = [httpHeaders objectForKey:@"Content-Type"];
AudioFileTypeID typeIdFromMimeType = [HttpDataSource audioFileTypeHintFromMimeType:contentType];
AudioFileTypeID typeIdFromMimeType = [STKHttpDataSource audioFileTypeHintFromMimeType:contentType];
if (typeIdFromMimeType != 0)
{
@@ -34,7 +34,7 @@
#import "STKCoreFoundationDataSource.h"
@interface LocalFileDataSource : STKCoreFoundationDataSource
@interface STKLocalFileDataSource : STKCoreFoundationDataSource
{
@private
long long position;
@@ -34,13 +34,13 @@
#import "STKLocalFileDataSource.h"
@interface LocalFileDataSource()
@interface STKLocalFileDataSource()
@property (readwrite, copy) NSString* filePath;
-(void) open;
@end
@implementation LocalFileDataSource
@implementation STKLocalFileDataSource
@synthesize filePath;
-(id) initWithFilePath:(NSString*)filePathIn
@@ -51,7 +51,7 @@
[self open];
audioFileTypeHint = [LocalFileDataSource audioFileTypeHintFromFileExtension:filePathIn.pathExtension];
audioFileTypeHint = [STKLocalFileDataSource audioFileTypeHintFromFileExtension:filePathIn.pathExtension];
}
return self;