📄 gsm06_10_codec.c
字号:
/*
* GSM 06.10 Plugin codec for OpenH323/OPAL
*
* Copyright (C) 2004 Post Increment, All Rights Reserved
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Open H323 Library.
*
* The Initial Developer of the Original Code is Post Increment
*
* Contributor(s): ______________________________________.
*
* $Log: gsm06_10_codec.c,v $
* Revision 1.14 2005/07/15 10:08:59 rogerhardiman
* Fix SF bug 1237507. Windows uses malloc.h. Linux and FreeBSD uses stdlib.h
* Wrap #include with _WIN32 to be consistent with malloc.h in pwlib.
*
* Revision 1.13 2004/12/20 23:17:45 csoutheren
* Added stdlib.h to all plugins to keep FreeBSD happy
* Thanks to Kevin Oberman
*
* Revision 1.12 2004/08/24 14:15:12 csoutheren
* Fixed potential problems with MS-GSM
*
* Revision 1.11 2004/06/17 22:04:40 csoutheren
* Changed codec version number to be sensible rather than string $Ver$
*
* Revision 1.10 2004/05/26 03:56:02 csoutheren
* Fixed codecs using compare functions for non-standard capability matching
*
* Revision 1.9 2004/05/18 22:24:24 csoutheren
* Initiali support for embedded codecs
*
* Revision 1.8 2004/05/11 14:07:57 csoutheren
* Fixed problems with non-standard codecs using comparefunc
*
* Revision 1.7 2004/05/11 12:45:09 rjongbloed
* Fixed codec name to be compatible with standard OpalMediaFormat
*
* Revision 1.6 2004/05/10 10:14:17 csoutheren
* Removed warnings under Linux
*
* Revision 1.5 2004/05/05 13:22:09 rjongbloed
* Fixed MSVC warning
*
* Revision 1.4 2004/05/04 12:45:10 csoutheren
* Added MS-GSM
*
* Revision 1.3 2004/05/03 14:36:44 rjongbloed
* Converted everything to be codec plug in freindly
* Removed GSM and G.729 as now plug ins are "the way"!
*
* Revision 1.2 2004/04/09 12:24:18 csoutheren
* Renamed h323plugin.h to opalplugin.h, and modified everything else
* as required
*
* Revision 1.1 2004/04/04 14:16:42 csoutheren
* Initial version
*
*
*/
#include <opalplugin.h>
PLUGIN_CODEC_IMPLEMENT(GSM_0610)
#include <stdlib.h>
#ifdef _WIN32
#include <malloc.h>
#endif
#include <string.h>
#include "inc/gsm.h"
#define BITS_PER_SECOND 13200
#define BYTES_PER_FRAME 33
#define MSGSM_BYTES_PER_FRAME 65
#define SAMPLES_PER_FRAME 160
#define MSGSM_SAMPLES_PER_FRAME 320
#define MAX_FRAMES_PER_PACKET 7
#define PREF_FRAMES_PER_PACKET 1
#define PAYLOAD_CODE 3
/////////////////////////////////////////////////////////////////////////////
#ifdef _MSC_VER
#pragma warning(disable:4100)
#endif
static void * create_codec(const struct PluginCodec_Definition * codec)
{
int opt = (int)codec->userData;
struct gsm_state * context = gsm_create();
gsm_option(context, GSM_OPT_WAV49, &opt);
return context;
}
static void destroy_codec(const struct PluginCodec_Definition * codec, void * _context)
{
struct gsm_state * context = (struct gsm_state *)_context;
gsm_destroy(context);
}
static int codec_encoder(const struct PluginCodec_Definition * codec,
void * _context,
const void * from,
unsigned * fromLen,
void * to,
unsigned * toLen,
unsigned int * flag)
{
struct gsm_state * context = (struct gsm_state *)_context;
gsm_encode(context, (void *)from, to);
*toLen = BYTES_PER_FRAME;
return 1;
}
static int codec_decoder(const struct PluginCodec_Definition * codec,
void * _context,
const void * from,
unsigned * fromLen,
void * to,
unsigned * toLen,
unsigned int * flag)
{
struct gsm_state * context = (struct gsm_state *)_context;
if (*fromLen < BYTES_PER_FRAME)
return 0;
gsm_decode(context, (void *)from, to);
*toLen = SAMPLES_PER_FRAME * 2;
return 1;
}
/////////////////////////////////////////////////////////////////////////////
static int codec_msgsm_encoder(const struct PluginCodec_Definition * codec,
void * _context,
const void * from,
unsigned * fromLen,
void * to,
unsigned * toLen,
unsigned int * flag)
{
struct gsm_state * context = (struct gsm_state *)_context;
if (*fromLen < (MSGSM_SAMPLES_PER_FRAME*2) || *toLen < MSGSM_BYTES_PER_FRAME)
return 0;
gsm_encode(context, (short *)from, (unsigned char *)to);
gsm_encode(context, ((short *)from)+160, ((unsigned char *)to)+32);
*toLen = MSGSM_BYTES_PER_FRAME;
return 1;
}
static int codec_msgsm_decoder(const struct PluginCodec_Definition * codec,
void * _context,
const void * from,
unsigned * fromLen,
void * to,
unsigned * toLen,
unsigned int * flag)
{
struct gsm_state * context = (struct gsm_state *)_context;
if (*fromLen < MSGSM_BYTES_PER_FRAME || *toLen < (MSGSM_SAMPLES_PER_FRAME*2))
return 0;
gsm_decode(context, (unsigned char *)from, (short *)to);
gsm_decode(context, ((unsigned char *)from)+33, ((short *)to)+160);
*toLen = MSGSM_SAMPLES_PER_FRAME * 2;
return 1;
}
/////////////////////////////////////////////////////////////////////////////
static struct PluginCodec_information licenseInfo = {
1081086550, // timestamp = Sun 04 Apr 2004 01:49:10 PM UTC =
"Craig Southeren, Post Increment", // source code author
"1.1", // source code version
"craigs@postincrement.com", // source code email
"http://www.postincrement.com", // source code URL
"Copyright (C) 2004 by Post Increment, All Rights Reserved", // source code copyright
"MPL 1.0", // source code license
PluginCodec_License_MPL, // source code license
"GSM 06.10 Full-Rate", // codec description
"Jutta Degener and Carsten Bormann", // codec author
"Version 10", // codec version
"jutta@cs.tu-berlin.de\ncabo@cs.tu-berlin.de", // codec email
"http://kbs.cs.tu-berlin.de/~jutta/toast.html", // codec URL
"Copyright 1992, 1993, 1994 by Jutta Degener and Carsten Bormann, Technische Universitaet Berlin", // codec copyright information
NULL, // codec license
PluginCodec_Licence_None // codec license code
};
/////////////////////////////////////////////////////////////////////////////
static const char L16Desc[] = { "L16" };
static const char gsm0610[] = { "GSM-06.10" };
static const char msGSM[] = { "MS-GSM" };
static const char sdpGSM[] = { "gsm" };
static const char sdpMSGSM[] = { "msgsm" };
static struct PluginCodec_H323AudioGSMData gsmCaps = {
0, // int comfortNoise:1;
0, // int scrambled:1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -