2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include <sys/types.h>
26 #include "aviheader.h"
29 #include "stream/stream.h"
32 static muxer_stream_t
* rawaudiofile_new_stream(muxer_t
*muxer
,int type
){
34 if (!muxer
) return NULL
;
35 if(type
==MUXER_TYPE_AUDIO
&& muxer
->avih
.dwStreams
>=1){
36 mp_msg(MSGT_MUXER
, MSGL_ERR
, "%s %s", mp_gtext("Too many streams!"),
37 mp_gtext("Rawaudio muxer supports only one audio stream!\n"));
40 s
=malloc(sizeof(muxer_stream_t
));
41 memset(s
,0,sizeof(muxer_stream_t
));
42 if(!s
) return NULL
; // no mem!?
43 muxer
->streams
[muxer
->avih
.dwStreams
]=s
;
45 s
->id
=muxer
->avih
.dwStreams
;
50 case MUXER_TYPE_AUDIO
:
51 s
->ckid
=mmioFOURCC(('0'+s
->id
/10),('0'+(s
->id
%10)),'d','c');
52 s
->h
.fccType
=streamtypeAUDIO
;
53 muxer
->avih
.dwStreams
++;
55 case MUXER_TYPE_VIDEO
:
56 mp_tmsg(MSGT_MUXER
,MSGL_WARN
,"Ignoring video stream!\n");
57 s
->ckid
=mmioFOURCC(('0'+s
->id
/10),('0'+(s
->id
%10)),'d','c');
58 s
->h
.fccType
=streamtypeAUDIO
;
61 mp_tmsg(MSGT_MUXER
,MSGL_ERR
,"Warning, unknown stream type: %d\n",type
);
67 static void rawaudiofile_write_chunk(muxer_stream_t
*s
,size_t len
,unsigned int flags
, double dts
, double pts
){
68 muxer_t
*muxer
=s
->muxer
;
70 // write out the chunk:
71 if (s
->type
==MUXER_TYPE_AUDIO
)
72 stream_write_buffer(muxer
->stream
, s
->buffer
, len
);
75 static void rawaudiofile_write_header(muxer_t
*muxer
){
79 static void rawaudiofile_write_index(muxer_t
*muxer
){
83 int muxer_init_muxer_rawaudio(muxer_t
*muxer
){
84 muxer
->cont_new_stream
= &rawaudiofile_new_stream
;
85 muxer
->cont_write_chunk
= &rawaudiofile_write_chunk
;
86 muxer
->cont_write_header
= &rawaudiofile_write_header
;
87 muxer
->cont_write_index
= &rawaudiofile_write_index
;