Blame view

LiveChat/SDK/include/grape/zmf_codec.h 4.77 KB
9f17d59e   陈明泉   no message
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
  #ifndef __ZMF_CODEC_H__
  #define __ZMF_CODEC_H__
  
  /**
   * @file zmf_codec.h
   * @brief ZMF codec interfaces
   */
  
  #ifdef __cplusplus
  extern "C" {
  #endif
  /**
   * @brief Parameters of video codec.
   */
  
  typedef struct {
      /* 'Base','Main', 'Extd', 'High' */
      char                    cProfile[4];
      /* '10','1b','11','12',...,'51' */
      char                    cLevel[2];
      char                    bErrorConcealOn;
      char                    bSmallNalu;
  } ZmfVideoCodecH264;
  
  typedef struct {
      char                    bPictureLossIndicationOn;
      char                    feedbackModeOn;
      char                    bErrorConcealOn;
  } ZmfVideoCodecVP8;
  
  typedef union {
      ZmfVideoCodecH264       H264;
      ZmfVideoCodecVP8        VP8;
  } ZmfVideoCodecSpecific;
  
  typedef struct {
      /* video settings */
      unsigned                width;
      unsigned                height;
      /* kbps */
      unsigned                startBitrate;
      unsigned                maxBitrate;
      unsigned                minBitrate;
      unsigned                maxFramerate;
      ZmfVideoCodecSpecific   codecSpecific;
  } ZmfVideoCodec;
  /**
   * @}
   */
  
  /**
   * @brief Parameters of audio codec.
   */
  
  typedef struct {
      unsigned                bandMode;
  } ZmfAudioCodecAMR;
  
  typedef union {
      ZmfAudioCodecAMR        AMR;
  } ZmfAudioCodecSpecific;
  
  typedef struct {
      unsigned                sampleRate;
      unsigned                bitrate;
      ZmfAudioCodecSpecific   codecSpecific;
  } ZmfAudioCodec;
  /**
   * @}
   */
  
  typedef union {
      ZmfVideoCodec           video;
      ZmfAudioCodec           audio;
  } ZmfCodec;
  
  typedef enum {
      ZmfCodecKeyFrame = 0,
      ZmfCodecBitrate,
      ZmfCodecFramerate,
      ZmfAmrBandMode,
      /* optional */
      ZmfCodecWidth,
      ZmfCodecHeight,
      ZmfCodecPacketLoss,
      ZmfCodecRtt,
  } ZmfCodecKey;
  
  typedef void (*ZmfCodecOut)(void* user_data, const char* buf, unsigned length, void* cookie, int bLastFrag);
  
  /**
   * @brief Type of Codec class.
   */
  typedef struct {
      /**
       * @brief Create new codec instance
       * @param callback The codec receive callback
       * @param user_data The callback user data
       * @return  0  on succeed, otherwise failed.
       */
      void* (*codecNew)(const char* codecName, ZmfCodecOut callback, void* user_data);
  
      /**
       * @brief execute codec instance
       * @param handle  The codec instance pointer.
       * @param in      The source data pointer. 
       * @param in_len  The byte count of in
       * @return  0  on succeed, otherwise failed.
       */
      int (*codecDo)(void *handle, void* in, unsigned in_len, void* cookie, int bLastFrag);
  
      /**
       * @brief reset codec instance
       * @param handle  The codec instance pointer.
       * @param settings The codec settings parameters. 
       * @return  0  on succeed, otherwise failed.
       */
      int (*codecReset)(void *handle, ZmfCodec* settings);
  
      /**
       * @brief set codec dynamic parameters.
       * @param handle    The codec instance pointer.
       * @param key       The name of parameters @ref ZmfCodecKey
       * @param value     The value of parameters. 
       * @param value_size  The bytes of value 
       * @return  0  on succeed, otherwise failed.
       */
      int (*codecSet)(void *handle, ZmfCodecKey key, const void *value, int value_size);
  
      /**
       * @brief get codec dynamic parameters, is optional.
       * @param handle    The codec instance pointer.
       * @param key       The name of parameters @ref ZmfCodecKey
       * @param value     The value of parameters. 
       * @param value_size  The bytes of value 
       * @return  0  on succeed, otherwise failed.
       */
      int (*codecGet)(void *handle, ZmfCodecKey key, void *value, int value_size);
  
      /**
       * @brief delete codec instance.
       * @param handle    The codec instance pointer.
       * @return  0  on succeed, otherwise failed.
       */
      int (*codecDelete)(void *handle);
  } ZmfCodecClass;
  
  /**
   * @}
   */
  
  /**
   * @brief register external Codec 
   * @param  codecName      The codec name, must keep valid globally
   * @param  ZmfCodecClass   The codec class @ref ZmfCodecClass, must keep valid globally.
   * @return  0  on succeed, otherwise failed.
   */
  int Zmf_CodecRegister(const char* codecName, const ZmfCodecClass *klass);
  
  /**
   * @brief Get Codec 
   * @param  codecName        The codec name,liking com.juphoon.H264.decoder
   * @param  ZmfCodecClass    The codec class @ref ZmfCodecClass.
   * @return  0  on succeed, otherwise failed.
   */
  const ZmfCodecClass* Zmf_CodecGetClass(const char* codecName);
  
  /**
   * @brief Get list of codec name
   * after call, *count is the number of codec.
   * @param  codecNames      The codec name array 
   * @param  count           the array size of codecNames
   * @return size of codecNames on succeed, otherwise failed.
   */
  int Zmf_CodecGetList(const char* codecNames[], int *count);
  
  #ifdef __cplusplus
  }
  #endif /* __cplusplus */
  
  #endif