[Opalvoip-svn] SF.net SVN: opalvoip: [19366] opal/branches/NewMediaType2
Brought to you by:
csoutheren,
rjongbloed
From: <cso...@us...> - 2008-01-30 08:50:52
|
Revision: 19366 http://opalvoip.svn.sourceforge.net/opalvoip/?rev=19366&view=rev Author: csoutheren Date: 2008-01-30 00:50:56 -0800 (Wed, 30 Jan 2008) Log Message: ----------- updated to trunk up to rev 19365 Revision Links: -------------- http://opalvoip.svn.sourceforge.net/opalvoip/?rev=19365&view=rev Modified Paths: -------------- opal/branches/NewMediaType2/include/opal/mediastrm.h opal/branches/NewMediaType2/include/t38/sipt38.h opal/branches/NewMediaType2/plugins/Makefile.in opal/branches/NewMediaType2/plugins/configure opal/branches/NewMediaType2/plugins/configure.ac opal/branches/NewMediaType2/plugins/video/H.261-vic/Makefile.in opal/branches/NewMediaType2/plugins/video/H.261-vic/h261vic.cxx opal/branches/NewMediaType2/plugins/video/H.263-1998/Makefile.in opal/branches/NewMediaType2/plugins/video/H.263-1998/h263-1998.cxx opal/branches/NewMediaType2/plugins/video/H.263-1998/h263-1998.h opal/branches/NewMediaType2/plugins/video/H.264/Makefile.in opal/branches/NewMediaType2/plugins/video/H.264/h264-x264.cxx opal/branches/NewMediaType2/plugins/video/H.264/h264-x264.h opal/branches/NewMediaType2/plugins/video/MPEG4-ffmpeg/Makefile.in opal/branches/NewMediaType2/plugins/video/MPEG4-ffmpeg/mpeg4.cxx opal/branches/NewMediaType2/plugins/video/THEORA/Makefile.in opal/branches/NewMediaType2/plugins/video/common/dyna.cxx opal/branches/NewMediaType2/plugins/video/common/rtpframe.h opal/branches/NewMediaType2/samples/openphone/OpenPhone_2005.sln opal/branches/NewMediaType2/src/codec/opalpluginmgr.cxx opal/branches/NewMediaType2/src/codec/rfc2833.cxx opal/branches/NewMediaType2/src/codec/vidcodec.cxx opal/branches/NewMediaType2/src/opal/call.cxx opal/branches/NewMediaType2/src/opal/mediastrm.cxx opal/branches/NewMediaType2/src/sip/handlers.cxx opal/branches/NewMediaType2/src/t38/sipt38.cxx Modified: opal/branches/NewMediaType2/include/opal/mediastrm.h =================================================================== --- opal/branches/NewMediaType2/include/opal/mediastrm.h 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/include/opal/mediastrm.h 2008-01-30 08:50:56 UTC (rev 19366) @@ -234,11 +234,6 @@ */ virtual PBoolean IsSynchronous() const = 0; - /**Indicate if the media stream requires a OpalMediaPatch instance. - The default behaviour returns true. - */ - virtual PBoolean RequiresPatch() const; - /**Indicate if the media stream requires a OpalMediaPatch thread (active patch). The default behaviour returns true. */ @@ -395,11 +390,6 @@ PINDEX & written ///< Length of data actually written ); - /**Indicate if the media stream requires a OpalMediaPatch instance - The default behaviour returns false. - */ - virtual PBoolean RequiresPatch() const; - /**Indicate if the media stream requires a OpalMediaPatch thread (active patch). The default behaviour returns false. */ Modified: opal/branches/NewMediaType2/include/t38/sipt38.h =================================================================== --- opal/branches/NewMediaType2/include/t38/sipt38.h 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/include/t38/sipt38.h 2008-01-30 08:50:56 UTC (rev 19366) @@ -38,4 +38,5 @@ #include <sip/sdp.h> -#endif \ No newline at end of file +#endif + Modified: opal/branches/NewMediaType2/plugins/Makefile.in =================================================================== --- opal/branches/NewMediaType2/plugins/Makefile.in 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/plugins/Makefile.in 2008-01-30 08:50:56 UTC (rev 19366) @@ -12,14 +12,10 @@ SUBDIRS += video/H.263-ffmpeg endif -HAS_MPEG4=@HAS_MPEG4@ -ifeq ($(HAS_MPEG4),1) -SUBDIRS += video/MPEG4-ffmpeg -endif - HAS_LIBDL=@HAS_LIBDL@ HAS_X264=@HAS_X264@ HAS_FFMPEG=@HAS_FFMPEG@ + ifeq ($(HAS_LIBDL),1) ifeq ($(HAS_X264),1) ifeq ($(HAS_FFMPEG),1) @@ -31,6 +27,7 @@ ifeq ($(HAS_FFMPEG),1) SUBDIRS += video/H.263-1998 +SUBDIRS += video/MPEG4-ffmpeg endif HAS_THEORA=@HAS_THEORA@ Modified: opal/branches/NewMediaType2/plugins/configure =================================================================== --- opal/branches/NewMediaType2/plugins/configure 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/plugins/configure 2008-01-30 08:50:56 UTC (rev 19366) @@ -691,11 +691,10 @@ HAS_VPB HAS_CAPI HAS_LIBDL -HAS_MPEG4 +PLUGIN_CFLAGS +HAS_FFMPEG FFMPEG_SOURCE -FFMPEG_STACKALIGN_HACK FFMPEG_CFLAGS -HAS_FFMPEG x264_CFLAGS x264_LIBS HAS_X264 @@ -1299,6 +1298,8 @@ --enable-localspeex use local version of Speex library rather than system version --enable-vpb enable voicetronix vpb --enable-capi enable CAPI + --disable-rfc-compliant-defaults + Enable FFMPEG stack align hack for MPEG 4 --enable-ffmpeg-stackalign-hack Enable FFMPEG stack align hack for MPEG 4 --disable-ffmpeg Disable ffmpeg @@ -6635,10 +6636,32 @@ fi +PLUGIN_CFLAGS= +# Check whether --enable-rfc-compliant-defaults was given. +if test "${enable_rfc_compliant_defaults+set}" = set; then + enableval=$enable_rfc_compliant_defaults; rfc_compliant_defaults=$enableval +fi -HAS_MPEG4=0 +if test "x${rfc_compliant_defaults}" != "xno" ; then + rfc_compliant_defaults=yes + PLUGIN_CFLAGS="${PLUGIN_CFLAGS} -DWITH_RFC_COMPLIANT_DEFAULTS" +fi + + +# Check whether --enable-ffmpeg-stackalign-hack was given. +if test "${enable_ffmpeg_stackalign_hack+set}" = set; then + enableval=$enable_ffmpeg_stackalign_hack; ffmpeg_stackalign_hack=$enableval +fi + + + + + + FFMPEG_SOURCE= +FFMPEG_CFLAGS= + { echo "$as_me:$LINENO: checking MPEG4 plugin" >&5 echo $ECHO_N "checking MPEG4 plugin... $ECHO_C" >&6; } @@ -6660,8 +6683,8 @@ then { echo "$as_me:$LINENO: result: enabled" >&5 echo "${ECHO_T}enabled" >&6; } - HAS_MPEG4=1 FFMPEG_SOURCE=$with_ffmpeg_src_dir + FFMPEG_CFLAGS="${FFMPEG_CFLAGS} -DWITH_FFMPEG_SRC" else { { echo "$as_me:$LINENO: error: $with_ffmpeg_src_dir doesn't contain an ffmpeg source tree" >&5 echo "$as_me: error: $with_ffmpeg_src_dir doesn't contain an ffmpeg source tree" >&2;} @@ -6672,26 +6695,9 @@ echo "${ECHO_T}disabled" >&6; } fi -# Check whether --enable-ffmpeg-stackalign-hack was given. -if test "${enable_ffmpeg_stackalign_hack+set}" = set; then - enableval=$enable_ffmpeg_stackalign_hack; ffmpeg_stackalign_hack=$enableval -fi -if test "${ffmpeg_stackalign_hack}" = "yes" ; then - { echo "$as_me:$LINENO: FFMPEG stack align hack enabled" >&5 -echo "$as_me: FFMPEG stack align hack enabled" >&6;} - FFMPEG_STACKALIGN_HACK="-DWITH_STACKALIGN_HACK" -else - { echo "$as_me:$LINENO: FFMPEG stack align hack disabled" >&5 -echo "$as_me: FFMPEG stack align hack disabled" >&6;} - FFMPEG_STACKALIGN_HACK="" -fi - - - - HAS_FFMPEG=0 # Check whether --enable-ffmpeg was given. @@ -6958,7 +6964,7 @@ rm -f t t.c { echo "$as_me:$LINENO: result: $ffmpeg_lib_name" >&5 echo "${ECHO_T}$ffmpeg_lib_name" >&6; } - FFMPEG_CFLAGS="-DLIBAVCODEC_LIB_NAME='\"$ffmpeg_lib_name\"'" + FFMPEG_CFLAGS="${FFMPEG_CFLAGS} -DLIBAVCODEC_LIB_NAME='\"$ffmpeg_lib_name\"'" fi else { echo "$as_me:$LINENO: result: no" >&5 @@ -6968,9 +6974,25 @@ fi fi +# Check whether --enable-ffmpeg-stackalign-hack was given. +if test "${enable_ffmpeg_stackalign_hack+set}" = set; then + enableval=$enable_ffmpeg_stackalign_hack; ffmpeg_stackalign_hack=$enableval +fi +if test "${ffmpeg_stackalign_hack}" = "yes" ; then + { echo "$as_me:$LINENO: FFMPEG stack align hack enabled" >&5 +echo "$as_me: FFMPEG stack align hack enabled" >&6;} + FFMPEG_CFLAGS="${FFMPEG_CFLAGS} -DWITH_STACKALIGN_HACK" +else + { echo "$as_me:$LINENO: FFMPEG stack align hack disabled" >&5 +echo "$as_me: FFMPEG stack align hack disabled" >&6;} +fi + + + + HAS_X264=0 X264_LIBS= LIBX264_LINKED=0 @@ -8667,11 +8689,10 @@ HAS_VPB!$HAS_VPB$ac_delim HAS_CAPI!$HAS_CAPI$ac_delim HAS_LIBDL!$HAS_LIBDL$ac_delim -HAS_MPEG4!$HAS_MPEG4$ac_delim +PLUGIN_CFLAGS!$PLUGIN_CFLAGS$ac_delim +HAS_FFMPEG!$HAS_FFMPEG$ac_delim FFMPEG_SOURCE!$FFMPEG_SOURCE$ac_delim -FFMPEG_STACKALIGN_HACK!$FFMPEG_STACKALIGN_HACK$ac_delim FFMPEG_CFLAGS!$FFMPEG_CFLAGS$ac_delim -HAS_FFMPEG!$HAS_FFMPEG$ac_delim x264_CFLAGS!$x264_CFLAGS$ac_delim x264_LIBS!$x264_LIBS$ac_delim HAS_X264!$HAS_X264$ac_delim @@ -8684,7 +8705,7 @@ LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 93; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 92; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 @@ -9736,11 +9757,10 @@ HAS_VPB!$HAS_VPB$ac_delim HAS_CAPI!$HAS_CAPI$ac_delim HAS_LIBDL!$HAS_LIBDL$ac_delim -HAS_MPEG4!$HAS_MPEG4$ac_delim +PLUGIN_CFLAGS!$PLUGIN_CFLAGS$ac_delim +HAS_FFMPEG!$HAS_FFMPEG$ac_delim FFMPEG_SOURCE!$FFMPEG_SOURCE$ac_delim -FFMPEG_STACKALIGN_HACK!$FFMPEG_STACKALIGN_HACK$ac_delim FFMPEG_CFLAGS!$FFMPEG_CFLAGS$ac_delim -HAS_FFMPEG!$HAS_FFMPEG$ac_delim x264_CFLAGS!$x264_CFLAGS$ac_delim x264_LIBS!$x264_LIBS$ac_delim HAS_X264!$HAS_X264$ac_delim @@ -9753,7 +9773,7 @@ LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 93; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 92; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 @@ -10114,10 +10134,15 @@ else echo " THEORA : disabled" fi -if test "x${HAS_MPEG4}" = "x1" ; then +if test "x${HAS_FFMPEG}" = "x1" ; then + +if test "x${FFMPEG_SOURCE}" = "x" ; then +echo " MPEG4 Part 2 : enabled (no rate control correction)" +else echo " MPEG4 Part 2 : enabled" +fi else -echo " MPEG4 Part 2 : disabled (needs ffmpeg sources)" +echo " MPEG4 Part 2 : disabled (needs libavcodec)" fi echo "" echo " OS Type : $target_os" Modified: opal/branches/NewMediaType2/plugins/configure.ac =================================================================== --- opal/branches/NewMediaType2/plugins/configure.ac 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/plugins/configure.ac 2008-01-30 08:50:56 UTC (rev 19366) @@ -308,14 +308,30 @@ fi AC_SUBST(HAS_LIBDL) +PLUGIN_CFLAGS= +AC_ARG_ENABLE(rfc-compliant-defaults, + AC_HELP_STRING([--disable-rfc-compliant-defaults],[Enable FFMPEG stack align hack for MPEG 4]), rfc_compliant_defaults=$enableval) +if test "x${rfc_compliant_defaults}" != "xno" ; then + rfc_compliant_defaults=yes + PLUGIN_CFLAGS="${PLUGIN_CFLAGS} -DWITH_RFC_COMPLIANT_DEFAULTS" +fi + + +AC_ARG_ENABLE(ffmpeg-stackalign-hack, + AC_HELP_STRING([--enable-ffmpeg-stackalign-hack],[Enable FFMPEG stack align hack for MPEG 4]), ffmpeg_stackalign_hack=$enableval) + + +AC_SUBST(PLUGIN_CFLAGS) + dnl ######################################################################## dnl dnl MPEG4 plugin - needs ffmpeg source tree dnl -HAS_MPEG4=0 FFMPEG_SOURCE= +FFMPEG_CFLAGS= + AC_MSG_CHECKING(MPEG4 plugin) AC_ARG_WITH(ffmpeg-src-dir, AC_HELP_STRING([--with-ffmpeg-src-dir],[Directory with ffmpeg source code, needed for MPEG 4 plugin])) @@ -328,8 +344,8 @@ if test -f "$with_ffmpeg_src_dir/libavcodec/avcodec.h" then AC_MSG_RESULT(enabled) - HAS_MPEG4=1 FFMPEG_SOURCE=$with_ffmpeg_src_dir + FFMPEG_CFLAGS="${FFMPEG_CFLAGS} -DWITH_FFMPEG_SRC" else AC_MSG_ERROR([$with_ffmpeg_src_dir doesn't contain an ffmpeg source tree]) fi @@ -337,19 +353,7 @@ AC_MSG_RESULT(disabled) fi -AC_ARG_ENABLE(ffmpeg-stackalign-hack, - AC_HELP_STRING([--enable-ffmpeg-stackalign-hack],[Enable FFMPEG stack align hack for MPEG 4]), ffmpeg_stackalign_hack=$enableval) -if test "${ffmpeg_stackalign_hack}" = "yes" ; then - AC_MSG_NOTICE(FFMPEG stack align hack enabled) - FFMPEG_STACKALIGN_HACK="-DWITH_STACKALIGN_HACK" -else - AC_MSG_NOTICE(FFMPEG stack align hack disabled) - FFMPEG_STACKALIGN_HACK="" -fi -AC_SUBST(HAS_MPEG4) -AC_SUBST(FFMPEG_SOURCE) -AC_SUBST(FFMPEG_STACKALIGN_HACK) dnl ########################################################################### dnl Checks for ffmpeg @@ -392,7 +396,7 @@ ffmpeg_lib_name=`ldd ./t | grep libavcodec | awk '{ print $1; }'` rm -f t t.c AC_MSG_RESULT($ffmpeg_lib_name) - FFMPEG_CFLAGS="-DLIBAVCODEC_LIB_NAME='\"$ffmpeg_lib_name\"'" + FFMPEG_CFLAGS="${FFMPEG_CFLAGS} -DLIBAVCODEC_LIB_NAME='\"$ffmpeg_lib_name\"'" fi else AC_MSG_RESULT([no]) @@ -400,8 +404,19 @@ fi fi fi + +AC_ARG_ENABLE(ffmpeg-stackalign-hack, + AC_HELP_STRING([--enable-ffmpeg-stackalign-hack],[Enable FFMPEG stack align hack for MPEG 4]), ffmpeg_stackalign_hack=$enableval) +if test "${ffmpeg_stackalign_hack}" = "yes" ; then + AC_MSG_NOTICE(FFMPEG stack align hack enabled) + FFMPEG_CFLAGS="${FFMPEG_CFLAGS} -DWITH_STACKALIGN_HACK" +else + AC_MSG_NOTICE(FFMPEG stack align hack disabled) +fi + +AC_SUBST(HAS_FFMPEG) +AC_SUBST(FFMPEG_SOURCE) AC_SUBST(FFMPEG_CFLAGS) -AC_SUBST(HAS_FFMPEG) dnl ########################################################################### dnl Checks for x264 @@ -652,10 +667,15 @@ else echo " THEORA : disabled" fi -if test "x${HAS_MPEG4}" = "x1" ; then +if test "x${HAS_FFMPEG}" = "x1" ; then + +if test "x${FFMPEG_SOURCE}" = "x" ; then +echo " MPEG4 Part 2 : enabled (no rate control correction)" +else echo " MPEG4 Part 2 : enabled" +fi else -echo " MPEG4 Part 2 : disabled (needs ffmpeg sources)" +echo " MPEG4 Part 2 : disabled (needs libavcodec)" fi echo "" echo " OS Type : $target_os" Modified: opal/branches/NewMediaType2/plugins/video/H.261-vic/Makefile.in =================================================================== --- opal/branches/NewMediaType2/plugins/video/H.261-vic/Makefile.in 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/plugins/video/H.261-vic/Makefile.in 2008-01-30 08:50:56 UTC (rev 19366) @@ -73,8 +73,9 @@ PLUGINEXT =@PLUGINEXT@ STDCCFLAGS =@STDCCFLAGS@ LDFLAGS =@LDFLAGS@ +PLUGIN_CFLAGS =@PLUGIN_CFLAGS@ -EXTRACCFLAGS += -I$(COMMONDIR) +EXTRACCFLAGS += $(PLUGIN_CFLAGS) -I$(COMMONDIR) vpath %.cxx $(COMMONDIR) vpath %.cxx $(SRCDIR) Modified: opal/branches/NewMediaType2/plugins/video/H.261-vic/h261vic.cxx =================================================================== --- opal/branches/NewMediaType2/plugins/video/H.261-vic/h261vic.cxx 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/plugins/video/H.261-vic/h261vic.cxx 2008-01-30 08:50:56 UTC (rev 19366) @@ -54,6 +54,7 @@ #include <codec/opalplugin.h> + #include <stdlib.h> #if defined (_WIN32) || defined (_WIN32_WCE) #include <malloc.h> @@ -81,6 +82,9 @@ #include <stdio.h> #include <math.h> +#include "critsect.h" +#include "rtpframe.h" + #ifdef _MSC_VER #pragma warning(disable:4800) #endif @@ -147,165 +151,8 @@ #endif -///////////////////////////////////////////////////////////////// -// -// define a class to implement a critical section mutex -// based on PCriticalSection from PWLib - -class CriticalSection -{ - public: - CriticalSection() - { -#ifdef _WIN32 - ::InitializeCriticalSection(&criticalSection); -#else - ::sem_init(&sem, 0, 1); -#endif - } - - ~CriticalSection() - { -#ifdef _WIN32 - ::DeleteCriticalSection(&criticalSection); -#else - ::sem_destroy(&sem); -#endif - } - - void Wait() - { -#ifdef _WIN32 - ::EnterCriticalSection(&criticalSection); -#else - ::sem_wait(&sem); -#endif - } - - void Signal() - { -#ifdef _WIN32 - ::LeaveCriticalSection(&criticalSection); -#else - ::sem_post(&sem); -#endif - } - - private: - CriticalSection & operator=(const CriticalSection &) { return *this; } -#ifdef _WIN32 - mutable CRITICAL_SECTION criticalSection; -#else - mutable sem_t sem; -#endif -}; - -class WaitAndSignal { - public: - inline WaitAndSignal(const CriticalSection & cs) - : sync((CriticalSection &)cs) - { sync.Wait(); } - - ~WaitAndSignal() - { sync.Signal(); } - - WaitAndSignal & operator=(const WaitAndSignal &) - { return *this; } - - protected: - CriticalSection & sync; -}; - -///////////////////////////////////////////////////////////////////////////// -// -// define some simple RTP packet routines -// - #define RTP_MIN_HEADER_SIZE 12 -class RTPFrame -{ - public: - RTPFrame(const unsigned char * _packet, int _packetLen) - : packet((unsigned char *)_packet), packetLen(_packetLen) - { - } - - RTPFrame(unsigned char * _packet, int _packetLen, unsigned char payloadType) - : packet(_packet), packetLen(_packetLen) - { - if (packetLen > 0) - packet[0] = 0x80; // set version, no extensions, zero contrib count - SetPayloadType(payloadType); - } - - inline unsigned long GetLong(int offs) const - { - if (offs + 4 > packetLen) - return 0; - return (packet[offs + 0] << 24) + (packet[offs+1] << 16) + (packet[offs+2] << 8) + packet[offs+3]; - } - - inline void SetLong(int offs, unsigned long n) - { - if (offs + 4 <= packetLen) { - packet[offs + 0] = (u_char)((n >> 24) & 0xff); - packet[offs + 1] = (u_char)((n >> 16) & 0xff); - packet[offs + 2] = (u_char)((n >> 8) & 0xff); - packet[offs + 3] = (u_char)(n & 0xff); - } - } - - inline unsigned short GetShort(int offs) const - { - if (offs + 2 > packetLen) - return 0; - return (packet[offs + 0] << 8) + packet[offs + 1]; - } - - inline void SetShort(int offs, unsigned short n) - { - if (offs + 2 <= packetLen) { - packet[offs + 0] = (u_char)((n >> 8) & 0xff); - packet[offs + 1] = (u_char)(n & 0xff); - } - } - - inline int GetPacketLen() const { return packetLen; } - inline unsigned GetVersion() const { return (packetLen < 1) ? 0 : (packet[0]>>6)&3; } - inline bool GetExtension() const { return (packetLen < 1) ? 0 : (packet[0]&0x10) != 0; } - inline bool GetMarker() const { return (packetLen < 2) ? 0 : ((packet[1]&0x80) != 0); } - inline unsigned char GetPayloadType() const { return (packetLen < 2) ? 0 : (packet[1] & 0x7f); } - inline unsigned short GetSequenceNumber() const { return GetShort(2); } - inline unsigned long GetTimestamp() const { return GetLong(4); } - inline unsigned long GetSyncSource() const { return GetLong(8); } - inline int GetContribSrcCount() const { return (packetLen < 1) ? 0 : (packet[0]&0xf); } - inline int GetExtensionSize() const { return !GetExtension() ? 0 : GetShort(RTP_MIN_HEADER_SIZE + 4*GetContribSrcCount() + 2); } - inline int GetExtensionType() const { return !GetExtension() ? -1 : GetShort(RTP_MIN_HEADER_SIZE + 4*GetContribSrcCount()); } - inline int GetPayloadSize() const { return packetLen - GetHeaderSize(); } - inline unsigned char * GetPayloadPtr() const { return packet + GetHeaderSize(); } - inline unsigned char * GetPacketPtr() const { return packet; } - - inline unsigned int GetHeaderSize() const - { - unsigned int sz = RTP_MIN_HEADER_SIZE + 4*GetContribSrcCount(); - if (GetExtension()) - sz += 4 + GetExtensionSize(); - return sz; - } - - inline void SetMarker(bool m) { if (packetLen >= 2) packet[1] = (packet[1] & 0x7f) | (m ? 0x80 : 0x00); } - inline void SetPayloadType(unsigned char t) { if (packetLen >= 2) packet[1] = (packet[1] & 0x80) | (t & 0x7f); } - inline void SetSequenceNumber(unsigned short v) { SetShort(2, v); } - inline void SetTimestamp(unsigned long n) { SetLong(4, n); } - inline void SetSyncSource(unsigned long n) { SetLong(8, n); } - inline void SetPayloadSize(int payloadSize) { packetLen = GetHeaderSize() + payloadSize; } - - protected: - unsigned char * packet; - int packetLen; -}; - ///////////////////////////////////////////////////////////////////////////// class H261EncoderContext @@ -503,7 +350,7 @@ flags |= isLast ? PluginCodec_ReturnCoderLastFrame : 0; // marker bit on last frame of video flags |= PluginCodec_ReturnCoderIFrame; // sadly, this encoder *always* returns I-frames :( - return dstRTP.GetPacketLen(); + return dstRTP.GetFrameLen(); } static void * create_encoder(const struct PluginCodec_Definition * /*codec*/) @@ -634,7 +481,7 @@ #if DEBUG_OUTPUT static int decoderInput = -1; -debug_write_data(decoderInput, "decoder input", "decoder.input", srcRTP.GetPacketPtr(), srcRTP.GetPacketLen()); +debug_write_data(decoderInput, "decoder input", "decoder.input", srcRTP.GetPacketPtr(), srcRTP.GetFrameLen()); #endif videoDecoder->mark(now); @@ -687,7 +534,7 @@ videoDecoder->resetndblk(); - dstLen = dstRTP.GetPacketLen(); + dstLen = dstRTP.GetFrameLen(); #if DEBUG_OUTPUT static int decoderOutput = -1; @@ -863,10 +710,17 @@ minHeight = 288; frameTime = 3003*cif_mpi; } - else { // Default handling according to RFC 4587 (QCIF=1) + else { +#ifdef WITH_RFC_COMPLIANT_DEFAULTS + // Default handling according to RFC 4587 (QCIF=1) maxWidth = 176; maxHeight = 144; frameTime = 3003*1; +#else + maxWidth = 352; + maxHeight = 288; + frameTime = 3003*1; +#endif } char ** options = (char **)calloc(15, sizeof(char *)); Modified: opal/branches/NewMediaType2/plugins/video/H.263-1998/Makefile.in =================================================================== --- opal/branches/NewMediaType2/plugins/video/H.263-1998/Makefile.in 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/plugins/video/H.263-1998/Makefile.in 2008-01-30 08:50:56 UTC (rev 19366) @@ -37,9 +37,9 @@ STDCCFLAGS =@STDCCFLAGS@ LDFLAGS =@LDFLAGS@ FFMPEG_CFLAGS =@FFMPEG_CFLAGS@ -FFMPEG_STACKALIGN_HACK := @FFMPEG_STACKALIGN_HACK@ +PLUGIN_CFLAGS =@PLUGIN_CFLAGS@ -EXTRACCFLAGS += $(FFMPEG_CFLAGS) -I$(COMMONDIR) $(FFMPEG_STACKALIGN_HACK) +EXTRACCFLAGS += $(PLUGIN_CFLAGS) $(FFMPEG_CFLAGS) -I$(COMMONDIR) vpath %.cxx $(COMMONDIR) vpath %.o $(OBJDIR) Modified: opal/branches/NewMediaType2/plugins/video/H.263-1998/h263-1998.cxx =================================================================== --- opal/branches/NewMediaType2/plugins/video/H.263-1998/h263-1998.cxx 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/plugins/video/H.263-1998/h263-1998.cxx 2008-01-30 08:50:56 UTC (rev 19366) @@ -398,8 +398,6 @@ return 1; } - TRACE(4, "H263+\tEncoded " << frameSize << " bytes of YUV420P raw data into " << _txH263PFrame->GetFrameSize() << " bytes"); - if (_txH263PFrame->HasRTPFrames()) { _txH263PFrame->GetRTPFrame(dstRTP, flags); @@ -692,9 +690,18 @@ h263MPIList.addMPI(CIF16_WIDTH, CIF16_HEIGHT, atoi(option[1]) ); } - // Defaul value - if (h263MPIList.size() == 0) + // Defaul value(s) + if (h263MPIList.size() == 0) { +#ifdef WITH_RFC_COMPLIANT_DEFAULTS h263MPIList.addMPI(QCIF_WIDTH, QCIF_HEIGHT, 2 ); +#else + h263MPIList.addMPI(SQCIF_WIDTH, SQCIF_HEIGHT, 1); + h263MPIList.addMPI(QCIF_WIDTH, QCIF_HEIGHT, 1); + h263MPIList.addMPI(CIF_WIDTH, CIF_HEIGHT, 1); + h263MPIList.addMPI(CIF4_WIDTH, QCIF4_HEIGHT, 1); + h263MPIList.addMPI(CIF16_WIDTH, CIF16_HEIGHT, 1); +#endif + } char ** options = (char **)calloc(7, sizeof(char *)); *(char ***)parm = options; Modified: opal/branches/NewMediaType2/plugins/video/H.263-1998/h263-1998.h =================================================================== --- opal/branches/NewMediaType2/plugins/video/H.263-1998/h263-1998.h 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/plugins/video/H.263-1998/h263-1998.h 2008-01-30 08:50:56 UTC (rev 19366) @@ -73,6 +73,9 @@ #define QCIF_WIDTH (CIF_WIDTH/2) #define QCIF_HEIGHT (CIF_HEIGHT/2) +#define QCIF4_WIDTH (CIF4_WIDTH/2) +#define QCIF4_HEIGHT (CIF4_HEIGHT/2) + #define SQCIF_WIDTH 128 #define SQCIF_HEIGHT 96 Modified: opal/branches/NewMediaType2/plugins/video/H.264/Makefile.in =================================================================== --- opal/branches/NewMediaType2/plugins/video/H.264/Makefile.in 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/plugins/video/H.264/Makefile.in 2008-01-30 08:50:56 UTC (rev 19366) @@ -87,9 +87,9 @@ STDCCFLAGS =@STDCCFLAGS@ LDFLAGS =@LDFLAGS@ FFMPEG_CFLAGS =@FFMPEG_CFLAGS@ -FFMPEG_STACKALIGN_HACK := @FFMPEG_STACKALIGN_HACK@ +PLUGIN_CFLAGS =@PLUGIN_CFLAGS@ -EXTRACCFLAGS +=-DLICENCE_MPL $(FFMPEG_CFLAGS) -I$(COMMONDIR) $(FFMPEG_STACKALIGN_HACK) +EXTRACCFLAGS += -DLICENCE_MPL $(FFMPEG_CFLAGS) $(PLUGIN_CFLAGS) -I$(COMMONDIR) vpath %.cxx $(SHAREDDIR) vpath %.cxx $(COMMONDIR) Modified: opal/branches/NewMediaType2/plugins/video/H.264/h264-x264.cxx =================================================================== --- opal/branches/NewMediaType2/plugins/video/H.264/h264-x264.cxx 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/plugins/video/H.264/h264-x264.cxx 2008-01-30 08:50:56 UTC (rev 19366) @@ -478,7 +478,6 @@ if (parmLen == NULL || parm == NULL || *parmLen != sizeof(char ***)) return 0; - char* pEnd = NULL; unsigned profile = 66; unsigned constraints = 0; unsigned level = 51; @@ -489,9 +488,9 @@ for (const char * const * option = *(const char * const * *)parm; *option != NULL; option += 2) { if (STRCMPI(option[0], "CAP RFC3894 Profile Level") == 0) { - profile = (strtol(option[1]+1, &pEnd, 16) & 0xFF0000) >> 16; - constraints = (strtol(option[1]+1, &pEnd, 16) & 0x00FF00) >> 8; - level = (strtol(option[1]+1, &pEnd, 16) & 0x0000FF); + profile = (strtoul(option[1]+1, NULL, 16) & 0xFF0000) >> 16; + constraints = (strtoul(option[1]+1, NULL, 16) & 0x00FF00) >> 8; + level = (strtoul(option[1]+1, NULL, 16) & 0x0000FF); } if (STRCMPI(option[0], PLUGINCODEC_OPTION_FRAME_WIDTH) == 0) width = atoi(option[1]); @@ -510,6 +509,20 @@ width -= width % 16; height -= height % 16; + if ((profile==0) && (constraints == 0) && (level == 0)) { +#ifdef WITH_RFC_COMPLIANT_DEFAULTS + // Baseline, Level 1 + profile = 0x42; + constraints = 0xC0; + level = 0x0A; +#else + // Baseline, Level 3 + profile = 0x42; + constraints = 0xC0; + level = 0x1E; +#endif + } + if (!adjust_to_level (width, height, frameTime, targetBitrate,level)) return 0; @@ -570,7 +583,6 @@ if (parmLen == NULL || *parmLen != sizeof(const char **)) return 0; - char* pEnd = NULL; unsigned profile = 66; unsigned constraints = 0; unsigned level = 51; @@ -580,9 +592,9 @@ unsigned targetBitrate = 64000; for (i = 0; options[i] != NULL; i += 2) { if (STRCMPI(options[i], "CAP RFC3894 Profile Level") == 0) { - profile = (strtol(options[i+1]+1, &pEnd, 16) & 0xFF0000) >> 16; - constraints = (strtol(options[i+1]+1, &pEnd, 16) & 0x00FF00) >> 8; - level = (strtol(options[i+1]+1, &pEnd, 16) & 0x0000FF); + profile = (strtoul(options[i+1]+1, NULL, 16) & 0xFF0000) >> 16; + constraints = (strtoul(options[i+1]+1, NULL, 16) & 0x00FF00) >> 8; + level = (strtoul(options[i+1]+1, NULL, 16) & 0x0000FF); } if (STRCMPI(options[i], PLUGINCODEC_OPTION_TARGET_BIT_RATE) == 0) targetBitrate = atoi(options[i+1]); @@ -602,6 +614,19 @@ } TRACE(4, "H264\tCap\tProfile and Level: " << profile << ";" << constraints << ";" << level); + if ((profile==0) && (constraints == 0) && (level == 0)) { +#ifdef WITH_RFC_COMPLIANT_DEFAULTS + // Baseline, Level 1 + profile = 0x42; + constraints = 0xC0; + level = 0x0A; +#else + // Baseline, Level 3 + profile = 0x42; + constraints = 0xC0; + level = 0x1E; +#endif + } if (!adjust_bitrate_to_level (targetBitrate, level)) return 0; @@ -648,7 +673,69 @@ } ///////////////////////////////////////////////////////////////////////////// +static int merge_profile_level_h264(char ** result, const char * dest, const char * src) +{ + // c0: obbeys A.2.1 Baseline + // c1: obbeys A.2.2 Main + // c2: obbeys A.2.3, Extended + // c3: if profile_idc profile = 66, 77, 88, and level =11 and c3: obbeys annexA for level 1b + unsigned srcProfile = (strtoul(src, NULL, 16) & 0xFF0000) >> 16; + unsigned srcConstraints = (strtoul(src, NULL, 16) & 0x00FF00) >> 8; + unsigned srcLevel = (strtoul(src, NULL, 16) & 0x0000FF); + + unsigned dstProfile = (strtoul(dest, NULL, 16) & 0xFF0000) >> 16; + unsigned dstConstraints = (strtoul(dest, NULL, 16) & 0x00FF00) >> 8; + unsigned dstLevel = (strtoul(dest, NULL, 16) & 0x0000FF); + + switch (srcLevel) { + case 10: + srcLevel = 8; + break; + default: + break; + } + + switch (dstLevel) { + case 10: + dstLevel = 8; + break; + default: + break; + } + + if (dstProfile > srcProfile) { + dstProfile = srcProfile; + dstConstraints = srcConstraints; + } + + if (dstLevel > srcLevel) + dstLevel = srcLevel; + + switch (dstLevel) { + case 8: + dstLevel = 10; + break; + default: + break; + } + + + char buffer[10]; + sprintf(buffer, "%x", (dstProfile<<16)|(dstConstraints<<8)|(dstLevel)); + + *result = strdup(buffer); + + return true; +} + +static void free_string(char * str) +{ + free(str); +} + +///////////////////////////////////////////////////////////////////////////// + extern "C" { PLUGIN_CODEC_IMPLEMENT(H264) Modified: opal/branches/NewMediaType2/plugins/video/H.264/h264-x264.h =================================================================== --- opal/branches/NewMediaType2/plugins/video/H.264/h264-x264.h 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/plugins/video/H.264/h264-x264.h 2008-01-30 08:50:56 UTC (rev 19366) @@ -153,8 +153,10 @@ void *, unsigned *); /////////////////////////////////////////////////////////////////////////////// +static int merge_profile_level_h264(char ** result, const char * dest, const char * src); +static void free_string(char * str); +/////////////////////////////////////////////////////////////////////////////// - static struct PluginCodec_information licenseInfo = { 1143692893, // timestamp = Thu 30 Mar 2006 04:28:13 AM UTC @@ -227,7 +229,7 @@ PluginCodec_EqualMerge, // Merge mode "1", // Initial value "packetization-mode", // FMTP option name - "0", // FMTP default value ? + "0", // FMTP default value 0, "1", "2" @@ -238,10 +240,15 @@ PluginCodec_StringOption, // Option type "CAP RFC3894 Profile Level", // User visible name false, // User Read/Only flag - PluginCodec_NoMerge, // Merge mode + PluginCodec_CustomMerge, // Merge mode "42C01E", // Initial value (Baseline, Level 3) "profile-level-id", // FMTP option name - "42C00A", // FMTP default value (Baseline, Level 1) + "000000", // FMTP default value + 0, + "000000", + "58F033", + merge_profile_level_h264, // Function to do merge + free_string // Function to free memory in string }; static struct PluginCodec_Option const * const optionTable[] = { Modified: opal/branches/NewMediaType2/plugins/video/MPEG4-ffmpeg/Makefile.in =================================================================== --- opal/branches/NewMediaType2/plugins/video/MPEG4-ffmpeg/Makefile.in 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/plugins/video/MPEG4-ffmpeg/Makefile.in 2008-01-30 08:50:56 UTC (rev 19366) @@ -67,14 +67,18 @@ $(COMMONDIR)/dyna.cxx \ $(COMMONDIR)/trace.cxx +PLUGIN_CFLAGS =@PLUGIN_CFLAGS@ FFMPEG_CFLAGS =@FFMPEG_CFLAGS@ -FFMPEG_STACKALIGN_HACK := @FFMPEG_STACKALIGN_HACK@ FFMPEG_SOURCE := @FFMPEG_SOURCE@ # Add FFMPEG_SOURCE to the include path so we can #include <libavcodec/...h> # Also add libavutil, so ffmpeg headers can #include "log.h". -EXTRACCFLAGS +=$(FFMPEG_CFLAGS) -I$(FFMPEG_SOURCE) -I$(FFMPEG_SOURCE)/libavutil -I$(COMMONDIR) $(FFMPEG_STACKALIGN_HACK) +EXTRACCFLAGS +=$(PLUGIN_CFLAGS) $(FFMPEG_CFLAGS) -I$(COMMONDIR) +ifneq (,$(FFMPEG_SOURCE)) +EXTRACCFLAGS += -I$(FFMPEG_SOURCE) -I$(FFMPEG_SOURCE)/libavutil +endif + OBJDIR = ./obj $(OBJDIR)/%.o : %.cxx Modified: opal/branches/NewMediaType2/plugins/video/MPEG4-ffmpeg/mpeg4.cxx =================================================================== --- opal/branches/NewMediaType2/plugins/video/MPEG4-ffmpeg/mpeg4.cxx 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/plugins/video/MPEG4-ffmpeg/mpeg4.cxx 2008-01-30 08:50:56 UTC (rev 19366) @@ -87,6 +87,7 @@ // We'll pull them in from their locations in the ffmpeg source tree, // but it would be possible to get them all from /usr/include/ffmpeg // with #include <ffmpeg/...h>. +#ifdef WITH_FFMPEG_SRC #include <libavutil/common.h> #include <libavcodec/avcodec.h> #include <libavutil/avutil.h> @@ -96,6 +97,10 @@ #include <libavutil/intreadwrite.h> #include <libavutil/bswap.h> #include <libavcodec/mpegvideo.h> + +#else /* WITH_FFMPEG_SRC */ +#include <ffmpeg/avcodec.h> +#endif /* WITH_FFMPEG_SRC */ } #define RTP_DYNAMIC_PAYLOAD 96 @@ -135,12 +140,13 @@ unsigned maxVideoPacketLength; /* max. video packet length (bits) */ long unsigned bitrate; } mpeg4_profile_levels[] = { - { 0, "Simple", 1, 0, 1, 198, 99, 1485, 0, 10, 10, 2048, 64000 }, // Streaming Video Profile Amendment { 1, "Simple", 1, 1, 1, 198, 99, 1485, 0, 10, 10, 2048, 64000 }, { 2, "Simple", 1, 2, 1, 792, 396, 5940, 0, 40, 40, 4096, 128000 }, { 3, "Simple", 1, 3, 1, 792, 396, 11880, 0, 40, 40, 8192, 384000 }, { 4, "Simple", 1, 4, 1, 2400, 1200, 36000, 0, 80, 80, 16384, 4000000 }, // is really 4a { 5, "Simple", 1, 5, 1, 3240, 1620, 40500, 0, 112, 112, 16384, 8000000 }, + { 8, "Simple", 1, 0, 1, 198, 99, 1485, 0, 10, 10, 2048, 64000 }, + { 9, "Simple", 1, 0, 1, 198, 99, 1485, 0, 20, 20, 2048, 128000 }, // 0b { 17, "Simple Scalable", 2, 1, 1, 1782, 495, 7425, 0, 40, 40, 2048, 128000 }, { 18, "Simple Scalable", 2, 2, 1, 3168, 792, 23760, 0, 40, 40, 4096, 256000 }, { 33, "Core", 3, 1, 4, 594, 198, 5940, 2970, 16, 16, 4096, 384000 }, @@ -207,13 +213,35 @@ case AV_LOG_INFO: severity = 4; break; case AV_LOG_DEBUG: severity = 4; break; } - AVClass * avc = *(AVClass**) v; snprintf(buffer, sizeof(buffer), "MPEG4\tFFMPEG\t"); vsprintf(buffer + strlen(buffer), fmt, arg); buffer[strlen(buffer)-1] = 0; TRACE (severity, buffer); } } + + + +static bool mpeg4IsIframe (BYTE * frameBuffer, unsigned int frameLen ) +{ + bool isIFrame = false; + unsigned i = 0; + while ((i+4)<= frameLen) { + if ((frameBuffer[i] == 0) && (frameBuffer[i+1] == 0) && (frameBuffer[i+2] == 1)) { + if (frameBuffer[i+3] == 0xb0) + TRACE(4, "Found visual_object_sequence_start_code, Profile/Level is " << (unsigned) frameBuffer[i+4]); + if (frameBuffer[i+3] == 0xb6) { + unsigned vop_coding_type = (unsigned) ((frameBuffer[i+4] & 0xC0) >> 6); + TRACE(4, "Found vop_start_code, is vop_coding_type is " << vop_coding_type ); + if (vop_coding_type == 0) + isIFrame = true; + } + } + i++; + } + return isIFrame; +} + ///////////////////////////////////////////////////////////////////////////// // // define the encoding context @@ -233,7 +261,6 @@ void SetIQuantFactor(float newFactor); void SetThrottle(bool enable); - void SetForceKeyframeUpdate(bool enable); void SetKeyframeUpdatePeriod(int interval); void SetMaxBitrate(int max); void SetFPS(int frameTime); @@ -259,8 +286,8 @@ // Modifiable quantization factor. Defaults to -0.8 float _iQuantFactor; - // Automatic IFrame updates. Defaults to false - bool _forceKeyframeUpdate; + // Max VBV buffer size in bits. + unsigned _maxBufferSize; // Interval in seconds between forced IFrame updates if enabled int _keyframeUpdatePeriod; @@ -299,7 +326,7 @@ unsigned int _frameHeight; unsigned long _lastTimeStamp; - time_t _lastKeyframe; + bool _isIFrame; enum StdSize { SQCIF, @@ -385,8 +412,7 @@ // MPEG4EncoderContext::MPEG4EncoderContext() -: _forceKeyframeUpdate(false), - _doThrottle(false), +: _doThrottle(false), _encFrameBuffer(NULL), _rawFrameBuffer(NULL), _avcodec(NULL), @@ -400,13 +426,15 @@ _videoQMin = 2; _videoTSTO = 10; _iQuantFactor = -0.8f; + _maxBufferSize = 112 * 16384; - _keyframeUpdatePeriod = 125; // 125 frames between forced keyframes, if enabled + _keyframeUpdatePeriod = 0; _frameNum = 0; _lastPktOffset = 0; - _lastKeyframe = time(NULL); + _isIFrame = false; + if (!FFMPEGLibraryInstance.IsLoaded()){ return; } @@ -473,15 +501,6 @@ ///////////////////////////////////////////////////////////////////////////// // -// Setter function for _forceKeyframeUpdate. This is called from -// encoder_set_options if the "Force Keyframe Update" boolean option is passed - -void MPEG4EncoderContext::SetForceKeyframeUpdate(bool enable) { - _forceKeyframeUpdate = enable; -} - -///////////////////////////////////////////////////////////////////////////// -// // Setter function for _keyframeUpdatePeriod. This is called from // encoder_set_options if the "Keyframe Update Period" integer option is passed @@ -550,8 +569,20 @@ // when the "Encoding Quality" integer option is passed void MPEG4EncoderContext::SetProfileLevel (unsigned profileLevel) { -//FIXME + int i = 0; + while (mpeg4_profile_levels[i].profileLevel) { + if (mpeg4_profile_levels[i].profileLevel == profileLevel) + break; + i++; + } + + if (!mpeg4_profile_levels[i].profileLevel) { + TRACE(1, "MPEG4\tCap\tIllegal Profle-Level negotiated"); + return; + } + _maxBufferSize = mpeg4_profile_levels[i].maxBufferSize * 16384; + } ///////////////////////////////////////////////////////////////////////////// @@ -567,6 +598,7 @@ // affect quantization - rc_buffer_size/2. // +#ifdef WITH_FFMPEG_SRC void MPEG4EncoderContext::ResetBitCounter(int spread) { MpegEncContext *s = (MpegEncContext *) _avcontext->priv_data; int64_t wanted_bits @@ -578,8 +610,8 @@ s->rc_context.buffer_index += (want_buffer - s->rc_context.buffer_index) / double(spread); } +#endif - ///////////////////////////////////////////////////////////////////////////// // // Set static encoding parameters. These should be values that remain @@ -611,8 +643,8 @@ _avcontext->rc_buffer_aggressivity = 1.0f; // Ratecontrol buffer size, in bits. Usually 0.5-1 second worth. - // 224 kbyte is what VLC uses, and it seems to fix the quantization pulse. - _avcontext->rc_buffer_size = 224*1024*8; + // 224 kbyte is what VLC uses, and it seems to fix the quantization pulse (at Level 5) + _avcontext->rc_buffer_size = _maxBufferSize; // In MEncoder this defaults to 1/4 buffer size, but in ffmpeg.c it // defaults to 3/4. I think the buffer is supposed to stabilize at @@ -630,7 +662,11 @@ _avcontext->time_base.den = _targetFPS; // Number of frames for a group of pictures - _avcontext->gop_size = _avcontext->time_base.den * 8; + if (_keyframeUpdatePeriod == 0) + _avcontext->gop_size = _targetFPS * 8; + else + _avcontext->gop_size = _keyframeUpdatePeriod; + _throttle->reset(_avcontext->time_base.den / 2); // Set the initial frame quality to something sane @@ -800,7 +836,7 @@ size -= max_rtp; } } - + ///////////////////////////////////////////////////////////////////////////// // // The main encoding loop. If there are no packets ready to be sent, generate @@ -848,15 +884,10 @@ memcpy(_rawFrameBuffer, OPAL_VIDEO_FRAME_DATA_PTR(header), _rawFrameLen); - time_t now = time(NULL); // Should the next frame be an I-Frame? - if ((_forceKeyframeUpdate - && (now - _lastKeyframe > (_keyframeUpdatePeriod / _targetFPS) )) - || (flags & PluginCodec_CoderForceIFrame) || (_frameNum == 0)) + if ((flags & PluginCodec_CoderForceIFrame) || (_frameNum == 0)) { - _lastKeyframe = now; _avpicture->pict_type = FF_I_TYPE; - flags = PluginCodec_ReturnCoderIFrame; } else // No IFrame requested, let avcodec decide what to do { @@ -867,15 +898,21 @@ int total = FFMPEGLibraryInstance.AvcodecEncodeVideo (_avcontext, _encFrameBuffer, _encFrameLen, _avpicture); - TRACE(4, "MPEG4\tEncoded " << _encFrameLen << " bytes of YUV420P raw data into " << total << " bytes"); if (total > 0) { _frameNum++; // increment the number of frames encoded +#ifdef WITH_FFMPEG_SRC ResetBitCounter(8); // Fix ffmpeg rate control +#endif _throttle->record(total); // record frames for throttler + _isIFrame = mpeg4IsIframe(_encFrameBuffer, _encFrameLen ); } + } + if (_isIFrame) + flags |= PluginCodec_ReturnCoderIFrame; + // _packetSizes should not be empty unless we've been throttled if(_packetSizes.empty() == false) { @@ -1066,6 +1103,14 @@ width -= width % 16; height -= height % 16; + if (profileLevel == 0) { +#ifdef WITH_RFC_COMPLIANT_DEFAULTS + profileLevel = 1; +#else + profileLevel = 5; +#endif + } + if (!adjust_to_profile_level (width, height, frameTime, targetBitrate, profileLevel)) return 0; @@ -1110,7 +1155,6 @@ // 9) "Dynamic Encoding Quality" enables dynamic adjustment of encoding quality // 10) "Bandwidth Throttling" will turn on bandwidth throttling for the encoder // 11) "IQuantFactor" will update the quantization factor to a float value - // 12) "Force Keyframe Update": force the encoder to make an IFrame every 3s if (parm != NULL) { const char ** options = (const char **)parm; @@ -1137,10 +1181,15 @@ context->SetThrottle(atoi(options[i+1])); else if(STRCMPI(options[i], "IQuantFactor") == 0) context->SetIQuantFactor(atof(options[i+1])); - else if(STRCMPI(options[i], "Force Keyframe Update") == 0) - context->SetForceKeyframeUpdate(atoi(options[i+1])); } + if (profileLevel == 0) { +#ifdef WITH_RFC_COMPLIANT_DEFAULTS + profileLevel = 1; +#else + profileLevel = 5; +#endif + } if (!adjust_bitrate_to_profile_level (targetBitrate, profileLevel)) return 0; @@ -1358,7 +1407,7 @@ // // Check for errors on I-Frames. If we found one, ask for another. // - +#ifdef WITH_FFMPEG_SRC bool MPEG4DecoderContext::DecoderError(int threshold) { if (_doError) { int errors = 0; @@ -1374,8 +1423,8 @@ } return false; } +#endif - ///////////////////////////////////////////////////////////////////////////// // // If there's any other dynamic decoder updates to do, put them here. For @@ -1526,10 +1575,12 @@ _encFrameBuffer, _lastPktOffset); if (len >= 0 && got_picture) { +#ifdef WITH_FFMPEG_SRC if (DecoderError(_keyRefreshThresh)) { // ask for an IFrame update, but still show what we've got flags |= PluginCodec_ReturnCoderRequestIFrame; } +#endif TRACE(4, "MPEG4\tDecoder\tDecoded " << len << " bytes" << ", Resolution: " << _avcontext->width << "x" << _avcontext->height); // If the decoding size changes on us, we can catch it and resize if (!_disableResize @@ -1721,23 +1772,77 @@ static int MergeProfileAndLevelMPEG4(char ** result, const char * dest, const char * src) { - // Due to the "special case" where the value 8 is simple profile level zero, + // Due to the "special case" where the value 8 and 9 is simple profile level zero and zero b, // we cannot actually use a simple min merge! unsigned dstPL = strtoul(dest, NULL, 10); unsigned srcPL = strtoul(src, NULL, 10); - unsigned dstProfile = (dstPL>>4)&7; - unsigned dstLevel = dstPL&7; - unsigned srcProfile = (srcPL>>4)&7; - unsigned srcLevel = srcPL&7; + unsigned dstProfile; + int dstLevel; + unsigned srcProfile; + int srcLevel; + switch (dstPL) { + case 0: + dstProfile = 0; + dstLevel = -10; + break; + case 8: + dstProfile = 0; + dstLevel = -2; + break; + case 9: + dstProfile = 0; + dstLevel = -1; + break; + default: + dstProfile = (dstPL>>4)&7; + dstLevel = dstPL&7; + break; + } + + switch (srcPL) { + case 0: + srcProfile = 0; + srcLevel = -10; + break; + case 8: + srcProfile = 0; + srcLevel = -2; + break; + case 9: + srcProfile = 0; + srcLevel = -1; + break; + default: + srcProfile = (srcPL>>4)&7; + srcLevel = srcPL&7; + break; + } + + if (dstProfile > srcProfile) dstProfile = srcProfile; if (dstLevel > srcLevel) dstLevel = srcLevel; char buffer[10]; - sprintf(buffer, "%u", (dstProfile<<4)|(dstLevel > 0 ? dstLevel : 8)); + + switch (dstLevel) { + case -10: + sprintf(buffer, "%u", (0)); + break; + case -2: + sprintf(buffer, "%u", (8)); + break; + case -1: + sprintf(buffer, "%u", (9)); + break; + default: + sprintf(buffer, "%u", (dstProfile<<4)|(dstLevel)); + break; + } + *result = strdup(buffer); return true; @@ -1756,7 +1861,7 @@ PluginCodec_CustomMerge, // Merge mode "5", // Initial value (Simple Profile/Level 5) "profile-level-id", // FMTP option name - "1", // FMTP default value (Simple Profile/Level 1) + "0", // FMTP default value (Simple Profile/Level 1) H245_ANNEX_E_PROFILE_LEVEL, // H.245 generic capability code and bit mask "0", // Minimum value "245", // Maximum value Modified: opal/branches/NewMediaType2/plugins/video/THEORA/Makefile.in =================================================================== --- opal/branches/NewMediaType2/plugins/video/THEORA/Makefile.in 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/plugins/video/THEORA/Makefile.in 2008-01-30 08:50:56 UTC (rev 19366) @@ -38,8 +38,9 @@ STDCCFLAGS =@STDCCFLAGS@ LDFLAGS =@LDFLAGS@ THEORA_LIBS =@THEORA_LIBS@ +PLUGIN_CFLAGS =@PLUGIN_CFLAGS@ -EXTRACCFLAGS +=-I$(COMMONDIR) +EXTRACCFLAGS += $(PLUGIN_CFLAGS) -I$(COMMONDIR) vpath %.cxx $(COMMONDIR) vpath %.o $(OBJDIR) Modified: opal/branches/NewMediaType2/plugins/video/common/dyna.cxx =================================================================== --- opal/branches/NewMediaType2/plugins/video/common/dyna.cxx 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/plugins/video/common/dyna.cxx 2008-01-30 08:50:56 UTC (rev 19366) @@ -384,7 +384,7 @@ WITH_ALIGNED_STACK({ int res = Favcodec_encode_video(ctx, buf, buf_size, pict); - TRACE(4, _codecString << "\tDYNA\tEncoded video into " << res << " bytes"); + TRACE(4, _codecString << "\tDYNA\tEncoded " << buf_size << " bytes of YUV420P data into " << res << " bytes"); return res; }); } Modified: opal/branches/NewMediaType2/plugins/video/common/rtpframe.h =================================================================== --- opal/branches/NewMediaType2/plugins/video/common/rtpframe.h 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/plugins/video/common/rtpframe.h 2008-01-30 08:50:56 UTC (rev 19366) @@ -86,6 +86,14 @@ return (_frame[1] & 0x80); } + unsigned GetSequenceNumber () { + if (_frameLen < 4) + return 0; + return (_frame[2] << 8) + _frame[3]; + } + + + void SetMarker (bool set) { if (_frameLen < 2) return; Modified: opal/branches/NewMediaType2/samples/openphone/OpenPhone_2005.sln =================================================================== --- opal/branches/NewMediaType2/samples/openphone/OpenPhone_2005.sln 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/samples/openphone/OpenPhone_2005.sln 2008-01-30 08:50:56 UTC (rev 19366) @@ -43,12 +43,6 @@ Release.AspNetCompiler.Debug = "False" EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "USB HID LID", "..\..\plugins\LID\USB\USB_2005.vcproj", "{3FCBA070-C605-4EE5-B078-E2461F792B36}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ffmpeg H.263 Video Codec", "..\..\plugins\video\H.263-ffmpeg\h263ffmpeg_2005.vcproj", "{3716C952-D6E0-40C2-B132-4F6D1636D31B}" ProjectSection(WebsiteProperties) = preProject Debug.AspNetCompiler.Debug = "True" @@ -234,18 +228,6 @@ {9A4E2793-1D97-4B0C-BCFD-130136990E35}.Release|Win32.Build.0 = Release|Win32 {9A4E2793-1D97-4B0C-BCFD-130136990E35}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32 {9A4E2793-1D97-4B0C-BCFD-130136990E35}.Release|Windows Mobile 6 Professional SDK (ARMV4I).ActiveCfg = Release|Win32 - {3FCBA070-C605-4EE5-B078-E2461F792B36}.Debug|Win32.ActiveCfg = Debug|Win32 - {3FCBA070-C605-4EE5-B078-E2461F792B36}.Debug|Win32.Build.0 = Debug|Win32 - {3FCBA070-C605-4EE5-B078-E2461F792B36}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Win32 - {3FCBA070-C605-4EE5-B078-E2461F792B36}.Debug|Windows Mobile 6 Professional SDK (ARMV4I).ActiveCfg = Debug|Win32 - {3FCBA070-C605-4EE5-B078-E2461F792B36}.No Trace|Win32.ActiveCfg = Release|Win32 - {3FCBA070-C605-4EE5-B078-E2461F792B36}.No Trace|Win32.Build.0 = Release|Win32 - {3FCBA070-C605-4EE5-B078-E2461F792B36}.No Trace|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32 - {3FCBA070-C605-4EE5-B078-E2461F792B36}.No Trace|Windows Mobile 6 Professional SDK (ARMV4I).ActiveCfg = Release|Win32 - {3FCBA070-C605-4EE5-B078-E2461F792B36}.Release|Win32.ActiveCfg = Release|Win32 - {3FCBA070-C605-4EE5-B078-E2461F792B36}.Release|Win32.Build.0 = Release|Win32 - {3FCBA070-C605-4EE5-B078-E2461F792B36}.Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Release|Win32 - {3FCBA070-C605-4EE5-B078-E2461F792B36}.Release|Windows Mobile 6 Professional SDK (ARMV4I).ActiveCfg = Release|Win32 {3716C952-D6E0-40C2-B132-4F6D1636D31B}.Debug|Win32.ActiveCfg = Debug|Win32 {3716C952-D6E0-40C2-B132-4F6D1636D31B}.Debug|Win32.Build.0 = Debug|Win32 {3716C952-D6E0-40C2-B132-4F6D1636D31B}.Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I).ActiveCfg = Debug|Win32 Modified: opal/branches/NewMediaType2/src/codec/opalpluginmgr.cxx =================================================================== --- opal/branches/NewMediaType2/src/codec/opalpluginmgr.cxx 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/src/codec/opalpluginmgr.cxx 2008-01-30 08:50:56 UTC (rev 19366) @@ -178,11 +178,13 @@ OpalPluginControl::OpalPluginControl(const PluginCodec_Definition * def, const char * name) : codecDef(def) , fnName(name) - , controlDef(def->codecControls) + , controlDef(NULL) { - if (controlDef == NULL) + if (codecDef == NULL || codecDef->codecControls == NULL || name == NULL) return; + controlDef = codecDef->codecControls; + while (controlDef->name != NULL) { if (strcasecmp(controlDef->name, name) == 0 && controlDef->control != NULL) return; Modified: opal/branches/NewMediaType2/src/codec/rfc2833.cxx =================================================================== --- opal/branches/NewMediaType2/src/codec/rfc2833.cxx 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/src/codec/rfc2833.cxx 2008-01-30 08:50:56 UTC (rev 19366) @@ -120,8 +120,10 @@ if (transmitTimestampSet) frame.SetTimestamp(transmitTimestamp); rtpSession->WriteOOBData(frame); - if (!transmitTimestampSet) - transmitTimestamp = frame.GetTimestamp(); + if (!transmitTimestampSet) { + transmitTimestamp = frame.GetTimestamp(); + transmitTimestampSet = PTrue; + } } } @@ -202,11 +204,12 @@ PWaitAndSignal m(mutex); if (frame.GetPayloadSize() < 4) { - PTRACE(2, "RFC2833\tIgnoring packet, too small."); + PTRACE(2, "RFC2833\tIgnoring packet size " << frame.GetPayloadSize() << " - too small."); return; } const BYTE * payload = frame.GetPayloadPtr(); + if (payload[0] < sizeof(RFC2833Table1Events)-1) receivedTone = RFC2833Table1Events[payload[0]]; else if (payload[0] >= 192 && payload[0] <= 193) Modified: opal/branches/NewMediaType2/src/codec/vidcodec.cxx =================================================================== --- opal/branches/NewMediaType2/src/codec/vidcodec.cxx 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/src/codec/vidcodec.cxx 2008-01-30 08:50:56 UTC (rev 19366) @@ -96,7 +96,7 @@ : OpalTranscoder(inputMediaFormat, outputMediaFormat) , inDataSize(2048) , outDataSize(2048) - , forceIFrame(false) + , forceIFrame(true) { } Modified: opal/branches/NewMediaType2/src/opal/call.cxx =================================================================== --- opal/branches/NewMediaType2/src/opal/call.cxx 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/src/opal/call.cxx 2008-01-30 08:50:56 UTC (rev 19366) @@ -355,14 +355,12 @@ OpalMediaStreamPtr sink = conn->OpenMediaStream(sinkFormat, sessionID, false); if (sink != NULL) { startedOne = true; - /* if (source->RequiresPatch()) */ { - if (patch == NULL) { - patch = manager.CreateMediaPatch(*source, source->RequiresPatchThread()); - if (patch == NULL) - return false; - } - patch->AddSink(sink, map); + if (patch == NULL) { + patch = manager.CreateMediaPatch(*source, source->RequiresPatchThread()); + if (patch == NULL) + return false; } + patch->AddSink(sink, map); } } } Modified: opal/branches/NewMediaType2/src/opal/mediastrm.cxx =================================================================== --- opal/branches/NewMediaType2/src/opal/mediastrm.cxx 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/src/opal/mediastrm.cxx 2008-01-30 08:50:56 UTC (rev 19366) @@ -392,12 +392,6 @@ } -PBoolean OpalMediaStream::RequiresPatch() const -{ - return true; -} - - PBoolean OpalMediaStream::RequiresPatchThread() const { return true; @@ -501,12 +495,6 @@ } -PBoolean OpalNullMediaStream::RequiresPatch() const -{ - return false; -} - - PBoolean OpalNullMediaStream::RequiresPatchThread() const { return false; @@ -1041,7 +1029,8 @@ frame->height = height; PINDEX bytesReturned = size - sizeof(OpalVideoTranscoder::FrameHeader); - if (!inputDevice->GetFrameData((BYTE *)OPAL_VIDEO_FRAME_DATA_PTR(frame), &bytesReturned)) + unsigned flags = 0; + if (!inputDevice->GetFrameData((BYTE *)OPAL_VIDEO_FRAME_DATA_PTR(frame), &bytesReturned, flags)) return false; PTimeInterval currentGrabTime = PTimer::Tick(); @@ -1051,10 +1040,14 @@ marker = true; length = bytesReturned + sizeof(PluginCodec_Video_FrameHeader); + if ((flags & PluginCodec_CoderForceIFrame) != 0) { + ExecuteCommand(OpalVideoUpdatePicture()); + } + if (outputDevice == NULL) return true; - return outputDevice->SetFrameData(0, 0, width, height, OPAL_VIDEO_FRAME_DATA_PTR(frame), true); + return outputDevice->SetFrameData(0, 0, width, height, OPAL_VIDEO_FRAME_DATA_PTR(frame), true, flags); } Modified: opal/branches/NewMediaType2/src/sip/handlers.cxx =================================================================== --- opal/branches/NewMediaType2/src/sip/handlers.cxx 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/src/sip/handlers.cxx 2008-01-30 08:50:56 UTC (rev 19366) @@ -309,7 +309,7 @@ } // And end connect mode on the transport - transport->SetInterface(transaction.GetTransport().GetLastReceivedInterface()); + transport->SetInterface(transaction.GetInterface()); } Modified: opal/branches/NewMediaType2/src/t38/sipt38.cxx =================================================================== --- opal/branches/NewMediaType2/src/t38/sipt38.cxx 2008-01-30 08:33:47 UTC (rev 19365) +++ opal/branches/NewMediaType2/src/t38/sipt38.cxx 2008-01-30 08:50:56 UTC (rev 19366) @@ -118,3 +118,4 @@ return sdpFormat; } + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |