1 | LoadedCodec gsm_codec;
|
2 | gsm_codec.lIsVad = 0;
|
3 | int gsm_available = 1;
|
4 |
|
5 | // Load the used codec
|
6 | codec_status = LoadUSCCodecByNumber(&gsm_codec, 3);
|
7 | if(codec_status < 0)
|
8 | {
|
9 | T.Trace(TraceInfo, __FUNCTION__"++. GSM: Unable to load codec\n");
|
10 | gsm_available = -1;
|
11 | }
|
12 | // Allocate memory for the codec
|
13 | codec_status = USCCodecAllocInfo(&gsm_codec.uscParams);
|
14 | if(codec_status < 0)
|
15 | {
|
16 | T.Trace(TraceInfo, __FUNCTION__"++. GSM: Could not allocate CodecInfo\n");
|
17 | gsm_available = -1;
|
18 | }
|
19 | // Get CodecInfo
|
20 | codec_status = USCCodecGetInfo(&gsm_codec.uscParams);
|
21 | if(codec_status < 0)
|
22 | {
|
23 | T.Trace(TraceInfo, __FUNCTION__"++. GSM: Could not get CodecInfo\n");
|
24 | gsm_available = -1;
|
25 | }
|
26 | // Get Params by format
|
27 | codec_status = GetUSCCodecParamsByFormat(&gsm_codec,BY_NAME);
|
28 | if(codec_status < 0)
|
29 | {
|
30 | T.Trace(TraceInfo, __FUNCTION__"++. GSM: CodecInfoByFormat got successful\n");
|
31 | gsm_available = -1;
|
32 | }
|
33 | SetUSCEncoderParams(&gsm_codec.uscParams);
|
34 | gsm_codec.uscParams.nChannels = 1;
|
35 | // allocate memory for the codec
|
36 | codec_status = USCCodecAlloc(&gsm_codec.uscParams);
|
37 | if(codec_status < 0)
|
38 | {
|
39 | T.Trace(TraceInfo, __FUNCTION__"++. GSM: USCCodecAlloc() failed\n");
|
40 | gsm_available = -1;
|
41 | }
|
42 | // init the Encoder
|
43 | codec_status = USCEncoderInit(&gsm_codec.uscParams);
|
44 | if(codec_status < 0)
|
45 | {
|
46 | T.Trace(TraceInfo, __FUNCTION__"++. GSM: EncoderInit not successful\n");
|
47 | gsm_available = -1;
|
48 | }
|
49 |
|
50 | char outbuffer_lin[1000];
|
51 | char outbuffer[1000];
|
52 | char* p_out = outbuffer_lin;
|
53 | char* p_in = (char*)(datalist->item[tmp_session->data_index].data);
|
54 | int cvtLen = 160;//RTP_PACKETSIZE * tmp_session->packetsize;
|
55 | int outlen = 0;
|
56 |
|
57 | codec_status = USC_CvtToLiniar(&gsm_codec.uscParams, 6, &p_in, &cvtLen, &p_out, &outlen);
|
58 | if(codec_status < 0)
|
59 | T.Trace(TraceInfo, __FUNCTION__"++. GSM: USC_CvtToLinear was not successful\n");
|
60 |
|
61 | outlen = encode(&gsm_codec.uscParams, (char*)(outbuffer_lin), outbuffer, outlen, 500);
|