2003-04-11 10:03:16 +00:00
|
|
|
/*
|
|
|
|
mkvmerge -- utility for splicing together matroska files
|
|
|
|
from component media subtypes
|
|
|
|
|
|
|
|
r_matroska.h
|
|
|
|
|
|
|
|
Written by Moritz Bunkus <moritz@bunkus.org>
|
|
|
|
|
|
|
|
Distributed under the GPL
|
|
|
|
see the file COPYING for details
|
|
|
|
or visit http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\file
|
2003-06-15 14:03:28 +00:00
|
|
|
\version $Id$
|
2003-04-11 10:03:16 +00:00
|
|
|
\brief class definitions for the Matroska reader
|
2003-05-18 20:57:08 +00:00
|
|
|
\author Moritz Bunkus <moritz@bunkus.org>
|
2003-04-11 10:03:16 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __R_MATROSKA_H
|
|
|
|
#define __R_MATROSKA_H
|
|
|
|
|
2003-06-20 19:29:26 +00:00
|
|
|
#include "os.h"
|
|
|
|
|
2003-04-11 10:03:16 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2003-05-23 06:34:58 +00:00
|
|
|
#include "mm_io.h"
|
2003-04-11 10:03:16 +00:00
|
|
|
#include "common.h"
|
|
|
|
#include "pr_generic.h"
|
|
|
|
#include "error.h"
|
|
|
|
|
|
|
|
#include "KaxBlock.h"
|
2003-04-18 10:08:24 +00:00
|
|
|
#include "KaxCluster.h"
|
2003-04-11 10:03:16 +00:00
|
|
|
#include "StdIOCallback.h"
|
|
|
|
|
|
|
|
using namespace LIBMATROSKA_NAMESPACE;
|
|
|
|
|
|
|
|
typedef struct {
|
2003-05-03 20:22:18 +00:00
|
|
|
uint32_t tnum, tuid;
|
2003-05-20 06:30:25 +00:00
|
|
|
|
2003-04-11 10:03:16 +00:00
|
|
|
char *codec_id;
|
|
|
|
int ms_compat;
|
|
|
|
|
|
|
|
char type; // 'v' = video, 'a' = audio, 't' = text subs
|
2003-05-20 06:30:25 +00:00
|
|
|
|
2003-04-11 10:03:16 +00:00
|
|
|
// Parameters for video tracks
|
2003-05-06 10:22:55 +00:00
|
|
|
uint32_t v_width, v_height, v_dwidth, v_dheight;
|
2003-04-11 10:03:16 +00:00
|
|
|
float v_frate;
|
|
|
|
char v_fourcc[5];
|
|
|
|
|
|
|
|
// Parameters for audio tracks
|
2003-05-22 11:11:30 +00:00
|
|
|
uint32_t a_channels, a_bps, a_formattag;
|
2003-04-11 10:03:16 +00:00
|
|
|
float a_sfreq;
|
|
|
|
|
|
|
|
void *private_data;
|
|
|
|
unsigned int private_size;
|
|
|
|
|
|
|
|
unsigned char *headers[3];
|
2003-05-02 20:11:34 +00:00
|
|
|
uint32_t header_sizes[3];
|
2003-04-11 10:03:16 +00:00
|
|
|
|
2003-05-11 09:24:02 +00:00
|
|
|
int default_track;
|
|
|
|
char *language;
|
|
|
|
|
2003-04-13 15:23:03 +00:00
|
|
|
int64_t units_processed;
|
2003-04-11 10:03:16 +00:00
|
|
|
|
|
|
|
int ok;
|
|
|
|
|
|
|
|
generic_packetizer_c *packetizer;
|
|
|
|
} mkv_track_t;
|
|
|
|
|
2003-04-18 10:08:24 +00:00
|
|
|
typedef struct {
|
|
|
|
unsigned char *data;
|
|
|
|
int length;
|
|
|
|
} buffer_t;
|
|
|
|
|
2003-04-11 10:03:16 +00:00
|
|
|
class mkv_reader_c: public generic_reader_c {
|
|
|
|
private:
|
|
|
|
int act_wchar;
|
|
|
|
|
|
|
|
mkv_track_t **tracks;
|
|
|
|
int num_tracks;
|
|
|
|
|
2003-04-13 15:23:03 +00:00
|
|
|
int64_t tc_scale;
|
2003-05-02 20:11:34 +00:00
|
|
|
uint32_t cluster_tc;
|
2003-04-11 10:03:16 +00:00
|
|
|
|
|
|
|
StdIOCallback *in;
|
|
|
|
|
|
|
|
EbmlStream *es;
|
|
|
|
EbmlElement *saved_l1, *saved_l2, *segment;
|
2003-04-18 10:08:24 +00:00
|
|
|
|
|
|
|
KaxCluster *cluster;
|
|
|
|
|
|
|
|
buffer_t **buffers;
|
|
|
|
int num_buffers;
|
2003-04-20 20:08:02 +00:00
|
|
|
|
2003-06-11 17:06:48 +00:00
|
|
|
float segment_duration, last_timecode, first_timecode;
|
2003-04-20 20:08:02 +00:00
|
|
|
|
2003-04-11 10:03:16 +00:00
|
|
|
public:
|
|
|
|
mkv_reader_c(track_info_t *nti) throw (error_c);
|
|
|
|
virtual ~mkv_reader_c();
|
|
|
|
|
2003-05-02 20:11:34 +00:00
|
|
|
virtual int read();
|
|
|
|
virtual packet_t *get_packet();
|
2003-04-11 10:03:16 +00:00
|
|
|
|
2003-05-02 20:11:34 +00:00
|
|
|
virtual int display_priority();
|
|
|
|
virtual void display_progress();
|
2003-05-02 21:49:42 +00:00
|
|
|
virtual void set_headers();
|
2003-06-12 23:05:49 +00:00
|
|
|
virtual void identify();
|
2003-05-20 06:30:25 +00:00
|
|
|
|
2003-05-23 06:34:58 +00:00
|
|
|
static int probe_file(mm_io_c *mm_io, int64_t size);
|
2003-05-20 06:30:25 +00:00
|
|
|
|
2003-04-11 10:03:16 +00:00
|
|
|
private:
|
2003-05-02 20:11:34 +00:00
|
|
|
virtual int read_headers();
|
|
|
|
virtual void create_packetizers();
|
2003-04-11 10:03:16 +00:00
|
|
|
virtual mkv_track_t *new_mkv_track();
|
2003-05-02 20:11:34 +00:00
|
|
|
virtual mkv_track_t *find_track_by_num(uint32_t num, mkv_track_t *c = NULL);
|
2003-05-03 20:22:18 +00:00
|
|
|
virtual mkv_track_t *find_track_by_uid(uint32_t uid, mkv_track_t *c = NULL);
|
2003-05-02 20:11:34 +00:00
|
|
|
virtual void verify_tracks();
|
|
|
|
virtual int packets_available();
|
2003-04-11 10:03:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // __R_MATROSKA_H
|