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