xref: /haiku/src/add-ons/media/media-add-ons/videowindow/VideoNode.h (revision 2f470aec1c92ce6917b8a903e343795dc77af41f)
1 /*
2  * VideoNode.h - "Video Window" media add-on.
3  *
4  * Copyright (C) 2006 Marcus Overhagen <marcus@overhagen.de>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * version 2 as published by the Free Software Foundation.
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 Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  *
19  */
20 #ifndef __VIDEO_NODE_H_
21 #define __VIDEO_NODE_H_
22 
23 #include <BufferConsumer.h>
24 #include <MediaEventLooper.h>
25 
26 class VideoView;
27 
28 class VideoNode : public BMediaEventLooper, public BBufferConsumer
29 {
30 public:
31 					VideoNode(const char *name, VideoView *view);
32 					~VideoNode();
33 
34 	void			SetOverlayEnabled(bool yesno);
35 	bool			IsOverlayActive();
36 
37 	void			LockBitmap();
38 	BBitmap *		Bitmap();
39 	void			UnlockBitmap();
40 
41 protected:
42 	BMediaAddOn	*	AddOn(int32 *internal_id) const;
43 
44 	void			NodeRegistered();
45 
46 	void			BufferReceived(BBuffer * buffer);
47 
48 	status_t		GetNextInput(int32 *cookie,	media_input *out_input);
49 	void			DisposeInputCookie(int32 cookie);
50 
51 	status_t		HandleMessage(
52 							int32 message,
53 							const void *data,
54 							size_t size);
55 
56 	void			HandleEvent(
57 							const media_timed_event *event,
58 							bigtime_t lateness,
59 							bool realTimeEvent);
60 
61 	status_t		AcceptFormat(
62 							const media_destination &dst,
63 							media_format *format);
64 
65 	void			ProducerDataStatus(
66 							const media_destination &dst,
67 							int32 status,
68 							bigtime_t at_media_time);
69 
70 	status_t		GetLatencyFor(
71 							const media_destination &dst,
72 							bigtime_t *out_latency,
73 							media_node_id *out_id);
74 
75 	status_t		Connected(
76 							const media_source &src,
77 							const media_destination &dst,
78 							const media_format &format,
79 							media_input *out_input);
80 
81 	void			Disconnected(
82 							const media_source &src,
83 							const media_destination &dst);
84 
85 	status_t		FormatChanged(
86 							const media_source &src,
87 							const media_destination &dst,
88 							int32 from_change_count,
89 							const media_format &format);
90 
91 protected:
92 	void			HandleBuffer(BBuffer *buffer);
93 	status_t		CreateBuffers(BRect frame, color_space cspace, bool overlay);
94 	void			DeleteBuffers();
95 
96 protected:
97 	VideoView *		fVideoView;
98 	media_input		fInput;
99 	bool			fOverlayEnabled;
100 	bool			fOverlayActive;
101 	bool			fDirectOverlayBuffer;	// If the overlay memory is directly written by the producer node.
102 	BBitmap *		fBitmap;
103 	BLocker	*		fBitmapLocker;
104 };
105 
106 #endif
107