blob: 93a661013061dadd8a3e276690ffe74ad41bc3e2 [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>
17#include <rfb/VNCServerST.h>
18
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
39 virtual rfb::Point getFbSize();
40 virtual unsigned int setScreenLayout(int fb_width, int fb_height, const rfb::ScreenSet& layout);
41
Steve Kondikf19d1422019-09-06 13:52:12 -070042 virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
Steve Kondik961b4cc2017-06-22 18:10:50 -070043 virtual void pointerEvent(const rfb::Point& pos, int buttonMask);
44
45 virtual void processFrames();
46
47 virtual int getEventFd() {
48 return mEventFd;
49 }
50
Steve Kondik6f9ab852017-07-09 21:30:20 -070051 virtual void onBufferDimensionsChanged(uint32_t width, uint32_t height);
52
53 virtual void onFrameAvailable(const BufferItem& item);
54
Steve Kondikf19d1422019-09-06 13:52:12 -070055 virtual void queryConnection(network::Socket* sock, const char* userName);
56
Steve Kondik961b4cc2017-06-22 18:10:50 -070057 private:
Steve Kondik961b4cc2017-06-22 18:10:50 -070058 virtual void notify();
59
Steve Kondik6f9ab852017-07-09 21:30:20 -070060 virtual status_t updateDisplayInfo();
Steve Kondik961b4cc2017-06-22 18:10:50 -070061
Steve Kondik961b4cc2017-06-22 18:10:50 -070062 Rect mDisplayRect;
63
Steve Kondik6f9ab852017-07-09 21:30:20 -070064 Mutex mLock;
Steve Kondik961b4cc2017-06-22 18:10:50 -070065
66 uint64_t mFrameNumber;
Steve Kondik961b4cc2017-06-22 18:10:50 -070067
68 int mEventFd;
69
Steve Kondik961b4cc2017-06-22 18:10:50 -070070 // Server instance
71 rfb::VNCServerST* mServer;
72
73 // Pixel buffer
74 sp<AndroidPixelBuffer> mPixels;
75
Steve Kondik6f9ab852017-07-09 21:30:20 -070076 // Virtual display controller
77 sp<VirtualDisplay> mVirtualDisplay;
78
Steve Kondik961b4cc2017-06-22 18:10:50 -070079 // Primary display
80 sp<IBinder> mMainDpy;
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