mtc_util.h 7.75 KB
/************************************************************************

        Copyright (c) 2005-2011 by Juphoon System Software, Inc.
                       All rights reserved.

     This software is confidential and proprietary to Juphoon System,
     Inc. No part of this software may be reproduced, stored, transmitted,
     disclosed or used in any form or by any means other than as expressly
     provided by the written license agreement between Juphoon and its
     licensee.

     THIS SOFTWARE IS PROVIDED BY JUPHOON "AS IS" AND ANY EXPRESS OR 
     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
     WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     ARE DISCLAIMED. IN NO EVENT SHALL JUPHOON BE LIABLE FOR ANY DIRECT, 
     INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
     (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
     OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
     STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
     IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
     POSSIBILITY OF SUCH DAMAGE. 

                    Juphoon System Software, Inc.
                    Email: support@juphoon.com
                    Web: http://www.juphoon.com

************************************************************************/
/*************************************************
  File name     : mtc_util.h
  Module        : multimedia talk client
  Author        : leo.lv
  Created on    : 2011-01-03
  Description   :
      Data structure and function declare required by MTC utility

  Modify History:
  1. Date:        Author:         Modification:
*************************************************/
#ifndef _MTC_UTIL_H__
#define _MTC_UTIL_H__

/**
 * @file mtc_util.h
 * @brief MTC Utility Interface Functions.
 */
#ifdef __cplusplus
extern "C" {
#endif

/** @brief User defined callback when timer triggers. */
typedef ZVOID (*PFN_ZMTCTMRA)(ZTIMERID zTimerId, ZCOOKIE zCookie);

/** @brief User defined schedule when timer triggers. */
typedef ZVOID (*PFN_ZMTCTMRS)(ZCOOKIE zCookie);

/** @brief Mtc system time. */
typedef struct tagMTC_SYS_TIME
{
    ZUSHORT wYear;                   /**< @brief Year */
    ZUCHAR ucMonth;                  /**< @brief Month 1 - 12 */
    ZUCHAR ucDay;                    /**< @brief Day 1 - 31 */
    ZUCHAR ucWeekDay;                /**< @brief Week day 0 - 6, 0 for Sunday */
    ZUCHAR ucHour;                   /**< @brief Hour 0 - 23 */
    ZUCHAR ucMinute;                 /**< @brief Minute 0 - 59 */
    ZUCHAR ucSecond;                 /**< @brief Second 0 - 59 */
    ZINT iTzOffset;                  /**< @brief Time zone offset in seconds */
} ST_MTC_SYS_TIME;

/**
 * @brief Print ERROR log with format string information.
 * User can specific log name as the log module prefix
 * Log print level can be set by Mtc_CliDbSetLogLevel.
 *
 * @param [in] pcLogName The log name. Default name is "ZOS" if no log name.
 * @param [in] pcFormat String format.
 * @param [in] ... String vars.
 *
 * @see @ref Mtc_AnyLogInfoStr
 */
MTCFUNC ZVOID Mtc_AnyLogErrStr(ZCHAR *pcLogName, ZCHAR *pcFormat, ...);

/**
 * @brief Print INFO log with format string information.
 * User can specific log name as the log module prefix
 * Log print level can be set by Mtc_CliDbSetLogLevel.
 *
 * @param [in] pcLogName The log name. Default name is "ZOS" if no log name.
 * @param [in] pcFormat String format.
 * @param [in] ... String vars.
 *
 * @see @ref Mtc_AnyLogErrStr
 */
MTCFUNC ZVOID Mtc_AnyLogInfoStr(ZCHAR *pcLogName, ZCHAR *pcFormat, ...);

/**
 * @brief Print DEBUG log with format string information.
 * User can specific log name as the log module prefix
 * Log print level can be set by Mtc_DbSetLogLevel.
 *
 * @param [in] pcLogName The log name. Default name is "ZOS" if no log name.
 * @param [in] pcFormat String format.
 * @param [in] ... String vars.
 *
 * @see @ref Mtc_AnyLogInfoStr
 */
MTCFUNC ZVOID Mtc_AnyLogDbgStr(ZCHAR *pcLogName, ZCHAR *pcFormat, ...);

/**
 * @brief Get local ip count.
 *
 * @return Local ip count successfully, otherwise retrun 0.
 *
 * @see @ref Mtc_GetLclIp
 */
MTCFUNC ZINT Mtc_GetLclIpCnt();

/**
 * @brief Get local ip.
 *
 * @param [in] iIndex Local ip index.
 *
 * @return Local ip successfully, otherwise return loopback address.
 *    the caller must copy it, then use.
 *
 * @see @ref Mtc_GetLclIpCnt
 */
MTCFUNC ZCHAR * Mtc_GetLclIp(ZINT iIndex);

/**
 * @brief Get access network type.
 *
 * @return Access network type successfully, 
 * otherwise return MTC_ANET_UNKNOWN.
 *
 * @see @ref group_def_access_net_type
 */
MTCFUNC ZINT Mtc_GetAccessNetType();

/**
 * @brief Convert time value from ZTIME_T to ST_MTC_SYS_TIME structure.
 *
 * @param [in] zTime Time value.
 * @param [out] pstTime Time value in ST_MTC_SYS_TIME structure.
 *
 * @retval ZOK Convert successfully.
 * @retval ZFAILED Convert failed.
 *
 * @see
 */
MTCFUNC ZINT Mtc_Time2SysTime(ZTIME_T zTime, ST_MTC_SYS_TIME *pstTime);

/**
 * @brief Convert time value from ST_MTC_SYS_TIME structure to ZTIME_T.
 *
 * @param [in] pstTime Time value in ST_MTC_SYS_TIME structure.
 * @param [out] pzTime Time value in ZTIME_T structure.
 *
 * @retval ZOK Convert successfully.
 * @retval ZFAILED Convert failed.
 *
 * @see
 */
MTCFUNC ZINT Mtc_SysTime2Time(ST_MTC_SYS_TIME *pstTime, ZTIME_T *pzTime);

/**
 * @defgroup MtcError MTC error string.
 * @{
 */
/** @brief No environment. MTC maynot initilized or already destroied. */
#define MTC_ERROR_NO_ENV                "Mtc.NoEnv"

/** @brief Invalid state. MTC maynot started. */
#define MTC_ERROR_INV_STATE             "Mtc.InvState"

/** @brief During auth. MTC during authorization. */
#define MTC_ERROR_IN_AUTH               "Mtc.InAuth"

/** @brief Invlaid parameter. */
#define MTC_ERROR_INV_PARM              "Mtc.InvParm"

/** @brief Allocate memory. */
#define MTC_ERROR_ALLOC_MEM             "Mtc.AllocMem"

/** @brief New Object. */
#define MTC_ERROR_NEW_OBJ               "Mtc.NewObj"

/** @brief No Agent. */
#define MTC_ERROR_NO_AGENT              "Mtc.NoAgent"

/** @brief Invalid ID */
#define MTC_ERROR_INV_ID                "Mtc.InvId"

/** @brief No password. */
#define MTC_ERROR_NO_PWD                "Mtc.NoPwd"

/** @brief Subscribe event. */
#define MTC_ERROR_SUB_EVNT              "Mtc.SubEvnt"

/** @brief Provision. */
#define MTC_ERROR_PROVISION             "Mtc.Provision"

/** @brief Authorizaiton failed. */
#define MTC_ERROR_AUTH_FAIL             "Mtc.AuthFail"

/** @brief No account. */
#define MTC_ERROR_NO_ACCOUNT            "Mtc.NoAccount"

/** @brief Expired. */
#define MTC_ERROR_EXPIRED               "Mtc.Expired"

/** @brief No auth code. */
#define MTC_ERROR_NO_AUTH               "Mtc.NoAuth"

/** @brief Internal error. */
#define MTC_ERROR_INTERNAL              "Mtc.Internal"

/** @brief Call initialize connection. */
#define MTC_ERROR_CALL_INIT_CONN        "MtcCall.InitConn"

/** @brief Call initialize session. */
#define MTC_ERROR_CALL_INIT_SESS        "MtcCall.InitSess"

/** @brief Call add audio stream. */
#define MTC_ERROR_CALL_ADD_AUDIO_STRM   "MtcCall.AddAudioStrm"

/** @brief Call add video stream. */
#define MTC_ERROR_CALL_ADD_VIDEO_STRM   "MtcCall.AddVideoStrm"

/** @brief Call no SIP registeration. */
#define MTC_ERROR_CALL_NO_SIP_REG       "MtcCall.NoSipReg"

/** @brief Call exist */
#define MTC_ERROR_CALL_EXIST            "MtcCall.Exist"

/** @brief Call fill SDP. */
#define MTC_ERROR_CALL_FILL_SDP         "MtcCall.FillSdp"

/** @brief Call perform action. */
#define MTC_ERROR_CALL_ACTION           "MtcCall.Action"

/**
 * @}
 */

/** 
 * @brief Get last error.
 *
 * @retval Last error string.
 */
MTCFUNC ZCONST ZCHAR * Mtc_GetLastError(ZFUNC_VOID);

#ifdef __cplusplus
}
#endif

#endif /* _MTC_UTIL_H__ */