1 package org.sipdroid.media.codecs; |
|
2 |
|
3 public class GSM extends Codec { |
|
4 |
|
5 public static final CodecInfo mCodecInfo = new CodecInfo(); |
|
6 |
|
7 static { |
|
8 System.loadLibrary("gsm"); |
|
9 mCodecInfo.displayName = "GSM"; |
|
10 mCodecInfo.rtpPayloadName = "GSM"; |
|
11 mCodecInfo.description = "GSM Full Rate codec"; |
|
12 mCodecInfo.rtpPayloadCode = 3; |
|
13 mCodecInfo.samplingRate = 8000; |
|
14 mCodecInfo.rtpSampleDivider = 1; |
|
15 mCodecInfo.minFrameTimeMsecs = 20; |
|
16 mCodecInfo.codecFrameSize = 33; |
|
17 CodecManager.registerAudioCodec(new GSM()); |
|
18 } |
|
19 |
|
20 public class GSMContext extends Context { |
|
21 public long ctx; |
|
22 } |
|
23 |
|
24 @Override |
|
25 public Context initDecoder() { |
|
26 GSMContext decoderCtx = new GSMContext(); |
|
27 decoderCtx.ctx = GSMJNI.create(); |
|
28 return decoderCtx; |
|
29 } |
|
30 |
|
31 @Override |
|
32 public Context initEncoder() { |
|
33 GSMContext encoderCtx = new GSMContext(); |
|
34 encoderCtx.ctx = GSMJNI.create(); |
|
35 return encoderCtx; |
|
36 } |
|
37 |
|
38 @Override |
|
39 public void cleanDecoder(Context ctx) { |
|
40 GSMJNI.destroy(((GSMContext)ctx).ctx); |
|
41 } |
|
42 |
|
43 @Override |
|
44 public void cleanEncoder(Context ctx) { |
|
45 GSMJNI.destroy(((GSMContext)ctx).ctx); |
|
46 } |
|
47 |
|
48 @Override |
|
49 public int decode(Context ctx, byte[] indata, int inoffset, int size, |
|
50 short[] outsample, int outoffset) { |
|
51 return GSMJNI.decode(((GSMContext)ctx).ctx, indata, inoffset, outsample, outoffset); |
|
52 } |
|
53 |
|
54 @Override |
|
55 public int encode(Context ctx, short[] insample, int inoffset, int size, |
|
56 byte[] outdata, int outoffset) { |
|
57 GSMJNI.encode(((GSMContext)ctx).ctx, insample, inoffset, outdata, outoffset); |
|
58 return size; |
|
59 } |
|
60 |
|
61 @Override |
|
62 public CodecInfo getInfo() { |
|
63 return mCodecInfo; |
|
64 } |
|
65 |
|
66 static public void load(){ |
|
67 } |
|
68 } |
|