From e60cb009efb937ba74d657caccfea40452b76aec Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 14 Jul 2004 13:25:16 +0000 Subject: [PATCH] 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. --- src/input/r_aac.cpp | 3 ++- src/input/r_aac.h | 2 +- src/input/r_ac3.cpp | 3 ++- src/input/r_ac3.h | 2 +- src/input/r_avi.cpp | 3 ++- src/input/r_avi.h | 2 +- src/input/r_dts.cpp | 3 ++- src/input/r_dts.h | 2 +- src/input/r_flac.cpp | 3 ++- src/input/r_flac.h | 2 +- src/input/r_matroska.cpp | 3 ++- src/input/r_matroska.h | 2 +- src/input/r_mp3.cpp | 3 ++- src/input/r_mp3.h | 2 +- src/input/r_ogm.cpp | 3 ++- src/input/r_ogm.h | 2 +- src/input/r_qtmp4.cpp | 3 ++- src/input/r_qtmp4.h | 2 +- src/input/r_real.cpp | 3 ++- src/input/r_real.h | 2 +- src/input/r_srt.cpp | 3 ++- src/input/r_srt.h | 2 +- src/input/r_ssa.cpp | 3 ++- src/input/r_ssa.h | 2 +- src/input/r_tta.cpp | 3 ++- src/input/r_tta.h | 2 +- src/input/r_vobsub.cpp | 3 ++- src/input/r_vobsub.h | 2 +- src/input/r_wav.cpp | 3 ++- src/input/r_wav.h | 2 +- src/pr_generic.cpp | 7 +++++++ src/pr_generic.h | 3 ++- 32 files changed, 54 insertions(+), 31 deletions(-) diff --git a/src/input/r_aac.cpp b/src/input/r_aac.cpp index 2f385dad3..997a5e782 100644 --- a/src/input/r_aac.cpp +++ b/src/input/r_aac.cpp @@ -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); diff --git a/src/input/r_aac.h b/src/input/r_aac.h index af6fb7579..3d0ad1a3b 100644 --- a/src/input/r_aac.h +++ b/src/input/r_aac.h @@ -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(); diff --git a/src/input/r_ac3.cpp b/src/input/r_ac3.cpp index 6b2f66c7a..ccafb9d95 100644 --- a/src/input/r_ac3.cpp +++ b/src/input/r_ac3.cpp @@ -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); diff --git a/src/input/r_ac3.h b/src/input/r_ac3.h index bbcafd849..d94f01d09 100644 --- a/src/input/r_ac3.h +++ b/src/input/r_ac3.h @@ -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(); diff --git a/src/input/r_avi.cpp b/src/input/r_avi.cpp index 0700863e3..c44c61232 100644 --- a/src/input/r_avi.cpp +++ b/src/input/r_avi.cpp @@ -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::iterator demuxer; int key, last_frame, frames_read, size; long nread; diff --git a/src/input/r_avi.h b/src/input/r_avi.h index 2b7656339..12b9a9c11 100644 --- a/src/input/r_avi.h +++ b/src/input/r_avi.h @@ -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(); diff --git a/src/input/r_dts.cpp b/src/input/r_dts.cpp index 547178668..ddc9361c3 100644 --- a/src/input/r_dts.cpp +++ b/src/input/r_dts.cpp @@ -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); diff --git a/src/input/r_dts.h b/src/input/r_dts.h index cd97d26c1..05e015dd1 100644 --- a/src/input/r_dts.h +++ b/src/input/r_dts.h @@ -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(); diff --git a/src/input/r_flac.cpp b/src/input/r_flac.cpp index 877a31086..bcdbed28b 100644 --- a/src/input/r_flac.cpp +++ b/src/input/r_flac.cpp @@ -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()) diff --git a/src/input/r_flac.h b/src/input/r_flac.h index ca9fc9abd..a7b65b584 100644 --- a/src/input/r_flac.h +++ b/src/input/r_flac.h @@ -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); diff --git a/src/input/r_matroska.cpp b/src/input/r_matroska.cpp index 32ba79607..f4fe14b92 100644 --- a/src/input/r_matroska.cpp +++ b/src/input/r_matroska.cpp @@ -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; diff --git a/src/input/r_matroska.h b/src/input/r_matroska.h index 45245c917..775f75804 100644 --- a/src/input/r_matroska.h +++ b/src/input/r_matroska.h @@ -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); diff --git a/src/input/r_mp3.cpp b/src/input/r_mp3.cpp index 47b25a426..12947d7ac 100644 --- a/src/input/r_mp3.cpp +++ b/src/input/r_mp3.cpp @@ -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); diff --git a/src/input/r_mp3.h b/src/input/r_mp3.h index 50d7cac69..941495e9f 100644 --- a/src/input/r_mp3.h +++ b/src/input/r_mp3.h @@ -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); diff --git a/src/input/r_ogm.cpp b/src/input/r_ogm.cpp index 725948a8e..5267d8470 100644 --- a/src/input/r_ogm.cpp +++ b/src/input/r_ogm.cpp @@ -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; diff --git a/src/input/r_ogm.h b/src/input/r_ogm.h index f0252ab7a..cb740244f 100644 --- a/src/input/r_ogm.h +++ b/src/input/r_ogm.h @@ -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); diff --git a/src/input/r_qtmp4.cpp b/src/input/r_qtmp4.cpp index 9f061f034..cd8f3c4e5 100644 --- a/src/input/r_qtmp4.cpp +++ b/src/input/r_qtmp4.cpp @@ -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; diff --git a/src/input/r_qtmp4.h b/src/input/r_qtmp4.h index 6007113f3..e455789a6 100644 --- a/src/input/r_qtmp4.h +++ b/src/input/r_qtmp4.h @@ -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(); diff --git a/src/input/r_real.cpp b/src/input/r_real.cpp index 15e194b96..a2a8ebb4e 100644 --- a/src/input/r_real.cpp +++ b/src/input/r_real.cpp @@ -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; diff --git a/src/input/r_real.h b/src/input/r_real.h index 38e1e2820..b8955768b 100644 --- a/src/input/r_real.h +++ b/src/input/r_real.h @@ -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(); diff --git a/src/input/r_srt.cpp b/src/input/r_srt.cpp index 86a527ee9..60a9c35ca 100644 --- a/src/input/r_srt.cpp +++ b/src/input/r_srt.cpp @@ -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; diff --git a/src/input/r_srt.h b/src/input/r_srt.h index 175e7580d..5b7b731ab 100644 --- a/src/input/r_srt.h +++ b/src/input/r_srt.h @@ -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); diff --git a/src/input/r_ssa.cpp b/src/input/r_ssa.cpp index 0c4259665..691e7e085 100644 --- a/src/input/r_ssa.cpp +++ b/src/input/r_ssa.cpp @@ -228,7 +228,8 @@ ssa_reader_c::recode_text(vector &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; diff --git a/src/input/r_ssa.h b/src/input/r_ssa.h index 0d1a5667f..b8b4c63b4 100644 --- a/src/input/r_ssa.h +++ b/src/input/r_ssa.h @@ -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); diff --git a/src/input/r_tta.cpp b/src/input/r_tta.cpp index 5b04b9c21..061bde953 100644 --- a/src/input/r_tta.cpp +++ b/src/input/r_tta.cpp @@ -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; diff --git a/src/input/r_tta.h b/src/input/r_tta.h index ec8cedf6a..1871d09c0 100644 --- a/src/input/r_tta.h +++ b/src/input/r_tta.h @@ -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(); diff --git a/src/input/r_vobsub.cpp b/src/input/r_vobsub.cpp index 27b4610b7..de2b35b24 100644 --- a/src/input/r_vobsub.cpp +++ b/src/input/r_vobsub.cpp @@ -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; diff --git a/src/input/r_vobsub.h b/src/input/r_vobsub.h index c4094f051..0c6a6d2b4 100644 --- a/src/input/r_vobsub.h +++ b/src/input/r_vobsub.h @@ -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); diff --git a/src/input/r_wav.cpp b/src/input/r_wav.cpp index 604ccbb25..328190ad6 100644 --- a/src/input/r_wav.cpp +++ b/src/input/r_wav.cpp @@ -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; diff --git a/src/input/r_wav.h b/src/input/r_wav.h index 794edd9fd..e2502f312 100644 --- a/src/input/r_wav.h +++ b/src/input/r_wav.h @@ -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); diff --git a/src/pr_generic.cpp b/src/pr_generic.cpp index d014187e4..fe108784f 100644 --- a/src/pr_generic.cpp +++ b/src/pr_generic.cpp @@ -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) { diff --git a/src/pr_generic.h b/src/pr_generic.h index 714dde446..174761426 100644 --- a/src/pr_generic.h +++ b/src/pr_generic.h @@ -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();