Re #1758: Initial implementation of OpenH264 wrapper. Supports:

- library detection via autoconf
 - CBP
 - packetization modes: 0, 1
 - key frame request and indication
 - obey remote's fmtp

Also added video codec test in samples (similar to the one in pjmedia test though).
And there are some fixes here and there too (e.g. in vid_codec_util.c).


git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@4815 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
Benny Prijono 2014-04-10 10:01:07 +00:00
parent 2d91e02341
commit b3034d498f
16 changed files with 2016 additions and 112 deletions

View File

@ -1,9 +1,11 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for pjproject 2.x.
# Generated by GNU Autoconf 2.68 for pjproject 2.x.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
# Foundation, Inc.
#
#
# This configure script is free software; the Free Software Foundation
@ -132,31 +134,6 @@ export LANGUAGE
# CDPATH.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
# Use a proper internal environment variable to ensure we don't fall
# into an infinite loop, continuously re-executing ourselves.
if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
_as_can_reexec=no; export _as_can_reexec;
# We cannot yet assume a decent shell, so we have to provide a
# neutralization value for shells without unset; and this also
# works around shells that cannot unset nonexistent variables.
# Preserve -v and -x to the replacement shell.
BASH_ENV=/dev/null
ENV=/dev/null
(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
case $- in # ((((
*v*x* | *x*v* ) as_opts=-vx ;;
*v* ) as_opts=-v ;;
*x* ) as_opts=-x ;;
* ) as_opts= ;;
esac
exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
# Admittedly, this is quite paranoid, since all the known shells bail
# out after a failed `exec'.
$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
as_fn_exit 255
fi
# We don't want this to propagate to other subprocesses.
{ _as_can_reexec=; unset _as_can_reexec;}
if test "x$CONFIG_SHELL" = x; then
as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
emulate sh
@ -190,8 +167,7 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
else
exitcode=1; echo positional parameters were not saved.
fi
test x\$exitcode = x0 || exit 1
test -x / || exit 1"
test x\$exitcode = x0 || exit 1"
as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
@ -236,25 +212,21 @@ IFS=$as_save_IFS
if test "x$CONFIG_SHELL" != x; then :
export CONFIG_SHELL
# We cannot yet assume a decent shell, so we have to provide a
# neutralization value for shells without unset; and this also
# works around shells that cannot unset nonexistent variables.
# Preserve -v and -x to the replacement shell.
BASH_ENV=/dev/null
ENV=/dev/null
(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
case $- in # ((((
*v*x* | *x*v* ) as_opts=-vx ;;
*v* ) as_opts=-v ;;
*x* ) as_opts=-x ;;
* ) as_opts= ;;
esac
exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
# Admittedly, this is quite paranoid, since all the known shells bail
# out after a failed `exec'.
$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
exit 255
# We cannot yet assume a decent shell, so we have to provide a
# neutralization value for shells without unset; and this also
# works around shells that cannot unset nonexistent variables.
# Preserve -v and -x to the replacement shell.
BASH_ENV=/dev/null
ENV=/dev/null
(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
export CONFIG_SHELL
case $- in # ((((
*v*x* | *x*v* ) as_opts=-vx ;;
*v* ) as_opts=-v ;;
*x* ) as_opts=-x ;;
* ) as_opts= ;;
esac
exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"}
fi
if test x$as_have_required = xno; then :
@ -356,14 +328,6 @@ $as_echo X"$as_dir" |
} # as_fn_mkdir_p
# as_fn_executable_p FILE
# -----------------------
# Test if FILE is an executable regular file.
as_fn_executable_p ()
{
test -f "$1" && test -x "$1"
} # as_fn_executable_p
# as_fn_append VAR VALUE
# ----------------------
# Append the text in VALUE to the end of the definition contained in VAR. Take
@ -485,10 +449,6 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits
chmod +x "$as_me.lineno" ||
{ $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
# If we had to re-execute with $CONFIG_SHELL, we're ensured to have
# already done that, so ensure we don't try to do so again and fall
# in an infinite loop. This has already happened in practice.
_as_can_reexec=no; export _as_can_reexec
# Don't try to exec as it changes $[0], causing all sort of problems
# (the dirname of $[0] is not the place where we might find the
# original and so on. Autoconf is especially sensitive to this).
@ -523,16 +483,16 @@ if (echo >conf$$.file) 2>/dev/null; then
# ... but there are two gotchas:
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
# In both cases, we have to default to `cp -pR'.
# In both cases, we have to default to `cp -p'.
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
as_ln_s='cp -pR'
as_ln_s='cp -p'
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
as_ln_s='cp -pR'
as_ln_s='cp -p'
fi
else
as_ln_s='cp -pR'
as_ln_s='cp -p'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null
@ -544,8 +504,28 @@ else
as_mkdir_p=false
fi
as_test_x='test -x'
as_executable_p=as_fn_executable_p
if test -x / >/dev/null 2>&1; then
as_test_x='test -x'
else
if ls -dL / >/dev/null 2>&1; then
as_ls_L_option=L
else
as_ls_L_option=
fi
as_test_x='
eval sh -c '\''
if test -d "$1"; then
test -d "$1/.";
else
case $1 in #(
-*)set "./$1";;
esac;
case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
???[sx]*):;;*)false;;esac;fi
'\'' sh
'
fi
as_executable_p=$as_test_x
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@ -638,6 +618,8 @@ libcrypto_present
libssl_present
openssl_h_present
ac_no_ssl
ac_openh264_ldflags
ac_openh264_cflags
ac_v4l2_ldflags
ac_v4l2_cflags
PKG_CONFIG
@ -790,6 +772,8 @@ enable_sdl
with_ffmpeg
enable_ffmpeg
enable_v4l2
with_openh264
enable_openh264
enable_ipp
with_ipp
with_ipp_samples
@ -1270,6 +1254,8 @@ target=$target_alias
if test "x$host_alias" != x; then
if test "x$build_alias" = x; then
cross_compiling=maybe
$as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used" >&2
elif test "x$build_alias" != "x$host_alias"; then
cross_compiling=yes
fi
@ -1453,6 +1439,7 @@ Optional Features:
--disable-sdl Disable SDL (default: not disabled)
--disable-ffmpeg Disable ffmpeg (default: not disabled)
--disable-v4l2 Disable Video4Linux2 (default: not disabled)
--disable-openh264 Disable OpenH264 (default: not disabled)
--enable-ipp Enable Intel IPP support. Specify the Intel IPP
package and samples location using IPPROOT and
IPPSAMPLES env var or with --with-ipp and
@ -1491,6 +1478,7 @@ Optional Packages:
include/lib paths)
--with-sdl=DIR Specify alternate libSDL prefix
--with-ffmpeg=DIR Specify alternate FFMPEG prefix
--with-openh264=DIR Specify alternate OpenH264 prefix
--with-ipp=DIR Specify the Intel IPP location
--with-ipp-samples=DIR Specify the Intel IPP samples location
--with-ipp-arch=ARCH Specify the Intel IPP ARCH suffix, e.g. "64" or
@ -1583,9 +1571,9 @@ test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
pjproject configure 2.x
generated by GNU Autoconf 2.69
generated by GNU Autoconf 2.68
Copyright (C) 2012 Free Software Foundation, Inc.
Copyright (C) 2010 Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.
_ACEOF
@ -1699,7 +1687,7 @@ $as_echo "$ac_try_echo"; } >&5
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
test -x conftest$ac_exeext
$as_test_x conftest$ac_exeext
}; then :
ac_retval=0
else
@ -1986,7 +1974,7 @@ This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by pjproject $as_me 2.x, which was
generated by GNU Autoconf 2.69. Invocation command line was
generated by GNU Autoconf 2.68. Invocation command line was
$ $0 $@
@ -2511,7 +2499,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_CC="${ac_tool_prefix}gcc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -2551,7 +2539,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_ac_ct_CC="gcc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -2604,7 +2592,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_CC="${ac_tool_prefix}cc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -2645,7 +2633,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
ac_prog_rejected=yes
continue
@ -2703,7 +2691,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -2747,7 +2735,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_ac_ct_CC="$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -3193,7 +3181,8 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdarg.h>
#include <stdio.h>
struct stat;
#include <sys/types.h>
#include <sys/stat.h>
/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
struct buf { int x; };
FILE * (*rcsopen) (struct buf *, struct stat *, int);
@ -3306,7 +3295,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -3350,7 +3339,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_ac_ct_CXX="$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -3559,7 +3548,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -3599,7 +3588,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_ac_ct_RANLIB="ranlib"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -3653,7 +3642,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -3697,7 +3686,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_ac_ct_AR="$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -4479,7 +4468,7 @@ do
for ac_prog in grep ggrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
as_fn_executable_p "$ac_path_GREP" || continue
{ test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
# Check for GNU ac_path_GREP and select it if it is found.
# Check for GNU $ac_path_GREP
case `"$ac_path_GREP" --version 2>&1` in
@ -4545,7 +4534,7 @@ do
for ac_prog in egrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
as_fn_executable_p "$ac_path_EGREP" || continue
{ test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
# Check for GNU ac_path_EGREP and select it if it is found.
# Check for GNU $ac_path_EGREP
case `"$ac_path_EGREP" --version 2>&1` in
@ -6512,7 +6501,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_path_SDL_CONFIG="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -6558,7 +6547,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_path_SDL_CONFIG="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -6663,7 +6652,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_prog_PKG_CONFIG="$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@ -7066,6 +7055,94 @@ fi
fi
# Check whether --with-openh264 was given.
if test "${with_openh264+set}" = set; then :
withval=$with_openh264;
else
with_openh264=no
fi
if test "x$ac_cross_compile" != "x" -a "x$with_openh264" = "xno"; then
enable_openh264=no
fi
# Check whether --enable-openh264 was given.
if test "${enable_openh264+set}" = set; then :
enableval=$enable_openh264;
if test "$enable_openh264" = "no"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Checking if OpenH264 is disabled... yes" >&5
$as_echo "Checking if OpenH264 is disabled... yes" >&6; }
fi
else
if test "x$with_openh264" != "xno" -a "x$with_openh264" != "x"; then
OPENH264_PREFIX=$with_openh264
OPENH264_CFLAGS="-I$OPENH264_PREFIX/include"
OPENH264_LDFLAGS="-L$OPENH264_PREFIX/lib"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: Using OpenH264 prefix... $with_openh264" >&5
$as_echo "Using OpenH264 prefix... $with_openh264" >&6; }
else
OPENH264_CFLAGS=""
OPENH264_LDFLAGS=""
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking OpenH264 availability" >&5
$as_echo_n "checking OpenH264 availability... " >&6; }
OPENH264_LIBS="-lwels"
SAVED_LIBS="$LIBS"
SAVED_LDFLAGS="$LDFLAGS"
SAVED_CFLAGS="$CFLAGS"
LIBS="$OPENH264_LIBS $LIBS"
LDFLAGS="$OPENH264_LDFLAGS $LDFLAGS"
CFLAGS="$OPENH264_CFLAGS $CFLAGS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <wels/codec_api.h>
#include <wels/codec_app_def.h>
int
main ()
{
int main() { CreateSVCEncoder(0); return 0; }
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_openh264_cflags="-DPJMEDIA_HAS_OPENH264_CODEC=1 $OPENH264_CFLAGS"
ac_openh264_ldflags="$OPENH264_LDFLAGS $OPENH264_LIBS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
$as_echo "ok" >&6; }
else
LIBS="$SAVED_LIBS"
LDFLAGS="$SAVED_LDFLAGS"
CFLAGS="$SAVED_CFLAGS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5
$as_echo "failed" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
# Check whether --enable-ipp was given.
if test "${enable_ipp+set}" = set; then :
enableval=$enable_ipp;
@ -8345,16 +8422,16 @@ if (echo >conf$$.file) 2>/dev/null; then
# ... but there are two gotchas:
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
# In both cases, we have to default to `cp -pR'.
# In both cases, we have to default to `cp -p'.
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
as_ln_s='cp -pR'
as_ln_s='cp -p'
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
as_ln_s='cp -pR'
as_ln_s='cp -p'
fi
else
as_ln_s='cp -pR'
as_ln_s='cp -p'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null
@ -8414,16 +8491,28 @@ else
as_mkdir_p=false
fi
# as_fn_executable_p FILE
# -----------------------
# Test if FILE is an executable regular file.
as_fn_executable_p ()
{
test -f "$1" && test -x "$1"
} # as_fn_executable_p
as_test_x='test -x'
as_executable_p=as_fn_executable_p
if test -x / >/dev/null 2>&1; then
as_test_x='test -x'
else
if ls -dL / >/dev/null 2>&1; then
as_ls_L_option=L
else
as_ls_L_option=
fi
as_test_x='
eval sh -c '\''
if test -d "$1"; then
test -d "$1/.";
else
case $1 in #(
-*)set "./$1";;
esac;
case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
???[sx]*):;;*)false;;esac;fi
'\'' sh
'
fi
as_executable_p=$as_test_x
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@ -8445,7 +8534,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# values after options handling.
ac_log="
This file was extended by pjproject $as_me 2.x, which was
generated by GNU Autoconf 2.69. Invocation command line was
generated by GNU Autoconf 2.68. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
CONFIG_HEADERS = $CONFIG_HEADERS
@ -8507,10 +8596,10 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
pjproject config.status 2.x
configured by $0, generated by GNU Autoconf 2.69,
configured by $0, generated by GNU Autoconf 2.68,
with options \\"\$ac_cs_config\\"
Copyright (C) 2012 Free Software Foundation, Inc.
Copyright (C) 2010 Free Software Foundation, Inc.
This config.status script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it."
@ -8598,7 +8687,7 @@ fi
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
if \$ac_cs_recheck; then
set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
shift
\$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
CONFIG_SHELL='$SHELL'

View File

@ -1095,6 +1095,73 @@ AC_ARG_ENABLE(v4l2,
)
])
dnl # OpenH264 alt prefix
AC_ARG_WITH(openh264,
AC_HELP_STRING([--with-openh264=DIR],
[Specify alternate OpenH264 prefix]),
[],
[with_openh264=no]
)
dnl # Do not use default OpenH264 installation if we are cross-compiling
if test "x$ac_cross_compile" != "x" -a "x$with_openh264" = "xno"; then
enable_openh264=no
fi
dnl # OpenH264
AC_SUBST(ac_openh264_cflags)
AC_SUBST(ac_openh264_ldflags)
AC_ARG_ENABLE(openh264,
AC_HELP_STRING([--disable-openh264],
[Disable OpenH264 (default: not disabled)]),
[
if test "$enable_openh264" = "no"; then
AC_MSG_RESULT([Checking if OpenH264 is disabled... yes])
fi
],
[
if test "x$with_openh264" != "xno" -a "x$with_openh264" != "x"; then
OPENH264_PREFIX=$with_openh264
OPENH264_CFLAGS="-I$OPENH264_PREFIX/include"
OPENH264_LDFLAGS="-L$OPENH264_PREFIX/lib"
AC_MSG_RESULT([Using OpenH264 prefix... $with_openh264])
else
OPENH264_CFLAGS=""
OPENH264_LDFLAGS=""
fi
AC_MSG_CHECKING([OpenH264 availability])
OPENH264_LIBS="-lwels"
SAVED_LIBS="$LIBS"
SAVED_LDFLAGS="$LDFLAGS"
SAVED_CFLAGS="$CFLAGS"
LIBS="$OPENH264_LIBS $LIBS"
LDFLAGS="$OPENH264_LDFLAGS $LDFLAGS"
CFLAGS="$OPENH264_CFLAGS $CFLAGS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <wels/codec_api.h>
#include <wels/codec_app_def.h>
]],
[int main() { CreateSVCEncoder(0); return 0; }]
)],
[ ac_openh264_cflags="-DPJMEDIA_HAS_OPENH264_CODEC=1 $OPENH264_CFLAGS"
ac_openh264_ldflags="$OPENH264_LDFLAGS $OPENH264_LIBS"
AC_MSG_RESULT(ok)
],
[
LIBS="$SAVED_LIBS"
LDFLAGS="$SAVED_LDFLAGS"
CFLAGS="$SAVED_CFLAGS"
AC_MSG_RESULT(failed)
])
])
dnl ########################################################
dnl # Intel IPP support
dnl #

View File

@ -133,7 +133,7 @@ endif
SDL_CFLAGS = @ac_sdl_cflags@
SDL_LDFLAGS = @ac_sdl_ldflags@
# FFMPEG dlags
# FFMPEG flags
FFMPEG_CFLAGS = @ac_ffmpeg_cflags@
FFMPEG_LDFLAGS = @ac_ffmpeg_ldflags@
@ -141,6 +141,10 @@ FFMPEG_LDFLAGS = @ac_ffmpeg_ldflags@
V4L2_CFLAGS = @ac_v4l2_cflags@
V4L2_LDFLAGS = @ac_v4l2_ldflags@
# OPENH264 flags
OPENH264_CFLAGS = @ac_openh264_cflags@
OPENH264_LDFLAGS = @ac_openh264_ldflags@
# QT
AC_PJMEDIA_VIDEO_HAS_QT = @ac_pjmedia_video_has_qt@
QT_CFLAGS = @ac_qt_cflags@
@ -150,8 +154,9 @@ IOS_CFLAGS = @ac_ios_cflags@
# PJMEDIA features exclusion
PJ_VIDEO_CFLAGS += $(SDL_CFLAGS) $(FFMPEG_CFLAGS) $(V4L2_CFLAGS) $(QT_CFLAGS) \
$(IOS_CFLAGS)
PJ_VIDEO_LDFLAGS += $(SDL_LDFLAGS) $(FFMPEG_LDFLAGS) $(V4L2_LDFLAGS)
$(OPENH264_CFLAGS) $(IOS_CFLAGS)
PJ_VIDEO_LDFLAGS += $(SDL_LDFLAGS) $(FFMPEG_LDFLAGS) $(V4L2_LDFLAGS) \
$(OPENH264_LDFLAGS)
# CFLAGS, LDFLAGS, and LIBS to be used by applications

View File

@ -134,7 +134,7 @@ export PJSDP_LDFLAGS += $(PJMEDIA_LDLIB) \
# Defines for building PJMEDIA-Codec library
#
export PJMEDIA_CODEC_SRCDIR = ../src/pjmedia-codec
export PJMEDIA_CODEC_OBJS += audio_codecs.o ffmpeg_vid_codecs.o \
export PJMEDIA_CODEC_OBJS += audio_codecs.o ffmpeg_vid_codecs.o openh264.o \
h263_packetizer.o h264_packetizer.o \
$(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \
ipp_codecs.o opencore_amr.o silk.o $(CODEC_OBJS) \

View File

@ -35,6 +35,7 @@
#include <pjmedia-codec/g7221.h>
#include <pjmedia-codec/ipp_codecs.h>
#include <pjmedia-codec/opencore_amr.h>
#include <pjmedia-codec/openh264.h>
#include <pjmedia-codec/passthrough.h>
#include <pjmedia-codec/silk.h>

View File

@ -0,0 +1,69 @@
/* $Id$ */
/*
* Copyright (C) 2014 Teluu Inc. (http://www.teluu.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __PJMEDIA_CODEC_OPENH264_H__
#define __PJMEDIA_CODEC_OPENH264_H__
#include <pjmedia-codec/types.h>
#include <pjmedia/vid_codec.h>
/**
* @file pjmedia-codec/openh264.h
* @brief Open H.264 codec
*/
PJ_BEGIN_DECL
/**
* @defgroup PJMEDIA_CODEC_OPENH264 Open H.264 Codec
* @ingroup PJMEDIA_CODEC_VID_CODECS
* @{
*/
/**
* Initialize and register OpenH264 codec factory.
*
* @param mgr The video codec manager instance where this codec will
* be registered to. Specify NULL to use default instance
* (in that case, an instance of video codec manager must
* have been created beforehand).
* @param pf Pool factory.
*
* @return PJ_SUCCESS on success.
*/
PJ_DECL(pj_status_t) pjmedia_codec_openh264_vid_init(pjmedia_vid_codec_mgr *mgr,
pj_pool_factory *pf);
/**
* Unregister OpenH264 video codecs factory from the video codec manager and
* deinitialize the codec library.
*
* @return PJ_SUCCESS on success.
*/
PJ_DECL(pj_status_t) pjmedia_codec_openh264_vid_deinit(void);
/**
* @} PJMEDIA_CODEC_OPENH264
*/
PJ_END_DECL
#endif /* __PJMEDIA_CODEC_OPENH264_H__ */

View File

@ -239,6 +239,11 @@ typedef pj_status_t pjmedia_event_cb(pjmedia_event *event,
*/
typedef enum pjmedia_event_publish_flag
{
/**
* Default flag.
*/
PJMEDIA_EVENT_PUBLISH_DEFAULT,
/**
* Publisher will only post the event to the event manager. It is the
* event manager that will later notify all the publisher's subscribers.

File diff suppressed because it is too large Load Diff

View File

@ -631,7 +631,7 @@ static pj_status_t find_highest_res(pjmedia_vid_codec_h264_fmtp *fmtp,
}
/* Calculate maximum size (in macroblocks) */
max_fs = fmtp->max_mbps * fps->denum / fps->num;
max_fs = fmtp->max_mbps * the_fps.denum / the_fps.num;
max_fs = PJ_MIN(max_fs, fmtp->max_fs);
/* Check if the specified ratio is using big numbers

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "test.h"
#include <pjmedia-codec/ffmpeg_vid_codecs.h>
#include <pjmedia-codec.h>
#include <pjmedia-videodev/videodev.h>
#include <pjmedia/vid_codec.h>
#include <pjmedia/port.h>
@ -297,6 +297,9 @@ static int encode_decode_test(pj_pool_t *pool, const char *codec_id,
codec_param.packing = packing;
/* Don't apply SDP fmtp */
codec_param.ignore_fmtp = PJ_TRUE;
/* Open codec */
status = pjmedia_vid_codec_mgr_alloc_codec(NULL, codec_info,
&codec);
@ -453,6 +456,13 @@ int vid_codec_test(void)
if (status != PJ_SUCCESS)
return -10;
#if PJMEDIA_HAS_VIDEO && PJMEDIA_HAS_OPENH264_CODEC
status = pjmedia_codec_openh264_vid_init(NULL, mem);
if (status != PJ_SUCCESS) {
return -22;
}
#endif
#if PJMEDIA_HAS_FFMPEG_VID_CODEC
status = pjmedia_codec_ffmpeg_vid_init(NULL, mem);
if (status != PJ_SUCCESS)
@ -463,6 +473,7 @@ int vid_codec_test(void)
if (rc != 0)
goto on_return;
#if PJMEDIA_HAS_FFMPEG_VID_CODEC
rc = encode_decode_test(pool, "h263-1998", PJMEDIA_VID_PACKING_WHOLE);
if (rc != 0)
goto on_return;
@ -470,10 +481,25 @@ int vid_codec_test(void)
rc = encode_decode_test(pool, "h263-1998", PJMEDIA_VID_PACKING_PACKETS);
if (rc != 0)
goto on_return;
#endif
#if PJMEDIA_HAS_FFMPEG_VID_CODEC || PJMEDIA_HAS_OPENH264_CODEC
rc = encode_decode_test(pool, "h264", PJMEDIA_VID_PACKING_WHOLE);
if (rc != 0)
goto on_return;
rc = encode_decode_test(pool, "h264", PJMEDIA_VID_PACKING_PACKETS);
if (rc != 0)
goto on_return;
#endif
on_return:
#if PJMEDIA_HAS_FFMPEG_VID_CODEC
pjmedia_codec_ffmpeg_vid_deinit();
#endif
#if defined(PJMEDIA_HAS_OPENH264_CODEC) && PJMEDIA_HAS_OPENH264_CODEC != 0
pjmedia_codec_openh264_vid_deinit();
#endif
pjmedia_vid_dev_subsys_shutdown();
pj_pool_release(pool);

View File

@ -45,6 +45,7 @@ SAMPLES := auddemo \
streamutil \
strerror \
tonegen \
vid_codec_test \
vid_streamutil
PJSUA2_SAMPLES := pjsua2_demo

View File

@ -500,6 +500,12 @@ static int main_func(int argc, char *argv[])
goto on_return;
}
#if defined(PJMEDIA_HAS_OPENH264_CODEC) && PJMEDIA_HAS_OPENH264_CODEC != 0
status = pjmedia_codec_openh264_vid_init(NULL, &cp.factory);
if (status != PJ_SUCCESS)
goto on_return;
#endif
#if PJMEDIA_HAS_FFMPEG_VID_CODEC
status = pjmedia_codec_ffmpeg_vid_init(NULL, &cp.factory);
if (status != PJ_SUCCESS)
@ -520,6 +526,9 @@ static int main_func(int argc, char *argv[])
on_return:
#if PJMEDIA_HAS_FFMPEG_VID_CODEC
pjmedia_codec_ffmpeg_vid_deinit();
#endif
#if defined(PJMEDIA_HAS_OPENH264_CODEC) && PJMEDIA_HAS_OPENH264_CODEC != 0
pjmedia_codec_openh264_vid_deinit();
#endif
pjmedia_aud_subsys_shutdown();
pjmedia_vid_dev_subsys_shutdown();

View File

@ -385,6 +385,11 @@ int main(int argc, char *argv[])
status = pjmedia_vid_dev_subsys_init(&cp.factory);
PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
# if defined(PJMEDIA_HAS_OPENH264_CODEC) && PJMEDIA_HAS_OPENH264_CODEC != 0
status = pjmedia_codec_openh264_vid_init(NULL, &cp.factory);
PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
# endif
# if defined(PJMEDIA_HAS_FFMPEG_VID_CODEC) && PJMEDIA_HAS_FFMPEG_VID_CODEC!=0
/* Init ffmpeg video codecs */
status = pjmedia_codec_ffmpeg_vid_init(NULL, &cp.factory);
@ -576,6 +581,9 @@ int main(int argc, char *argv[])
# if defined(PJMEDIA_HAS_FFMPEG_VID_CODEC) && PJMEDIA_HAS_FFMPEG_VID_CODEC!=0
pjmedia_codec_ffmpeg_vid_deinit();
# endif
# if defined(PJMEDIA_HAS_OPENH264_CODEC) && PJMEDIA_HAS_OPENH264_CODEC != 0
pjmedia_codec_openh264_vid_deinit();
# endif
#endif

View File

@ -0,0 +1,521 @@
/* $Id$ */
/*
* Copyright (C) 2014 Teluu Inc. (http://www.teluu.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* \page page_pjmedia_samples_vid_codec_test_c Samples: Video Codec Test
*
* Video codec encode and decode test.
*
* This file is pjsip-apps/src/samples/vid_vodec_test.c
*
* \includelineno vid_vodec_test.c
*/
#include <pjlib.h>
#include <pjlib-util.h>
#include <pjmedia.h>
#include <pjmedia-codec.h>
#if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0)
#include <stdlib.h> /* atoi() */
#include <stdio.h>
#include "util.h"
static const char *desc =
" vid_vodec_test \n"
;
#define THIS_FILE "vid_vodec_test.c"
/* If set, local renderer will be created to play original file */
#define HAS_LOCAL_RENDERER_FOR_PLAY_FILE 1
/* Default width and height for the renderer, better be set to maximum
* acceptable size.
*/
#define DEF_RENDERER_WIDTH 640
#define DEF_RENDERER_HEIGHT 480
/* Prototype */
static void print_stream_stat(pjmedia_vid_stream *stream,
const pjmedia_vid_codec_param *codec_param);
/* Prototype for LIBSRTP utility in file datatypes.c */
int hex_string_to_octet_string(char *raw, char *hex, int len);
/*
* Register all codecs.
*/
static pj_status_t init_codecs(pj_pool_factory *pf)
{
pj_status_t status;
/* To suppress warning about unused var when all codecs are disabled */
PJ_UNUSED_ARG(status);
#if defined(PJMEDIA_HAS_OPENH264_CODEC) && PJMEDIA_HAS_OPENH264_CODEC != 0
status = pjmedia_codec_openh264_vid_init(NULL, pf);
PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
#endif
#if defined(PJMEDIA_HAS_FFMPEG_VID_CODEC) && PJMEDIA_HAS_FFMPEG_VID_CODEC != 0
status = pjmedia_codec_ffmpeg_vid_init(NULL, pf);
PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
#endif
return PJ_SUCCESS;
}
/*
* Register all codecs.
*/
static void deinit_codecs()
{
#if defined(PJMEDIA_HAS_FFMPEG_VID_CODEC) && PJMEDIA_HAS_FFMPEG_VID_CODEC != 0
pjmedia_codec_ffmpeg_vid_deinit();
#endif
#if defined(PJMEDIA_HAS_OPENH264_CODEC) && PJMEDIA_HAS_OPENH264_CODEC != 0
pjmedia_codec_openh264_vid_deinit();
#endif
}
/*
* usage()
*/
static void usage()
{
puts(desc);
}
static void show_diff(const pj_uint8_t *buf1, const pj_uint8_t *buf2,
unsigned size)
{
enum {
STEP = 50
};
unsigned i=0;
for (; i<size; ) {
const pj_uint8_t *p1 = buf1 + i, *p2 = buf2 + i;
unsigned j;
printf("%8d ", i);
for (j=0; j<STEP && i+j<size; ++j) {
printf(" %02x", *(p1+j));
}
printf("\n");
printf(" ");
for (j=0; j<STEP && i+j<size; ++j) {
if (*(p1+j) == *(p2+j)) {
printf(" %02x", *(p2+j));
} else {
printf(" %02x", *(p2+j));
}
}
printf("\n");
i += j;
}
}
static void diff_file()
{
const char *filename[2] = {
"/home/bennylp/Desktop/opt/src/openh264-svn/testbin/test.264",
"/home/bennylp/Desktop/opt/src/openh264-svn/testbin/test2.264"
};
unsigned size[2];
pj_uint8_t *buf[2], start_nal[3] = {0, 0, 1};
unsigned i, pos[2], frame_cnt, mismatch_cnt=0;
for (i=0; i<2; ++i) {
FILE *fhnd;
const pj_uint8_t start_nal[] = { 0, 0, 1};
fhnd = fopen(filename[i], "rb");
if (!fhnd) {
printf("Error opening %s\n", filename[i]);
return;
}
fseek(fhnd, 0, SEEK_END);
size[i] = ftell(fhnd);
fseek(fhnd, 0, SEEK_SET);
buf[i] = (pj_uint8_t*)malloc(size[i] + 4);
if (!buf[i])
return;
if (fread (buf[i], 1, size[i], fhnd) != (unsigned)size[i]) {
fprintf (stderr, "Unable to read whole file\n");
return;
}
memcpy (buf[i] + size[i], start_nal, sizeof(start_nal));
fclose(fhnd);
}
if (size[0] != size[1]) {
printf("File size mismatch\n");
return;
}
pos[0] = pos[1] = 0;
for ( frame_cnt=0; ; ++frame_cnt) {
unsigned nal_len[2];
for (i = 0; i < size[0]; i++) {
if (memcmp(buf[0] + pos[0] + i, start_nal,
sizeof(start_nal)) == 0 && i > 0)
{
break;
}
}
nal_len[0] = i;
for (i = 0; i < size[1]; i++) {
if (memcmp(buf[1] + pos[1] + i, start_nal,
sizeof(start_nal)) == 0 && i > 0)
{
break;
}
}
nal_len[1] = i;
if (nal_len[0] != nal_len[1]) {
printf("Different size in frame %d (%d vs %d)\n",
frame_cnt, nal_len[0], nal_len[1]);
}
if (memcmp(buf[0]+pos[0], buf[1]+pos[1], nal_len[0]) != 0) {
printf("Mismatch in frame %d\n", frame_cnt);
show_diff(buf[0]+pos[0], buf[1]+pos[1], nal_len[0]);
puts("");
++mismatch_cnt;
}
pos[0] += nal_len[0];
pos[1] += nal_len[1];
if (pos[0] >= size[0])
break;
}
free(buf[0]);
free(buf[1]);
if (!mismatch_cnt)
puts("Files the same!");
else
printf("%d mismatches\n", mismatch_cnt);
}
/*
* main()
*/
int main(int argc, char *argv[])
{
pj_caching_pool cp;
pjmedia_endpt *med_endpt;
pj_pool_t *pool;
pj_status_t status;
/* Codec */
char *codec_id = (char*)"H264";
const pjmedia_vid_codec_info *codec_info;
pjmedia_vid_codec_param codec_param;
pjmedia_vid_codec *codec = NULL;
//const char *save_filename =
// "/home/bennylp/Desktop/opt/src/openh264-svn/testbin/test.264";
const char *save_filename = NULL;
/* File */
enum
{
WIDTH = 320,
HEIGHT = 192,
FPS = 12,
YUV_SIZE = WIDTH * HEIGHT * 3 >> 1,
YUV_BUF_SIZE = YUV_SIZE + WIDTH,
MAX_FRAMES = 32,
MTU = 1500
};
FILE *fyuv = NULL;
FILE *f264 = NULL;
typedef pj_uint8_t enc_buf_type[MTU];
pj_uint8_t yuv_frame[YUV_BUF_SIZE];
enc_buf_type enc_buf[MAX_FRAMES];
unsigned read_cnt = 0,
pkt_cnt = 0,
dec_cnt = 0,
enc_cnt;
if (0) {
diff_file();
return 1;
}
/* init PJLIB : */
status = pj_init();
PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
/* Must create a pool factory before we can allocate any memory. */
pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0);
/* Initialize media endpoint. */
status = pjmedia_endpt_create(&cp.factory, NULL, 1, &med_endpt);
PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
/* Create memory pool for application purpose */
pool = pj_pool_create( &cp.factory, /* pool factory */
"app", /* pool name. */
4000, /* init size */
4000, /* increment size */
NULL /* callback on error */
);
/* Init video format manager */
pjmedia_video_format_mgr_create(pool, 64, 0, NULL);
/* Init video converter manager */
pjmedia_converter_mgr_create(pool, NULL);
/* Init event manager */
pjmedia_event_mgr_create(pool, 0, NULL);
/* Init video codec manager */
pjmedia_vid_codec_mgr_create(pool, NULL);
/* Register all supported codecs */
status = init_codecs(&cp.factory);
PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
/* Open YUV file */
fyuv = fopen("pjsip-apps/bin/CiscoVT2people_320x192_12fps.yuv", "rb");
if (!fyuv) {
puts("Unable to open ../CiscoVT2people_320x192_12fps.yuv");
status = -1;
goto on_exit;
}
/* Write 264 file if wanted */
if (save_filename) {
f264 = fopen(save_filename, "wb");
}
/* Find which codec to use. */
if (codec_id) {
unsigned count = 1;
pj_str_t str_codec_id = pj_str(codec_id);
status = pjmedia_vid_codec_mgr_find_codecs_by_id(NULL,
&str_codec_id, &count,
&codec_info, NULL);
if (status != PJ_SUCCESS) {
printf("Error: unable to find codec %s\n", codec_id);
return 1;
}
} else {
static pjmedia_vid_codec_info info[1];
unsigned count = PJ_ARRAY_SIZE(info);
/* Default to first codec */
pjmedia_vid_codec_mgr_enum_codecs(NULL, &count, info, NULL);
codec_info = &info[0];
}
/* Get codec default param for info */
status = pjmedia_vid_codec_mgr_get_default_param(NULL, codec_info,
&codec_param);
pj_assert(status == PJ_SUCCESS);
/* Alloc encoder */
status = pjmedia_vid_codec_mgr_alloc_codec(NULL, codec_info, &codec);
if (status != PJ_SUCCESS) {
PJ_PERROR(3,(THIS_FILE, status, "Error allocating codec"));
goto on_exit;
}
codec_param.dir = PJMEDIA_DIR_ENCODING_DECODING;
codec_param.packing = PJMEDIA_VID_PACKING_PACKETS;
codec_param.enc_mtu = MTU;
codec_param.enc_fmt.det.vid.size.w = WIDTH;
codec_param.enc_fmt.det.vid.size.h = HEIGHT;
codec_param.enc_fmt.det.vid.fps.num = FPS;
codec_param.enc_fmt.det.vid.avg_bps = WIDTH * HEIGHT * FPS;
status = pjmedia_vid_codec_init(codec, pool);
if (status != PJ_SUCCESS) {
PJ_PERROR(3,(THIS_FILE, status, "Error initializing codec"));
goto on_exit;
}
status = pjmedia_vid_codec_open(codec, &codec_param);
if (status != PJ_SUCCESS) {
PJ_PERROR(3,(THIS_FILE, status, "Error opening codec"));
goto on_exit;
}
while (fread(yuv_frame, 1, YUV_SIZE, fyuv) == YUV_SIZE) {
pjmedia_frame frm_yuv, frm_enc[MAX_FRAMES];
pj_bool_t has_more = PJ_FALSE;
const pj_uint8_t start_nal[] = { 0, 0, 1 };
unsigned i;
++ read_cnt;
pj_bzero(&frm_enc, sizeof(frm_enc));
pj_bzero(&frm_yuv, sizeof(frm_yuv));
frm_yuv.buf = yuv_frame;
frm_yuv.size = YUV_SIZE;
enc_cnt = 0;
frm_enc[enc_cnt].buf = enc_buf[enc_cnt];
frm_enc[enc_cnt].size = MTU;
status = pjmedia_vid_codec_encode_begin(codec, NULL, &frm_yuv,
MTU, &frm_enc[enc_cnt],
&has_more);
if (status != PJ_SUCCESS) {
PJ_PERROR(3,(THIS_FILE, status, "Codec encode error"));
goto on_exit;
}
if (frm_enc[enc_cnt].size) {
if (f264) {
fwrite(start_nal, 1, sizeof(start_nal), f264);
fwrite(frm_enc[enc_cnt].buf, 1, frm_enc[enc_cnt].size, f264);
}
++pkt_cnt;
++enc_cnt;
}
while (has_more) {
if (enc_cnt >= MAX_FRAMES) {
status = -1;
puts("Error: too many encoded frames");
goto on_exit;
}
has_more = PJ_FALSE;
frm_enc[enc_cnt].buf = enc_buf[enc_cnt];
frm_enc[enc_cnt].size = MTU;
status = pjmedia_vid_codec_encode_more(codec, MTU,
&frm_enc[enc_cnt],
&has_more);
if (status != PJ_SUCCESS) {
PJ_PERROR(3,(THIS_FILE, status, "Codec encode error"));
goto on_exit;
}
if (frm_enc[enc_cnt].size) {
if (f264) {
fwrite(start_nal, 1, sizeof(start_nal), f264);
fwrite(frm_enc[enc_cnt].buf, 1, frm_enc[enc_cnt].size,
f264);
}
++pkt_cnt;
++enc_cnt;
}
}
if (enc_cnt) {
frm_yuv.buf = yuv_frame;
frm_yuv.size = YUV_BUF_SIZE;
status = pjmedia_vid_codec_decode(codec, enc_cnt,
frm_enc,
YUV_BUF_SIZE,
&frm_yuv);
if (status != PJ_SUCCESS) {
PJ_PERROR(3,(THIS_FILE, status, "Codec decode error"));
goto on_exit;
}
if (frm_yuv.size != 0) {
++dec_cnt;
}
}
}
printf("Done.\n"
" Read YUV frames: %d\n"
" Encoded packets: %d\n"
" Decoded YUV frames: %d\n",
read_cnt, pkt_cnt, dec_cnt);
/* Start deinitialization: */
on_exit:
if (codec) {
pjmedia_vid_codec_close(codec);
pjmedia_vid_codec_mgr_dealloc_codec(NULL, codec);
}
if (f264)
fclose(f264);
if (fyuv)
fclose(fyuv);
/* Deinit codecs */
deinit_codecs();
/* Destroy event manager */
pjmedia_event_mgr_destroy(NULL);
/* Release application pool */
pj_pool_release( pool );
/* Destroy media endpoint. */
pjmedia_endpt_destroy( med_endpt );
/* Destroy pool factory */
pj_caching_pool_destroy( &cp );
/* Shutdown PJLIB */
pj_shutdown();
return (status == PJ_SUCCESS) ? 0 : 1;
}
#else
int main(int argc, char *argv[])
{
PJ_UNUSED_ARG(argc);
PJ_UNUSED_ARG(argv);
puts("Error: this sample requires video capability "
"(PJMEDIA_HAS_VIDEO == 1)");
return -1;
}
#endif /* PJMEDIA_HAS_VIDEO */

View File

@ -121,6 +121,11 @@ static pj_status_t init_codecs(pj_pool_factory *pf)
/* To suppress warning about unused var when all codecs are disabled */
PJ_UNUSED_ARG(status);
#if defined(PJMEDIA_HAS_OPENH264_CODEC) && PJMEDIA_HAS_OPENH264_CODEC != 0
status = pjmedia_codec_openh264_vid_init(NULL, pf);
PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
#endif
#if defined(PJMEDIA_HAS_FFMPEG_VID_CODEC) && PJMEDIA_HAS_FFMPEG_VID_CODEC != 0
status = pjmedia_codec_ffmpeg_vid_init(NULL, pf);
PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
@ -137,6 +142,11 @@ static void deinit_codecs()
#if defined(PJMEDIA_HAS_FFMPEG_VID_CODEC) && PJMEDIA_HAS_FFMPEG_VID_CODEC != 0
pjmedia_codec_ffmpeg_vid_deinit();
#endif
#if defined(PJMEDIA_HAS_OPENH264_CODEC) && PJMEDIA_HAS_OPENH264_CODEC != 0
pjmedia_codec_openh264_vid_deinit();
#endif
}
static pj_status_t create_file_player( pj_pool_t *pool,

View File

@ -73,6 +73,15 @@ pj_status_t pjsua_vid_subsys_init(void)
goto on_error;
}
#if PJMEDIA_HAS_VIDEO && PJMEDIA_HAS_OPENH264_CODEC
status = pjmedia_codec_openh264_vid_init(NULL, &pjsua_var.cp.factory);
if (status != PJ_SUCCESS) {
PJ_PERROR(1,(THIS_FILE, status,
"Error initializing OpenH264 library"));
goto on_error;
}
#endif
#if PJMEDIA_HAS_VIDEO && PJMEDIA_HAS_FFMPEG_VID_CODEC
status = pjmedia_codec_ffmpeg_vid_init(NULL, &pjsua_var.cp.factory);
if (status != PJ_SUCCESS) {
@ -133,6 +142,10 @@ pj_status_t pjsua_vid_subsys_destroy(void)
pjmedia_codec_ffmpeg_vid_deinit();
#endif
#if defined(PJMEDIA_HAS_OPENH264_CODEC) && PJMEDIA_HAS_OPENH264_CODEC != 0
pjmedia_codec_openh264_vid_deinit();
#endif
if (pjmedia_vid_codec_mgr_instance())
pjmedia_vid_codec_mgr_destroy(NULL);