xref: /haiku/src/tests/kits/media/nodetest/ProducerNode.h (revision 51978af14a173e7fae0563b562be5603bc652aeb)
1 #include <BufferProducer.h>
2 #include <MediaEventLooper.h>
3 
4 class ProducerNode : public virtual BBufferProducer, BMediaEventLooper
5 {
6 public:
7 	ProducerNode();
8 	~ProducerNode();
9 
10 protected:
11 
12 	/* functionality of BMediaNode */
13 virtual	BMediaAddOn* AddOn(
14 				int32 * internal_id) const;
15 
16 virtual		void NodeRegistered();
17 
18 	/* functionality of BBufferProducer */
19 virtual	status_t FormatSuggestionRequested(
20 				media_type type,
21 				int32 quality,
22 				media_format * format);
23 virtual	status_t FormatProposal(
24 				const media_source & output,
25 				media_format * format);
26 virtual	status_t FormatChangeRequested(
27 				const media_source & source,
28 				const media_destination & destination,
29 				media_format * io_format,
30 				int32 * _deprecated_);
31 virtual	status_t GetNextOutput(	/* cookie starts as 0 */
32 				int32 * cookie,
33 				media_output * out_output);
34 virtual	status_t DisposeOutputCookie(
35 				int32 cookie);
36 virtual	status_t SetBufferGroup(
37 				const media_source & for_source,
38 				BBufferGroup * group);
39 virtual	status_t VideoClippingChanged(
40 				const media_source & for_source,
41 				int16 num_shorts,
42 				int16 * clip_data,
43 				const media_video_display_info & display,
44 				int32 * _deprecated_);
45 virtual	status_t GetLatency(
46 				bigtime_t * out_lantency);
47 virtual	status_t PrepareToConnect(
48 				const media_source & what,
49 				const media_destination & where,
50 				media_format * format,
51 				media_source * out_source,
52 				char * out_name);
53 virtual	void Connect(
54 				status_t error,
55 				const media_source & source,
56 				const media_destination & destination,
57 				const media_format & format,
58 				char * io_name);
59 virtual	void Disconnect(
60 				const media_source & what,
61 				const media_destination & where);
62 virtual	void LateNoticeReceived(
63 				const media_source & what,
64 				bigtime_t how_much,
65 				bigtime_t performance_time);
66 virtual	void EnableOutput(
67 				const media_source & what,
68 				bool enabled,
69 				int32 * _deprecated_);
70 
71 virtual status_t HandleMessage(int32 message,
72 				const void *data, size_t size);
73 
74 virtual	void AdditionalBufferRequested(
75 				const media_source & source,
76 				media_buffer_id prev_buffer,
77 				bigtime_t prev_time,
78 				const media_seek_tag * prev_tag);
79 
80 virtual	void LatencyChanged(
81 				const media_source & source,
82 				const media_destination & destination,
83 				bigtime_t new_latency,
84 				uint32 flags);
85 
86 	/* functionality of BMediaEventLooper */
87 virtual void HandleEvent(const media_timed_event *event,
88 						 bigtime_t lateness,
89 						 bool realTimeEvent = false);
90 
91 	/* our own functionality */
92 void InitializeOutput();
93 
94 static int32 _bufferproducer(void *arg);
95 void BufferProducer();
96 
97 	BBufferGroup *mBufferGroup;
98 	sem_id		mBufferProducerSem;
99 	thread_id	mBufferProducer;
100 
101 	bool 		 mOutputEnabled;
102 	media_output mOutput;
103 };
104 
105