• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 
16 #ifndef OHOS_DSCHED_COLLAB_CHANNEL_COMMON_DEFINITION_H
17 #define OHOS_DSCHED_COLLAB_CHANNEL_COMMON_DEFINITION_H
18 #include "data_sender_receiver.h"
19 #include <map>
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 namespace OHOS {
25 namespace DistributedCollab {
26 enum class ChannelStatus {
27     CONNECTED = 0,
28     UNCONNECTED
29 };
30 
31 enum class ChannelDataType {
32     MESSAGE = 0,
33     BYTES,
34     VIDEO_STREAM,
35     FILE
36 };
37 
38 struct ChannelPeerInfo {
39     std::string peerName;
40     std::string networkId;
41 };
42 
43 struct ChannelInfo {
44     int32_t channelId = 0;
45     ChannelStatus status = ChannelStatus::UNCONNECTED;
46     ChannelDataType dataType = ChannelDataType::MESSAGE;
47     std::string channelName;
48     ChannelPeerInfo peerInfo;
49     std::vector<int32_t> clientSockets;
50     // socketId->sender
51     std::map<int32_t, std::unique_ptr<DataSenderReceiver>> dataSenderReceivers;
52 };
53 
54 enum class ChannelFileEvent : uint32_t {
55     SEND_PROCESS = 0,     /**< Sending file */
56     SEND_FINISH,      /**< Send file end */
57     SEND_ERROR,       /**< Send file failed */
58     RECV_START,       /**< Receive file start */
59     RECV_PROCESS,     /**< Receiving file */
60     RECV_FINISH,      /**< Receive file end */
61     RECV_ERROR,       /**< Receive file failed */
62 };
63 
64 struct FileSendInfo {
65     uint64_t bytesProcessed = 0;             /**< Send or receive bytes of the files*/
66     uint64_t bytesTotal = 0;                 /**< Total bytes of the files*/
67     std::optional<uint32_t> rate = std::nullopt;
68 };
69 
70 struct FileRecvInfo {
71     uint64_t bytesProcessed = 0;             /**< Send or receive bytes of the files*/
72     uint64_t bytesTotal = 0;                 /**< Total bytes of the files*/
73     std::optional<uint32_t> rate = std::nullopt;
74 };
75 
76 struct FileErrorInfo {
77     int32_t errorCode = 0;
78 };
79 
80 struct FileCommonInfo {
81     ChannelFileEvent eventType = ChannelFileEvent::SEND_PROCESS;
82     std::vector<std::string> fileList;
83     uint32_t fileCnt = 0;
84 };
85 
86 struct FileInfo {
87     FileCommonInfo commonInfo;
88     std::optional<FileSendInfo> sendInfo = std::nullopt;
89     std::optional<FileRecvInfo> recvInfo = std::nullopt;
90     std::optional<FileErrorInfo> errorInfo = std::nullopt;
91 };
92 }
93 }
94 #endif