GsmCompress.cpp
资源名称:视频会议系统.rar [点击查看]
上传用户:popouu88
上传日期:2013-02-11
资源大小:2894k
文件大小:1k
源码类别:
IP电话/视频会议
开发平台:
Visual C++
- #include "....Stdafx.h"
- #include "GsmCompress.h"
- #pragma comment(lib,"Client/Sound/gsm.lib")
- CGsmCompress::CGsmCompress()
- {
- m_hGsm = NULL;
- m_hGsm = gsm_create();
- *( int * )this->compress_buffer = CCompress::GSM610;
- this->type = CCompress::GSM610;
- }
- CGsmCompress::~CGsmCompress()
- {
- if( m_hGsm != NULL )
- {
- gsm_destroy( m_hGsm );
- m_hGsm = NULL;
- }
- }
- char * CGsmCompress::Compress(char* src ,int * srclen )
- {
- if( m_hGsm == NULL )
- return FALSE;
- gsm_frame dst_gsm;
- int i , l = 0;
- char * now = this->compress_buffer + sizeof( int );
- for (i = 0 ; i < * srclen; i += 160)
- {
- gsm_encode( m_hGsm , (short*)(src + i), dst_gsm);
- memcpy( now + l, dst_gsm, sizeof(dst_gsm));
- l += sizeof(dst_gsm);
- }
- *srclen = l + sizeof( int );
- return this->compress_buffer;
- }
- char * CGsmCompress::UnCompress(char* src,int * srclen )
- {
- if( m_hGsm == NULL )
- return FALSE;
- gsm_signal dst_gsm[160];
- int i , l = 0;
- src += sizeof( int );
- * srclen -= sizeof( int );
- for (i = 0; i < * srclen; i += sizeof(gsm_frame) )
- {
- gsm_decode(m_hGsm , (gsm_byte*)src + i, dst_gsm);
- memcpy(this->uncompress_buffer + l, dst_gsm, sizeof(dst_gsm));
- l += 160;
- }
- *srclen = l;
- return this->uncompress_buffer;
- }