vfs: check userland buffers before reading them.
[haiku.git] / src / kits / media / MediaRecorderNode.h
blob699176094ddecec0dabacb9da613488057f6f78e
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
11 #include <BufferConsumer.h>
12 #include <MediaEventLooper.h>
13 #include <MediaRecorder.h>
14 #include <String.h>
17 namespace BPrivate { namespace media {
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);
28 // TODO these are not thread safe; we should fix that...
29 void SetAcceptedFormat(const media_format& format);
30 const media_format& AcceptedFormat() const;
32 void GetInput(media_input* input);
34 void SetDataEnabled(bool enabled);
35 void ActivateInternalConnect(bool connectMode);
37 protected:
39 virtual BMediaAddOn* AddOn(int32* id) const;
41 virtual void NodeRegistered();
43 virtual void SetRunMode(run_mode mode);
45 virtual void HandleEvent(const media_timed_event* event,
46 bigtime_t lateness,
47 bool realTimeEvent);
49 virtual void Start(bigtime_t performanceTime);
51 virtual void Stop(bigtime_t performanceTime,
52 bool immediate);
54 virtual void Seek(bigtime_t mediaTime,
55 bigtime_t performanceTime);
57 virtual void TimeWarp(bigtime_t realTime,
58 bigtime_t performanceTime);
60 virtual status_t HandleMessage(int32 message,
61 const void* data,
62 size_t size);
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.
70 virtual status_t AcceptFormat(const media_destination& dest,
71 media_format* format);
73 virtual status_t GetNextInput(int32* cookie,
74 media_input* outInput);
76 virtual void DisposeInputCookie(int32 cookie);
78 virtual void BufferReceived(BBuffer* buffer);
80 virtual void ProducerDataStatus(
81 const media_destination& destination,
82 int32 status,
83 bigtime_t performanceTime);
85 virtual status_t GetLatencyFor(const media_destination& destination,
86 bigtime_t* outLatency,
87 media_node_id* outTimesource);
89 virtual status_t Connected(const media_source& producer,
90 const media_destination& where,
91 const media_format& format,
92 media_input* outInput);
94 virtual void Disconnected(const media_source& producer,
95 const media_destination& where);
97 virtual status_t FormatChanged(const media_source& producer,
98 const media_destination& consumer,
99 int32 tag,
100 const media_format& format);
102 protected:
104 virtual ~BMediaRecorderNode();
106 BMediaRecorder* fRecorder;
107 media_format fOKFormat;
108 media_input fInput;
109 BString fName;
110 bool fConnectMode;
116 using namespace BPrivate::media;
118 #endif // _MEDIA_RECORDER_NODE_H