xref: /haiku/src/kits/media/MediaRecorderNode.h (revision 21258e2674226d6aa732321b6f8494841895af5f)
1 /*
2  * Copyright 2014-2016, Dario Casalinuovo
3  * Copyright 1999, Be Incorporated
4  * All Rights Reserved.
5  * This file may be used under the terms of the Be Sample Code License.
6  */
7 #ifndef _MEDIA_RECORDER_NODE_H
8 #define _MEDIA_RECORDER_NODE_H
9 
10 
11 #include <BufferConsumer.h>
12 #include <MediaEventLooper.h>
13 #include <MediaRecorder.h>
14 #include <String.h>
15 
16 
17 namespace BPrivate { namespace media {
18 
19 
20 class BMediaRecorderNode : public BMediaEventLooper,
21 	public BBufferConsumer {
22 public:
23 								BMediaRecorderNode(const char* name,
24 									BMediaRecorder* recorder,
25 									media_type type
26 										= B_MEDIA_UNKNOWN_TYPE);
27 
28 			//	TODO these are not thread safe; we should fix that...
29 			void				SetAcceptedFormat(const media_format& format);
30 			const media_format&	AcceptedFormat() const;
31 
32 			void				GetInput(media_input* input);
33 
34 			void				SetDataEnabled(bool enabled);
35 			void				ActivateInternalConnect(bool connectMode);
36 
37 protected:
38 
39 	virtual	BMediaAddOn*		AddOn(int32* id) const;
40 
41 	virtual void				NodeRegistered();
42 
43 	virtual void				SetRunMode(run_mode mode);
44 
45 	virtual void				HandleEvent(const media_timed_event* event,
46 									bigtime_t lateness,
47 									bool realTimeEvent);
48 
49 	virtual	void				Start(bigtime_t performanceTime);
50 
51 	virtual	void				Stop(bigtime_t performanceTime,
52 									bool immediate);
53 
54 	virtual	void				Seek(bigtime_t mediaTime,
55 									bigtime_t performanceTime);
56 
57 	virtual	void				TimeWarp(bigtime_t realTime,
58 									bigtime_t performanceTime);
59 
60 	virtual	status_t			HandleMessage(int32 message,
61 									const void* data,
62 									size_t size);
63 
64 			// Someone, probably the producer, is asking you about
65 			// this format. Give your honest opinion, possibly
66 			// modifying *format. Do not ask upstream producer about
67 			//	the format, since he's synchronously waiting for your
68 			// reply.
69 
70 	virtual	status_t			AcceptFormat(const media_destination& dest,
71 									media_format* format);
72 
73 	virtual	status_t			GetNextInput(int32* cookie,
74 									media_input* outInput);
75 
76 	virtual	void				DisposeInputCookie(int32 cookie);
77 
78 	virtual	void				BufferReceived(BBuffer* buffer);
79 
80 	virtual	void				ProducerDataStatus(
81 									const media_destination& destination,
82 									int32 status,
83 									bigtime_t performanceTime);
84 
85 	virtual	status_t			GetLatencyFor(const media_destination& destination,
86 									bigtime_t* outLatency,
87 									media_node_id* outTimesource);
88 
89 	virtual	status_t			Connected(const media_source& producer,
90 									const media_destination& where,
91 									const media_format& format,
92 									media_input* outInput);
93 
94 	virtual	void				Disconnected(const media_source& producer,
95 									const media_destination& where);
96 
97 	virtual	status_t			FormatChanged(const media_source& producer,
98 									const media_destination& consumer,
99 									int32 tag,
100 									const media_format& format);
101 
102 protected:
103 
104 	virtual						~BMediaRecorderNode();
105 
106 			BMediaRecorder*		fRecorder;
107 			media_format		fOKFormat;
108 			media_input			fInput;
109 			BString				fName;
110 			bool				fConnectMode;
111 };
112 
113 }
114 }
115 
116 using namespace BPrivate::media;
117 
118 #endif	//	_MEDIA_RECORDER_NODE_H
119