#ifndef __YELIANK_RCC_MULTI_CALL_H__
#define __YELIANK_RCC_MULTI_CALL_H__

/****************************************************************************
*
*   yealinksdk.h
*
*   FreeType high-level API and common types (specification only).
*
* Copyright (c) 2020 Yealink ltd.
*
* This file defines the  interface for the Yealink SDK to control Yealink devices.
*
*/


#if defined _WIN32 || defined __CYGWIN___
#ifdef  BUILD_SDK
#define YEALINK_API extern "C" __declspec(dllexport)
#else
#define YEALINK_API extern "C" __declspec(dllimport)
#endif
#else
#ifdef __APPLE__
#ifdef __cplusplus
#define YEALINK_API extern "C" __attribute__ ((visibility ("default")))
#else
#define YEALINK_API __attribute__ ((visibility ("default")))
#endif
#include <stdbool.h>
#elif __linux__
#ifdef __cplusplus
#define YEALINK_API extern "C" __attribute__ ((visibility ("default")))
#else
#define YEALINK_API __attribute__ ((visibility ("default")))
#include <stdbool.h>
#endif
#endif
#endif

#if defined _WIN32 || defined __CYGWIN___
#define Yealink_VAR extern "C" __declspec(dllexport)
#else
#ifdef __cplusplus
#define Yealink_VAR extern "C" __attribute__ ((visibility ("default")))
#else
#define Yealink_VAR extern __attribute__ ((visibility ("default")))
#endif
#endif

#include "yealinksdkcommon.h"

typedef enum _CallAction
{
    ACALL_ACTION_ACCEPT = 1,                // accept call
    ACALL_ACTION_TERMINATE = 2,             // terminate call
    ACALL_ACTION_HOLD = 3,                  // hold call
    ACALL_ACTION_RESUME = 4,                // resume call
    ACALL_ACTION_REJECT = 5,                // reject call
    ACALL_ACTION_CALL_OUT = 6,              // call out
    ACALL_ACTION_ENTER_DIAL = 7,            // enter dial
    ACALL_ACTION_MUTE = 8,                  // mute call
    ACALL_ACTION_UNMUTE = 9,                // unmute call
    ACALL_ACTION_DTMF = 10,                 // dtmf
    ACALL_ACTION_REDIAL = 11,               // redial call
} Yealink_CallAction;

typedef enum
{
    CALL_RETURN_SUCCESS = 0,                // success
    CALL_RETURN_NOT_SUPPORT_RCC = 1,        // device not support remote call control
    CALL_RETURN_CALL_NOT_EXIST = 2,         // the operating call not exist
    CALL_RETURN_CALL_ALREADY_EXIST = 3,     // the operating call exist
    CALL_RETURN_CID_ALLOC_FAILED = 4,       // sdk's call id allocate failed
    CALL_RETURN_CALL_SYNC_FAILED = 5,       // failed to sync call state to device
    CALL_RETURN_USER_CID_UNEXPECT = 6,      // user call id unexpected
    CALL_RETURN_CALL_COUNT_LIMIT = 7,       // count of call exceed the limit
    CALL_RETURN_RCC_DISABLE_BY_YUC = 8,     // rcc is disabled by YUC, if you want to use it, please enable it in YUC
    CALL_RETRUN_OPERATION_NOT_SUPPORT = 9,  // device or protocol does not support this operation, you can ignore and continue next operation
    CALL_RETURN_OTHER = 9999,               // other fail
} Yealink_CallReturn;


/**
 * @brief Put the device on dial.
 * @param[in] uDeviceId ID for a specific device.
 * @param[in] iCid for identifying user call.
 * @return CALL_RETURN_SUCCESS if success, other if failed.
 */
YEALINK_API Yealink_CallReturn Yealink_EnterDialCall(unsigned short uDeviceId, int iCid);

/**
 * @brief The device enters the ringback call state.
 * @param[in] uDeviceId ID for a specific device.
 * @param[in] iCid for identifying user call.
 * @return CALL_RETURN_SUCCESS if success, other if failed.
 */
YEALINK_API Yealink_CallReturn Yealink_RingBackCall(unsigned short uDeviceId, int iCid);

/**
 * @brief The device enters the incoming call state.
 * @param[in] uDeviceId ID for a specific device.
 * @param[in] iCid for identifying user call.
 * @param[in] pContact for contact info #Yealink_ContactInfo.
 * @return CALL_RETURN_SUCCESS if success, other if failed.
 */
YEALINK_API Yealink_CallReturn Yealink_IncomingCall(unsigned short uDeviceId, int iCid, Yealink_ContactInfo* pContact);

/**
 * @brief The device enters the active call state.
 * @param[in] uDeviceId ID for a specific device.
 * @param[in] iCid for identifying user call.
 * @param[in] pContact for contact info #Yealink_ContactInfo.
 * @return CALL_RETURN_SUCCESS if success, other if failed.
 */
YEALINK_API Yealink_CallReturn Yealink_OutgoingCall(unsigned short uDeviceId, int iCid, Yealink_ContactInfo* pContact);

/**
 * @brief End call.
 * @param[in] uDeviceId ID for a specific device.
 * @param[in] iCid for identifying user call.
 * @return CALL_RETURN_SUCCESS if success, other if failed.
 */
YEALINK_API Yealink_CallReturn Yealink_TerminateCall(unsigned short uDeviceId, int iCid);

/**
 * @brief Answer call, the device enters the active call state.
 * @param[in] uDeviceId ID for a specific device.
 * @param[in] iCid for identifying user call.
 * @return CALL_RETURN_SUCCESS if success, other if failed.
 */
YEALINK_API Yealink_CallReturn Yealink_AnswerCall(unsigned short uDeviceId, int iCid);

/**
 * @brief Hold a call, Tthe device enters the hold call state.
 * @param[in] uDeviceId ID for a specific device.
 * @param[in] iCid for identifying user call.
 * @param[in] pContact for contact info #Yealink_ContactInfo.
 * @return CALL_RETURN_SUCCESS if success, other if failed.
 */
YEALINK_API Yealink_CallReturn Yealink_HoldCall(unsigned short uDeviceId, int iCid, Yealink_ContactInfo* pContact);

/**
 * @brief Resume call, Tthe device enters the active call state.
 * @param[in] uDeviceId ID for a specific device.
 * @param[in] iCid for identifying user call.
 * @return CALL_RETURN_SUCCESS if success, other if failed.
 */
YEALINK_API Yealink_CallReturn Yealink_ResumeCall(unsigned short uDeviceId, int iCid);

/**
 * @brief Mute call.
 * @param[in] uDeviceId ID for a specific device.
 * @param[in] iCid for identifying user call.
 * @return CALL_RETURN_SUCCESS if success, other if failed.
 */
YEALINK_API Yealink_CallReturn Yealink_MuteCall(unsigned short uDeviceId, int iCid);

/**
 * @brief Ummute call.
 * @param[in] uDeviceId ID for a specific device.
 * @param[in] iCid for identifying user call.
 * @return CALL_RETURN_SUCCESS if success, other if failed.
 */
YEALINK_API Yealink_CallReturn Yealink_UnmuteCall(unsigned short uDeviceId, int iCid);

/**
 * @brief Update contact info for call.
 * @param[in] uDeviceId ID for a specific device.
 * @param[in] iCid for identifying user call.
 * @param[in] pContact for contact info #Yealink_ContactInfo.
 * @return CALL_RETURN_SUCCESS if success, other if failed.
 */
YEALINK_API Yealink_CallReturn Yealink_UpdateContact(unsigned short uDeviceId, int iCid, Yealink_ContactInfo* pContact);

/**
 * @brief Update contact info for call.
 * @param[in] funcCallAction Callback method, will be called when device operates a call.
 */
YEALINK_API void Yealink_RegisterCallAction(void(*funcCallAction)(unsigned short uDeviceID, int iCid, Yealink_CallAction eCallAction));

/**
 * @brief Update contact info for call.
 * @param[in] funcDialNumChanged Callback method, will be called when device dial number changes.
 * @notice pDialNum need free by Yealink_FreeString
 */
YEALINK_API void Yealink_RegisterDialNumChanged(void(*funcDialNumChanged)(unsigned short uDeviceID, int iCid, char* pDialNum));

#endif // __YELIANK_RCC_MULTI_CALL_H__
