Preparations for file appending: Added a "force" parameter to the the reader's read() call. If force is true then the reader must read packets for each packetizer that hasn't been finished yet (otherwise a reader may return EHOLDING if a specific packetizer has a lot of data queued). Also ptzr may be NULL in this case.

This commit is contained in:
Moritz Bunkus 2004-07-14 13:25:16 +00:00
parent 47de897341
commit e60cb009ef
32 changed files with 54 additions and 31 deletions

View File

@ -168,7 +168,8 @@ aac_reader_c::guess_adts_version() {
}
int
aac_reader_c::read(generic_packetizer_c *) {
aac_reader_c::read(generic_packetizer_c *,
bool) {
int nread;
nread = mm_io->read(chunk, 4096);

View File

@ -43,7 +43,7 @@ public:
aac_reader_c(track_info_c *nti) throw (error_c);
virtual ~aac_reader_c();
virtual int read(generic_packetizer_c *ptzr);
virtual int read(generic_packetizer_c *ptzr, bool force = false);
virtual int display_priority();
virtual void display_progress(bool final = false);
virtual void identify();

View File

@ -106,7 +106,8 @@ ac3_reader_c::create_packetizer(int64_t) {
}
int
ac3_reader_c::read(generic_packetizer_c *) {
ac3_reader_c::read(generic_packetizer_c *,
bool) {
int nread;
nread = mm_io->read(chunk, 4096);

View File

@ -42,7 +42,7 @@ public:
ac3_reader_c(track_info_c *nti) throw (error_c);
virtual ~ac3_reader_c();
virtual int read(generic_packetizer_c *ptzr);
virtual int read(generic_packetizer_c *ptzr, bool force = false);
virtual int display_priority();
virtual void display_progress(bool final = false);
virtual void identify();

View File

@ -355,7 +355,8 @@ avi_reader_c::is_keyframe(unsigned char *data,
// {{{ FUNCTION avi_reader_c::read
int
avi_reader_c::read(generic_packetizer_c *ptzr) {
avi_reader_c::read(generic_packetizer_c *ptzr,
bool force) {
vector<avi_demuxer_t>::iterator demuxer;
int key, last_frame, frames_read, size;
long nread;

View File

@ -61,7 +61,7 @@ public:
avi_reader_c(track_info_c *nti) throw (error_c);
virtual ~avi_reader_c();
virtual int read(generic_packetizer_c *ptzr);
virtual int read(generic_packetizer_c *ptzr, bool force = false);
virtual int display_priority();
virtual void display_progress(bool final = false);
virtual void identify();

View File

@ -100,7 +100,8 @@ dts_reader_c::create_packetizer(int64_t) {
}
int
dts_reader_c::read(generic_packetizer_c *) {
dts_reader_c::read(generic_packetizer_c *,
bool) {
int nread;
nread = mm_io->read(chunk, max_dts_packet_size);

View File

@ -42,7 +42,7 @@ public:
dts_reader_c(track_info_c *nti) throw (error_c);
virtual ~dts_reader_c();
virtual int read(generic_packetizer_c *ptzr);
virtual int read(generic_packetizer_c *ptzr, bool force = false);
virtual int display_priority();
virtual void display_progress(bool final = false);
virtual void identify();

View File

@ -207,7 +207,8 @@ flac_reader_c::parse_file() {
}
int
flac_reader_c::read(generic_packetizer_c *) {
flac_reader_c::read(generic_packetizer_c *,
bool) {
unsigned char *buf;
if (current_block == blocks.end())

View File

@ -56,7 +56,7 @@ public:
flac_reader_c(track_info_c *nti) throw (error_c);
virtual ~flac_reader_c();
virtual int read(generic_packetizer_c *ptzr);
virtual int read(generic_packetizer_c *ptzr, bool force = false);
virtual void identify();
virtual void create_packetizer(int64_t id);

View File

@ -1695,7 +1695,8 @@ kax_reader_c::create_packetizers() {
// {{{ FUNCTION kax_reader_c::read()
int
kax_reader_c::read(generic_packetizer_c *) {
kax_reader_c::read(generic_packetizer_c *,
bool force) {
int upper_lvl_el, i, bgidx;
// Elements for different levels
EbmlElement *l0 = NULL, *l1 = NULL, *l2 = NULL;

View File

@ -137,7 +137,7 @@ public:
kax_reader_c(track_info_c *nti) throw (error_c);
virtual ~kax_reader_c();
virtual int read(generic_packetizer_c *ptzr);
virtual int read(generic_packetizer_c *ptzr, bool force = false);
virtual int display_priority();
virtual void display_progress(bool final = false);

View File

@ -81,7 +81,8 @@ mp3_reader_c::create_packetizer(int64_t) {
}
int
mp3_reader_c::read(generic_packetizer_c *) {
mp3_reader_c::read(generic_packetizer_c *,
bool) {
int nread;
nread = mm_io->read(chunk, 16384);

View File

@ -42,7 +42,7 @@ public:
mp3_reader_c(track_info_c *nti) throw (error_c);
virtual ~mp3_reader_c();
virtual int read(generic_packetizer_c *ptzr);
virtual int read(generic_packetizer_c *ptzr, bool force = false);
virtual void identify();
virtual void create_packetizer(int64_t tid);

View File

@ -1032,7 +1032,8 @@ ogm_reader_c::read_headers() {
* General reader. Read a page and hand it over for processing.
*/
int
ogm_reader_c::read(generic_packetizer_c *) {
ogm_reader_c::read(generic_packetizer_c *,
bool) {
int i;
ogg_page og;

View File

@ -110,7 +110,7 @@ public:
ogm_reader_c(track_info_c *nti) throw (error_c);
virtual ~ogm_reader_c();
virtual int read(generic_packetizer_c *ptzr);
virtual int read(generic_packetizer_c *ptzr, bool force = false);
virtual void identify();
virtual void create_packetizers();
virtual void create_packetizer(int64_t tid);

View File

@ -819,7 +819,8 @@ qtmp4_reader_c::handle_header_atoms(uint32_t parent,
}
int
qtmp4_reader_c::read(generic_packetizer_c *ptzr) {
qtmp4_reader_c::read(generic_packetizer_c *ptzr,
bool force) {
uint32_t i, k, frame, frame_size;
qtmp4_demuxer_t *dmx;
bool chunks_left, is_keyframe;

View File

@ -125,7 +125,7 @@ public:
qtmp4_reader_c(track_info_c *nti) throw (error_c);
virtual ~qtmp4_reader_c();
virtual int read(generic_packetizer_c *ptzr);
virtual int read(generic_packetizer_c *ptzr, bool force = false);
virtual int display_priority();
virtual void display_progress(bool final = false);
virtual void identify();

View File

@ -420,7 +420,8 @@ real_reader_c::finish() {
// {{{ FUNCTION real_reader_c::read()
int
real_reader_c::read(generic_packetizer_c *) {
real_reader_c::read(generic_packetizer_c *,
bool) {
int size;
unsigned char *chunk;
real_demuxer_t *dmx;

View File

@ -73,7 +73,7 @@ public:
real_reader_c(track_info_c *nti) throw (error_c);
virtual ~real_reader_c();
virtual int read(generic_packetizer_c *ptzr);
virtual int read(generic_packetizer_c *ptzr, bool force = false);
virtual int display_priority();
virtual void display_progress(bool final = false);
virtual void identify();

View File

@ -107,7 +107,8 @@ srt_reader_c::create_packetizer(int64_t) {
#define STATE_TIME 3
int
srt_reader_c::read(generic_packetizer_c *) {
srt_reader_c::read(generic_packetizer_c *,
bool) {
int64_t start, end;
char *chunk;
subtitles_c subs;

View File

@ -37,7 +37,7 @@ public:
srt_reader_c(track_info_c *nti) throw (error_c);
virtual ~srt_reader_c();
virtual int read(generic_packetizer_c *ptzr);
virtual int read(generic_packetizer_c *ptzr, bool force = false);
virtual void identify();
virtual void create_packetizer(int64_t tid);

View File

@ -228,7 +228,8 @@ ssa_reader_c::recode_text(vector<string> &fields) {
}
int
ssa_reader_c::read(generic_packetizer_c *) {
ssa_reader_c::read(generic_packetizer_c *,
bool) {
string line, stime, orig_line, comma;
int i, num;
int64_t start, end;

View File

@ -46,7 +46,7 @@ public:
ssa_reader_c(track_info_c *nti) throw (error_c);
virtual ~ssa_reader_c();
virtual int read(generic_packetizer_c *ptzr);
virtual int read(generic_packetizer_c *ptzr, bool force = false);
virtual void identify();
virtual void create_packetizer(int64_t tid);

View File

@ -115,7 +115,8 @@ tta_reader_c::create_packetizer(int64_t) {
}
int
tta_reader_c::read(generic_packetizer_c *) {
tta_reader_c::read(generic_packetizer_c *,
bool) {
unsigned char *buf;
int nread;

View File

@ -44,7 +44,7 @@ public:
tta_reader_c(track_info_c *nti) throw (error_c);
virtual ~tta_reader_c();
virtual int read(generic_packetizer_c *ptzr);
virtual int read(generic_packetizer_c *ptzr, bool force = false);
virtual int display_priority();
virtual void display_progress(bool final = false);
virtual void identify();

View File

@ -530,7 +530,8 @@ vobsub_reader_c::extract_one_spu_packet(int64_t timecode,
}
int
vobsub_reader_c::read(generic_packetizer_c *ptzr) {
vobsub_reader_c::read(generic_packetizer_c *ptzr,
bool force) {
vobsub_track_c *track;
uint32_t i, id;

View File

@ -68,7 +68,7 @@ public:
vobsub_reader_c(track_info_c *nti) throw (error_c);
virtual ~vobsub_reader_c();
virtual int read(generic_packetizer_c *ptzr);
virtual int read(generic_packetizer_c *ptzr, bool force = false);
virtual void identify();
virtual void create_packetizers();
virtual void create_packetizer(int64_t tid);

View File

@ -167,7 +167,8 @@ wav_reader_c::create_packetizer(int64_t) {
}
int
wav_reader_c::read(generic_packetizer_c *) {
wav_reader_c::read(generic_packetizer_c *,
bool) {
if (!is_dts) {
int nread;

View File

@ -50,7 +50,7 @@ public:
wav_reader_c(track_info_c *nti) throw (error_c);
virtual ~wav_reader_c();
virtual int read(generic_packetizer_c *ptzr);
virtual int read(generic_packetizer_c *ptzr, bool force = false);
virtual void identify();
virtual void create_packetizer(int64_t tid);

View File

@ -1107,6 +1107,13 @@ generic_reader_c::~generic_reader_c() {
delete ti;
}
int
generic_reader_c::read_all() {
while (read(NULL, true) != 0)
;
return 0;
}
bool
generic_reader_c::demuxing_requested(char type,
int64_t id) {

View File

@ -258,7 +258,8 @@ public:
generic_reader_c(track_info_c *nti);
virtual ~generic_reader_c();
virtual int read(generic_packetizer_c *ptzr) = 0;
virtual int read(generic_packetizer_c *ptzr, bool force = false) = 0;
virtual int read_all();
virtual int display_priority();
virtual void display_progress(bool final = false);
virtual void set_headers();