1739fd34cSBarrett/*
2c1ad6121SDario Casalinuovo * Copyright 2014-2016, Dario Casalinuovo
3683cf2ffSHamish Morrison * Copyright 1999, Be Incorporated
4739fd34cSBarrett * All Rights Reserved.
5739fd34cSBarrett * This file may be used under the terms of the Be Sample Code License.
6739fd34cSBarrett */
7739fd34cSBarrett#ifndef _MEDIA_RECORDER_NODE_H
8739fd34cSBarrett#define _MEDIA_RECORDER_NODE_H
9739fd34cSBarrett
10739fd34cSBarrett
11739fd34cSBarrett#include <BufferConsumer.h>
12739fd34cSBarrett#include <MediaEventLooper.h>
133ef4b200SDario Casalinuovo#include <MediaRecorder.h>
14739fd34cSBarrett#include <String.h>
15739fd34cSBarrett
16739fd34cSBarrett
17739fd34cSBarrettnamespace BPrivate { namespace media {
18739fd34cSBarrett
19739fd34cSBarrett
20739fd34cSBarrettclass BMediaRecorderNode : public BMediaEventLooper,
21739fd34cSBarrett	public BBufferConsumer {
22739fd34cSBarrettpublic:
232a2e352aSDario Casalinuovo								BMediaRecorderNode(const char* name,
242a2e352aSDario Casalinuovo									BMediaRecorder* recorder,
252a2e352aSDario Casalinuovo									media_type type
262a2e352aSDario Casalinuovo										= B_MEDIA_UNKNOWN_TYPE);
27739fd34cSBarrett
28739fd34cSBarrett			//	TODO these are not thread safe; we should fix that...
292a2e352aSDario Casalinuovo			void				SetAcceptedFormat(const media_format& format);
302a2e352aSDario Casalinuovo			const media_format&	AcceptedFormat() const;
31739fd34cSBarrett
322a2e352aSDario Casalinuovo			void				GetInput(media_input* input);
33739fd34cSBarrett
342a2e352aSDario Casalinuovo			void				SetDataEnabled(bool enabled);
35c1ad6121SDario Casalinuovo			void				ActivateInternalConnect(bool connectMode);
36739fd34cSBarrett
37739fd34cSBarrettprotected:
38739fd34cSBarrett
392a2e352aSDario Casalinuovo	virtual	BMediaAddOn*		AddOn(int32* id) const;
40739fd34cSBarrett
412a2e352aSDario Casalinuovo	virtual void				NodeRegistered();
42739fd34cSBarrett
432a2e352aSDario Casalinuovo	virtual void				SetRunMode(run_mode mode);
44739fd34cSBarrett
452a2e352aSDario Casalinuovo	virtual void				HandleEvent(const media_timed_event* event,
462a2e352aSDario Casalinuovo									bigtime_t lateness,
472a2e352aSDario Casalinuovo									bool realTimeEvent);
48739fd34cSBarrett
492a2e352aSDario Casalinuovo	virtual	void				Start(bigtime_t performanceTime);
50739fd34cSBarrett
512a2e352aSDario Casalinuovo	virtual	void				Stop(bigtime_t performanceTime,
522a2e352aSDario Casalinuovo									bool immediate);
53739fd34cSBarrett
542a2e352aSDario Casalinuovo	virtual	void				Seek(bigtime_t mediaTime,
552a2e352aSDario Casalinuovo									bigtime_t performanceTime);
56739fd34cSBarrett
572a2e352aSDario Casalinuovo	virtual	void				TimeWarp(bigtime_t realTime,
582a2e352aSDario Casalinuovo									bigtime_t performanceTime);
59739fd34cSBarrett
602a2e352aSDario Casalinuovo	virtual	status_t			HandleMessage(int32 message,
612a2e352aSDario Casalinuovo									const void* data,
622a2e352aSDario Casalinuovo									size_t size);
63739fd34cSBarrett
64739fd34cSBarrett			// Someone, probably the producer, is asking you about
65739fd34cSBarrett			// this format. Give your honest opinion, possibly
66739fd34cSBarrett			// modifying *format. Do not ask upstream producer about
67739fd34cSBarrett			//	the format, since he's synchronously waiting for your
68739fd34cSBarrett			// reply.
69739fd34cSBarrett
702a2e352aSDario Casalinuovo	virtual	status_t			AcceptFormat(const media_destination& dest,
712a2e352aSDario Casalinuovo									media_format* format);
72739fd34cSBarrett
732a2e352aSDario Casalinuovo	virtual	status_t			GetNextInput(int32* cookie,
742a2e352aSDario Casalinuovo									media_input* outInput);
75739fd34cSBarrett
762a2e352aSDario Casalinuovo	virtual	void				DisposeInputCookie(int32 cookie);
77739fd34cSBarrett
782a2e352aSDario Casalinuovo	virtual	void				BufferReceived(BBuffer* buffer);
79739fd34cSBarrett
802a2e352aSDario Casalinuovo	virtual	void				ProducerDataStatus(
812a2e352aSDario Casalinuovo									const media_destination& destination,
822a2e352aSDario Casalinuovo									int32 status,
832a2e352aSDario Casalinuovo									bigtime_t performanceTime);
84739fd34cSBarrett
852a2e352aSDario Casalinuovo	virtual	status_t			GetLatencyFor(const media_destination& destination,
862a2e352aSDario Casalinuovo									bigtime_t* outLatency,
872a2e352aSDario Casalinuovo									media_node_id* outTimesource);
88739fd34cSBarrett
892a2e352aSDario Casalinuovo	virtual	status_t			Connected(const media_source& producer,
902a2e352aSDario Casalinuovo									const media_destination& where,
912a2e352aSDario Casalinuovo									const media_format& format,
922a2e352aSDario Casalinuovo									media_input* outInput);
93739fd34cSBarrett
942a2e352aSDario Casalinuovo	virtual	void				Disconnected(const media_source& producer,
952a2e352aSDario Casalinuovo									const media_destination& where);
96739fd34cSBarrett
972a2e352aSDario Casalinuovo	virtual	status_t			FormatChanged(const media_source& producer,
982a2e352aSDario Casalinuovo									const media_destination& consumer,
992a2e352aSDario Casalinuovo									int32 tag,
1002a2e352aSDario Casalinuovo									const media_format& format);
101739fd34cSBarrett
102739fd34cSBarrettprotected:
103739fd34cSBarrett
1042a2e352aSDario Casalinuovo	virtual						~BMediaRecorderNode();
105739fd34cSBarrett
1062a2e352aSDario Casalinuovo			BMediaRecorder*		fRecorder;
1072a2e352aSDario Casalinuovo			media_format		fOKFormat;
1082a2e352aSDario Casalinuovo			media_input			fInput;
1092a2e352aSDario Casalinuovo			BString				fName;
110c1ad6121SDario Casalinuovo			bool				fConnectMode;
111739fd34cSBarrett};
112739fd34cSBarrett
113739fd34cSBarrett}
114739fd34cSBarrett}
115739fd34cSBarrett
116739fd34cSBarrettusing namespace BPrivate::media;
117739fd34cSBarrett
118739fd34cSBarrett#endif	//	_MEDIA_RECORDER_NODE_H
119