IAgoraRtmCallManager.h 15.8 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490
//
//  Agora's RTM SDK
//
//
//  Copyright (c) 2019 Agora.io. All rights reserved.
//
#pragma once

#include "IAgoraRtmService.h"

namespace agora {
  namespace rtm {
      
    /**
     @brief <b>RETURNED TO THE CALLER.</b> States of an outgoing call invitation.
     */
    enum LOCAL_INVITATION_STATE {
        
      /**
       0: <b>RETURNED TO THE CALLER.</b> The initial state of a call invitation (idle).
       */
      LOCAL_INVITATION_STATE_IDLE = 0,
        
      /**
       1: <b>RETURNED TO THE CALLER.</b> The call invitation is sent to the callee.
       */
      LOCAL_INVITATION_STATE_SENT_TO_REMOTE = 1,
        
      /**
       2: <b>RETURNED TO THE CALLER.</b> The call invitation is received by the callee.
       */
      LOCAL_INVITATION_STATE_RECEIVED_BY_REMOTE = 2,
        
      /**
       3: <b>RETURNED TO THE CALLER.</b> The call invitation is accepted by the callee.
       */
      LOCAL_INVITATION_STATE_ACCEPTED_BY_REMOTE = 3,
        
      /**
       4: <b>RETURNED TO THE CALLER.</b> The call invitation is declined by the callee.
       */
      LOCAL_INVITATION_STATE_REFUSED_BY_REMOTE = 4,
        
      /**
       5: <b>RETURNED TO THE CALLER.</b> You have canceled the call invitation.
       */
      LOCAL_INVITATION_STATE_CANCELED = 5,
        
      /**
       6: <b>RETURNED TO THE CALLER.</b> The call invitation fails.
       */
      LOCAL_INVITATION_STATE_FAILURE = 6,
    };

    /**
     @brief <b>RETURNED TO THE CALLEE.</b> States of an incoming call invitation.
     */
    enum REMOTE_INVITATION_STATE {
        
      /**
       0: <b>RETURNED TO THE CALLEE.</b> The initial state of a call invitation (idle).
       */
      REMOTE_INVITATION_STATE_IDLE = 0,
        
      /**
       1: <b>RETURNED TO THE CALLEE.</b> A call invitation from a remote caller is received.
       */
      REMOTE_INVITATION_STATE_INVITATION_RECEIVED = 1,
        
      /**
       2: <b>RETURNED TO THE CALLEE.</b> The message is sent to the caller that the call invitation is accepted.
       */
      REMOTE_INVITATION_STATE_ACCEPT_SENT_TO_LOCAL = 2,
        
      /**
       3: <b>RETURNED TO THE CALLEE.</b> You have declined the call invitation.
       */
      REMOTE_INVITATION_STATE_REFUSED = 3,
        
      /**
       4: <b>RETURNED TO THE CALLEE.</b> You have accepted the call invitation.
       */
      REMOTE_INVITATION_STATE_ACCEPTED = 4,
        
      /**
       5: <b>RETURNED TO THE CALLEE.</b> The call invitation is canceled by the remote caller.
       */
      REMOTE_INVITATION_STATE_CANCELED = 5,
        
      /**
       6: <b>RETURNED TO THE CALLEE.</b> The call invitation fails.
       */
      REMOTE_INVITATION_STATE_FAILURE = 6,
    };

    /**
     @brief <b>RETURNED TO THE CALLER.</b> Error codes of an outgoing call invitation.
     */
    enum LOCAL_INVITATION_ERR_CODE {
        
      /**
       0: <b>RETURNED TO THE CALLER.</b> The outgoing invitation succeeds.
       */
      LOCAL_INVITATION_ERR_OK = 0,
        
      /**
       1: <b>RETURNED TO THE CALLER.</b> The callee is offline.
        
       The SDK performs the following:
       - Keeps resending the call invitation to the callee, if the callee is offline.
       - Returns this error code, if the callee is still offline 30 seconds since the call invitation is sent.
       */
      LOCAL_INVITATION_ERR_PEER_OFFLINE = 1,
        
      /**
       2: <b>RETURNED TO THE CALLER.</b> The callee is online but has not ACKed to the call invitation 30 seconds since it is sent.
       */
      LOCAL_INVITATION_ERR_PEER_NO_RESPONSE = 2,
        
      /**
       3: <b>RETURNED TO THE CALLER. SAVED FOR FUTURE USE.</b> The call invitation expires 60 seconds since it is sent, if the callee ACKs to the call invitation but neither the caller or callee takes any further action (cancel, accpet, or decline it).
       */
      LOCAL_INVITATION_ERR_INVITATION_EXPIRE = 3,
        
      /**
       4: <b>RETURNED TO THE CALLER.</b> The caller is not logged in.
       */
      LOCAL_INVITATION_ERR_NOT_LOGGEDIN = 4,
    };
      
    /**
     @brief <b>RETURNED TO THE CALLEE.</b> Error codes of an incoming call invitation.
     */
    enum REMOTE_INVITATION_ERR_CODE {
        
      /**
       0: <b>RETURNED TO THE CALLEE.</b> The incoming calll invitation succeeds.
       */
      REMOTE_INVITATION_ERR_OK = 0,
        
      /**
       1: <b>RETURNED TO THE CALLEE.</b> The call invitation received by the callee fails: the callee is not online.
       */
      REMOTE_INVITATION_ERR_PEER_OFFLINE = 1,
        
      /**
       2: <b>RETURNED TO THE CALLEE.</b> The call invitation received by callee fails: the acceptance of the call invitation fails.
       */
      REMOTE_INVITATION_ERR_ACCEPT_FAILURE = 2,
        
      /**
       3: <b>RETURNED TO THE CALLEE.</b> The call invitation expires 60 seconds since it is sent, if the callee ACKs to the call invitation but neither the caller or callee takes any further action (cancel, accpet, or decline it).
       */
      REMOTE_INVITATION_ERR_INVITATION_EXPIRE = 3,
    };

    /**
     @brief Error codes of the call invitation methods.
     */
    enum INVITATION_API_CALL_ERR_CODE {
        
      /**
       0: The method call succeeds.
       */
      INVITATION_API_CALL_ERR_OK = 0,
        
      /**
       1: The method call fails. Invalid argument.
       */
      INVITATION_API_CALL_ERR_INVALID_ARGUMENT = 1,
        
      /**
       2: The method call fails. The call invitation has not started.
       */
      INVITATION_API_CALL_ERR_NOT_STARTED = 2,
        
      /**
       3: The method call fails. The call invitation has ended.
       */
      INVITATION_API_CALL_ERR_ALREADY_END = 3, // accepted, failure, canceled, refused
        
      /**
       4: The method call fails. The call invitation is already accepted.
       */
      INVITATION_API_CALL_ERR_ALREADY_ACCEPT = 4,   // more details
        
      /**
       5: The method call fails. The call invitation is already sent.
       */
      INVITATION_API_CALL_ERR_ALREADY_SENT = 5,
    };

    /**
     The class allowing the caller to retrieve the attributes of an outgoing call invitation.
     */
    class ILocalCallInvitation
    {
    protected:
      virtual ~ILocalCallInvitation() {}
    public:
        
      /**
       Allows the caller to get the User ID of the callee.
       */
      virtual const char *getCalleeId() const = 0;
        
      /**
       Allows the caller to set the call invitation content.
    
       @param content The content of the call invitation. The @p content must not exceed 8 KB in length if encoded in UTF-8.
       */
      virtual void setContent(const char *content) = 0;
        
      /**
       Allows the caller to get the call invitation content.
       
       @note The caller sets the call invitation content using the \ref agora::rtm::ILocalCallInvitation::setContent "setContent" method.
       */
      virtual const char *getContent() const = 0;
        
      /**
       Sets the channel ID.
       
       @note To intercommunicate with the legacy Agora Signaling SDK, you MUST set the channel ID. However, even if the callee successfully accepts the call invitation, the Agora RTM SDK does not join the channel of the specified channel ID. 
       
       @param channelId The channel ID to be set.
       */
      virtual void setChannelId(const char *channelId) = 0;
        
      /**
       Gets the channel ID.
       */
      virtual const char *getChannelId() const = 0;
        
      /**
       Allows the caller to get the callee's response to the call invitation.
       
       @note The callee sets his/her response using the \ref agora::rtm::IRemoteCallInvitation::setResponse "setResponse" method.
       */
      virtual const char *getResponse() const = 0;
        
      /**
       Allows the caller to get the state of the outgoing call invitation.

       @return State of the outgoing call invitation. See: #LOCAL_INVITATION_STATE.
       */
      virtual LOCAL_INVITATION_STATE getState() const = 0;
        
      /**
       Releases all resources used by the ILocalCallInvitation instance.
       */
      virtual void release() = 0;
    };

    /**
     The class allowing the callee to retrieve the attributes of an incoming call invitation.
     */
    class IRemoteCallInvitation
    {
    protected:
      virtual ~IRemoteCallInvitation() {}
    public:
        
      /**
       Allows the callee to get the User ID of the caller.
       */
      virtual const char *getCallerId() const = 0;
      
      /**
       Allows the callee to get the call invitation content set by the caller.
       
       @note The caller sets the call invitation content using the \ref agora::rtm::ILocalCallInvitation::setContent "setContent" method.
       */
      virtual const char *getContent() const = 0;
        
      /**
       Allows the callee to set a response to the call invitation.

       @param response The callee's response to the call invitation. The @p response must not exceed 8 KB in length if encoded in UTF-8.
       */
      virtual void setResponse(const char *response) = 0;
      
      /**
       Allows the callee to get his/her response to the incoming call invitation.
       
       @note The callee sets a response to the incoming call invitation using the \ref agora::rtm::IRemoteCallInvitation::setResponse "setResponse" method.
       */
      virtual const char *getResponse() const = 0;
        
      /**
       Gets the channel ID.
       */
      virtual const char *getChannelId() const = 0;
      
      /**
       Allows the callee to get the state of the incoming call invitation.
       
       @return The state of the incoming call invitation See: #REMOTE_INVITATION_STATE.
       */
      virtual REMOTE_INVITATION_STATE getState() const = 0;
        
      /**
       Releases all resources used by the IRemoteCallInvitation instance.
       */
      virtual void release() = 0;
    };

    /**
     Callbacks for the call invitation methods.
     */
    class IRtmCallEventHandler
    {
    public:
      virtual ~IRtmCallEventHandler()
      {
      }
        
      /**
       Callback to the caller: occurs when the callee receives the call invitation.
	
	   @param localInvitation An ILocalCallInvitation object.
	   */
      virtual void onLocalInvitationReceivedByPeer(ILocalCallInvitation *localInvitation)
      {
        (ILocalCallInvitation *) localInvitation;
      }
        
      /**
       Callback to the caller: occurs when the caller cancels a call invitation.
	 
	   @param localInvitation An ILocalCallInvitation object.
       */
      virtual void onLocalInvitationCanceled(ILocalCallInvitation *localInvitation)
      {
        (ILocalCallInvitation *) localInvitation;
      }
        
      /**
       Callback to the caller: occurs when the life cycle of the outgoing call invitation ends in failure.
	 
       @param localInvitation An ILocalCallInvitation object.
       @param errorCode The error code. See #LOCAL_INVITATION_ERR_CODE.
       */
      virtual void onLocalInvitationFailure(ILocalCallInvitation *localInvitation, LOCAL_INVITATION_ERR_CODE errorCode)
      {
        (ILocalCallInvitation *) localInvitation;
        (LOCAL_INVITATION_ERR_CODE) errorCode;
      }
    
      /**
       Callback to the caller: occurs when the callee accepts the call invitation.
	 
	   @param localInvitation An ILocalCallInvitation object.
       @param response The callee's response to the call invitation.
	   */
      virtual void onLocalInvitationAccepted(ILocalCallInvitation *localInvitation, const char *response)
      {
        (ILocalCallInvitation *) localInvitation;
        (const char *) response;
      }
      
      /**
       Callback to the caller: occurs when the callee refuses the call invitation.

       @param localInvitation An ILocalCallInvitation object.
       @param response The callee's response to the call invitation.
       */
      virtual void onLocalInvitationRefused(ILocalCallInvitation *localInvitation, const char *response)
      {
        (ILocalCallInvitation *) localInvitation;
        (const char *) response;
      }
        
      /**
       Callback for the callee: occurs when the callee refuses a call invitation.
    
       @param remoteInvitation An IRemoteCallInvitation object.
       */
      virtual void onRemoteInvitationRefused(IRemoteCallInvitation *remoteInvitation)
      {
        (IRemoteCallInvitation *) remoteInvitation;
      }
        
      /**
       Callback to the callee: occurs when the callee accepts a call invitation.
    
       @param remoteInvitation An IRemoteCallInvitation object.
       */
      virtual void onRemoteInvitationAccepted(IRemoteCallInvitation *remoteInvitation)
      {
        (IRemoteCallInvitation *) remoteInvitation;
      }
        
      /**
       Callback to the callee: occurs when the callee receives a call invitation.
	
	   @param remoteInvitation An IRemoteCallInvitation object.
	   */
      virtual void onRemoteInvitationReceived(IRemoteCallInvitation *remoteInvitation)
      {
        (IRemoteCallInvitation *) remoteInvitation;
      }
        
      /**
       Callback to the callee: occurs when the life cycle of the incoming call invitation ends in failure.
	
       @param remoteInvitation An IRemoteCallInvitation object.
       @param errorCode The error code. See #REMOTE_INVITATION_ERR_CODE.
       */
      virtual void onRemoteInvitationFailure(IRemoteCallInvitation *remoteInvitation, REMOTE_INVITATION_ERR_CODE errorCode)
      {
        (IRemoteCallInvitation *) remoteInvitation;
      }
        
      /**
       Callback to the callee: occurs when the caller cancels the call invitation.
	
	   @param remoteInvitation An IRemoteCallInvitation object.
	   */
      virtual void onRemoteInvitationCanceled(IRemoteCallInvitation *remoteInvitation)
      {
        (IRemoteCallInvitation *) remoteInvitation;
      }
    };
      
    /**
     RTM call manager methods.
     */
    class IRtmCallManager
    {
    protected:
      virtual ~IRtmCallManager() {}
    public:
        
      /**
       Allows the caller to send a call invitation to the callee.
    
       @param invitation An \ref agora::rtm::ILocalCallInvitation "ILocalCallInvitation" object.
       @return
       - 0: Success.
       - <0: Failure. See #INVITATION_API_CALL_ERR_CODE for the error code.
       */
      virtual int sendLocalInvitation(ILocalCallInvitation *invitation)= 0;
        
      /**
       Allows the callee to accept an incoming call invitation.
     
       @param invitation An \ref agora::rtm::IRemoteCallInvitation "IRemoteCallInvitation" object.
       @return
       - 0: Success.
       - <0: Failure. See #INVITATION_API_CALL_ERR_CODE for the error code.
       */
      virtual int acceptRemoteInvitation(IRemoteCallInvitation *invitation) = 0;
        
      /**
       Allows the callee to decline an incoming call invitation.
    
       @param invitation An \ref agora::rtm::IRemoteCallInvitation "IRemoteCallInvitation" object.
       @return
       - 0: Success.
       - <0: Failure. See #INVITATION_API_CALL_ERR_CODE for the error code.
       */
      virtual int refuseRemoteInvitation(IRemoteCallInvitation *invitation) = 0;
        
      /**
       Allows the caller to cancel an outgoing call invitation.

       @param invitation An \ref agora::rtm::ILocalCallInvitation "ILocalCallInvitation" object.
       @return
       - 0: Success.
       - <0: Failure. See #INVITATION_API_CALL_ERR_CODE for the error code.
       */
      virtual int cancelLocalInvitation(ILocalCallInvitation *invitation) = 0;
        
       /**
        Creates an ILocalCallInvitation object.
	
	    @param calleeId The Callee's user ID.
	    @return An \ref agora::rtm::ILocalCallInvitation "ILocalCallInvitation" object.
        */
      virtual ILocalCallInvitation *createLocalCallInvitation(const char *calleeId) = 0;
        
      // sync_call
      /**
       Releases all resources used by the IRtmCallManager instance.
       */
      virtual void release() = 0;
    };
  }
}