Created
February 22, 2016 09:47
-
-
Save crowjdh/486589c1530c6195af4b to your computer and use it in GitHub Desktop.
Set HTTP header information to FFmpeg avformat_open_input function in iOS
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
- (AVDictionary*) createAVFormatContextOptions: (NSDictionary*)dict | |
{ | |
AVDictionary *options = NULL; | |
for (NSString* keyString in dict) { | |
av_dict_set(&options, [keyString UTF8String], [[dict objectForKey:keyString] UTF8String], 0); | |
} | |
return options; | |
} | |
- (void) updateAVFormatContextWithOptions: (AVDictionary**)options { | |
if (_formatCtx) | |
return; | |
AVDictionary *tmp = NULL; | |
if (options) { | |
av_dict_copy(&tmp, *options, 0); | |
} | |
if (av_opt_set_dict(_formatCtx, &tmp) < 0) { | |
av_dict_free(&tmp); | |
} | |
} | |
- (void) someWhereElse | |
{ | |
NSMutableString* cookieString = [NSMutableString stringWithString:@"Cookie: "]; | |
for (NSHTTPCookie* cookie in [NSHTTPCookieStorage sharedHTTPCookieStorage].cookies) { | |
[cookieString appendFormat:@"%@=%@;", cookie.name, cookie.value]; | |
} | |
[cookieString appendString:@"\n"]; | |
NSDictionary* dict = [NSDictionary dictionaryWithObject:cookieString forKey: @"headers"]; | |
AVDictionary* options = [self createAVFormatContextOptions:dict]; | |
avformat_open_input(&formatCtx, [path cStringUsingEncoding: NSUTF8StringEncoding], NULL, &options) | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment