我目前在iOS应用程序中将rtmpdump
用作C程序。但是,似乎不必重启应用程序就不能多次使用它。这可能是什么原因,我该如何解决?
相关代码:
NSDictionary *details = [args objectAtIndex:0]; //rtmpe deatils
NSString *flvStore = [args objectAtIndex:1];
NSString *mp4Store = [args objectAtIndex:2];
[self performSelectorOnMainThread:@selector(updateProgressBar:) withObject:flvPath waitUntilDone:NO];
[self getFlashFile:details withFlvPathName:flvStore];
NSFileManager *fileManager = [NSFileManager defaultManager];
if([fileManager fileExistsAtPath:flvPath]){
NSNumber *filesize = 0;
NSDictionary *fileAttributes = [[NSFileManager defaultManager] fileAttributesAtPath:flvPath traverseLink:NO];
if(fileAttributes != nil){
filesize = [fileAttributes objectForKey:NSFileSize];
}
if([filesize longLongValue] > 1024){
[self removeFlvWrapper:flvPath withMp4PathName:mp4Path andTitle:[thePid objectForKey:@"title"]];
}
[fileManager removeItemAtPath:flvPath error:NULL];
}
- (void)getFlashFile:(NSDictionary *)details withFlvPathName:(NSString *)flvPath {
static char **rt_argv;
static int rt_argc;
rt_argc = 16;
rt_argv = (char **)malloc(sizeof(char *) * (rt_argc));
rt_argv[0] = "rtmpdump";
rt_argv[1] = (char *)[@"-r" UTF8String];
rt_argv[2] = (char *)[[details objectForKey:@"r"] UTF8String];
rt_argv[3] = (char *)[@"-a" UTF8String];
rt_argv[4] = (char *)[[details objectForKey:@"a"] UTF8String];
rt_argv[5] = (char *)[@"-f" UTF8String];
rt_argv[6] = (char *)[@"WIN 10,0,32,18" UTF8String];
rt_argv[7] = (char *)[@"-W" UTF8String];
rt_argv[8] = (char *)[[details objectForKey:@"W"] UTF8String];
rt_argv[9] = (char *)[@"-p" UTF8String];
rt_argv[10] = (char *)[[details objectForKey:@"p"] UTF8String];
rt_argv[11] = (char *)[@"-y" UTF8String];
rt_argv[12] = (char *)[[details objectForKey:@"y"] UTF8String];
rt_argv[13] = (char *)[@"-o" UTF8String];
rt_argv[14] = (char *)[flvPath UTF8String];
rt_argv[15] = (char *)[@"-q" UTF8String];
getStream(rt_argc, rt_argv);
finished = true;
}
您也可以查看BigBadOwl repository under iPlayerFetch.m以查看类似的代码。
最佳答案
我最终在Objective-C中创建了rtmpdump的替代方案。该代码使用librtmp而不是rtmpdump,但是受到rtmpdump的启发。
谢谢!
关于iphone - 发布C库(使用ARC),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14838814/