stream/tv: move new_handle() function from header to tv.c
[mplayer.git] / libmpdemux / muxer_rawvideo.c
blobc4ed4ba22aaf9822c5b7bb6e3edf375927d08952
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 <inttypes.h>
23 #include <unistd.h>
25 #include "config.h"
26 //#include "stream/stream.h"
27 //#include "demuxer.h"
28 //#include "stheader.h"
29 #include "aviheader.h"
30 #include "ms_hdr.h"
32 #include "stream/stream.h"
33 #include "muxer.h"
35 static muxer_stream_t* rawvideofile_new_stream(muxer_t *muxer,int type){
36 muxer_stream_t* s;
37 if (!muxer) return NULL;
38 s=malloc(sizeof(muxer_stream_t));
39 memset(s,0,sizeof(muxer_stream_t));
40 if(!s) return NULL; // no mem!?
41 muxer->streams[muxer->avih.dwStreams]=s;
42 s->type=type;
43 s->id=muxer->avih.dwStreams;
44 s->timer=0.0;
45 s->size=0;
46 s->muxer=muxer;
47 switch(type){
48 case MUXER_TYPE_VIDEO:
49 s->ckid=mmioFOURCC(('0'+s->id/10),('0'+(s->id%10)),'d','c');
50 s->h.fccType=streamtypeVIDEO;
51 if(!muxer->def_v) muxer->def_v=s;
52 break;
54 muxer->avih.dwStreams++;
55 return s;
58 static void write_rawvideo_chunk(stream_t *stream,int len,void* data){
59 if(len>0){
60 if(data){
61 // DATA
62 stream_write_buffer(stream,data,len);
67 static void rawvideofile_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_VIDEO)
72 write_rawvideo_chunk(muxer->stream,len,s->buffer); /* unsigned char */
74 // if((unsigned int)len>s->h.dwSuggestedBufferSize) s->h.dwSuggestedBufferSize=len;
78 static void rawvideofile_write_header(muxer_t *muxer){
79 return;
82 static void rawvideofile_write_index(muxer_t *muxer){
83 return;
86 int muxer_init_muxer_rawvideo(muxer_t *muxer){
87 muxer->cont_new_stream = &rawvideofile_new_stream;
88 muxer->cont_write_chunk = &rawvideofile_write_chunk;
89 muxer->cont_write_header = &rawvideofile_write_header;
90 muxer->cont_write_index = &rawvideofile_write_index;
91 return 1;