Changeset 5302
- Timestamp:
- May 17, 2016 3:54:14 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-videodev/ffmpeg_dev.c
r4722 r5302 45 45 #define THIS_FILE "ffmpeg.c" 46 46 47 #define LIBAVFORMAT_VER_AT_LEAST(major,minor) (LIBAVFORMAT_VERSION_MAJOR > major || \ 48 (LIBAVFORMAT_VERSION_MAJOR == major && \ 49 LIBAVFORMAT_VERSION_MINOR >= minor)) 50 47 51 #include "../pjmedia/ffmpeg_util.h" 48 52 #include <libavdevice/avdevice.h> 49 53 #include <libavformat/avformat.h> 54 #if LIBAVFORMAT_VER_AT_LEAST(53,2) 55 # include <libavutil/pixdesc.h> 56 #endif 50 57 51 58 #define MAX_DEV_CNT 8 … … 159 166 const pjmedia_vid_dev_param *param) 160 167 { 168 #if LIBAVFORMAT_VER_AT_LEAST(53,2) 169 AVDictionary *format_opts = NULL; 170 char buf[128]; 171 #else 161 172 AVFormatParameters fp; 173 #endif 162 174 pjmedia_video_format_detail *vfd; 163 175 int err; … … 172 184 *ctx = avformat_alloc_context(); 173 185 186 #if LIBAVFORMAT_VER_AT_LEAST(53,2) 187 /* Init ffmpeg dictionary */ 188 snprintf(buf, sizeof(buf), "%d/%d", vfd->fps.num, vfd->fps.denum); 189 av_dict_set(&format_opts, "framerate", buf, 0); 190 snprintf(buf, sizeof(buf), "%dx%d", vfd->size.w, vfd->size.h); 191 av_dict_set(&format_opts, "video_size", buf, 0); 192 av_dict_set(&format_opts, "pixel_format", av_get_pix_fmt_name(PIX_FMT_BGR24), 0); 193 194 /* Open capture stream */ 195 err = avformat_open_input(ctx, dev_name, ifmt, &format_opts); 196 #else 174 197 /* Init ffmpeg format param */ 175 198 pj_bzero(&fp, sizeof(fp)); … … 183 206 /* Open capture stream */ 184 207 err = av_open_input_stream(ctx, NULL, dev_name, ifmt, &fp); 208 #endif 185 209 if (err < 0) { 186 210 *ctx = NULL; /* ffmpeg freed its states on failure, do we must too */ … … 195 219 { 196 220 if (ctx) 221 #if LIBAVFORMAT_VER_AT_LEAST(53,2) 222 avformat_close_input(&ctx); 223 #else 197 224 av_close_input_stream(ctx); 225 #endif 198 226 } 199 227
Note: See TracChangeset
for help on using the changeset viewer.