iOS에서 FFmpeg를 사용해 동영상을 스트리밍할 때 HTTP 요청의 헤더 변경 방법
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) | |
... | |
} |
댓글
댓글 쓰기