小编Chu*_*ran的帖子

需要在iOS项目的C++类中使用fopen写入文件

我有一个使用C++类和FFmpeg的项目,我需要使用fopen并将文件写入应用程序沙箱,因此我需要用C++编写的代码相当于:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docs_dir = [paths objectAtIndex:0];
Run Code Online (Sandbox Code Playgroud)

这将是我的应用程序沙箱,我几乎可以操作我的文件问题是我如何在C++中编写此代码,以便我可以在文件上使用fopen?

这是需要实现的方法:

int testGrabAndWrite(const char* streamURL, bool decode, const char* filename)
{
    FILE *outfile;
    int ret;
    int counter = 0;
    uint8_t *data;              // Pointer to the received audio mem
    int size;                   // Size of the received audio buffer


    outfile = fopen(filename, "w");

    if (outfile == NULL)
        exit(1);

    // Open the RTP stream
    if ((ret = openStream(streamURL, decode)) < 0)
        return ret;

    // Print out info about the stream …
Run Code Online (Sandbox Code Playgroud)

c++ iphone ffmpeg objective-c ios

5
推荐指数
1
解决办法
5212
查看次数

标签 统计

c++ ×1

ffmpeg ×1

ios ×1

iphone ×1

objective-c ×1