README_en.md
1# **Distributed screen components**
2
3## **Introduction**
4
5The system architecture is shown in the figure below:
6
7![](figures/distributedscreen_arch.png)
8
9**ScreenRegionManager** : Manages the status of the display region mapped by the master terminal on the screen of the controlled terminal, including specifying the display for the display region, setting the width and height of the display region, decoding type and other parameters.
10
11**Distributed ScreenManager** : Manages the parameters and state of the screen on the controlled end, and is responsible for the creation and destruction of objects related to the master end.
12
13**ScreenService** : Distributed screen master SA service and distributed screen controlled SA service, responsible for handling IPC calls of distributed hardware management framework
14
15**SoftbusAdapter** : connects to the soft bus transmission interface, provides unified call interface encapsulation for screen images, input events, etc, and realizes the transmission and interaction of stream data and byte data between devices.
16
17**ScreenTransport** : Distributed screen transmission module, screen image data encoding, decoding, sending, receiving.
18
19**ScreenClient** : ScreenClient client for displaying screen image data projected from other devices on the device.
20
21## **Directory**
22
23```
24/foundation/distributedhardware/distributed_screen
25├── common # Distributed screen common data definitions, including constants, error codes, logs, tools, and so on
26├── interface # Distributed screen SDK, including master side and controlled side service call interface调用接口
27├── sa_profile # SA configuration information for distributed screens
28├── services # Distributed screen main control terminal and controlled terminal function main business implementation
29│ └── common # Distributed screen function Main control end, controlled end shared function realization
30│ ├── databuffer # Screen data store definition
31│ └── screen_channel # Screen data transfer channel interface definition
32│ └── screenclient # Distributed screen agent client implementation
33│ └── screenservice # Distributed screen main function realization
34│ └── sinkservice # Distributed screen controlled end service function realization
35│ ├── dscreenservice # Distributed screen controller SA
36│ └── screenregionmgr # Distributed screen manages the display area of the controller
37│ └── sourceservice # Distributed screen master terminal service function realization
38│ ├── dscreenmgr # Distributed screen Main control terminal screen management
39│ └── dscreenservice # Distributed screen master SA
40│ └── screentransport # Distributed screen transfer components
41│ ├── screendatachannel # Screen data transfer channel for data transfer between transport components and codecs
42│ ├── screensinkprocessor # Distributed screen controlled data processing module, including decoding, etc
43│ ├── screensinktrans # Distributed screen data transmission component at the controlled end, including data transmission channel and data processing module Processor
44│ ├── screensourceprocessor # Distributed screen master terminal data processing module, including coding, etc
45│ └── screensourcetrans # Distributed screen main control terminal data transmission components, including data transmission channel and data processing module Processor
46│ └── softbusadapter # Soft bus interface adapter for screen transmission, touch event transmission to provide a unified transmission interface
47└── screenhandler # The distributed hardware information report and device status change notification are loaded by the distributed hardware management framework
48```
49
50## **constraint**
51**language restrictions** : C++
52
53**Networking environment** : Ensure that the devices are on the same LAN.
54
55**Operating system Restrictions** : OpenHarmony operating system.
56
57## **indicates**
58### **The concept that**
59
60Master terminal (source) : The control terminal, by invoking the distributed screen capability, uses the screen of the controlled terminal to display the screen content of the master terminal device.
61
62Controlled end (sink) : the controlled end receives the control of the main control end through the distributed screen and receives and displays the screen content of the main control end in the local interconnection window.
63
64### **Interface specification**
65The distributed screen implements the interface provided by the distributed hardware management framework. The distributed hardware management framework uniformly calls the interface to create and register the virtual screen hardware.
66
67### **Scenario Description**
68After device networking authentication, the main control device can specify the screen of the controlled device to Display the content drawn by Display.
69
70
71### **Process description**
72#### **1. Start the device**
73The system pulls up the SA service of the distributed screen, initializes the Source side, and initializes related modules.
74
75#### **2. Device networking online**
76After the device goes online, the distributed hardware management framework synchronizes the screen hardware information of the online device and enables it. After the device is enabled successfully, a virtual screen is added to the system and notified to the window subsystem, which manages the local screen and distributed screen in a unified manner. The northbound application can query the distributed screen through the interface provided by the window subsystem and use the distributed screen according to the interface provided by the window subsystem.
77
78#### **3. Screen data flow**
79(1) The graphics subsystem of the master terminal saves the screen data to be sent in the input Surface created by the encoder.
80
81(2) The master encoder encodes the input data and returns the encoding result to the transmission component ScreenSourceTrans.
82
83(3) ScreenSourcetrans, the transmission component of the master end, sends the encoded data to the SoftBusAdapter through the transmission channel ScreenDatachannel, and sends it to the controlled end device through the softbus subsystem.
84
85(4) After receiving the screendata, the softbus subsystem of the controlled device returns it to the ScreenDatachannel through the SoftBusAdapter.
86
87(5) The controlled transmission channel ScreenDatachannel will transfer the screendata obtained to the decoder for decoding.
88
89(6) The decoder decodes the screen data and saves the decoded data to the Surface of the decoder set by the display window of the controlled end agent. Finally, the screen will be displayed by the window.
90
91#### **4. Device offline**
92After the device is offline, the distributed hardware management framework disables the screen hardware of the offline device, removes the corresponding virtual screen locally, and notifies the window subsystem. In this case, the distributed screen of the offline device is unavailable.
93
94## **refers to warehouse**
95
96**Distributed hardware subsystem:**
97
98Equipment management
99[device_manager](https://gitee.com/openharmony/device_manager)
100
101A step-by-step hardware management framework
102[distributed_hardware_fwk](https://gitee.com/openharmony/distributed_hardware_fwk)
103
104Distributed camera
105[distributed_camera](https://gitee.com/openharmony/distributed_camera)
106
107**Distributed screen
108[distributed_screen](https://gitee.com/openharmony/distributed_screen)**
README_zh.md
1# **分布式屏幕部件**
2
3## **简介**
4
5分布式屏幕是一种屏幕虚拟化能力,支持用户指定组网认证过的其他OpenHarmony设备的屏幕作为Display的显示区域。在分布式硬件子系统中,分布式屏幕组件提供跨设备屏幕能力调用,为OpenHarmony操作系统提供系统投屏、屏幕镜像、屏幕分割等能力的实现。
6
7系统架构如下图所示:
8
9![](figures/distributedscreen_arch.png)
10
11**屏幕区域管理(ScreenRegionManager)**:管理主控端映射在被控端屏幕上的显示区域的状态,包括为显示区域指定显示的display,设置显示区域的宽高,解码类型等参数。
12
13**分布式屏幕管理(DScreenManager)**:管理被控端屏幕的参数和状态,负责主控端相关对象的创建和销毁。
14
15**屏幕服务(ScreenService)**:分布式屏幕主控端SA服务和分布式屏幕被控端SA服务,负责处理分布式硬件管理框架的IPC调用
16
17**软总线适配器(SoftbusAdapter)**:对接软总线传输接口,为屏幕图像、输入事件等提供封装的统一调用接口,实现设备间的流数据、字节数据传输和交互。
18
19**屏幕传输组件(ScreenTransport)**:分布式屏幕传输模块,实现屏幕图像数据编码、解码、发送、接收。
20
21**屏幕代理客户端(ScreenClient)**:屏幕图像显示代理客户端,用于在设备上显示其他设备投射过来的屏幕图像数据。
22
23
24## **目录**
25
26```
27/foundation/distributedhardware/distributed_screen
28├── common # 分布式屏幕公共数据定义,包括常量、错误码、日志、工具等
29├── interface # 分布式屏幕SDK,包含主控端和被控端服务调用接口
30├── sa_profile # 分布式屏幕的SA配置信息
31├── screenhandler # 分布式屏幕硬件信息上报、设备状态变化通知,由分布式硬件管理框架加载
32├── services # 分布式屏幕主控端和被控端功能主体业务实现
33│ └── common # 分布式屏幕功能主控端、被控端共用功能实现
34│ ├── databuffer # 屏幕数据存储定义
35│ └── screen_channel # 屏幕数据传输通道接口定义
36│ ├── screenclient # 分布式屏幕代理客户端实现
37│ ├── screendemo # 分布式屏幕demo
38│ └── screenservice # 分布式屏幕主体功能实现
39│ └── sinkservice # 分布式屏幕被控端服务功能实现
40│ ├── dscreenservice # 分布式屏幕被控端SA
41│ └── screenregionmgr # 分布式屏幕被控端显示区域管理
42│ └── sourceservice # 分布式屏幕主控端服务功能实现
43│ ├── dscreenmgr # 分布式屏幕主控端屏幕管理
44│ └── dscreenservice # 分布式屏幕主控端SA
45│ └── screentransport # 分布式屏幕传输组件
46│ ├── screendatachannel # 屏幕数据传输通道,用于传输组件和编解码器之间数据传输
47│ ├── screensinkprocessor # 分布式屏幕被控端数据处理模块,包括解码等
48│ ├── screensinktrans # 分布式屏幕被控端数据传输组件,包含数据传输通道channel和数据处理模块processor
49│ ├── screensourceprocessor # 分布式屏幕主控端数据处理模块,包括编码等
50│ └── screensourcetrans # 分布式屏幕主控端数据传输组件,包含数据传输通道channel和数据处理模块processor
51│ └── softbusadapter # 软总线接口适配器,为屏幕传输、触控事件传输提供统一传输接口
52```
53
54## **约束**
55**语言限制**:C++语言。
56**组网环境**:必须确保设备在同一个局域网中。
57**操作系统限制**:OpenHarmony操作系统。
58
59## **说明**
60### **概念说明**
61主控端(source):控制端,通过调用分布式屏幕能力,使用被控端的屏幕用于显示主控端设备的屏幕内容。
62被控端(sink):被控制端,通过分布式屏幕接收主控端的控制,在本地对接窗口用于接收和显示主控端设备的屏幕内容。
63
64### **接口说明**
65分布式屏幕实现分布式硬件管理框架提供的接口,由分布式硬件管理框架统一调用接口实现虚拟屏幕硬件的创建和注册功能。
66
67### **场景说明**
68设备组网认证后,主控端设备可以指定被控端设备的屏幕来显示Display绘制的内容。
69
70### **流程说明**
71#### **1. 设备开机启动**
72系统拉起分布式屏幕的SA服务,Source侧被初始化,相关模块被初始化。
73
74#### **2. 设备组网上线**
75设备上线后,分布式硬件管理框架同步到上线设备的屏幕硬件信息并使能,使能成功后在系统中会新增虚拟屏幕并通知到窗口子系统,窗口子系统统一管理本地屏幕和分布式屏幕;北向应用通过窗口子系统提供的接口可以查询到分布式屏幕,并按照窗口子系统提供的接口来使用分布式屏幕。
76
77#### **3. 屏幕数据流转**
78(1)主控端图形子系统将需要发送屏幕数据保存在编码器创建的输入Surface中。
79(2)主控端编码器将输入数据进行编码,并将编码结果返回传输组件screensourcetrans。
80(3)主控端传输组件screensourcetrans将编码后的数据通过传输通道screendatachannel发送到softbusadapter,并经由软总线子系统发送到被控端端设备。
81(4)被控端设备软总线子系统收到屏幕数据后,通过softbusadapter返回给被控端传输通道screendatachannel。
82(5)被控端传输通道screendatachannel将获取到的屏幕数据传递给解码器进行解码。
83(6)解码器将屏幕数据解码,并将解码后的数据保存到被控端代理显示窗口设置到解码器的Surface中,最终由窗口将画面显示在屏幕上。
84
85#### **4. 设备下线**
86设备下线后,分布式硬件管理框架去使能下线设备的屏幕硬件,本地移除对应的虚拟屏幕并通知窗口子系统,此时下线设备的分布式屏幕不可用。
87
88## **相关仓**
89****
90**分布式硬件子系统:**
91
92设备管理
93[distributedhardware_device_manager](https://gitee.com/openharmony/distributedhardware_device_manager)
94
95分步式硬件管理框架
96[distributedhardware_distributed_hardware_fwk](https://gitee.com/openharmony/distributedhardware_distributed_hardware_fwk)
97
98分布式相机
99[distributedhardware_distributed_camera](https://gitee.com/openharmony/distributedhardware_distributed_camera)
100
101**分布式屏幕
102[distributedhardware_distributed_screen](https://gitee.com/openharmony/distributedhardware_distributed_screen)**