2008-02-22 09:09:46 +00:00
|
|
|
#ifndef MPLAYER_DEMUXER_H
|
|
|
|
#define MPLAYER_DEMUXER_H
|
2001-04-23 16:12:21 +00:00
|
|
|
|
2008-06-17 09:09:36 +00:00
|
|
|
#include <sys/types.h>
|
2008-03-05 23:32:01 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "stream/stream.h"
|
2008-07-30 12:01:30 +00:00
|
|
|
#ifdef CONFIG_ASS
|
2006-07-07 18:26:51 +00:00
|
|
|
#include "libass/ass_types.h"
|
|
|
|
#endif
|
|
|
|
|
2001-04-26 20:43:12 +00:00
|
|
|
#define MAX_PACKS 4096
|
2008-08-03 15:21:40 +00:00
|
|
|
#ifdef CONFIG_TV_BSDBT848
|
2002-03-27 12:12:24 +00:00
|
|
|
#define MAX_PACK_BYTES 0x2000000
|
|
|
|
#else
|
2001-04-26 20:43:12 +00:00
|
|
|
#define MAX_PACK_BYTES 0x800000
|
2002-03-27 12:12:24 +00:00
|
|
|
#endif
|
2001-04-23 16:12:21 +00:00
|
|
|
|
|
|
|
#define DEMUXER_TYPE_UNKNOWN 0
|
|
|
|
#define DEMUXER_TYPE_MPEG_ES 1
|
|
|
|
#define DEMUXER_TYPE_MPEG_PS 2
|
|
|
|
#define DEMUXER_TYPE_AVI 3
|
|
|
|
#define DEMUXER_TYPE_AVI_NI 4
|
|
|
|
#define DEMUXER_TYPE_AVI_NINI 5
|
|
|
|
#define DEMUXER_TYPE_ASF 6
|
2001-08-12 01:58:05 +00:00
|
|
|
#define DEMUXER_TYPE_MOV 7
|
2001-11-04 16:57:09 +00:00
|
|
|
#define DEMUXER_TYPE_VIVO 8
|
2001-11-09 23:46:06 +00:00
|
|
|
#define DEMUXER_TYPE_TV 9
|
2001-11-24 23:58:12 +00:00
|
|
|
#define DEMUXER_TYPE_FLI 10
|
2001-12-26 22:57:51 +00:00
|
|
|
#define DEMUXER_TYPE_REAL 11
|
2001-12-27 02:08:31 +00:00
|
|
|
#define DEMUXER_TYPE_Y4M 12
|
2001-12-27 21:24:56 +00:00
|
|
|
#define DEMUXER_TYPE_NUV 13
|
2002-01-16 03:25:07 +00:00
|
|
|
#define DEMUXER_TYPE_FILM 14
|
2002-02-01 05:35:16 +00:00
|
|
|
#define DEMUXER_TYPE_ROQ 15
|
2002-02-06 20:16:35 +00:00
|
|
|
#define DEMUXER_TYPE_MF 16
|
2002-02-14 13:04:35 +00:00
|
|
|
#define DEMUXER_TYPE_AUDIO 17
|
2002-03-16 14:32:03 +00:00
|
|
|
#define DEMUXER_TYPE_OGG 18
|
2002-06-11 14:29:51 +00:00
|
|
|
#define DEMUXER_TYPE_RAWAUDIO 20
|
2002-08-05 00:39:07 +00:00
|
|
|
#define DEMUXER_TYPE_RTP 21
|
2002-08-05 17:21:35 +00:00
|
|
|
#define DEMUXER_TYPE_RAWDV 22
|
2002-09-10 21:50:03 +00:00
|
|
|
#define DEMUXER_TYPE_PVA 23
|
2002-09-13 18:58:14 +00:00
|
|
|
#define DEMUXER_TYPE_SMJPEG 24
|
2002-12-22 21:01:01 +00:00
|
|
|
#define DEMUXER_TYPE_XMMS 25
|
2003-01-22 23:51:04 +00:00
|
|
|
#define DEMUXER_TYPE_RAWVIDEO 26
|
2003-01-23 02:12:15 +00:00
|
|
|
#define DEMUXER_TYPE_MPEG4_ES 27
|
2003-01-28 00:12:23 +00:00
|
|
|
#define DEMUXER_TYPE_GIF 28
|
2003-03-16 20:13:28 +00:00
|
|
|
#define DEMUXER_TYPE_MPEG_TS 29
|
2003-04-04 15:38:46 +00:00
|
|
|
#define DEMUXER_TYPE_H264_ES 30
|
2003-04-30 11:39:32 +00:00
|
|
|
#define DEMUXER_TYPE_MATROSKA 31
|
2003-04-30 19:50:46 +00:00
|
|
|
#define DEMUXER_TYPE_REALAUDIO 32
|
2003-06-09 00:24:49 +00:00
|
|
|
#define DEMUXER_TYPE_MPEG_TY 33
|
2003-12-08 19:33:38 +00:00
|
|
|
#define DEMUXER_TYPE_LMLM4 34
|
2004-04-11 14:26:04 +00:00
|
|
|
#define DEMUXER_TYPE_LAVF 35
|
2004-04-12 14:19:12 +00:00
|
|
|
#define DEMUXER_TYPE_NSV 36
|
2004-12-29 19:51:56 +00:00
|
|
|
#define DEMUXER_TYPE_VQF 37
|
2005-02-13 13:39:19 +00:00
|
|
|
#define DEMUXER_TYPE_AVS 38
|
2005-06-13 20:40:29 +00:00
|
|
|
#define DEMUXER_TYPE_AAC 39
|
2005-07-10 17:14:12 +00:00
|
|
|
#define DEMUXER_TYPE_MPC 40
|
2005-08-05 19:57:47 +00:00
|
|
|
#define DEMUXER_TYPE_MPEG_PES 41
|
2005-08-26 17:40:02 +00:00
|
|
|
#define DEMUXER_TYPE_MPEG_GXF 42
|
2006-09-17 09:32:28 +00:00
|
|
|
#define DEMUXER_TYPE_NUT 43
|
2007-04-14 10:03:42 +00:00
|
|
|
#define DEMUXER_TYPE_LAVF_PREFERRED 44
|
2007-12-04 13:05:25 +00:00
|
|
|
#define DEMUXER_TYPE_RTP_NEMESI 45
|
2002-09-13 18:58:14 +00:00
|
|
|
|
2002-02-20 16:59:25 +00:00
|
|
|
// This should always match the higest demuxer type number.
|
|
|
|
// Unless you want to disallow users to force the demuxer to some types
|
2002-03-27 12:12:24 +00:00
|
|
|
#define DEMUXER_TYPE_MIN 0
|
2007-12-04 13:05:25 +00:00
|
|
|
#define DEMUXER_TYPE_MAX 45
|
2002-02-20 16:59:25 +00:00
|
|
|
|
|
|
|
#define DEMUXER_TYPE_DEMUXERS (1<<16)
|
2002-02-21 13:14:52 +00:00
|
|
|
// A virtual demuxer type for the network code
|
|
|
|
#define DEMUXER_TYPE_PLAYLIST (2<<16)
|
|
|
|
|
2001-04-23 16:12:21 +00:00
|
|
|
|
2006-04-24 10:36:29 +00:00
|
|
|
#define MP_NOPTS_VALUE (-1LL<<63) //both int64_t and double should be able to represent this exactly
|
2001-04-23 16:12:21 +00:00
|
|
|
|
|
|
|
|
2002-11-16 03:42:14 +00:00
|
|
|
// DEMUXER control commands/answers
|
|
|
|
#define DEMUXER_CTRL_NOTIMPL -1
|
|
|
|
#define DEMUXER_CTRL_DONTKNOW 0
|
|
|
|
#define DEMUXER_CTRL_OK 1
|
|
|
|
#define DEMUXER_CTRL_GUESS 2
|
|
|
|
#define DEMUXER_CTRL_GET_TIME_LENGTH 10
|
|
|
|
#define DEMUXER_CTRL_GET_PERCENT_POS 11
|
2005-04-03 14:08:28 +00:00
|
|
|
#define DEMUXER_CTRL_SWITCH_AUDIO 12
|
2006-11-07 22:51:18 +00:00
|
|
|
#define DEMUXER_CTRL_RESYNC 13
|
2006-11-16 21:23:06 +00:00
|
|
|
#define DEMUXER_CTRL_SWITCH_VIDEO 14
|
2006-11-18 14:31:31 +00:00
|
|
|
#define DEMUXER_CTRL_IDENTIFY_PROGRAM 15
|
2008-02-03 12:14:29 +00:00
|
|
|
#define DEMUXER_CTRL_CORRECT_PTS 16
|
2002-11-16 03:42:14 +00:00
|
|
|
|
2008-01-29 15:11:38 +00:00
|
|
|
#define SEEK_ABSOLUTE (1 << 0)
|
|
|
|
#define SEEK_FACTOR (1 << 1)
|
|
|
|
|
2008-07-17 17:14:12 +00:00
|
|
|
#define MP_INPUT_BUFFER_PADDING_SIZE 8
|
2008-07-16 16:18:25 +00:00
|
|
|
|
2001-07-31 23:18:16 +00:00
|
|
|
// Holds one packet/frame/whatever
|
2001-04-23 16:12:21 +00:00
|
|
|
typedef struct demux_packet_st {
|
|
|
|
int len;
|
2006-04-27 11:13:21 +00:00
|
|
|
double pts;
|
2007-02-05 18:25:28 +00:00
|
|
|
double endpts;
|
2006-12-31 11:05:26 +00:00
|
|
|
double stream_pts;
|
2001-08-11 20:37:33 +00:00
|
|
|
off_t pos; // position in index (AVI) or file (MPG)
|
2001-04-23 16:12:21 +00:00
|
|
|
unsigned char* buffer;
|
2001-06-03 23:37:20 +00:00
|
|
|
int flags; // keyframe, etc
|
2002-05-25 22:13:23 +00:00
|
|
|
int refcount; //refcounter for the master packet, if 0, buffer can be free()d
|
|
|
|
struct demux_packet_st* master; //pointer to the master packet if this one is a cloned one
|
2001-04-23 16:12:21 +00:00
|
|
|
struct demux_packet_st* next;
|
|
|
|
} demux_packet_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int buffer_pos; // current buffer position
|
|
|
|
int buffer_size; // current buffer size
|
2002-05-25 22:13:23 +00:00
|
|
|
unsigned char* buffer; // current buffer, never free() it, always use free_demux_packet(buffer_ref);
|
2006-04-27 11:13:21 +00:00
|
|
|
double pts; // current buffer's pts
|
2001-05-10 03:39:54 +00:00
|
|
|
int pts_bytes; // number of bytes read after last pts stamp
|
2001-04-23 16:12:21 +00:00
|
|
|
int eof; // end of demuxed stream? (true if all buffer empty)
|
2001-07-31 23:18:16 +00:00
|
|
|
off_t pos; // position in the input stream (file)
|
|
|
|
off_t dpos; // position in the demuxed stream
|
2001-05-27 00:02:12 +00:00
|
|
|
int pack_no; // serial number of packet
|
2001-06-03 23:37:20 +00:00
|
|
|
int flags; // flags of current packet (keyframe etc)
|
2001-04-23 16:12:21 +00:00
|
|
|
//---------------
|
|
|
|
int packs; // number of packets in buffer
|
|
|
|
int bytes; // total bytes of packets in buffer
|
|
|
|
demux_packet_t *first; // read to current buffer from here
|
|
|
|
demux_packet_t *last; // append new packets from input stream to here
|
2002-05-25 22:13:23 +00:00
|
|
|
demux_packet_t *current;// needed for refcounting of the buffer
|
2001-04-23 16:12:21 +00:00
|
|
|
int id; // stream ID (for multiple audio/video streams)
|
|
|
|
struct demuxer_st *demuxer; // parent demuxer structure (stream handler)
|
|
|
|
// ---- asf -----
|
|
|
|
demux_packet_t *asf_packet; // read asf fragments here
|
|
|
|
int asf_seq;
|
2001-10-23 13:55:49 +00:00
|
|
|
// ---- mov -----
|
|
|
|
unsigned int ss_mul,ss_div;
|
2001-04-23 16:12:21 +00:00
|
|
|
// ---- stream header ----
|
|
|
|
void* sh;
|
|
|
|
} demux_stream_t;
|
|
|
|
|
2001-11-21 16:14:14 +00:00
|
|
|
typedef struct demuxer_info_st {
|
|
|
|
char *name;
|
|
|
|
char *author;
|
|
|
|
char *encoder;
|
|
|
|
char *comments;
|
2001-11-22 15:43:24 +00:00
|
|
|
char *copyright;
|
2001-11-21 16:14:14 +00:00
|
|
|
} demuxer_info_t;
|
|
|
|
|
2002-02-10 18:09:20 +00:00
|
|
|
#define MAX_A_STREAMS 256
|
|
|
|
#define MAX_V_STREAMS 256
|
2006-11-13 16:15:23 +00:00
|
|
|
#define MAX_S_STREAMS 32
|
2002-02-10 18:09:20 +00:00
|
|
|
|
2005-08-05 19:57:47 +00:00
|
|
|
struct demuxer_st;
|
|
|
|
|
2006-07-06 06:58:17 +00:00
|
|
|
extern int correct_pts;
|
2008-02-03 12:14:29 +00:00
|
|
|
extern int user_correct_pts;
|
2006-07-06 06:58:17 +00:00
|
|
|
|
2005-08-05 19:57:47 +00:00
|
|
|
/**
|
|
|
|
* Demuxer description structure
|
|
|
|
*/
|
|
|
|
typedef struct demuxers_desc_st {
|
|
|
|
const char *info; ///< What is it (long name and/or description)
|
|
|
|
const char *name; ///< Demuxer name, used with -demuxer switch
|
|
|
|
const char *shortdesc; ///< Description printed at demuxer detection
|
|
|
|
const char *author; ///< Demuxer author(s)
|
|
|
|
const char *comment; ///< Comment, printed with -demuxer help
|
|
|
|
|
|
|
|
int type; ///< DEMUXER_TYPE_xxx
|
|
|
|
int safe_check; ///< If 1 detection is safe and fast, do it before file extension check
|
|
|
|
|
|
|
|
/// Check if can demux the file, return DEMUXER_TYPE_xxx on success
|
|
|
|
int (*check_file)(struct demuxer_st *demuxer); ///< Mandatory if safe_check == 1, else optional
|
|
|
|
/// Get packets from file, return 0 on eof
|
|
|
|
int (*fill_buffer)(struct demuxer_st *demuxer, demux_stream_t *ds); ///< Mandatory
|
|
|
|
/// Open the demuxer, return demuxer on success, NULL on failure
|
|
|
|
struct demuxer_st* (*open)(struct demuxer_st *demuxer); ///< Optional
|
|
|
|
/// Close the demuxer
|
|
|
|
void (*close)(struct demuxer_st *demuxer); ///< Optional
|
|
|
|
// Seek
|
2006-02-17 01:57:41 +00:00
|
|
|
void (*seek)(struct demuxer_st *demuxer, float rel_seek_secs, float audio_delay, int flags); ///< Optional
|
2005-08-05 19:57:47 +00:00
|
|
|
// Control
|
|
|
|
int (*control)(struct demuxer_st *demuxer, int cmd, void *arg); ///< Optional
|
|
|
|
} demuxer_desc_t;
|
|
|
|
|
2006-08-06 18:55:34 +00:00
|
|
|
typedef struct demux_chapter_s
|
|
|
|
{
|
|
|
|
uint64_t start, end;
|
|
|
|
char* name;
|
|
|
|
} demux_chapter_t;
|
|
|
|
|
2008-01-12 01:12:36 +00:00
|
|
|
typedef struct demux_attachment_s
|
|
|
|
{
|
|
|
|
char* name;
|
|
|
|
char* type;
|
|
|
|
void* data;
|
|
|
|
unsigned int data_size;
|
|
|
|
} demux_attachment_t;
|
|
|
|
|
2001-04-23 16:12:21 +00:00
|
|
|
typedef struct demuxer_st {
|
2008-01-13 15:47:24 +00:00
|
|
|
const demuxer_desc_t *desc; ///< Demuxer description structure
|
2002-05-29 17:14:38 +00:00
|
|
|
off_t filepos; // input stream current pos.
|
|
|
|
off_t movi_start;
|
|
|
|
off_t movi_end;
|
2001-04-23 16:12:21 +00:00
|
|
|
stream_t *stream;
|
2006-12-31 11:05:26 +00:00
|
|
|
double stream_pts; // current stream pts, if applicable (e.g. dvd)
|
2008-02-23 10:31:44 +00:00
|
|
|
double reference_clock;
|
2005-08-05 19:57:47 +00:00
|
|
|
char *filename; ///< Needed by avs_check_file
|
2001-04-23 16:12:21 +00:00
|
|
|
int synced; // stream synced (used by mpeg)
|
2001-07-21 22:37:55 +00:00
|
|
|
int type; // demuxer type: mpeg PS, mpeg ES, avi, avi-ni, avi-nini, asf
|
|
|
|
int file_format; // file format: mpeg/avi/asf
|
2001-08-22 16:42:37 +00:00
|
|
|
int seekable; // flag
|
2001-04-23 16:12:21 +00:00
|
|
|
//
|
2001-08-11 20:37:33 +00:00
|
|
|
demux_stream_t *audio; // audio buffer/demuxer
|
|
|
|
demux_stream_t *video; // video buffer/demuxer
|
|
|
|
demux_stream_t *sub; // dvd subtitle buffer/demuxer
|
2001-04-23 16:12:21 +00:00
|
|
|
|
|
|
|
// stream headers:
|
2002-02-10 18:09:20 +00:00
|
|
|
void* a_streams[MAX_A_STREAMS]; // audio streams (sh_audio_t)
|
|
|
|
void* v_streams[MAX_V_STREAMS]; // video sterams (sh_video_t)
|
2006-11-13 16:15:23 +00:00
|
|
|
void *s_streams[MAX_S_STREAMS]; // dvd subtitles (flag)
|
2006-08-06 18:55:34 +00:00
|
|
|
|
|
|
|
demux_chapter_t* chapters;
|
|
|
|
int num_chapters;
|
2001-08-11 20:37:33 +00:00
|
|
|
|
2008-01-12 01:12:36 +00:00
|
|
|
demux_attachment_t* attachments;
|
|
|
|
int num_attachments;
|
|
|
|
|
2001-08-11 20:37:33 +00:00
|
|
|
void* priv; // fileformat-dependent data
|
2002-02-14 13:04:35 +00:00
|
|
|
char** info;
|
2001-04-23 16:12:21 +00:00
|
|
|
} demuxer_t;
|
|
|
|
|
2006-11-18 14:31:31 +00:00
|
|
|
typedef struct {
|
|
|
|
int progid; //program id
|
|
|
|
int aid, vid, sid; //audio, video and subtitle id
|
|
|
|
} demux_program_t;
|
|
|
|
|
2007-06-04 09:39:55 +00:00
|
|
|
static inline demux_packet_t* new_demux_packet(int len){
|
2002-08-05 00:39:07 +00:00
|
|
|
demux_packet_t* dp=(demux_packet_t*)malloc(sizeof(demux_packet_t));
|
2001-04-23 16:12:21 +00:00
|
|
|
dp->len=len;
|
|
|
|
dp->next=NULL;
|
2008-02-12 10:48:42 +00:00
|
|
|
dp->pts=MP_NOPTS_VALUE;
|
2007-02-05 18:25:28 +00:00
|
|
|
dp->endpts=MP_NOPTS_VALUE;
|
2006-12-31 11:05:26 +00:00
|
|
|
dp->stream_pts = MP_NOPTS_VALUE;
|
2001-04-23 16:12:21 +00:00
|
|
|
dp->pos=0;
|
2001-06-03 23:37:20 +00:00
|
|
|
dp->flags=0;
|
2002-05-25 22:13:23 +00:00
|
|
|
dp->refcount=1;
|
|
|
|
dp->master=NULL;
|
2006-02-12 17:01:30 +00:00
|
|
|
dp->buffer=NULL;
|
2008-07-17 17:14:12 +00:00
|
|
|
if (len > 0 && (dp->buffer = (unsigned char *)malloc(len + MP_INPUT_BUFFER_PADDING_SIZE)))
|
2006-02-12 09:28:09 +00:00
|
|
|
memset(dp->buffer + len, 0, 8);
|
|
|
|
else
|
|
|
|
dp->len = 0;
|
2002-05-25 22:13:23 +00:00
|
|
|
return dp;
|
|
|
|
}
|
|
|
|
|
2007-06-04 09:39:55 +00:00
|
|
|
static inline void resize_demux_packet(demux_packet_t* dp, int len)
|
2003-08-24 18:08:54 +00:00
|
|
|
{
|
2006-02-12 09:28:09 +00:00
|
|
|
if(len > 0)
|
2003-08-24 18:08:54 +00:00
|
|
|
{
|
|
|
|
dp->buffer=(unsigned char *)realloc(dp->buffer,len+8);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(dp->buffer) free(dp->buffer);
|
|
|
|
dp->buffer=NULL;
|
|
|
|
}
|
|
|
|
dp->len=len;
|
2006-02-12 09:28:09 +00:00
|
|
|
if (dp->buffer)
|
|
|
|
memset(dp->buffer + len, 0, 8);
|
|
|
|
else
|
|
|
|
dp->len = 0;
|
2003-08-24 18:08:54 +00:00
|
|
|
}
|
|
|
|
|
2007-06-04 09:39:55 +00:00
|
|
|
static inline demux_packet_t* clone_demux_packet(demux_packet_t* pack){
|
2002-08-05 00:39:07 +00:00
|
|
|
demux_packet_t* dp=(demux_packet_t*)malloc(sizeof(demux_packet_t));
|
2002-05-25 22:13:23 +00:00
|
|
|
while(pack->master) pack=pack->master; // find the master
|
|
|
|
memcpy(dp,pack,sizeof(demux_packet_t));
|
|
|
|
dp->next=NULL;
|
|
|
|
dp->refcount=0;
|
|
|
|
dp->master=pack;
|
|
|
|
pack->refcount++;
|
2001-04-23 16:12:21 +00:00
|
|
|
return dp;
|
|
|
|
}
|
|
|
|
|
2007-06-04 09:39:55 +00:00
|
|
|
static inline void free_demux_packet(demux_packet_t* dp){
|
2002-05-25 22:13:23 +00:00
|
|
|
if (dp->master==NULL){ //dp is a master packet
|
|
|
|
dp->refcount--;
|
|
|
|
if (dp->refcount==0){
|
|
|
|
if (dp->buffer) free(dp->buffer);
|
|
|
|
free(dp);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// dp is a clone:
|
|
|
|
free_demux_packet(dp->master);
|
2001-04-23 16:12:21 +00:00
|
|
|
free(dp);
|
|
|
|
}
|
|
|
|
|
2006-06-04 22:41:27 +00:00
|
|
|
#ifndef SIZE_MAX
|
|
|
|
#define SIZE_MAX ((size_t)-1)
|
|
|
|
#endif
|
|
|
|
|
2007-06-04 09:39:55 +00:00
|
|
|
static inline void *realloc_struct(void *ptr, size_t nmemb, size_t size) {
|
2006-06-04 22:41:27 +00:00
|
|
|
if (nmemb > SIZE_MAX / size) {
|
|
|
|
free(ptr);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return realloc(ptr, nmemb * size);
|
|
|
|
}
|
|
|
|
|
2001-04-23 16:12:21 +00:00
|
|
|
demux_stream_t* new_demuxer_stream(struct demuxer_st *demuxer,int id);
|
2005-08-05 19:57:47 +00:00
|
|
|
demuxer_t* new_demuxer(stream_t *stream,int type,int a_id,int v_id,int s_id,char *filename);
|
2001-08-22 23:54:57 +00:00
|
|
|
void free_demuxer_stream(demux_stream_t *ds);
|
|
|
|
void free_demuxer(demuxer_t *demuxer);
|
2001-04-23 16:12:21 +00:00
|
|
|
|
|
|
|
void ds_add_packet(demux_stream_t *ds,demux_packet_t* dp);
|
2006-04-27 11:13:21 +00:00
|
|
|
void ds_read_packet(demux_stream_t *ds, stream_t *stream, int len, double pts, off_t pos, int flags);
|
2001-04-23 16:12:21 +00:00
|
|
|
|
|
|
|
int demux_fill_buffer(demuxer_t *demux,demux_stream_t *ds);
|
|
|
|
int ds_fill_buffer(demux_stream_t *ds);
|
|
|
|
|
2007-06-04 09:39:55 +00:00
|
|
|
static inline off_t ds_tell(demux_stream_t *ds){
|
2001-04-23 16:12:21 +00:00
|
|
|
return (ds->dpos-ds->buffer_size)+ds->buffer_pos;
|
|
|
|
}
|
|
|
|
|
2007-06-04 09:39:55 +00:00
|
|
|
static inline int ds_tell_pts(demux_stream_t *ds){
|
2001-05-10 03:39:54 +00:00
|
|
|
return (ds->pts_bytes-ds->buffer_size)+ds->buffer_pos;
|
|
|
|
}
|
|
|
|
|
2001-04-23 16:12:21 +00:00
|
|
|
int demux_read_data(demux_stream_t *ds,unsigned char* mem,int len);
|
2006-01-17 20:04:49 +00:00
|
|
|
int demux_pattern_3(demux_stream_t *ds, unsigned char *mem, int maxlen,
|
|
|
|
int *read, uint32_t pattern);
|
2001-04-23 16:12:21 +00:00
|
|
|
|
2005-09-17 18:05:55 +00:00
|
|
|
#define demux_peekc(ds) (\
|
|
|
|
(likely(ds->buffer_pos<ds->buffer_size)) ? ds->buffer[ds->buffer_pos] \
|
|
|
|
:((unlikely(!ds_fill_buffer(ds)))? (-1) : ds->buffer[ds->buffer_pos] ) )
|
2001-04-23 16:12:21 +00:00
|
|
|
#if 1
|
|
|
|
#define demux_getc(ds) (\
|
2005-09-03 08:58:34 +00:00
|
|
|
(likely(ds->buffer_pos<ds->buffer_size)) ? ds->buffer[ds->buffer_pos++] \
|
|
|
|
:((unlikely(!ds_fill_buffer(ds)))? (-1) : ds->buffer[ds->buffer_pos++] ) )
|
2001-04-23 16:12:21 +00:00
|
|
|
#else
|
2007-06-04 09:39:55 +00:00
|
|
|
static inline int demux_getc(demux_stream_t *ds){
|
2001-04-23 16:12:21 +00:00
|
|
|
if(ds->buffer_pos>=ds->buffer_size){
|
|
|
|
if(!ds_fill_buffer(ds)){
|
|
|
|
// printf("DEMUX_GETC: EOF reached!\n");
|
|
|
|
return -1; // EOF
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// printf("[%02X]",ds->buffer[ds->buffer_pos]);
|
|
|
|
return ds->buffer[ds->buffer_pos++];
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void ds_free_packs(demux_stream_t *ds);
|
|
|
|
int ds_get_packet(demux_stream_t *ds,unsigned char **start);
|
2006-04-24 10:58:40 +00:00
|
|
|
int ds_get_packet_pts(demux_stream_t *ds, unsigned char **start, double *pts);
|
2001-04-23 16:12:21 +00:00
|
|
|
int ds_get_packet_sub(demux_stream_t *ds,unsigned char **start);
|
2006-04-27 11:13:21 +00:00
|
|
|
double ds_get_next_pts(demux_stream_t *ds);
|
2001-04-23 16:12:21 +00:00
|
|
|
|
2002-03-16 14:32:03 +00:00
|
|
|
// This is defined here because demux_stream_t ins't defined in stream.h
|
|
|
|
stream_t* new_ds_stream(demux_stream_t *ds);
|
2001-04-23 16:12:21 +00:00
|
|
|
|
|
|
|
static inline int avi_stream_id(unsigned int id){
|
|
|
|
unsigned char *p=(unsigned char *)&id;
|
|
|
|
unsigned char a,b;
|
2001-07-12 15:35:52 +00:00
|
|
|
#if WORDS_BIGENDIAN
|
|
|
|
a=p[3]-'0'; b=p[2]-'0';
|
|
|
|
#else
|
2001-04-23 16:12:21 +00:00
|
|
|
a=p[0]-'0'; b=p[1]-'0';
|
2001-07-12 15:35:52 +00:00
|
|
|
#endif
|
2001-04-23 16:12:21 +00:00
|
|
|
if(a>9 || b>9) return 100; // invalid ID
|
|
|
|
return a*10+b;
|
|
|
|
}
|
|
|
|
|
2003-01-19 00:21:54 +00:00
|
|
|
demuxer_t* demux_open(stream_t *stream,int file_format,int aid,int vid,int sid,char* filename);
|
2008-06-02 10:17:48 +00:00
|
|
|
void demux_flush(demuxer_t *demuxer);
|
2006-02-17 01:57:41 +00:00
|
|
|
int demux_seek(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags);
|
2002-02-20 16:59:25 +00:00
|
|
|
demuxer_t* new_demuxers_demuxer(demuxer_t* vd, demuxer_t* ad, demuxer_t* sd);
|
2001-04-23 16:12:21 +00:00
|
|
|
|
2001-10-30 17:03:11 +00:00
|
|
|
// AVI demuxer params:
|
|
|
|
extern int index_mode; // -1=untouched 0=don't use index 1=use (geneate) index
|
2003-10-22 19:01:37 +00:00
|
|
|
extern char *index_file_save, *index_file_load;
|
2001-10-30 17:03:11 +00:00
|
|
|
extern int force_ni;
|
|
|
|
extern int pts_from_bps;
|
|
|
|
|
2003-01-19 00:21:54 +00:00
|
|
|
extern int extension_parsing;
|
|
|
|
|
2006-07-13 05:03:43 +00:00
|
|
|
int demux_info_add(demuxer_t *demuxer, const char *opt, const char *param);
|
2007-06-24 10:20:42 +00:00
|
|
|
char* demux_info_get(demuxer_t *demuxer, const char *opt);
|
2001-11-22 15:43:24 +00:00
|
|
|
int demux_info_print(demuxer_t *demuxer);
|
2002-11-16 03:42:14 +00:00
|
|
|
int demux_control(demuxer_t *demuxer, int cmd, void *arg);
|
2002-03-03 18:47:29 +00:00
|
|
|
|
2008-08-02 16:30:32 +00:00
|
|
|
#ifdef CONFIG_OGGVORBIS
|
2004-08-24 21:20:24 +00:00
|
|
|
/* Found in demux_ogg.c */
|
|
|
|
int demux_ogg_num_subs(demuxer_t *demuxer);
|
|
|
|
int demux_ogg_sub_id(demuxer_t *demuxer, int index);
|
|
|
|
#endif
|
|
|
|
|
2006-11-07 22:55:49 +00:00
|
|
|
extern int demuxer_get_current_time(demuxer_t *demuxer);
|
2005-09-02 08:32:32 +00:00
|
|
|
extern double demuxer_get_time_length(demuxer_t *demuxer);
|
2002-11-16 03:42:14 +00:00
|
|
|
extern int demuxer_get_percent_pos(demuxer_t *demuxer);
|
2005-04-28 14:43:19 +00:00
|
|
|
extern int demuxer_switch_audio(demuxer_t *demuxer, int index);
|
2006-11-16 21:23:06 +00:00
|
|
|
extern int demuxer_switch_video(demuxer_t *demuxer, int index);
|
2003-01-19 00:21:54 +00:00
|
|
|
|
|
|
|
extern int demuxer_type_by_filename(char* filename);
|
2005-08-05 19:57:47 +00:00
|
|
|
|
|
|
|
extern void demuxer_help(void);
|
2005-08-30 23:56:24 +00:00
|
|
|
extern int get_demuxer_type_from_name(char *demuxer_name, int *force);
|
2006-08-06 18:55:34 +00:00
|
|
|
|
2008-01-12 01:12:36 +00:00
|
|
|
int demuxer_add_attachment(demuxer_t* demuxer, const char* name,
|
|
|
|
const char* type, const void* data, size_t size);
|
|
|
|
|
2006-08-06 18:55:34 +00:00
|
|
|
int demuxer_add_chapter(demuxer_t* demuxer, const char* name, uint64_t start, uint64_t end);
|
2006-08-21 19:19:00 +00:00
|
|
|
int demuxer_seek_chapter(demuxer_t *demuxer, int chapter, int mode, float *seek_pts, int *num_chapters, char **chapter_name);
|
2006-08-06 18:55:34 +00:00
|
|
|
|
2007-12-13 12:51:05 +00:00
|
|
|
/// Get current chapter index if available.
|
|
|
|
int demuxer_get_current_chapter(demuxer_t *demuxer);
|
|
|
|
/// Get chapter name by index if available.
|
|
|
|
char *demuxer_chapter_name(demuxer_t *demuxer, int chapter);
|
|
|
|
/// Get chapter display name by index.
|
|
|
|
char *demuxer_chapter_display_name(demuxer_t *demuxer, int chapter);
|
|
|
|
/// Get chapter start time and end time by index if available.
|
|
|
|
float demuxer_chapter_time(demuxer_t *demuxer, int chapter, float *end);
|
|
|
|
/// Get total chapter number.
|
|
|
|
int demuxer_chapter_count(demuxer_t *demuxer);
|
2008-01-05 14:28:57 +00:00
|
|
|
/// Get current angle index.
|
|
|
|
int demuxer_get_current_angle(demuxer_t *demuxer);
|
|
|
|
/// Set angle.
|
|
|
|
int demuxer_set_angle(demuxer_t *demuxer, int angle);
|
|
|
|
/// Get number of angles.
|
|
|
|
int demuxer_angles_count(demuxer_t *demuxer);
|
2007-06-20 16:52:32 +00:00
|
|
|
|
2008-02-29 17:25:43 +00:00
|
|
|
// get the index of a track
|
|
|
|
// lang is a comma-separated list
|
|
|
|
int demuxer_audio_track_by_lang(demuxer_t* demuxer, char* lang);
|
|
|
|
int demuxer_sub_track_by_lang(demuxer_t* demuxer, char* lang);
|
|
|
|
|
2008-03-30 16:55:46 +00:00
|
|
|
// find the default track
|
|
|
|
// for subtitles, it is the first track with default attribute
|
|
|
|
// for audio, additionally, the first track is selected if no track has default attribute set
|
|
|
|
int demuxer_default_audio_track(demuxer_t* d);
|
|
|
|
int demuxer_default_sub_track(demuxer_t* d);
|
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#endif /* MPLAYER_DEMUXER_H */
|