ffmpeg服务器传递视频

2020-06-16 15:46:54 浏览数 (1)

ffmpeg服务器

代码语言:javascript复制
extern "C"
{
    #include <libavformat/avformat.h>
    #include <libavutil/opt.h>
}
#include <unistd.h>
#include <thread>
static void process_client(AVIOContext *client, const char *in_uri)
{
    AVIOContext *input = NULL;
    uint8_t buf[1024]={0};
    int ret, n, reply_code;
    const char *resource = NULL;
    while ((ret = avio_handshake(client)) > 0) {
        av_opt_get(client, "resource", AV_OPT_SEARCH_CHILDREN, (uint8_t**)&resource);
        // check for strlen(resource) is necessary, because av_opt_get()
        // may return empty string.
        if (resource && strlen(resource))
            break;
        av_freep(&resource);
    }
    if (ret < 0)
        goto end;
    av_log(client, AV_LOG_TRACE, "resource=%pn", resource);
    if (resource && resource[0] == '/' && !strcmp((resource   1), in_uri)) {
        reply_code = 200;
    } else {
        reply_code = AVE

0 人点赞