• Home
Name Date Size #Lines LOC

..--

figures/12-May-2024-

frameworks/12-May-2024-15,26411,586

interfaces/12-May-2024-2,7851,310

sa_profile/12-May-2024-4831

services/12-May-2024-13,70310,191

test/resource/12-May-2024-1,9601,798

utils/12-May-2024-906658

LICENSED12-May-20249.9 KiB177150

OAT.xmlD12-May-20244.2 KiB6913

README.mdD12-May-20245.9 KiB7152

README_zh.mdD12-May-20245.7 KiB8157

bundle.jsonD12-May-20243.5 KiB8685

config.gniD12-May-2024779 1917

hisysevent.yamlD12-May-20246.2 KiB130108

README.md

1# AVSession Component
2
3## Introduction
4
5The AVSession component provides unified media control capabilities for the system. It enables users to use the system's Media Controller to control the playback behavior of third-party media applications on the local and remote devices and view related playback information.
6
7#### Architecture Objective
8
9The AVSession component aims to provide unified local and distributed media playback control capabilities and experience.
10
11The component uses a global playback control entry to fully present media information and distributed media device information, so users can operate remote media as they operate local media.
12
13The component provides simplified JS APIs for developers to quickly build media applications and easily access Media Controller to use distributed playback control capabilities.
14
15## Logical Architecture
16
17![Logical Architecture Diagram](figures/frameworkimage-en.png)
18
19### Introduction to module responsibilities
20
21| module name                                      | responsibilities                                             |
22| ------------------------------------------------ | ------------------------------------------------------------ |
23| AVSession                                        | A session object that supports configuring session properties and can proactively update playback status and metadata. |
24| AVSessionController                              | The controller object can obtain the playback status and metadata of the session, remotely send control commands to the session side, or listen to the update events of the session side by subscribing. |
25| AVSessionManager                                 | Provides the ability to query and obtain a specified session controller for basic information about the system's global sessions, and to limit the app's permissions. |
26| AVPlaybackCommand(Playback control commands)     | Used to describe the audio and video broadcast command tool class, the encapsulation object of the broadcast command, support setting and obtaining commands. |
27| AVSessionEvent(Playback control events)          | A utility class that describes audio and video playback events, encapsulates session events, and is sent and received by the session controller. |
28| AVPlaybackState(Playback state)                  | A tool class that describes the status of audio and video playback, supporting cross-process delivery. |
29| AVSessionMetadata(Media metadata)                | A utility class that describes session metadata information, represented as key-value pairs, and supports cross-process passing. |
30| AVSessionService(Session service)                | The system global session manages the SA service and implements the lifecycle callback of the session service. |
31| AVSessionItem(Session records)                   | An object that describes a service-side session record, holds a session label, and updates the record synchronously based on the behavior of the session side. |
32| AVSessionStrategy(Session policies)              | Contains system session distribution policies and session sequencing policies, and supports substitution. |
33| RemoteSessionSource(Distributed session control) | Used to send local sessions to the remote end and synchronize local session information. |
34| RemoteSessionSink(Distributed session control)   | Used to receive remote sessions and synchronize remote session information. |
35
36Data and command interaction between applications and AVSessionService(Session Service) are carried in media sessions(AVSession). Applications store information(Session records) in AVSessionService through sessions. AVSessionService receives control commands(Playback control events and Playback control commands) from system applications or external systems and forwards them to the applications, which then provide the functions as instructed.
37
38- AVSession: An audio and video application applies for a session from AVSessionManager. It is then bound to the session. Through this session, the application and system exchange data and control commands. If an application does not apply for a session, it cannot run in the background.
39
40- AVSessionController: Media Controller applies for a controller from AVSessionManager. Through this controller, Media Controller controls the session, thereby controlling application behavior.
41
42- Distributed session control: After a local session is created, it is synchronized to a remote device, and a remote session is created. The remote session is controlled by sending control commands to the remote device's AVSessionService through its AVSessionController.
43
44## Directory Structure
45
46The structure of the repository directory is as follows:
47
48```
49/foundation/multimedia/av_session # Service code of the AVSession component
50├── frameworks                             # Framework code
51│   ├── common                             # Common framework code
52│   ├── js                                 # JS framework implementation
53│   └── native                             # Native framework implementation
54├── interfaces                             # External APIs
55│   ├── inner_api                          # Native external API files
56│   └── kits                               # External JS API files
57├── sa_profile
58├── services                               # Service implementation
59│   ├── etc
60│   └── session
61│       ├── adapter                        # External dependency adaptation
62│       ├── ipc                            # IPC implementation
63│       └── server                         # Service code implementation
64│           └── remote                     # Distributed service implementation
65├── utils                                  # Public library
66└── bundle.json                            # Compilation file
67```
68
69## Repositories Involved
70
71[**multimedia_av_session**](https://gitee.com/openharmony/multimedia_av_session)

README_zh.md

1# AVSession部件<a name="ZH-CN_TOPIC_0000001148809513"></a>
2
3## 简介<a name="section1158716411637"></a>
4
5AVSession部件为系统提供了统一的媒体控制能力,当三方应用在OpenHarmony系统上运行时,用户可以通过系统播控中心对本端和组网内的远端音视频应用的播放行为进行控制,展示相关播放信息。
6
7#### 架构目标<a name="avsession_targets"></a>
8
9构建统一的本地和分布式的媒体播控能力及体验,包括:
10
111、面向用户:提供便捷的全局播控入口,将媒体信息充分展示给用户。同时自动展示分布式媒体设备信息,用户操作远端媒体如同操作本地媒体。
12
132、面向开发者:向开发者提供精简的JS接口,帮助开发者快速构建媒体应用,并且能够方便的接入系统的播控中心,使用分布式播控能力。
14
15## 逻辑架构<a name="avsession_arch"></a>
16
17![逻辑架构图](figures/frameworkimage.png)
18
19### 模块职责介绍
20
21| 模块名称                              | 职责                                                         |
22| ------------------------------------- | ------------------------------------------------------------ |
23| AVSession                             | 会话对象,支持配置会话属性,并可主动更新播放状态和元数据。   |
24| AVSessionController                   | 控制器对象,可获取会话的播放状态和元数据,远程发送控制命令到会话端,也可以通过订阅监听会话端的更新事件。 |
25| AVSessionManager                      | 提供系统全局会话基本信息的查询和获取指定会话控制器的能力,并对应用的权限进行限权。 |
26| AVPlaybackCommand(播控命令)         | 用于描述音视频播控命令工具类,播控命令的封装对象,支持设置和获取命令。 |
27| AVSessionEvent(播控事件)            | 用于描述音视频播放事件的工具类,对会话事件进行封装,由会话控制器发送和接收。 |
28| AVPlaybackState(播放状态)           | 用于描述音视频播放状态的工具类,支持跨进程传递。             |
29| AVSessionMetadata(媒体元数据)       | 用于描述会话元数据信息的工具类,以键值对的方式表示,支持跨进程传递。 |
30| AVSessionService(会话服务)          | 系统全局会话管理SA服务,实现会话服务的生命周期回调。         |
31| AVSessionItem(会话记录)             | 用于描述服务侧会话记录的对象,持有会话标签,根据会话端的行为同步更新记录。 |
32| AVSessionStrategy(会话策略)         | 包含系统会话分发策略和会话排序策略,支持替换。               |
33| RemoteSessionSource(分布式会话控制) | 用于将本地会话发送到远端并同步本地会话信息。                 |
34| RemoteSessionSink(分布式会话控制)   | 用于接收远端会话并同步远端会话信息。                         |
35
36媒体会话(AVSession)承载应用与系统服务(会话服务)间的数据和命令交互功能,应用通过会话将信息(会话记录)保存在系统服务内,系统服务接收系统应用或者外部的控制命令(播控事件、播控命令),并转发到应用端,由应用实现对应的功能。
37
38会话:音视频应用向控制中心(AVSessionManager)申请会话,会话与应用绑定。应用通过会话向系统传递信息,系统通过会话向应用传递控制命令,如果应用不申请会话,则无法在后台运行。
39
40控制器(AVSessionController):系统播控中心向会话控制中心申请控制器,播控中心通过控制器可以控制指定的会话,进而控制应用行为。
41
42分布式会话控制:组网内的设备创建本地会话后,本地会话会同步到远端,生成远端会话,并支持远端控制。需要控制远端会话时,通过远端控制器将控制命令发送到远端会话控制中心。
43
44## 目录结构<a name="section161941989596"></a>
45
46仓目录结构如下:
47
48```
49/foundation/multimedia/av_session  # 会话部件业务代码
50├── frameworks                             # 框架代码
51│   ├── common                             # 框架公共代码
52│   ├── js                                 # js框架实现
53│   └── native                             # native框架实现
54├── interfaces                             # 外部接口层
55│   ├── inner_api                          # native外部接口文件
56│   └── kits                               # js外部接口文件
57├── sa_profile
58├── services                               # 服务实现
59│   ├── etc
60│   └── session
61│       ├── adapter                        # 外部依赖适配
62│       ├── ipc                            # ipc通信实现
63│       └── server                         # 服务端代码实现
64│           └── remote                     # 分布式服务实现
65├── utils                                  # 会话部件公共库
66└── bundle.json                            # 编译文件
67```
68
69## 约束<a name="section1533973044317"></a>
70
71详细约束请参考[约束和限制](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/media/avsession-overview.md)
72
73## 说明
74
75详细接口说明请参考[API文档](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-avsession.md)
76
77使用说明请参考[开发指导](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/media/avsession-guidelines.md)
78
79## 相关仓<a name="section1533973044317"></a>
80
81[**multimedia_av_session**](https://gitee.com/openharmony/multimedia_av_session)