180634794SMarcus Overhagen/*
218c2aaaeSMarcus Overhagen * Copyright (C) 2006 Marcus Overhagen <marcus@overhagen.de>. All rights reserved.
372ac59d1SMaurice Kalinowski * Copyright (C) 2008 Maurice Kalinowski <haiku@kaldience.com>. All rights reserved.
480634794SMarcus Overhagen *
518c2aaaeSMarcus Overhagen * Distributed under the terms of the MIT License.
680634794SMarcus Overhagen */
780634794SMarcus Overhagen#ifndef __VIDEO_NODE_H_
880634794SMarcus Overhagen#define __VIDEO_NODE_H_
980634794SMarcus Overhagen
1072ac59d1SMaurice Kalinowski
1180634794SMarcus Overhagen#include <BufferConsumer.h>
1280634794SMarcus Overhagen#include <MediaEventLooper.h>
1380634794SMarcus Overhagen
1472ac59d1SMaurice Kalinowski
1572ac59d1SMaurice Kalinowskiclass BBitmap;
1672ac59d1SMaurice Kalinowskiclass BLocker;
1772ac59d1SMaurice Kalinowskiclass BWindow;
1880634794SMarcus Overhagenclass VideoView;
1972ac59d1SMaurice Kalinowskiclass VideoWindow;
2072ac59d1SMaurice Kalinowski
2180634794SMarcus Overhagen
2280634794SMarcus Overhagenclass VideoNode : public BMediaEventLooper, public BBufferConsumer
2380634794SMarcus Overhagen{
2480634794SMarcus Overhagenpublic:
2572ac59d1SMaurice Kalinowski					VideoNode(const char *name);
2672ac59d1SMaurice Kalinowski					VideoNode(const char *name, BMediaAddOn* addon, int32 id);
2780634794SMarcus Overhagen					~VideoNode();
2880634794SMarcus Overhagen
2980634794SMarcus Overhagen	void			SetOverlayEnabled(bool yesno);
3080634794SMarcus Overhagen	bool			IsOverlayActive();
3172ac59d1SMaurice Kalinowski
3280634794SMarcus Overhagen	void			LockBitmap();
3380634794SMarcus Overhagen	BBitmap *		Bitmap();
3480634794SMarcus Overhagen	void			UnlockBitmap();
3580634794SMarcus Overhagen
3680634794SMarcus Overhagenprotected:
3780634794SMarcus Overhagen	BMediaAddOn	*	AddOn(int32 *internal_id) const;
3880634794SMarcus Overhagen
3980634794SMarcus Overhagen	void			NodeRegistered();
4080634794SMarcus Overhagen
4180634794SMarcus Overhagen	void			BufferReceived(BBuffer * buffer);
4280634794SMarcus Overhagen
4380634794SMarcus Overhagen	status_t		GetNextInput(int32 *cookie,	media_input *out_input);
4480634794SMarcus Overhagen	void			DisposeInputCookie(int32 cookie);
4580634794SMarcus Overhagen
4680634794SMarcus Overhagen	status_t		HandleMessage(
4780634794SMarcus Overhagen							int32 message,
4880634794SMarcus Overhagen							const void *data,
4980634794SMarcus Overhagen							size_t size);
5080634794SMarcus Overhagen
5180634794SMarcus Overhagen	void			HandleEvent(
5280634794SMarcus Overhagen							const media_timed_event *event,
5380634794SMarcus Overhagen							bigtime_t lateness,
5480634794SMarcus Overhagen							bool realTimeEvent);
5580634794SMarcus Overhagen
5680634794SMarcus Overhagen	status_t		AcceptFormat(
5780634794SMarcus Overhagen							const media_destination &dst,
5880634794SMarcus Overhagen							media_format *format);
5980634794SMarcus Overhagen
6080634794SMarcus Overhagen	void			ProducerDataStatus(
6180634794SMarcus Overhagen							const media_destination &dst,
6280634794SMarcus Overhagen							int32 status,
6380634794SMarcus Overhagen							bigtime_t at_media_time);
6472ac59d1SMaurice Kalinowski
6580634794SMarcus Overhagen	status_t		GetLatencyFor(
6680634794SMarcus Overhagen							const media_destination &dst,
6780634794SMarcus Overhagen							bigtime_t *out_latency,
6880634794SMarcus Overhagen							media_node_id *out_id);
6980634794SMarcus Overhagen
7080634794SMarcus Overhagen	status_t		Connected(
7180634794SMarcus Overhagen							const media_source &src,
7280634794SMarcus Overhagen							const media_destination &dst,
7380634794SMarcus Overhagen							const media_format &format,
7480634794SMarcus Overhagen							media_input *out_input);
7580634794SMarcus Overhagen
7680634794SMarcus Overhagen	void			Disconnected(
7780634794SMarcus Overhagen							const media_source &src,
7880634794SMarcus Overhagen							const media_destination &dst);
7980634794SMarcus Overhagen
8080634794SMarcus Overhagen	status_t		FormatChanged(
8180634794SMarcus Overhagen							const media_source &src,
8280634794SMarcus Overhagen							const media_destination &dst,
8380634794SMarcus Overhagen							int32 from_change_count,
8480634794SMarcus Overhagen							const media_format &format);
8580634794SMarcus Overhagen
8680634794SMarcus Overhagen	void			HandleBuffer(BBuffer *buffer);
8780634794SMarcus Overhagen	status_t		CreateBuffers(BRect frame, color_space cspace, bool overlay);
8880634794SMarcus Overhagen	void			DeleteBuffers();
8980634794SMarcus Overhagen
9072ac59d1SMaurice Kalinowskiprivate:
9172ac59d1SMaurice Kalinowski	void			_InitDisplay();
9272ac59d1SMaurice Kalinowski	VideoWindow *	fWindow;
9380634794SMarcus Overhagen	VideoView *		fVideoView;
9480634794SMarcus Overhagen	media_input		fInput;
9580634794SMarcus Overhagen	bool			fOverlayEnabled;
9680634794SMarcus Overhagen	bool			fOverlayActive;
9780634794SMarcus Overhagen	bool			fDirectOverlayBuffer;	// If the overlay memory is directly written by the producer node.
9880634794SMarcus Overhagen	BBitmap *		fBitmap;
9980634794SMarcus Overhagen	BLocker	*		fBitmapLocker;
10072ac59d1SMaurice Kalinowski	BMediaAddOn*	fAddOn;
10172ac59d1SMaurice Kalinowski	int32			fInternalFlavorId;
10280634794SMarcus Overhagen};
10380634794SMarcus Overhagen
10480634794SMarcus Overhagen#endif
105