scf_list_init(&io->vout);
scf_list_init(&io->aout);
- pthread_mutex_init(&io->mutex);
- pthread_cond_init (&io->cond);
+ pthread_mutex_init(&io->mutex, NULL);
+ pthread_cond_init (&io->cond , NULL);
io->tid = -1;
io->width = -1;
#include"simp_ffmpeg.h"
-#include"scf_log.h"
+#include"scf_def.h"
static int _video_init(simp_ffmpeg_t* priv)
{
return 0;
}
-int __ffmpeg_decode(simp_avio_t* io, AVCodecContext* dec_ctx, AVPacket* pkt, AVFrame* frame, scf_list_t* h)
+static int __ffmpeg_decode(simp_avio_t* io, AVCodecContext* dec_ctx, AVPacket* pkt, AVFrame* frame, scf_list_t* h)
{
int ret = avcodec_send_packet(dec_ctx, pkt);
if (ret < 0) {
return 0;
}
-void* __ffmpeg_run(void* arg)
+static void* __ffmpeg_run(void* arg)
{
simp_avio_t* io = arg;
simp_ffmpeg_t* priv = io->priv;
if (!pkt)
goto end;
- while (!priv->exit) {
+ while (!io->exit) {
int ret = av_read_frame(priv->fmt_ctx, pkt);
if (ret < 0) {
scf_loge("av_read_frame error, ret: %s\n", av_err2str(ret));
av_packet_free(&pkt);
- priv->error = ret;
+ io->error = ret;
break;
}
}
}
- av_packet_unref(&pkt);
+ av_packet_unref(pkt);
}
end:
#include"simp_ffmpeg.h"
-#include"scf_log.h"
+#include"scf_def.h"
static int _video_init(simp_ffmpeg_t* priv)
{
if (!priv->vdec_ctx)
return -1;
- priv->vdec_ctx->codec_id = c->codec_id;
+ priv->vdec_ctx->codec_id = c->id;
priv->vdec_ctx->bit_rate = 1024 * 1024;
priv->vdec_ctx->width = 1920;
priv->vdec_ctx->height = 1080;
if (!priv->adec_ctx)
return -1;
- priv->adec_ctx->codec_id = c->codec_id;
+ priv->adec_ctx->codec_id = c->id;
priv->adec_ctx->bit_rate = 64 * 1024;
priv->adec_ctx->sample_rate = 44100;
priv->adec_ctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
error:
if (priv->fmt_ctx)
- avformat_close_output(&priv->fmt_ctx);
+ avformat_free_context(priv->fmt_ctx);
if (priv->vdec_ctx)
avcodec_close(priv->vdec_ctx);
if (priv) {
if (priv->fmt_ctx)
- avformat_close_output(&priv->fmt_ctx);
+ avformat_free_context(priv->fmt_ctx);
if (priv->vdec_ctx)
avcodec_close(priv->vdec_ctx);
return 0;
}
-int __ffmpeg_decode(simp_avio_t* io, AVCodecContext* dec_ctx, AVPacket* pkt, AVFrame* frame, scf_list_t* h)
+static int __ffmpeg_decode(simp_avio_t* io, AVCodecContext* dec_ctx, AVPacket* pkt, AVFrame* frame, scf_list_t* h)
{
int ret = avcodec_send_packet(dec_ctx, pkt);
if (ret < 0) {
return 0;
}
-void* __ffmpeg_run(void* arg)
+static void* __ffmpeg_run(void* arg)
{
simp_avio_t* io = arg;
simp_ffmpeg_t* priv = io->priv;
if (!pkt)
goto end;
- while (!priv->exit) {
+ while (!io->exit) {
pthread_mutex_lock(&io->mutex);
pthread_mutex_unlock(&io->mutex);
-
-
-
}
end:
voutputs = tmp;
}
- if (io->sample_rate > 0 && io->channels > 0 && io->aopen) {
+ if (io->sample_rate.den > 0 && io->channels > 0 && io->aopen) {
snprintf(args, sizeof(args),
"time_base=%d/%d:sample_rate=%d:sample_fmt=%s:channel_layout=0x%"PRIx64,
io->sample_rate.num, io->sample_rate.den,
io->sample_rate.den /io->sample_rate.num,
av_get_sample_fmt_name(io->sample_fmt),
- av_get_default_channel_layout(io->channel_layout));
+ av_get_default_channel_layout(io->channels));
ret = avfilter_graph_create_filter(&io->abuffersrc_ctx, abuffersrc, "in", args, NULL, f->agraph);
if (ret < 0)
scf_list_init(&f->inputs);
scf_list_init(&f->outputs);
- pthread_mutex_init(&f->mutex);
- pthread_cond_init (&f->cond);
+ pthread_mutex_init(&f->mutex, NULL);
+ pthread_cond_init (&f->cond, NULL);
f->tid = -1;
return 0;
int64_t time = sys_time - io->start_time;
- if (vopen) {
+ if (io->vopen) {
pthread_mutex_lock(&io->mutex);
if (!scf_list_empty(&io->vin)) {
}
}
- if (aopen) {
+ if (io->aopen) {
pthread_mutex_lock(&io->mutex);
if (!scf_list_empty(&io->ain)) {
int simp_filter_add_input(simp_filter_t* f, simp_avio_t* input)
{
if (f && input) {
- scf_list_add_tail(&f->inputs, input);
+ scf_list_add_tail(&f->inputs, &input->list);
return 0;
}
int simp_filter_add_output(simp_filter_t* f, simp_avio_t* output)
{
if (f && output) {
- scf_list_add_tail(&f->outputs, output);
+ scf_list_add_tail(&f->outputs, &output->list);
return 0;
}