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