~ubuntu-branches/ubuntu/karmic/gnash/karmic

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// 
//   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
// 
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

// 

#ifndef GNASH_VIDEO_STREAM_INSTANCE_H
#define GNASH_VIDEO_STREAM_INSTANCE_H

#include "character.h" // for inheritance
#include "video_stream_def.h"
#include "snappingrange.h"

// Forward declarations
namespace gnash {
	class NetStream;
}

namespace gnash {

/// VideoStream ActionScript object
//
/// A VideoStream provides audio/video frames either
/// embedded into the SWF itself or loaded from the
/// network using an associated NetStream object.
///
class video_stream_instance : public character
{

public:

	boost::intrusive_ptr<video_stream_definition>	m_def;
	
	video_stream_instance(video_stream_definition* def,
			character* parent, int id);

	~video_stream_instance();

	virtual bool pointInShape(boost::int32_t x, boost::int32_t y) const
	{
		// video character shape is always a rectangle..
		return pointInBounds(x, y);
	}

	rect getBounds() const;

	/// We use the call to ::advance to properly set invalidated status
	virtual void	advance();

	/// Register this video instance as a live character
	virtual void stagePlacementCallback();

	void	display();

	// For sure isActionScriptReferenceable...
	bool wantsInstanceName() const
	{
		return true; // text fields can be referenced 
	}	

	void add_invalidated_bounds(InvalidatedRanges& ranges, bool force);

	/// Set the input stream for this video
	void setStream(boost::intrusive_ptr<NetStream> ns);

protected:

#ifdef GNASH_USE_GC
	/// Mark video-specific reachable resources and invoke
	/// the parent's class version (markCharacterReachable)
	//
	/// video-specific reachable resources are:
	///	- Associated NetStream if any (_ns) 
	///
	virtual void markReachableResources() const;
#endif // GNASH_USE_GC

private:

	/// Initialize decoder for embedded video 
	//
	/// Call only if given a non-null video definition.
	///
	void initializeDecoder();

	/// Get video frame to be displayed
	image::ImageBase* getVideoFrame();

	// m_video_source - A Camera object that is capturing video data or a NetStream object.
	// To drop the connection to the Video object, pass null for source.
	// FIXME: don't use as_object, but a more meaningful type
	//as_object* m_video_source;

	// Who owns this ? Should it be an intrusive ptr ?
	boost::intrusive_ptr<NetStream> _ns;

	/// Playing an embbeded video stream ?
	bool _embeddedStream;

	/// Last decoded frame number
	boost::int32_t _lastDecodedVideoFrameNum;

	/// Last decoded frame 
	std::auto_ptr<image::ImageBase> _lastDecodedVideoFrame;

	/// The decoder used to decode the video frames
	std::auto_ptr<media::VideoDecoder> _decoder;
};

void video_class_init(as_object& global);

}	// end namespace gnash


#endif // GNASH_VIDEO_STREAM_INSTANCE_H