2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
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.
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.
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
22 #include <boost/intrusive_ptr.hpp>
23 #include "DisplayObject.h"
25 // Forward declarations
34 class DefineVideoStreamTag
;
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.
49 class Video
: public DisplayObject
53 Video(as_object
* object
, const SWF::DefineVideoStreamTag
* def
,
54 DisplayObject
* parent
);
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
);
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.
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.
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
; }
102 /// Mark video-specific reachable resources.
104 /// video-specific reachable resources are:
105 /// - Associated NetStream if any (_ns)
107 virtual void markOwnResources() const;
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 ?
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