forked from tumtumtum/StreamingKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated STKHttpDataSource to support dynamically generated URLs with …
…each 'open' or 'seek')
- Loading branch information
Showing
8 changed files
with
71 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,30 +36,56 @@ This product includes software developed by Thong Nguyen ([email protected]) | |
#import "STKLocalFileDataSource.h" | ||
|
||
@interface STKHttpDataSource() | ||
{ | ||
@private | ||
int seekStart; | ||
int relativePosition; | ||
long long fileLength; | ||
int discontinuous; | ||
NSURL* currentUrl; | ||
URLProvider urlProvider; | ||
NSDictionary* httpHeaders; | ||
AudioFileTypeID audioFileTypeHint; | ||
} | ||
-(void) open; | ||
|
||
@end | ||
|
||
@implementation STKHttpDataSource | ||
@synthesize url; | ||
|
||
-(id) initWithURL:(NSURL*)urlIn | ||
{ | ||
return [self initWithURLProvider:^NSURL* { return urlIn; }]; | ||
} | ||
|
||
-(id) initWithURLProvider:(URLProvider)urlProviderIn | ||
{ | ||
if (self = [super init]) | ||
{ | ||
seekStart = 0; | ||
relativePosition = 0; | ||
fileLength = -1; | ||
|
||
self.url = urlIn; | ||
self->urlProvider = urlProviderIn; | ||
|
||
[self open]; | ||
|
||
audioFileTypeHint = [STKLocalFileDataSource audioFileTypeHintFromFileExtension:urlIn.pathExtension]; | ||
audioFileTypeHint = [STKLocalFileDataSource audioFileTypeHintFromFileExtension:self->currentUrl.pathExtension]; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
-(void) dealloc | ||
{ | ||
NSLog(@"STKHttpDataSource dealloc"); | ||
} | ||
|
||
-(NSURL*) url | ||
{ | ||
return self->currentUrl; | ||
} | ||
|
||
+(AudioFileTypeID) audioFileTypeHintFromMimeType:(NSString*)mimeType | ||
{ | ||
static dispatch_once_t onceToken; | ||
|
@@ -192,6 +218,8 @@ -(int) readIntoBuffer:(UInt8*)buffer withSize:(int)size | |
|
||
-(void) open | ||
{ | ||
self->currentUrl = urlProvider(); | ||
|
||
CFHTTPMessageRef message = CFHTTPMessageCreateRequest(NULL, (CFStringRef)@"GET", (__bridge CFURLRef)self.url, kCFHTTPVersion1_1); | ||
|
||
if (seekStart > 0) | ||
|
@@ -225,7 +253,7 @@ -(void) open | |
|
||
// SSL support | ||
|
||
if ([url.scheme caseInsensitiveCompare:@"https"] == NSOrderedSame) | ||
if ([self->currentUrl.scheme caseInsensitiveCompare:@"https"] == NSOrderedSame) | ||
{ | ||
NSDictionary* sslSettings = [NSDictionary dictionaryWithObjectsAndKeys: | ||
(NSString*)kCFStreamSocketSecurityLevelNegotiatedSSL, kCFStreamSSLLevel, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,8 +35,12 @@ This product includes software developed by Thong Nguyen ([email protected]) | |
#import "STKLocalFileDataSource.h" | ||
|
||
@interface STKLocalFileDataSource() | ||
{ | ||
long long position; | ||
long long length; | ||
AudioFileTypeID audioFileTypeHint; | ||
} | ||
@property (readwrite, copy) NSString* filePath; | ||
|
||
-(void) open; | ||
@end | ||
|
||
|