发布C库(使用ARC)

时间:2013-02-12 18:01:24

标签: iphone ios objective-c c automatic-ref-counting

我目前在我的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以查看类似代码。

1 个答案:

答案 0 :(得分:0)

我最终在Objective-C中创建了rtmpdump的替代品。该代码使用librtmp而不是rtmpdump,但灵感来自rtmpdump。

谢谢!