blob: 1ceecc2901c4a05270a73690977dd0573ef76493 [file] [log] [blame]
Steve Kondik961b4cc2017-06-22 18:10:50 -07001#ifndef ANDROID_DESKTOP_H_
2#define ANDROID_DESKTOP_H_
3
4#include <memory>
5
6#include <utils/Condition.h>
7#include <utils/Mutex.h>
8#include <utils/RefBase.h>
9#include <utils/Thread.h>
10
11#include <gui/CpuConsumer.h>
12
Steve Kondik6f9ab852017-07-09 21:30:20 -070013#include <ui/DisplayInfo.h>
14
Steve Kondik961b4cc2017-06-22 18:10:50 -070015#include <rfb/PixelBuffer.h>
16#include <rfb/SDesktop.h>
Steve Kondik71850752019-09-12 12:45:23 -070017#include <rfb/ScreenSet.h>
Steve Kondik961b4cc2017-06-22 18:10:50 -070018
Steve Kondik6f9ab852017-07-09 21:30:20 -070019#include "AndroidPixelBuffer.h"
Steve Kondik961b4cc2017-06-22 18:10:50 -070020#include "InputDevice.h"
Steve Kondik6f9ab852017-07-09 21:30:20 -070021#include "VirtualDisplay.h"
Steve Kondik961b4cc2017-06-22 18:10:50 -070022
23using namespace android;
24
25namespace vncflinger {
26
Steve Kondik6f9ab852017-07-09 21:30:20 -070027class AndroidDesktop : public rfb::SDesktop,
28 public CpuConsumer::FrameAvailableListener,
29 public AndroidPixelBuffer::BufferDimensionsListener {
Steve Kondik961b4cc2017-06-22 18:10:50 -070030 public:
31 AndroidDesktop();
32
33 virtual ~AndroidDesktop();
34
35 virtual void start(rfb::VNCServer* vs);
36 virtual void stop();
Steve Kondikf19d1422019-09-06 13:52:12 -070037 virtual void terminate();
Steve Kondik961b4cc2017-06-22 18:10:50 -070038
Steve Kondik961b4cc2017-06-22 18:10:50 -070039 virtual unsigned int setScreenLayout(int fb_width, int fb_height, const rfb::ScreenSet& layout);
40
Steve Kondikf19d1422019-09-06 13:52:12 -070041 virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
Steve Kondik961b4cc2017-06-22 18:10:50 -070042 virtual void pointerEvent(const rfb::Point& pos, int buttonMask);
43
44 virtual void processFrames();
45
46 virtual int getEventFd() {
47 return mEventFd;
48 }
49
Steve Kondik6f9ab852017-07-09 21:30:20 -070050 virtual void onBufferDimensionsChanged(uint32_t width, uint32_t height);
51
52 virtual void onFrameAvailable(const BufferItem& item);
53
Steve Kondikf19d1422019-09-06 13:52:12 -070054 virtual void queryConnection(network::Socket* sock, const char* userName);
55
Steve Kondik961b4cc2017-06-22 18:10:50 -070056 private:
Steve Kondik961b4cc2017-06-22 18:10:50 -070057 virtual void notify();
58
Steve Kondik6f9ab852017-07-09 21:30:20 -070059 virtual status_t updateDisplayInfo();
Steve Kondik961b4cc2017-06-22 18:10:50 -070060
Steve Kondik71850752019-09-12 12:45:23 -070061 virtual rfb::ScreenSet computeScreenLayout();
62
Steve Kondik961b4cc2017-06-22 18:10:50 -070063 Rect mDisplayRect;
64
Steve Kondik6f9ab852017-07-09 21:30:20 -070065 Mutex mLock;
Steve Kondik961b4cc2017-06-22 18:10:50 -070066
67 uint64_t mFrameNumber;
Steve Kondik961b4cc2017-06-22 18:10:50 -070068
69 int mEventFd;
70
Steve Kondik961b4cc2017-06-22 18:10:50 -070071 // Server instance
Steve Kondik71850752019-09-12 12:45:23 -070072 rfb::VNCServer* mServer;
Steve Kondik961b4cc2017-06-22 18:10:50 -070073
74 // Pixel buffer
75 sp<AndroidPixelBuffer> mPixels;
76
Steve Kondik6f9ab852017-07-09 21:30:20 -070077 // Virtual display controller
78 sp<VirtualDisplay> mVirtualDisplay;
79
Steve Kondik961b4cc2017-06-22 18:10:50 -070080 // Primary display
Steve Kondik6f9ab852017-07-09 21:30:20 -070081 DisplayInfo mDisplayInfo;
Steve Kondik961b4cc2017-06-22 18:10:50 -070082
83 // Virtual input device
84 sp<InputDevice> mInputDevice;
85};
86};
87
88#endif