MWCapture SDK Linux  3.3.1.LAST_SVN_COMMIT_NUM
mw_mp4.h
1 // CONFIDENTIAL and PROPRIETARY software of Magewell Electronics Co., Ltd.
3 // Copyright (c) 2011-2020 Magewell Electronics Co., Ltd. (Nanjing)
4 // All rights reserved.
5 // This copyright notice MUST be reproduced on all authorized copies.
7 
8 #ifndef MW_MP4_H
9 #define MW_MP4_H
10 
11 #include <stdint.h>
12 #if !defined( _WIN32 )
13 #include <stdbool.h>
14 #endif
15 
16 #ifdef _WIN32
17 #ifdef MW_MP4_EXPORTS
18 #define MW_MP4_API __declspec(dllexport)
19 #else
20 #define MW_MP4_API __declspec(dllimport)
21 #endif
22 #else
23 #define MW_MP4_API
24 #endif
25 
26 typedef struct _mw_mp4_handle_t{int32_t r;} *mw_mp4_handle_t;
27 
28 typedef enum _mw_mp4_status
29 {
30  MW_MP4_STATUS_SUCCESS = 0,
31  MW_MP4_STATUS_UNEXPECTED_ERROR,
32  MW_MP4_STATUS_INVALID_PARAM,
33 } mw_mp4_status_t;
34 
35 typedef enum _mw_mp4_video_type {
36  MW_MP4_VIDEO_TYPE_UNKNOWN = 0,
37  MW_MP4_VIDEO_TYPE_H264 = 1,
38  MW_MP4_VIDEO_TYPE_HEVC = 2,
39  MW_MP4_VIDEO_TYPE_H265 = MW_MP4_VIDEO_TYPE_HEVC
40 }mw_mp4_video_type_t;
41 
43  uint8_t* sps; // can be nullptr if it's contained in the stream
44  int16_t sps_size; // can be 0 if it's contained in the stream
45  uint8_t* pps; // can be nullptr if it's contained in the stream
46  int16_t pps_size; // can be 0 if it's contained in the stream
48 
50  uint8_t* sps; // can be nullptr if it's contained in the stream
51  int16_t sps_size; // can be 0 if it's contained in the stream
52  uint8_t* pps; // can be nullptr if it's contained in the stream
53  int16_t pps_size; // can be 0 if it's contained in the stream
54  uint8_t* vps; // can be nullptr if it's contained in the stream
55  int16_t vps_size; // can be 0 if it's contained in the stream
57 
58 typedef struct _mw_mp4_video_info {
59  mw_mp4_video_type_t codec_type;
60  uint32_t timescale;
61  uint16_t width;
62  uint16_t height;
63 
64  union{
67  };
69 
70 typedef enum _mw_mp4_audio_type {
71  MW_MP4_AUDIO_TYPE_UNKNOWN = 0,
72  MW_MP4_AUDIO_TYPE_AAC = 1,
73  MW_MP4_AUDIO_TYPE_ADTS_AAC = 2
74 }mw_mp4_audio_codec_t;
75 
76 typedef struct _mw_mp4_audio_info {
77  mw_mp4_audio_codec_t codec_type;
78  uint32_t timescale;
79  uint16_t sample_rate; // can be 0 if codec is aac with adts
80  uint16_t channels; // can be 0 if codec is aac with adts
81  uint8_t profile; // can be 0 if codec is aac with adts
83 
84 typedef enum _mw_mp4_subtitle_type {
85  MW_MP4_SUBTITLE_TYPE_UNKNOWN = 0,
86  MW_MP4_SUBTITLE_TYPE_CC608 = 1,
87  MW_MP4_SUBTITLE_TYPE_CC708 = 2
88 }mw_mp4_subtitle_type_t;
89 
90 typedef struct _mw_mp4_subtitle_info {
91  mw_mp4_subtitle_type_t codec_type;
92  uint32_t timescale;
94 
95 #ifdef __cplusplus
96 extern "C"
97 {
98 #endif
99 
106 MW_MP4_API
107 mw_mp4_handle_t mw_mp4_open(const char * p_path);
108 
116 MW_MP4_API
117 mw_mp4_status_t mw_mp4_set_video(mw_mp4_handle_t handle, const mw_mp4_video_info_t* p_info);
118 
126 MW_MP4_API
127 mw_mp4_status_t mw_mp4_set_audio(mw_mp4_handle_t handle, const mw_mp4_audio_info_t* p_info);
128 
136 MW_MP4_API
137 mw_mp4_status_t mw_mp4_set_subtitle(mw_mp4_handle_t handle, const mw_mp4_subtitle_info_t* p_info);
138 
148 MW_MP4_API
149 mw_mp4_status_t mw_mp4_write_video(mw_mp4_handle_t handle, const uint8_t * p_stream, uint32_t size, uint64_t timestamp);
150 
160 MW_MP4_API
161 mw_mp4_status_t mw_mp4_write_audio(mw_mp4_handle_t handle, const uint8_t * p_stream, uint32_t size, uint64_t timestamp);
162 
172 MW_MP4_API
173 mw_mp4_status_t mw_mp4_write_subtitle(mw_mp4_handle_t handle, const uint8_t * p_stream, uint32_t size, uint64_t timestamp);
174 
181 MW_MP4_API
182 mw_mp4_status_t mw_mp4_close(mw_mp4_handle_t handle);
183 
191 MW_MP4_API
192 mw_mp4_status_t mw_mp4_repair(const char * p_path, bool del);
193 #ifdef __cplusplus
194 }
195 #endif
196 #endif
MW_MP4_API mw_mp4_status_t mw_mp4_write_video(mw_mp4_handle_t handle, const uint8_t *p_stream, uint32_t size, uint64_t timestamp)
MW_MP4_API mw_mp4_status_t mw_mp4_set_audio(mw_mp4_handle_t handle, const mw_mp4_audio_info_t *p_info)
Definition: mw_mp4.h:90
Definition: mw_mp4.h:76
MW_MP4_API mw_mp4_status_t mw_mp4_set_subtitle(mw_mp4_handle_t handle, const mw_mp4_subtitle_info_t *p_info)
Definition: mw_mp4.h:42
MW_MP4_API mw_mp4_status_t mw_mp4_set_video(mw_mp4_handle_t handle, const mw_mp4_video_info_t *p_info)
Definition: mw_mp4.h:58
MW_MP4_API mw_mp4_status_t mw_mp4_repair(const char *p_path, bool del)
MW_MP4_API mw_mp4_handle_t mw_mp4_open(const char *p_path)
Definition: mw_mp4.h:49
MW_MP4_API mw_mp4_status_t mw_mp4_write_audio(mw_mp4_handle_t handle, const uint8_t *p_stream, uint32_t size, uint64_t timestamp)
MW_MP4_API mw_mp4_status_t mw_mp4_write_subtitle(mw_mp4_handle_t handle, const uint8_t *p_stream, uint32_t size, uint64_t timestamp)
Definition: mw_mp4.h:26
MW_MP4_API mw_mp4_status_t mw_mp4_close(mw_mp4_handle_t handle)