Agora Java API Reference for Android

NGIAgoraDataChannel.h
1
2 // Copyright (c) 2022 Agora.io. All rights reserved
3
4 // This program is confidential and proprietary to Agora.io.
5 // And may not be copied, reproduced, modified, disclosed to others, published
6 // or used, in whole or in part, without the express prior written permission
7 // of Agora.io.
8 #pragma once // NOLINT(build/header_guard)
9
10 #include "AgoraRefPtr.h"
11 #include "AgoraBase.h"
12 #include <api/cpp/aosl_ares_class.h>
13 namespace agora {
14
18 struct DataChannelConfig {
24 bool syncWithMedia;
30 bool ordered;
31
37 int compressionLength;
38 // optional
39 Optional<int> channelId; // 0~7
40
44 int32_t priority;
45 DataChannelConfig() :
46 syncWithMedia(false),
47 ordered(false),
48 compressionLength(0),
49 priority(-1) {}
50 };
51
55 struct DataChannelInfo {
59 int dataChannelId;
63 util::AString metadata;
64 };
65
69 struct UserDataChannelInfo {
73 util::AString userId;
77 const DataChannelInfo* infos;
81 size_t info_size;
82 };
83
84 class ILocalDataChannel : public RefCountInterface {
85 public:
95 virtual int sendDataPacket(const char* packet, size_t length, uint64_t capture_time_ms, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
105 virtual int setMetaData(const char* metaData, size_t length, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
106
112 virtual Optional<int> configuredChannelId() const = 0;
113
114 protected:
115 virtual ~ILocalDataChannel() {}
116 };
117
118 class IRemoteDataChannel: public RefCountInterface {
119 public:
120 virtual util::AString UserId() const = 0;
121 virtual int ChannelId() const = 0;
122 virtual util::AString Meta() = 0;
123
124 protected:
125 virtual ~IRemoteDataChannel() {}
126 };
127
128 class IDataChannelObserver {
129 public:
134 virtual void onLocalDataChannelPublished(agora_refptr<ILocalDataChannel> channel) {}
135
140 virtual void onRemoteDataChannelSubscribed(agora_refptr<IRemoteDataChannel> channel) {}
141
146 virtual void onRemoteDataChannelUnsubscribed(agora_refptr<IRemoteDataChannel> channel) {}
152 virtual void onRemoteDataPacketReceived(const UserDataChannelInfo& info, util::AString packet) {}
153
161 virtual void onRemoteDataChannelInfoUpdated(const UserDataChannelInfo* modified_infos, size_t modified_infos_size,
162 const UserDataChannelInfo* deleted_infos, size_t deleted_infos_size) {}
163 virtual ~IDataChannelObserver() {}
164 };
165
166 } // namespace agora
agora::DataChannelInfo::metadata
util::AString metadata
Definition: NGIAgoraDataChannel.h:63
agora::IDataChannelObserver::onRemoteDataChannelSubscribed
virtual void onRemoteDataChannelSubscribed(agora_refptr< IRemoteDataChannel > channel)
Definition: NGIAgoraDataChannel.h:140
agora::DataChannelConfig::syncWithMedia
bool syncWithMedia
Definition: NGIAgoraDataChannel.h:24
agora::agora_refptr
Definition: AgoraRefPtr.h:44
agora::DataChannelConfig::ordered
bool ordered
Definition: NGIAgoraDataChannel.h:30
agora::IRemoteDataChannel
Definition: NGIAgoraDataChannel.h:118
agora::UserDataChannelInfo::userId
util::AString userId
Definition: NGIAgoraDataChannel.h:73
agora::ILocalDataChannel::setMetaData
virtual int setMetaData(const char *metaData, size_t length, aosl_ref_t ares=AOSL_REF_INVALID)=0
agora::DataChannelInfo::dataChannelId
int dataChannelId
Definition: NGIAgoraDataChannel.h:59
agora::DataChannelConfig::priority
int32_t priority
Definition: NGIAgoraDataChannel.h:44
agora::IDataChannelObserver::onRemoteDataChannelInfoUpdated
virtual void onRemoteDataChannelInfoUpdated(const UserDataChannelInfo *modified_infos, size_t modified_infos_size, const UserDataChannelInfo *deleted_infos, size_t deleted_infos_size)
Definition: NGIAgoraDataChannel.h:161
agora::UserDataChannelInfo::info_size
size_t info_size
Definition: NGIAgoraDataChannel.h:81
agora::IDataChannelObserver::onRemoteDataChannelUnsubscribed
virtual void onRemoteDataChannelUnsubscribed(agora_refptr< IRemoteDataChannel > channel)
Definition: NGIAgoraDataChannel.h:146
agora::DataChannelInfo
Definition: NGIAgoraDataChannel.h:55
agora::DataChannelConfig::compressionLength
int compressionLength
Definition: NGIAgoraDataChannel.h:37
agora::IDataChannelObserver::onLocalDataChannelPublished
virtual void onLocalDataChannelPublished(agora_refptr< ILocalDataChannel > channel)
Definition: NGIAgoraDataChannel.h:134
agora::UserDataChannelInfo::infos
const DataChannelInfo * infos
Definition: NGIAgoraDataChannel.h:77
agora::UserDataChannelInfo
Definition: NGIAgoraDataChannel.h:69
agora::IDataChannelObserver::onRemoteDataPacketReceived
virtual void onRemoteDataPacketReceived(const UserDataChannelInfo &info, util::AString packet)
Definition: NGIAgoraDataChannel.h:152
agora::ILocalDataChannel::sendDataPacket
virtual int sendDataPacket(const char *packet, size_t length, uint64_t capture_time_ms, aosl_ref_t ares=AOSL_REF_INVALID)=0
agora::RefCountInterface
Definition: AgoraRefPtr.h:31
agora::util::CopyableAutoPtr
Definition: AgoraBase.h:156
agora::ILocalDataChannel
Definition: NGIAgoraDataChannel.h:84
agora::ILocalDataChannel::configuredChannelId
virtual Optional< int > configuredChannelId() const =0
agora::DataChannelConfig
Definition: NGIAgoraDataChannel.h:18
agora::IDataChannelObserver
Definition: NGIAgoraDataChannel.h:128
agora::Optional< int >