Question

I am trying to compile PJSIP 2.1 with Video support on Ubuntu but I get the following error when running 'make' :

    In file included from ../src/pjmedia/ffmpeg_util.c:26:0:
../src/pjmedia/ffmpeg_util.h:50:12: warning: ‘enum CodecID’ declared inside parameter list [enabled by default]
       enum CodecID *codec_id);
            ^
../src/pjmedia/ffmpeg_util.h:50:12: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]
../src/pjmedia/ffmpeg_util.h:53:7: warning: ‘enum CodecID’ declared inside parameter list [enabled by default]
       pjmedia_format_id *fmt_id);
       ^
../src/pjmedia/ffmpeg_util.c:65:18: error: field ‘codec_id’ has incomplete type
     enum CodecID codec_id;
                  ^
../src/pjmedia/ffmpeg_util.c:167:13: error: conflicting types for ‘pjmedia_format_id_to_CodecID’
 pj_status_t pjmedia_format_id_to_CodecID(pjmedia_format_id fmt_id,
             ^
In file included from ../src/pjmedia/ffmpeg_util.c:26:0:
../src/pjmedia/ffmpeg_util.h:49:13: note: previous declaration of ‘pjmedia_format_id_to_CodecID’ was here
 pj_status_t pjmedia_format_id_to_CodecID(pjmedia_format_id fmt_id,
             ^
../src/pjmedia/ffmpeg_util.c: In function ‘pjmedia_format_id_to_CodecID’:
../src/pjmedia/ffmpeg_util.c:173:35: warning: comparison between pointer and integer [enabled by default]
  if (t->id==fmt_id && t->codec_id != PIX_FMT_NONE) {
                                   ^
../src/pjmedia/ffmpeg_util.c:174:6: error: dereferencing pointer to incomplete type
      *codec_id = t->codec_id;
      ^
../src/pjmedia/ffmpeg_util.c:174:6: warning: statement with no effect [-Wunused-value]
../src/pjmedia/ffmpeg_util.c:179:5: error: dereferencing pointer to incomplete type
     *codec_id = PIX_FMT_NONE;
     ^
../src/pjmedia/ffmpeg_util.c:179:5: warning: statement with no effect [-Wunused-value]
../src/pjmedia/ffmpeg_util.c: At top level:
../src/pjmedia/ffmpeg_util.c:183:55: error: parameter 1 (‘codec_id’) has incomplete type
 pj_status_t CodecID_to_pjmedia_format_id(enum CodecID codec_id,
                                                       ^
make[2]: *** [output/pjmedia-i686-pc-linux-gnu/ffmpeg_util.o] Error 1
make[2]: Leaving directory `/home/gboutmy/Downloads/pjproject-2.1.0/pjmedia/build'
make[1]: *** [pjmedia] Error 2
make[1]: Leaving directory `/home/gboutmy/Downloads/pjproject-2.1.0/pjmedia/build'
make: *** [all] Error 1

I have installed the required dependencies and have no idea what the problem is. Reading the error messages it looks like it comes from error in the PJSIP code?

EDIT : I renamed enum CodecID to enum AVCodecID according to Getting “field has incomplete type” and "conflicting types" but now i'm getting the following error :

../lib/libpjmedia-codec-i686-pc-linux-gnu.a(ffmpeg_vid_codecs.o): In function `ffmpeg_codec_encode_whole.isra.7':
ffmpeg_vid_codecs.c:(.text+0x1374): undefined reference to `avcodec_encode_video2'
collect2: error: ld returned 1 exit status
make[2]: *** [../bin/pjmedia-test-i686-pc-linux-gnu] Error 1
make[2]: Leaving directory `/home/gboutmy/Downloads/pjproject-2.1.0/pjmedia/build'
make[1]: *** [pjmedia-test] Error 2
make[1]: Leaving directory `/home/gboutmy/Downloads/pjproject-2.1.0/pjmedia/build'
make: *** [all] Error 1
Was it helpful?

Solution

Seems that you miss libavcodec/avcodec.h and, most probably, also libavformat/avformat.h. This should be because ffmpeg include folder is not into gcc's list of directories to look for header files.

From your update seems that pjsip is building against a newer ffmpeg version that the one available in Ubuntu's repositories. As you've built it yourself, you can configure pjsip to use your version by running:

./configure --with-ffmpeg=<YOUR_FFMPEG_FOLDER>

or

#Copy all library ffmpeg library files into one folder 
CFLAGS="-I<YOUR_FFMPEG_FOLDER>" LDFLAGS="-L<YOUR_FFMPEG_LIB_FOLDER>" ./configure 

OTHER TIPS

The answer to the original question :

While compiling PJSIP I find that CodecID enum has been deprecated from ffmpeg. However it's been replaced by AV_CodecID and also the enum values have a leading AV_ added to them.

Thus after changing CodecID to AV_CodecID, please change the enums in ffmpeg_util.c.

For example this is what the table looks like after the change :

/* Conversion table between pjmedia_format_id and CodecID */
static const struct ffmpeg_codec_table_t
{
    pjmedia_format_id   id;
    enum AVCodecID      codec_id;
} ffmpeg_codec_table[] =
{
    {PJMEDIA_FORMAT_H261,       AV_CODEC_ID_H261},
    {PJMEDIA_FORMAT_H263,       AV_CODEC_ID_H263},
    {PJMEDIA_FORMAT_H263P,      AV_CODEC_ID_H263P},
    {PJMEDIA_FORMAT_H264,       AV_CODEC_ID_H264},
    {PJMEDIA_FORMAT_MPEG1VIDEO, AV_CODEC_ID_MPEG1VIDEO},
    {PJMEDIA_FORMAT_MPEG2VIDEO, AV_CODEC_ID_MPEG2VIDEO},
    {PJMEDIA_FORMAT_MPEG4,      AV_CODEC_ID_MPEG4},
    {PJMEDIA_FORMAT_MJPEG,      AV_CODEC_ID_MJPEG}
};
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top