16a739773SCodeforEvolution/*
26a739773SCodeforEvolution * Copyright 1998-1999 Be, Inc. All Rights Reserved.
36a739773SCodeforEvolution * Copyright 2003-2019 Haiku, Inc. All rights reserved.
46a739773SCodeforEvolution * Distributed under the terms of the MIT License.
56a739773SCodeforEvolution */
69d3f15c6SIngo Weinhold#ifndef VIDEO_CONSUMER_H
79d3f15c6SIngo Weinhold#define VIDEO_CONSUMER_H
8dba5824bSPhil Greenway
9dba5824bSPhil Greenway
10dba5824bSPhil Greenway#include <Bitmap.h>
11dba5824bSPhil Greenway#include <BufferConsumer.h>
12dba5824bSPhil Greenway#include <MediaEventLooper.h>
139d3f15c6SIngo Weinhold#include <MediaNode.h>
149d3f15c6SIngo Weinhold#include <TimedEventQueue.h>
156a739773SCodeforEvolution#include <TranslatorRoster.h>
169d3f15c6SIngo Weinhold#include <View.h>
179d3f15c6SIngo Weinhold#include <Window.h>
18dba5824bSPhil Greenway
199d3f15c6SIngo Weinhold
209d3f15c6SIngo Weinholdtypedef struct {
219d3f15c6SIngo Weinhold	port_id		port;
229d3f15c6SIngo Weinhold	bigtime_t	rate;
239d3f15c6SIngo Weinhold	uint32		imageFormat;
249d3f15c6SIngo Weinhold	int32		translator;
25e3145a8dSFran├žois Revol	int32		uploadClient;
269d3f15c6SIngo Weinhold	bool		passiveFtp;
279d3f15c6SIngo Weinhold	char		fileNameText[64];
289d3f15c6SIngo Weinhold	char		serverText[64];
299d3f15c6SIngo Weinhold	char		loginText[64];
30476fad7fSMatt Madia	char		passwordText[64];
319d3f15c6SIngo Weinhold	char		directoryText[64];
32dba5824bSPhil Greenway} ftp_msg_info;
33dba5824bSPhil Greenway
349d3f15c6SIngo Weinhold#define FTP_INFO 0x60000001
35dba5824bSPhil Greenway
369d3f15c6SIngo Weinholdclass BStringView;
37dba5824bSPhil Greenway
38dba5824bSPhil Greenway
39dba5824bSPhil Greenway
409d3f15c6SIngo Weinholdclass VideoConsumer : public BMediaEventLooper, public BBufferConsumer {
416a739773SCodeforEvolutionpublic:
426a739773SCodeforEvolution								VideoConsumer(const char* name, BView* view,
436a739773SCodeforEvolution									BStringView* statusLine, BMediaAddOn *addon,
446a739773SCodeforEvolution									const uint32 internalId);
456a739773SCodeforEvolution								~VideoConsumer();
46dba5824bSPhil Greenway
476a739773SCodeforEvolution/*	BMediaNode */
486a739773SCodeforEvolutionpublic:
496a739773SCodeforEvolution	virtual	BMediaAddOn* 		AddOn(int32* cookie) const;
50dba5824bSPhil Greenway
516a739773SCodeforEvolutionprotected:
526a739773SCodeforEvolution	virtual void 				Start(bigtime_t performanceTime);
536a739773SCodeforEvolution	virtual void 				Stop(bigtime_t performanceTime, bool immediate);
546a739773SCodeforEvolution	virtual void 				Seek(bigtime_t mediaTime,
556a739773SCodeforEvolution									bigtime_t performanceTime);
566a739773SCodeforEvolution	virtual void 				TimeWarp(bigtime_t atRealTime,
576a739773SCodeforEvolution									bigtime_t toPerformanceTime);
58dba5824bSPhil Greenway
596a739773SCodeforEvolution	virtual void 				NodeRegistered();
606a739773SCodeforEvolution	virtual	status_t 			RequestCompleted(
616a739773SCodeforEvolution									const media_request_info& info);
62dba5824bSPhil Greenway
636a739773SCodeforEvolution	virtual	status_t 			HandleMessage(int32 message, const void* data,
646a739773SCodeforEvolution									size_t size);
659d3f15c6SIngo Weinhold
666a739773SCodeforEvolution	virtual status_t 			DeleteHook(BMediaNode* node);
679d3f15c6SIngo Weinhold
686a739773SCodeforEvolution/*  BMediaEventLooper */
696a739773SCodeforEvolutionprotected:
706a739773SCodeforEvolution		virtual void 			HandleEvent(const media_timed_event* event,
716a739773SCodeforEvolution									bigtime_t lateness, bool realTimeEvent);
729d3f15c6SIngo Weinhold
736a739773SCodeforEvolution/*	BBufferConsumer */
746a739773SCodeforEvolutionpublic:
756a739773SCodeforEvolution	virtual	status_t 			AcceptFormat(const media_destination& dest,
766a739773SCodeforEvolution									media_format* format);
779d3f15c6SIngo Weinhold
786a739773SCodeforEvolution	virtual	status_t 			GetNextInput(int32* cookie,
796a739773SCodeforEvolution									media_input* outInput);
809d3f15c6SIngo Weinhold
816a739773SCodeforEvolution	virtual	void 				DisposeInputCookie(int32 cookie);
829d3f15c6SIngo Weinhold
836a739773SCodeforEvolutionprotected:
846a739773SCodeforEvolution	virtual	void 				BufferReceived(BBuffer* buffer);
859d3f15c6SIngo Weinhold
866a739773SCodeforEvolutionprivate:
876a739773SCodeforEvolution	virtual	void 				ProducerDataStatus(
886a739773SCodeforEvolution									const media_destination &forWhom,
896a739773SCodeforEvolution									int32 status, bigtime_t atMediaTime);
90476fad7fSMatt Madia
916a739773SCodeforEvolution	virtual	status_t 			GetLatencyFor(const media_destination& forWhom,
926a739773SCodeforEvolution									bigtime_t* outLatency,
936a739773SCodeforEvolution									media_node_id* outId);
94476fad7fSMatt Madia
956a739773SCodeforEvolution	virtual	status_t 			Connected(const media_source& producer,
966a739773SCodeforEvolution									const media_destination& where,
976a739773SCodeforEvolution									const media_format& withFormat,
986a739773SCodeforEvolution									media_input* outInput);
999d3f15c6SIngo Weinhold
1006a739773SCodeforEvolution	virtual	void 				Disconnected(const media_source& producer,
1016a739773SCodeforEvolution									const media_destination& where);
1029d3f15c6SIngo Weinhold
1036a739773SCodeforEvolution	virtual	status_t 			FormatChanged(const media_source& producer,
1046a739773SCodeforEvolution									const media_destination& consumer,
1056a739773SCodeforEvolution									int32 fromChangeCount,
1066a739773SCodeforEvolution									const media_format& format);
1079d3f15c6SIngo Weinhold
1086a739773SCodeforEvolution/*	implementation */
1099d3f15c6SIngo Weinhold
1106a739773SCodeforEvolutionpublic:
1116a739773SCodeforEvolution			status_t 			CreateBuffers(const media_format& withFormat);
1129d3f15c6SIngo Weinhold
1136a739773SCodeforEvolution			void 				DeleteBuffers();
114476fad7fSMatt Madia
1156a739773SCodeforEvolution	static 	status_t 			FtpRun(void* data);
1169d3f15c6SIngo Weinhold
1176a739773SCodeforEvolution			void 				FtpThread();
118476fad7fSMatt Madia
1196a739773SCodeforEvolution			void 				UpdateFtpStatus(const char* status);
1209d3f15c6SIngo Weinhold
1216a739773SCodeforEvolution			status_t 			LocalSave(char* filename, BBitmap* bitmap);
1229d3f15c6SIngo Weinhold
1236a739773SCodeforEvolution			status_t 			FtpSave(char* filename);
1249d3f15c6SIngo Weinhold
1256a739773SCodeforEvolutionprivate:
1266a739773SCodeforEvolution			BStringView*		fStatusLine;
1276a739773SCodeforEvolution			int32				fInternalID;
1286a739773SCodeforEvolution			BMediaAddOn*		fAddOn;
1299d3f15c6SIngo Weinhold
1306a739773SCodeforEvolution			thread_id			fFtpThread;
1319d3f15c6SIngo Weinhold
1326a739773SCodeforEvolution			bool				fConnectionActive;
1336a739773SCodeforEvolution			media_input			fIn;
1346a739773SCodeforEvolution			media_destination	fDestination;
1356a739773SCodeforEvolution			bigtime_t			fMyLatency;
1369d3f15c6SIngo Weinhold
1376a739773SCodeforEvolution			BWindow*			fWindow;
1386a739773SCodeforEvolution			BView*				fView;
1396a739773SCodeforEvolution			BBitmap*			fBitmap[3];
1406a739773SCodeforEvolution			bool				fOurBuffers;
1416a739773SCodeforEvolution			BBufferGroup*		fBuffers;
1426a739773SCodeforEvolution			BBuffer*			fBufferMap[3];
1439d3f15c6SIngo Weinhold
1446a739773SCodeforEvolution			BBitmap*			fFtpBitmap;
1456a739773SCodeforEvolution			volatile bool		fTimeToFtp;
1466a739773SCodeforEvolution			volatile bool		fFtpComplete;
1479d3f15c6SIngo Weinhold
1486a739773SCodeforEvolution			bigtime_t			fRate;
1496a739773SCodeforEvolution			uint32				fImageFormat;
1506a739773SCodeforEvolution			int32				fTranslator;
1516a739773SCodeforEvolution			int32				fUploadClient;
1526a739773SCodeforEvolution			bool				fPassiveFtp;
1536a739773SCodeforEvolution			char				fFileNameText[64];
1546a739773SCodeforEvolution			char				fServerText[64];
1556a739773SCodeforEvolution			char				fLoginText[64];
1566a739773SCodeforEvolution			char				fPasswordText[64];
1576a739773SCodeforEvolution			char				fDirectoryText[64];
158dba5824bSPhil Greenway};
159dba5824bSPhil Greenway
1609d3f15c6SIngo Weinhold#endif	// VIDEO_CONSUMER_H
161