Changeset 1873 for trunk/src


Ignore:
Timestamp:
Aug 24, 2010 2:29:21 AM (14 years ago)
Author:
dkearney
Message:

adding video viewing widget. this requires ffmpeg and libav* friends. if the libs are not available, the widget won't be built

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/Makefile.in

    r1825 r1873  
    7979                rappture.h
    8080
     81LOCAL_HEADERS = \
     82                config.h
    8183
    8284SCEW_HEADERS    = \
     
    181183          $(INSTALL) -m 444  $(srcdir)/$$i $(incdir) ; \
    182184        done
     185        for i in $(LOCAL_HEADERS) ; do \
     186          $(INSTALL) -m 444  $$i $(incdir) ; \
     187        done
    183188
    184189.cc.o:
  • trunk/src/core/config.h.in

    r1844 r1873  
    33/* Define if building universal (internal helper macro) */
    44#undef AC_APPLE_UNIVERSAL_BUILD
     5
     6/* Build rappture with ffmpeg widgets */
     7#undef BUILD_with_ffmpeg
    58
    69/* Define to 1 if you have the <algorithm> header file. */
     
    3437#undef HAVE_ERRNO_H
    3538
     39/* Define to 1 if you have the <ffmpeg/avcodec.h> header file. */
     40#undef HAVE_FFMPEG_AVCODEC_H
     41
     42/* Define to 1 if you have the <ffmpeg/avformat.h> header file. */
     43#undef HAVE_FFMPEG_AVFORMAT_H
     44
     45/* Define to 1 if you have the <ffmpeg/avutil.h> header file. */
     46#undef HAVE_FFMPEG_AVUTIL_H
     47
     48/* Define to 1 if you have the <ffmpeg/swscale.h> header file. */
     49#undef HAVE_FFMPEG_SWSCALE_H
     50
    3651/* Define to 1 if you have the <float.h> header file. */
    3752#undef HAVE_FLOAT_H
     
    3954/* Define to 1 if you have the <fstream> header file. */
    4055#undef HAVE_FSTREAM
     56
     57/* Define to 1 if you have the `img_convert' function. */
     58#undef HAVE_IMG_CONVERT
    4159
    4260/* Define to 1 if you have the <inttypes.h> header file. */
     
    4967#undef HAVE_ITERATOR
    5068
     69/* Define to 1 if you have the <libavcodec/avcodec.h> header file. */
     70#undef HAVE_LIBAVCODEC_AVCODEC_H
     71
     72/* Define to 1 if you have the <libavformat/avformat.h> header file. */
     73#undef HAVE_LIBAVFORMAT_AVFORMAT_H
     74
     75/* Define to 1 if you have the <libavutil/avutil.h> header file. */
     76#undef HAVE_LIBAVUTIL_AVUTIL_H
     77
    5178/* Define to 1 if you have the `m' library (-lm). */
    5279#undef HAVE_LIBM
     
    5481/* Define to 1 if you have the `stdc++' library (-lstdc++). */
    5582#undef HAVE_LIBSTDC__
     83
     84/* Define to 1 if you have the <libswscale/swscale.h> header file. */
     85#undef HAVE_LIBSWSCALE_SWSCALE_H
    5686
    5787/* Define to 1 if you have the <limits.h> header file. */
     
    93123/* Define to 1 if you have the <string.h> header file. */
    94124#undef HAVE_STRING_H
     125
     126/* Define to 1 if you have the `sws_scale' function. */
     127#undef HAVE_SWS_SCALE
    95128
    96129/* Define to 1 if you have the `sysinfo' function. */
  • trunk/src/objects/Makefile.in

    r1581 r1873  
    2727LIB_SEARCH_DIRS = @LIB_SEARCH_DIRS@
    2828CFLAGS          = @CFLAGS@
     29FFMPEG          = @HAVE_FFMPEG_LIBS@
    2930RM              = rm -f
    3031CC_SWITCHES = $(CFLAGS) $(INCLUDES) $(DEFINES) $(CFLAGS_DEBUG)
     
    3738                -I$(includedir)
    3839LIBS        = -L../core -lrappture
     40
    3941
    4042RANLIB      = @RANLIB@
     
    110112                RpObject.o
    111113
     114ifeq ($(FFMPEG),yes)
     115  # since ffmpeg libraries are available,
     116  # include them in compilation
     117  LIBS += -lavcodec -lavformat -lswscale
     118  HEADERS += RpMediaPlayer.h
     119  OBJS += RpMediaPlayer.o
     120endif
     121
    112122
    113123name        = RpObjects
  • trunk/src/objects/RpMediaPlayer.cc

    r1850 r1873  
    5151MediaPlayer::~MediaPlayer()
    5252{
    53     // close();
     53    // release();
    5454}
    5555
     
    151151
    152152bool
    153 MediaPlayer::close()
    154 {
    155     // status.addContext("Rappture::MediaPlayer::close()");
     153MediaPlayer::release()
     154{
     155    // status.addContext("Rappture::MediaPlayer::release()");
    156156
    157157    // Free the RGB image
     
    188188
    189189size_t
    190 MediaPlayer::read(Outcome &status, SimpleCharBuffer *b[], size_t nframes)
     190MediaPlayer::read(Outcome &status, SimpleCharBuffer *b)
    191191{
    192192    status.addContext("Rappture::MediaPlayer::read()");
    193193
    194194    int frameFinished = 0;
    195     size_t frameIndex = 0;
    196     size_t frameCount = 0;
    197195
    198196    while(av_read_frame(_pFormatCtx, &_packet)>=0) {
     
    206204            if (frameFinished) {
    207205                // Convert the image from its native format to RGB
    208                 if (frameCount >= nframes) {
    209                     // artificially limit number of images saved
    210                     break;
    211                 }
    212                 if ((frameIndex%1000) == 0) {
    213                     // artificially spread out the saved frames
    214                     sws_scale(_swsctx,
    215                               (const uint8_t * const*)_pFrame->data,
    216                               _pFrame->linesize, 0, _pCodecCtx->height,
    217                               _pFrameRGB->data, _pFrameRGB->linesize);
    218 
    219                     // Save the frame to the SimpleBuffer object
    220                     // FIXME:
    221                     // should be b[frameCount] but operator[] was
    222                     // overloaded in Rappture::SimpleBuffer, and I
    223                     // think it is causing problems
    224                     __frame2ppm(*b+frameCount);
    225                     frameCount++;
    226                 }
    227                 frameIndex++;
     206                sws_scale(_swsctx,
     207                          (const uint8_t * const*)_pFrame->data,
     208                          _pFrame->linesize, 0, _pCodecCtx->height,
     209                          _pFrameRGB->data, _pFrameRGB->linesize);
     210
     211                __frame2ppm(b);
     212                break;
    228213            }
    229214        }
     
    232217        av_free_packet(&_packet);
    233218    }
    234     return frameCount;
     219    return 1;
    235220}
    236221
  • trunk/src/objects/RpMediaPlayer.h

    r1847 r1873  
    1515#define RP_MEDIAPLAYER_H 1
    1616
     17#include "config.h"
     18
    1719extern "C" {
    18 // https://roundup.ffmpeg.org/issue2093
    1920#define __STDC_CONSTANT_MACROS 1
     21
     22#ifdef HAVE_FFMPEG_AVFORMAT_H
     23#include <ffmpeg/avformat.h>
     24#endif
     25#ifdef HAVE_LIBAVFORMAT_AVFORMAT_H
     26#include <libavformat/avformat.h>
     27#endif
     28
     29#ifdef HAVE_FFMPEG_AVCODEC_H
     30#include <ffmpeg/avcodec.h>
     31#endif
     32#ifdef HAVE_LIBAVCODEC_AVCODEC_H
    2033#include <libavcodec/avcodec.h>
    21 #include <libavformat/avformat.h>
     34#endif
     35
     36#ifdef HAVE_FFMPEG_SWSCALE_H
     37#include <ffmpeg/swscale.h>
     38#endif
     39#ifdef HAVE_LIBSWSCALE_SWSCALE_H
    2240#include <libswscale/swscale.h>
     41#endif
    2342}
     43
    2444
    2545#include "RpOutcome.h"
     
    3656    bool init(Outcome &status, const char *filename);
    3757    bool load(Outcome &status, const char *filename);
    38     bool close();
     58    bool release();
    3959
    4060    size_t nframes() const;
    4161
    42     size_t read(Outcome &status, SimpleCharBuffer *b[], size_t nframes);
     62    size_t read(Outcome &status, SimpleCharBuffer *b);
    4363    int seek(long offset, int whence);
    4464    int tell() const;
     
    97117
    98118} // namespace Rappture
    99  
     119
    100120#endif /* RP_MEDIAPLAYER_H */
Note: See TracChangeset for help on using the changeset viewer.