2009-11-08 Chris Toshok <toshok@ximian.com>
[moon.git] / src / pipeline-ffmpeg.h
blobc8bc6475ff6c72f2ed09d12d4181d81f55376147
1 /*
2 * pipeline.h: Ffmpeg related parts of the pipeline for the media
4 * Contact:
5 * Moonlight List (moonlight-list@lists.ximian.com)
7 * Copyright 2007 Novell, Inc. (http://www.novell.com)
9 * See the LICENSE file included with the distribution for details.
13 #ifdef INCLUDE_FFMPEG
15 #ifndef __MOON_PIPELINE_FFMPEG__
16 #define __MOON_PIPELINE_FFMPEG__
18 #include <glib.h>
20 G_BEGIN_DECLS
21 #include <limits.h>
22 #if HAVE_LIBAVCODEC_AVCODEC_H
23 #include <libavcodec/avcodec.h>
24 #else
25 #include <avcodec.h>
26 #endif
27 G_END_DECLS
29 #include "pipeline.h"
31 #define AUDIO_BUFFER_SIZE (AVCODEC_MAX_AUDIO_FRAME_SIZE * 2)
33 void register_ffmpeg ();
35 class FfmpegDemuxer : public IMediaDemuxer {
36 public:
37 FfmpegDemuxer (Media *media, IMediaSource *source);
40 class FfmpegDecoder : public IMediaDecoder {
41 private:
42 AVCodecContext *context;
43 guint8* audio_buffer;
44 guint8* frame_buffer;
45 guint32 frame_buffer_length;
46 guint64 last_pts;
47 bool has_delayed_frame;
49 MediaResult Open ();
51 protected:
52 virtual ~FfmpegDecoder () {}
53 virtual void DecodeFrameAsyncInternal (MediaFrame* frame);
54 virtual void OpenDecoderAsyncInternal ();
56 public:
57 FfmpegDecoder (Media* media, IMediaStream* stream);
58 virtual void Dispose ();
59 virtual void Cleanup (MediaFrame* frame);
60 virtual void CleanState ();
61 virtual bool HasDelayedFrame () {return has_delayed_frame; }
63 static PixelFormat ToFfmpegPixFmt (MoonPixelFormat format);
64 static MoonPixelFormat ToMoonPixFmt (PixelFormat format);
67 class FfmpegDecoderInfo : public DecoderInfo {
68 public:
69 virtual bool Supports (const char* codec);
70 virtual IMediaDecoder* Create (Media* media, IMediaStream* stream);
71 virtual const char* GetName () { return "FfmpegDecoder"; }
74 #endif // __MOON_PIPELINE_FFMPEG__
75 #endif // INCLUDE_FFMPEG