2009-05-08 21:51:13 +00:00
|
|
|
/*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#ifndef MPLAYER_MUXER_H
|
|
|
|
#define MPLAYER_MUXER_H
|
2002-12-27 22:43:20 +00:00
|
|
|
|
2008-03-05 23:32:01 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include "aviheader.h"
|
|
|
|
#include "ms_hdr.h"
|
|
|
|
#include "stream/stream.h"
|
|
|
|
|
2002-12-27 22:43:20 +00:00
|
|
|
#define MUXER_MAX_STREAMS 16
|
|
|
|
|
|
|
|
#define MUXER_TYPE_VIDEO 0
|
|
|
|
#define MUXER_TYPE_AUDIO 1
|
|
|
|
|
|
|
|
#define MUXER_TYPE_AVI 0
|
|
|
|
#define MUXER_TYPE_MPEG 1
|
2004-03-09 14:46:34 +00:00
|
|
|
#define MUXER_TYPE_RAWVIDEO 2
|
2005-02-21 23:18:31 +00:00
|
|
|
#define MUXER_TYPE_LAVF 3
|
2005-06-19 09:12:44 +00:00
|
|
|
#define MUXER_TYPE_RAWAUDIO 4
|
2002-12-27 22:43:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
// muxer data:
|
|
|
|
int type; // audio or video
|
|
|
|
int id; // stream no
|
|
|
|
uint32_t ckid; // chunk id (00dc 01wb etc)
|
|
|
|
double timer;
|
|
|
|
off_t size;
|
2004-03-24 15:16:36 +00:00
|
|
|
float aspect; // aspect ratio of this stream (set by ve_*.c)
|
2002-12-27 22:43:20 +00:00
|
|
|
// buffering:
|
|
|
|
unsigned char *buffer;
|
|
|
|
unsigned int buffer_size;
|
|
|
|
unsigned int buffer_len;
|
|
|
|
// mpeg block buffer:
|
|
|
|
unsigned char *b_buffer;
|
2005-02-21 21:45:49 +00:00
|
|
|
unsigned int b_buffer_size; //size of b_buffer
|
|
|
|
unsigned int b_buffer_ptr; //index to next data to write
|
|
|
|
unsigned int b_buffer_len; //len of next data to write
|
2005-11-21 22:53:14 +00:00
|
|
|
// muxer frame buffer:
|
|
|
|
unsigned int muxbuf_seen;
|
2002-12-27 22:43:20 +00:00
|
|
|
// source stream:
|
|
|
|
void* source; // sh_audio or sh_video
|
|
|
|
int codec; // codec used for encoding. 0 means copy
|
|
|
|
// avi stream header:
|
|
|
|
AVIStreamHeader h; // Rate/Scale and SampleSize must be filled by caller!
|
|
|
|
// stream specific:
|
|
|
|
WAVEFORMATEX *wf;
|
|
|
|
BITMAPINFOHEADER *bih; // in format
|
2006-02-21 09:40:25 +00:00
|
|
|
int encoder_delay; // in number of frames
|
|
|
|
int decoder_delay; // in number of frames
|
2007-05-17 00:15:08 +00:00
|
|
|
int imgfmt;
|
2002-12-27 22:43:20 +00:00
|
|
|
// mpeg specific:
|
|
|
|
size_t ipb[3]; // sizes of I/P/B frames
|
2003-01-19 00:33:11 +00:00
|
|
|
// muxer of that stream
|
|
|
|
struct muxer_t *muxer;
|
2003-10-22 17:04:39 +00:00
|
|
|
void *priv; // private stream specific data stored by the muxer
|
2006-01-25 01:17:57 +00:00
|
|
|
|
|
|
|
int vbv_size;
|
|
|
|
int max_rate;
|
2006-08-10 21:48:41 +00:00
|
|
|
int avg_rate;
|
2002-12-27 22:43:20 +00:00
|
|
|
} muxer_stream_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint32_t id;
|
|
|
|
char *text;
|
|
|
|
} muxer_info_t;
|
|
|
|
|
|
|
|
typedef struct muxer_t{
|
|
|
|
// encoding:
|
|
|
|
MainAVIHeader avih;
|
2004-03-17 14:50:37 +00:00
|
|
|
off_t movi_start;
|
|
|
|
off_t movi_end;
|
|
|
|
off_t file_end; // for MPEG it's system timestamp in 1/90000 s
|
2006-02-19 09:34:37 +00:00
|
|
|
float audio_delay_fix;
|
2002-12-27 22:43:20 +00:00
|
|
|
// index:
|
|
|
|
AVIINDEXENTRY *idx;
|
|
|
|
int idx_pos;
|
|
|
|
int idx_size;
|
|
|
|
// streams:
|
|
|
|
int num_videos; // for MPEG recalculations
|
2005-02-21 21:45:49 +00:00
|
|
|
int num_audios;
|
2002-12-27 22:43:20 +00:00
|
|
|
unsigned int sysrate; // max rate in bytes/s
|
|
|
|
//int num_streams;
|
|
|
|
muxer_stream_t* def_v; // default video stream (for general headers)
|
|
|
|
muxer_stream_t* streams[MUXER_MAX_STREAMS];
|
2005-11-21 22:53:14 +00:00
|
|
|
// muxer frame buffer:
|
|
|
|
struct muxbuf_t * muxbuf;
|
|
|
|
int muxbuf_num;
|
|
|
|
int muxbuf_skip_buffer;
|
|
|
|
// functions:
|
2006-12-18 21:03:59 +00:00
|
|
|
stream_t *stream;
|
2005-02-21 21:45:49 +00:00
|
|
|
void (*fix_stream_parameters)(muxer_stream_t *);
|
2006-01-26 19:32:07 +00:00
|
|
|
void (*cont_write_chunk)(muxer_stream_t *,size_t,unsigned int, double dts, double pts);
|
2003-01-19 00:33:11 +00:00
|
|
|
void (*cont_write_header)(struct muxer_t *);
|
|
|
|
void (*cont_write_index)(struct muxer_t *);
|
2002-12-27 22:43:20 +00:00
|
|
|
muxer_stream_t* (*cont_new_stream)(struct muxer_t *,int);
|
2005-02-21 21:45:49 +00:00
|
|
|
void *priv;
|
2002-12-27 22:43:20 +00:00
|
|
|
} muxer_t;
|
|
|
|
|
2005-11-21 22:53:14 +00:00
|
|
|
/* muxer frame buffer */
|
|
|
|
typedef struct muxbuf_t {
|
|
|
|
muxer_stream_t *stream; /* pointer back to corresponding stream */
|
2006-01-26 19:32:07 +00:00
|
|
|
double dts; /* decode timestamp / time at which this packet should be feeded into the decoder */
|
|
|
|
double pts; /* presentation timestamp / time at which the data in this packet will be presented to the user */
|
2005-11-21 22:53:14 +00:00
|
|
|
unsigned char *buffer;
|
|
|
|
size_t len;
|
|
|
|
unsigned int flags;
|
|
|
|
} muxbuf_t;
|
|
|
|
|
2007-01-21 10:10:07 +00:00
|
|
|
extern char *force_fourcc;
|
|
|
|
|
2006-12-18 21:03:59 +00:00
|
|
|
muxer_t *muxer_new_muxer(int type,stream_t *stream);
|
2002-12-27 22:43:20 +00:00
|
|
|
#define muxer_new_stream(muxer,a) muxer->cont_new_stream(muxer,a)
|
2005-02-21 21:45:49 +00:00
|
|
|
#define muxer_stream_fix_parameters(muxer, a) muxer->fix_stream_parameters(a)
|
2006-01-26 19:32:07 +00:00
|
|
|
void muxer_write_chunk(muxer_stream_t *s, size_t len, unsigned int flags, double dts, double pts);
|
2003-01-19 00:33:11 +00:00
|
|
|
#define muxer_write_header(muxer) muxer->cont_write_header(muxer)
|
|
|
|
#define muxer_write_index(muxer) muxer->cont_write_index(muxer)
|
2002-12-27 22:43:20 +00:00
|
|
|
|
2005-02-21 21:45:49 +00:00
|
|
|
int muxer_init_muxer_avi(muxer_t *);
|
|
|
|
int muxer_init_muxer_mpeg(muxer_t *);
|
|
|
|
int muxer_init_muxer_rawvideo(muxer_t *);
|
2005-03-18 01:59:43 +00:00
|
|
|
int muxer_init_muxer_lavf(muxer_t *);
|
2005-06-19 09:12:44 +00:00
|
|
|
int muxer_init_muxer_rawaudio(muxer_t *);
|
2008-01-01 21:35:58 +00:00
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#endif /* MPLAYER_MUXER_H */
|