Update with current status
[gnash.git] / libcore / Video.h
blob157cb99b460a4d0ac8f4e5a4747f8e74e653044f
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #ifndef GNASH_VIDEO_H
20 #define GNASH_VIDEO_H
22 #include <boost/intrusive_ptr.hpp>
23 #include "DisplayObject.h"
25 // Forward declarations
26 namespace gnash {
27 class NetStream_as;
28 class as_object;
29 namespace image {
30 class GnashImage;
32 struct ObjectURI;
33 namespace SWF {
34 class DefineVideoStreamTag;
36 namespace media {
37 class VideoDecoder;
41 namespace gnash {
43 /// VideoStream ActionScript object
45 /// A VideoStream provides audio/video frames either
46 /// embedded into the SWF itself or loaded from the
47 /// network using an associated NetStream object.
48 ///
49 class Video : public DisplayObject
51 public:
53 Video(as_object* object, const SWF::DefineVideoStreamTag* def,
54 DisplayObject* parent);
56 ~Video();
58 virtual bool pointInShape(std::int32_t x, std::int32_t y) const
60 // video DisplayObject shape is always a rectangle..
61 return pointInBounds(x, y);
64 virtual SWFRect getBounds() const;
66 /// Register this video instance as a live DisplayObject
67 virtual void construct(as_object* init = nullptr);
69 virtual void display(Renderer& renderer, const Transform& xform);
71 void add_invalidated_bounds(InvalidatedRanges& ranges, bool force);
73 /// Set the input stream for this video
74 void setStream(NetStream_as* ns);
76 void clear();
78 /// Get the height of the video.
80 /// The method depends on whether it is an embedded or a live
81 /// stream. This returns 0 until the height is known, which for
82 /// FLV streams is only after decoding. The value may possibly
83 /// vary during playback.
84 int height() const;
86 /// Get the width of the video.
88 /// The method depends on whether it is an embedded or a live
89 /// stream. This returns 0 until the height is known, which for
90 /// FLV streams is only after decoding. The value may possibly
91 /// vary during playback.
92 int width() const;
94 /// Whether this Video object should request smoothing when scaled.
95 bool smoothing() const { return _smoothing; }
97 /// Set whether smoothing is required.
98 void setSmoothing(bool b) { _smoothing = b; }
100 protected:
102 /// Mark video-specific reachable resources.
104 /// video-specific reachable resources are:
105 /// - Associated NetStream if any (_ns)
107 virtual void markOwnResources() const;
109 private:
111 /// Get video frame to be displayed
112 image::GnashImage* getVideoFrame();
114 const boost::intrusive_ptr<const SWF::DefineVideoStreamTag> m_def;
116 // Who owns this ? Should it be an intrusive ptr ?
117 NetStream_as* _ns;
119 /// Playing an embbeded video stream ?
120 bool _embeddedStream;
122 /// Last decoded frame number
123 std::int32_t _lastDecodedVideoFrameNum;
125 /// Last decoded frame
126 std::unique_ptr<image::GnashImage> _lastDecodedVideoFrame;
128 /// The decoder used to decode the video frames for embedded streams
130 /// For dynamically loaded videos NetStream takes care of decoding
131 /// see the _ns property
133 std::unique_ptr<media::VideoDecoder> _decoder;
135 /// Whether to request smoothing when the video is scaled
136 bool _smoothing;
139 } // namespace gnash
141 #endif