vfs: check userland buffers before reading them.
[haiku.git] / src / apps / codycam / VideoConsumer.h
blobaf3e640a476093945a505ad14af7a17fba44e036
1 // Copyright (c) 1998-99, Be Incorporated, All Rights Reserved.
2 // SMS
3 /* VideoConsumer.h */
4 #ifndef VIDEO_CONSUMER_H
5 #define VIDEO_CONSUMER_H
8 #include <Bitmap.h>
9 #include <BufferConsumer.h>
10 #include <MediaEventLooper.h>
11 #include <MediaNode.h>
12 #include <TimedEventQueue.h>
13 #include <TranslationKit.h>
14 #include <View.h>
15 #include <Window.h>
18 typedef struct {
19 port_id port;
20 bigtime_t rate;
21 uint32 imageFormat;
22 int32 translator;
23 int32 uploadClient;
24 bool passiveFtp;
25 char fileNameText[64];
26 char serverText[64];
27 char loginText[64];
28 char passwordText[64];
29 char directoryText[64];
30 } ftp_msg_info;
32 #define FTP_INFO 0x60000001
34 class BStringView;
38 class VideoConsumer : public BMediaEventLooper, public BBufferConsumer {
39 public:
40 VideoConsumer(const char* name, BView* view, BStringView* statusLine,
41 BMediaAddOn *addon, const uint32 internalId);
42 ~VideoConsumer();
44 /* BMediaNode */
45 public:
46 virtual BMediaAddOn* AddOn(int32* cookie) const;
48 protected:
49 virtual void Start(bigtime_t performanceTime);
50 virtual void Stop(bigtime_t performanceTime, bool immediate);
51 virtual void Seek(bigtime_t mediaTime, bigtime_t performanceTime);
52 virtual void TimeWarp(bigtime_t atRealTime,
53 bigtime_t toPerformanceTime);
55 virtual void NodeRegistered();
56 virtual status_t RequestCompleted(const media_request_info& info);
58 virtual status_t HandleMessage(int32 message, const void* data,
59 size_t size);
61 virtual status_t DeleteHook(BMediaNode* node);
63 /* BMediaEventLooper */
64 protected:
65 virtual void HandleEvent(const media_timed_event* event,
66 bigtime_t lateness, bool realTimeEvent);
68 /* BBufferConsumer */
69 public:
70 virtual status_t AcceptFormat(const media_destination& dest,
71 media_format* format);
73 virtual status_t GetNextInput(int32* cookie, media_input* outInput);
75 virtual void DisposeInputCookie(int32 cookie);
77 protected:
78 virtual void BufferReceived(BBuffer* buffer);
80 private:
81 virtual void ProducerDataStatus(const media_destination &forWhom,
82 int32 status, bigtime_t atMediaTime);
84 virtual status_t GetLatencyFor(const media_destination& forWhom,
85 bigtime_t* outLatency, media_node_id* outId);
87 virtual status_t Connected(const media_source& producer,
88 const media_destination& where, const media_format& withFormat,
89 media_input* outInput);
91 virtual void Disconnected(const media_source& producer,
92 const media_destination& where);
94 virtual status_t FormatChanged(const media_source& producer,
95 const media_destination& consumer, int32 fromChangeCount,
96 const media_format& format);
98 /* implementation */
100 public:
101 status_t CreateBuffers(const media_format& withFormat);
103 void DeleteBuffers();
105 static status_t FtpRun(void* data);
107 void FtpThread();
109 void UpdateFtpStatus(const char* status);
111 status_t LocalSave(char* filename, BBitmap* bitmap);
113 status_t FtpSave(char* filename);
115 private:
116 BStringView* fStatusLine;
117 int32 fInternalID;
118 BMediaAddOn* fAddOn;
120 thread_id fFtpThread;
122 bool fConnectionActive;
123 media_input fIn;
124 media_destination fDestination;
125 bigtime_t fMyLatency;
127 BWindow* fWindow;
128 BView* fView;
129 BBitmap* fBitmap[3];
130 bool fOurBuffers;
131 BBufferGroup* fBuffers;
132 BBuffer* fBufferMap[3];
134 BBitmap* fFtpBitmap;
135 volatile bool fTimeToFtp;
136 volatile bool fFtpComplete;
138 bigtime_t fRate;
139 uint32 fImageFormat;
140 int32 fTranslator;
141 int32 fUploadClient;
142 bool fPassiveFtp;
143 char fFileNameText[64];
144 char fServerText[64];
145 char fLoginText[64];
146 char fPasswordText[64];
147 char fDirectoryText[64];
150 #endif // VIDEO_CONSUMER_H