# If
! Defined (afx_head_2833_h000093b5c358_6f19_475b_a49f_13bfcc9dfe1c00000000ded _)
# Define
Afx_head_2833_h000093b5c358_6f19_475b_a49f_13bfcc9dfe1c00000000ded _
# If _ msc_ver> 1000
# Pragma once
# Endif // _ msc_ver> 1000
Class chead_2833
{
Public:
Bool dispelhead (char *
Cvalue );
Int btodd (char * cvalue );
Char * dtob (int
Nvalue );
Chead_2833 ();
Virtual ~ Chead_2833 ();
Bool get2883head (char *
Bvalue );
Char m_cevent;
Int m_nvolume;
Long m_lduration;
Short int
M_nend;
Short int m_nrest;
PRIVATE:
};
# Endif //
! Defined (afx_head_2833_h000093b5c358_6f19_475b_a49f_13bfcc9dfe1c00000000ded _)
Class implementation:
// Head_2833.cpp: Implementation of the chead_2833
Class.
//
//////////////////////////////////////// //////////////////////////////
# Include "stdafx. H"
# Include "head_2833.h"
//////////////////////////////////////// //////////////////////////////
//
Construction/destruction
//////////////////////////////////////// //////////////////////////////
Chead_2833: chead_2833 ()
{
M_cevent = '/0 ';
M_lduration = 0;
M_nend = 0;
M_nrest = 0;
M_nvolume = 0;
}
Chead_2833 ::~ Chead_2833 ()
{
}
// Decimal to binary
Char * chead_2833: dtob (INT nvalue)
{
Cstring
Res = "";
Char * temp;
Temp =
NULL;
While (nvalue)
{
Sprintf (temp, "% d", nvalue % 2 );
Res + =
Temp;
// Strcat (Res, temp );
Nvalue = nvalue> 1;
}
Res. makereverse ();
Return (lptstr) (lpctstr) RES;
}
// Binary to decimal
Int chead_2833: btodd (char * cvalue)
{
Int
S = 0, M = 1, I = 0, J;
Char K;
While (* cvalue )! = '/0 ')
{
Cvalue ++;
I ++;
J = I;
}
For (I = J; I> 0; I --)
{
Cvalue --;
K = * cvalue;
S = S + (k-48) * m );
M = m * 2;
}
Return S;
}
//-----------------------------------------------------------------------------
//
Function Name: get2883head ()
// Author: lihao, R & D
Department
// Creation date: 2006-12-21
// Description: Get
Infomation head to rfc2833 depand to
M_cevent,
// M_lduration = 0;
// M_nend = 0;
// M_nrest = 0;
// M_nvolume = 0;
//
//
// Params
// Char * bvalue; // a point of Return Value
// Return
Value
//
// Typical usage:
// Char * m_shead;
//
Get2883head (m_shead );
//-----------------------------------------------------------------------------
//
Function
History
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
Bool chead_2833: get2883head (char * bvalue)
{
// Byte
M_bhead [4];
Memset (bvalue, 0, 4 );
Switch (m_cevent)
{
Case
'*':
Bvalue [0] = 10;
Break;
Case
'#':
Bvalue [0] = 11;
Break;
Case
'A ':
Bvalue [0] = 12;
Break;
Case
'B ':
Bvalue [0] = 13;
Break;
Case
'C ':
Bvalue [0] = 14;
Break;
Case
'D ':
Bvalue [0] = 15;
Break;
Default:
Bvalue [0] = m_cEvent-48;
Break;
}
Bvalue [1] = (char) 0xf0;
Bvalue [2] = (char) 0x00;
Bvalue [3] = (char) 0x00;
Return
True;
}
Bool chead_2833: dispelhead (char * cvalue)
{
Byte
Bevent = cvalue [0];
Switch (bevent)
{
Case
10:
M_cevent = '*';
Break;
Case
11:
M_cevent = '#';
Break;
Case
12:
M_cevent = 'a ';
Break;
Case
13:
M_cevent = 'B ';
Break;
Case
14:
M_cevent = 'C ';
Break;
Case
15:
M_cevent = 'D ';
Break;
Default:
M_cevent = 48 + bevent;
Break;
}
Return
True;
}
Class call:
Assume that RTP is used for data transmission.
Chead_2833 head2833;
Head2833.m _ cevent = m_ckey;
Char
R2833buf [4];
Head2833.get2883head (r2833buf); // obtain the 2833 header.
// Char
Rtpbuf [16];
Copymemory (rtpbuf729 + 12, r2833buf, 4 );
For (int
I = 0; I <
5; I ++)
//{
// Sleep (5 );
Paudiocenter-> m_paudiotransmitter-> sendaudiopacket (rtpbuf729, 16, m_nrfc2833type );
//}