Permalink
Browse files

another change to make sure testing of YouTube video variants times o…

…ut after 10 seconds

Signed-off-by: Jonathan 'Wolf' Rentzsch <jwr.git@redshed.net>
  • Loading branch information...
1 parent 97ec6c1 commit cf7d286ed7b81552e2a60b8939b38802548cb39f Simone Manganelli committed with Jul 15, 2009
Showing with 26 additions and 12 deletions.
  1. +12 −3 Plugin/CTFURLConnection.m
  2. +14 −9 Plugin/Plugin.m
View
@@ -11,6 +11,14 @@
@implementation CTFURLConnection
+- (id)init;
+{
+ if ((self = [super init])) {
+ responseToReturn = nil;
+ }
+
+ return self;
+}
- (NSHTTPURLResponse *)getURLResponseHeaders:(NSURL *)URL
error:(NSError **)error;
@@ -35,7 +43,7 @@ - (NSHTTPURLResponse *)getURLResponseHeaders:(NSURL *)URL
[NSThread detachNewThreadSelector:@selector(startRequest:) toTarget:self withObject:request];
[request release];
- [theLock lockWhenCondition:1];
+ [theLock lockWhenCondition:1 beforeDate:[NSDate dateWithTimeIntervalSinceNow:10]];
if (error) (*error) = errorToReturn;
return [responseToReturn autorelease];
@@ -57,6 +65,7 @@ - (void)startRequest:(NSURLRequest *)request;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[request retain];
+ NSLog(@"Connection is starting immediately.");
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request
delegate:self
startImmediately:YES];
@@ -70,7 +79,7 @@ - (void)startRequest:(NSURLRequest *)request;
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error;
{
-
+ NSLog(@"Connection failed with error: %@",error);
[theLock tryLock];
errorToReturn = error;
@@ -93,7 +102,7 @@ - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSHTTPURLRe
- (void)connectionDidFinishLoading:(NSURLConnection *)connection;
{
-
+ NSLog(@"Connection did finish loading.");
[theLock tryLock];
[theLock unlockWithCondition:1];
View
@@ -1099,22 +1099,27 @@ - (void) _checkForH264VideoVariants
error:&error];
[theConnection release];
- int statusCode = [H264Response statusCode];
-
- // 206 status code means partial content has been delivered, because of the
- // range header, 200 means the request was OK
- if ( ((statusCode == 206) || (statusCode == 200)) && (! error) ) {
- [self _setHasH264Version:YES];
+ int statusCode = 0;
+ if (H264Response) {
+ statusCode = [H264Response statusCode];
+
+ // 206 status code means partial content has been delivered, because of the
+ // range header, 200 means the request was OK
+ if ( ((statusCode == 206) || (statusCode == 200)) && (! error) ) {
+ [self _setHasH264Version:YES];
+ }
}
CTFURLConnection *connectionTwo = [[CTFURLConnection alloc] init];
NSHTTPURLResponse *HDH264Response = [connectionTwo getURLResponseHeaders:[NSURL URLWithString:HDSrc]
error:&error];
[connectionTwo release];
- statusCode = [HDH264Response statusCode];
- if ( ((statusCode == 206) || (statusCode == 200)) && (! error) ) {
- [self _setHasHDH264Version:YES];
+ if (HDH264Response) {
+ statusCode = [HDH264Response statusCode];
+ if ( ((statusCode == 206) || (statusCode == 200)) && (! error) ) {
+ [self _setHasHDH264Version:YES];
+ }
}
// this is here because the user may have already opened the contextual

0 comments on commit cf7d286

Please sign in to comment.