#ifndef __MPEG2_PS_H__
#define __MPEG2_PS_H__ 1
#include <gpac/avparse.h>
#ifndef GPAC_DISABLE_MPEG2PS
#define MPEG2_PS_START 0x00000100
#define MPEG2_PS_START_MASK 0xffffff00
#define MPEG2_PS_PACKSTART 0x000001BA
#define MPEG2_PS_SYSSTART 0x000001BB
#define MPEG2_PS_END 0x000001B9
#define MPEG12_START_CODE_PREFIX 0x000001
#define MPEG12_PICTURE_START_CODE 0x00000100
#define MPEG12_SLICE_MIN_START 0x00000101
#define MPEG12_SLICE_MAX_START 0x000001af
#define MPEG12_USER_DATA_START_CODE 0x000001b2
#define MPEG12_SEQUENCE_START_CODE 0x000001b3
#define MPEG12_SEQUENCE_ERR_START_CODE 0x000001b4
#define MPEG12_EXT_START_CODE 0x000001b5
#define MPEG12_SEQUENCE_END_START_CODE 0x000001b7
#define MPEG12_GOP_START_CODE 0x000001b8
typedef struct mpeg2ps_ mpeg2ps_t;
typedef enum {
TS_MSEC,
TS_90000,
} mpeg2ps_ts_type_t;
typedef enum {
MPEG_AUDIO_MPEG = 0,
MPEG_AUDIO_AC3 = 1,
MPEG_AUDIO_LPCM = 2,
MPEG_AUDIO_UNKNOWN = 3
} mpeg2ps_audio_type_t;
typedef enum {
MPEG_VIDEO_MPEG1 = 0,
MPEG_VIDEO_MPEG2 = 1,
MPEG_VIDEO_UNKNOWN = 2
} mpeg2ps_video_type_t;
#ifdef __cplusplus
extern "C" {
#endif
mpeg2ps_t *mpeg2ps_init(const char *filename);
void mpeg2ps_close(mpeg2ps_t *ps);
u64 mpeg2ps_get_max_time_msec(mpeg2ps_t *ps);
u32 mpeg2ps_get_video_stream_count(mpeg2ps_t *ps);
const char *mpeg2ps_get_video_stream_name(mpeg2ps_t *ps,
u32 streamno);
mpeg2ps_video_type_t mpeg2ps_get_video_stream_type(mpeg2ps_t *ps,
u32 streamno);
u32 mpeg2ps_get_video_stream_width(mpeg2ps_t *ps, u32 streamno);
u32 mpeg2ps_get_video_stream_height(mpeg2ps_t *ps, u32 streamno);
u32 mpeg2ps_get_video_stream_aspect_ratio(mpeg2ps_t *ps, u32 streamno);
double mpeg2ps_get_video_stream_bitrate(mpeg2ps_t *ps, u32 streamno);
double mpeg2ps_get_video_stream_framerate(mpeg2ps_t *ps, u32 streamno);
Bool mpeg2ps_get_video_frame(mpeg2ps_t *ps,
u32 streamno,
u8 **buffer,
u32 *buflen,
u8 *frame_type,
mpeg2ps_ts_type_t ts_type,
u64 *timestamp);
Bool mpeg2ps_seek_video_frame(mpeg2ps_t *ps, u32 streamno,
u64 msec_timestamp);
u32 mpeg2ps_get_audio_stream_count(mpeg2ps_t *ps);
const char *mpeg2ps_get_audio_stream_name(mpeg2ps_t *ps, u32 streamno);
mpeg2ps_audio_type_t mpeg2ps_get_audio_stream_type(mpeg2ps_t *ps, u32 streamno);
u32 mpeg2ps_get_audio_stream_sample_freq(mpeg2ps_t *ps, u32 streamno);
u32 mpeg2ps_get_audio_stream_channels(mpeg2ps_t *ps, u32 streamno);
u32 mpeg2ps_get_audio_stream_bitrate(mpeg2ps_t *ps, u32 streamno);
Bool mpeg2ps_get_audio_frame(mpeg2ps_t *ps,
u32 streamno,
u8 **buffer,
u32 *buflen,
mpeg2ps_ts_type_t ts_type,
u32 *freq_timestamp,
u64 *msec_timestamp);
Bool mpeg2ps_seek_audio_frame(mpeg2ps_t *ps, u32 streamno,
u64 msec_timestamp);
u64 mpeg2ps_get_ps_size(mpeg2ps_t *ps);
s64 mpeg2ps_get_video_pos(mpeg2ps_t *ps, u32 streamno);
s64 mpeg2ps_get_audio_pos(mpeg2ps_t *ps, u32 streamno);
typedef void (*error_msg_func_t)(int loglevel,
const char *lib,
const char *fmt,
va_list ap);
void mpeg2ps_set_loglevel(int loglevel);
void mpeg2ps_set_error_func(error_msg_func_t func);
#endif
#ifdef __cplusplus
}
#endif
#endif