[FFmpeg-devel] [PATCH] doc/examples/muxing: make compatible with C++

Michael Niedermayer michaelni at gmx.at
Tue Mar 18 23:14:50 CET 2014


On Tue, Mar 18, 2014 at 09:37:01PM +0530, anshul wrote:
> On 03/18/2014 04:57 PM, Clément Boesch wrote:
> >On Tue, Mar 18, 2014 at 04:12:49PM +0530, anshul wrote:
> >>On 03/18/2014 12:28 AM, Stefano Sabatini wrote:
> >>>On date Friday 2014-03-14 17:15:23 +0100, Michael Niedermayer encoded:
> >>>>On Fri, Mar 14, 2014 at 10:17:16AM +0100, Stefano Sabatini wrote:
> >>>>>On date Thursday 2014-03-13 23:10:40 +0100, Clément Boesch encoded:
> >>>>>>On Thu, Mar 13, 2014 at 06:03:49PM +0100, Michael Niedermayer wrote:
> >>>>>[...]
> >>>>>>I don't think supporting examples compilation with g++ is worth the
> >>>>>>effort. Actually, I believe it's harmful because people doing C will start
> >>>>>>copying naive/broken/c++ patterns (are you going to cast malloc() return
> >>>>>>values too?).
> >>>>>+1, we decided FFmpeg was C and we shouldn't try to make half-baked
> >>>>>attempts at pretending it is C++ or the next looks-almost-like-c
> >>>>>thing.
> >>>>this patch doesnt change ffmpeg, it changes the examples.
> >>>>
> >>>>People who want to use ffmpeg from C++ need examples which work in
> >>>>C++.
> >>>>ive written that patch in response to a question of how to do what
> >>>>muxing.c does from C++ as it didnt build even with extern C and the
> >>>>error messages truly where not helpfull in figuring out what was
> >>>>the cause.
> >>>We have this page:
> >>>http://trac.ffmpeg.org/wiki/Including%20FFmpeg%20headers%20in%20a%20C%2B%2B%20application
> >>>
> >>>We could extend the page, probably rename it, add more comments about
> >>>using FFmpeg from C++ and link it from the README (which we should
> >>>rename DONTREADME so people would actually read it).
> >>>
> >>>As it is the patch is half baked, because:
> >>>
> >>>1. it is not written anywhere that examples can be directly converted
> >>>to C++ code
> >>>2. the preprocessor hack is only adopted in muxing.c, ignoring all the
> >>>other C examples.
> >>Hi
> >>
> >>Here is patch attached for cpp examples files.
> >>
> >>Please report if they fail to compile or do there intended job.
> >>
> >>
> >>Thanks
> >>Anshul
> >> From 6adc8aaf4da5bb829505f398c0c7d2be8e22081d Mon Sep 17 00:00:00 2001
> >>From: Anshul Maheshwari <er.anshul.maheshwari at gmail.com>
> >>Date: Tue, 18 Mar 2014 16:07:20 +0530
> >>Subject: [PATCH] added examples in cpp
> >>
> >>---
> >>  doc/examples_cpp/Makefile              |  44 ++
> >>  doc/examples_cpp/avcodec.cpp           | 659 ++++++++++++++++++++++++++++
> >>  doc/examples_cpp/avio_reading.cpp      | 134 ++++++
> >>  doc/examples_cpp/demuxing_decoding.cpp | 387 +++++++++++++++++
> >>  doc/examples_cpp/filter_audio.cpp      | 364 ++++++++++++++++
> >>  doc/examples_cpp/filtering_audio.cpp   | 283 +++++++++++++
> >>  doc/examples_cpp/filtering_video.cpp   | 263 ++++++++++++
> >>  doc/examples_cpp/metadata.cpp          |  58 +++
> >>  doc/examples_cpp/muxing.cpp            | 614 +++++++++++++++++++++++++++
> >>  doc/examples_cpp/remuxing.cpp          | 173 ++++++++
> >>  doc/examples_cpp/resampling_audio.cpp  | 218 ++++++++++
> >>  doc/examples_cpp/scaling_video.cpp     | 143 +++++++
> >>  doc/examples_cpp/transcode_aac.cpp     | 754 +++++++++++++++++++++++++++++++++
> >>  doc/examples_cpp/transcoding.cpp       | 602 ++++++++++++++++++++++++++
> >>  14 files changed, 4696 insertions(+)
> >>  create mode 100644 doc/examples_cpp/Makefile
> >>  create mode 100644 doc/examples_cpp/avcodec.cpp
> >>  create mode 100644 doc/examples_cpp/avio_reading.cpp
> >>  create mode 100644 doc/examples_cpp/demuxing_decoding.cpp
> >>  create mode 100644 doc/examples_cpp/filter_audio.cpp
> >>  create mode 100644 doc/examples_cpp/filtering_audio.cpp
> >>  create mode 100644 doc/examples_cpp/filtering_video.cpp
> >>  create mode 100644 doc/examples_cpp/metadata.cpp
> >>  create mode 100644 doc/examples_cpp/muxing.cpp
> >>  create mode 100644 doc/examples_cpp/remuxing.cpp
> >>  create mode 100644 doc/examples_cpp/resampling_audio.cpp
> >>  create mode 100644 doc/examples_cpp/scaling_video.cpp
> >>  create mode 100644 doc/examples_cpp/transcode_aac.cpp
> >>  create mode 100644 doc/examples_cpp/transcoding.cpp
> >>
> >This lacks the integration with our build system. It sounds like this is
> >going to be a hell to maintain...
> >
> >[...]
> >
> >
> >
> >_______________________________________________
> >ffmpeg-devel mailing list
> >ffmpeg-devel at ffmpeg.org
> >http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> I have added integration with build system.
> 
> Thanks
> Anshul Maheshwari

>  Makefile                               |    7 
>  doc/Makefile                           |   10 
>  doc/examples_cpp/Makefile              |   44 +
>  doc/examples_cpp/README                |   23 +
>  doc/examples_cpp/avcodec.cpp           |  659 ++++++++++++++++++++++++++++
>  doc/examples_cpp/avio_reading.cpp      |  134 +++++
>  doc/examples_cpp/demuxing_decoding.cpp |  387 ++++++++++++++++
>  doc/examples_cpp/filter_audio.cpp      |  365 +++++++++++++++
>  doc/examples_cpp/filtering_audio.cpp   |  283 ++++++++++++
>  doc/examples_cpp/filtering_video.cpp   |  263 +++++++++++
>  doc/examples_cpp/metadata.cpp          |   58 ++
>  doc/examples_cpp/muxing.cpp            |  614 ++++++++++++++++++++++++++
>  doc/examples_cpp/remuxing.cpp          |  173 +++++++
>  doc/examples_cpp/resampling_audio.cpp  |  218 +++++++++
>  doc/examples_cpp/scaling_video.cpp     |  143 ++++++
>  doc/examples_cpp/transcode_aac.cpp     |  754 +++++++++++++++++++++++++++++++++
>  doc/examples_cpp/transcoding.cpp       |  602 ++++++++++++++++++++++++++
>  17 files changed, 4734 insertions(+), 3 deletions(-)
> 7c6a83b9b007df59913920f5c0084f5af16cf1d0  0001-added-CPlusPlus-examples.patch
> From a98dc136a7f66ef29be0b1bca6bf9eaa9a01e9cd Mon Sep 17 00:00:00 2001
> From: Anshul Maheshwari <er.anshul.maheshwari at gmail.com>
> Date: Tue, 18 Mar 2014 21:32:08 +0530
> Subject: [PATCH] added CPlusPlus examples
> 
> ---
>  Makefile                               |   7 +-
>  doc/Makefile                           |  10 +-
>  doc/examples_cpp/Makefile              |  44 ++
>  doc/examples_cpp/README                |  23 +
>  doc/examples_cpp/avcodec.cpp           | 659 ++++++++++++++++++++++++++++
>  doc/examples_cpp/avio_reading.cpp      | 134 ++++++
>  doc/examples_cpp/demuxing_decoding.cpp | 387 +++++++++++++++++
>  doc/examples_cpp/filter_audio.cpp      | 365 ++++++++++++++++
>  doc/examples_cpp/filtering_audio.cpp   | 283 +++++++++++++
>  doc/examples_cpp/filtering_video.cpp   | 263 ++++++++++++
>  doc/examples_cpp/metadata.cpp          |  58 +++
>  doc/examples_cpp/muxing.cpp            | 614 +++++++++++++++++++++++++++
>  doc/examples_cpp/remuxing.cpp          | 173 ++++++++
>  doc/examples_cpp/resampling_audio.cpp  | 218 ++++++++++
>  doc/examples_cpp/scaling_video.cpp     | 143 +++++++
>  doc/examples_cpp/transcode_aac.cpp     | 754 +++++++++++++++++++++++++++++++++
>  doc/examples_cpp/transcoding.cpp       | 602 ++++++++++++++++++++++++++
>  17 files changed, 4734 insertions(+), 3 deletions(-)
>  create mode 100644 doc/examples_cpp/Makefile
>  create mode 100644 doc/examples_cpp/README
>  create mode 100644 doc/examples_cpp/avcodec.cpp
>  create mode 100644 doc/examples_cpp/avio_reading.cpp
>  create mode 100644 doc/examples_cpp/demuxing_decoding.cpp
>  create mode 100644 doc/examples_cpp/filter_audio.cpp
>  create mode 100644 doc/examples_cpp/filtering_audio.cpp
>  create mode 100644 doc/examples_cpp/filtering_video.cpp
>  create mode 100644 doc/examples_cpp/metadata.cpp
>  create mode 100644 doc/examples_cpp/muxing.cpp
>  create mode 100644 doc/examples_cpp/remuxing.cpp
>  create mode 100644 doc/examples_cpp/resampling_audio.cpp
>  create mode 100644 doc/examples_cpp/scaling_video.cpp
>  create mode 100644 doc/examples_cpp/transcode_aac.cpp
>  create mode 100644 doc/examples_cpp/transcoding.cpp
> 
> diff --git a/Makefile b/Makefile
> index f497f57..ca68bb5 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -47,6 +47,7 @@ FFLIBS := avutil
>  
>  DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.ffpreset) $(SRC_PATH)/doc/ffprobe.xsd
>  EXAMPLES_FILES := $(wildcard $(SRC_PATH)/doc/examples/*.c) $(SRC_PATH)/doc/examples/Makefile $(SRC_PATH)/doc/examples/README
> +CPP_EXAMPLES_FILES := $(wildcard $(SRC_PATH)/doc/examples_cpp/*.cpp) $(SRC_PATH)/doc/examples_cpp/Makefile $(SRC_PATH)/doc/examples_cpp/README
>  
>  SKIPHEADERS = cmdutils_common_opts.h compat/w32pthreads.h
>  
> @@ -146,10 +147,12 @@ install-progs: install-progs-yes $(AVPROGS)
>  	$(Q)mkdir -p "$(BINDIR)"
>  	$(INSTALL) -c -m 755 $(INSTPROGS) "$(BINDIR)"
>  
> -install-data: $(DATA_FILES) $(EXAMPLES_FILES)
> +install-data: $(DATA_FILES) $(EXAMPLES_FILES) $(CPP_EXAMPLES_FILES)
>  	$(Q)mkdir -p "$(DATADIR)/examples"
> +	$(Q)mkdir -p "$(DATADIR)/examples_cpp"
>  	$(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
>  	$(INSTALL) -m 644 $(EXAMPLES_FILES) "$(DATADIR)/examples"
> +	$(INSTALL) -m 644 $(CPP_EXAMPLES_FILES) "$(DATADIR)/examples_cpp"
>  
>  uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
>  
> @@ -173,7 +176,7 @@ distclean::
>  config:
>  	$(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION)
>  
> -check: all alltools examples testprogs fate
> +check: all alltools examples examples_cpp testprogs fate
>  
>  include $(SRC_PATH)/tests/Makefile
>  
> diff --git a/doc/Makefile b/doc/Makefile
> index 10f03cc..eddd6b4 100644
> --- a/doc/Makefile
> +++ b/doc/Makefile
> @@ -56,6 +56,8 @@ ALL_DOC_EXAMPLES   := $(ALL_DOC_EXAMPLES_LIST:%=doc/examples/%$(PROGSSUF)$(EXESU
>  ALL_DOC_EXAMPLES_G := $(ALL_DOC_EXAMPLES_LIST:%=doc/examples/%$(PROGSSUF)_g$(EXESUF))
>  PROGS              += $(DOC_EXAMPLES)
>  
> +DOC_EXAMPLES_CPP_DIR := doc/examples_cpp/
> +
>  all-$(CONFIG_DOC): doc
>  
>  doc: documentation

> @@ -65,6 +67,9 @@ documentation: $(DOCS)
>  
>  examples: $(DOC_EXAMPLES)
>  
> +examples_cpp:
> +	make -C $(DOC_EXAMPLES_CPP_DIR)

this will not work on BSD as its called gmake there



> +
>  TEXIDEP = perl $(SRC_PATH)/doc/texidep.pl $(SRC_PATH) $< $@ >$(@:%=%.d)
>  
>  doc/%.txt: TAG = TXT
> @@ -158,7 +163,10 @@ examplesclean:
>  	$(RM) $(ALL_DOC_EXAMPLES) $(ALL_DOC_EXAMPLES_G)
>  	$(RM) $(CLEANSUFFIXES:%=doc/examples/%)
>  
> -docclean: examplesclean
> +examples_cpp_clean:
> +	make -C $(DOC_EXAMPLES_CPP_DIR) clean
> +
> +docclean: examplesclean examples_cpp_clean
>  	$(RM) $(CLEANSUFFIXES:%=doc/%)
>  	$(RM) $(TXTPAGES) doc/*.html doc/*.pod doc/*.1 doc/*.3 doc/avoptions_*.texi
>  	$(RM) -r doc/doxy/html

> diff --git a/doc/examples_cpp/Makefile b/doc/examples_cpp/Makefile
> new file mode 100644
> index 0000000..fc5ce9f
> --- /dev/null
> +++ b/doc/examples_cpp/Makefile
> @@ -0,0 +1,44 @@
> +
> +CC=g++

its not guranteed the c++ compiler is called g++ nor is it guranteed
that one is there at all


also if you want to maintain this code, please add yourself to
the MAINTAINERs file

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140318/9f909040/attachment.asc>


More information about the ffmpeg-devel mailing list