[Mplayer-cvslog] CVS: main/libmpdemux matroska.h,NONE,1.1 demux_mkv.cpp,NONE,1.1 demuxer.c,1.140,1.141 demuxer.h,1.58,1.59 Makefile,1.60,1.61

Moritz Bunkus CVS mosu at mplayerhq.hu
Wed Apr 30 13:39:35 CEST 2003


Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var/tmp.root/cvs-serv13358/libmpdemux

Modified Files:
	demuxer.c demuxer.h Makefile 
Added Files:
	matroska.h demux_mkv.cpp 
Log Message:
Added Matroska demuxing support.

--- NEW FILE ---
/*
 * CodecID definitions for Matroska files
 *
 * see http://cvs.corecodec.org/cgi-bin/cvsweb.cgi/~checkout~/matroska/doc/website/specs/codex.html?rev=HEAD&content-type=text/html
 */

#ifndef __MATROSKA_H
#define __MATROSKA_H

#define MKV_A_MP3        "A_MPEG/L3"
#define MKV_A_AC3        "A_AC3"
#define MKV_A_PCM        "A_PCM/INT/LIT"
#define MKV_A_VORBIS     "A_VORBIS"
#define MKV_A_ACM        "A_MS/ACM"

#define MKV_V_MSCOMP     "V_MS/VFW/FOURCC"

#define MKV_S_TEXTASCII  "S_TEXT/ASCII"
#define MKV_S_TEXTUTF8   "S_TEXT/UTF8"

#endif /* __MATROSKA_H */

--- NEW FILE ---
extern "C" {
#include "config.h"
}

#ifdef HAVE_MATROSKA

extern "C" {
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "../mp_msg.h"
#include "../help_mp.h"
#include "stream.h"
#include "demuxer.h"
#include "stheader.h"

#include "../subreader.h"
#include "../libvo/sub.h"
[...1906 lines suppressed...]
    case DEMUXER_CTRL_GET_PERCENT_POS:
      if (mkv_d->duration == -1.0) {
        if (demuxer->movi_start == demuxer->movi_end)
          return DEMUXER_CTRL_DONTKNOW;

        *((int *)arg) =
          (int)((demuxer->filepos - demuxer->movi_start) /
                ((demuxer->movi_end - demuxer->movi_start) / 100));
        return DEMUXER_CTRL_OK;
      }

      *((int *)arg) = (int)(100 * mkv_d->last_pts / mkv_d->duration);
      return DEMUXER_CTRL_OK; 

    default:
      return DEMUXER_CTRL_NOTIMPL;
  }
}

#endif /* HAVE_MATROSKA */

Index: demuxer.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.c,v
retrieving revision 1.140
retrieving revision 1.141
diff -u -r1.140 -r1.141
--- demuxer.c	14 Apr 2003 01:38:36 -0000	1.140
+++ demuxer.c	30 Apr 2003 11:39:32 -0000	1.141
@@ -135,6 +135,7 @@
 extern void demux_close_xmms(demuxer_t* demuxer);
 extern void demux_close_gif(demuxer_t* demuxer);
 extern void demux_close_ts(demuxer_t* demuxer);
+extern void demux_close_mkv(demuxer_t* demuxer);
 
 #ifdef USE_TV
 #include "tv.h"
@@ -185,6 +186,10 @@
     case DEMUXER_TYPE_OGG:
       demux_close_ogg(demuxer); break;
 #endif
+#ifdef HAVE_MATROSKA
+    case DEMUXER_TYPE_MATROSKA:
+      demux_close_mkv(demuxer); break;
+#endif
 #ifdef STREAMING_LIVE_DOT_COM
     case DEMUXER_TYPE_RTP:
       demux_close_rtp(demuxer); break;
@@ -292,6 +297,7 @@
 extern int demux_rawaudio_fill_buffer(demuxer_t* demuxer, demux_stream_t *ds);
 extern int demux_rawvideo_fill_buffer(demuxer_t* demuxer, demux_stream_t *ds);
 extern int demux_smjpeg_fill_buffer(demuxer_t* demux);
+extern int demux_mkv_fill_buffer(demuxer_t *d);
 
 int demux_fill_buffer(demuxer_t *demux,demux_stream_t *ds){
   // Note: parameter 'ds' can be NULL!
@@ -330,6 +336,9 @@
 #ifdef HAVE_OGGVORBIS
     case DEMUXER_TYPE_OGG: return demux_ogg_fill_buffer(demux);
 #endif
+#ifdef HAVE_MATROSKA
+    case DEMUXER_TYPE_MATROSKA: return demux_mkv_fill_buffer(demux);
+#endif
     case DEMUXER_TYPE_RAWAUDIO: return demux_rawaudio_fill_buffer(demux,ds);
     case DEMUXER_TYPE_RAWVIDEO: return demux_rawvideo_fill_buffer(demux,ds);
 #ifdef STREAMING_LIVE_DOT_COM
@@ -574,6 +583,7 @@
 extern int gif_check_file(demuxer_t *demuxer);
 extern int demux_open_gif(demuxer_t* demuxer);
 extern int ts_check_file(demuxer_t * demuxer);
+extern int demux_open_mkv(demuxer_t *demuxer);
 
 extern demuxer_t* init_avi_with_ogg(demuxer_t* demuxer);
 
@@ -700,6 +710,19 @@
       demuxer = NULL;
   }
 }
+#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
 
 //=============== Try based on filename EXTENSION: =================
 // Ok. We're over the stable detectable fileformats, the next ones are a bit
@@ -1277,6 +1300,7 @@
 extern void demux_rawaudio_seek(demuxer_t *demuxer,float rel_seek_secs,int flags);
 extern void demux_rawvideo_seek(demuxer_t *demuxer,float rel_seek_secs,int flags);
 extern void demux_xmms_seek(demuxer_t *demuxer,float rel_seek_secs,int flags);
+extern void demux_mkv_seek(demuxer_t *demuxer,float rel_seek_secs,int flags);
 
 int demux_seek(demuxer_t *demuxer,float rel_seek_secs,int flags){
     demux_stream_t *d_audio=demuxer->audio;
@@ -1366,6 +1390,10 @@
  case DEMUXER_TYPE_XMMS:
       demux_xmms_seek(demuxer,rel_seek_secs,flags); break;
 #endif
+#ifdef HAVE_MATROSKA
+ case DEMUXER_TYPE_MATROSKA:
+      demux_mkv_seek(demuxer,rel_seek_secs,flags);  break;
+#endif
  case DEMUXER_TYPE_MPEG_TS:
       demux_seek_ts(demuxer,rel_seek_secs,flags); break;
 
@@ -1428,6 +1456,7 @@
 extern int demux_asf_control(demuxer_t *demuxer, int cmd, void *arg);
 extern int demux_avi_control(demuxer_t *demuxer, int cmd, void *arg);
 extern int demux_xmms_control(demuxer_t *demuxer, int cmd, void *arg);
+extern int demux_mkv_control(demuxer_t *demuxer, int cmd, void *arg);
 
 int demux_control(demuxer_t *demuxer, int cmd, void *arg) {
     switch(demuxer->type) {
@@ -1444,6 +1473,10 @@
 #ifdef HAVE_XMMS
 	case DEMUXER_TYPE_XMMS:
 	    return demux_xmms_control(demuxer,cmd,arg);
+#endif
+#ifdef HAVE_MATROSKA
+        case DEMUXER_TYPE_MATROSKA:
+	    return demux_mkv_control(demuxer,cmd,arg);
 #endif
 	default:
 	    return DEMUXER_CTRL_NOTIMPL;

Index: demuxer.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.h,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- demuxer.h	4 Apr 2003 15:38:46 -0000	1.58
+++ demuxer.h	30 Apr 2003 11:39:32 -0000	1.59
@@ -39,11 +39,12 @@
 #define DEMUXER_TYPE_GIF 28
 #define DEMUXER_TYPE_MPEG_TS 29
 #define DEMUXER_TYPE_H264_ES 30
+#define DEMUXER_TYPE_MATROSKA 31
 
 // This should always match the higest demuxer type number.
 // Unless you want to disallow users to force the demuxer to some types
 #define DEMUXER_TYPE_MIN 0
-#define DEMUXER_TYPE_MAX 30
+#define DEMUXER_TYPE_MAX 31
 
 #define DEMUXER_TYPE_DEMUXERS (1<<16)
 // A virtual demuxer type for the network code

Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/Makefile,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -r1.60 -r1.61
--- Makefile	18 Apr 2003 21:52:53 -0000	1.60
+++ Makefile	30 Apr 2003 11:39:32 -0000	1.61
@@ -26,7 +26,9 @@
 SRCS += dvb_tune.c
 endif
 
-
+ifeq ($(MATROSKA),yes)
+CPLUSPLUSSRCS += demux_mkv.cpp
+endif
 
 
 OBJS	= $(SRCS:.c=.o)



More information about the MPlayer-cvslog mailing list