Changeset 5302


Ignore:
Timestamp:
May 17, 2016 3:54:14 PM (9 years ago)
Author:
riza
Message:

Re #1920: Since FFmpeg version 0.7 (June 2011), the struct AVFormatParameters,
the function av_open_input_stream, and function av_close_input_stream
are deprecated. With FFmpeg 0.11, those three symbols were removed.

Thanks to Alexander Traud for the patch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia-videodev/ffmpeg_dev.c

    r4722 r5302  
    4545#define THIS_FILE               "ffmpeg.c" 
    4646 
     47#define LIBAVFORMAT_VER_AT_LEAST(major,minor)  (LIBAVFORMAT_VERSION_MAJOR > major || \ 
     48                                               (LIBAVFORMAT_VERSION_MAJOR == major && \ 
     49                                                LIBAVFORMAT_VERSION_MINOR >= minor)) 
     50 
    4751#include "../pjmedia/ffmpeg_util.h" 
    4852#include <libavdevice/avdevice.h> 
    4953#include <libavformat/avformat.h> 
     54#if LIBAVFORMAT_VER_AT_LEAST(53,2) 
     55# include <libavutil/pixdesc.h> 
     56#endif 
    5057 
    5158#define MAX_DEV_CNT     8 
     
    159166                                       const pjmedia_vid_dev_param *param) 
    160167{ 
     168#if LIBAVFORMAT_VER_AT_LEAST(53,2) 
     169    AVDictionary *format_opts = NULL; 
     170    char buf[128]; 
     171#else 
    161172    AVFormatParameters fp; 
     173#endif 
    162174    pjmedia_video_format_detail *vfd; 
    163175    int err; 
     
    172184    *ctx = avformat_alloc_context(); 
    173185 
     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 
    174197    /* Init ffmpeg format param */ 
    175198    pj_bzero(&fp, sizeof(fp)); 
     
    183206    /* Open capture stream */ 
    184207    err = av_open_input_stream(ctx, NULL, dev_name, ifmt, &fp); 
     208#endif 
    185209    if (err < 0) { 
    186210        *ctx = NULL; /* ffmpeg freed its states on failure, do we must too */ 
     
    195219{ 
    196220    if (ctx) 
     221#if LIBAVFORMAT_VER_AT_LEAST(53,2) 
     222        avformat_close_input(&ctx); 
     223#else 
    197224        av_close_input_stream(ctx); 
     225#endif 
    198226} 
    199227 
Note: See TracChangeset for help on using the changeset viewer.