• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Unionman Technology Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef VPCODEC_1_0_H_
17 #define VPCODEC_1_0_H_
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 typedef enum vl_codec_id_e {
24     CODEC_ID_NONE,
25     CODEC_ID_VP8,
26     CODEC_ID_H261,
27     CODEC_ID_H263,
28     CODEC_ID_H264, /* must support */
29     CODEC_ID_H265,
30 } vl_codec_id_t;
31 
32 typedef enum vl_img_format_e {
33     IMG_FMT_NONE,
34     IMG_FMT_NV12, /* must support  */
35     IMG_FMT_NV21,
36     IMG_FMT_YV12,
37 } vl_img_format_t;
38 
39 typedef enum vl_frame_type_e {
40     FRAME_TYPE_NONE,
41     FRAME_TYPE_AUTO, /* encoder self-adaptation(default) */
42     FRAME_TYPE_IDR,
43     FRAME_TYPE_I,
44     FRAME_TYPE_P,
45 } vl_frame_type_t;
46 
47 typedef struct {
48     int framerate;
49     int bitrate;
50     int gop; /* max I frame interval */
51 } vl_encoder_param_t;
52 
53 typedef struct {
54     vl_frame_type_t frame_type;
55     int format;
56 } vl_encode_info_t;
57 
58 
59 /**
60  * Getting version information
61  *
62  * @return : version information
63  */
64 const char *vl_get_version(void);
65 
66 /**
67  * init encoder
68  *
69  * @param : codec_id: codec type
70  * @param : width: video width
71  * @param : height: video height
72  * @param : vl_encoder_param_t: encoder param
73  * @param : img_format: image format
74  * @return : if success return encoder handle,else return <= 0
75  */
76 long vl_video_encoder_init(vl_codec_id_t codec_id, int width, int height, vl_encoder_param_t param, \
77     vl_img_format_t img_format);
78 
79 /**
80  * encode video
81  *
82  * @param : handle
83  * @param : vl_encode_info_t : encode info
84  * @param : in: data to be encoded
85  * @param : out: data output,H.264 need header(0x00, 0x00, 0x00, 0x01),
86  *          and format must be I420(apk set param out,through jni,
87  *          so modify "out" in the function,don't change address point)
88  * @param : idr: idr frame flag
89  * @return : if success return encoded data length,else return <= 0
90  */
91 int vl_video_encoder_encode(long handle, vl_encode_info_t info, unsigned char *in, \
92     unsigned char *out, int *idr);
93 
94 /**
95  * destroy encoder
96  *
97  * @param :handle: encoder handle
98  * @return :if success return 1,else return 0
99  */
100 int vl_video_encoder_destory(long handle);
101 
102 #ifdef __cplusplus
103 }
104 #endif
105 
106 #endif /* VPCODEC_1_0_H_ */
107