[MPlayer-dev-eng] Re: audio out feature (not a request)
Tobias Diedrich
ranma at tdiedrich.de
Sun Jun 19 03:59:19 CEST 2005
I wrote:
> Hmm, I just so happen to have a rawaudio muxer lying around here. :-)
> Not quite cleaned up yet (e.g. still uses printf), but should work.
Cleaned-up version attached.
--
Tobias PGP: http://9ac7e0bc.uguu.de
-------------- next part --------------
Index: help/help_mp-en.h
===================================================================
RCS file: /cvsroot/mplayer/main/help/help_mp-en.h,v
retrieving revision 1.170
diff -u -r1.170 help_mp-en.h
--- help/help_mp-en.h 9 Jun 2005 20:13:53 -0000 1.170
+++ help/help_mp-en.h 19 Jun 2005 01:01:10 -0000
@@ -482,6 +482,13 @@
#define MSGTR_DVDnoVOBs "Cannot open title VOBS (VTS_%02d_1.VOB).\n"
#define MSGTR_DVDopenOk "DVD successfully opened.\n"
+// muxer_*.c:
+#define MSGTR_TooManyStreams "Too many streams!"
+#define MSGTR_RawMuxerOnlyOneStream "Rawaudio muxer supports only one audio stream!\n"
+#define MSGTR_IgnoringVideoStream "Ignoring video stream!\n"
+#define MSGTR_UnknownStreamType "Warning! unknown stream type: %d\n"
+#define MSGTR_WarningLenIsntDivisible "Warning! len isn't divisible by samplesize!\n"
+
// demuxer.c, demux_*.c:
#define MSGTR_AudioStreamRedefined "WARNING: Audio stream header %d redefined.\n"
#define MSGTR_VideoStreamRedefined "WARNING: Video stream header %d redefined.\n"
Index: help/help_mp-de.h
===================================================================
RCS file: /cvsroot/mplayer/main/help/help_mp-de.h,v
retrieving revision 1.111
diff -u -r1.111 help_mp-de.h
--- help/help_mp-de.h 1 Jun 2005 21:54:43 -0000 1.111
+++ help/help_mp-de.h 19 Jun 2005 01:01:12 -0000
@@ -486,6 +486,13 @@
#define MSGTR_DVDnoVOBs "Kann VOB-Dateien des Titels (VTS_%02d_1.VOB) nicht ?ffnen.\n"
#define MSGTR_DVDopenOk "DVD erfolgreich ge?ffnet.\n"
+// muxer_*.c:
+#define MSGTR_TooManyStreams "Zu viele Streams!"
+#define MSGTR_RawMuxerOnlyOneStream "Der rawaudio-Muxer unterst?tzt nur einen Audiostream!\n"
+#define MSGTR_IgnoringVideoStream "Ignoriere Videostream!\n"
+#define MSGTR_UnknownStreamType "Warnung! Unbekannter Streamtyp: %d\n"
+#define MSGTR_WarningLenIsntDivisible "Warnung! 'len' ist nicht durch 'samplesize' teilbar!\n"
+
// demuxer.c, demux_*.c:
#define MSGTR_AudioStreamRedefined "Warnung! Audiostream-Header %d neu definiert!\n"
#define MSGTR_VideoStreamRedefined "Warnung! Videostream-Header %d neu definiert!\n"
Index: libmpdemux/Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/Makefile,v
retrieving revision 1.92
diff -u -r1.92 Makefile
--- libmpdemux/Makefile 13 Jun 2005 20:39:17 -0000 1.92
+++ libmpdemux/Makefile 19 Jun 2005 01:01:12 -0000
@@ -3,7 +3,7 @@
include ../config.mak
-SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c muxer.c muxer_avi.c muxer_mpeg.c demux_asf.c demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_ty.c demux_ty_osd.c demux_pva.c demux_viv.c demuxer.c dvdnav_stream.c open.c parse_es.c stream.c stream_file.c stream_netstream.c stream_vcd.c stream_null.c stream_ftp.c stream_smb.c stream_vstream.c tv.c tvi_dummy.c tvi_v4l.c tvi_v4l2.c tvi_bsdbt848.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c demux_demuxers.c demux_ogg.c cdda.c demux_rawaudio.c demux_rawvideo.c cddb.c cdinfo.c demux_rawdv.c ai_alsa.c ai_alsa1x.c ai_oss.c audio_in.c demux_smjpeg.c demux_lmlm4.c cue_read.c extension.c demux_gif.c demux_ts.c demux_realaud.c url.c muxer_rawvideo.c demux_lavf.c demux_nsv.c demux_vqf.c stream_dvd.c stream_livedotcom.c demux_aac.c
+SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c muxer.c muxer_avi.c muxer_mpeg.c demux_asf.c demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_ty.c demux_ty_osd.c demux_pva.c demux_viv.c demuxer.c dvdnav_stream.c open.c parse_es.c stream.c stream_file.c stream_netstream.c stream_vcd.c stream_null.c stream_ftp.c stream_smb.c stream_vstream.c tv.c tvi_dummy.c tvi_v4l.c tvi_v4l2.c tvi_bsdbt848.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c demux_demuxers.c demux_ogg.c cdda.c demux_rawaudio.c demux_rawvideo.c cddb.c cdinfo.c demux_rawdv.c ai_alsa.c ai_alsa1x.c ai_oss.c audio_in.c demux_smjpeg.c demux_lmlm4.c cue_read.c extension.c demux_gif.c demux_ts.c demux_realaud.c url.c muxer_rawvideo.c muxer_rawaudio.c demux_lavf.c demux_nsv.c demux_vqf.c stream_dvd.c stream_livedotcom.c demux_aac.c
ifeq ($(XMMS_PLUGINS),yes)
SRCS += demux_xmms.c
endif
Index: libmpdemux/muxer.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/muxer.c,v
retrieving revision 1.7
diff -u -r1.7 muxer.c
--- libmpdemux/muxer.c 21 Feb 2005 23:18:31 -0000 1.7
+++ libmpdemux/muxer.c 19 Jun 2005 01:01:12 -0000
@@ -41,6 +41,10 @@
default:
if(! muxer_init_muxer_avi(muxer))
return NULL;
+ case MUXER_TYPE_RAWAUDIO:
+ if(! muxer_init_muxer_rawaudio(muxer))
+ return NULL;
+ break;
}
return muxer;
}
--- libmpdemux/muxer_rawaudio.c.none 1970-01-01 01:00:00.000000000 +0100
+++ libmpdemux/muxer_rawaudio.c 2005-06-19 02:53:41.000000000 +0200
@@ -0,0 +1,82 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "help_mp.h"
+#include "mp_msg.h"
+
+#include "aviheader.h"
+#include "ms_hdr.h"
+
+#include "muxer.h"
+
+static muxer_stream_t* rawaudiofile_new_stream(muxer_t *muxer,int type){
+ muxer_stream_t* s;
+ if (!muxer) return NULL;
+ if(type==MUXER_TYPE_AUDIO && muxer->avih.dwStreams>=1){
+ mp_msg(MSGT_MUXER,MSGL_ERR,MSGTR_TooManyStreams" "MSGTR_RawMuxerOnlyOneStream);
+ return NULL;
+ }
+ s=malloc(sizeof(muxer_stream_t));
+ memset(s,0,sizeof(muxer_stream_t));
+ if(!s) return NULL; // no mem!?
+ muxer->streams[muxer->avih.dwStreams]=s;
+ s->type=type;
+ s->id=muxer->avih.dwStreams;
+ s->timer=0.0;
+ s->size=0;
+ s->muxer=muxer;
+ switch(type){
+ case MUXER_TYPE_AUDIO:
+ s->ckid=mmioFOURCC(('0'+s->id/10),('0'+(s->id%10)),'d','c');
+ s->h.fccType=streamtypeAUDIO;
+ muxer->avih.dwStreams++;
+ break;
+ case MUXER_TYPE_VIDEO:
+ mp_msg(MSGT_MUXER,MSGL_WARN,MSGTR_IgnoringVideoStream);
+ s->ckid=mmioFOURCC(('0'+s->id/10),('0'+(s->id%10)),'d','c');
+ s->h.fccType=streamtypeAUDIO;
+ break;
+ default:
+ mp_msg(MSGT_MUXER,MSGL_ERR,MSGTR_UnknownStreamType,type);
+ return NULL;
+ }
+ return s;
+}
+
+static void rawaudiofile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags){
+ muxer_t *muxer=s->muxer;
+
+ // write out the chunk:
+ if (s->type==MUXER_TYPE_AUDIO)
+ fwrite(s->buffer,len,1,muxer->file);
+
+ // alter counters:
+ if(s->h.dwSampleSize){
+ // CBR
+ s->h.dwLength+=len/s->h.dwSampleSize;
+ if(len%s->h.dwSampleSize)
+ mp_msg(MSGT_MUXER,MSGL_WARN,MSGTR_WarningLenIsntDivisible);
+ } else {
+ // VBR
+ s->h.dwLength++;
+ }
+ s->timer=(double)s->h.dwLength*s->h.dwScale/s->h.dwRate;
+ s->size+=len;
+}
+
+static void rawaudiofile_write_header(muxer_t *muxer){
+ return;
+}
+
+static void rawaudiofile_write_index(muxer_t *muxer){
+ return;
+}
+
+int muxer_init_muxer_rawaudio(muxer_t *muxer){
+ muxer->cont_new_stream = &rawaudiofile_new_stream;
+ muxer->cont_write_chunk = &rawaudiofile_write_chunk;
+ muxer->cont_write_header = &rawaudiofile_write_header;
+ muxer->cont_write_index = &rawaudiofile_write_index;
+ return 1;
+}
Index: help/help_mp-ja.h
===================================================================
RCS file: /cvsroot/mplayer/main/help/help_mp-ja.h,v
retrieving revision 1.10
diff -u -r1.10 help_mp-ja.h
--- help/help_mp-ja.h 11 Nov 2004 02:22:16 -0000 1.10
+++ help/help_mp-ja.h 19 Jun 2005 01:51:04 -0000
@@ -185,6 +185,13 @@
#define MSGTR_DVDnoVOBs "Cannot open title VOBS (VTS_%02d_1.VOB).\n"
#define MSGTR_DVDopenOk "DVD????????????????????????.\n"
+// muxer_*.c:
+#define MSGTR_TooManyStreams "????????????????????!"
+#define MSGTR_RawMuxerOnlyOneStream "Rawaudio muxer??????????????????????????????????????????!\n"
+#define MSGTR_IgnoringVideoStream "????????????????????????????!\n"
+#define MSGTR_UnknownStreamType "????: ??????????????????????: %d\n"
+#define MSGTR_WarningLenIsntDivisible "????: samplesize??len??????????????!\n"
+
// demuxer.c, demux_*.c:
#define MSGTR_AudioStreamRedefined "????: Audio stream header %d redefined.\n"
#define MSGTR_VideoStreamRedefined "????: Video stream header %d redefined.\n"
More information about the MPlayer-dev-eng
mailing list