1/*
2 * Copyright (c) 2004-2007 Marcus Overhagen <marcus@overhagen.de>
3 *
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without restriction,
7 * including without limitation the rights to use, copy, modify,
8 * merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
23 */
24#ifndef __VIDEO_NODE_H_
25#define __VIDEO_NODE_H_
26
27
28#include <BufferConsumer.h>
29#include <MediaEventLooper.h>
30
31class BLocker;
32class VideoView;
33
34
35class VideoNode : public BMediaEventLooper, public BBufferConsumer {
36public:
37					VideoNode(const char *name, VideoView *view);
38					~VideoNode();
39
40	void			SetOverlayEnabled(bool yesno);
41	bool			IsOverlayActive();
42
43	void			LockBitmap();
44	BBitmap *		Bitmap();
45	void			UnlockBitmap();
46
47protected:
48	BMediaAddOn	*	AddOn(int32 *internal_id) const;
49
50	void			NodeRegistered();
51
52	void			BufferReceived(BBuffer * buffer);
53
54	status_t		GetNextInput(int32 *cookie,	media_input *out_input);
55	void			DisposeInputCookie(int32 cookie);
56
57	status_t		HandleMessage(int32 message, const void *data, size_t size);
58
59	void			HandleEvent(const media_timed_event *event,
60						bigtime_t lateness, bool realTimeEvent);
61
62	status_t		AcceptFormat(const media_destination &dst,
63						media_format *format);
64
65	void			ProducerDataStatus(const media_destination &dst,
66						int32 status, bigtime_t at_media_time);
67
68	status_t		GetLatencyFor(const media_destination &dst,
69						bigtime_t *out_latency, media_node_id *out_id);
70
71	status_t		Connected(const media_source &src,
72						const media_destination &dst,
73						const media_format &format, media_input *out_input);
74
75	void			Disconnected(const media_source &src,
76						const media_destination &dst);
77
78	status_t		FormatChanged(const media_source &src,
79						const media_destination &dst, int32 from_change_count,
80						const media_format &format);
81
82protected:
83	void			HandleBuffer(BBuffer *buffer);
84	status_t		CreateBuffers(BRect frame, color_space cspace, bool overlay);
85	void			DeleteBuffers();
86
87protected:
88	VideoView *		fVideoView;
89	media_input		fInput;
90	bool			fOverlayEnabled;
91	bool			fOverlayActive;
92	bool			fDirectOverlayBuffer;	// If the overlay memory is directly written by the producer node.
93	BBitmap *		fBitmap;
94	BLocker	*		fBitmapLocker;
95};
96
97#endif	// __VIDEO_NODE_H_
98