1 /* 2 * Copyright 1998-1999 Be, Inc. All Rights Reserved. 3 * Copyright 2003-2019 Haiku, Inc. All rights reserved. 4 * Distributed under the terms of the MIT License. 5 */ 6 #ifndef VIDEO_CONSUMER_H 7 #define VIDEO_CONSUMER_H 8 9 10 #include <Bitmap.h> 11 #include <BufferConsumer.h> 12 #include <MediaEventLooper.h> 13 #include <MediaNode.h> 14 #include <TimedEventQueue.h> 15 #include <TranslatorRoster.h> 16 #include <View.h> 17 #include <Window.h> 18 19 20 typedef struct { 21 port_id port; 22 bigtime_t rate; 23 uint32 imageFormat; 24 int32 translator; 25 int32 uploadClient; 26 bool passiveFtp; 27 char fileNameText[64]; 28 char serverText[64]; 29 char loginText[64]; 30 char passwordText[64]; 31 char directoryText[64]; 32 } ftp_msg_info; 33 34 #define FTP_INFO 0x60000001 35 36 class BStringView; 37 38 39 40 class VideoConsumer : public BMediaEventLooper, public BBufferConsumer { 41 public: 42 VideoConsumer(const char* name, BView* view, 43 BStringView* statusLine, BMediaAddOn *addon, 44 const uint32 internalId); 45 ~VideoConsumer(); 46 47 /* BMediaNode */ 48 public: 49 virtual BMediaAddOn* AddOn(int32* cookie) const; 50 51 protected: 52 virtual void Start(bigtime_t performanceTime); 53 virtual void Stop(bigtime_t performanceTime, bool immediate); 54 virtual void Seek(bigtime_t mediaTime, 55 bigtime_t performanceTime); 56 virtual void TimeWarp(bigtime_t atRealTime, 57 bigtime_t toPerformanceTime); 58 59 virtual void NodeRegistered(); 60 virtual status_t RequestCompleted( 61 const media_request_info& info); 62 63 virtual status_t HandleMessage(int32 message, const void* data, 64 size_t size); 65 66 virtual status_t DeleteHook(BMediaNode* node); 67 68 /* BMediaEventLooper */ 69 protected: 70 virtual void HandleEvent(const media_timed_event* event, 71 bigtime_t lateness, bool realTimeEvent); 72 73 /* BBufferConsumer */ 74 public: 75 virtual status_t AcceptFormat(const media_destination& dest, 76 media_format* format); 77 78 virtual status_t GetNextInput(int32* cookie, 79 media_input* outInput); 80 81 virtual void DisposeInputCookie(int32 cookie); 82 83 protected: 84 virtual void BufferReceived(BBuffer* buffer); 85 86 private: 87 virtual void ProducerDataStatus( 88 const media_destination &forWhom, 89 int32 status, bigtime_t atMediaTime); 90 91 virtual status_t GetLatencyFor(const media_destination& forWhom, 92 bigtime_t* outLatency, 93 media_node_id* outId); 94 95 virtual status_t Connected(const media_source& producer, 96 const media_destination& where, 97 const media_format& withFormat, 98 media_input* outInput); 99 100 virtual void Disconnected(const media_source& producer, 101 const media_destination& where); 102 103 virtual status_t FormatChanged(const media_source& producer, 104 const media_destination& consumer, 105 int32 fromChangeCount, 106 const media_format& format); 107 108 /* implementation */ 109 110 public: 111 status_t CreateBuffers(const media_format& withFormat); 112 113 void DeleteBuffers(); 114 115 static status_t FtpRun(void* data); 116 117 void FtpThread(); 118 119 void UpdateFtpStatus(const char* status); 120 121 status_t LocalSave(char* filename, BBitmap* bitmap); 122 123 status_t FtpSave(char* filename); 124 125 private: 126 BStringView* fStatusLine; 127 int32 fInternalID; 128 BMediaAddOn* fAddOn; 129 130 thread_id fFtpThread; 131 132 bool fConnectionActive; 133 media_input fIn; 134 media_destination fDestination; 135 bigtime_t fMyLatency; 136 137 BWindow* fWindow; 138 BView* fView; 139 BBitmap* fBitmap[3]; 140 bool fOurBuffers; 141 BBufferGroup* fBuffers; 142 BBuffer* fBufferMap[3]; 143 144 BBitmap* fFtpBitmap; 145 volatile bool fTimeToFtp; 146 volatile bool fFtpComplete; 147 148 bigtime_t fRate; 149 uint32 fImageFormat; 150 int32 fTranslator; 151 int32 fUploadClient; 152 bool fPassiveFtp; 153 char fFileNameText[64]; 154 char fServerText[64]; 155 char fLoginText[64]; 156 char fPasswordText[64]; 157 char fDirectoryText[64]; 158 }; 159 160 #endif // VIDEO_CONSUMER_H 161