1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.iailab.netsdk.lib.enumeration;
 
/**
 * 语音编码类型
 *
 * @author 47040
 * @since Created at 2021/5/26 10:25
 */
public enum TALK_CODING_TYPE {
 
    NET_TALK_DEFAULT(0, "无头PCM"),
    NET_TALK_PCM(1, "带头PCM"),
    NET_TALK_G711a(2, "G711a"),
    NET_TALK_AMR(3, "AMR"),
    NET_TALK_G711u(4, "G711u"),
    NET_TALK_G726(5, "G726"),
    NET_TALK_G723_53(6, "G723_53"),
    NET_TALK_G723_63(7, "G723_63"),
    NET_TALK_AAC(8, "AAC"),
    NET_TALK_OGG(9, "OGG"),
    NET_TALK_G729(10, "G729"),
    NET_TALK_MPEG2(11, "MPEG2"),
    NET_TALK_MPEG2_Layer2(12, "MPEG2-Layer2"),
    NET_TALK_G722_1(13, "G.722.1"),
    NET_TALK_ADPCM(21, "ADPCM"),
    NET_TALK_MP3(22, "MP3");
 
    private final int value;
    private final String note;
 
    TALK_CODING_TYPE(int givenValue, String note) {
        this.value = givenValue;
        this.note = note;
    }
 
    public String getNote() {
        return note;
    }
 
    public int getValue() {
        return value;
    }
 
    public static String getNoteByValue(int givenValue) {
        for (TALK_CODING_TYPE enumType : TALK_CODING_TYPE.values()) {
            if (givenValue == enumType.getValue()) {
                return enumType.getNote();
            }
        }
        return null;
    }
 
    public static int getValueByNote(String givenNote) {
        for (TALK_CODING_TYPE enumType : TALK_CODING_TYPE.values()) {
            if (givenNote.equals(enumType.getNote())) {
                return enumType.getValue();
            }
        }
        return -1;
    }
 
    public static TALK_CODING_TYPE getEnum(int value) {
        for (TALK_CODING_TYPE e : TALK_CODING_TYPE.values()) {
            if (e.getValue() == value)
                return e;
        }
        return TALK_CODING_TYPE.NET_TALK_DEFAULT;
    }
}