diff options
author | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-11-04 23:07:04 +0000 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2010-11-04 23:07:04 +0000 |
commit | 6e872935db95638edd73093d299608076eed7d9c (patch) | |
tree | db3c35521bf0c3fc267c88d07c37a55dfaf35646 /ffserver.c | |
parent | 58b4e5407d05164f1874ffb32612237253411093 (diff) | |
download | ffmpeg-6e872935db95638edd73093d299608076eed7d9c.tar.gz |
Implement get_preset_file() in cmdutils.h and use it to factorize code
from ffmpeg.c and ffserver.c.
Originally committed as revision 25679 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'ffserver.c')
-rw-r--r-- | ffserver.c | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/ffserver.c b/ffserver.c index 63bd2677b2..fcc3359a41 100644 --- a/ffserver.c +++ b/ffserver.c @@ -3972,27 +3972,11 @@ static int ffserver_opt_preset(const char *arg, { FILE *f=NULL; char filename[1000], tmp[1000], tmp2[1000], line[1000]; - int i, ret = 0; - const char *base[3]= { getenv("FFMPEG_DATADIR"), - getenv("HOME"), - FFMPEG_DATADIR, - }; - - for(i=0; i<3 && !f; i++){ - if(!base[i]) - continue; - snprintf(filename, sizeof(filename), "%s%s/%s.ffpreset", base[i], i != 1 ? "" : "/.ffmpeg", arg); - f= fopen(filename, "r"); - if(!f){ - AVCodec *codec = avcodec_find_encoder(avctx->codec_id); - if (codec) { - snprintf(filename, sizeof(filename), "%s%s/%s-%s.ffpreset", base[i], i != 1 ? "" : "/.ffmpeg", codec->name, arg); - f= fopen(filename, "r"); - } - } - } + int ret = 0; + AVCodec *codec = avcodec_find_encoder(avctx->codec_id); - if(!f){ + if (!(f = get_preset_file(filename, sizeof(filename), arg, 0, + codec ? codec->name : NULL))) { fprintf(stderr, "File for preset '%s' not found\n", arg); return 1; } |