Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

real_rmff.h

00001 /*
00002  * Copyright (C) 2002-2003 the xine project
00003  *
00004  * This file is part of xine, a free video player.
00005  *
00006  * xine is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * xine is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
00019  *
00020  * $Id: rmff.h,v 1.5 2004/04/06 19:20:16 valtri Exp $
00021  *
00022  * some functions for real media file headers
00023  * adopted from joschkas real tools
00024  */
00025 
00026 #ifndef HAVE_RMFF_H
00027 #define HAVE_RMFF_H
00028 
00029 
00030 #define RMFF_HEADER_SIZE 0x12
00031 
00032 #define FOURCC_TAG( ch0, ch1, ch2, ch3 ) \
00033         (((long)(unsigned char)(ch3)       ) | \
00034         ( (long)(unsigned char)(ch2) << 8  ) | \
00035         ( (long)(unsigned char)(ch1) << 16 ) | \
00036         ( (long)(unsigned char)(ch0) << 24 ) )
00037 
00038 
00039 #define RMF_TAG   FOURCC_TAG('.', 'R', 'M', 'F')
00040 #define PROP_TAG  FOURCC_TAG('P', 'R', 'O', 'P')
00041 #define MDPR_TAG  FOURCC_TAG('M', 'D', 'P', 'R')
00042 #define CONT_TAG  FOURCC_TAG('C', 'O', 'N', 'T')
00043 #define DATA_TAG  FOURCC_TAG('D', 'A', 'T', 'A')
00044 #define INDX_TAG  FOURCC_TAG('I', 'N', 'D', 'X')
00045 #define PNA_TAG   FOURCC_TAG('P', 'N', 'A',  0 )
00046 
00047 #define MLTI_TAG  FOURCC_TAG('M', 'L', 'T', 'I')
00048 
00049 /* prop flags */
00050 #define PN_SAVE_ENABLED         0x01
00051 #define PN_PERFECT_PLAY_ENABLED 0x02
00052 #define PN_LIVE_BROADCAST       0x04
00053 
00054 /*
00055  * rm header data structs
00056  */
00057 
00058 typedef struct {
00059 
00060   uint32_t object_id;
00061   uint32_t size;
00062   uint16_t object_version;
00063 
00064   uint32_t file_version;
00065   uint32_t num_headers;
00066 } rmff_fileheader_t;
00067 
00068 typedef struct {
00069 
00070   uint32_t object_id;
00071   uint32_t size;
00072   uint16_t object_version;
00073 
00074   uint32_t max_bit_rate;
00075   uint32_t avg_bit_rate;
00076   uint32_t max_packet_size;
00077   uint32_t avg_packet_size;
00078   uint32_t num_packets;
00079   uint32_t duration;
00080   uint32_t preroll;
00081   uint32_t index_offset;
00082   uint32_t data_offset;
00083   uint16_t num_streams;
00084   uint16_t flags;
00085 } rmff_prop_t;
00086 
00087 typedef struct {
00088 
00089   uint32_t  object_id;
00090   uint32_t  size;
00091   uint16_t  object_version;
00092 
00093   uint16_t  stream_number;
00094   uint32_t  max_bit_rate;
00095   uint32_t  avg_bit_rate;
00096   uint32_t  max_packet_size;
00097   uint32_t  avg_packet_size;
00098   uint32_t  start_time;
00099   uint32_t  preroll;
00100   uint32_t  duration;
00101   uint8_t   stream_name_size;
00102   char      *stream_name;
00103   uint8_t   mime_type_size;
00104   char      *mime_type;
00105   uint32_t  type_specific_len;
00106   char      *type_specific_data;
00107 
00108   int       mlti_data_size;
00109   char      *mlti_data;
00110 
00111 } rmff_mdpr_t;
00112 
00113 typedef struct {
00114 
00115   uint32_t  object_id;
00116   uint32_t  size;
00117   uint16_t  object_version;
00118 
00119   uint16_t  title_len;
00120   char      *title;
00121   uint16_t  author_len;
00122   char      *author;
00123   uint16_t  copyright_len;
00124   char      *copyright;
00125   uint16_t  comment_len;
00126   char      *comment;
00127 
00128 } rmff_cont_t;
00129 
00130 typedef struct {
00131 
00132   uint32_t object_id;
00133   uint32_t size;
00134   uint16_t object_version;
00135 
00136   uint32_t num_packets;
00137   uint32_t next_data_header; /* rarely used */
00138 } rmff_data_t;
00139 
00140 typedef struct {
00141 
00142   rmff_fileheader_t *fileheader;
00143   rmff_prop_t *prop;
00144   rmff_mdpr_t **streams;
00145   rmff_cont_t *cont;
00146   rmff_data_t *data;
00147 } rmff_header_t;
00148 
00149 typedef struct {
00150 
00151   uint16_t object_version;
00152 
00153   uint16_t length;
00154   uint16_t stream_number;
00155   uint32_t timestamp;
00156   uint8_t reserved;
00157   uint8_t flags;
00158 
00159 } rmff_pheader_t;
00160 
00161 /*
00162  * constructors for header structs
00163  */
00164 
00165 rmff_fileheader_t *rmff_new_fileheader(uint32_t num_headers);
00166 
00167 rmff_prop_t *rmff_new_prop (
00168     uint32_t max_bit_rate,
00169     uint32_t avg_bit_rate,
00170     uint32_t max_packet_size,
00171     uint32_t avg_packet_size,
00172     uint32_t num_packets,
00173     uint32_t duration,
00174     uint32_t preroll,
00175     uint32_t index_offset,
00176     uint32_t data_offset,
00177     uint16_t num_streams,
00178     uint16_t flags );
00179 
00180 rmff_mdpr_t *rmff_new_mdpr(
00181     uint16_t   stream_number,
00182     uint32_t   max_bit_rate,
00183     uint32_t   avg_bit_rate,
00184     uint32_t   max_packet_size,
00185     uint32_t   avg_packet_size,
00186     uint32_t   start_time,
00187     uint32_t   preroll,
00188     uint32_t   duration,
00189     const char *stream_name,
00190     const char *mime_type,
00191     uint32_t   type_specific_len,
00192     const char *type_specific_data );
00193 
00194 rmff_cont_t *rmff_new_cont(
00195     const char *title,
00196     const char *author,
00197     const char *copyright,
00198     const char *comment);
00199 
00200 rmff_data_t *rmff_new_dataheader(
00201     uint32_t num_packets, uint32_t next_data_header);
00202 
00203 /*
00204  * reads header infos from data and returns a newly allocated header struct
00205  */
00206 rmff_header_t *rmff_scan_header(const char *data);
00207 
00208 /*
00209  * scans a data packet header. Notice, that this function does not allocate
00210  * the header struct itself.
00211  */
00212 void rmff_scan_pheader(rmff_pheader_t *h, char *data);
00213 
00214 /*
00215  * reads header infos from stream and returns a newly allocated header struct
00216  */
00217 rmff_header_t *rmff_scan_header_stream(int fd);
00218 
00219 /*
00220  * prints header information in human readible form to stdout
00221  */
00222 void rmff_print_header(rmff_header_t *h);
00223 
00224 /*
00225  * does some checks and fixes header if possible
00226  */
00227 void rmff_fix_header(rmff_header_t *h);
00228 
00229 /*
00230  * returns the size of the header (incl. first data-header)
00231  */
00232 int rmff_get_header_size(rmff_header_t *h);
00233  
00234 /*
00235  * dumps the header <h> to <buffer>. <max> is the size of <buffer>
00236  */
00237 int rmff_dump_header(rmff_header_t *h, char *buffer, int max);
00238 
00239 /*
00240  * dumps a packet header
00241  */
00242 void rmff_dump_pheader(rmff_pheader_t *h, char *data);
00243 
00244 /*
00245  * frees a header struct
00246  */
00247 void rmff_free_header(rmff_header_t *h);
00248 
00249 #endif

Generated on Tue Dec 20 10:14:26 2005 for vlc-0.8.4a by  doxygen 1.4.2