⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ci.cpp

📁 这是G.723和G.729的音频编解码的源代码
💻 CPP
字号:
// CI.cpp: implementation of the CControlIndication class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "CI.h"
#include "commondef.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CControlIndication::CControlIndication(CSendChannel* pCommandSendChannel, CPortStatus* PortStatus)
									   //:m_pCommandSendChannel(pCommandSendChannel), m_ppcPortStatus(PortStatus)
{
	m_pcTPortStatus = PortStatus;
	m_pcTPortStatus->m_bAddConference = FALSE;
	m_pcTPortStatus->m_bOwnToken = FALSE;
	m_pcTPortStatus->m_bRequestToken = FALSE;
	m_pcTPortStatus->m_bRequestTokenRefused = FALSE;
	m_pcTPortStatus->m_byThisPortWatched=0;
	for(int j=0; j<MAXPORTNUMBER;j++)
		m_pcTPortStatus->m_byWatchingThisPort[j]=0;
	m_pcTPortStatus->m_bWantWatch=FALSE;
	m_pcTPortStatus->m_byThisPortWatching=0;
	m_pcTPortStatus->m_bWantWatchRefused=FALSE;
	m_pCommandSendChannel = pCommandSendChannel;
}

CControlIndication::~CControlIndication()
{
}

//When receiving a new c&i, call this function
//pFrame-------C&I saved in here
//nLength------C&I's length
//bFrameState--This frame is valid
//LPVOID-------Some other data
//这一段程序可能需要加入同步程序
void CControlIndication::CommandCallBack(BYTE* pFrame,int nLength,BOOL bFrameState)
{
	static int nPortCount = 0;
	BYTE i;
	BYTE byFFCode = 0xff;
	BYTE byTempCode=0;
	static BYTE byWatchingPortNumber = 0;

	if(bFrameState == FS_VALID)
	{
		if(pFrame[0]>=1 && pFrame[0]<=31)//Is video quant, Tell all port
		{
			//SendPacketToAllPort
			return;
		}
		else
		{
			switch(pFrame[0])
			{
			case TRequestAddConference:
					if(m_pCommandSendChannel)
					{
						m_pCommandSendChannel->SendData(pFrame, nLength);
						m_pCommandSendChannel->SendData(&byFFCode,1);
					}
				break;

			case TGetAddConferenceAck:
					//Tell User this terminal has added conference right
					m_pcTPortStatus->m_bAddConference = TRUE;
				break;
			case TGetTerminalHaveAddedConference:
					//Tell User all terminal has added conference 
					for(i=0; i<pFrame[1]; i++)//pFrame[1] is the port name's length
					{
						AllTerminalName[nPortCount][i] = (char)pFrame[2+i];//Next is the port name string
						nPortCount++;
					}		
					//Display in userface
					//----------------Do something--------------------
				break;
			case TRequestToken:
					if(m_pCommandSendChannel)
					{
						m_pCommandSendChannel->SendData(pFrame, nLength);
						m_pCommandSendChannel->SendData(&byFFCode,1);
					}
				break;
			case TOwnToken:
					//Tell user this terminal own token
					m_pcTPortStatus->m_bRequestTokenRefused=FALSE;
					m_pcTPortStatus->m_bOwnToken = TRUE;
				break;
			case TRequestTokenRefuse:
					//Tell user this terminal request token have been refused
					m_pcTPortStatus->m_bRequestTokenRefused = TRUE;
					m_pcTPortStatus->m_bOwnToken = FALSE;
				break;
			case TRequestReleaseToken:
					if(m_pCommandSendChannel)
					{
						m_pCommandSendChannel->SendData(pFrame, nLength);
						m_pCommandSendChannel->SendData(&byFFCode,1);
					}
				break;
			case TGetReleaseTokenAck:
					//Tell user have released token sucessuflly
					m_pcTPortStatus->m_bOwnToken = FALSE;
				break;
			case TWantWatch://pFrame[1] record this port want to watching port
					byWatchingPortNumber = pFrame[1];
					//Now send ack CI
					if(m_pCommandSendChannel)
					{
						m_pCommandSendChannel->SendData(pFrame, nLength);
						m_pCommandSendChannel->SendData(&byFFCode,1);
					}
				break;
			case TGetWantWatchAck:
					//Tell user have the termial that it want
					m_pcTPortStatus->m_byThisPortWatched = byWatchingPortNumber;
				break;
			case TGetWantWatchRefuse:
					//Tell user have the termial that it want
					m_pcTPortStatus->m_byThisPortWatched = WANT_WATCH_REFUSED;
				break;
			case TStopWatch:
				break;
			case TGetStopWatchAck:
					//Tell user have the termial that it want
					m_pcTPortStatus->m_byThisPortWatched = 0;
				break;
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -