source: branches/blt4/src/objects/RpMediaPlayer.h @ 1902

Last change on this file since 1902 was 1902, checked in by gah, 14 years ago
File size: 2.5 KB
Line 
1/*
2 * ======================================================================
3 *  Rappture::MediaPlayer
4 *
5 *  AUTHOR:  Derrick Kearney, Purdue University
6 *
7 *  Copyright (c) 2005-2010  Purdue Research Foundation
8 * ----------------------------------------------------------------------
9 *  See the file "license.terms" for information on usage and
10 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11 * ======================================================================
12 */
13
14#ifndef RP_MEDIAPLAYER_H
15#define RP_MEDIAPLAYER_H 1
16
17#include "config.h"
18
19extern "C" {
20#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
33#include <libavcodec/avcodec.h>
34#endif
35
36#ifdef HAVE_FFMPEG_SWSCALE_H
37#include <ffmpeg/swscale.h>
38#endif
39#ifdef HAVE_LIBSWSCALE_SWSCALE_H
40#include <libswscale/swscale.h>
41#endif
42}
43
44
45#include "RpOutcome.h"
46#include "RpSimpleBuffer.h"
47
48namespace Rappture {
49
50class MediaPlayer {
51public:
52    enum VideoFormats { MPEG1, MPEG4, THEORA, QUICKTIME };
53    MediaPlayer();
54    virtual ~MediaPlayer();
55
56    bool init(Outcome &status, const char *filename);
57    bool load(Outcome &status, const char *filename);
58    bool release();
59
60    size_t nframes() const;
61
62    size_t read(Outcome &status, SimpleCharBuffer *b);
63    int seek(long offset, int whence);
64    int tell() const;
65    size_t set(size_t nframes);
66
67    bool good() const;
68    bool bad() const;
69    bool eof() const;
70
71private:
72    void __frame2ppm(SimpleCharBuffer *b);
73
74    size_t _width;
75    size_t _height;
76    size_t _bitRate;
77    float _frameRate;                // frames/seconds
78
79    AVFormatContext *_pFormatCtx;
80    int _videoStream;
81    AVCodecContext *_pCodecCtx;
82    AVCodec *_pCodec;
83    AVFrame *_pFrame;
84    AVFrame *_pFrameRGB;
85    AVPacket _packet;
86    uint8_t *_buffer;
87    struct SwsContext *_swsctx;
88
89
90
91    size_t width(void) {
92        return _width;
93    }
94    void width(size_t width) {
95        _width = width;
96    }
97    size_t height(void) {
98        return _width;
99    }
100    void height(size_t width) {
101        _width = width;
102    }
103    size_t bitRate(void) {
104        return _bitRate;
105    }
106    void bitRate(size_t bitRate) {
107        _bitRate = bitRate;
108    }
109    float frameRate(void) {
110        return _frameRate;
111    }
112    void frameRate(size_t frameRate) {
113        _frameRate = frameRate;
114    }
115
116};
117
118} // namespace Rappture
119
120#endif /* RP_MEDIAPLAYER_H */
Note: See TracBrowser for help on using the repository browser.