2001-02-24 20:28:24 +00:00
|
|
|
//=================== DEMUXER v2.5 =========================
|
|
|
|
|
2001-04-23 03:42:17 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2001-11-27 00:42:39 +00:00
|
|
|
#include <string.h>
|
2001-08-01 09:14:02 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2001-07-21 22:37:55 +00:00
|
|
|
#include "config.h"
|
2001-08-17 00:40:25 +00:00
|
|
|
#include "mp_msg.h"
|
2001-08-18 20:32:09 +00:00
|
|
|
#include "help_mp.h"
|
2003-03-27 20:38:14 +00:00
|
|
|
#include "../m_config.h"
|
2001-07-21 22:37:55 +00:00
|
|
|
|
2001-04-23 03:42:17 +00:00
|
|
|
#include "stream.h"
|
|
|
|
#include "demuxer.h"
|
2001-07-21 22:37:55 +00:00
|
|
|
#include "stheader.h"
|
2002-02-06 20:16:35 +00:00
|
|
|
#include "mf.h"
|
2001-07-21 22:37:55 +00:00
|
|
|
|
2004-12-27 17:30:15 +00:00
|
|
|
#include "../libaf/af_format.h"
|
2002-03-15 15:53:11 +00:00
|
|
|
#include "../libvo/fastmemcpy.h"
|
|
|
|
|
2004-11-25 22:24:00 +00:00
|
|
|
// Should be set to 1 by demux module if ids it passes to new_sh_audio and
|
|
|
|
// new_sh_video don't match aids and vids it accepts from the command line
|
|
|
|
int demux_aid_vid_mismatch = 0;
|
|
|
|
|
2001-08-22 23:54:57 +00:00
|
|
|
void free_demuxer_stream(demux_stream_t *ds){
|
|
|
|
ds_free_packs(ds);
|
|
|
|
free(ds);
|
|
|
|
}
|
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
demux_stream_t* new_demuxer_stream(struct demuxer_st *demuxer,int id){
|
|
|
|
demux_stream_t* ds=malloc(sizeof(demux_stream_t));
|
|
|
|
ds->buffer_pos=ds->buffer_size=0;
|
|
|
|
ds->buffer=NULL;
|
|
|
|
ds->pts=0;
|
2001-05-10 03:39:54 +00:00
|
|
|
ds->pts_bytes=0;
|
2001-02-24 20:28:24 +00:00
|
|
|
ds->eof=0;
|
|
|
|
ds->pos=0;
|
|
|
|
ds->dpos=0;
|
2001-05-27 00:02:12 +00:00
|
|
|
ds->pack_no=0;
|
2001-02-24 20:28:24 +00:00
|
|
|
//---------------
|
|
|
|
ds->packs=0;
|
|
|
|
ds->bytes=0;
|
2002-05-25 22:13:23 +00:00
|
|
|
ds->first=ds->last=ds->current=NULL;
|
2001-02-24 20:28:24 +00:00
|
|
|
ds->id=id;
|
|
|
|
ds->demuxer=demuxer;
|
|
|
|
//----------------
|
|
|
|
ds->asf_seq=-1;
|
|
|
|
ds->asf_packet=NULL;
|
2001-10-23 13:55:49 +00:00
|
|
|
//----------------
|
2002-10-16 16:51:03 +00:00
|
|
|
ds->ss_mul=ds->ss_div=0;
|
2001-04-06 01:18:59 +00:00
|
|
|
//----------------
|
|
|
|
ds->sh=NULL;
|
2001-02-24 20:28:24 +00:00
|
|
|
return ds;
|
|
|
|
}
|
|
|
|
|
2001-04-20 22:35:15 +00:00
|
|
|
demuxer_t* new_demuxer(stream_t *stream,int type,int a_id,int v_id,int s_id){
|
2001-02-24 20:28:24 +00:00
|
|
|
demuxer_t *d=malloc(sizeof(demuxer_t));
|
2001-04-23 03:42:17 +00:00
|
|
|
memset(d,0,sizeof(demuxer_t));
|
2001-02-24 20:28:24 +00:00
|
|
|
d->stream=stream;
|
2001-04-23 21:25:09 +00:00
|
|
|
d->movi_start=stream->start_pos;
|
|
|
|
d->movi_end=stream->end_pos;
|
2001-08-22 16:42:37 +00:00
|
|
|
d->seekable=1;
|
2001-02-24 20:28:24 +00:00
|
|
|
d->synced=0;
|
|
|
|
d->filepos=0;
|
|
|
|
d->audio=new_demuxer_stream(d,a_id);
|
|
|
|
d->video=new_demuxer_stream(d,v_id);
|
2001-04-20 22:35:15 +00:00
|
|
|
d->sub=new_demuxer_stream(d,s_id);
|
2001-02-24 20:28:24 +00:00
|
|
|
d->type=type;
|
2001-08-12 17:28:16 +00:00
|
|
|
stream_reset(stream);
|
|
|
|
stream_seek(stream,stream->start_pos);
|
2001-02-24 20:28:24 +00:00
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
2001-07-21 22:37:55 +00:00
|
|
|
sh_audio_t* new_sh_audio(demuxer_t *demuxer,int id){
|
2002-03-15 15:53:11 +00:00
|
|
|
if(id > MAX_A_STREAMS-1 || id < 0)
|
2002-02-10 18:09:20 +00:00
|
|
|
{
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_WARN,"Requested audio stream id overflow (%d > %d)\n",
|
|
|
|
id, MAX_A_STREAMS);
|
|
|
|
return NULL;
|
|
|
|
}
|
2001-07-21 22:37:55 +00:00
|
|
|
if(demuxer->a_streams[id]){
|
2001-08-18 20:32:09 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_AudioStreamRedefined,id);
|
2001-07-21 22:37:55 +00:00
|
|
|
} else {
|
2004-09-16 19:51:13 +00:00
|
|
|
sh_audio_t *sh;
|
2002-08-08 13:55:15 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_V,MSGTR_FoundAudioStream,id);
|
2001-07-21 22:37:55 +00:00
|
|
|
demuxer->a_streams[id]=malloc(sizeof(sh_audio_t));
|
|
|
|
memset(demuxer->a_streams[id],0,sizeof(sh_audio_t));
|
2004-09-16 19:51:13 +00:00
|
|
|
sh = demuxer->a_streams[id];
|
|
|
|
// set some defaults
|
|
|
|
sh->samplesize=2;
|
2004-12-27 17:30:15 +00:00
|
|
|
sh->sample_format=AF_FORMAT_S16_NE;
|
2004-09-16 19:51:13 +00:00
|
|
|
sh->audio_out_minsize=8192;/* default size, maybe not enough for Win32/ACM*/
|
2004-11-25 22:24:00 +00:00
|
|
|
if (identify && !demux_aid_vid_mismatch)
|
|
|
|
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_ID=%d\n", id);
|
2001-07-21 22:37:55 +00:00
|
|
|
}
|
|
|
|
return demuxer->a_streams[id];
|
|
|
|
}
|
|
|
|
|
2001-08-22 23:54:57 +00:00
|
|
|
void free_sh_audio(sh_audio_t* sh){
|
2004-11-15 09:09:29 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_DBG2,"DEMUXER: freeing sh_audio at %p\n",sh);
|
2001-08-22 23:54:57 +00:00
|
|
|
if(sh->wf) free(sh->wf);
|
|
|
|
free(sh);
|
|
|
|
}
|
|
|
|
|
2001-07-21 22:37:55 +00:00
|
|
|
sh_video_t* new_sh_video(demuxer_t *demuxer,int id){
|
2002-03-15 15:53:11 +00:00
|
|
|
if(id > MAX_V_STREAMS-1 || id < 0)
|
2002-02-10 18:09:20 +00:00
|
|
|
{
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_WARN,"Requested video stream id overflow (%d > %d)\n",
|
|
|
|
id, MAX_V_STREAMS);
|
|
|
|
return NULL;
|
|
|
|
}
|
2001-07-21 22:37:55 +00:00
|
|
|
if(demuxer->v_streams[id]){
|
2001-08-18 20:32:09 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_VideoStreamRedefined,id);
|
2001-07-21 22:37:55 +00:00
|
|
|
} else {
|
2002-08-08 13:55:15 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_V,MSGTR_FoundVideoStream,id);
|
2001-07-21 22:37:55 +00:00
|
|
|
demuxer->v_streams[id]=malloc(sizeof(sh_video_t));
|
|
|
|
memset(demuxer->v_streams[id],0,sizeof(sh_video_t));
|
2004-11-25 22:24:00 +00:00
|
|
|
if (identify && !demux_aid_vid_mismatch)
|
|
|
|
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_VIDEO_ID=%d\n", id);
|
2001-07-21 22:37:55 +00:00
|
|
|
}
|
|
|
|
return demuxer->v_streams[id];
|
|
|
|
}
|
|
|
|
|
2001-08-22 23:54:57 +00:00
|
|
|
void free_sh_video(sh_video_t* sh){
|
2004-11-15 09:09:29 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_DBG2,"DEMUXER: freeing sh_video at %p\n",sh);
|
2001-08-23 12:47:23 +00:00
|
|
|
if(sh->bih) free(sh->bih);
|
2001-08-22 23:54:57 +00:00
|
|
|
free(sh);
|
|
|
|
}
|
|
|
|
|
2002-04-24 15:36:07 +00:00
|
|
|
extern void demux_close_vivo(demuxer_t *demuxer);
|
|
|
|
extern void demux_close_real(demuxer_t *demuxer);
|
|
|
|
extern void demux_close_y4m(demuxer_t *demuxer);
|
|
|
|
extern void demux_close_mf(demuxer_t* demuxer);
|
|
|
|
extern void demux_close_roq(demuxer_t* demuxer);
|
|
|
|
extern void demux_close_film(demuxer_t* demuxer);
|
|
|
|
extern void demux_close_fli(demuxer_t* demuxer);
|
2004-04-12 14:19:12 +00:00
|
|
|
extern void demux_close_nsv(demuxer_t* demuxer);
|
2002-04-24 15:36:07 +00:00
|
|
|
extern void demux_close_nuv(demuxer_t* demuxer);
|
2002-04-24 17:28:23 +00:00
|
|
|
extern void demux_close_audio(demuxer_t* demuxer);
|
2005-07-10 17:14:12 +00:00
|
|
|
extern void demux_close_mpc(demuxer_t* demuxer);
|
2002-04-24 17:28:23 +00:00
|
|
|
extern void demux_close_ogg(demuxer_t* demuxer);
|
2004-10-23 00:05:38 +00:00
|
|
|
extern void demux_close_mpg(demuxer_t* demuxer);
|
2002-08-05 00:39:07 +00:00
|
|
|
extern void demux_close_rtp(demuxer_t* demuxer);
|
2002-04-24 17:28:23 +00:00
|
|
|
extern void demux_close_demuxers(demuxer_t* demuxer);
|
2002-07-26 12:36:13 +00:00
|
|
|
extern void demux_close_avi(demuxer_t *demuxer);
|
2002-08-05 17:21:35 +00:00
|
|
|
extern void demux_close_rawdv(demuxer_t* demuxer);
|
2002-09-10 21:50:03 +00:00
|
|
|
extern void demux_close_pva(demuxer_t* demuxer);
|
2002-09-13 18:58:14 +00:00
|
|
|
extern void demux_close_smjpeg(demuxer_t* demuxer);
|
2002-12-22 21:01:01 +00:00
|
|
|
extern void demux_close_xmms(demuxer_t* demuxer);
|
2003-01-28 00:12:23 +00:00
|
|
|
extern void demux_close_gif(demuxer_t* demuxer);
|
2003-12-08 19:33:38 +00:00
|
|
|
extern void demux_close_lmlm4(demuxer_t* demuxer);
|
2003-03-16 20:13:28 +00:00
|
|
|
extern void demux_close_ts(demuxer_t* demuxer);
|
2003-04-30 11:39:32 +00:00
|
|
|
extern void demux_close_mkv(demuxer_t* demuxer);
|
2003-04-30 19:50:46 +00:00
|
|
|
extern void demux_close_ra(demuxer_t* demuxer);
|
2003-06-09 00:24:49 +00:00
|
|
|
extern void demux_close_ty(demuxer_t* demuxer);
|
2004-04-11 14:26:04 +00:00
|
|
|
extern void demux_close_lavf(demuxer_t* demuxer);
|
2004-12-29 19:51:56 +00:00
|
|
|
extern void demux_close_vqf(demuxer_t* demuxer);
|
2005-06-13 20:40:29 +00:00
|
|
|
extern void demux_close_aac(demuxer_t* demuxer);
|
2005-02-13 13:39:19 +00:00
|
|
|
#ifdef USE_WIN32DLL
|
|
|
|
extern void demux_close_avs(demuxer_t* demuxer);
|
|
|
|
#endif
|
2005-06-20 14:16:59 +00:00
|
|
|
extern void demux_close_mov(demuxer_t* demuxer);
|
2003-06-09 00:24:49 +00:00
|
|
|
|
2002-04-24 15:36:07 +00:00
|
|
|
|
2002-08-21 21:31:20 +00:00
|
|
|
#ifdef USE_TV
|
|
|
|
#include "tv.h"
|
|
|
|
extern int tv_param_on;
|
|
|
|
|
2002-09-08 23:00:01 +00:00
|
|
|
extern int demux_tv_fill_buffer(demuxer_t *demux, demux_stream_t *ds);
|
|
|
|
extern int demux_open_tv(demuxer_t *demuxer);
|
2003-08-07 12:40:15 +00:00
|
|
|
#if defined(USE_TV) && (defined(HAVE_TV_V4L) || defined(HAVE_TV_V4L2))
|
2002-09-08 23:00:01 +00:00
|
|
|
extern void demux_close_tv(demuxer_t *demuxer);
|
2002-08-21 21:31:20 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2001-08-22 23:54:57 +00:00
|
|
|
void free_demuxer(demuxer_t *demuxer){
|
|
|
|
int i;
|
2004-11-15 09:09:29 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_DBG2,"DEMUXER: freeing demuxer at %p\n",demuxer);
|
2002-04-24 15:36:07 +00:00
|
|
|
switch(demuxer->type) {
|
2002-09-10 21:50:03 +00:00
|
|
|
case DEMUXER_TYPE_PVA:
|
|
|
|
demux_close_pva(demuxer); break;
|
2002-04-24 15:36:07 +00:00
|
|
|
case DEMUXER_TYPE_VIVO:
|
|
|
|
demux_close_vivo(demuxer); break;
|
|
|
|
case DEMUXER_TYPE_REAL:
|
|
|
|
demux_close_real(demuxer); break;
|
|
|
|
case DEMUXER_TYPE_Y4M:
|
|
|
|
demux_close_y4m(demuxer); break;
|
|
|
|
case DEMUXER_TYPE_MF:
|
|
|
|
demux_close_mf(demuxer); break;
|
|
|
|
case DEMUXER_TYPE_ROQ:
|
|
|
|
demux_close_roq(demuxer); break;
|
|
|
|
case DEMUXER_TYPE_FILM:
|
|
|
|
demux_close_film(demuxer); break;
|
|
|
|
case DEMUXER_TYPE_FLI:
|
|
|
|
demux_close_fli(demuxer); break;
|
2004-04-12 14:19:12 +00:00
|
|
|
case DEMUXER_TYPE_NSV:
|
|
|
|
demux_close_nsv(demuxer); break;
|
2002-04-24 15:36:07 +00:00
|
|
|
case DEMUXER_TYPE_NUV:
|
|
|
|
demux_close_nuv(demuxer); break;
|
2003-06-09 00:24:49 +00:00
|
|
|
case DEMUXER_TYPE_MPEG_TY:
|
|
|
|
demux_close_ty(demuxer); break;
|
2003-08-07 12:40:15 +00:00
|
|
|
#if defined(USE_TV) && (defined(HAVE_TV_V4L) || defined(HAVE_TV_V4L2))
|
2002-08-21 21:31:20 +00:00
|
|
|
case DEMUXER_TYPE_TV:
|
2002-09-08 23:00:01 +00:00
|
|
|
demux_close_tv(demuxer); break;
|
2002-08-21 21:31:20 +00:00
|
|
|
#endif
|
2002-08-05 17:21:35 +00:00
|
|
|
#ifdef HAVE_LIBDV095
|
|
|
|
case DEMUXER_TYPE_RAWDV:
|
|
|
|
demux_close_rawdv(demuxer); break;
|
|
|
|
#endif
|
2002-04-24 17:28:23 +00:00
|
|
|
case DEMUXER_TYPE_AUDIO:
|
|
|
|
demux_close_audio(demuxer); break;
|
2005-07-10 17:14:12 +00:00
|
|
|
case DEMUXER_TYPE_MPC:
|
|
|
|
demux_close_mpc(demuxer); break;
|
2002-09-15 22:38:30 +00:00
|
|
|
#ifdef HAVE_OGGVORBIS
|
2002-04-24 17:28:23 +00:00
|
|
|
case DEMUXER_TYPE_OGG:
|
|
|
|
demux_close_ogg(demuxer); break;
|
2002-09-15 22:38:30 +00:00
|
|
|
#endif
|
2003-04-30 11:39:32 +00:00
|
|
|
#ifdef HAVE_MATROSKA
|
|
|
|
case DEMUXER_TYPE_MATROSKA:
|
|
|
|
demux_close_mkv(demuxer); break;
|
|
|
|
#endif
|
2002-08-05 00:39:07 +00:00
|
|
|
#ifdef STREAMING_LIVE_DOT_COM
|
|
|
|
case DEMUXER_TYPE_RTP:
|
|
|
|
demux_close_rtp(demuxer); break;
|
|
|
|
#endif
|
2002-09-13 18:58:14 +00:00
|
|
|
case DEMUXER_TYPE_SMJPEG:
|
2005-02-06 10:30:10 +00:00
|
|
|
demux_close_smjpeg(demuxer); break;
|
2002-04-24 17:28:23 +00:00
|
|
|
case DEMUXER_TYPE_DEMUXERS:
|
2005-04-29 21:57:05 +00:00
|
|
|
demux_close_demuxers(demuxer); return;
|
2002-07-26 12:36:13 +00:00
|
|
|
case DEMUXER_TYPE_AVI:
|
|
|
|
case DEMUXER_TYPE_AVI_NI:
|
|
|
|
case DEMUXER_TYPE_AVI_NINI:
|
2005-02-06 10:30:10 +00:00
|
|
|
demux_close_avi(demuxer); break;
|
2002-12-22 21:01:01 +00:00
|
|
|
#ifdef HAVE_XMMS
|
|
|
|
case DEMUXER_TYPE_XMMS:
|
|
|
|
demux_close_xmms(demuxer); break;
|
|
|
|
#endif
|
2003-01-28 00:12:23 +00:00
|
|
|
#ifdef HAVE_GIF
|
|
|
|
case DEMUXER_TYPE_GIF:
|
|
|
|
demux_close_gif(demuxer); break;
|
|
|
|
#endif
|
2003-12-08 19:33:38 +00:00
|
|
|
case DEMUXER_TYPE_LMLM4:
|
|
|
|
demux_close_lmlm4(demuxer); break;
|
2003-03-16 20:13:28 +00:00
|
|
|
case DEMUXER_TYPE_MPEG_TS:
|
|
|
|
demux_close_ts(demuxer); break;
|
2004-10-23 00:05:38 +00:00
|
|
|
case DEMUXER_TYPE_MPEG_PS:
|
|
|
|
demux_close_mpg(demuxer); break;
|
2003-04-30 19:50:46 +00:00
|
|
|
case DEMUXER_TYPE_REALAUDIO:
|
|
|
|
demux_close_ra(demuxer); break;
|
2004-12-29 19:51:56 +00:00
|
|
|
case DEMUXER_TYPE_VQF:
|
|
|
|
demux_close_vqf(demuxer); break;
|
2005-06-13 20:40:29 +00:00
|
|
|
case DEMUXER_TYPE_AAC:
|
|
|
|
demux_close_aac(demuxer); break;
|
2004-04-11 14:26:04 +00:00
|
|
|
#ifdef USE_LIBAVFORMAT
|
|
|
|
case DEMUXER_TYPE_LAVF:
|
|
|
|
demux_close_lavf(demuxer); break;
|
2005-02-13 13:39:19 +00:00
|
|
|
#endif
|
|
|
|
#ifdef USE_WIN32DLL
|
|
|
|
case DEMUXER_TYPE_AVS:
|
|
|
|
demux_close_avs(demuxer); break;
|
2004-04-11 14:26:04 +00:00
|
|
|
#endif
|
2005-06-20 14:16:59 +00:00
|
|
|
case DEMUXER_TYPE_MOV:
|
|
|
|
demux_close_mov(demuxer); break;
|
2002-04-24 15:36:07 +00:00
|
|
|
}
|
2001-08-22 23:54:57 +00:00
|
|
|
// free streams:
|
2005-02-06 10:30:10 +00:00
|
|
|
for(i = 0; i < MAX_A_STREAMS; i++)
|
2001-08-22 23:54:57 +00:00
|
|
|
if(demuxer->a_streams[i]) free_sh_audio(demuxer->a_streams[i]);
|
2005-02-06 10:30:10 +00:00
|
|
|
for(i = 0; i < MAX_V_STREAMS; i++)
|
2001-08-22 23:54:57 +00:00
|
|
|
if(demuxer->v_streams[i]) free_sh_video(demuxer->v_streams[i]);
|
|
|
|
//if(sh_audio) free_sh_audio(sh_audio);
|
|
|
|
//if(sh_video) free_sh_video(sh_video);
|
|
|
|
// free demuxers:
|
|
|
|
free_demuxer_stream(demuxer->audio);
|
|
|
|
free_demuxer_stream(demuxer->video);
|
2002-03-31 02:45:14 +00:00
|
|
|
free_demuxer_stream(demuxer->sub);
|
2002-02-14 13:04:35 +00:00
|
|
|
if(demuxer->info) {
|
|
|
|
for(i=0;demuxer->info[i] != NULL; i++)
|
|
|
|
free(demuxer->info[i]);
|
|
|
|
free(demuxer->info);
|
|
|
|
}
|
2001-08-22 23:54:57 +00:00
|
|
|
free(demuxer);
|
|
|
|
}
|
|
|
|
|
2001-07-21 22:37:55 +00:00
|
|
|
|
2001-04-23 03:42:17 +00:00
|
|
|
void ds_add_packet(demux_stream_t *ds,demux_packet_t* dp){
|
2001-02-24 20:28:24 +00:00
|
|
|
// demux_packet_t* dp=new_demux_packet(len);
|
|
|
|
// stream_read(stream,dp->buffer,len);
|
|
|
|
// dp->pts=pts; //(float)pts/90000.0f;
|
|
|
|
// dp->pos=pos;
|
|
|
|
// append packet to DS stream:
|
|
|
|
++ds->packs;
|
|
|
|
ds->bytes+=dp->len;
|
|
|
|
if(ds->last){
|
|
|
|
// next packet in stream
|
|
|
|
ds->last->next=dp;
|
|
|
|
ds->last=dp;
|
|
|
|
} else {
|
|
|
|
// first packet in stream
|
|
|
|
ds->first=ds->last=dp;
|
|
|
|
}
|
2001-08-17 00:40:25 +00:00
|
|
|
mp_dbg(MSGT_DEMUXER,MSGL_DBG2,"DEMUX: Append packet to %s, len=%d pts=%5.3f pos=%u [packs: A=%d V=%d]\n",
|
2001-02-24 20:28:24 +00:00
|
|
|
(ds==ds->demuxer->audio)?"d_audio":"d_video",
|
2001-07-31 23:18:16 +00:00
|
|
|
dp->len,dp->pts,(unsigned int)dp->pos,ds->demuxer->audio->packs,ds->demuxer->video->packs);
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
|
|
|
|
2001-07-31 23:18:16 +00:00
|
|
|
void ds_read_packet(demux_stream_t *ds,stream_t *stream,int len,float pts,off_t pos,int flags){
|
2001-02-24 20:28:24 +00:00
|
|
|
demux_packet_t* dp=new_demux_packet(len);
|
2003-09-20 12:50:25 +00:00
|
|
|
len = stream_read(stream,dp->buffer,len);
|
|
|
|
resize_demux_packet(dp, len);
|
2001-02-24 20:28:24 +00:00
|
|
|
dp->pts=pts; //(float)pts/90000.0f;
|
|
|
|
dp->pos=pos;
|
2001-06-03 23:37:20 +00:00
|
|
|
dp->flags=flags;
|
2001-02-24 20:28:24 +00:00
|
|
|
// append packet to DS stream:
|
|
|
|
ds_add_packet(ds,dp);
|
|
|
|
}
|
|
|
|
|
|
|
|
// return value:
|
|
|
|
// 0 = EOF or no stream found or invalid type
|
|
|
|
// 1 = successfully read a packet
|
2002-02-06 20:16:35 +00:00
|
|
|
int demux_mf_fill_buffer( demuxer_t *demux);
|
2002-02-01 05:35:16 +00:00
|
|
|
int demux_roq_fill_buffer(demuxer_t *demux);
|
2002-01-16 03:25:07 +00:00
|
|
|
int demux_film_fill_buffer(demuxer_t *demux);
|
2001-11-24 23:58:12 +00:00
|
|
|
int demux_fli_fill_buffer(demuxer_t *demux);
|
2001-02-24 20:28:24 +00:00
|
|
|
int demux_mpg_es_fill_buffer(demuxer_t *demux);
|
|
|
|
int demux_mpg_fill_buffer(demuxer_t *demux);
|
2003-06-09 00:24:49 +00:00
|
|
|
int demux_ty_fill_buffer(demuxer_t *demux);
|
2001-02-24 20:28:24 +00:00
|
|
|
int demux_avi_fill_buffer(demuxer_t *demux);
|
|
|
|
int demux_avi_fill_buffer_ni(demuxer_t *demux,demux_stream_t *ds);
|
|
|
|
int demux_avi_fill_buffer_nini(demuxer_t *demux,demux_stream_t *ds);
|
|
|
|
int demux_asf_fill_buffer(demuxer_t *demux);
|
2001-10-06 11:29:18 +00:00
|
|
|
int demux_mov_fill_buffer(demuxer_t *demux,demux_stream_t* ds);
|
2001-11-04 16:57:09 +00:00
|
|
|
int demux_vivo_fill_buffer(demuxer_t *demux);
|
2001-12-27 21:24:56 +00:00
|
|
|
int demux_real_fill_buffer(demuxer_t *demuxer);
|
2004-04-12 14:19:12 +00:00
|
|
|
int demux_nsv_fill_buffer(demuxer_t *demux);
|
2001-12-27 21:24:56 +00:00
|
|
|
int demux_nuv_fill_buffer(demuxer_t *demux);
|
2002-08-05 00:39:07 +00:00
|
|
|
int demux_rtp_fill_buffer(demuxer_t *demux, demux_stream_t* ds);
|
2002-08-05 17:21:35 +00:00
|
|
|
int demux_rawdv_fill_buffer(demuxer_t *demuxer);
|
2001-12-27 02:08:31 +00:00
|
|
|
int demux_y4m_fill_buffer(demuxer_t *demux);
|
2002-02-14 13:04:35 +00:00
|
|
|
int demux_audio_fill_buffer(demux_stream_t *ds);
|
2005-07-10 17:14:12 +00:00
|
|
|
int demux_mpc_fill_buffer(demux_stream_t *ds);
|
2002-09-10 21:50:03 +00:00
|
|
|
int demux_pva_fill_buffer(demuxer_t *demux);
|
2002-12-22 21:01:01 +00:00
|
|
|
int demux_xmms_fill_buffer(demuxer_t *demux,demux_stream_t *ds);
|
2003-01-28 00:12:23 +00:00
|
|
|
int demux_gif_fill_buffer(demuxer_t *demux);
|
2003-03-16 20:13:28 +00:00
|
|
|
int demux_ts_fill_buffer(demuxer_t *demux);
|
2003-04-30 19:50:46 +00:00
|
|
|
int demux_ra_fill_buffer(demuxer_t *demux);
|
2004-12-29 19:51:56 +00:00
|
|
|
int demux_vqf_fill_buffer(demuxer_t *demux);
|
2002-09-10 21:50:03 +00:00
|
|
|
|
2005-06-13 20:40:29 +00:00
|
|
|
extern int demux_aac_fill_buffer(demuxer_t *demux);
|
2002-02-20 16:59:25 +00:00
|
|
|
extern int demux_demuxers_fill_buffer(demuxer_t *demux,demux_stream_t *ds);
|
2002-03-16 14:32:03 +00:00
|
|
|
extern int demux_ogg_fill_buffer(demuxer_t *d);
|
2002-06-11 14:29:51 +00:00
|
|
|
extern int demux_rawaudio_fill_buffer(demuxer_t* demuxer, demux_stream_t *ds);
|
2003-01-22 23:51:04 +00:00
|
|
|
extern int demux_rawvideo_fill_buffer(demuxer_t* demuxer, demux_stream_t *ds);
|
2002-09-13 18:58:14 +00:00
|
|
|
extern int demux_smjpeg_fill_buffer(demuxer_t* demux);
|
2003-12-08 19:33:38 +00:00
|
|
|
extern int demux_lmlm4_fill_buffer(demuxer_t* demux);
|
2003-04-30 11:39:32 +00:00
|
|
|
extern int demux_mkv_fill_buffer(demuxer_t *d);
|
2004-04-11 14:26:04 +00:00
|
|
|
extern int demux_lavf_fill_buffer(demuxer_t *d);
|
2005-02-13 13:39:19 +00:00
|
|
|
#ifdef USE_WIN32DLL
|
|
|
|
extern int demux_avs_fill_buffer(demuxer_t *d);
|
|
|
|
#endif
|
2001-02-24 20:28:24 +00:00
|
|
|
|
|
|
|
int demux_fill_buffer(demuxer_t *demux,demux_stream_t *ds){
|
|
|
|
// Note: parameter 'ds' can be NULL!
|
2001-07-21 22:37:55 +00:00
|
|
|
// printf("demux->type=%d\n",demux->type);
|
2001-02-24 20:28:24 +00:00
|
|
|
switch(demux->type){
|
2002-02-06 20:16:35 +00:00
|
|
|
case DEMUXER_TYPE_MF: return demux_mf_fill_buffer(demux);
|
2002-02-01 05:35:16 +00:00
|
|
|
case DEMUXER_TYPE_ROQ: return demux_roq_fill_buffer(demux);
|
2002-01-16 03:25:07 +00:00
|
|
|
case DEMUXER_TYPE_FILM: return demux_film_fill_buffer(demux);
|
2001-11-24 23:58:12 +00:00
|
|
|
case DEMUXER_TYPE_FLI: return demux_fli_fill_buffer(demux);
|
2003-06-09 00:24:49 +00:00
|
|
|
case DEMUXER_TYPE_MPEG_TY: return demux_ty_fill_buffer( demux );
|
2003-01-23 02:12:15 +00:00
|
|
|
case DEMUXER_TYPE_MPEG4_ES:
|
2003-04-04 15:38:46 +00:00
|
|
|
case DEMUXER_TYPE_H264_ES:
|
2001-02-24 20:28:24 +00:00
|
|
|
case DEMUXER_TYPE_MPEG_ES: return demux_mpg_es_fill_buffer(demux);
|
|
|
|
case DEMUXER_TYPE_MPEG_PS: return demux_mpg_fill_buffer(demux);
|
|
|
|
case DEMUXER_TYPE_AVI: return demux_avi_fill_buffer(demux);
|
|
|
|
case DEMUXER_TYPE_AVI_NI: return demux_avi_fill_buffer_ni(demux,ds);
|
|
|
|
case DEMUXER_TYPE_AVI_NINI: return demux_avi_fill_buffer_nini(demux,ds);
|
|
|
|
case DEMUXER_TYPE_ASF: return demux_asf_fill_buffer(demux);
|
2001-10-06 11:29:18 +00:00
|
|
|
case DEMUXER_TYPE_MOV: return demux_mov_fill_buffer(demux,ds);
|
2001-11-04 16:57:09 +00:00
|
|
|
case DEMUXER_TYPE_VIVO: return demux_vivo_fill_buffer(demux);
|
2002-09-10 21:50:03 +00:00
|
|
|
case DEMUXER_TYPE_PVA: return demux_pva_fill_buffer(demux);
|
2002-08-05 17:21:35 +00:00
|
|
|
#ifdef HAVE_LIBDV095
|
|
|
|
case DEMUXER_TYPE_RAWDV: return demux_rawdv_fill_buffer(demux);
|
|
|
|
#endif
|
2001-12-26 22:57:51 +00:00
|
|
|
case DEMUXER_TYPE_REAL: return demux_real_fill_buffer(demux);
|
2004-04-12 14:19:12 +00:00
|
|
|
case DEMUXER_TYPE_NSV: return demux_nsv_fill_buffer(demux);
|
2001-12-27 21:24:56 +00:00
|
|
|
case DEMUXER_TYPE_NUV: return demux_nuv_fill_buffer(demux);
|
2001-11-09 23:46:06 +00:00
|
|
|
#ifdef USE_TV
|
2002-09-08 23:00:01 +00:00
|
|
|
case DEMUXER_TYPE_TV: return demux_tv_fill_buffer(demux, ds);
|
2001-11-09 23:46:06 +00:00
|
|
|
#endif
|
2001-12-27 02:08:31 +00:00
|
|
|
case DEMUXER_TYPE_Y4M: return demux_y4m_fill_buffer(demux);
|
2002-02-14 13:04:35 +00:00
|
|
|
case DEMUXER_TYPE_AUDIO: return demux_audio_fill_buffer(ds);
|
2005-07-10 17:14:12 +00:00
|
|
|
case DEMUXER_TYPE_MPC: return demux_mpc_fill_buffer(ds);
|
2002-12-22 21:01:01 +00:00
|
|
|
#ifdef HAVE_XMMS
|
|
|
|
case DEMUXER_TYPE_XMMS: return demux_xmms_fill_buffer(demux,ds);
|
|
|
|
#endif
|
2002-02-20 16:59:25 +00:00
|
|
|
case DEMUXER_TYPE_DEMUXERS: return demux_demuxers_fill_buffer(demux,ds);
|
2002-09-15 22:38:30 +00:00
|
|
|
#ifdef HAVE_OGGVORBIS
|
2002-03-16 14:32:03 +00:00
|
|
|
case DEMUXER_TYPE_OGG: return demux_ogg_fill_buffer(demux);
|
2003-04-30 11:39:32 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_MATROSKA
|
|
|
|
case DEMUXER_TYPE_MATROSKA: return demux_mkv_fill_buffer(demux);
|
2002-09-15 22:38:30 +00:00
|
|
|
#endif
|
2002-06-11 14:29:51 +00:00
|
|
|
case DEMUXER_TYPE_RAWAUDIO: return demux_rawaudio_fill_buffer(demux,ds);
|
2003-01-22 23:51:04 +00:00
|
|
|
case DEMUXER_TYPE_RAWVIDEO: return demux_rawvideo_fill_buffer(demux,ds);
|
2002-08-05 00:39:07 +00:00
|
|
|
#ifdef STREAMING_LIVE_DOT_COM
|
|
|
|
case DEMUXER_TYPE_RTP: return demux_rtp_fill_buffer(demux, ds);
|
|
|
|
#endif
|
2002-09-13 18:58:14 +00:00
|
|
|
case DEMUXER_TYPE_SMJPEG: return demux_smjpeg_fill_buffer(demux);
|
2003-01-28 00:12:23 +00:00
|
|
|
#ifdef HAVE_GIF
|
|
|
|
case DEMUXER_TYPE_GIF: return demux_gif_fill_buffer(demux);
|
|
|
|
#endif
|
2003-12-08 19:33:38 +00:00
|
|
|
case DEMUXER_TYPE_LMLM4: return demux_lmlm4_fill_buffer(demux);
|
2003-08-24 18:08:54 +00:00
|
|
|
case DEMUXER_TYPE_MPEG_TS:
|
|
|
|
return demux_ts_fill_buffer(demux);
|
2003-04-30 19:50:46 +00:00
|
|
|
case DEMUXER_TYPE_REALAUDIO: return demux_ra_fill_buffer(demux);
|
2004-12-29 19:51:56 +00:00
|
|
|
case DEMUXER_TYPE_VQF: return demux_vqf_fill_buffer(demux);
|
2005-06-13 20:40:29 +00:00
|
|
|
case DEMUXER_TYPE_AAC: return demux_aac_fill_buffer(demux);
|
2004-04-11 14:26:04 +00:00
|
|
|
#ifdef USE_LIBAVFORMAT
|
|
|
|
case DEMUXER_TYPE_LAVF: return demux_lavf_fill_buffer(demux);
|
2005-02-13 13:39:19 +00:00
|
|
|
#endif
|
|
|
|
#ifdef USE_WIN32DLL
|
|
|
|
case DEMUXER_TYPE_AVS: return demux_avs_fill_buffer(demux);
|
2004-04-11 14:26:04 +00:00
|
|
|
#endif
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// return value:
|
|
|
|
// 0 = EOF
|
|
|
|
// 1 = succesfull
|
2001-04-23 03:42:17 +00:00
|
|
|
int ds_fill_buffer(demux_stream_t *ds){
|
2001-02-24 20:28:24 +00:00
|
|
|
demuxer_t *demux=ds->demuxer;
|
2002-05-25 22:13:23 +00:00
|
|
|
if(ds->current) free_demux_packet(ds->current);
|
2001-02-24 20:28:24 +00:00
|
|
|
if(verbose>2){
|
2001-08-17 00:40:25 +00:00
|
|
|
if(ds==demux->audio) mp_dbg(MSGT_DEMUXER,MSGL_DBG3,"ds_fill_buffer(d_audio) called\n");else
|
|
|
|
if(ds==demux->video) mp_dbg(MSGT_DEMUXER,MSGL_DBG3,"ds_fill_buffer(d_video) called\n");else
|
2002-04-03 17:49:40 +00:00
|
|
|
if(ds==demux->sub) mp_dbg(MSGT_DEMUXER,MSGL_DBG3,"ds_fill_buffer(d_sub) called\n");else
|
2001-08-17 00:40:25 +00:00
|
|
|
mp_dbg(MSGT_DEMUXER,MSGL_DBG3,"ds_fill_buffer(unknown 0x%X) called\n",(unsigned int)ds);
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
|
|
|
while(1){
|
|
|
|
if(ds->packs){
|
|
|
|
demux_packet_t *p=ds->first;
|
|
|
|
// copy useful data:
|
|
|
|
ds->buffer=p->buffer;
|
|
|
|
ds->buffer_pos=0;
|
|
|
|
ds->buffer_size=p->len;
|
|
|
|
ds->pos=p->pos;
|
|
|
|
ds->dpos+=p->len; // !!!
|
2001-05-27 00:02:12 +00:00
|
|
|
++ds->pack_no;
|
2001-05-10 03:39:54 +00:00
|
|
|
if(p->pts){
|
|
|
|
ds->pts=p->pts;
|
|
|
|
ds->pts_bytes=0;
|
|
|
|
}
|
|
|
|
ds->pts_bytes+=p->len; // !!!
|
2001-06-03 23:37:20 +00:00
|
|
|
ds->flags=p->flags;
|
2002-05-25 22:13:23 +00:00
|
|
|
// unlink packet:
|
2001-02-24 20:28:24 +00:00
|
|
|
ds->bytes-=p->len;
|
2002-05-25 22:13:23 +00:00
|
|
|
ds->current=p;
|
2001-02-24 20:28:24 +00:00
|
|
|
ds->first=p->next;
|
|
|
|
if(!ds->first) ds->last=NULL;
|
|
|
|
--ds->packs;
|
|
|
|
return 1; //ds->buffer_size;
|
|
|
|
}
|
|
|
|
if(demux->audio->packs>=MAX_PACKS || demux->audio->bytes>=MAX_PACK_BYTES){
|
2001-08-18 20:32:09 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_TooManyAudioInBuffer,demux->audio->packs,demux->audio->bytes);
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_HINT,MSGTR_MaybeNI);
|
2001-02-24 20:28:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(demux->video->packs>=MAX_PACKS || demux->video->bytes>=MAX_PACK_BYTES){
|
2001-08-18 20:32:09 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_TooManyVideoInBuffer,demux->video->packs,demux->video->bytes);
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_HINT,MSGTR_MaybeNI);
|
2001-02-24 20:28:24 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-07-29 21:07:34 +00:00
|
|
|
if(!demux_fill_buffer(demux,ds)){
|
2001-08-17 00:40:25 +00:00
|
|
|
mp_dbg(MSGT_DEMUXER,MSGL_DBG2,"ds_fill_buffer()->demux_fill_buffer() failed\n");
|
2001-07-29 21:07:34 +00:00
|
|
|
break; // EOF
|
|
|
|
}
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
|
|
|
ds->buffer_pos=ds->buffer_size=0;
|
|
|
|
ds->buffer=NULL;
|
2002-05-25 22:13:23 +00:00
|
|
|
ds->current=NULL;
|
2001-08-17 00:40:25 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_V,"ds_fill_buffer: EOF reached (stream: %s) \n",ds==demux->audio?"audio":"video");
|
2001-02-24 20:28:24 +00:00
|
|
|
ds->eof=1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-04-23 03:42:17 +00:00
|
|
|
int demux_read_data(demux_stream_t *ds,unsigned char* mem,int len){
|
2001-02-24 20:28:24 +00:00
|
|
|
int x;
|
|
|
|
int bytes=0;
|
|
|
|
while(len>0){
|
|
|
|
x=ds->buffer_size-ds->buffer_pos;
|
|
|
|
if(x==0){
|
|
|
|
if(!ds_fill_buffer(ds)) return bytes;
|
|
|
|
} else {
|
|
|
|
if(x>len) x=len;
|
|
|
|
if(mem) memcpy(mem+bytes,&ds->buffer[ds->buffer_pos],x);
|
|
|
|
bytes+=x;len-=x;ds->buffer_pos+=x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return bytes;
|
|
|
|
}
|
|
|
|
|
2001-05-10 03:39:54 +00:00
|
|
|
int demux_read_data_pack(demux_stream_t *ds,unsigned char* mem,int len){
|
|
|
|
int x;
|
|
|
|
int bytes=0;
|
|
|
|
while(len>0){
|
|
|
|
x=ds->buffer_size-ds->buffer_pos;
|
|
|
|
if(x==0){
|
|
|
|
if(!ds_fill_buffer(ds)) return bytes;
|
|
|
|
} else {
|
|
|
|
if(x>len) x=len;
|
|
|
|
if(mem) memcpy(mem+bytes,&ds->buffer[ds->buffer_pos],x);
|
|
|
|
bytes+=x;len-=x;ds->buffer_pos+=x;
|
|
|
|
return bytes; // stop at end of package! (for correct timestamping)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return bytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
void ds_free_packs(demux_stream_t *ds){
|
|
|
|
demux_packet_t *dp=ds->first;
|
|
|
|
while(dp){
|
|
|
|
demux_packet_t *dn=dp->next;
|
2002-05-25 22:13:23 +00:00
|
|
|
free_demux_packet(dp);
|
2001-02-24 20:28:24 +00:00
|
|
|
dp=dn;
|
|
|
|
}
|
|
|
|
if(ds->asf_packet){
|
|
|
|
// free unfinished .asf fragments:
|
|
|
|
free(ds->asf_packet->buffer);
|
|
|
|
free(ds->asf_packet);
|
|
|
|
ds->asf_packet=NULL;
|
|
|
|
}
|
|
|
|
ds->first=ds->last=NULL;
|
|
|
|
ds->packs=0; // !!!!!
|
|
|
|
ds->bytes=0;
|
2002-05-25 22:13:23 +00:00
|
|
|
if(ds->current) free_demux_packet(ds->current);
|
|
|
|
ds->current=NULL;
|
2001-02-24 20:28:24 +00:00
|
|
|
ds->buffer=NULL;
|
|
|
|
ds->buffer_pos=ds->buffer_size;
|
2001-05-17 22:15:00 +00:00
|
|
|
ds->pts=0; ds->pts_bytes=0;
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
|
|
|
|
2001-04-23 03:42:17 +00:00
|
|
|
int ds_get_packet(demux_stream_t *ds,unsigned char **start){
|
2001-02-24 20:28:24 +00:00
|
|
|
while(1){
|
|
|
|
int len;
|
|
|
|
if(ds->buffer_pos>=ds->buffer_size){
|
|
|
|
if(!ds_fill_buffer(ds)){
|
|
|
|
// EOF
|
|
|
|
*start = NULL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
len=ds->buffer_size-ds->buffer_pos;
|
|
|
|
*start = &ds->buffer[ds->buffer_pos];
|
|
|
|
ds->buffer_pos+=len;
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
}
|
2001-04-20 23:00:11 +00:00
|
|
|
|
2001-04-23 03:42:17 +00:00
|
|
|
int ds_get_packet_sub(demux_stream_t *ds,unsigned char **start){
|
2001-04-20 23:00:11 +00:00
|
|
|
while(1){
|
|
|
|
int len;
|
|
|
|
if(ds->buffer_pos>=ds->buffer_size){
|
|
|
|
*start = NULL;
|
|
|
|
if(!ds->packs) return -1; // no sub
|
|
|
|
if(!ds_fill_buffer(ds)) return -1; // EOF
|
|
|
|
}
|
|
|
|
len=ds->buffer_size-ds->buffer_pos;
|
|
|
|
*start = &ds->buffer[ds->buffer_pos];
|
|
|
|
ds->buffer_pos+=len;
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-05-02 10:25:48 +00:00
|
|
|
float ds_get_next_pts(demux_stream_t *ds) {
|
|
|
|
demuxer_t* demux = ds->demuxer;
|
|
|
|
while(!ds->first) {
|
|
|
|
if(demux->audio->packs>=MAX_PACKS || demux->audio->bytes>=MAX_PACK_BYTES){
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_TooManyAudioInBuffer,demux->audio->packs,demux->audio->bytes);
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_HINT,MSGTR_MaybeNI);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if(demux->video->packs>=MAX_PACKS || demux->video->bytes>=MAX_PACK_BYTES){
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_TooManyVideoInBuffer,demux->video->packs,demux->video->bytes);
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_HINT,MSGTR_MaybeNI);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if(!demux_fill_buffer(demux,ds))
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return ds->first->pts;
|
|
|
|
}
|
|
|
|
|
2001-07-21 22:37:55 +00:00
|
|
|
// ====================================================================
|
|
|
|
|
|
|
|
// commandline options, flags:
|
|
|
|
extern int force_ni;
|
|
|
|
extern int pts_from_bps;
|
|
|
|
|
2002-09-29 19:26:40 +00:00
|
|
|
//extern int audio_id;
|
|
|
|
//extern int video_id;
|
|
|
|
//extern int dvdsub_id;
|
2001-07-21 22:37:55 +00:00
|
|
|
|
|
|
|
int asf_check_header(demuxer_t *demuxer);
|
|
|
|
int read_asf_header(demuxer_t *demuxer);
|
|
|
|
demux_stream_t* demux_avi_select_stream(demuxer_t *demux,unsigned int id);
|
2001-10-02 21:45:41 +00:00
|
|
|
demuxer_t* demux_open_avi(demuxer_t* demuxer);
|
|
|
|
int mov_check_file(demuxer_t* demuxer);
|
|
|
|
int mov_read_header(demuxer_t* demuxer);
|
2001-11-24 23:58:12 +00:00
|
|
|
int demux_open_fli(demuxer_t* demuxer);
|
2002-02-06 20:16:35 +00:00
|
|
|
int demux_open_mf(demuxer_t* demuxer);
|
2002-01-16 03:25:07 +00:00
|
|
|
int demux_open_film(demuxer_t* demuxer);
|
2002-02-01 05:35:16 +00:00
|
|
|
int demux_open_roq(demuxer_t* demuxer);
|
2005-06-06 21:30:53 +00:00
|
|
|
int demux_mpg_probe(demuxer_t *demuxer);
|
2002-08-05 17:21:35 +00:00
|
|
|
#ifdef HAVE_LIBDV095
|
|
|
|
int demux_open_rawdv(demuxer_t* demuxer);
|
2002-10-04 19:23:36 +00:00
|
|
|
extern int rawdv_check_file(demuxer_t *demuxer);
|
2002-08-05 17:21:35 +00:00
|
|
|
#endif
|
2001-07-21 22:37:55 +00:00
|
|
|
|
2005-02-13 13:39:19 +00:00
|
|
|
#ifdef USE_WIN32DLL
|
|
|
|
int avs_check_file(demuxer_t *demuxer, const char *filename);
|
|
|
|
#endif
|
|
|
|
|
2005-06-13 20:40:29 +00:00
|
|
|
extern int demux_aac_open(demuxer_t *demuxer);
|
|
|
|
extern int demux_aac_probe(demuxer_t *demuxer);
|
2001-11-16 21:30:10 +00:00
|
|
|
extern int vivo_check_file(demuxer_t *demuxer);
|
|
|
|
extern void demux_open_vivo(demuxer_t *demuxer);
|
2001-12-27 02:08:31 +00:00
|
|
|
extern int y4m_check_file(demuxer_t *demuxer);
|
|
|
|
extern void demux_open_y4m(demuxer_t *demuxer);
|
2002-02-01 05:35:16 +00:00
|
|
|
extern int roq_check_file(demuxer_t *demuxer);
|
2002-09-10 21:50:03 +00:00
|
|
|
extern int pva_check_file(demuxer_t * demuxer);
|
2002-11-06 23:54:29 +00:00
|
|
|
extern demuxer_t * demux_open_pva(demuxer_t * demuxer);
|
2001-12-26 22:57:51 +00:00
|
|
|
extern int real_check_file(demuxer_t *demuxer);
|
|
|
|
extern void demux_open_real(demuxer_t *demuxer);
|
2004-04-12 14:19:12 +00:00
|
|
|
extern int nsv_check_file(demuxer_t *demuxer);
|
2001-12-27 21:24:56 +00:00
|
|
|
extern int nuv_check_file(demuxer_t *demuxer);
|
2004-04-12 14:19:12 +00:00
|
|
|
extern void demux_open_nsv(demuxer_t *demuxer);
|
2001-12-27 21:24:56 +00:00
|
|
|
extern void demux_open_nuv(demuxer_t *demuxer);
|
2002-02-14 13:04:35 +00:00
|
|
|
extern int demux_audio_open(demuxer_t* demuxer);
|
2005-07-10 17:14:12 +00:00
|
|
|
extern int demux_mpc_open(demuxer_t* demuxer);
|
2002-03-16 14:32:03 +00:00
|
|
|
extern int demux_ogg_open(demuxer_t* demuxer);
|
2004-10-23 00:05:38 +00:00
|
|
|
extern int demux_mpg_open(demuxer_t* demuxer);
|
2002-06-11 14:29:51 +00:00
|
|
|
extern int demux_rawaudio_open(demuxer_t* demuxer);
|
2003-01-22 23:51:04 +00:00
|
|
|
extern int demux_rawvideo_open(demuxer_t* demuxer);
|
2002-09-13 18:58:14 +00:00
|
|
|
extern int smjpeg_check_file(demuxer_t *demuxer);
|
|
|
|
extern int demux_open_smjpeg(demuxer_t* demuxer);
|
2002-12-22 21:01:01 +00:00
|
|
|
extern int demux_xmms_open(demuxer_t* demuxer);
|
2003-01-28 00:12:23 +00:00
|
|
|
extern int gif_check_file(demuxer_t *demuxer);
|
|
|
|
extern int demux_open_gif(demuxer_t* demuxer);
|
2003-12-08 19:33:38 +00:00
|
|
|
extern int lmlm4_check_file(demuxer_t* demuxer);
|
|
|
|
extern int demux_open_lmlm4(demuxer_t* demuxer);
|
2003-03-16 20:13:28 +00:00
|
|
|
extern int ts_check_file(demuxer_t * demuxer);
|
2003-05-31 17:41:45 +00:00
|
|
|
extern int demux_open_ts(demuxer_t *demuxer);
|
2003-04-30 11:39:32 +00:00
|
|
|
extern int demux_open_mkv(demuxer_t *demuxer);
|
2003-04-30 19:50:46 +00:00
|
|
|
extern int ra_check_file(demuxer_t *demuxer);
|
|
|
|
extern int demux_open_ra(demuxer_t* demuxer);
|
2004-12-29 19:51:56 +00:00
|
|
|
extern int demux_probe_vqf(demuxer_t *demuxer);
|
|
|
|
extern int demux_open_vqf(demuxer_t* demuxer);
|
2003-12-08 09:51:10 +00:00
|
|
|
#ifdef HAVE_MATROSKA
|
|
|
|
extern int demux_mkv_open(demuxer_t *demuxer);
|
|
|
|
#endif
|
2004-04-11 14:26:04 +00:00
|
|
|
extern int lavf_check_file(demuxer_t *demuxer);
|
|
|
|
extern int demux_open_lavf(demuxer_t* demuxer);
|
2005-02-13 13:39:19 +00:00
|
|
|
#ifdef USE_WIN32DLL
|
|
|
|
extern int demux_open_avs(demuxer_t* demuxer);
|
|
|
|
#endif
|
2002-03-16 14:32:03 +00:00
|
|
|
|
|
|
|
extern demuxer_t* init_avi_with_ogg(demuxer_t* demuxer);
|
2004-09-23 23:01:48 +00:00
|
|
|
#ifdef STREAMING_LIVE_DOT_COM
|
|
|
|
extern demuxer_t* demux_open_rtp(demuxer_t* demuxer);
|
|
|
|
#endif
|
2001-12-27 21:24:56 +00:00
|
|
|
|
2003-01-19 00:21:54 +00:00
|
|
|
int extension_parsing=1; // 0=off 1=mixed (used only for unstable formats)
|
2002-02-20 16:59:25 +00:00
|
|
|
|
2003-03-30 17:12:11 +00:00
|
|
|
/*
|
|
|
|
NOTE : Several demuxers may be opened at the same time so
|
|
|
|
demuxers should NEVER rely on an external var to enable them
|
|
|
|
self. If a demuxer can't do any autodection it should only use
|
|
|
|
file_format. The user can explictly set file_format with the -demuxer
|
|
|
|
option so there is really no need for another extra var.
|
|
|
|
For conivence an option can be added to set file_format directly
|
|
|
|
to the right type (ex: rawaudio,rawvideo).
|
|
|
|
Also the stream can override the file_format so a demuxer wich rely
|
|
|
|
on a special stream type can set file_format at the stream level
|
|
|
|
(ex: tv,mf).
|
|
|
|
*/
|
|
|
|
|
2003-01-19 00:21:54 +00:00
|
|
|
static demuxer_t* demux_open_stream(stream_t *stream,int file_format,int audio_id,int video_id,int dvdsub_id,char* filename){
|
2001-07-21 22:37:55 +00:00
|
|
|
|
|
|
|
//int file_format=(*file_format_ptr);
|
|
|
|
|
|
|
|
demuxer_t *demuxer=NULL;
|
|
|
|
|
|
|
|
demux_stream_t *d_audio=NULL;
|
|
|
|
demux_stream_t *d_video=NULL;
|
|
|
|
|
|
|
|
sh_audio_t *sh_audio=NULL;
|
|
|
|
sh_video_t *sh_video=NULL;
|
|
|
|
|
2001-08-23 13:20:25 +00:00
|
|
|
//printf("demux_open(%p,%d,%d,%d,%d) \n",stream,file_format,audio_id,video_id,dvdsub_id);
|
|
|
|
|
2003-03-30 17:12:11 +00:00
|
|
|
if(file_format == DEMUXER_TYPE_RAWAUDIO) {
|
2002-06-11 14:29:51 +00:00
|
|
|
demuxer = new_demuxer(stream,DEMUXER_TYPE_RAWAUDIO,audio_id,video_id,dvdsub_id);
|
|
|
|
}
|
2003-03-27 20:38:14 +00:00
|
|
|
if(file_format == DEMUXER_TYPE_RAWVIDEO) {
|
2003-01-22 23:51:04 +00:00
|
|
|
demuxer = new_demuxer(stream,DEMUXER_TYPE_RAWVIDEO,audio_id,video_id,dvdsub_id);
|
|
|
|
}
|
2002-06-11 14:29:51 +00:00
|
|
|
|
2001-11-09 23:46:06 +00:00
|
|
|
#ifdef USE_TV
|
|
|
|
//=============== Try to open as TV-input: =================
|
2003-03-30 17:12:11 +00:00
|
|
|
if(file_format==DEMUXER_TYPE_TV){
|
2001-11-09 23:46:06 +00:00
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_TV,audio_id,video_id,dvdsub_id);
|
2002-08-08 13:55:15 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_DetectedTV);
|
2001-11-09 23:46:06 +00:00
|
|
|
}
|
|
|
|
#endif
|
2001-11-24 23:58:12 +00:00
|
|
|
|
2002-08-06 21:21:14 +00:00
|
|
|
//=============== Try to open as multi file: =================
|
2003-03-30 17:12:11 +00:00
|
|
|
if(file_format==DEMUXER_TYPE_MF){
|
2002-08-06 21:21:14 +00:00
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_MF,audio_id,video_id,dvdsub_id);
|
|
|
|
mp_msg( MSGT_DEMUXER,MSGL_INFO,"[demuxer] mf support.\n" );
|
|
|
|
}
|
|
|
|
|
2001-07-21 22:37:55 +00:00
|
|
|
//=============== Try to open as AVI file: =================
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_AVI){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_AVI,audio_id,video_id,dvdsub_id);
|
|
|
|
{ //---- RIFF header:
|
|
|
|
int id=stream_read_dword_le(demuxer->stream); // "RIFF"
|
2004-10-08 21:28:19 +00:00
|
|
|
if((id==mmioFOURCC('R','I','F','F')) || (id==mmioFOURCC('O','N','2',' '))){
|
2001-07-21 22:37:55 +00:00
|
|
|
stream_read_dword_le(demuxer->stream); //filesize
|
|
|
|
id=stream_read_dword_le(demuxer->stream); // "AVI "
|
|
|
|
if(id==formtypeAVI){
|
2002-09-22 14:28:29 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"AVI");
|
2001-07-21 22:37:55 +00:00
|
|
|
file_format=DEMUXER_TYPE_AVI;
|
2002-02-20 16:59:25 +00:00
|
|
|
}
|
2004-10-08 21:28:19 +00:00
|
|
|
if(id==mmioFOURCC('O','N','2','f')){
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"ON2 AVI");
|
|
|
|
file_format=DEMUXER_TYPE_AVI;
|
|
|
|
}
|
2001-07-21 22:37:55 +00:00
|
|
|
}
|
2004-10-01 19:51:03 +00:00
|
|
|
if (file_format==DEMUXER_TYPE_UNKNOWN) {
|
|
|
|
free_demuxer(demuxer);
|
|
|
|
demuxer = NULL;
|
|
|
|
}
|
2001-07-21 22:37:55 +00:00
|
|
|
}
|
|
|
|
}
|
2001-12-27 02:08:31 +00:00
|
|
|
//=============== Try to open as Y4M file: =================
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_Y4M){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_Y4M,audio_id,video_id,dvdsub_id);
|
|
|
|
if(y4m_check_file(demuxer)){
|
2002-09-22 14:28:29 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"YUV4MPEG2");
|
2001-12-27 02:08:31 +00:00
|
|
|
file_format=DEMUXER_TYPE_Y4M;
|
2002-02-20 16:59:25 +00:00
|
|
|
} else {
|
2002-02-11 12:11:48 +00:00
|
|
|
free_demuxer(demuxer);
|
2002-02-20 16:59:25 +00:00
|
|
|
demuxer = NULL;
|
|
|
|
}
|
2001-12-27 02:08:31 +00:00
|
|
|
}
|
2001-12-28 16:49:10 +00:00
|
|
|
//=============== Try to open as ASF file: =================
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_ASF){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_ASF,audio_id,video_id,dvdsub_id);
|
|
|
|
if(asf_check_header(demuxer)){
|
2002-09-22 14:28:29 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"ASF");
|
2001-12-28 16:49:10 +00:00
|
|
|
file_format=DEMUXER_TYPE_ASF;
|
2002-02-20 16:59:25 +00:00
|
|
|
} else {
|
2002-02-11 12:11:48 +00:00
|
|
|
free_demuxer(demuxer);
|
2002-02-20 16:59:25 +00:00
|
|
|
demuxer = NULL;
|
|
|
|
}
|
2001-12-28 16:49:10 +00:00
|
|
|
}
|
2004-04-12 14:19:12 +00:00
|
|
|
//=============== Try to open as NSV file: =================
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_NSV){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_NSV,audio_id,video_id,dvdsub_id);
|
|
|
|
if(file_format==DEMUXER_TYPE_NSV||nsv_check_file(demuxer)){
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"Nullsoft Streaming Video");
|
|
|
|
file_format=DEMUXER_TYPE_NSV;
|
|
|
|
} else {
|
|
|
|
free_demuxer(demuxer);
|
|
|
|
demuxer = NULL;
|
|
|
|
}
|
|
|
|
}
|
2001-12-27 21:24:56 +00:00
|
|
|
//=============== Try to open as NUV file: =================
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_NUV){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_NUV,audio_id,video_id,dvdsub_id);
|
|
|
|
if(nuv_check_file(demuxer)){
|
2002-09-22 14:28:29 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"NuppelVideo");
|
2001-12-27 21:24:56 +00:00
|
|
|
file_format=DEMUXER_TYPE_NUV;
|
2002-02-20 16:59:25 +00:00
|
|
|
} else {
|
2002-02-11 12:11:48 +00:00
|
|
|
free_demuxer(demuxer);
|
2002-02-20 16:59:25 +00:00
|
|
|
demuxer = NULL;
|
|
|
|
}
|
2001-12-27 21:24:56 +00:00
|
|
|
}
|
2003-01-19 00:21:54 +00:00
|
|
|
//=============== Try to open as REAL file: =================
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_REAL){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_REAL,audio_id,video_id,dvdsub_id);
|
|
|
|
if(real_check_file(demuxer)){
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"REAL");
|
|
|
|
file_format=DEMUXER_TYPE_REAL;
|
|
|
|
} else {
|
|
|
|
free_demuxer(demuxer);
|
|
|
|
demuxer = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//=============== Try to open as SMJPEG file: =================
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_SMJPEG){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_SMJPEG,audio_id,video_id,dvdsub_id);
|
|
|
|
if(smjpeg_check_file(demuxer)){
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"SMJPEG");
|
|
|
|
file_format=DEMUXER_TYPE_SMJPEG;
|
|
|
|
} else {
|
|
|
|
free_demuxer(demuxer);
|
|
|
|
demuxer = NULL;
|
|
|
|
}
|
|
|
|
}
|
2003-04-30 11:39:32 +00:00
|
|
|
#ifdef HAVE_MATROSKA
|
|
|
|
//=============== Try to open as Matroska file: =================
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_MATROSKA){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_MATROSKA,audio_id,video_id,dvdsub_id);
|
|
|
|
if(demux_mkv_open(demuxer)){
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"Matroska");
|
|
|
|
file_format=DEMUXER_TYPE_MATROSKA;
|
|
|
|
} else {
|
|
|
|
free_demuxer(demuxer);
|
|
|
|
demuxer = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2003-04-30 19:50:46 +00:00
|
|
|
//=============== Try to open as REALAUDIO file: =================
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_REALAUDIO){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_REALAUDIO,audio_id,video_id,dvdsub_id);
|
|
|
|
if(ra_check_file(demuxer)){
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"REALAUDIO");
|
|
|
|
file_format=DEMUXER_TYPE_REALAUDIO;
|
|
|
|
} else {
|
|
|
|
free_demuxer(demuxer);
|
|
|
|
demuxer = NULL;
|
|
|
|
}
|
|
|
|
}
|
2003-01-19 00:21:54 +00:00
|
|
|
|
2004-12-29 19:51:56 +00:00
|
|
|
//=============== Try to open as VQF file: =================
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_VQF){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_VQF,audio_id,video_id,dvdsub_id);
|
|
|
|
if(demux_probe_vqf(demuxer)){
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"VQF");
|
|
|
|
file_format=DEMUXER_TYPE_VQF;
|
|
|
|
} else {
|
|
|
|
free_demuxer(demuxer);
|
|
|
|
demuxer = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-19 00:21:54 +00:00
|
|
|
//=============== Try based on filename EXTENSION: =================
|
|
|
|
// Ok. We're over the stable detectable fileformats, the next ones are a bit
|
|
|
|
// fuzzy. So by default (extension_parsing==1) try extension-based detection
|
|
|
|
// first:
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN && filename && extension_parsing==1){
|
|
|
|
file_format=demuxer_type_by_filename(filename);
|
|
|
|
if(file_format!=DEMUXER_TYPE_UNKNOWN){
|
|
|
|
// we like recursion :)
|
2005-02-13 13:39:19 +00:00
|
|
|
demuxer=demux_open_stream(stream,file_format,audio_id,video_id,dvdsub_id,filename);
|
2003-01-19 00:21:54 +00:00
|
|
|
if(demuxer) return demuxer; // done!
|
|
|
|
file_format=DEMUXER_TYPE_UNKNOWN; // continue fuzzy guessing...
|
2003-07-05 11:37:25 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_V,"demuxer: continue fuzzy content-based format guessing...\n");
|
2003-01-19 00:21:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-13 21:10:51 +00:00
|
|
|
//=============== Try to open as MOV file: =================
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_MOV){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_MOV,audio_id,video_id,dvdsub_id);
|
|
|
|
if(mov_check_file(demuxer)){
|
2002-09-22 14:28:29 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"QuickTime/MOV");
|
2003-01-13 02:42:06 +00:00
|
|
|
file_format=demuxer->type;
|
2002-02-20 16:59:25 +00:00
|
|
|
} else {
|
2002-02-11 12:11:48 +00:00
|
|
|
free_demuxer(demuxer);
|
2002-02-20 16:59:25 +00:00
|
|
|
demuxer = NULL;
|
|
|
|
}
|
2001-11-13 21:10:51 +00:00
|
|
|
}
|
2001-12-01 22:12:58 +00:00
|
|
|
//=============== Try to open as VIVO file: =================
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_VIVO){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_VIVO,audio_id,video_id,dvdsub_id);
|
|
|
|
if(vivo_check_file(demuxer)){
|
2002-09-22 14:28:29 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat, "VIVO");
|
2001-12-01 22:12:58 +00:00
|
|
|
file_format=DEMUXER_TYPE_VIVO;
|
2002-02-20 16:59:25 +00:00
|
|
|
} else {
|
|
|
|
free_demuxer(demuxer);
|
|
|
|
demuxer = NULL;
|
2001-12-01 22:12:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//=============== Try to open as FLI file: =================
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_FLI){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_FLI,audio_id,video_id,dvdsub_id);
|
|
|
|
{
|
2002-01-16 03:25:07 +00:00
|
|
|
int id;
|
|
|
|
stream_seek(demuxer->stream, 4);
|
|
|
|
id=stream_read_word_le(demuxer->stream);
|
|
|
|
// check for the FLI file magic number
|
2001-12-01 22:12:58 +00:00
|
|
|
if((id==0xAF11) || (id==0xAF12)){
|
2002-09-22 14:28:29 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"FLI");
|
2001-12-01 22:12:58 +00:00
|
|
|
file_format=DEMUXER_TYPE_FLI;
|
2002-02-20 16:59:25 +00:00
|
|
|
} else {
|
2002-02-11 12:11:48 +00:00
|
|
|
free_demuxer(demuxer);
|
2002-02-20 16:59:25 +00:00
|
|
|
demuxer = NULL;
|
|
|
|
}
|
2001-12-01 22:12:58 +00:00
|
|
|
}
|
|
|
|
}
|
2002-01-16 03:25:07 +00:00
|
|
|
//=============== Try to open as FILM file: =================
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_FILM){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_FILM,audio_id,video_id,dvdsub_id);
|
|
|
|
{
|
|
|
|
int signature=stream_read_fourcc(demuxer->stream);
|
|
|
|
// check for the FLI file magic number
|
|
|
|
if(signature==mmioFOURCC('F', 'I', 'L', 'M')){
|
2002-09-22 14:28:29 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"FILM");
|
2002-01-16 03:25:07 +00:00
|
|
|
file_format=DEMUXER_TYPE_FILM;
|
2002-02-20 16:59:25 +00:00
|
|
|
} else {
|
2002-02-11 12:11:48 +00:00
|
|
|
free_demuxer(demuxer);
|
2002-02-20 16:59:25 +00:00
|
|
|
demuxer = NULL;
|
|
|
|
}
|
2002-01-16 03:25:07 +00:00
|
|
|
}
|
|
|
|
}
|
2002-02-01 05:35:16 +00:00
|
|
|
//=============== Try to open as RoQ file: =================
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_ROQ){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_ROQ,audio_id,video_id,dvdsub_id);
|
|
|
|
if(roq_check_file(demuxer)){
|
2002-09-22 14:28:29 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"ROQ");
|
2002-02-01 05:35:16 +00:00
|
|
|
file_format=DEMUXER_TYPE_ROQ;
|
2002-02-20 16:59:25 +00:00
|
|
|
} else {
|
2002-02-11 12:11:48 +00:00
|
|
|
free_demuxer(demuxer);
|
2002-02-20 16:59:25 +00:00
|
|
|
demuxer = NULL;
|
|
|
|
}
|
2002-02-01 05:35:16 +00:00
|
|
|
}
|
2003-01-28 00:12:23 +00:00
|
|
|
#ifdef HAVE_GIF
|
|
|
|
//=============== Try to open as GIF file: =================
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_GIF){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_GIF,audio_id,video_id,dvdsub_id);
|
|
|
|
if(gif_check_file(demuxer)){
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"GIF");
|
|
|
|
file_format=DEMUXER_TYPE_GIF;
|
|
|
|
} else {
|
|
|
|
free_demuxer(demuxer);
|
|
|
|
demuxer = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2002-09-15 22:38:30 +00:00
|
|
|
#ifdef HAVE_OGGVORBIS
|
2002-03-16 14:32:03 +00:00
|
|
|
//=============== Try to open as Ogg file: =================
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_OGG){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_OGG,audio_id,video_id,dvdsub_id);
|
|
|
|
if(demux_ogg_open(demuxer)){
|
2004-05-07 08:31:39 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"Ogg");
|
2002-03-16 14:32:03 +00:00
|
|
|
file_format=DEMUXER_TYPE_OGG;
|
|
|
|
} else {
|
|
|
|
free_demuxer(demuxer);
|
|
|
|
demuxer = NULL;
|
|
|
|
}
|
|
|
|
}
|
2002-09-15 22:38:30 +00:00
|
|
|
#endif
|
2005-02-13 13:39:19 +00:00
|
|
|
#ifdef USE_WIN32DLL
|
|
|
|
//=============== Try to open as Avisynth file: =================
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_AVS){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_AVS,audio_id,video_id,dvdsub_id);
|
|
|
|
if (avs_check_file(demuxer, filename)){
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"AVS");
|
|
|
|
file_format=DEMUXER_TYPE_AVS;
|
|
|
|
} else {
|
|
|
|
free_demuxer(demuxer);
|
|
|
|
demuxer = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2002-09-10 21:50:03 +00:00
|
|
|
//=============== Try to open as PVA file: =================
|
|
|
|
if(file_format == DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_PVA){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_PVA,audio_id,video_id,dvdsub_id);
|
|
|
|
if(pva_check_file(demuxer)) {
|
2002-09-22 14:28:29 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"PVA");
|
2002-09-10 21:50:03 +00:00
|
|
|
file_format=DEMUXER_TYPE_PVA;
|
|
|
|
} else {
|
|
|
|
free_demuxer(demuxer);
|
|
|
|
demuxer=NULL;
|
|
|
|
}
|
|
|
|
}
|
2003-03-16 20:13:28 +00:00
|
|
|
//=============== Try to open as MPEG-TS file: =================
|
|
|
|
if(file_format == DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_MPEG_TS){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_MPEG_TS,audio_id,video_id,dvdsub_id);
|
|
|
|
if(ts_check_file(demuxer)) {
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"TS");
|
|
|
|
file_format=DEMUXER_TYPE_MPEG_TS;
|
|
|
|
} else {
|
|
|
|
free_demuxer(demuxer);
|
|
|
|
demuxer=NULL;
|
|
|
|
}
|
|
|
|
}
|
2003-12-08 19:33:38 +00:00
|
|
|
//=============== Try to open as LMLM4 file: =================
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_LMLM4){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_LMLM4,audio_id,video_id,dvdsub_id);
|
|
|
|
if(lmlm4_check_file(demuxer)){
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"RAW LMLM4");
|
|
|
|
file_format=DEMUXER_TYPE_LMLM4;
|
|
|
|
} else {
|
|
|
|
free_demuxer(demuxer);
|
|
|
|
demuxer = NULL;
|
|
|
|
}
|
|
|
|
}
|
2001-12-26 16:34:06 +00:00
|
|
|
|
2005-06-06 21:30:53 +00:00
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_MPEG_PS){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_MPEG_PS,audio_id,video_id,dvdsub_id);
|
|
|
|
file_format = demux_mpg_probe(demuxer);
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_V,"demux_mpg_probe returned file_format %d\n", file_format);
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN) {
|
|
|
|
free_demuxer(demuxer);
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_MPEG_PS,audio_id,video_id,dvdsub_id);
|
|
|
|
demuxer->synced = 3;
|
|
|
|
file_format = demux_mpg_probe(demuxer);
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_V,"demux_mpg_probe returned file_format %d\n", file_format);
|
|
|
|
if(file_format==DEMUXER_TYPE_MPEG_PS)
|
2002-09-22 14:28:29 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"MPEG-PES");
|
2005-06-06 21:30:53 +00:00
|
|
|
} else if(file_format==DEMUXER_TYPE_MPEG_PS)
|
2002-09-22 14:28:29 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"MPEG-PS");
|
2005-06-06 21:30:53 +00:00
|
|
|
|
|
|
|
if(file_format != DEMUXER_TYPE_MPEG_PS) {
|
|
|
|
free_demuxer(demuxer);
|
|
|
|
demuxer = NULL;
|
2001-07-21 22:37:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//=============== Try to open as MPEG-ES file: =================
|
2003-04-04 15:38:46 +00:00
|
|
|
if(file_format==DEMUXER_TYPE_MPEG_ES || file_format==DEMUXER_TYPE_MPEG4_ES || file_format==DEMUXER_TYPE_H264_ES){ // little hack, see above!
|
2003-01-23 02:12:15 +00:00
|
|
|
demuxer=new_demuxer(stream,file_format,audio_id,video_id,dvdsub_id);
|
2001-07-21 22:37:55 +00:00
|
|
|
if(!ds_fill_buffer(demuxer->video)){
|
2001-08-18 20:32:09 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_InvalidMPEGES);
|
2001-07-21 22:37:55 +00:00
|
|
|
file_format=DEMUXER_TYPE_UNKNOWN;
|
2002-02-11 12:11:48 +00:00
|
|
|
free_demuxer(demuxer);
|
2002-02-20 16:59:25 +00:00
|
|
|
demuxer = NULL;
|
2001-07-21 22:37:55 +00:00
|
|
|
} else {
|
2003-04-04 15:38:46 +00:00
|
|
|
switch(file_format){
|
|
|
|
case DEMUXER_TYPE_MPEG_ES:
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat, "MPEG-ES"); break;
|
|
|
|
case DEMUXER_TYPE_MPEG4_ES:
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat, "MPEG4-ES"); break;
|
|
|
|
case DEMUXER_TYPE_H264_ES:
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat, "H264-ES"); break;
|
|
|
|
}
|
2001-07-21 22:37:55 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-05 17:21:35 +00:00
|
|
|
#ifdef HAVE_LIBDV095
|
|
|
|
//=============== Try to open raw DV file, as produced by dvgrab --format raw =================
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_RAWDV)
|
|
|
|
{
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_RAWDV,audio_id,video_id,dvdsub_id);
|
2002-10-04 19:23:36 +00:00
|
|
|
if(rawdv_check_file(demuxer))
|
2002-08-05 17:21:35 +00:00
|
|
|
{
|
2002-09-22 14:28:29 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"RAWDV");
|
2002-08-05 17:21:35 +00:00
|
|
|
file_format=DEMUXER_TYPE_RAWDV;
|
|
|
|
}
|
2003-01-06 14:54:36 +00:00
|
|
|
else {
|
2002-08-05 17:21:35 +00:00
|
|
|
free_demuxer(demuxer);
|
2003-01-06 14:54:36 +00:00
|
|
|
demuxer=NULL;
|
|
|
|
}
|
2002-08-05 17:21:35 +00:00
|
|
|
}
|
|
|
|
#endif
|
2002-02-14 16:09:36 +00:00
|
|
|
//=============== Try to open as audio file: =================
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_AUDIO){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_AUDIO,audio_id,video_id,dvdsub_id);
|
|
|
|
if(demux_audio_open(demuxer)){
|
2002-08-08 13:55:15 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_DetectedAudiofile);
|
2002-02-14 16:09:36 +00:00
|
|
|
file_format=DEMUXER_TYPE_AUDIO;
|
2002-02-20 16:59:25 +00:00
|
|
|
} else {
|
2002-02-14 16:09:36 +00:00
|
|
|
free_demuxer(demuxer);
|
2002-02-20 16:59:25 +00:00
|
|
|
demuxer = NULL;
|
|
|
|
}
|
2002-02-14 16:09:36 +00:00
|
|
|
}
|
2005-07-10 17:14:12 +00:00
|
|
|
//=============== Try to open as musepack file: =================
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_MPC){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_MPC,audio_id,video_id,dvdsub_id);
|
|
|
|
if(demux_mpc_open(demuxer)){
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat, "MPC");
|
|
|
|
file_format=DEMUXER_TYPE_MPC;
|
|
|
|
} else {
|
|
|
|
free_demuxer(demuxer);
|
|
|
|
demuxer = NULL;
|
|
|
|
}
|
|
|
|
}
|
2002-12-22 21:01:01 +00:00
|
|
|
#ifdef HAVE_XMMS
|
|
|
|
//=============== Try to open as XMMS file: =================
|
2003-05-23 13:29:54 +00:00
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_XMMS){
|
2002-12-22 21:01:01 +00:00
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_XMMS,audio_id,video_id,dvdsub_id);
|
|
|
|
if(demux_xmms_open(demuxer)){
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_DetectedAudiofile);
|
|
|
|
file_format=DEMUXER_TYPE_XMMS;
|
|
|
|
} else {
|
|
|
|
free_demuxer(demuxer);
|
|
|
|
demuxer = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2003-06-09 22:01:33 +00:00
|
|
|
//=============== Try to open as MPEG-TY file: =================
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_MPEG_TY)
|
|
|
|
{
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_MPEG_TY,audio_id,video_id,dvdsub_id);
|
|
|
|
if(ds_fill_buffer(demuxer->video)){
|
2003-07-19 17:39:47 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"TiVo");
|
2003-06-09 22:01:33 +00:00
|
|
|
file_format=DEMUXER_TYPE_MPEG_TY;
|
|
|
|
} else {
|
|
|
|
free_demuxer(demuxer);
|
|
|
|
demuxer = NULL;
|
|
|
|
}
|
|
|
|
}
|
2002-08-14 21:55:48 +00:00
|
|
|
//=============== Try to open as a RTP stream: ===========
|
2002-08-05 00:39:07 +00:00
|
|
|
if(file_format==DEMUXER_TYPE_RTP) {
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_RTP,audio_id,video_id,dvdsub_id);
|
|
|
|
}
|
2004-04-11 14:26:04 +00:00
|
|
|
//=============== Try to open with LAVF: =================
|
|
|
|
#ifdef USE_LIBAVFORMAT
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_LAVF){
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_LAVF,audio_id,video_id,dvdsub_id);
|
|
|
|
if(lavf_check_file(demuxer)){
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat,"libavformat"); //FIXME print format
|
|
|
|
file_format=DEMUXER_TYPE_LAVF;
|
|
|
|
} else {
|
|
|
|
free_demuxer(demuxer);
|
|
|
|
demuxer = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2005-06-13 20:40:29 +00:00
|
|
|
//================Try AAC ===============================
|
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_AAC) {
|
|
|
|
demuxer=new_demuxer(stream,DEMUXER_TYPE_AAC,audio_id,video_id,dvdsub_id);
|
|
|
|
if(! demux_aac_probe(demuxer)) {
|
|
|
|
free_demuxer(demuxer);
|
|
|
|
demuxer = NULL;
|
|
|
|
} else file_format = DEMUXER_TYPE_AAC;
|
|
|
|
}
|
2001-07-21 22:37:55 +00:00
|
|
|
//=============== Unknown, exiting... ===========================
|
2002-02-20 16:59:25 +00:00
|
|
|
if(file_format==DEMUXER_TYPE_UNKNOWN || demuxer == NULL){
|
2003-01-12 19:41:38 +00:00
|
|
|
//mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_FormatNotRecognized); // will be done by mplayer.c after fallback to playlist-parsing
|
2001-07-21 22:37:55 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
//====== File format recognized, set up these for compatibility: =========
|
|
|
|
d_audio=demuxer->audio;
|
|
|
|
d_video=demuxer->video;
|
|
|
|
//d_dvdsub=demuxer->sub;
|
|
|
|
|
2001-08-11 20:37:33 +00:00
|
|
|
demuxer->file_format=file_format;
|
|
|
|
|
2001-07-21 22:37:55 +00:00
|
|
|
switch(file_format){
|
2002-08-05 17:21:35 +00:00
|
|
|
#ifdef HAVE_LIBDV095
|
|
|
|
case DEMUXER_TYPE_RAWDV:
|
|
|
|
{
|
|
|
|
if (!demux_open_rawdv(demuxer)) return NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
2002-06-11 14:29:51 +00:00
|
|
|
case DEMUXER_TYPE_RAWAUDIO: {
|
|
|
|
demux_rawaudio_open(demuxer);
|
|
|
|
break;
|
|
|
|
}
|
2003-01-22 23:51:04 +00:00
|
|
|
case DEMUXER_TYPE_RAWVIDEO: {
|
|
|
|
demux_rawvideo_open(demuxer);
|
|
|
|
break;
|
|
|
|
}
|
2002-02-06 20:16:35 +00:00
|
|
|
case DEMUXER_TYPE_MF: {
|
|
|
|
if (!demux_open_mf(demuxer)) return NULL;
|
|
|
|
break;
|
|
|
|
}
|
2001-11-24 23:58:12 +00:00
|
|
|
case DEMUXER_TYPE_FLI: {
|
|
|
|
if (!demux_open_fli(demuxer)) return NULL;
|
|
|
|
break;
|
|
|
|
}
|
2002-01-16 03:25:07 +00:00
|
|
|
case DEMUXER_TYPE_FILM: {
|
|
|
|
if (!demux_open_film(demuxer)) return NULL;
|
2002-02-01 05:35:16 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-01-28 00:12:23 +00:00
|
|
|
#ifdef HAVE_GIF
|
|
|
|
case DEMUXER_TYPE_GIF: {
|
|
|
|
if (!demux_open_gif(demuxer)) return NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
2002-02-01 05:35:16 +00:00
|
|
|
case DEMUXER_TYPE_ROQ: {
|
|
|
|
if (!demux_open_roq(demuxer)) return NULL;
|
2002-01-16 03:25:07 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-09-13 18:58:14 +00:00
|
|
|
case DEMUXER_TYPE_SMJPEG: {
|
|
|
|
if (!demux_open_smjpeg(demuxer)) return NULL;
|
|
|
|
break;
|
|
|
|
}
|
2001-08-12 01:58:05 +00:00
|
|
|
case DEMUXER_TYPE_MOV: {
|
2001-10-07 21:59:49 +00:00
|
|
|
if(!mov_read_header(demuxer)) return NULL;
|
|
|
|
// sh_video=d_video->sh;if(sh_video) sh_video->ds=d_video;
|
|
|
|
// sh_audio=d_audio->sh;if(sh_audio) sh_audio->ds=d_audio;
|
2001-08-12 01:58:05 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-07-21 22:37:55 +00:00
|
|
|
case DEMUXER_TYPE_AVI: {
|
2002-03-16 14:32:03 +00:00
|
|
|
sh_audio_t* sh_a;
|
|
|
|
demuxer = (demuxer_t*) demux_open_avi(demuxer);
|
2002-03-31 02:45:14 +00:00
|
|
|
if(!demuxer) return NULL; // failed to open
|
2002-03-16 14:32:03 +00:00
|
|
|
sh_a = (sh_audio_t*)demuxer->audio->sh;
|
2002-04-29 13:36:18 +00:00
|
|
|
if(demuxer->audio->id != -2 && sh_a) {
|
2002-09-15 22:38:30 +00:00
|
|
|
#ifdef HAVE_OGGVORBIS
|
|
|
|
// support for Ogg-in-AVI:
|
2002-04-29 13:36:18 +00:00
|
|
|
if(sh_a->format == 0xFFFE)
|
|
|
|
demuxer = init_avi_with_ogg(demuxer);
|
|
|
|
else if(sh_a->format == 0x674F) {
|
|
|
|
stream_t* s;
|
|
|
|
demuxer_t *od;
|
|
|
|
s = new_ds_stream(demuxer->audio);
|
|
|
|
od = new_demuxer(s,DEMUXER_TYPE_OGG,-1,-2,-2);
|
|
|
|
if(!demux_ogg_open(od)) {
|
2002-08-08 13:55:15 +00:00
|
|
|
mp_msg( MSGT_DEMUXER,MSGL_ERR,MSGTR_ErrorOpeningOGGDemuxer);
|
2002-04-29 13:36:18 +00:00
|
|
|
free_stream(s);
|
|
|
|
demuxer->audio->id = -2;
|
|
|
|
} else
|
|
|
|
demuxer = new_demuxers_demuxer(demuxer,od,demuxer);
|
|
|
|
}
|
2002-09-15 22:38:30 +00:00
|
|
|
#endif
|
2002-04-29 13:36:18 +00:00
|
|
|
}
|
2002-03-16 14:32:03 +00:00
|
|
|
return demuxer;
|
2001-08-11 20:37:33 +00:00
|
|
|
// break;
|
2001-07-21 22:37:55 +00:00
|
|
|
}
|
2004-04-12 14:19:12 +00:00
|
|
|
case DEMUXER_TYPE_NSV: {
|
|
|
|
demux_open_nsv(demuxer);
|
|
|
|
break;
|
|
|
|
}
|
2001-12-27 21:24:56 +00:00
|
|
|
case DEMUXER_TYPE_NUV: {
|
|
|
|
demux_open_nuv(demuxer);
|
|
|
|
break;
|
|
|
|
}
|
2001-11-04 16:57:09 +00:00
|
|
|
case DEMUXER_TYPE_VIVO: {
|
|
|
|
demux_open_vivo(demuxer);
|
|
|
|
break;
|
|
|
|
}
|
2002-09-10 21:50:03 +00:00
|
|
|
case DEMUXER_TYPE_PVA: {
|
|
|
|
demux_open_pva(demuxer);
|
|
|
|
break;
|
|
|
|
}
|
2001-12-27 02:08:31 +00:00
|
|
|
case DEMUXER_TYPE_Y4M: {
|
|
|
|
demux_open_y4m(demuxer);
|
|
|
|
break;
|
|
|
|
}
|
2003-12-08 19:33:38 +00:00
|
|
|
case DEMUXER_TYPE_LMLM4: {
|
|
|
|
demux_open_lmlm4(demuxer);
|
|
|
|
if(!ds_fill_buffer(d_video)){
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,"LMLM4: " MSGTR_MissingVideoStream);
|
2005-05-27 12:38:29 +00:00
|
|
|
d_video->sh=NULL;
|
2003-12-08 19:33:38 +00:00
|
|
|
} else {
|
|
|
|
sh_video=d_video->sh;sh_video->ds=d_video;
|
|
|
|
}
|
|
|
|
if(audio_id!=-2) {
|
|
|
|
if(!ds_fill_buffer(d_audio)){
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,"LMLM4: " MSGTR_MissingAudioStream);
|
2005-05-27 12:38:29 +00:00
|
|
|
d_audio->sh=NULL;
|
2003-12-08 19:33:38 +00:00
|
|
|
} else {
|
|
|
|
sh_audio=d_audio->sh;sh_audio->ds=d_audio;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2001-12-26 22:57:51 +00:00
|
|
|
case DEMUXER_TYPE_REAL: {
|
|
|
|
demux_open_real(demuxer);
|
|
|
|
break;
|
|
|
|
}
|
2001-07-21 22:37:55 +00:00
|
|
|
case DEMUXER_TYPE_ASF: {
|
|
|
|
//---- ASF header:
|
|
|
|
read_asf_header(demuxer);
|
|
|
|
stream_reset(demuxer->stream);
|
|
|
|
stream_seek(demuxer->stream,demuxer->movi_start);
|
2001-08-11 20:37:33 +00:00
|
|
|
// demuxer->idx_pos=0;
|
2001-07-21 22:37:55 +00:00
|
|
|
// demuxer->endpos=avi_header.movi_end;
|
2002-02-08 16:00:14 +00:00
|
|
|
if(d_video->id != -2) {
|
|
|
|
if(!ds_fill_buffer(d_video)){
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_WARN,"ASF: " MSGTR_MissingVideoStream);
|
2005-05-27 12:38:29 +00:00
|
|
|
d_video->sh=NULL;
|
2002-02-08 16:00:14 +00:00
|
|
|
//printf("ASF: missing video stream!? contact the author, it may be a bug :(\n");
|
|
|
|
} else {
|
|
|
|
sh_video=d_video->sh;sh_video->ds=d_video;
|
|
|
|
sh_video->fps=1000.0f; sh_video->frametime=0.001f; // 1ms
|
|
|
|
// sh_video->i_bps=10*asf_packetsize; // FIXME!
|
|
|
|
}
|
2001-07-21 22:37:55 +00:00
|
|
|
}
|
2002-02-08 16:00:14 +00:00
|
|
|
if(d_audio->id!=-2){
|
2002-08-08 13:55:15 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_V,MSGTR_ASFSearchingForAudioStream,d_audio->id);
|
2001-07-21 22:37:55 +00:00
|
|
|
if(!ds_fill_buffer(d_audio)){
|
2001-09-26 21:35:14 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,"ASF: " MSGTR_MissingAudioStream);
|
2005-05-27 12:38:29 +00:00
|
|
|
d_audio->sh=NULL;
|
2001-07-21 22:37:55 +00:00
|
|
|
} else {
|
|
|
|
sh_audio=d_audio->sh;sh_audio->ds=d_audio;
|
|
|
|
sh_audio->format=sh_audio->wf->wFormatTag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2003-04-04 15:38:46 +00:00
|
|
|
case DEMUXER_TYPE_H264_ES:
|
2003-01-23 02:12:15 +00:00
|
|
|
case DEMUXER_TYPE_MPEG4_ES:
|
2001-07-21 22:37:55 +00:00
|
|
|
case DEMUXER_TYPE_MPEG_ES: {
|
2005-05-27 12:38:29 +00:00
|
|
|
d_audio->sh=NULL; // ES streams has no audio channel
|
2001-07-21 22:37:55 +00:00
|
|
|
d_video->sh=new_sh_video(demuxer,0); // create dummy video stream header, id=0
|
|
|
|
sh_video=d_video->sh;sh_video->ds=d_video;
|
|
|
|
break;
|
|
|
|
}
|
2003-06-09 00:24:49 +00:00
|
|
|
|
2005-04-03 14:08:28 +00:00
|
|
|
case DEMUXER_TYPE_MPEG_TY:
|
2001-07-21 22:37:55 +00:00
|
|
|
case DEMUXER_TYPE_MPEG_PS: {
|
|
|
|
sh_video=d_video->sh;sh_video->ds=d_video;
|
2002-01-27 20:10:28 +00:00
|
|
|
// if(demuxer->stream->type!=STREAMTYPE_VCD) demuxer->movi_start=0; // for VCD
|
2001-08-22 19:03:15 +00:00
|
|
|
|
2001-07-21 22:37:55 +00:00
|
|
|
if(audio_id!=-2) {
|
|
|
|
if(!ds_fill_buffer(d_audio)){
|
2001-09-26 21:35:14 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_INFO,"MPEG: " MSGTR_MissingAudioStream);
|
2005-05-27 12:38:29 +00:00
|
|
|
d_audio->sh=NULL;
|
2001-07-21 22:37:55 +00:00
|
|
|
} else {
|
|
|
|
sh_audio=d_audio->sh;sh_audio->ds=d_audio;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2001-11-09 23:46:06 +00:00
|
|
|
#ifdef USE_TV
|
|
|
|
case DEMUXER_TYPE_TV: {
|
2002-09-08 23:00:01 +00:00
|
|
|
if (!demux_open_tv(demuxer)) return(NULL);
|
2001-11-09 23:46:06 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
2002-08-05 00:39:07 +00:00
|
|
|
#ifdef STREAMING_LIVE_DOT_COM
|
|
|
|
case DEMUXER_TYPE_RTP: {
|
2004-10-18 18:51:35 +00:00
|
|
|
if (!(demuxer = demux_open_rtp(demuxer))) return NULL;
|
2002-08-05 00:39:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
2004-11-24 18:55:03 +00:00
|
|
|
case DEMUXER_TYPE_MPEG_TS: {
|
2003-03-16 20:13:28 +00:00
|
|
|
demux_open_ts(demuxer);
|
|
|
|
break;
|
|
|
|
}
|
2003-04-30 19:50:46 +00:00
|
|
|
case DEMUXER_TYPE_REALAUDIO: {
|
|
|
|
if (!demux_open_ra(demuxer)) return NULL;
|
|
|
|
break;
|
|
|
|
}
|
2004-12-29 19:51:56 +00:00
|
|
|
case DEMUXER_TYPE_VQF: {
|
|
|
|
if (!demux_open_vqf(demuxer)) return NULL;
|
|
|
|
break;
|
|
|
|
}
|
2005-06-13 20:40:29 +00:00
|
|
|
case DEMUXER_TYPE_AAC: {
|
|
|
|
if (!demux_aac_open(demuxer)) return NULL;
|
|
|
|
break;
|
|
|
|
}
|
2004-04-11 14:26:04 +00:00
|
|
|
#ifdef USE_LIBAVFORMAT
|
|
|
|
case DEMUXER_TYPE_LAVF: {
|
|
|
|
if (!demux_open_lavf(demuxer)) return NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
2005-02-13 13:39:19 +00:00
|
|
|
#ifdef USE_WIN32DLL
|
|
|
|
case DEMUXER_TYPE_AVS: {
|
|
|
|
if (!demux_open_avs(demuxer)) return NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
2001-07-21 22:37:55 +00:00
|
|
|
} // switch(file_format)
|
2001-10-31 15:04:36 +00:00
|
|
|
pts_from_bps=0; // !!!
|
2004-09-10 02:07:16 +00:00
|
|
|
if ((sh_video=demuxer->video->sh) && sh_video->bih)
|
|
|
|
mp_msg(MSGT_DEMUX,MSGL_INFO,"VIDEO: [%.4s] %ldx%ld %dbpp %5.3f fps %5.1f kbps (%4.1f kbyte/s)\n",
|
|
|
|
(char *)&sh_video->bih->biCompression,
|
|
|
|
sh_video->bih->biWidth,
|
|
|
|
sh_video->bih->biHeight,
|
|
|
|
sh_video->bih->biBitCount,
|
|
|
|
sh_video->fps,
|
|
|
|
sh_video->i_bps*0.008f,
|
|
|
|
sh_video->i_bps/1024.0f );
|
2001-07-21 22:37:55 +00:00
|
|
|
return demuxer;
|
|
|
|
}
|
2001-08-12 17:28:16 +00:00
|
|
|
|
2002-07-02 22:31:50 +00:00
|
|
|
char* audio_stream = NULL;
|
2002-10-23 17:21:01 +00:00
|
|
|
char* sub_stream = NULL;
|
|
|
|
int demuxer_type = 0, audio_demuxer_type = 0, sub_demuxer_type = 0;
|
2003-03-27 20:38:14 +00:00
|
|
|
int audio_stream_cache = 0;
|
2002-10-23 17:21:01 +00:00
|
|
|
|
|
|
|
extern int hr_mp3_seek;
|
2002-02-20 16:59:25 +00:00
|
|
|
|
2004-07-16 20:31:17 +00:00
|
|
|
extern float stream_cache_min_percent;
|
|
|
|
extern float stream_cache_prefill_percent;
|
|
|
|
|
2003-01-19 00:21:54 +00:00
|
|
|
demuxer_t* demux_open(stream_t *vs,int file_format,int audio_id,int video_id,int dvdsub_id,char* filename){
|
2002-02-20 16:59:25 +00:00
|
|
|
stream_t *as = NULL,*ss = NULL;
|
|
|
|
demuxer_t *vd,*ad = NULL,*sd = NULL;
|
2004-04-17 16:46:41 +00:00
|
|
|
int afmt =DEMUXER_TYPE_UNKNOWN,sfmt = DEMUXER_TYPE_UNKNOWN ;
|
2002-02-20 16:59:25 +00:00
|
|
|
|
2004-11-25 22:24:00 +00:00
|
|
|
demux_aid_vid_mismatch = 0;
|
|
|
|
|
2002-02-20 16:59:25 +00:00
|
|
|
if(audio_stream) {
|
|
|
|
as = open_stream(audio_stream,0,&afmt);
|
|
|
|
if(!as) {
|
2002-08-08 13:55:15 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_CannotOpenAudioStream,audio_stream);
|
2002-02-20 16:59:25 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2003-03-27 20:38:14 +00:00
|
|
|
if(audio_stream_cache) {
|
2004-07-16 20:31:17 +00:00
|
|
|
if(!stream_enable_cache(as,audio_stream_cache*1024,audio_stream_cache*1024*(stream_cache_min_percent / 100.0),
|
|
|
|
audio_stream_cache*1024*(stream_cache_prefill_percent / 100.0))) {
|
2003-03-27 20:38:14 +00:00
|
|
|
free_stream(as);
|
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_ERR,"Can't enable audio stream cache\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2002-02-20 16:59:25 +00:00
|
|
|
}
|
|
|
|
if(sub_stream) {
|
|
|
|
ss = open_stream(sub_stream,0,&sfmt);
|
|
|
|
if(!ss) {
|
2002-08-08 13:55:15 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_CannotOpenSubtitlesStream,sub_stream);
|
2002-02-20 16:59:25 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-19 00:21:54 +00:00
|
|
|
vd = demux_open_stream(vs,demuxer_type ? demuxer_type : file_format,audio_stream ? -2 : audio_id,video_id, sub_stream ? -2 : dvdsub_id, filename);
|
2003-03-27 20:38:14 +00:00
|
|
|
if(!vd) {
|
|
|
|
if(as) free_stream(as);
|
|
|
|
if(ss) free_stream(ss);
|
2002-02-20 16:59:25 +00:00
|
|
|
return NULL;
|
2003-03-27 20:38:14 +00:00
|
|
|
}
|
2002-02-20 16:59:25 +00:00
|
|
|
if(as) {
|
2003-01-19 00:21:54 +00:00
|
|
|
ad = demux_open_stream(as,audio_demuxer_type ? audio_demuxer_type : afmt,audio_id,-2,-2, audio_stream);
|
2003-03-27 20:38:14 +00:00
|
|
|
if(!ad) {
|
2002-08-08 13:55:15 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_OpeningAudioDemuxerFailed,audio_stream);
|
2003-03-27 20:38:14 +00:00
|
|
|
free_stream(as);
|
|
|
|
}
|
2002-02-20 16:59:25 +00:00
|
|
|
else if(ad->audio->sh && ((sh_audio_t*)ad->audio->sh)->format == 0x55) // MP3
|
2002-10-23 17:21:01 +00:00
|
|
|
hr_mp3_seek=1; // Enable high res seeking
|
2002-02-20 16:59:25 +00:00
|
|
|
}
|
|
|
|
if(ss) {
|
2003-01-19 00:21:54 +00:00
|
|
|
sd = demux_open_stream(ss,sub_demuxer_type ? sub_demuxer_type : sfmt,-2,-2,dvdsub_id, sub_stream);
|
2003-03-27 20:38:14 +00:00
|
|
|
if(!sd) {
|
2002-08-08 13:55:15 +00:00
|
|
|
mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_OpeningSubtitlesDemuxerFailed,sub_stream);
|
2003-03-27 20:38:14 +00:00
|
|
|
free_stream(ss);
|
|
|
|
}
|
2002-02-20 16:59:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(ad && sd)
|
|
|
|
return new_demuxers_demuxer(vd,ad,sd);
|
|
|
|
else if(ad)
|
|
|
|
return new_demuxers_demuxer(vd,ad,vd);
|
|
|
|
else if(sd)
|
|
|
|
return new_demuxers_demuxer(vd,vd,sd);
|
|
|
|
else
|
|
|
|
return vd;
|
|
|
|
}
|
|
|
|
|
2001-08-12 17:28:16 +00:00
|
|
|
int demux_seek_avi(demuxer_t *demuxer,float rel_seek_secs,int flags);
|
|
|
|
int demux_seek_asf(demuxer_t *demuxer,float rel_seek_secs,int flags);
|
|
|
|
int demux_seek_mpg(demuxer_t *demuxer,float rel_seek_secs,int flags);
|
2003-06-09 00:24:49 +00:00
|
|
|
int demux_seek_ty(demuxer_t *demuxer,float rel_seek_secs,int flags);
|
2001-12-28 22:58:49 +00:00
|
|
|
int demux_seek_y4m(demuxer_t *demuxer,float rel_seek_secs,int flags);
|
2001-12-17 00:24:03 +00:00
|
|
|
int demux_seek_fli(demuxer_t *demuxer,float rel_seek_secs,int flags);
|
2002-03-17 02:59:04 +00:00
|
|
|
int demux_seek_film(demuxer_t *demuxer,float rel_seek_secs,int flags);
|
2002-02-06 20:16:35 +00:00
|
|
|
int demux_seek_mf(demuxer_t *demuxer,float rel_seek_secs,int flags);
|
2002-01-09 17:09:21 +00:00
|
|
|
int demux_seek_nuv(demuxer_t *demuxer,float rel_seek_secs,int flags);
|
2001-10-16 22:41:46 +00:00
|
|
|
void demux_seek_mov(demuxer_t *demuxer,float pts,int flags);
|
2002-03-15 15:53:11 +00:00
|
|
|
int demux_seek_real(demuxer_t *demuxer,float rel_seek_secs,int flags);
|
2002-09-10 21:50:03 +00:00
|
|
|
int demux_seek_pva(demuxer_t *demuxer,float rel_seek_secs,int flags);
|
2003-03-16 20:13:28 +00:00
|
|
|
int demux_seek_ts(demuxer_t *demuxer,float rel_seek_secs,int flags);
|
2004-04-11 14:26:04 +00:00
|
|
|
int demux_seek_lavf(demuxer_t *demuxer,float rel_seek_secs,int flags);
|
2005-02-13 13:39:19 +00:00
|
|
|
#ifdef USE_WIN32DLL
|
|
|
|
int demux_seek_avs(demuxer_t *demuxer,float rel_seek_secs,int flags);
|
|
|
|
#endif
|
2002-09-10 21:50:03 +00:00
|
|
|
|
2002-08-05 17:21:35 +00:00
|
|
|
#ifdef HAVE_LIBDV095
|
|
|
|
int demux_seek_rawdv(demuxer_t *demuxer, float pts, int flags);
|
|
|
|
#endif
|
|
|
|
|
2002-02-14 13:04:35 +00:00
|
|
|
extern void demux_audio_seek(demuxer_t *demuxer,float rel_seek_secs,int flags);
|
2005-07-10 17:14:12 +00:00
|
|
|
extern void demux_mpc_seek(demuxer_t *demuxer,float rel_seek_secs,int flags);
|
2002-02-20 16:59:25 +00:00
|
|
|
extern void demux_demuxers_seek(demuxer_t *demuxer,float rel_seek_secs,int flags);
|
2002-04-20 17:50:11 +00:00
|
|
|
extern void demux_ogg_seek(demuxer_t *demuxer,float rel_seek_secs,int flags);
|
2002-06-11 14:29:51 +00:00
|
|
|
extern void demux_rawaudio_seek(demuxer_t *demuxer,float rel_seek_secs,int flags);
|
2003-01-22 23:51:04 +00:00
|
|
|
extern void demux_rawvideo_seek(demuxer_t *demuxer,float rel_seek_secs,int flags);
|
2002-12-22 21:01:01 +00:00
|
|
|
extern void demux_xmms_seek(demuxer_t *demuxer,float rel_seek_secs,int flags);
|
2003-04-30 11:39:32 +00:00
|
|
|
extern void demux_mkv_seek(demuxer_t *demuxer,float rel_seek_secs,int flags);
|
2004-12-29 19:51:56 +00:00
|
|
|
extern void demux_seek_vqf(demuxer_t *demuxer,float rel_seek_secs,int flags);
|
2005-06-13 20:40:29 +00:00
|
|
|
extern void demux_aac_seek(demuxer_t *demuxer,float rel_seek_secs,int flags);
|
2001-08-12 17:28:16 +00:00
|
|
|
|
|
|
|
int demux_seek(demuxer_t *demuxer,float rel_seek_secs,int flags){
|
|
|
|
demux_stream_t *d_audio=demuxer->audio;
|
|
|
|
demux_stream_t *d_video=demuxer->video;
|
|
|
|
sh_audio_t *sh_audio=d_audio->sh;
|
|
|
|
sh_video_t *sh_video=d_video->sh;
|
|
|
|
|
2001-08-22 16:42:37 +00:00
|
|
|
if(!demuxer->seekable){
|
|
|
|
if(demuxer->file_format==DEMUXER_TYPE_AVI)
|
2001-09-26 21:35:14 +00:00
|
|
|
mp_msg(MSGT_SEEK,MSGL_WARN,MSGTR_CantSeekRawAVI);
|
2001-11-09 23:46:06 +00:00
|
|
|
#ifdef USE_TV
|
|
|
|
else if (demuxer->file_format==DEMUXER_TYPE_TV)
|
2002-08-08 13:55:15 +00:00
|
|
|
mp_msg(MSGT_SEEK,MSGL_WARN,MSGTR_TVInputNotSeekable);
|
2001-11-09 23:46:06 +00:00
|
|
|
#endif
|
2001-08-22 16:42:37 +00:00
|
|
|
else
|
2001-09-26 21:35:14 +00:00
|
|
|
mp_msg(MSGT_SEEK,MSGL_WARN,MSGTR_CantSeekFile);
|
2001-08-22 16:42:37 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2001-08-12 17:28:16 +00:00
|
|
|
|
|
|
|
// clear demux buffers:
|
|
|
|
if(sh_audio){ ds_free_packs(d_audio);sh_audio->a_buffer_len=0;}
|
|
|
|
ds_free_packs(d_video);
|
|
|
|
|
|
|
|
demuxer->stream->eof=0; // clear eof flag
|
2001-12-17 00:03:50 +00:00
|
|
|
demuxer->video->eof=0;
|
|
|
|
demuxer->audio->eof=0;
|
2001-08-12 17:28:16 +00:00
|
|
|
|
2002-01-17 00:32:46 +00:00
|
|
|
#if 0
|
2001-12-28 01:38:40 +00:00
|
|
|
if(sh_audio) sh_audio->timer=sh_video->timer;
|
|
|
|
#else
|
2002-11-02 19:52:59 +00:00
|
|
|
if(sh_audio) sh_audio->delay=0;
|
2002-02-08 16:00:14 +00:00
|
|
|
if(sh_video) sh_video->timer=0; // !!!!!!
|
2001-12-28 01:38:40 +00:00
|
|
|
#endif
|
2001-08-12 17:28:16 +00:00
|
|
|
|
|
|
|
switch(demuxer->file_format){
|
|
|
|
|
2002-08-05 17:21:35 +00:00
|
|
|
#ifdef HAVE_LIBDV095
|
|
|
|
case DEMUXER_TYPE_RAWDV:
|
|
|
|
demux_seek_rawdv(demuxer,rel_seek_secs,flags); break;
|
|
|
|
#endif
|
2001-08-12 17:28:16 +00:00
|
|
|
case DEMUXER_TYPE_AVI:
|
|
|
|
demux_seek_avi(demuxer,rel_seek_secs,flags); break;
|
|
|
|
|
|
|
|
case DEMUXER_TYPE_ASF:
|
|
|
|
demux_seek_asf(demuxer,rel_seek_secs,flags); break;
|
2003-06-09 00:24:49 +00:00
|
|
|
|
|
|
|
case DEMUXER_TYPE_MPEG_TY:
|
|
|
|
demux_seek_ty(demuxer,rel_seek_secs,flags); break;
|
2001-08-12 17:28:16 +00:00
|
|
|
|
2003-04-04 15:38:46 +00:00
|
|
|
case DEMUXER_TYPE_H264_ES:
|
2003-01-23 02:12:15 +00:00
|
|
|
case DEMUXER_TYPE_MPEG4_ES:
|
2001-08-12 17:28:16 +00:00
|
|
|
case DEMUXER_TYPE_MPEG_ES:
|
|
|
|
case DEMUXER_TYPE_MPEG_PS:
|
|
|
|
demux_seek_mpg(demuxer,rel_seek_secs,flags); break;
|
|
|
|
|
2001-10-16 22:41:46 +00:00
|
|
|
case DEMUXER_TYPE_MOV:
|
|
|
|
demux_seek_mov(demuxer,rel_seek_secs,flags); break;
|
|
|
|
|
2002-03-15 15:53:11 +00:00
|
|
|
case DEMUXER_TYPE_REAL:
|
|
|
|
demux_seek_real(demuxer,rel_seek_secs,flags); break;
|
|
|
|
|
2001-12-28 22:58:49 +00:00
|
|
|
case DEMUXER_TYPE_Y4M:
|
|
|
|
demux_seek_y4m(demuxer,rel_seek_secs,flags); break;
|
|
|
|
|
2002-02-07 12:07:47 +00:00
|
|
|
case DEMUXER_TYPE_MF:
|
|
|
|
demux_seek_mf(demuxer,rel_seek_secs,flags); break;
|
2002-09-10 21:50:03 +00:00
|
|
|
|
|
|
|
case DEMUXER_TYPE_PVA:
|
|
|
|
demux_seek_pva(demuxer,rel_seek_secs,flags); break;
|
2002-02-07 12:07:47 +00:00
|
|
|
|
2001-12-17 00:24:03 +00:00
|
|
|
case DEMUXER_TYPE_FLI:
|
|
|
|
demux_seek_fli(demuxer,rel_seek_secs,flags); break;
|
2002-03-17 02:59:04 +00:00
|
|
|
case DEMUXER_TYPE_FILM:
|
|
|
|
demux_seek_film(demuxer,rel_seek_secs,flags); break;
|
2002-01-09 17:09:21 +00:00
|
|
|
case DEMUXER_TYPE_NUV:
|
|
|
|
demux_seek_nuv(demuxer,rel_seek_secs,flags); break;
|
2002-02-14 13:04:35 +00:00
|
|
|
case DEMUXER_TYPE_AUDIO:
|
|
|
|
demux_audio_seek(demuxer,rel_seek_secs,flags); break;
|
2005-07-10 17:14:12 +00:00
|
|
|
case DEMUXER_TYPE_MPC:
|
|
|
|
demux_mpc_seek(demuxer,rel_seek_secs,flags); break;
|
2002-02-20 16:59:25 +00:00
|
|
|
case DEMUXER_TYPE_DEMUXERS:
|
|
|
|
demux_demuxers_seek(demuxer,rel_seek_secs,flags); break;
|
2002-04-21 02:38:50 +00:00
|
|
|
#ifdef HAVE_OGGVORBIS
|
2002-04-20 17:50:11 +00:00
|
|
|
case DEMUXER_TYPE_OGG:
|
|
|
|
demux_ogg_seek(demuxer,rel_seek_secs,flags); break;
|
2002-04-21 02:38:50 +00:00
|
|
|
#endif
|
2002-06-11 14:29:51 +00:00
|
|
|
case DEMUXER_TYPE_RAWAUDIO:
|
|
|
|
demux_rawaudio_seek(demuxer,rel_seek_secs,flags); break;
|
2003-01-22 23:51:04 +00:00
|
|
|
case DEMUXER_TYPE_RAWVIDEO:
|
|
|
|
demux_rawvideo_seek(demuxer,rel_seek_secs,flags); break;
|
2002-12-22 21:01:01 +00:00
|
|
|
#ifdef HAVE_XMMS
|
|
|
|
case DEMUXER_TYPE_XMMS:
|
|
|
|
demux_xmms_seek(demuxer,rel_seek_secs,flags); break;
|
2003-04-30 11:39:32 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_MATROSKA
|
|
|
|
case DEMUXER_TYPE_MATROSKA:
|
|
|
|
demux_mkv_seek(demuxer,rel_seek_secs,flags); break;
|
2002-12-22 21:01:01 +00:00
|
|
|
#endif
|
2003-03-16 20:13:28 +00:00
|
|
|
case DEMUXER_TYPE_MPEG_TS:
|
|
|
|
demux_seek_ts(demuxer,rel_seek_secs,flags); break;
|
2004-04-11 14:26:04 +00:00
|
|
|
#ifdef USE_LIBAVFORMAT
|
|
|
|
case DEMUXER_TYPE_LAVF:
|
|
|
|
demux_seek_lavf(demuxer,rel_seek_secs,flags); break;
|
|
|
|
#endif
|
2004-12-29 19:51:56 +00:00
|
|
|
case DEMUXER_TYPE_VQF:
|
|
|
|
demux_seek_vqf(demuxer,rel_seek_secs,flags); break;
|
2005-02-13 13:39:19 +00:00
|
|
|
#ifdef USE_WIN32DLL
|
|
|
|
case DEMUXER_TYPE_AVS:
|
|
|
|
demux_seek_avs(demuxer,rel_seek_secs,flags); break;
|
|
|
|
#endif
|
2005-06-13 20:40:29 +00:00
|
|
|
case DEMUXER_TYPE_AAC:
|
|
|
|
demux_aac_seek(demuxer,rel_seek_secs,flags); break;
|
2001-12-17 00:24:03 +00:00
|
|
|
|
2001-08-12 17:28:16 +00:00
|
|
|
} // switch(demuxer->file_format)
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2001-11-21 16:14:14 +00:00
|
|
|
int demux_info_add(demuxer_t *demuxer, char *opt, char *param)
|
|
|
|
{
|
2002-02-14 13:04:35 +00:00
|
|
|
char **info = demuxer->info;
|
|
|
|
int n = 0;
|
2001-11-21 16:14:14 +00:00
|
|
|
|
|
|
|
|
2002-02-14 13:04:35 +00:00
|
|
|
for(n = 0; info && info[2*n] != NULL; n++)
|
|
|
|
{
|
|
|
|
if(!strcasecmp(opt,info[2*n]))
|
|
|
|
{
|
2002-08-08 13:55:15 +00:00
|
|
|
mp_msg(MSGT_DEMUX, MSGL_WARN,MSGTR_DemuxerInfoAlreadyPresent,opt);
|
2002-02-14 13:04:35 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
info = demuxer->info = (char**)realloc(info,(2*(n+2))*sizeof(char*));
|
|
|
|
info[2*n] = strdup(opt);
|
|
|
|
info[2*n+1] = strdup(param);
|
|
|
|
memset(&info[2*(n+1)],0,2*sizeof(char*));
|
2001-11-22 15:43:24 +00:00
|
|
|
|
2002-02-14 13:04:35 +00:00
|
|
|
return 1;
|
2001-11-21 16:14:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int demux_info_print(demuxer_t *demuxer)
|
|
|
|
{
|
2002-02-14 13:04:35 +00:00
|
|
|
char **info = demuxer->info;
|
|
|
|
int n;
|
2001-11-21 16:14:14 +00:00
|
|
|
|
2002-02-14 13:04:35 +00:00
|
|
|
if(!info)
|
|
|
|
return 0;
|
|
|
|
|
2002-08-08 13:55:15 +00:00
|
|
|
mp_msg(MSGT_DEMUX, MSGL_INFO,MSGTR_ClipInfo);
|
2002-02-14 13:04:35 +00:00
|
|
|
for(n = 0; info[2*n] != NULL ; n++)
|
2005-06-20 23:07:35 +00:00
|
|
|
{
|
2002-02-14 13:04:35 +00:00
|
|
|
mp_msg(MSGT_DEMUX, MSGL_INFO, " %s: %s\n",info[2*n],info[2*n+1]);
|
2005-07-07 17:35:05 +00:00
|
|
|
if (identify) {
|
|
|
|
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_CLIP_INFO_NAME%d=%s\n", n, info[2*n]);
|
|
|
|
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_CLIP_INFO_VALUE%d=%s\n", n, info[2*n+1]);
|
|
|
|
}
|
2005-06-20 23:07:35 +00:00
|
|
|
}
|
2005-07-07 17:35:05 +00:00
|
|
|
if (identify)
|
|
|
|
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_CLIP_INFO_N=%d\n", n);
|
2002-01-16 03:25:07 +00:00
|
|
|
|
|
|
|
return 0;
|
2001-11-21 16:14:14 +00:00
|
|
|
}
|
2002-02-20 16:59:25 +00:00
|
|
|
|
|
|
|
char* demux_info_get(demuxer_t *demuxer, char *opt) {
|
|
|
|
int i;
|
|
|
|
char **info = demuxer->info;
|
|
|
|
|
|
|
|
for(i = 0; info && info[2*i] != NULL; i++) {
|
|
|
|
if(!strcasecmp(opt,info[2*i]))
|
|
|
|
return info[2*i+1];
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2003-06-19 18:20:15 +00:00
|
|
|
extern int demux_ty_control(demuxer_t *demuxer, int cmd, void *arg);
|
2002-11-16 03:42:14 +00:00
|
|
|
extern int demux_mpg_control(demuxer_t *demuxer, int cmd, void *arg);
|
|
|
|
extern int demux_asf_control(demuxer_t *demuxer, int cmd, void *arg);
|
|
|
|
extern int demux_avi_control(demuxer_t *demuxer, int cmd, void *arg);
|
2002-12-22 21:01:01 +00:00
|
|
|
extern int demux_xmms_control(demuxer_t *demuxer, int cmd, void *arg);
|
2003-04-30 11:39:32 +00:00
|
|
|
extern int demux_mkv_control(demuxer_t *demuxer, int cmd, void *arg);
|
2003-09-19 19:40:46 +00:00
|
|
|
extern int demux_audio_control(demuxer_t *demuxer, int cmd, void *arg);
|
2005-07-10 17:14:12 +00:00
|
|
|
extern int demux_mpc_control(demuxer_t *demuxer, int cmd, void *arg);
|
2003-12-08 09:47:15 +00:00
|
|
|
extern int demux_ogg_control(demuxer_t *demuxer, int cmd, void *arg);
|
2003-11-15 22:27:02 +00:00
|
|
|
extern int demux_real_control(demuxer_t *demuxer, int cmd, void *arg);
|
2004-04-11 14:26:04 +00:00
|
|
|
extern int demux_lavf_control(demuxer_t *demuxer, int cmd, void *arg);
|
2004-12-21 12:25:59 +00:00
|
|
|
extern int demux_mov_control(demuxer_t *demuxer, int cmd, void *arg);
|
2005-02-13 13:39:19 +00:00
|
|
|
#ifdef USE_WIN32DLL
|
|
|
|
extern int demux_avs_control(demuxer_t *demuxer, int cmd, void *arg);
|
|
|
|
#endif
|
2005-03-09 20:29:50 +00:00
|
|
|
#ifdef HAVE_LIBDV095
|
|
|
|
extern int demux_rawdv_control(demuxer_t *demuxer,int cmd, void *arg);
|
|
|
|
#endif
|
2002-11-16 03:42:14 +00:00
|
|
|
|
|
|
|
int demux_control(demuxer_t *demuxer, int cmd, void *arg) {
|
|
|
|
switch(demuxer->type) {
|
2003-06-09 00:24:49 +00:00
|
|
|
case DEMUXER_TYPE_MPEG_TY:
|
|
|
|
return demux_ty_control(demuxer,cmd,arg);
|
2003-01-23 02:12:15 +00:00
|
|
|
case DEMUXER_TYPE_MPEG4_ES:
|
2002-11-16 03:42:14 +00:00
|
|
|
case DEMUXER_TYPE_MPEG_ES:
|
|
|
|
case DEMUXER_TYPE_MPEG_PS:
|
2003-08-24 18:08:54 +00:00
|
|
|
case DEMUXER_TYPE_MPEG_TS:
|
2002-11-16 03:42:14 +00:00
|
|
|
return demux_mpg_control(demuxer,cmd,arg);
|
|
|
|
case DEMUXER_TYPE_ASF:
|
|
|
|
return demux_asf_control(demuxer,cmd,arg);
|
|
|
|
case DEMUXER_TYPE_AVI:
|
2002-12-11 20:48:51 +00:00
|
|
|
case DEMUXER_TYPE_AVI_NI:
|
|
|
|
case DEMUXER_TYPE_AVI_NINI:
|
2002-11-16 03:42:14 +00:00
|
|
|
return demux_avi_control(demuxer,cmd,arg);
|
2003-09-19 19:40:46 +00:00
|
|
|
case DEMUXER_TYPE_AUDIO:
|
|
|
|
return demux_audio_control(demuxer,cmd,arg);
|
2005-07-10 17:14:12 +00:00
|
|
|
case DEMUXER_TYPE_MPC:
|
|
|
|
return demux_mpc_control(demuxer,cmd,arg);
|
2003-12-08 09:47:15 +00:00
|
|
|
#ifdef HAVE_OGGVORBIS
|
|
|
|
case DEMUXER_TYPE_OGG:
|
|
|
|
return demux_ogg_control(demuxer,cmd,arg);
|
|
|
|
#endif
|
2002-12-22 21:01:01 +00:00
|
|
|
#ifdef HAVE_XMMS
|
|
|
|
case DEMUXER_TYPE_XMMS:
|
|
|
|
return demux_xmms_control(demuxer,cmd,arg);
|
2003-04-30 11:39:32 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_MATROSKA
|
|
|
|
case DEMUXER_TYPE_MATROSKA:
|
|
|
|
return demux_mkv_control(demuxer,cmd,arg);
|
2002-12-22 21:01:01 +00:00
|
|
|
#endif
|
2003-11-12 10:27:16 +00:00
|
|
|
case DEMUXER_TYPE_REAL:
|
|
|
|
return demux_real_control(demuxer, cmd, arg);
|
2004-04-11 14:26:04 +00:00
|
|
|
#ifdef USE_LIBAVFORMAT
|
|
|
|
case DEMUXER_TYPE_LAVF:
|
|
|
|
return demux_lavf_control(demuxer, cmd, arg);
|
|
|
|
#endif
|
2004-12-21 12:25:59 +00:00
|
|
|
case DEMUXER_TYPE_MOV:
|
|
|
|
return demux_mov_control(demuxer, cmd, arg);
|
2005-02-13 13:39:19 +00:00
|
|
|
#ifdef USE_WIN32DLL
|
|
|
|
case DEMUXER_TYPE_AVS:
|
|
|
|
return demux_avs_control(demuxer, cmd, arg);
|
|
|
|
#endif
|
2005-03-09 20:29:50 +00:00
|
|
|
#ifdef HAVE_LIBDV095
|
|
|
|
case DEMUXER_TYPE_RAWDV:
|
|
|
|
return demux_rawdv_control(demuxer,cmd, arg);
|
|
|
|
#endif
|
2002-11-16 03:42:14 +00:00
|
|
|
default:
|
|
|
|
return DEMUXER_CTRL_NOTIMPL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned long demuxer_get_time_length(demuxer_t *demuxer){
|
|
|
|
unsigned long get_time_ans;
|
2005-01-15 16:11:45 +00:00
|
|
|
sh_video_t *sh_video = demuxer->video->sh;
|
|
|
|
// <= 0 means DEMUXER_CTRL_NOTIMPL or DEMUXER_CTRL_DONTKNOW
|
2002-11-16 03:42:14 +00:00
|
|
|
if (demux_control(demuxer, DEMUXER_CTRL_GET_TIME_LENGTH,(void *)&get_time_ans)<=0) {
|
2005-01-15 16:11:45 +00:00
|
|
|
if (sh_video && sh_video->i_bps)
|
|
|
|
get_time_ans = (demuxer->movi_end-demuxer->movi_start)/sh_video->i_bps;
|
|
|
|
else
|
2002-11-16 03:42:14 +00:00
|
|
|
get_time_ans=0;
|
|
|
|
}
|
|
|
|
return get_time_ans;
|
|
|
|
}
|
|
|
|
|
|
|
|
int demuxer_get_percent_pos(demuxer_t *demuxer){
|
2004-12-21 12:25:59 +00:00
|
|
|
int ans = 0;
|
|
|
|
int res = demux_control(demuxer, DEMUXER_CTRL_GET_PERCENT_POS, &ans);
|
|
|
|
int len = (demuxer->movi_end - demuxer->movi_start) / 100;
|
2005-01-15 16:11:45 +00:00
|
|
|
if (res <= 0) {
|
|
|
|
if (len > 0)
|
2004-12-21 12:25:59 +00:00
|
|
|
ans = (demuxer->filepos - demuxer->movi_start) / len;
|
2005-01-15 16:11:45 +00:00
|
|
|
else
|
|
|
|
ans = 0;
|
|
|
|
}
|
|
|
|
if (ans < 0) ans = 0;
|
|
|
|
if (ans > 100) ans = 100;
|
2002-11-16 03:42:14 +00:00
|
|
|
return ans;
|
|
|
|
}
|
|
|
|
|
2005-04-28 14:43:19 +00:00
|
|
|
int demuxer_switch_audio(demuxer_t *demuxer, int index){
|
|
|
|
int res = demux_control(demuxer, DEMUXER_CTRL_SWITCH_AUDIO, &index);
|
|
|
|
if (res == DEMUXER_CTRL_NOTIMPL)
|
|
|
|
index = demuxer->audio->id;
|
|
|
|
return index;
|
2005-04-03 14:08:28 +00:00
|
|
|
}
|