stream/tv: move new_handle() function from header to tv.c
[mplayer.git] / libmpdemux / muxer_rawaudio.c
blob68e433f4ad60e662484922485895fbe3348c1d64
1 /*
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.
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <sys/types.h>
24 #include "mp_msg.h"
26 #include "aviheader.h"
27 #include "ms_hdr.h"
29 #include "stream/stream.h"
30 #include "muxer.h"
32 static muxer_stream_t* rawaudiofile_new_stream(muxer_t *muxer,int type){
33 muxer_stream_t* s;
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"));
38 return NULL;
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;
44 s->type=type;
45 s->id=muxer->avih.dwStreams;
46 s->timer=0.0;
47 s->size=0;
48 s->muxer=muxer;
49 switch(type){
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++;
54 break;
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;
59 break;
60 default:
61 mp_tmsg(MSGT_MUXER,MSGL_ERR,"Warning, unknown stream type: %d\n",type);
62 return NULL;
64 return s;
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){
76 return;
79 static void rawaudiofile_write_index(muxer_t *muxer){
80 return;
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;
88 return 1;