diff --git a/zh-cn/native_sdk/dsoftbus/dfs_session.h b/zh-cn/native_sdk/dsoftbus/dfs_session.h
new file mode 100755
index 0000000000000000000000000000000000000000..2b2f66a0af3e40c8006258097a95bf5632272b29
--- /dev/null
+++ b/zh-cn/native_sdk/dsoftbus/dfs_session.h
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @addtogroup 软总线
+ * @{
+ *
+ * @brief 在设备之间提供高速、安全的通信。
+ *
+ * 该部件实现附近设备之间的统一分布式通信能力管理,并提供独立于链路的设备发现和传输接口,以支持业务发布和数据传输。
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+
+/**
+ * @file dfs_session.h
+ *
+ * @brief 为软总线的分布式文件服务声明函数和常量。这些函数用于执行以下操作:
+ *
+ * - 获取会话密钥和会话句柄
+ * - 禁用分布式文件服务的会话监听
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+
+#ifndef DFS_SESSION_H
+#define DFS_SESSION_H
+
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief 指示会话密钥的长度,包括终止空字符 \0。
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+#define SESSION_KEY_LEN 32
+
+/**
+ * @example dfs_demo.c
+ */
+
+/**
+ * @brief 根据会话ID获取会话密钥。
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * @param key 指示指向用于存储会话密钥的缓冲区的指针。
+ * @param len 指示缓冲区的长度。
+ * 常见的返回值如下:
+ * @return 返回SOFTBUS_OK,指示成功获取会话密钥。
+ * @return 返回SOFTBUS_INVALID_PARAM,指示输入参数的值无效。
+ * @return 返回SOFTBUS_TRANS_FUNC_NOT_SUPPORT,指示入参的会话ID不是该函数所支持的分布式文件服务对应的会话ID。
+ * @return 返回SOFTBUS_ERR,指示软总线内部处理出现错误。
+ * @return 返回SOFTBUS_MEM_ERR,指示内存不足。
+ * @since 1.0
+ * @version 1.0
+ */
+int32_t GetSessionKey(int32_t sessionId, char *key, unsigned int len);
+
+/**
+ * @brief 根据会话ID获取会话句柄。
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * @param handle 指示指向用于存储会话句柄的缓冲区的指针。
+ * 常见的返回值如下:
+ * @return 返回SOFTBUS_OK,指示成功获取会话句柄。
+ * @return 返回SOFTBUS_INVALID_PARAM,指示输入参数的值无效。
+ * @return 返回SOFTBUS_TRANS_FUNC_NOT_SUPPORT,指示入参的会话ID不是该函数所支持的分布式文件服务对应的会话ID。
+ * @return 返回SOFTBUS_ERR,指示软总线内部处理出现错误。
+ * @return 返回SOFTBUS_MEM_ERR,指示内存不足。
+ * @since 1.0
+ * @version 1.0
+ */
+int32_t GetSessionHandle(int32_t sessionId, int *handle);
+
+/**
+ * @brief 根据会话ID禁用会话监听。
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * 常见的返回值如下:
+ * @return 返回SOFTBUS_OK,指示禁用成功。
+ * @return 返回SOFTBUS_INVALID_PARAM,指示输入参数的值无效。
+ * @return 返回SOFTBUS_TRANS_FUNC_NOT_SUPPORT,指示入参的会话ID不是该函数所支持的分布式文件服务对应的会话ID。
+ * @return 返回SOFTBUS_ERR,指示软总线内部处理出现错误。
+ * @since 1.0
+ * @version 1.0
+ */
+int32_t DisableSessionListener(int32_t sessionId);
+
+#ifdef __cplusplus
+}
+#endif
+#endif // DFS_SESSION_H
\ No newline at end of file
diff --git a/zh-cn/native_sdk/dsoftbus/example/transport/dfs_demo.c b/zh-cn/native_sdk/dsoftbus/example/transport/dfs_demo.c
new file mode 100755
index 0000000000000000000000000000000000000000..e6823bc3d20c2515b421df40a9b88fa12ad959e2
--- /dev/null
+++ b/zh-cn/native_sdk/dsoftbus/example/transport/dfs_demo.c
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file dfs_demo.c
+ *
+ * @brief 分布式文件服务的示例。
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+
+//设备A:
+
+#include
+#include "session.h"
+#include "softbus_config_type.h"
+
+const char *g_pkgNameA = "dms"; // 设备A的应用包名
+const char *g_sessionNameA = "DistributedFileService"; // 设备A的分布式文件服务的会话名称
+const char *g_sessionNameB = "DistributedFileService";
+const char *g_networkidB = "ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00"; // 组网后设备B生成的networkid
+const char *g_groupid = "TEST_GROUP_ID"; //组网时的群组信息
+static SessionAttribute g_sessionAttr = {
+ .dataType = TYPE_FILE, //会话类型
+};
+const char *g_testData = "TranSessionTest_GetSessionKeyTestData";
+
+//通知会话建立成功
+static int OnSessionOpened(int sessionId, int result)
+{
+ printf("session opened,sesison id = %d\r\n", sessionId);
+ return 0;
+}
+
+//通知会话关闭
+static void OnSessionClosed(int sessionId)
+{
+ printf("session closed, session id = %d\r\n", sessionId);
+}
+
+//通知字节数据接收情况
+static void OnBytesReceived(int sessionId, const void *data, unsigned int len)
+{
+ printf("session bytes received, session id = %d\r\n", sessionId);
+}
+
+//通知消息数据接收情况
+static void OnMessageReceived(int sessionId, const void *data, unsigned int len)
+{
+ printf("session msg received, session id = %d\r\n", sessionId);
+}
+
+//通知流数据接收情况
+static void OnStreamReceived(int sessionId, const StreamData *data, const StreamData *ext,
+ const StreamFrameInfo *param)
+{
+ printf("session stream received, session id = %d\r\n", sessionId);
+}
+
+static ISessionListener g_sessionlistenerA = {
+ .OnSessionOpened = OnSessionOpened,
+ .OnSessionClosed = OnSessionClosed,
+ .OnBytesReceived = OnBytesReceived,
+ .OnMessageReceived = OnMessageReceived,
+ .OnStreamReceived = OnStreamReceived,
+};
+
+int main(void)
+{
+ //1、设备A先根据应用包名和会话名称通过CreateSessionServer创建会话服务并注册通道打开关闭.字节接收.消息接收的回调。
+ int ret = CreateSessionServer(g_pkgNameA, g_sessionNameA, &g_sessionlistenerA);
+ printf("create session server result = %d\n", ret);
+
+ //2、A根据本端会话名称和对端会话名称以及对端networkid调用OpenSession打开会话,根据会话的类型决定会话通道,当成功打开会话会通过回调通知设备A和设备B打开会话成功
+ //并返回会话ID,后续的操作赖此会话ID,此外sessionName必须为"DistributedFileService"。
+ int sessionId = OpenSession(g_sessionNameA, g_sessionNameB, g_networkidB, g_groupid, &g_sessionAttr);
+ printf("open session result = %d\n", sessionId);
+
+ //3、当会话打开成功后,设备A可以调用分布式文件服务相关的接口进行相应的操作。
+ char *key = (char *)g_testData;
+ unsigned int len = strlen(key);
+ ret = GetSessionKey(sessionId, key, len);
+ printf("get session key result = %d\n", ret);
+
+ int handle = 1;
+ ret = GetSessionHandle(sessionId, &handle);
+ printf("get session handle result = %d\n", ret);
+
+ ret = DisableSessionListener(sessionId);
+ printf("disable session listener result = %d\n", ret);
+}
\ No newline at end of file
diff --git a/zh-cn/native_sdk/dsoftbus/example/transport/getsessioninfo_demo.c b/zh-cn/native_sdk/dsoftbus/example/transport/getsessioninfo_demo.c
new file mode 100755
index 0000000000000000000000000000000000000000..8ab2a18e34bf0e4ba0280cd7a6e457dd9c01382e
--- /dev/null
+++ b/zh-cn/native_sdk/dsoftbus/example/transport/getsessioninfo_demo.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file dfs_demo.c
+ *
+ * @brief 获取会话信息的示例。
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+
+//设备A:
+
+#include
+#include "session.h"
+#include "softbus_def.h"
+#include "softbus_config_type.h"
+
+const char *g_pkgNameA = "dms"; // 设备A的应用包名
+const char *g_sessionNameA = "ohos.distributedschedule.dms.test"; // 设备A的分布式文件服务的会话名称
+const char *g_sessionNameB = "ohos.distributedschedule.dms.test";
+const char *g_networkidB = "ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00"; // 组网后设备B生成的networkid
+const char *g_groupid = "TEST_GROUP_ID"; //组网时的群组信息
+static SessionAttribute g_sessionAttr = {
+ .dataType = TYPE_BYTES, //会话类型
+};
+const char *g_testData = "TranSessionTest_GetSessionKeyTestData";
+
+//通知会话建立成功
+static int OnSessionOpened(int sessionId, int result)
+{
+ printf("session opened,sesison id = %d\r\n", sessionId);
+ return 0;
+}
+
+//通知会话关闭
+static void OnSessionClosed(int sessionId)
+{
+ printf("session closed, session id = %d\r\n", sessionId);
+}
+
+//通知字节数据接收情况
+static void OnBytesReceived(int sessionId, const void *data, unsigned int len)
+{
+ printf("session bytes received, session id = %d\r\n", sessionId);
+}
+
+//通知消息数据接收情况
+static void OnMessageReceived(int sessionId, const void *data, unsigned int len)
+{
+ printf("session msg received, session id = %d\r\n", sessionId);
+}
+
+//通知流数据接收情况
+static void OnStreamReceived(int sessionId, const StreamData *data, const StreamData *ext,
+ const StreamFrameInfo *param)
+{
+ printf("session stream received, session id = %d\r\n", sessionId);
+}
+
+static ISessionListener g_sessionlistenerA = {
+ .OnSessionOpened = OnSessionOpened,
+ .OnSessionClosed = OnSessionClosed,
+ .OnBytesReceived = OnBytesReceived,
+ .OnMessageReceived = OnMessageReceived,
+ .OnStreamReceived = OnStreamReceived,
+};
+
+int main(void)
+{
+ //1、设备A先根据应用包名和会话名称通过CreateSessionServer创建会话服务并注册通道打开关闭.字节接收.消息接收的回调。
+ int ret = CreateSessionServer(g_pkgNameA, g_sessionNameA, &g_sessionlistenerA);
+ printf("create session server result = %d\n", ret);
+
+ //2、A根据本端会话名称和对端会话名称以及对端networkid调用OpenSession打开会话,根据会话的类型决定会话通道,当成功打开会话会通过回调通知设备A和设备B打开会话成功
+ //并返回会话ID,后续的操作依赖此会话ID。
+ int sessionId = OpenSession(g_sessionNameA, g_sessionNameB, g_networkidB, g_groupid, &g_sessionAttr);
+ printf("open session result = %d\n", sessionId);
+
+ //3、当会话打开成功后,设备A可以获取session相关的信息。
+ char sessionName[SESSION_NAME_SIZE_MAX] = {0};
+ ret = GetMySessionName(sessionId, sessionName, SESSION_NAME_SIZE_MAX);
+ printf("get mySessionName result = %d\n", ret);
+
+ char deviceId[DEVICE_ID_SIZE_MAX] = {0};
+ ret = GetPeerDeviceId(sessionId, deviceId, DEVICE_ID_SIZE_MAX);
+ printf("get peerDeviceId result = %d\n", ret);
+
+ char peerSessionName[SESSION_NAME_SIZE_MAX] = {0};
+ ret = GetPeerSessionName(sessionId, peerSessionName, SESSION_NAME_SIZE_MAX);
+ printf("get peerSessionName result = %d\n", ret);
+
+ ret = GetSessionSide(sessionId);
+ printf("get sessionside result = %d\n", ret);
+}
\ No newline at end of file
diff --git a/zh-cn/native_sdk/dsoftbus/example/transport/openauthsession_demo.c b/zh-cn/native_sdk/dsoftbus/example/transport/openauthsession_demo.c
new file mode 100755
index 0000000000000000000000000000000000000000..362c845721c8c9bd5e26ef878fc0601b8f1c66d1
--- /dev/null
+++ b/zh-cn/native_sdk/dsoftbus/example/transport/openauthsession_demo.c
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file openauthsession_demo.c
+ *
+ * @brief 打开认证会话的示例。
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+
+//设备A:
+
+#include
+#include "inner_session.h"
+#include "session.h"
+
+ConnectionAddr g_addrInfo; //设备间的连接信息
+const char *g_pkgNameA = "dms"; // 设备A的应用包名
+const char *g_sessionNameA = "ohos.distributedschedule.dms.test"; // 设备A的会话名称
+
+//通知会话建立成功
+static int OnSessionOpened(int sessionId, int result)
+{
+ printf("session opened,sesison id = %d\r\n", sessionId);
+ return 0;
+}
+
+//通知会话关闭
+static void OnSessionClosed(int sessionId)
+{
+ printf("session closed, session id = %d\r\n", sessionId);
+}
+
+//通知字节数据接收情况
+static void OnBytesReceived(int sessionId, const void *data, unsigned int len)
+{
+ printf("session bytes received, session id = %d\r\n", sessionId);
+}
+
+//通知消息数据接收情况
+static void OnMessageReceived(int sessionId, const void *data, unsigned int len)
+{
+ printf("session msg received, session id = %d\r\n", sessionId);
+}
+
+static ISessionListener g_sessionlistenerA = {
+ .OnSessionOpened = OnSessionOpened,
+ .OnSessionClosed = OnSessionClosed,
+ .OnBytesReceived = OnBytesReceived,
+ .OnMessageReceived = OnMessageReceived,
+};
+
+int main(void)
+{
+ //1、设备A先根据应用包名和会话名称通过CreateSessionServer创建会话服务并注册通道打开关闭.字节接收.消息接收的回调。
+ int ret = CreateSessionServer(g_pkgNameA, g_sessionNameA, &g_sessionlistenerA);
+ printf("create session server result = %d\n", ret);
+
+ //2、设备A先根据会话名称和连接信息在组网前通过OpenAuthSession创建裸通道进行身份协商。
+ int sessionId = OpenAuthSession(g_sessionNameA, &(g_addrInfo), 1, NULL);
+ printf("open auth session result = %d\n", sessionId);
+
+ //3、当完成身份认证后NotifyAuthSuccess通知设备A认证成功
+ NotifyAuthSuccess(sessionId);
+
+ //4、认证成功后,设备A关闭会话并移除此次会话服务。
+ ret = RemoveSessionServer(g_pkgNameB, g_sessionNameB);
+ printf("remove session server result = %d\n", ret);
+}
+
+//设备B:
+
+#include
+#include "inner_session.h"
+#include "session.h"
+
+const char *g_pkgNameB = "dmsB"; // 设备B的应用包名
+const char *g_sessionNameB = "ohos.distributedschedule.dms.testB"; // 设备B的会话名称
+
+static int OnSessionOpened(int sessionId, int result)
+{
+ printf("session opened,sesison id = %d\r\n", sessionId);
+ return 0;
+}
+
+static void OnSessionClosed(int sessionId)
+{
+ printf("session closed, session id = %d\r\n", sessionId);
+}
+
+static void OnBytesReceived(int sessionId, const void *data, unsigned int len)
+{
+ printf("session bytes received, session id = %d\r\n", sessionId);
+}
+
+static void OnMessageReceived(int sessionId, const void *data, unsigned int len)
+{
+ printf("session msg received, session id = %d\r\n", sessionId);
+}
+
+static ISessionListener g_sessionlistenerB = {
+ .OnSessionOpened = OnSessionOpened,
+ .OnSessionClosed = OnSessionClosed,
+ .OnBytesReceived = OnBytesReceived,
+ .OnMessageReceived = OnMessageReceived,
+};
+
+int main(void)
+{
+ //1、设备B先根据应用包名和会话名称通过CreateSessionServer创建会话服务并注册通道打开关闭的回调。
+ int ret = CreateSessionServer(g_pkgNameB, g_sessionNameB, &g_sessionlistenerB);
+ printf("create session server result = %d\n", ret);
+
+ //2、设备B收到设备A的身份认证会话协商信息通过回调OnSessionOpened通知设备B身份认证会话通道打开成功。
+
+ //3、认证成功后,设备B关闭会话并移除此次会话服务。
+ ret = RemoveSessionServer(g_pkgNameB, g_sessionNameB);
+ printf("remove session server result = %d\n", ret);
+}
\ No newline at end of file
diff --git a/zh-cn/native_sdk/dsoftbus/example/transport/sendbytes_message_demo.c b/zh-cn/native_sdk/dsoftbus/example/transport/sendbytes_message_demo.c
new file mode 100755
index 0000000000000000000000000000000000000000..9525752add17c5ba008b284028ace40d80bc748f
--- /dev/null
+++ b/zh-cn/native_sdk/dsoftbus/example/transport/sendbytes_message_demo.c
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file sendbytes_message_demo.c
+ *
+ * @brief 发送消息或者字节数据的示例。
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+
+//设备A:
+
+#include
+#include "session.h"
+#include "softbus_config_type.h"
+
+const char *g_pkgNameA = "dms"; // 设备A的应用包名
+const char *g_sessionNameA = "ohos.distributedschedule.dms.test"; // 设备A的会话名称
+const char *g_networkidB = "ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00"; // 组网后设备B生成的networkid
+const char *g_groupid = "TEST_GROUP_ID"; //组网时的群组信息
+static SessionAttribute g_sessionAttr = {
+ .dataType = TYPE_BYTES, //会话类型
+};
+
+//通知会话建立成功
+static int OnSessionOpened(int sessionId, int result)
+{
+ printf("session opened,sesison id = %d\r\n", sessionId);
+ return 0;
+}
+
+//通知会话关闭
+static void OnSessionClosed(int sessionId)
+{
+ printf("session closed, session id = %d\r\n", sessionId);
+}
+
+//通知字节数据接收情况
+static void OnBytesReceived(int sessionId, const void *data, unsigned int len)
+{
+ printf("session bytes received, session id = %d\r\n", sessionId);
+}
+
+//通知消息数据接收情况
+static void OnMessageReceived(int sessionId, const void *data, unsigned int len)
+{
+ printf("session msg received, session id = %d\r\n", sessionId);
+}
+
+static ISessionListener g_sessionlistenerA = {
+ .OnSessionOpened = OnSessionOpened,
+ .OnSessionClosed = OnSessionClosed,
+ .OnBytesReceived = OnBytesReceived,
+ .OnMessageReceived = OnMessageReceived,
+};
+
+int main(void)
+{
+ //1、设备A先根据应用包名和会话名称通过CreateSessionServer创建会话服务并注册通道打开关闭.字节接收.消息接收的回调。
+ int ret = CreateSessionServer(g_pkgNameA, g_sessionNameA, &g_sessionlistenerA);
+ printf("create session server result = %d\n", ret);
+
+ //2、A根据本端会话名称和对端会话名称以及对端networkid调用OpenSession打开会话,根据会话的类型决定会话通道,当成功打开会话会通过回调通知设备A和设备B打开会话成功
+ //并返回会话ID,后续的数据发送依赖此会话ID。
+ int sessionId = OpenSession(g_sessionNameA, g_sessionNameB, g_networkidB, g_groupid, &g_sessionAttr);
+ printf("open session result = %d\n", sessionId);
+
+ //3、当会话打开成功后,设备A调用SendBytes或者SendMessage向设备B发送数据。
+ const char *data = "testdata";
+ uint32_t len = strlen(data);
+ uint32_t maxLen = SOFTBUS_INT_MAX_BYTES_LENGTH;
+ ret = SendBytes(sessionId, data, len);
+ printf("send bytes result = %d\n", ret);
+
+ ret = SendMessage(sessionId, data, len);
+ printf("send message result = %d\n", ret);
+
+ //4、当数据发送完成后,设备A通过CloseSession接口关闭会话,并通知设备B关闭会话
+ CloseSession(sessionId);
+ printf("SOFTBUS_OK");
+
+ //5、关闭会话后,设备A和设备B通过RemoveSessionServer接口移除此次会话服务
+ ret = RemoveSessionServer(g_pkgNameA, g_sessionNameA);
+ printf("remove session server result = %d\n", ret);
+}
+
+//设备B:
+
+#include
+#include "session.h"
+
+const char *g_pkgNameB = "dmsB"; // 设备B的应用包名
+const char *g_sessionNameB = "ohos.distributedschedule.dms.testB"; // 设备B的会话名称
+
+static int OnSessionOpened(int sessionId, int result)
+{
+ printf("session opened,sesison id = %d\r\n", sessionId);
+ return 0;
+}
+
+static void OnSessionClosed(int sessionId)
+{
+ printf("session closed, session id = %d\r\n", sessionId);
+}
+
+static void OnBytesReceived(int sessionId, const void *data, unsigned int len)
+{
+ printf("session bytes received, session id = %d\r\n", sessionId);
+}
+
+static void OnMessageReceived(int sessionId, const void *data, unsigned int len)
+{
+ printf("session msg received, session id = %d\r\n", sessionId);
+}
+
+static ISessionListener g_sessionlistenerB = {
+ .OnSessionOpened = OnSessionOpened,
+ .OnSessionClosed = OnSessionClosed,
+ .OnBytesReceived = OnBytesReceived,
+ .OnMessageReceived = OnMessageReceived,
+};
+
+int main(void)
+{
+ //1、设备B先根据应用包名和会话名称通过CreateSessionServer创建会话服务并注册通道打开关闭.字节接收.消息接收的回调。
+ int ret = CreateSessionServer(g_pkgNameB, g_sessionNameB, &g_sessionlistenerB);
+ printf("create session server result = %d\n", ret);
+
+ //2、设备B通过OnSessionOpened收到会话打开的回调后后便等待设备A发送数据,当接收到数据时通过OnBytesReceived和OnMessageReceived反馈接收情况。
+
+ //3、接收数据结束后,设备B关闭会话并移除此次会话服务。
+ ret = RemoveSessionServer(g_pkgNameB, g_sessionNameB);
+ printf("remove session server result = %d\n", ret);
+}
\ No newline at end of file
diff --git a/zh-cn/native_sdk/dsoftbus/example/transport/sendfile_demo.c b/zh-cn/native_sdk/dsoftbus/example/transport/sendfile_demo.c
new file mode 100755
index 0000000000000000000000000000000000000000..ec69edd2208b44e0ce5b71ffa5ba1381304a507d
--- /dev/null
+++ b/zh-cn/native_sdk/dsoftbus/example/transport/sendfile_demo.c
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file sendfile_demo.c
+ *
+ * @brief 发送文件的示例。
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+
+//设备A:
+
+#include
+#include "session.h"
+#include "softbus_config_type.h"
+
+const char *g_pkgNameA = "dms"; // 设备A的应用包名
+const char *g_sessionNameA = "ohos.distributedschedule.dms.test"; // 设备A的会话名称
+const char *g_networkidB = "ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00"; // 组网后设备B生成的networkid
+const char *g_groupid = "TEST_GROUP_ID"; //组网时的群组信息
+static SessionAttribute g_sessionAttr = {
+ .dataType = TYPE_FILE, //文件类型
+};
+const char *g_rootDir = "/data/"; //接收方根目录
+const int FILE_NUM = 4;
+
+//通知会话建立成功
+static int OnSessionOpened(int sessionId, int result)
+{
+ printf("session opened,sesison id = %d\r\n", sessionId);
+ return 0;
+}
+
+//通知会话关闭
+static void OnSessionClosed(int sessionId)
+{
+ printf("session closed, session id = %d\r\n", sessionId);
+}
+
+//会话相关的回调
+static ISessionListener g_sessionlistenerA = {
+ .OnSessionOpened = OnSessionOpened,
+ .OnSessionClosed = OnSessionClosed,
+};
+
+static int OnSendFileProcess(int sessionId, uint64_t bytesUpload, uint64_t bytesTotal)
+{
+ printf("OnSendFileProcess sessionId = %d, bytesUpload = %u, total = %u\n",
+ sessionId, bytesUpload, bytesTotal);
+ return 0;
+}
+
+static int OnSendFileFinished(int sessionId, const char *firstFile)
+{
+ printf("OnSendFileFinished sessionId = %d, first file = %s\n", sessionId, firstFile);
+ return 0;
+}
+
+static void OnFileTransError(int sessionId)
+{
+ printf("OnFileTransError sessionId = %d\n", sessionId);
+}
+
+//文件发送相关的回调
+static IFileSendListener g_fileSendListener = {
+ .OnSendFileProcess = OnSendFileProcess,
+ .OnSendFileFinished = OnSendFileFinished,
+ .OnFileTransError = OnFileTransError,
+};
+
+int main(void)
+{
+ //1、设备A通过SetFileSendListener接口设置文件的发送回调。
+ int ret = SetFileSendListener(g_pkgNameA, g_sessionNameA, &g_fileSendListener);
+ printf("set file send listener result = %d\n", ret);
+
+ //2、设备A先根据应用包名和会话名称通过CreateSessionServer创建会话服务并注册通道打开关闭.字节接收.消息接收的回调。
+ ret = CreateSessionServer(g_pkgNameA, g_sessionNameA, &g_sessionlistenerA);
+ printf("create session server result = %d\n", ret);
+
+ //3、A根据本端会话名称和对端会话名称以及对端networkid和会话类型调用OpenSession打开会话,根据会话的类型决定会话通道,当成功打开会话会通过回调通知设备A和设备B打开会话成功
+ //并返回会话ID,后续的文件发送依赖此会话ID。
+ int sessionId = OpenSession(g_sessionNameA, g_sessionNameB, g_networkidB, g_groupid, &g_sessionAttr);
+ printf("open session result = %d\n", sessionId);
+
+ //4、当会话打开成功后,设备A调用SendFile向设备B发送文件。
+ const char *sfileList[] = {
+ "/data/big.tar",
+ "/data/richu.jpg",
+ "/data/richu-002.jpg",
+ "/data/richu-003.jpg",
+ };
+ ret = SendFile(sessionId, sfileList, NULL, FILE_NUM);
+ printf("send file result = %d\n", ret);
+
+ //5、当数据发送完成后,设备A通过CloseSession接口关闭会话,并通知设备B关闭会话
+ CloseSession(sessionId);
+ printf("SOFTBUS_OK");
+
+ //6、关闭会话后,设备A和设备B通过RemoveSessionServer接口移除此次会话服务
+ ret = RemoveSessionServer(g_pkgNameA, g_sessionNameA);
+ printf("remove session server result = %d\n", ret);
+}
+
+//设备B:
+
+#include
+#include "session.h"
+
+const char *g_pkgNameB = "dmsB"; // 设备B的应用包名
+const char *g_sessionNameB = "ohos.distributedschedule.dms.testB"; // 设备B的会话名称
+const char *g_rootDirB = "/data"; //设备B的文件目录
+
+static int OnSessionOpened(int sessionId, int result)
+{
+ printf("session opened,sesison id = %d\r\n", sessionId);
+ return 0;
+}
+
+static void OnSessionClosed(int sessionId)
+{
+ printf("session closed, session id = %d\r\n", sessionId);
+}
+
+static ISessionListener g_sessionlistenerB = {
+ .OnSessionOpened = OnSessionOpened,
+ .OnSessionClosed = OnSessionClosed,
+};
+
+static int OnReceiveFileStarted(int sessionId, const char *files, int fileCnt)
+{
+ printf("File receive start sessionId = %d, first file = %s, fileCnt = %d\n", sessionId, files, fileCnt);
+ return 0;
+}
+
+static int OnReceiveFileProcess(int sessionId, const char *firstFile, uint64_t bytesUpload, uint64_t bytesTotal)
+{
+ printf("File receive Process sessionId = %d, first file = %s, bytesUpload = %u, bytesTotal = %u\n",
+ sessionId, firstFile, bytesUpload, bytesTotal);
+ return 0;
+}
+
+static void OnReceiveFileFinished(int sessionId, const char *files, int fileCnt)
+{
+ printf("File receive finished sessionId = %d, first file = %s, fileCnt = %d\n", sessionId, files, fileCnt);
+}
+
+static void OnFileTransError(int sessionId)
+{
+ printf("OnFileTransError sessionId = %d\n", sessionId);
+}
+
+//文件接收相关的回调
+static IFileReceiveListener g_fileRecvListener = {
+ .OnReceiveFileStarted = OnReceiveFileStarted,
+ .OnReceiveFileProcess = OnReceiveFileProcess,
+ .OnReceiveFileFinished = OnReceiveFileFinished,
+ .OnFileTransError = OnFileTransError,
+};
+
+int main(void)
+{
+ //1、设备B通过SetFileReceiveListener接口设置文件的接收回调。
+ int ret = SetFileReceiveListener(g_pkgNameB, g_sessionNameB, &g_fileRecvListener, g_rootDirB);
+ printf("set file receive listener result = %d\n", ret);
+
+ //2、设备B先根据应用包名和会话名称通过CreateSessionServer创建会话服务并注册通道打开关闭.字节接收.消息接收的回调。
+ ret = CreateSessionServer(g_pkgNameB, g_sessionNameB, &g_sessionlistenerB);
+ printf("create session server result = %d\n", ret);
+
+ //3、设备B通过OnSessionOpened收到会话打开的回调后后便等待设备A发送文件,当接收到文件时
+ //通过OnReceiveFileProcess和OnReceiveFileStarted,OnReceiveFileFinished反馈接收情况。
+
+ //4、接收数据结束后,设备B关闭会话并移除此次会话服务。
+ ret = RemoveSessionServer(g_pkgNameB, g_sessionNameB);
+ printf("remove session server result = %d\n", ret);
+}
\ No newline at end of file
diff --git a/zh-cn/native_sdk/dsoftbus/example/transport/sendstream_demo.c b/zh-cn/native_sdk/dsoftbus/example/transport/sendstream_demo.c
new file mode 100755
index 0000000000000000000000000000000000000000..8df84de64f2df159d4d0814e74f545f6a6bfa9b8
--- /dev/null
+++ b/zh-cn/native_sdk/dsoftbus/example/transport/sendstream_demo.c
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file sendstream_demo.c
+ *
+ * @brief 发送流数据的示例。
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+
+//设备A:
+
+#include
+#include "session.h"
+#include "softbus_config_type.h"
+
+const char *g_pkgNameA = "dms"; // 设备A的应用包名
+const char *g_sessionNameA = "ohos.distributedschedule.dms.test"; // 设备A的会话名称
+const char *g_networkidB = "ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00ABCDEF00"; // A和B组网时对端生成的networkid
+const char *g_groupid = "TEST_GROUP_ID"; //组网时的群组信息
+static SessionAttribute g_sessionAttr = {
+ .dataType = TYPE_BYTES, //会话类型
+};
+
+//通知会话建立成功
+static int OnSessionOpened(int sessionId, int result)
+{
+ printf("session opened,sesison id = %d\r\n", sessionId);
+ return 0;
+}
+
+//通知会话关闭
+static void OnSessionClosed(int sessionId)
+{
+ printf("session closed, session id = %d\r\n", sessionId);
+}
+
+//通知流数据接收情况
+static void OnStreamReceived(int sessionId, const StreamData *data, const StreamData *ext,
+ const StreamFrameInfo *param)
+{
+ printf("session stream received, session id = %d\r\n", sessionId);
+}
+
+static ISessionListener g_sessionlistenerA = {
+ .OnSessionOpened = OnSessionOpened,
+ .OnSessionClosed = OnSessionClosed,
+ .OnStreamReceived = OnStreamReceived,
+};
+
+int main(void)
+{
+ //1、设备A先根据应用包名和会话名称通过CreateSessionServer创建会话服务并注册通道打开关闭.字节接收.消息接收的回调。
+ int ret = CreateSessionServer(g_pkgNameA, g_sessionNameA, &g_sessionlistenerA);
+ printf("create session server result = %d\n", ret);
+
+ //2、A根据本端会话名称和对端会话名称以及对端networkid调用OpenSession打开会话,根据会话的类型决定会话通道,当成功打开会话会通过回调通知设备A和设备B打开会话成功
+ //并返回会话ID,后续的数据发送依赖此会话ID。
+ int sessionId = OpenSession(g_sessionNameA, g_sessionNameB, g_networkidB, g_groupid, &g_sessionAttr);
+ printf("open session result = %d\n", sessionId);
+
+ //3、当会话打开成功后,设备A调用SendStream向设备B发送数据。
+ const StreamData streamData = {0};
+ const StreamData ext = {0};
+ const StreamFrameInfo param = {0};
+
+ ret = SendStream(sessionId, &streamData, &ext, ¶m);
+ printf("send stream result = %d\n", ret);
+
+ //4、当数据发送完成后,设备A通过CloseSession接口关闭会话,并通知设备B关闭会话
+ CloseSession(sessionId);
+ printf("SOFTBUS_OK");
+
+ //5、关闭会话后,设备A和设备B通过RemoveSessionServer接口移除此次会话服务
+ ret = RemoveSessionServer(g_pkgNameA, g_sessionNameA);
+ printf("remove session server result = %d\n", ret);
+}
+
+//设备B:
+
+#include
+#include "session.h"
+
+const char *g_pkgNameB = "dmsB"; // 设备B的应用包名
+const char *g_sessionNameB = "ohos.distributedschedule.dms.testB"; // 设备B的会话名称
+
+static int OnSessionOpened(int sessionId, int result)
+{
+ printf("session opened,sesison id = %d\r\n", sessionId);
+ return 0;
+}
+
+static void OnSessionClosed(int sessionId)
+{
+ printf("session closed, session id = %d\r\n", sessionId);
+}
+
+static void OnStreamReceived(int sessionId, const StreamData *data, const StreamData *ext,
+ const StreamFrameInfo *param)
+{
+ printf("session stream received, session id = %d\r\n", sessionId);
+}
+
+static ISessionListener g_sessionlistenerB = {
+ .OnSessionOpened = OnSessionOpened,
+ .OnSessionClosed = OnSessionClosed,
+ .OnStreamReceived = OnStreamReceived,
+};
+
+int main(void)
+{
+ //1、设备B先根据应用包名和会话名称通过CreateSessionServer创建会话服务并注册通道打开关闭.字节接收.消息接收的回调。
+ int ret = CreateSessionServer(g_pkgNameB, g_sessionNameB, &g_sessionlistenerB);
+ printf("create session server result = %d\n", ret);
+
+ //2、设备B通过OnSessionOpened收到会话打开的回调后后便等待设备A发送数据,当接收到数据时通过OnStreamReceived反馈接收情况。
+
+ //3、接收数据结束后,设备B关闭会话并移除此次会话服务。
+ ret = RemoveSessionServer(g_pkgNameB, g_sessionNameB);
+ printf("remove session server result = %d\n", ret);
+}
\ No newline at end of file
diff --git a/zh-cn/native_sdk/dsoftbus/inner_session.h b/zh-cn/native_sdk/dsoftbus/inner_session.h
new file mode 100755
index 0000000000000000000000000000000000000000..a5fae6217bd0b0edd832fd527cc48eda941dfd44
--- /dev/null
+++ b/zh-cn/native_sdk/dsoftbus/inner_session.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @addtogroup 软总线
+ * @{
+ *
+ * @brief 在设备之间提供高速、安全的通信。
+ *
+ * 该部件实现附近设备之间的统一分布式通信能力管理,并提供独立于链路的设备发现和传输接口,以支持业务发布和数据传输。
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+
+/**
+ * @file inner_session.h
+ *
+ * @brief 为软总线身份认证声明函数。这些函数用于执行以下操作:
+ *
+ * - 打开身份认证会话
+ * - 通知认证成功
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+#ifndef INNER_SESSION_H
+#define INNER_SESSION_H
+
+#include "softbus_common.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @example openauthsession_demo.c
+ */
+
+/**
+ * @brief 启动身份认证会话打开请求。
+ *
+ * @param sessionName 指示指向本端身份认证会话名称的指针,会话名称是会话服务的唯一标志。该值不能为空,最多可包含256个字符。
+ * @param addrInfo 指示指向设备之间连接地址信息的指针。
+ * @param num 指示设备之间连接信息的数量。
+ * @param mixAddr 指示指向连接地址信息的指针,当第二个参数传入的地址信息无效时,通过转化该参数获取连接信息。
+ * 常见的错误代码如下:
+ * @return SOFTBUS_INVALID_PARAM 指示输入参数的值无效。
+ * @return INVALID_SESSION_ID 打开身份认证会话失败,并返回无效的会话标识。
+ * @return 如果身份认证会话成功打开,并且会话标识大于0,则返回会话标识,否则返回其他错误代码。
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+int OpenAuthSession(const char *sessionName, const ConnectionAddr *addrInfo, int num, const char *mixAddr);
+
+/**
+ * @brief 根据传输会话ID通知本端上层业务身份认证成功。
+ *
+ * @param sessionId 指示会话的唯一标识。
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+void NotifyAuthSuccess(int sessionId);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
\ No newline at end of file
diff --git a/zh-cn/native_sdk/dsoftbus/session.h b/zh-cn/native_sdk/dsoftbus/session.h
new file mode 100755
index 0000000000000000000000000000000000000000..b276e1d9ea208aa8d02b27c75226affd919a1e89
--- /dev/null
+++ b/zh-cn/native_sdk/dsoftbus/session.h
@@ -0,0 +1,730 @@
+/*
+ * Copyright (c) 2022 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @addtogroup Softbus
+ * @{
+ *
+ * @brief Provides high-speed, secure communication between devices.
+ *
+ * This module implements unified distributed communication capability management between
+ * nearby devices, and provides link-independent device discovery and transmission interfaces
+ * to support service publishing and data transmission.
+ *
+ * @since 1.0
+ * @version 1.0
+*/
+
+/**
+ * @file session.h
+ *
+ * @brief Declares unified data transmission interfaces.
+ *
+ * This file provides data transmission capabilities, including creating and removing a session server,
+ * opening and closing sessions, receiving data, and querying basic session information. \n
+ * After multiple nearby devices are discovered and networked, these interfaces can be used to
+ * transmit data across devices. \n
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+#ifndef SESSION_H
+#define SESSION_H
+
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief 列举会话的业务类型
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+typedef enum {
+ TYPE_MESSAGE = 1, /**< 会话类型是消息类型 */
+ TYPE_BYTES, /**< 会话类型是字节类型 */
+ TYPE_FILE, /**< 会话类型是文件类型 */
+ TYPE_STREAM, /**< 会话类型是流类型 */
+ TYPE_BUTT,
+} SessionType;
+
+/**
+ * @brief 列举流传输的业务类型
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+typedef enum {
+ INVALID = -1, /**< 无效的流传输类型 */
+ RAW_STREAM, /**< Send any segment of a frame each time. */
+ COMMON_VIDEO_STREAM, /**< Send a whole video frame each time. */
+ COMMON_AUDIO_STREAM, /**< Send a whole audio frame each time. */
+ VIDEO_SLICE_STREAM, /**< Slice frame mode. */
+} StreamType;
+
+/**
+ * @brief 列举连接类型
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+typedef enum {
+ LINK_TYPE_WIFI_WLAN_5G = 1, /**< 5GWiFi连接 */
+ LINK_TYPE_WIFI_WLAN_2G = 2, /**< 2.4GWiFi连接 */
+ LINK_TYPE_WIFI_P2P = 3, /**< p2p连接 */
+ LINK_TYPE_BR = 4, /**< Br连接 */
+ LINK_TYPE_MAX = 4, /**< 无效的连接类型 */
+} LinkType;
+
+/**
+ * @brief session attribute.
+ *
+ * control the attribute of session.
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+typedef struct {
+ int dataType; /**< 传输数据类型{@link SessionType} */
+ int linkTypeNum; /**< 连接类型的个数 */
+ LinkType linkType[LINK_TYPE_MAX]; /**< 连接类型{@link LinkType} */
+ /**
+ * @brief 属性
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+ union {
+ /**
+ * @brief 流数据的属性
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+ struct StreamAttr {
+ int streamType; /**< 流传输的类型{@link StreamType} */
+ } streamAttr;
+ } attr;
+} SessionAttribute;
+
+/**
+ * @brief 流数据
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+typedef struct {
+ char *buf; /**< 指示指向用于存储流数据的缓冲区的指针 */
+ int bufLen; /**< 指示缓冲区的长度 */
+} StreamData;
+
+/**
+ * @brief 流扩展数据
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+typedef struct {
+ int type; /**< 扩展数据类型{@link TransEnumEventType} */
+ int64_t value; /**< 扩展数据的值 */
+} TV;
+
+/**
+ * @brief 流传输的帧信息
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+typedef struct {
+ int frameType; /**< 帧类型,包括I帧和P帧 */
+ int64_t timeStamp; /**< 时间戳 */
+ int seqNum; /**< 序列号 */
+ int seqSubNum; /**< 切片的序列号 */
+ int level; /**< 可扩展视频编码级别,0:基本级别,1:扩展级别 1,2:扩展级别 2 */
+ int bitMap; /**< 帧标记,比如标记帧的首尾分片 */
+ int tvCount; /**< 扩展数据TV的数量 */
+ TV *tvList; /**< 指向扩展数据的指针 */
+} StreamFrameInfo;
+
+/**
+ * @brief 服务质量
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+typedef enum {
+ QOS_IMPROVE = 0, /**< 提高服务质量 */
+ QOS_RECOVER = 1, /**< 恢复服务质量 */
+} QosQuality;
+
+/**
+ * @brief 服务质量反馈
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+typedef enum {
+ TRANS_STREAM_QUALITY_EVENT = 1, /**< 流传输质量反馈 */
+ TRANS_CHANNEL_QUALITY_EVENT, /**< 传输通道质量反馈 */
+ TRANS_CAN_DELAY_EVENT, /**< 可延迟传输反馈*/
+ TRANS_CANT_DELAY_EVENT, /**< 不可延迟传输反馈*/
+ QOS_EVENT_MAX /**< 无效的反馈 */
+} QosEvent;
+
+/**
+ * @brief 流传输服务质量事件类型
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+typedef enum {
+ WIFI_CHANNEL_QUALITY = 1, /**< WiFi信道质量 */
+ FRAME_REALTIME_STATUS = 2, /**< 帧传输实时状态 */
+ BANDWIDTH_ESTIMATE_VALUE = 3, /**< 带宽信息 */
+ JITTER_DETECTION_VALUE = 4, /**< 网络抖动检测 */
+ STREAM_TRAFFIC_STASTICS = 5, /**< 流传输流量统计 */
+} TransEnumEventType;
+
+/**
+ * @brief Wifi信道质量
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+typedef struct {
+ int32_t channel; /**< WiFi信道 */
+ int32_t score; /**< WiFi信道评分 */
+} WifiChannelQuality;
+
+/**
+ * @brief 帧信息
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+typedef struct {
+ int32_t streamId; /**< 流数据的标识 */
+ int32_t seqNum; /**< 帧序号 */
+ int32_t level; /**< 帧层号 */
+ int32_t transStatus; /**< 帧状态 */
+ int32_t interval; /**< 未发送状态下的帧队列缓存时间 */
+} FrameStatus;
+
+/**
+ * @brief 带宽检测
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+typedef struct {
+ uint32_t trend; /**< 带宽变化趋势 */
+ uint32_t rate; /**< 带宽速率 */
+} BandwidthDetection;
+
+/**
+ * @brief 网络抖动预测
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+typedef struct {
+ int32_t jitterLevel; /**< 预测网络状态 */
+ uint32_t bufferTime; /**< 接收缓存所需时间 */
+} JitterEstimation;
+
+/**
+ * @brief 流传输信息统计
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+typedef struct {
+ uint64_t statisticsGotTime; /**< 统计获取流传输信息的时间点 */
+ uint64_t periodRecvBits; /**< 周期接收的比特数 */
+ uint32_t pktNum; /**< 数据包数量 */
+ uint32_t periodRecvPkts; /**< 周期接收的包数 */
+ uint32_t periodRecvPktLoss; /**< 周期接收的丢包数 */
+ uint32_t periodRecvRate; /**< 周期接收速率,单位:kbps */
+ uint64_t periodRecvRateBps; /**< 周期接收速率,单位:bps */
+ uint32_t periodRtt; /**< 周期往返时延,单位:毫秒 */
+ uint32_t periodRecvPktLossHighPrecision; /**< 高精度展示周期接收的丢包率,比如当丢包率为1.10%时,该值为110 */
+ uint32_t periodSendLostPkts; /**< 周期发送的丢包数 */
+ uint32_t periodSendPkts; /**< 周期发送的包数 */
+ uint32_t periodSendPktLossHighPrecision; /**< 高精度展示周期发送的丢包率,比如当丢包率为1.10%时,该值为110 */
+ uint64_t periodSendBits; /**< 周期发送的比特数 */
+ uint64_t periodSendRateBps; /**< 周期发送速率,单位:bps */
+} StreamStatistics;
+
+/**
+ * @brief 视频流传输服务质量
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+typedef struct {
+ TransEnumEventType type; /**< 流传输服务质量事件类型{@link TransEnumEventType} */
+ union {
+ WifiChannelQuality wifiChannelInfo; /**< Wifi信道质量{@link WifiChannelQuality} */
+ FrameStatus frameStatusInfo; /**< 帧信息{@link FrameStatus} */
+ BandwidthDetection bandwidthInfo; /**< 带宽预测{@link BandwidthDetection} */
+ JitterEstimation jitterInfo; /**< 网络抖动预测{@link JitterEstimation} */
+ StreamStatistics appStatistics; /**< 流传输信息统计{@link StreamStatistics} */
+ } info;
+} QosTv;
+
+/**
+ * @brief Defines session callbacks.
+ *
+ * When a session is opened or closed, or there is data to process, the related callback is invoked.
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+typedef struct {
+ /**
+ * @brief Called when a session is opened.
+ *
+ * This function can be used to verify the session or initialize resources related to the session.
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * @param result 0 if the session is opened successfully, returns an error code otherwise.
+ * @return Returns 0 if the session connection is accepted; returns a non-zero value
+ * otherwise (you do not need to call {@link CloseSession} to close the session).
+ * @since 1.0
+ * @version 1.0
+ */
+ int (*OnSessionOpened)(int sessionId, int result);
+
+ /**
+ * @brief Called when a session is closed.
+ *
+ * This function can be used to release resources related to the session.
+ * You do not need to call {@link CloseSession}.
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * @since 1.0
+ * @version 1.0
+ */
+ void (*OnSessionClosed)(int sessionId);
+
+ /**
+ * @brief Called when data is received.
+ *
+ * This function is used to notify that data is received.
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * @param data Indicates the pointer to the data received.
+ * @param dataLen Indicates the length of the data received.
+ * @since 1.0
+ * @version 1.0
+ */
+ void (*OnBytesReceived)(int sessionId, const void *data, unsigned int dataLen);
+
+ /**
+ * @brief Called when message is received.
+ *
+ * This function is used to notify that message is received.
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * @param data Indicates the pointer to the message data received.
+ * @param dataLen Indicates the length of the message received.
+ * @since 1.0
+ * @version 1.0
+ */
+ void (*OnMessageReceived)(int sessionId, const void *data, unsigned int dataLen);
+
+ /**
+ * @brief Called when stream is received.
+ *
+ * This function is used to notify that stream is received.
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * @param data Indicates the pointer to the stream data received.
+ * @param ext 指示指向要接收的业务扩展数据的指针
+ * @param param 指示指向流数据帧信息的指针
+ * @since 1.0
+ * @version 1.0
+ */
+ void (*OnStreamReceived)(int sessionId, const StreamData *data, const StreamData *ext,
+ const StreamFrameInfo *param);
+
+ /**
+ * @brief Called when QoS information is retrieved.
+ *
+ * This function is used to notify that QoS information is retrieved.
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * @param eventId Indicates the type of QoS information, e.g., channel quality and stream quality
+ * @param tvCount Indicates the number of structure returned in the fourth parameters, i.e., tvList.
+ * @param tvList Indicates the detailed information of data transmission.
+ * @since 1.0
+ * @version 1.0
+ */
+ void (*OnQosEvent)(int sessionId, int eventId, int tvCount, const QosTv *tvList);
+} ISessionListener;
+
+/**
+ * @brief 定义文件接收回调。
+ *
+ * 当接收文件时,将调用相关的回调。
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+typedef struct {
+ /**
+ * @brief 开始接收文件时调用.
+ *
+ * 此函数用于通知开始接收文件。
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * @param files 指示指向接收的文件的指针。
+ * @param fileCnt 指示接收的文件的个数。
+ * @return 如果开始接收文件,则返回 0;否则返回非零值。
+ * @since 1.0
+ * @version 1.0
+ */
+ int (*OnReceiveFileStarted)(int sessionId, const char *files, int fileCnt);
+
+ /**
+ * @brief 正在接收文件时调用.
+ *
+ * 此函数用于通知正在接收文件。
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * @param files 指示指向接收的第一个文件的指针。
+ * @param bytesUpload 指示当前已接收的文件大小。
+ * @param bytesTotal 指示拟接收的总文件大小。
+ * @return 如果正在接收文件,则返回 0;否则返回非零值。
+ * @since 1.0
+ * @version 1.0
+ */
+ int (*OnReceiveFileProcess)(int sessionId, const char *firstFile, uint64_t bytesUpload, uint64_t bytesTotal);
+
+ /**
+ * @brief 文件接收结束时调用.
+ *
+ * 此函数用于通知文件接收结束。
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * @param files 指示指向接收的文件的指针。
+ * @param fileCnt 指示接收的文件的个数。
+ * @since 1.0
+ * @version 1.0
+ */
+ void (*OnReceiveFileFinished)(int sessionId, const char *files, int fileCnt);
+
+ /**
+ * @brief 文件传输出错时调用.
+ *
+ * 此函数用于通知文件传输出错。
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * @since 1.0
+ * @version 1.0
+ */
+ void (*OnFileTransError)(int sessionId);
+} IFileReceiveListener;
+
+/**
+ * @brief 定义文件发送回调.
+ *
+ * 当发送文件时,将调用相关的回调。
+ *
+ * @since 1.0
+ * @version 1.0
+ */
+typedef struct {
+ /**
+ * @brief 正在发送文件时调用.
+ *
+ * 此函数用于通知正在发送文件。
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * @param bytesUpload 指示当前已发送的文件大小。
+ * @param bytesTotal 指示拟发送的总文件大小。
+ * @return 如果正在发送文件,则返回 0;否则返回非零值。
+ * @since 1.0
+ * @version 1.0
+ */
+ int (*OnSendFileProcess)(int sessionId, uint64_t bytesUpload, uint64_t bytesTotal);
+
+ /**
+ * @brief 文件接收结束时调用.
+ *
+ * 此函数用于通知文件发送结束。
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * @param firstFile 指示指向要发送的第一个文件的指针。
+ * @return 如果发送文件结束,则返回 0;否则返回非零值。
+ * @since 1.0
+ * @version 1.0
+ */
+ int (*OnSendFileFinished)(int sessionId, const char *firstFile);
+
+ /**
+ * @brief 文件传输出错时调用.
+ *
+ * 此函数用于通知文件传输出错。
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * @since 1.0
+ * @version 1.0
+ */
+ void (*OnFileTransError)(int sessionId);
+} IFileSendListener;
+
+/**
+ * @brief Creates a session server based on a package name and session name.
+ *
+ * A maximum of 8 session servers can be created.
+ *
+ * @param pkgName 指示指向业务包名的指针, 是上层业务的唯一标识。该值不能为空,最多可包含 64 个字符。
+ * @param sessionName Indicates the pointer to the session name, which is the unique ID of the session server.
+ * The value cannot be empty and can contain a maximum of 256 characters.
+ * @param listener Indicates the pointer to the session callback structure, which cannot be empty.
+ * The common error codes are as follows:
+ * @return Returns 0 if the operation is successful; returns -1 otherwise.
+ * @see RemoveSessionServer
+ * @since 1.0
+ * @version 1.0
+ */
+int CreateSessionServer(const char *pkgName, const char *sessionName, const ISessionListener *listener);
+
+/**
+ * @brief Removes a session server based on a package name and session name.
+ *
+ * @param pkgName 指示指向业务包名的指针, 是上层业务的唯一标识。该值不能为空,最多可包含 64 个字符。
+ * @param sessionName Indicates the pointer to the session name. The value cannot be empty and can contain
+ * a maximum of 256 characters.
+ * The common error codes are as follows:
+ * @return Returns 0 if the operation is successful, returns -1 otherwise.
+ * @see CreateSessionServer
+ * @since 1.0
+ * @version 1.0
+ */
+int RemoveSessionServer(const char *pkgName, const char *sessionName);
+
+/**
+ * @brief Initiate a session open request, which is an asynchronous process.
+ *
+ * The session connection is opened based on the service name to trigger the first packet interaction process.
+ * According to the {@link OnSessionOpened} Notify the user whether the session is successfully opened.
+ * Data can be transmitted only after the session is successfully opened.
+ *
+ * @param mySessionName local session name.
+ * @param peerSessionName remote session name.
+ * @param peerNetworkId remote device id.
+ * @param groupId 群组标识,自组网时可为空,手动组网时需要向HiChain申请有效的群组Id.
+ * @param attr session attribute {@link SessionAttribute}.
+ * The common error codes are as follows:
+ * @return SOFTBUS_TRANS_INVALID_PARAM invalid param.
+ * @return INVALID_SESSION_ID open session failed, and return invalid session id.
+ * @return return sessionId if the session is opened successfully,
+ * and the sessionId is greater than 0, returns other error codes otherwise.
+ * @since 1.0
+ * @version 1.0
+ */
+int OpenSession(const char *mySessionName, const char *peerSessionName, const char *peerNetworkId,
+ const char *groupId, const SessionAttribute* attr);
+
+/**
+ * @brief Closes a connected session based on a session ID.
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * @return no return value.
+ * @since 1.0
+ * @version 1.0
+ */
+void CloseSession(int sessionId);
+
+/**
+ * @example sendbytes_message_demo.c
+ */
+
+/**
+ * @brief Sends data based on a session ID.
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * @param data Indicates the pointer to the data to send, which cannot be NULL.
+ * @param len Indicates the length of the data to send. The maximum length cannot exceed 984 characters.
+ * The common error codes are as follows:
+ * @return Returns SOFTBUS_INVALID_PARAM param data or len of value is invalid.
+ * @return Returns SOFTBUS_TRANS_SEND_LEN_BEYOND_LIMIT The data length exceeds the maximum limit.
+ * @return Returns SOFTBUS_TRANS_INVALID_SESSION_ID invalid session id.
+ * @return Returns SOFTBUS_TRANS_SESSION_NO_ENABLE session is currently disable.
+ * @return Returns SOFTBUS_OK if the function is called successfully, return other errorcode otherwise.
+ * @since 1.0
+ * @version 1.0
+ */
+int SendBytes(int sessionId, const void *data, unsigned int len);
+
+/**
+ * @brief Sends message based on a session ID.
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * @param data Indicates the pointer to the message data to send, which cannot be NULL.
+ * @param len Indicates the length of the message to send.
+ * The common error codes are as follows:
+ * @return Returns SOFTBUS_INVALID_PARAM if the input data is NULL or len is Zero.
+ * @return Returns SOFTBUS_TRANS_SEND_LEN_BEYOND_LIMIT The data length exceeds the maximum limit.
+ * @return Returns SOFTBUS_INVALID_SESSION_ID if the sessionId is invalid.
+ * @return Returns SOFTBUS_TRANS_SESSION_NO_ENABLE if the session current be enabled.
+ * @return Returns SOFTBUS_OK if the function is called successfully, return other errorcode otherwise.
+ * @since 1.0
+ * @version 1.0
+ */
+int SendMessage(int sessionId, const void *data, unsigned int len);
+
+/**
+ * @example sendstream_demo.c
+ */
+
+/**
+ * @brief Sends stream based on a session ID.
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * @param data Indicates the pointer to the stream data to send, which cannot be NULL.
+ * @param ext Indicates the pointer to the ext stream data to send, which cannot be NULL.
+ * @param param Indicates the pointer to the stream data of param, which cannot be NULL.
+ * The common error codes are as follows:
+ * @return Returns SOFTBUS_INVALID_PARAM if the input param is NULL.
+ * @return Returns SOFTBUS_INVALID_SESSION_ID if the sessionId is invalid.
+ * @return Returns SOFTBUS_TRANS_SESSION_NO_ENABLE if the session current be enabled.
+ * @return Returns SOFTBUS_OK if the function is called successfully, return other errorcode otherwise.
+ * @since 1.0
+ * @version 1.0
+ */
+int SendStream(int sessionId, const StreamData *data, const StreamData *ext, const StreamFrameInfo *param);
+
+/**
+ * @example getsessioninfo_demo.c
+ */
+
+/**
+ * @brief Obtains the session name registered by the local device based on the session ID.
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * @param sessionName Indicates the pointer to the buffer for storing the session name.
+ * @param len Indicates the length of the buffer.
+ * The common error codes are as follows:
+ * @return Returns SOFTBUS_INVALID_PARAM Indicates invalid value for input param.
+ * @return Returns SOFTBUS_OK if the operation is successful, returns other error codes otherwise.
+ * @since 1.0
+ * @version 1.0
+ */
+int GetMySessionName(int sessionId, char *sessionName, unsigned int len);
+
+/**
+ * @brief Obtains the session name registered by the peer device based on the session ID.
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * @param sessionName Indicates the pointer to the buffer for storing the session name.
+ * @param len Indicates the length of the buffer.
+ * The common error codes are as follows:
+ * @return Returns SOFTBUS_INVALID_PARAM Indicates invalid value for input param.
+ * @return Returns SOFTBUS_OK if the operation is successful, returns other error codes otherwise.
+ * @since 1.0
+ * @version 1.0
+ */
+int GetPeerSessionName(int sessionId, char *sessionName, unsigned int len);
+
+/**
+ * @brief Obtains the peer device ID based on a session ID.
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * @param networkId Indicates the pointer to the buffer for storing the device ID.
+ * @param len Indicates the length of the buffer.
+ * The common error codes are as follows:
+ * @return Returns SOFTBUS_INVALID_PARAM Indicates invalid value for input param.
+ * @return Returns SOFTBUS_OK if the operation is successful, returns other error codes otherwise.
+ * @since 1.0
+ * @version 1.0
+ */
+int GetPeerDeviceId(int sessionId, char *networkId, unsigned int len);
+
+/**
+ * @brief Get session side based on a session ID.
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * @return Returns -1 Indicates get session side failed.
+ * @return Returns 0 Indicates the session is server side.
+ * @return Returns 1 Indicates the session is client side.
+ * @since 1.0
+ * @version 1.0
+ */
+int GetSessionSide(int sessionId);
+
+/**
+ * @brief Set file receive listener.
+ *
+ * @param pkgName Indicates the pointer to the name of the registered package, which can be used to check
+ * whether the session server is in this package. The value cannot be empty and can contain a maximum of 64 characters.
+ * @param sessionName Indicates the pointer to the buffer for storing the session name.
+ * @param recvListener Indicates the pointer to the file receive listener, which cannot be NULL.
+ * @param rootDir 指示指向文件存储的根路径的指针,长度不超过256位。
+ * The common error codes are as follows:
+ * @return Returns SOFTBUS_INVALID_PARAM Indicates invalid value for input param.
+ * @return Returns SOFTBUS_TRANS_SESSION_ADDPKG_FAILED if add pkgName failed.
+ * @return Returns SOFTBUS_OKif the function is called successfully, return other errorcodes otherwise.
+ * @since 1.0
+ * @version 1.0
+ */
+int SetFileReceiveListener(const char *pkgName, const char *sessionName,
+ const IFileReceiveListener *recvListener, const char *rootDir);
+
+/**
+ * @brief Set file sendListener based on pkgName and sessionName .
+ *
+ * @param pkgName 指示指向业务包名的指针, 是上层业务的唯一标识。该值不能为空,最多可包含 64 个字符。
+ * @param sessionName Indicates the pointer to the buffer for storing the session name.
+ * @param sendListener Indicates the pointer to the file send listener, which cannot be NULL.
+ * The common error codes are as follows:
+ * @return Returns SOFTBUS_INVALID_PARAM if the input param is invalid.
+ * @return Returns SOFTBUS_TRANS_SESSION_ADDPKG_FAILED if add pkgName failed.
+ * @return Returns SOFTBUS_OKif the function is called successfully, return other errorcodes otherwise.
+ * @since 1.0
+ * @version 1.0
+ */
+int SetFileSendListener(const char *pkgName, const char *sessionName, const IFileSendListener *sendListener);
+
+/**
+ * @example sendfile_demo.c
+ */
+
+/**
+ * @brief Sends file based on a session ID.
+ *
+ * @param sessionId 指示会话的唯一标识。
+ * @param sFileList Indicates the pointer to the source file list to send, which cannot be NULL.
+ * @param dFileList Indicates the pointer to the destination file list to send, which cannot be NULL.
+ * @param fileCnt Indicates the number of files to send, whic cannot be 0.
+ * The common error codes are as follows:
+ * @return Returns SOFTBUS_INVALID_PARAM if the sFileList is NULL or fileCnt is Zero.
+ * @return Returns SOFTBUS_INVALID_SESSION_ID if the sessionId is invalid.
+ * @return Returns SOFTBUS_TRANS_SESSION_NO_ENABLE if the session current be enabled.
+ * @return Returns SOFTBUS_OKif the function is called successfully, return other errorcodes otherwise.
+ * @since 1.0
+ * @version 1.0
+ */
+int SendFile(int sessionId, const char *sFileList[], const char *dFileList[], uint32_t fileCnt);
+
+#ifdef __cplusplus
+}
+#endif
+#endif // SESSION_H