Gnash  0.8.11dev
MediaHandler.h
Go to the documentation of this file.
1 // MediaHandler.h: Base class for media handlers
2 //
3 // Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
4 // Free Software Foundation, Inc.
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 
20 
21 #ifndef GNASH_MEDIAHANDLER_H
22 #define GNASH_MEDIAHANDLER_H
23 
24 #include "dsodefs.h" // DSOEXPORT
25 #include "VideoConverter.h"
26 
27 #include <vector>
28 #include <memory>
29 #include <string>
30 
31 #include "GnashFactory.h"
32 
33 // Forward declarations
34 namespace gnash {
35  class IOChannel;
36  namespace media {
37  class VideoDecoder;
38  class AudioDecoder;
39  class AudioInfo;
40  class VideoInfo;
41  class VideoInput;
42  class AudioInput;
43  class MediaHandler;
44  class MediaParser;
45  }
46 }
47 
48 namespace gnash {
49 
51 //
59 namespace media {
60 
62 {
64 };
65 
67 
70 {
71 public:
72 
73  virtual ~MediaHandler() {}
74 
76  virtual std::string description() const = 0;
77 
79  //
88  virtual std::unique_ptr<MediaParser>
89  createMediaParser(std::unique_ptr<IOChannel> stream);
90 
92  //
97  virtual std::unique_ptr<VideoDecoder>
98  createVideoDecoder(const VideoInfo& info)=0;
99 
101  //
106  virtual std::unique_ptr<AudioDecoder>
108 
110  //
116  virtual std::unique_ptr<VideoConverter>
118  ImgBuf::Type4CC dstFormat)=0;
119 
121  //
124  //
128  virtual VideoInput* getVideoInput(size_t index) = 0;
129 
130  virtual AudioInput* getAudioInput(size_t index) = 0;
131 
133  //
135  virtual void cameraNames(std::vector<std::string>& names) const = 0;
136 
138  //
141  virtual size_t getInputPaddingSize() const { return 0; }
142 
143 protected:
144 
146  //
149 
151  //
163  std::unique_ptr<AudioDecoder> createFlashAudioDecoder(const AudioInfo& info);
164 
166  //
168  bool isFLV(IOChannel& stream);
169 
170 };
171 
172 
173 } // gnash.media namespace
174 
175 // In order for GnashFactory to work correctly, there must be only a single
176 // instantiation of MediaFactory. Therefore, we declare its type as extern,
177 // which we can now that its dependent types are fully specified.
178 extern template class GnashFactory<media::MediaHandler,
179  media::RegisterAllHandlers, std::string>; // I.e., typedef MediaFactory.
180 
181 } // namespace gnash
182 
183 #endif
AudioDecoderSpeex.h
gnash::media::AudioDecoderSimple
Audio decoding using "simple" internal decoders.
Definition: AudioDecoderSimple.h:39
gnash::media::MediaHandler::createMediaParser
virtual std::unique_ptr< MediaParser > createMediaParser(std::unique_ptr< IOChannel > stream)
Return an appropriate MediaParser for given input.
Definition: MediaHandler.cpp:65
VideoConverter.h
gnash::media::AUDIO_CODEC_ADPCM
@ AUDIO_CODEC_ADPCM
ADPCM format.
Definition: MediaParser.h:148
dsodefs.h
_
#define _(String)
Definition: log.h:44
MediaHandler.h
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
AudioDecoderSimple.h
gnash::media::AudioInfo::codec
int codec
Codec identifier.
Definition: MediaParser.h:286
GnashFactory.h
gnash::media::VideoInfo
Information about a video stream.
Definition: MediaParser.h:323
gnash::key::m
@ m
Definition: GnashKey.h:159
gnash::media::AudioInput
A class representing a single AudioInput device.
Definition: AudioInput.h:36
gnash::media::MediaHandler::cameraNames
virtual void cameraNames(std::vector< std::string > &names) const =0
Return a list of available cameras.
gnash::IOChannel::seek
virtual bool seek(std::streampos p)=0
Seek to the specified position.
MediaHandlerHaiku.h
gnash::media::AUDIO_CODEC_SPEEX
@ AUDIO_CODEC_SPEEX
Always 16kHz mono.
Definition: MediaParser.h:187
gnash::log_error
void log_error(StringType msg, Args... args)
Definition: log.h:283
gnash::media::MediaHandler::createFlashAudioDecoder
std::unique_ptr< AudioDecoder > createFlashAudioDecoder(const AudioInfo &info)
Create an AudioDecoder for CODEC_TYPE_FLASH codecs.
Definition: MediaHandler.cpp:89
gnash::media::AUDIO_CODEC_UNCOMPRESSED
@ AUDIO_CODEC_UNCOMPRESSED
Linear PCM, strictly little-endian.
Definition: MediaParser.h:167
gnash::media::MediaHandler
The MediaHandler class acts as a factory to provide parser and decoders.
Definition: MediaHandler.h:70
gnash::media::MediaHandler::MediaHandler
MediaHandler()
Base constructor.
Definition: MediaHandler.h:148
gnash::IOChannel
A virtual IO channel.
Definition: IOChannel.h:43
gnash::IOException
Exception signalling an IO error.
Definition: IOChannel.h:35
FLVParser.h
gnash::media::AUDIO_CODEC_RAW
@ AUDIO_CODEC_RAW
Signed Linear PCM, unspecified byte order.
Definition: MediaParser.h:135
gnash::media::MediaFactory
GnashFactory< MediaHandler, RegisterAllHandlers, std::string > MediaFactory
Definition: MediaHandler.h:66
gnash::GnashFactory::RegisterHandler
Definition: GnashFactory.h:64
gnash::media::ImgBuf::Type4CC
std::uint32_t Type4CC
Definition: VideoConverter.h:45
gnash::media::audioCodecType
audioCodecType
Audio codec ids as defined in flash.
Definition: MediaParser.h:123
gnash::media::RegisterAllHandlers
Definition: MediaHandler.h:62
gnash::media::MediaHandler::description
virtual std::string description() const =0
Return a description of this media handler.
gnash::media::CODEC_TYPE_FLASH
@ CODEC_TYPE_FLASH
The internal flash codec ids.
Definition: MediaParser.h:68
MediaHandlerGst.h
names
char ** names[EV_MAX+1]
Definition: evtest.c:357
gnash::media::AudioInfo
Information about an audio stream.
Definition: MediaParser.h:237
gnash::media::MediaHandler::getVideoInput
virtual VideoInput * getVideoInput(size_t index)=0
Return a VideoInput.
gst
gnash::media::MediaHandler::createAudioDecoder
virtual std::unique_ptr< AudioDecoder > createAudioDecoder(const AudioInfo &info)=0
Create an AudioDecoder for decoding what's specified in the AudioInfo.
log.h
gnash::media::MediaHandler::createVideoDecoder
virtual std::unique_ptr< VideoDecoder > createVideoDecoder(const VideoInfo &info)=0
Create a VideoDecoder for decoding what's specified in the VideoInfo.
gnash::GnashFactory
A generic factory class for registering and retrieving objects by key.
Definition: GnashFactory.h:56
gnash::media::RegisterAllHandlers::RegisterAllHandlers
RegisterAllHandlers()
Definition: MediaHandler.cpp:141
gnashconfig.h
gnash::media::MediaHandler::isFLV
bool isFLV(IOChannel &stream)
Return true if input stream is an FLV.
Definition: MediaHandler.cpp:47
gnash::media::MediaHandler::getInputPaddingSize
virtual size_t getInputPaddingSize() const
Return the number of bytes padding needed for input buffers.
Definition: MediaHandler.h:141
DSOEXPORT
#define DSOEXPORT
Definition: dsodefs.h:55
gnash::media::MediaHandler::getAudioInput
virtual AudioInput * getAudioInput(size_t index)=0
gnash::media::AudioDecoderSpeex
Audio decoder for the speex codec.
Definition: AudioDecoderSpeex.h:41
gnash::equal
bool equal(string_table &st, string_table::key a, string_table::key b, bool caseless)
Check whether two keys are equivalent.
Definition: string_table.cpp:174
gnash::media::FLVParser
The FLVParser class parses FLV streams.
Definition: FLVParser.h:105
gnash::media::VideoInput
This is the interface for video input devices.
Definition: VideoInput.h:47
gnash::media::MediaHandler::createVideoConverter
virtual std::unique_ptr< VideoConverter > createVideoConverter(ImgBuf::Type4CC srcFormat, ImgBuf::Type4CC dstFormat)=0
Create an VideoConverter for converting between color spaces.
gnash::media::MediaHandler::~MediaHandler
virtual ~MediaHandler()
Definition: MediaHandler.h:73
gnash::MediaException
An exception from MediaHandler subsystem.
Definition: GnashException.h:50
IOChannel.h
gnash::media::AudioInfo::type
codecType type
Definition: MediaParser.h:297
gnash::IOChannel::read
virtual std::streamsize read(void *dst, std::streamsize num)=0
Read the given number of bytes from the stream.
MediaHandlerFfmpeg.h