Mercurial > mplayer.hg
annotate libmpdemux/muxer_rawaudio.c @ 36747:f42a82d80710
Use calloc instead of malloc+memset.
author | reimar |
---|---|
date | Sat, 15 Feb 2014 17:24:28 +0000 |
parents | d643e4643313 |
children |
rev | line source |
---|---|
29238
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
22605
diff
changeset
|
1 /* |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
22605
diff
changeset
|
2 * This file is part of MPlayer. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
22605
diff
changeset
|
3 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
22605
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
22605
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
22605
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
22605
diff
changeset
|
7 * (at your option) any later version. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
22605
diff
changeset
|
8 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
22605
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
22605
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
22605
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
22605
diff
changeset
|
12 * GNU General Public License for more details. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
22605
diff
changeset
|
13 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
22605
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
22605
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
22605
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
22605
diff
changeset
|
17 */ |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
22605
diff
changeset
|
18 |
15754 | 19 #include <stdio.h> |
20 #include <stdlib.h> | |
21 #include <string.h> | |
15774 | 22 #include <sys/types.h> |
15754 | 23 |
24 #include "help_mp.h" | |
25 #include "mp_msg.h" | |
26 | |
27 #include "aviheader.h" | |
28 #include "ms_hdr.h" | |
29 | |
22605
4d81dbdf46b9
Add explicit location for headers from the stream/ directory.
diego
parents:
21660
diff
changeset
|
30 #include "stream/stream.h" |
15754 | 31 #include "muxer.h" |
32 | |
33 static muxer_stream_t* rawaudiofile_new_stream(muxer_t *muxer,int type){ | |
34 muxer_stream_t* s; | |
35 if (!muxer) return NULL; | |
36 if(type==MUXER_TYPE_AUDIO && muxer->avih.dwStreams>=1){ | |
37 mp_msg(MSGT_MUXER,MSGL_ERR,MSGTR_TooManyStreams" "MSGTR_RawMuxerOnlyOneStream); | |
38 return NULL; | |
39 } | |
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_msg(MSGT_MUXER,MSGL_WARN,MSGTR_IgnoringVideoStream); | |
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_msg(MSGT_MUXER,MSGL_ERR,MSGTR_UnknownStreamType,type); | |
62 return NULL; | |
63 } | |
64 return s; | |
65 } | |
66 | |
17487
fa17424b4c7b
change muxer_write_chunk() so that pts/dts _could_ be passed from encoder to muxer
michael
parents:
17023
diff
changeset
|
67 static void rawaudiofile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags, double dts, double pts){ |
15754 | 68 muxer_t *muxer=s->muxer; |
69 | |
70 // write out the chunk: | |
71 if (s->type==MUXER_TYPE_AUDIO) | |
21660
ca9da45d13e9
muxers now write to output muxer->stream rather than to muxer->file
nicodvb
parents:
17487
diff
changeset
|
72 stream_write_buffer(muxer->stream, s->buffer, len); |
15754 | 73 } |
74 | |
75 static void rawaudiofile_write_header(muxer_t *muxer){ | |
76 return; | |
77 } | |
78 | |
79 static void rawaudiofile_write_index(muxer_t *muxer){ | |
80 return; | |
81 } | |
82 | |
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; | |
89 } |