00001 /***************************************************************************** 00002 * mpegdemux * 00003 *****************************************************************************/ 00004 00005 /***************************************************************************** 00006 * File name: mpeg_parse.h * 00007 * Created: 2003-02-01 by Hampa Hug <hampa@hampa.ch> * 00008 * Last modified: 2003-09-10 by Hampa Hug <hampa@hampa.ch> * 00009 * Copyright: (C) 2003 by Hampa Hug <hampa@hampa.ch> * 00010 *****************************************************************************/ 00011 00012 /***************************************************************************** 00013 * This program is free software. You can redistribute it and / or modify it * 00014 * under the terms of the GNU General Public License version 2 as published * 00015 * by the Free Software Foundation. * 00016 * * 00017 * This program is distributed in the hope that it will be useful, but * 00018 * WITHOUT ANY WARRANTY, without even the implied warranty of * 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * 00020 * Public License for more details. * 00021 *****************************************************************************/ 00022 00023 /* $Id: mpeg_parse.h 67 2004-01-02 18:20:15Z hampa $ */ 00024 00025 // The code has been modified to use file descriptors instead of FILE streams. 00026 // Only functionality needed in MediaTomb remains, all extra features are 00027 // stripped out. 00028 00029 #ifndef MPEG_PARSE_H 00030 #define MPEG_PARSE_H 1 00031 00032 #include <stdio.h> 00033 00034 00035 #define MPEG_DEMUX_BUFFER 4096 00036 00037 #define MPEG_END_CODE 0x01b9 00038 #define MPEG_PACK_START 0x01ba 00039 #define MPEG_SYSTEM_HEADER 0x01bb 00040 #define MPEG_PACKET_START 0x0001 00041 00042 00043 typedef struct { 00044 unsigned long packet_cnt; 00045 unsigned long long size; 00046 } mpeg_stream_info_t; 00047 00048 typedef struct { 00049 unsigned size; 00050 int fixed; 00051 int csps; 00052 } mpeg_shdr_t; 00053 00054 typedef struct { 00055 unsigned type; 00056 unsigned sid; 00057 unsigned ssid; 00058 unsigned size; 00059 unsigned offset; 00060 00061 char have_pts; 00062 unsigned long long pts; 00063 00064 char have_dts; 00065 unsigned long long dts; 00066 } mpeg_packet_t; 00067 00068 typedef struct { 00069 unsigned size; 00070 unsigned type; 00071 unsigned long long scr; 00072 unsigned long mux_rate; 00073 unsigned stuff; 00074 } mpeg_pack_t; 00075 00076 typedef struct mpeg_demux_t { 00077 int close; 00078 int free; 00079 00080 int fd; 00081 00082 unsigned long long ofs; 00083 00084 unsigned buf_i; 00085 unsigned buf_n; 00086 unsigned char buf[MPEG_DEMUX_BUFFER]; 00087 00088 mpeg_shdr_t shdr; 00089 mpeg_packet_t packet; 00090 mpeg_pack_t pack; 00091 00092 unsigned long shdr_cnt; 00093 unsigned long pack_cnt; 00094 unsigned long packet_cnt; 00095 unsigned long end_cnt; 00096 unsigned long skip_cnt; 00097 mpeg_stream_info_t streams[256]; 00098 mpeg_stream_info_t substreams[256]; 00099 00100 // void *ext; 00101 int ext; 00102 00103 int (*mpeg_skip) (struct mpeg_demux_t *mpeg); 00104 int (*mpeg_pack) (struct mpeg_demux_t *mpeg); 00105 int (*mpeg_system_header) (struct mpeg_demux_t *mpeg); 00106 int (*mpeg_packet) (struct mpeg_demux_t *mpeg); 00107 int (*mpeg_packet_check) (struct mpeg_demux_t *mpeg); 00108 int (*mpeg_end) (struct mpeg_demux_t *mpeg); 00109 } mpeg_demux_t; 00110 00111 00112 mpeg_demux_t *mpegd_open_fd (mpeg_demux_t *mpeg, int fd, int close_file); 00113 mpeg_demux_t *mpegd_open (mpeg_demux_t *mpeg, const char *fname); 00114 void mpegd_close (mpeg_demux_t *mpeg); 00115 void mpegd_reset_stats (mpeg_demux_t *mpeg); 00116 unsigned long mpegd_get_bits (mpeg_demux_t *mpeg, unsigned i, unsigned n); 00117 int mpegd_skip (mpeg_demux_t *mpeg, unsigned n); 00118 00119 /*!*************************************************************************** 00120 * @short Read from the mpeg stream 00121 * @return The number of bytes read 00122 *****************************************************************************/ 00123 unsigned mpegd_read (mpeg_demux_t *mpeg, void *buf, unsigned n); 00124 00125 int mpegd_set_offset (mpeg_demux_t *mpeg, unsigned long long ofs); 00126 int mpegd_parse (mpeg_demux_t *mpeg); 00127 00128 00129 #endif
1.6.1