1060ff233Sopenharmony_ci/* 2060ff233Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 3060ff233Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4060ff233Sopenharmony_ci * you may not use this file except in compliance with the License. 5060ff233Sopenharmony_ci * You may obtain a copy of the License at 6060ff233Sopenharmony_ci * 7060ff233Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8060ff233Sopenharmony_ci * 9060ff233Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10060ff233Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11060ff233Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12060ff233Sopenharmony_ci * See the License for the specific language governing permissions and 13060ff233Sopenharmony_ci * limitations under the License. 14060ff233Sopenharmony_ci */ 15060ff233Sopenharmony_ci 16060ff233Sopenharmony_ci/** 17060ff233Sopenharmony_ci * @addtogroup SoftBus 18060ff233Sopenharmony_ci * @{ 19060ff233Sopenharmony_ci * 20060ff233Sopenharmony_ci * @brief Provides high-speed, secure communications between devices. 21060ff233Sopenharmony_ci * 22060ff233Sopenharmony_ci * This module implements unified distributed communication management of 23060ff233Sopenharmony_ci * nearby devices, and provides link-independent device discovery and transmission interfaces 24060ff233Sopenharmony_ci * to support service publishing and data transmission. 25060ff233Sopenharmony_ci * 26060ff233Sopenharmony_ci * @since 1.0 27060ff233Sopenharmony_ci * @version 1.0 28060ff233Sopenharmony_ci*/ 29060ff233Sopenharmony_ci 30060ff233Sopenharmony_ci/** 31060ff233Sopenharmony_ci * @file session.h 32060ff233Sopenharmony_ci * 33060ff233Sopenharmony_ci * @brief Declares unified data transmission interfaces. 34060ff233Sopenharmony_ci * 35060ff233Sopenharmony_ci * This file provides data transmission capabilities, including creating and removing a session server, 36060ff233Sopenharmony_ci * opening and closing sessions, receiving data, and querying basic session information. \n 37060ff233Sopenharmony_ci * You can use the interfaces to transmit data across the nearby devices that are discovered and networked. 38060ff233Sopenharmony_ci * \n 39060ff233Sopenharmony_ci * 40060ff233Sopenharmony_ci * @since 1.0 41060ff233Sopenharmony_ci * @version 1.0 42060ff233Sopenharmony_ci */ 43060ff233Sopenharmony_ci#ifndef SESSION_H 44060ff233Sopenharmony_ci#define SESSION_H 45060ff233Sopenharmony_ci 46060ff233Sopenharmony_ci#include <stdint.h> 47060ff233Sopenharmony_ci 48060ff233Sopenharmony_ci#include "trans_type.h" 49060ff233Sopenharmony_ci 50060ff233Sopenharmony_ci#ifdef __cplusplus 51060ff233Sopenharmony_ciextern "C" { 52060ff233Sopenharmony_ci#endif 53060ff233Sopenharmony_ci 54060ff233Sopenharmony_ci/** 55060ff233Sopenharmony_ci * @brief Enumerates the session types. 56060ff233Sopenharmony_ci * 57060ff233Sopenharmony_ci * @since 1.0 58060ff233Sopenharmony_ci * @version 1.0 59060ff233Sopenharmony_ci */ 60060ff233Sopenharmony_citypedef enum { 61060ff233Sopenharmony_ci TYPE_MESSAGE = 1, /**< Message */ 62060ff233Sopenharmony_ci TYPE_BYTES, /**< Bytes */ 63060ff233Sopenharmony_ci TYPE_FILE, /**< File */ 64060ff233Sopenharmony_ci TYPE_STREAM, /**< Stream */ 65060ff233Sopenharmony_ci TYPE_BUTT, 66060ff233Sopenharmony_ci} SessionType; 67060ff233Sopenharmony_ci 68060ff233Sopenharmony_ci/** 69060ff233Sopenharmony_ci * @brief Enumerates the stream types. 70060ff233Sopenharmony_ci * 71060ff233Sopenharmony_ci * @since 1.0 72060ff233Sopenharmony_ci * @version 1.0 73060ff233Sopenharmony_ci */ 74060ff233Sopenharmony_citypedef enum { 75060ff233Sopenharmony_ci INVALID = -1, /**< Invalid stream type. */ 76060ff233Sopenharmony_ci RAW_STREAM, /**< Send any segment of a frame each time. */ 77060ff233Sopenharmony_ci COMMON_VIDEO_STREAM, /**< Send a whole video frame each time. */ 78060ff233Sopenharmony_ci COMMON_AUDIO_STREAM, /**< Send a whole audio frame each time. */ 79060ff233Sopenharmony_ci VIDEO_SLICE_STREAM, /**< Slice frame mode. */ 80060ff233Sopenharmony_ci} StreamType; 81060ff233Sopenharmony_ci 82060ff233Sopenharmony_ci/** 83060ff233Sopenharmony_ci * @brief Enumerates the link types. 84060ff233Sopenharmony_ci * 85060ff233Sopenharmony_ci * @since 1.0 86060ff233Sopenharmony_ci * @version 1.0 87060ff233Sopenharmony_ci */ 88060ff233Sopenharmony_citypedef enum { 89060ff233Sopenharmony_ci LINK_TYPE_WIFI_WLAN_5G = 1, /**< 5 GHz Wi-Fi link */ 90060ff233Sopenharmony_ci LINK_TYPE_WIFI_WLAN_2G = 2, /**< 2.4 GHz Wi-Fi link */ 91060ff233Sopenharmony_ci LINK_TYPE_WIFI_P2P = 3, /**< P2P link */ 92060ff233Sopenharmony_ci LINK_TYPE_BR = 4, /**< BR link */ 93060ff233Sopenharmony_ci LINK_TYPE_BLE = 5, 94060ff233Sopenharmony_ci LINK_TYPE_WIFI_P2P_REUSE = 6, 95060ff233Sopenharmony_ci LINK_TYPE_BLE_DIRECT = 7, 96060ff233Sopenharmony_ci LINK_TYPE_COC = 8, 97060ff233Sopenharmony_ci LINK_TYPE_COC_DIRECT = 9, 98060ff233Sopenharmony_ci LINK_TYPE_MAX = 9, 99060ff233Sopenharmony_ci} LinkType; 100060ff233Sopenharmony_ci 101060ff233Sopenharmony_ci/** 102060ff233Sopenharmony_ci * @brief Defines the session attributes. 103060ff233Sopenharmony_ci * 104060ff233Sopenharmony_ci * @since 1.0 105060ff233Sopenharmony_ci * @version 1.0 106060ff233Sopenharmony_ci */ 107060ff233Sopenharmony_citypedef struct { 108060ff233Sopenharmony_ci int dataType; /**< Session type {@link SessionType} */ 109060ff233Sopenharmony_ci int linkTypeNum; /**< Number of link types */ 110060ff233Sopenharmony_ci LinkType linkType[LINK_TYPE_MAX]; /**< Link type {@link LinkType} */ 111060ff233Sopenharmony_ci /** 112060ff233Sopenharmony_ci * @brief Defines the attributes. 113060ff233Sopenharmony_ci * 114060ff233Sopenharmony_ci * @since 1.0 115060ff233Sopenharmony_ci * @version 1.0 116060ff233Sopenharmony_ci */ 117060ff233Sopenharmony_ci union { 118060ff233Sopenharmony_ci /** 119060ff233Sopenharmony_ci * @brief Defines the stream attributes. 120060ff233Sopenharmony_ci * 121060ff233Sopenharmony_ci * @since 1.0 122060ff233Sopenharmony_ci * @version 1.0 123060ff233Sopenharmony_ci */ 124060ff233Sopenharmony_ci struct StreamAttr { 125060ff233Sopenharmony_ci int streamType; /**< Stream type {@link StreamType} */ 126060ff233Sopenharmony_ci } streamAttr; 127060ff233Sopenharmony_ci } attr; 128060ff233Sopenharmony_ci uint8_t *fastTransData; 129060ff233Sopenharmony_ci uint16_t fastTransDataSize; 130060ff233Sopenharmony_ci} SessionAttribute; 131060ff233Sopenharmony_ci 132060ff233Sopenharmony_ci/** 133060ff233Sopenharmony_ci * @brief Enumerates the quality of service (QoS) types. 134060ff233Sopenharmony_ci * 135060ff233Sopenharmony_ci * @since 1.0 136060ff233Sopenharmony_ci * @version 1.0 137060ff233Sopenharmony_ci */ 138060ff233Sopenharmony_citypedef enum { 139060ff233Sopenharmony_ci QOS_IMPROVE = 0, /**< Improve QoS */ 140060ff233Sopenharmony_ci QOS_RECOVER = 1, /**< Recover QoS */ 141060ff233Sopenharmony_ci} QosQuality; 142060ff233Sopenharmony_ci 143060ff233Sopenharmony_ci/** 144060ff233Sopenharmony_ci * @brief Enumerates the QoS feedback types. 145060ff233Sopenharmony_ci * 146060ff233Sopenharmony_ci * @since 1.0 147060ff233Sopenharmony_ci * @version 1.0 148060ff233Sopenharmony_ci */ 149060ff233Sopenharmony_citypedef enum { 150060ff233Sopenharmony_ci TRANS_STREAM_QUALITY_EVENT = 1, /**< Feedback on stream transmission quality */ 151060ff233Sopenharmony_ci TRANS_CHANNEL_QUALITY_EVENT, /**< Feedback on transmission channel quality */ 152060ff233Sopenharmony_ci TRANS_CAN_DELAY_EVENT, /**< Feedback on deferrable transmission */ 153060ff233Sopenharmony_ci TRANS_CANT_DELAY_EVENT, /**< Feedback on non-deferrable transmission */ 154060ff233Sopenharmony_ci QOS_EVENT_MAX /**< Invalid feedback */ 155060ff233Sopenharmony_ci} QosEvent; 156060ff233Sopenharmony_ci 157060ff233Sopenharmony_ci/** 158060ff233Sopenharmony_ci * @brief Enumerates the stream transmission QoS event types. 159060ff233Sopenharmony_ci * 160060ff233Sopenharmony_ci * @since 1.0 161060ff233Sopenharmony_ci * @version 1.0 162060ff233Sopenharmony_ci */ 163060ff233Sopenharmony_citypedef enum { 164060ff233Sopenharmony_ci WIFI_CHANNEL_QUALITY = 1, /**< Wi-Fi channel quality */ 165060ff233Sopenharmony_ci FRAME_REALTIME_STATUS = 2, /**< Real-time status of frame transmission */ 166060ff233Sopenharmony_ci BANDWIDTH_ESTIMATE_VALUE = 3, /**< Bandwidth estimation */ 167060ff233Sopenharmony_ci JITTER_DETECTION_VALUE = 4, /**< Jitter detection */ 168060ff233Sopenharmony_ci STREAM_TRAFFIC_STASTICS = 5, /**< Stream traffic statistics */ 169060ff233Sopenharmony_ci} TransEnumEventType; 170060ff233Sopenharmony_ci 171060ff233Sopenharmony_ci/** 172060ff233Sopenharmony_ci * @brief Defines the Wi-Fi channel quality. 173060ff233Sopenharmony_ci * 174060ff233Sopenharmony_ci * @since 1.0 175060ff233Sopenharmony_ci * @version 1.0 176060ff233Sopenharmony_ci */ 177060ff233Sopenharmony_citypedef struct { 178060ff233Sopenharmony_ci int32_t channel; /**< Wi-Fi channel */ 179060ff233Sopenharmony_ci int32_t score; /**< Wi-Fi channel score */ 180060ff233Sopenharmony_ci} WifiChannelQuality; 181060ff233Sopenharmony_ci 182060ff233Sopenharmony_ci/** 183060ff233Sopenharmony_ci * @brief Defines the frame information. 184060ff233Sopenharmony_ci * 185060ff233Sopenharmony_ci * @since 1.0 186060ff233Sopenharmony_ci * @version 1.0 187060ff233Sopenharmony_ci */ 188060ff233Sopenharmony_citypedef struct { 189060ff233Sopenharmony_ci int32_t streamId; /**< Stream ID */ 190060ff233Sopenharmony_ci int32_t seqNum; /**< Sequence number of the frame */ 191060ff233Sopenharmony_ci int32_t level; /**< Frame layer number */ 192060ff233Sopenharmony_ci int32_t transStatus; /**< Frame status */ 193060ff233Sopenharmony_ci int32_t interval; /**< Duration that unsent frames in the queue are cached */ 194060ff233Sopenharmony_ci} FrameStatus; 195060ff233Sopenharmony_ci 196060ff233Sopenharmony_ci/** 197060ff233Sopenharmony_ci * @brief Defines the bandwidth detection information. 198060ff233Sopenharmony_ci * 199060ff233Sopenharmony_ci * @since 1.0 200060ff233Sopenharmony_ci * @version 1.0 201060ff233Sopenharmony_ci */ 202060ff233Sopenharmony_citypedef struct { 203060ff233Sopenharmony_ci uint32_t trend; /**< Bandwidth change trend */ 204060ff233Sopenharmony_ci uint32_t rate; /**< Bandwidth rate */ 205060ff233Sopenharmony_ci} BandwidthDetection; 206060ff233Sopenharmony_ci 207060ff233Sopenharmony_ci/** 208060ff233Sopenharmony_ci * @brief Defines the jitter estimation information. 209060ff233Sopenharmony_ci * 210060ff233Sopenharmony_ci * @since 1.0 211060ff233Sopenharmony_ci * @version 1.0 212060ff233Sopenharmony_ci */ 213060ff233Sopenharmony_citypedef struct { 214060ff233Sopenharmony_ci int32_t jitterLevel; /**< Estimated network status */ 215060ff233Sopenharmony_ci uint32_t bufferTime; /**< Required buffer time */ 216060ff233Sopenharmony_ci} JitterEstimation; 217060ff233Sopenharmony_ci 218060ff233Sopenharmony_ci/** 219060ff233Sopenharmony_ci * @brief Defines the stream transmission statistics information. 220060ff233Sopenharmony_ci * 221060ff233Sopenharmony_ci * @since 1.0 222060ff233Sopenharmony_ci * @version 1.0 223060ff233Sopenharmony_ci */ 224060ff233Sopenharmony_citypedef struct { 225060ff233Sopenharmony_ci uint64_t statisticsGotTime; /**< Time when the statistics information is obtained */ 226060ff233Sopenharmony_ci uint64_t periodRecvBits; /**< Number of bits received in a transmission period */ 227060ff233Sopenharmony_ci uint32_t pktNum; /**< Number of packets */ 228060ff233Sopenharmony_ci uint32_t periodRecvPkts; /**< Number of packets received in a transmission period */ 229060ff233Sopenharmony_ci uint32_t periodRecvPktLoss; /**< Number of RX packets lost in a transmission period */ 230060ff233Sopenharmony_ci uint32_t periodRecvRate; /**< Receive rate in a transmission period, in kbit/s */ 231060ff233Sopenharmony_ci uint64_t periodRecvRateBps; /**< RX rate in a transmission period, in bit/s */ 232060ff233Sopenharmony_ci uint32_t periodRtt; /**< Round-trip time (RTT), in ms */ 233060ff233Sopenharmony_ci 234060ff233Sopenharmony_ci /**< RX packet loss rate displayed for high precision. 235060ff233Sopenharmony_ci For example, if the packet loss rate is 1.10%, the value is <b>110</b>. */ 236060ff233Sopenharmony_ci uint32_t periodRecvPktLossHighPrecision; 237060ff233Sopenharmony_ci uint32_t periodSendLostPkts; /**< Number of TX packets lost in a transmission period */ 238060ff233Sopenharmony_ci uint32_t periodSendPkts; /**< Number of packets sent in a transmission period */ 239060ff233Sopenharmony_ci 240060ff233Sopenharmony_ci /**< TX packet loss rate displayed for high precision. 241060ff233Sopenharmony_ci For example, if the packet loss rate is 1.10%, the value is <b>110</b>. */ 242060ff233Sopenharmony_ci uint32_t periodSendPktLossHighPrecision; 243060ff233Sopenharmony_ci uint64_t periodSendBits; /**< Number of bits sent in a transmission period */ 244060ff233Sopenharmony_ci uint64_t periodSendRateBps; /**< TX rate in a transmission period, in bps */ 245060ff233Sopenharmony_ci} StreamStatistics; 246060ff233Sopenharmony_ci 247060ff233Sopenharmony_ci/** 248060ff233Sopenharmony_ci * @brief Defines the video stream transmission QoS. 249060ff233Sopenharmony_ci * 250060ff233Sopenharmony_ci * @since 1.0 251060ff233Sopenharmony_ci * @version 1.0 252060ff233Sopenharmony_ci */ 253060ff233Sopenharmony_citypedef struct { 254060ff233Sopenharmony_ci TransEnumEventType type; /**< Stream transmission QoS event type {@link TransEnumEventType} */ 255060ff233Sopenharmony_ci union { 256060ff233Sopenharmony_ci WifiChannelQuality wifiChannelInfo; /**< Wi-Fi channel quality {@link WifiChannelQuality} */ 257060ff233Sopenharmony_ci FrameStatus frameStatusInfo; /**< Frame information {@link FrameStatus} */ 258060ff233Sopenharmony_ci BandwidthDetection bandwidthInfo; /**< Bandwidth detection {@link BandwidthDetection} */ 259060ff233Sopenharmony_ci JitterEstimation jitterInfo; /**< Network jitter estimation {@link JitterEstimation} */ 260060ff233Sopenharmony_ci StreamStatistics appStatistics; /**< Stream transmission statistics {@link StreamStatistics} */ 261060ff233Sopenharmony_ci } info; 262060ff233Sopenharmony_ci} QosTv; 263060ff233Sopenharmony_ci 264060ff233Sopenharmony_citypedef enum { 265060ff233Sopenharmony_ci SESSION_OPTION_MAX_SENDBYTES_SIZE = 0, /**< Value type of this option is uint32_t, this option only can be get */ 266060ff233Sopenharmony_ci SESSION_OPTION_MAX_SENDMESSAGE_SIZE, /**< Value type of this option is uint32_t, this option only can be get */ 267060ff233Sopenharmony_ci SESSION_OPTION_LINK_TYPE, /**< Value type of this option is int32_t, this option only can be get */ 268060ff233Sopenharmony_ci 269060ff233Sopenharmony_ci SESSION_OPTION_BUTT, 270060ff233Sopenharmony_ci} SessionOption; 271060ff233Sopenharmony_ci 272060ff233Sopenharmony_ci/** 273060ff233Sopenharmony_ci * @brief Defines session callbacks. 274060ff233Sopenharmony_ci * 275060ff233Sopenharmony_ci * When a session is opened or closed, or there is data to process, the related callback is invoked. 276060ff233Sopenharmony_ci * 277060ff233Sopenharmony_ci * @since 1.0 278060ff233Sopenharmony_ci * @version 1.0 279060ff233Sopenharmony_ci */ 280060ff233Sopenharmony_citypedef struct { 281060ff233Sopenharmony_ci /** 282060ff233Sopenharmony_ci * @brief Called when a session is opened. 283060ff233Sopenharmony_ci * 284060ff233Sopenharmony_ci * This callback is invoked to verify the session or initialize resources related to the session. 285060ff233Sopenharmony_ci * 286060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID. 287060ff233Sopenharmony_ci * @param result Indicates the result to return. 288060ff233Sopenharmony_ci * @return Returns <b>0</b> if the session is set up; returns a non-zero value 289060ff233Sopenharmony_ci * otherwise. You do not need to call {@link CloseSession} to close the session. 290060ff233Sopenharmony_ci * @since 1.0 291060ff233Sopenharmony_ci * @version 1.0 292060ff233Sopenharmony_ci */ 293060ff233Sopenharmony_ci int (*OnSessionOpened)(int sessionId, int result); 294060ff233Sopenharmony_ci 295060ff233Sopenharmony_ci /** 296060ff233Sopenharmony_ci * @brief Called when a session is closed. 297060ff233Sopenharmony_ci * 298060ff233Sopenharmony_ci * This callback is invoked to release resources related to the session. 299060ff233Sopenharmony_ci * You do not need to call {@link CloseSession}. 300060ff233Sopenharmony_ci * 301060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID. 302060ff233Sopenharmony_ci * @since 1.0 303060ff233Sopenharmony_ci * @version 1.0 304060ff233Sopenharmony_ci */ 305060ff233Sopenharmony_ci void (*OnSessionClosed)(int sessionId); 306060ff233Sopenharmony_ci 307060ff233Sopenharmony_ci /** 308060ff233Sopenharmony_ci * @brief Called when data is received. 309060ff233Sopenharmony_ci * 310060ff233Sopenharmony_ci * This callback is invoked to notify that data is received. 311060ff233Sopenharmony_ci * 312060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID. 313060ff233Sopenharmony_ci * @param data Indicates the pointer to the data received. 314060ff233Sopenharmony_ci * User-defined data type, users should apply for memory by themselves. 315060ff233Sopenharmony_ci * @param dataLen Indicates the length of the data received. 316060ff233Sopenharmony_ci * @since 1.0 317060ff233Sopenharmony_ci * @version 1.0 318060ff233Sopenharmony_ci */ 319060ff233Sopenharmony_ci void (*OnBytesReceived)(int sessionId, const void *data, unsigned int dataLen); 320060ff233Sopenharmony_ci 321060ff233Sopenharmony_ci /** 322060ff233Sopenharmony_ci * @brief Called when a message is received. 323060ff233Sopenharmony_ci * 324060ff233Sopenharmony_ci * This callback is invoked to notify that a message is received. 325060ff233Sopenharmony_ci * 326060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID. 327060ff233Sopenharmony_ci * @param data Indicates the pointer to the message received. 328060ff233Sopenharmony_ci * @param dataLen Indicates the length of the message received. 329060ff233Sopenharmony_ci * @since 1.0 330060ff233Sopenharmony_ci * @version 1.0 331060ff233Sopenharmony_ci */ 332060ff233Sopenharmony_ci void (*OnMessageReceived)(int sessionId, const void *data, unsigned int dataLen); 333060ff233Sopenharmony_ci 334060ff233Sopenharmony_ci /** 335060ff233Sopenharmony_ci * @brief Called when stream data is received. 336060ff233Sopenharmony_ci * 337060ff233Sopenharmony_ci * This callback is invoked to notify that stream data is received. 338060ff233Sopenharmony_ci * 339060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID. 340060ff233Sopenharmony_ci * @param data Indicates the pointer to the stream data received. 341060ff233Sopenharmony_ci * @param ext Indicates the pointer to the extended service data received. 342060ff233Sopenharmony_ci * @param param Indicates the pointer to the stream data frame information. 343060ff233Sopenharmony_ci * @since 1.0 344060ff233Sopenharmony_ci * @version 1.0 345060ff233Sopenharmony_ci */ 346060ff233Sopenharmony_ci void (*OnStreamReceived)(int sessionId, const StreamData *data, const StreamData *ext, 347060ff233Sopenharmony_ci const StreamFrameInfo *param); 348060ff233Sopenharmony_ci 349060ff233Sopenharmony_ci /** 350060ff233Sopenharmony_ci * @brief Called when QoS information is retrieved. 351060ff233Sopenharmony_ci * 352060ff233Sopenharmony_ci * This callback is invoked to notify that QoS information is retrieved. 353060ff233Sopenharmony_ci * 354060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID. 355060ff233Sopenharmony_ci * @param eventId Indicates the type of QoS information, such as the channel quality and stream quality. 356060ff233Sopenharmony_ci * @param tvCount Indicates the number of TVs returned in the fourth parameter <b>tvList</b>. 357060ff233Sopenharmony_ci * @param tvList Indicates the pointer to the TV list. 358060ff233Sopenharmony_ci * @since 1.0 359060ff233Sopenharmony_ci * @version 1.0 360060ff233Sopenharmony_ci */ 361060ff233Sopenharmony_ci void (*OnQosEvent)(int sessionId, int eventId, int tvCount, const QosTv *tvList); 362060ff233Sopenharmony_ci} ISessionListener; 363060ff233Sopenharmony_ci 364060ff233Sopenharmony_ci/** 365060ff233Sopenharmony_ci * @brief Defines the callbacks for file receiving. 366060ff233Sopenharmony_ci * 367060ff233Sopenharmony_ci * The callbacks are invoked to notify the file receiving status. 368060ff233Sopenharmony_ci * 369060ff233Sopenharmony_ci * @since 1.0 370060ff233Sopenharmony_ci * @version 1.0 371060ff233Sopenharmony_ci */ 372060ff233Sopenharmony_citypedef struct { 373060ff233Sopenharmony_ci /** 374060ff233Sopenharmony_ci * @brief Called when a file starts to be received. 375060ff233Sopenharmony_ci * 376060ff233Sopenharmony_ci * This callback is invoked to notify the start of file receiving. 377060ff233Sopenharmony_ci * 378060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID. 379060ff233Sopenharmony_ci * @param files Indicates the pointer to the files to receive. 380060ff233Sopenharmony_ci * @param fileCnt Indicates the number of files to receive. 381060ff233Sopenharmony_ci * @return Returns <b>0</b> if the file receiving starts; returns a non-zero value otherwise. 382060ff233Sopenharmony_ci * @since 1.0 383060ff233Sopenharmony_ci * @version 1.0 384060ff233Sopenharmony_ci */ 385060ff233Sopenharmony_ci int (*OnReceiveFileStarted)(int sessionId, const char *files, int fileCnt); 386060ff233Sopenharmony_ci 387060ff233Sopenharmony_ci /** 388060ff233Sopenharmony_ci * @brief Called when a file is being received. 389060ff233Sopenharmony_ci * 390060ff233Sopenharmony_ci * This callback is invoked to notify that a file is being received. 391060ff233Sopenharmony_ci * 392060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID. 393060ff233Sopenharmony_ci * @param files Indicates the pointer to the first file received. 394060ff233Sopenharmony_ci * @param bytesUpload Indicates the size of the files received. 395060ff233Sopenharmony_ci * @param bytesTotal Indicates the total size of the files to receive, in bytes. 396060ff233Sopenharmony_ci * @return Returns <b>0</b> if a file is being received; returns a non-zero value otherwise. 397060ff233Sopenharmony_ci * @since 1.0 398060ff233Sopenharmony_ci * @version 1.0 399060ff233Sopenharmony_ci */ 400060ff233Sopenharmony_ci int (*OnReceiveFileProcess)(int sessionId, const char *firstFile, uint64_t bytesUpload, uint64_t bytesTotal); 401060ff233Sopenharmony_ci 402060ff233Sopenharmony_ci /** 403060ff233Sopenharmony_ci * @brief Called when the file receiving ends. 404060ff233Sopenharmony_ci * 405060ff233Sopenharmony_ci * This callback is invoked to notify the end of file receiving. 406060ff233Sopenharmony_ci * 407060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID. 408060ff233Sopenharmony_ci * @param files Indicates the pointer to the files received. 409060ff233Sopenharmony_ci * @param fileCnt Indicates the number of files received. 410060ff233Sopenharmony_ci * @since 1.0 411060ff233Sopenharmony_ci * @version 1.0 412060ff233Sopenharmony_ci */ 413060ff233Sopenharmony_ci void (*OnReceiveFileFinished)(int sessionId, const char *files, int fileCnt); 414060ff233Sopenharmony_ci 415060ff233Sopenharmony_ci /** 416060ff233Sopenharmony_ci * @brief Called when an error occurs during the file receiving process. 417060ff233Sopenharmony_ci * 418060ff233Sopenharmony_ci * This callback is invoked to notify a file receiving error. 419060ff233Sopenharmony_ci * 420060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID. 421060ff233Sopenharmony_ci * @since 1.0 422060ff233Sopenharmony_ci * @version 1.0 423060ff233Sopenharmony_ci */ 424060ff233Sopenharmony_ci void (*OnFileTransError)(int sessionId); 425060ff233Sopenharmony_ci} IFileReceiveListener; 426060ff233Sopenharmony_ci 427060ff233Sopenharmony_ci/** 428060ff233Sopenharmony_ci * @brief Defines callbacks for file sending. 429060ff233Sopenharmony_ci * 430060ff233Sopenharmony_ci * The callbacks are invoked to notify the file sending status. 431060ff233Sopenharmony_ci * 432060ff233Sopenharmony_ci * @since 1.0 433060ff233Sopenharmony_ci * @version 1.0 434060ff233Sopenharmony_ci */ 435060ff233Sopenharmony_citypedef struct { 436060ff233Sopenharmony_ci /** 437060ff233Sopenharmony_ci * @brief Called when a file is being sent. 438060ff233Sopenharmony_ci * 439060ff233Sopenharmony_ci * This callback is invoked to notify that a file is being sent. 440060ff233Sopenharmony_ci * 441060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID. 442060ff233Sopenharmony_ci * @param bytesUpload Indicates the size of the file sent, in bytes. 443060ff233Sopenharmony_ci * @param bytesTotal Indicates the total size of the file to send, in bytes. 444060ff233Sopenharmony_ci * @return Returns <b>0</b> if the file is being sent; returns a non-zero value otherwise. 445060ff233Sopenharmony_ci * @since 1.0 446060ff233Sopenharmony_ci * @version 1.0 447060ff233Sopenharmony_ci */ 448060ff233Sopenharmony_ci int (*OnSendFileProcess)(int sessionId, uint64_t bytesUpload, uint64_t bytesTotal); 449060ff233Sopenharmony_ci 450060ff233Sopenharmony_ci /** 451060ff233Sopenharmony_ci * @brief Called when the file sending ends. 452060ff233Sopenharmony_ci * 453060ff233Sopenharmony_ci * This callback is invoked to notify the end of file sending. 454060ff233Sopenharmony_ci * 455060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID. 456060ff233Sopenharmony_ci * @param firstFile Indicates the pointer to the first file to send. 457060ff233Sopenharmony_ci * @return Returns<b>0</b> if the file sending is complete; returns a non-zero value otherwise. 458060ff233Sopenharmony_ci * @since 1.0 459060ff233Sopenharmony_ci * @version 1.0 460060ff233Sopenharmony_ci */ 461060ff233Sopenharmony_ci int (*OnSendFileFinished)(int sessionId, const char *firstFile); 462060ff233Sopenharmony_ci 463060ff233Sopenharmony_ci /** 464060ff233Sopenharmony_ci * @brief Called when an error occurs during the file sending process. 465060ff233Sopenharmony_ci * 466060ff233Sopenharmony_ci * This callback is invoked to notify a file sending error. 467060ff233Sopenharmony_ci * 468060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID. 469060ff233Sopenharmony_ci * @since 1.0 470060ff233Sopenharmony_ci * @version 1.0 471060ff233Sopenharmony_ci */ 472060ff233Sopenharmony_ci void (*OnFileTransError)(int sessionId); 473060ff233Sopenharmony_ci} IFileSendListener; 474060ff233Sopenharmony_ci 475060ff233Sopenharmony_ci/** 476060ff233Sopenharmony_ci * @brief Creates a session server. 477060ff233Sopenharmony_ci * 478060ff233Sopenharmony_ci * A maximum of 32 session servers can be created. 479060ff233Sopenharmony_ci * 480060ff233Sopenharmony_ci * @param pkgName Indicates the pointer to the service bundle name. 481060ff233Sopenharmony_ci * It is the unique identifier of the upper-layer service. The value cannot be empty or exceed 64 characters. 482060ff233Sopenharmony_ci * @param sessionName Indicates the pointer to the session name, which is the unique ID of the session server. 483060ff233Sopenharmony_ci * The value cannot be empty or exceed 255 characters. 484060ff233Sopenharmony_ci * @param listener Indicates the pointer to the session callback, which cannot be empty. 485060ff233Sopenharmony_ci * 486060ff233Sopenharmony_ci * @return Returns <b>0</b> if the operation is successful; returns <b>-1</b> otherwise. 487060ff233Sopenharmony_ci * @see RemoveSessionServer 488060ff233Sopenharmony_ci * @since 1.0 489060ff233Sopenharmony_ci * @version 1.0 490060ff233Sopenharmony_ci */ 491060ff233Sopenharmony_ciint CreateSessionServer(const char *pkgName, const char *sessionName, const ISessionListener *listener); 492060ff233Sopenharmony_ci 493060ff233Sopenharmony_ci/** 494060ff233Sopenharmony_ci * @brief Removes a session server. 495060ff233Sopenharmony_ci * 496060ff233Sopenharmony_ci * @param pkgName Indicates the pointer to the service bundle name. 497060ff233Sopenharmony_ci * It is the unique identifier of the upper-layer service. The value cannot be empty or exceed 64 characters. 498060ff233Sopenharmony_ci * @param sessionName Indicates the pointer to the session name. The value cannot be empty or exceed 255 characters. 499060ff233Sopenharmony_ci * 500060ff233Sopenharmony_ci * @return Returns <b>0</b> if the operation is successful, returns <b>-1</b> otherwise. 501060ff233Sopenharmony_ci * @see CreateSessionServer 502060ff233Sopenharmony_ci * @since 1.0 503060ff233Sopenharmony_ci * @version 1.0 504060ff233Sopenharmony_ci */ 505060ff233Sopenharmony_ciint RemoveSessionServer(const char *pkgName, const char *sessionName); 506060ff233Sopenharmony_ci 507060ff233Sopenharmony_ci/** 508060ff233Sopenharmony_ci * @brief Opens a session, which is an asynchronous process. 509060ff233Sopenharmony_ci * 510060ff233Sopenharmony_ci * The session is opened to trigger the first packet interaction process. 511060ff233Sopenharmony_ci * {@link OnSessionOpened} is invoked to return whether the session is successfully opened. 512060ff233Sopenharmony_ci * Data can be transmitted only after the session is successfully opened. 513060ff233Sopenharmony_ci * 514060ff233Sopenharmony_ci * @param mySessionName Indicates the pointer to the local session name. 515060ff233Sopenharmony_ci * @param peerSessionName Indicates the pointer to the remote session name. 516060ff233Sopenharmony_ci * @param peerNetworkId Indicates the pointer to the remote device ID. 517060ff233Sopenharmony_ci * @param groupId Indicates the pointer to the group ID. This parameter can be left empty in automatic networking. 518060ff233Sopenharmony_ci * In manual networking, you need to apply for a valid group ID from HiChain. 519060ff233Sopenharmony_ci * @param attr Indicates the pointer to the session attributes {@link SessionAttribute}. 520060ff233Sopenharmony_ci * 521060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_TRANS_INVALID_PARAM</b> if invalid parameters are detected. 522060ff233Sopenharmony_ci * @return Returns <b>INVALID_SESSION_ID</b> if the operation fails. 523060ff233Sopenharmony_ci * @return Returns the session ID (an integer greater than <b>0</b>) if the session is opened; 524060ff233Sopenharmony_ci * returns an error code otherwise. 525060ff233Sopenharmony_ci * @since 1.0 526060ff233Sopenharmony_ci * @version 1.0 527060ff233Sopenharmony_ci */ 528060ff233Sopenharmony_ciint OpenSession(const char *mySessionName, const char *peerSessionName, const char *peerNetworkId, 529060ff233Sopenharmony_ci const char *groupId, const SessionAttribute* attr); 530060ff233Sopenharmony_ci 531060ff233Sopenharmony_ci/** 532060ff233Sopenharmony_ci * @brief Closes a session. 533060ff233Sopenharmony_ci * 534060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID. 535060ff233Sopenharmony_ci * @return Returns no value. 536060ff233Sopenharmony_ci * @since 1.0 537060ff233Sopenharmony_ci * @version 1.0 538060ff233Sopenharmony_ci */ 539060ff233Sopenharmony_civoid CloseSession(int sessionId); 540060ff233Sopenharmony_ci 541060ff233Sopenharmony_ci/** 542060ff233Sopenharmony_ci * @example sendbytes_message_demo.c 543060ff233Sopenharmony_ci */ 544060ff233Sopenharmony_ci 545060ff233Sopenharmony_ci/** 546060ff233Sopenharmony_ci * @brief Sends data. 547060ff233Sopenharmony_ci * 548060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID. 549060ff233Sopenharmony_ci * @param data Indicates the pointer to the data to send, which cannot be <b>NULL</b>. 550060ff233Sopenharmony_ci * @param len Indicates the length of the data to send. 551060ff233Sopenharmony_ci * 552060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected. 553060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_TRANS_SEND_LEN_BEYOND_LIMIT</b> if the data exceeds the maximum limit. 554060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_TRANS_INVALID_SESSION_ID</b> if <b>sessionId</b> is invalid. 555060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_TRANS_SESSION_NO_ENABLE</b> if the session is not open. 556060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_OK</b> if the operation is successful; returns an error code otherwise. 557060ff233Sopenharmony_ci * @since 1.0 558060ff233Sopenharmony_ci * @version 1.0 559060ff233Sopenharmony_ci */ 560060ff233Sopenharmony_ciint SendBytes(int sessionId, const void *data, unsigned int len); 561060ff233Sopenharmony_ci 562060ff233Sopenharmony_ci/** 563060ff233Sopenharmony_ci * @brief Sends a message. 564060ff233Sopenharmony_ci * 565060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID. 566060ff233Sopenharmony_ci * @param data Indicates the pointer to the message to send, which cannot be <b>NULL</b>. 567060ff233Sopenharmony_ci * @param len Indicates the length of the message to send. 568060ff233Sopenharmony_ci * 569060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if <b>data</b> is <b>NULL</b> or <b>len</b> is zero. 570060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_TRANS_SEND_LEN_BEYOND_LIMIT</b> if the message length exceeds the limit. 571060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_INVALID_SESSION_ID</b> if <b>sessionId</b> is invalid. 572060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_TRANS_SESSION_NO_ENABLE</b> if the session is not open. 573060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_OK</b> if the operation is successful; returns an error code otherwise. 574060ff233Sopenharmony_ci * @since 1.0 575060ff233Sopenharmony_ci * @version 1.0 576060ff233Sopenharmony_ci */ 577060ff233Sopenharmony_ciint SendMessage(int sessionId, const void *data, unsigned int len); 578060ff233Sopenharmony_ci 579060ff233Sopenharmony_ci/** 580060ff233Sopenharmony_ci * @example sendstream_demo.c 581060ff233Sopenharmony_ci */ 582060ff233Sopenharmony_ci 583060ff233Sopenharmony_ci/** 584060ff233Sopenharmony_ci * @brief Sends stream data. 585060ff233Sopenharmony_ci * 586060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID. 587060ff233Sopenharmony_ci * @param data Indicates the pointer to the stream data to send, which cannot be <b>NULL</b>. 588060ff233Sopenharmony_ci * @param ext Indicates the pointer to the extended stream data to send, which cannot be <b>NULL</b>. 589060ff233Sopenharmony_ci * @param param Indicates the pointer to the stream frame information, which cannot be <b>NULL</b>. 590060ff233Sopenharmony_ci * 591060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if any of the input parameters is <b>NULL</b>. 592060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_INVALID_SESSION_ID</b> if <b>sessionId</b> is invalid. 593060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_TRANS_SESSION_NO_ENABLE</b> if the session is not open. 594060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_OK</b> if the operation is successful; returns an error code otherwise. 595060ff233Sopenharmony_ci * @since 1.0 596060ff233Sopenharmony_ci * @version 1.0 597060ff233Sopenharmony_ci */ 598060ff233Sopenharmony_ciint SendStream(int sessionId, const StreamData *data, const StreamData *ext, const StreamFrameInfo *param); 599060ff233Sopenharmony_ci 600060ff233Sopenharmony_ci/** 601060ff233Sopenharmony_ci * @example getsessioninfo_demo.c 602060ff233Sopenharmony_ci */ 603060ff233Sopenharmony_ci 604060ff233Sopenharmony_ci/** 605060ff233Sopenharmony_ci * @brief Obtains the session name registered by the local device. 606060ff233Sopenharmony_ci * 607060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID. 608060ff233Sopenharmony_ci * @param sessionName Indicates the pointer to the buffer for storing the session name. 609060ff233Sopenharmony_ci * @param len Indicates the length of the buffer. 610060ff233Sopenharmony_ci * 611060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected. 612060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_OK</b> if the operation is successful; returns an error code otherwise. 613060ff233Sopenharmony_ci * @since 1.0 614060ff233Sopenharmony_ci * @version 1.0 615060ff233Sopenharmony_ci */ 616060ff233Sopenharmony_ciint GetMySessionName(int sessionId, char *sessionName, unsigned int len); 617060ff233Sopenharmony_ci 618060ff233Sopenharmony_ci/** 619060ff233Sopenharmony_ci * @brief Obtains the session name registered by the peer device. 620060ff233Sopenharmony_ci * 621060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID. 622060ff233Sopenharmony_ci * @param sessionName Indicates the pointer to the buffer for storing the session name. 623060ff233Sopenharmony_ci * @param len Indicates the length of the buffer. 624060ff233Sopenharmony_ci * 625060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected. 626060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_OK</b> if the operation is successful; returns an error code otherwise. 627060ff233Sopenharmony_ci * @since 1.0 628060ff233Sopenharmony_ci * @version 1.0 629060ff233Sopenharmony_ci */ 630060ff233Sopenharmony_ciint GetPeerSessionName(int sessionId, char *sessionName, unsigned int len); 631060ff233Sopenharmony_ci 632060ff233Sopenharmony_ci/** 633060ff233Sopenharmony_ci * @brief Obtains the peer device ID. 634060ff233Sopenharmony_ci * 635060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID. 636060ff233Sopenharmony_ci * @param networkId Indicates the pointer to the buffer for storing the device ID. 637060ff233Sopenharmony_ci * @param len Indicates the length of the buffer. 638060ff233Sopenharmony_ci * 639060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected. 640060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_OK</b> if the operation is successful; returns an error code otherwise. 641060ff233Sopenharmony_ci * @since 1.0 642060ff233Sopenharmony_ci * @version 1.0 643060ff233Sopenharmony_ci */ 644060ff233Sopenharmony_ciint GetPeerDeviceId(int sessionId, char *networkId, unsigned int len); 645060ff233Sopenharmony_ci 646060ff233Sopenharmony_ci/** 647060ff233Sopenharmony_ci * @brief Obtains the session role. 648060ff233Sopenharmony_ci * 649060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID. 650060ff233Sopenharmony_ci * @return Returns <b>-1</b> if the operation fails. 651060ff233Sopenharmony_ci * @return Returns <b>0</b> if the session role is a server. 652060ff233Sopenharmony_ci * @return Returns <b>1</b> if the session role is a client. 653060ff233Sopenharmony_ci * @since 1.0 654060ff233Sopenharmony_ci * @version 1.0 655060ff233Sopenharmony_ci */ 656060ff233Sopenharmony_ciint GetSessionSide(int sessionId); 657060ff233Sopenharmony_ci 658060ff233Sopenharmony_ci/** 659060ff233Sopenharmony_ci * @brief Sets a listener for file receiving. 660060ff233Sopenharmony_ci * 661060ff233Sopenharmony_ci * @param pkgName Indicates the pointer to the registered bundle name, which can be used to check 662060ff233Sopenharmony_ci * whether the session server is in this package. The value cannot be empty or exceed 64 characters. 663060ff233Sopenharmony_ci * @param sessionName Indicates the pointer to the buffer for storing the session name. 664060ff233Sopenharmony_ci * @param recvListener Indicates the pointer to the file receive listener, which cannot be <b>NULL</b>. 665060ff233Sopenharmony_ci * @param rootDir Indicates the pointer to the root directory of the file. The length cannot exceed 255 bits. 666060ff233Sopenharmony_ci * 667060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected. 668060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_TRANS_SESSION_ADDPKG_FAILED</b> if the bundle specified by <b>pkgName</b> 669060ff233Sopenharmony_ci * fails to be added. 670060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_OK</b> if the operation is successful; returns an error code otherwise. 671060ff233Sopenharmony_ci * @since 1.0 672060ff233Sopenharmony_ci * @version 1.0 673060ff233Sopenharmony_ci */ 674060ff233Sopenharmony_ciint SetFileReceiveListener(const char *pkgName, const char *sessionName, 675060ff233Sopenharmony_ci const IFileReceiveListener *recvListener, const char *rootDir); 676060ff233Sopenharmony_ci 677060ff233Sopenharmony_ci/** 678060ff233Sopenharmony_ci * @brief Sets a listener for file sending. 679060ff233Sopenharmony_ci * 680060ff233Sopenharmony_ci * @param pkgName Indicates the pointer to the service bundle name. 681060ff233Sopenharmony_ci * It is the unique identifier of the upper-layer service. The value cannot be empty or exceed 64 characters. 682060ff233Sopenharmony_ci * @param sessionName Indicates the pointer to the buffer for storing the session name. 683060ff233Sopenharmony_ci * @param sendListener Indicates the pointer to the file send listener, which cannot be <b>NULL</b>. 684060ff233Sopenharmony_ci * 685060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if invalid parameters are detected. 686060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_TRANS_SESSION_ADDPKG_FAILED</b> if the bundle specified by <b>pkgName</b> 687060ff233Sopenharmony_ci * fails to be added. 688060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_OK</b> if the operation is successful; returns an error code otherwise. 689060ff233Sopenharmony_ci * @since 1.0 690060ff233Sopenharmony_ci * @version 1.0 691060ff233Sopenharmony_ci */ 692060ff233Sopenharmony_ciint SetFileSendListener(const char *pkgName, const char *sessionName, const IFileSendListener *sendListener); 693060ff233Sopenharmony_ci 694060ff233Sopenharmony_ci/** 695060ff233Sopenharmony_ci * @example sendfile_demo.c 696060ff233Sopenharmony_ci */ 697060ff233Sopenharmony_ci 698060ff233Sopenharmony_ci/** 699060ff233Sopenharmony_ci * @brief Sends files. 700060ff233Sopenharmony_ci * 701060ff233Sopenharmony_ci * @param sessionId Indicates the unique session ID. 702060ff233Sopenharmony_ci * @param sFileList Indicates the pointer to the source files to send, which cannot be <b>NULL</b>. 703060ff233Sopenharmony_ci * @param dFileList Indicates the pointer to the destination files, which cannot be <b>NULL</b>. 704060ff233Sopenharmony_ci * @param fileCnt Indicates the number of files to send, which cannot be <b>0</b>. 705060ff233Sopenharmony_ci * 706060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if <b>sFileList</b> is <b>NULL</b> or <b>fileCnt</b> is <b>0</b>. 707060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_INVALID_SESSION_ID</b> if <b>sessionId</b> is invalid. 708060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_TRANS_SESSION_NO_ENABLE</b> if the session is not open. 709060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_OK</b> if the operation is successful; returns an error code otherwise. 710060ff233Sopenharmony_ci * @since 1.0 711060ff233Sopenharmony_ci * @version 1.0 712060ff233Sopenharmony_ci */ 713060ff233Sopenharmony_ciint SendFile(int sessionId, const char *sFileList[], const char *dFileList[], uint32_t fileCnt); 714060ff233Sopenharmony_ci 715060ff233Sopenharmony_ci/** 716060ff233Sopenharmony_ci * @brief Get Session based on a session ID. 717060ff233Sopenharmony_ci * 718060ff233Sopenharmony_ci * @param sessionId Indicates the session ID. 719060ff233Sopenharmony_ci * @param option Indicates the session option type to get. 720060ff233Sopenharmony_ci * @param optionValue Indicates the session option value to get, which cannot be <b>NULL</b>. 721060ff233Sopenharmony_ci * @param valueSize Indicates the size of data which optionValue point to, which cannot be <b>0</b>. 722060ff233Sopenharmony_ci * The common error codes are as follows: 723060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_INVALID_PARAM</b> if the option is invalid, optionValue is NULL or valueSize is Zero. 724060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_INVALID_SESSION_ID</b> if the sessionId is invalid. 725060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_TRANS_SESSION_NO_ENABLE</b> if the session current be not enabled. 726060ff233Sopenharmony_ci * @return Returns <b>SOFTBUS_OK</b>if the function is called successfully, return other internal errorcodes otherwise. 727060ff233Sopenharmony_ci * @since 1.0 728060ff233Sopenharmony_ci * @version 1.0 729060ff233Sopenharmony_ci */ 730060ff233Sopenharmony_ciint GetSessionOption(int sessionId, SessionOption option, void* optionValue, uint32_t valueSize); 731060ff233Sopenharmony_ci 732060ff233Sopenharmony_ci#ifdef __cplusplus 733060ff233Sopenharmony_ci} 734060ff233Sopenharmony_ci#endif 735060ff233Sopenharmony_ci#endif // SESSION_H 736