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>
107  createAudioDecoder(const AudioInfo& info)=0;
108 
110  //
116  virtual std::unique_ptr<VideoConverter>
117  createVideoConverter(ImgBuf::Type4CC srcFormat,
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
A class representing a single AudioInput device.
Definition: AudioInput.h:35
virtual ~MediaHandler()
Definition: MediaHandler.h:73
A virtual IO channel.
Definition: IOChannel.h:42
std::uint32_t Type4CC
Definition: VideoConverter.h:45
Information about a video stream.
Definition: MediaParser.h:322
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
char ** names[EV_MAX+1]
Definition: evtest.c:357
This is the interface for video input devices.
Definition: VideoInput.h:47
The MediaHandler class acts as a factory to provide parser and decoders.
Definition: MediaHandler.h:69
GnashFactory< MediaHandler, RegisterAllHandlers, std::string > MediaFactory
Definition: MediaHandler.h:66
MediaHandler()
Base constructor.
Definition: MediaHandler.h:148
#define DSOEXPORT
Definition: dsodefs.h:55
Definition: MediaHandler.h:61
Information about an audio stream.
Definition: MediaParser.h:236
virtual size_t getInputPaddingSize() const
Return the number of bytes padding needed for input buffers.
Definition: MediaHandler.h:141
A generic factory class for registering and retrieving objects by key.
Definition: GnashFactory.h:55