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 6 7 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> 16 17 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; 31 32 #define FTP_INFO 0x60000001 33 34 class BStringView; 35 36 37 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(); 43 44 /* BMediaNode */ 45 public: 46 virtual BMediaAddOn* AddOn(long* cookie) const; 47 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); 54 55 virtual void NodeRegistered(); 56 virtual status_t RequestCompleted(const media_request_info& info); 57 58 virtual status_t HandleMessage(int32 message, const void* data, 59 size_t size); 60 61 virtual status_t DeleteHook(BMediaNode* node); 62 63 /* BMediaEventLooper */ 64 protected: 65 virtual void HandleEvent(const media_timed_event* event, 66 bigtime_t lateness, bool realTimeEvent); 67 68 /* BBufferConsumer */ 69 public: 70 virtual status_t AcceptFormat(const media_destination& dest, 71 media_format* format); 72 73 virtual status_t GetNextInput(int32* cookie, media_input* outInput); 74 75 virtual void DisposeInputCookie(int32 cookie); 76 77 protected: 78 virtual void BufferReceived(BBuffer* buffer); 79 80 private: 81 virtual void ProducerDataStatus(const media_destination &forWhom, 82 int32 status, bigtime_t atMediaTime); 83 84 virtual status_t GetLatencyFor(const media_destination& forWhom, 85 bigtime_t* outLatency, media_node_id* outId); 86 87 virtual status_t Connected(const media_source& producer, 88 const media_destination& where, const media_format& withFormat, 89 media_input* outInput); 90 91 virtual void Disconnected(const media_source& producer, 92 const media_destination& where); 93 94 virtual status_t FormatChanged(const media_source& producer, 95 const media_destination& consumer, int32 fromChangeCount, 96 const media_format& format); 97 98 /* implementation */ 99 100 public: 101 status_t CreateBuffers(const media_format& withFormat); 102 103 void DeleteBuffers(); 104 105 static status_t FtpRun(void* data); 106 107 void FtpThread(); 108 109 void UpdateFtpStatus(char* status); 110 111 status_t LocalSave(char* filename, BBitmap* bitmap); 112 113 status_t FtpSave(char* filename); 114 115 private: 116 BStringView* fStatusLine; 117 uint32 fInternalID; 118 BMediaAddOn* fAddOn; 119 120 thread_id fFtpThread; 121 122 bool fConnectionActive; 123 media_input fIn; 124 media_destination fDestination; 125 bigtime_t fMyLatency; 126 127 BWindow* fWindow; 128 BView* fView; 129 BBitmap* fBitmap[3]; 130 bool fOurBuffers; 131 BBufferGroup* fBuffers; 132 uint32 fBufferMap[3]; 133 134 BBitmap* fFtpBitmap; 135 volatile bool fTimeToFtp; 136 volatile bool fFtpComplete; 137 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]; 148 }; 149 150 #endif // VIDEO_CONSUMER_H 151