mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-23 19:31:44 +00:00
Do not use a global variable for passing the information about which elements to extract to functions.
This commit is contained in:
parent
ed9d1df852
commit
01005098ca
@ -73,7 +73,8 @@ using namespace libmatroska;
|
||||
using namespace std;
|
||||
|
||||
static void
|
||||
handle_attachments(KaxAttachments *atts) {
|
||||
handle_attachments(KaxAttachments *atts,
|
||||
vector<track_spec_t> &tracks) {
|
||||
KaxAttached *att;
|
||||
KaxFileData *fdata;
|
||||
EbmlElement *e;
|
||||
@ -146,6 +147,7 @@ handle_attachments(KaxAttachments *atts) {
|
||||
|
||||
void
|
||||
extract_attachments(const char *file_name,
|
||||
vector<track_spec_t> &tracks,
|
||||
bool parse_fully) {
|
||||
mm_io_c *in;
|
||||
mm_stdio_c out;
|
||||
@ -169,7 +171,7 @@ extract_attachments(const char *file_name,
|
||||
if (verbose > 0)
|
||||
debug_dump_elements(attachments, 0);
|
||||
|
||||
handle_attachments(attachments);
|
||||
handle_attachments(attachments, tracks);
|
||||
|
||||
delete attachments;
|
||||
}
|
||||
|
@ -76,7 +76,6 @@ using namespace std;
|
||||
#define MODE_CHAPTERS 3
|
||||
#define MODE_CUESHEET 4
|
||||
|
||||
vector<track_spec_t> tracks;
|
||||
bool no_variable_data = false;
|
||||
|
||||
void
|
||||
@ -150,7 +149,8 @@ static bool parse_fully = false;
|
||||
void
|
||||
parse_args(vector<string> args,
|
||||
string &file_name,
|
||||
int &mode) {
|
||||
int &mode,
|
||||
vector<track_spec_t> &tracks) {
|
||||
int i;
|
||||
char *colon, *copy;
|
||||
const char *sub_charset;
|
||||
@ -365,6 +365,7 @@ main(int argc,
|
||||
char **argv) {
|
||||
string input_file;
|
||||
int mode;
|
||||
vector<track_spec_t> tracks;
|
||||
|
||||
#if defined(SYS_UNIX)
|
||||
nice(2);
|
||||
@ -383,9 +384,9 @@ main(int argc,
|
||||
|
||||
xml_element_map_init();
|
||||
|
||||
parse_args(command_line_utf8(argc, argv), input_file, mode);
|
||||
parse_args(command_line_utf8(argc, argv), input_file, mode, tracks);
|
||||
if (mode == MODE_TRACKS) {
|
||||
extract_tracks(input_file.c_str());
|
||||
extract_tracks(input_file.c_str(), tracks);
|
||||
|
||||
if (verbose == 0)
|
||||
mxinfo(_("progress: 100%%\n"));
|
||||
@ -394,7 +395,7 @@ main(int argc,
|
||||
extract_tags(input_file.c_str(), parse_fully);
|
||||
|
||||
else if (mode == MODE_ATTACHMENTS)
|
||||
extract_attachments(input_file.c_str(), parse_fully);
|
||||
extract_attachments(input_file.c_str(), tracks, parse_fully);
|
||||
|
||||
else if (mode == MODE_CHAPTERS)
|
||||
extract_chapters(input_file.c_str(), chapter_format_simple, parse_fully);
|
||||
|
@ -46,7 +46,6 @@ struct track_spec_t {
|
||||
bool done;
|
||||
};
|
||||
|
||||
extern vector<track_spec_t> tracks;
|
||||
extern bool no_variable_data;
|
||||
|
||||
#define fits_parent(l, p) (l->GetElementPosition() < \
|
||||
@ -59,11 +58,12 @@ extern bool no_variable_data;
|
||||
void show_element(EbmlElement *l, int level, const char *fmt, ...);
|
||||
void show_error(const char *fmt, ...);
|
||||
|
||||
bool extract_tracks(const char *file_name);
|
||||
bool extract_tracks(const char *file_name, vector<track_spec_t> &tracks);
|
||||
void extract_tags(const char *file_name, bool parse_fully);
|
||||
void extract_chapters(const char *file_name, bool chapter_format_simple,
|
||||
bool parse_fully);
|
||||
void extract_attachments(const char *file_name, bool parse_fully);
|
||||
void extract_attachments(const char *file_name,
|
||||
vector<track_spec_t> &tracks, bool parse_fully);
|
||||
void extract_cuesheet(const char *file_name, bool parse_fully);
|
||||
void write_cuesheet(const char *file_name, KaxChapters &chapters,
|
||||
KaxTags &tags, int64_t tuid, mm_io_c &out);
|
||||
|
@ -66,7 +66,8 @@ static vector<xtr_base_c *> extractors;
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
static void
|
||||
create_extractors(KaxTracks &kax_tracks) {
|
||||
create_extractors(KaxTracks &kax_tracks,
|
||||
vector<track_spec_t> &tracks) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < kax_tracks.ListSize(); i++) {
|
||||
@ -219,7 +220,8 @@ close_extractors() {
|
||||
|
||||
static void
|
||||
write_all_cuesheets(KaxChapters &chapters,
|
||||
KaxTags &tags) {
|
||||
KaxTags &tags,
|
||||
vector<track_spec_t> &tracks) {
|
||||
int i;
|
||||
mm_io_c *out;
|
||||
|
||||
@ -261,7 +263,8 @@ write_all_cuesheets(KaxChapters &chapters,
|
||||
}
|
||||
|
||||
bool
|
||||
extract_tracks(const char *file_name) {
|
||||
extract_tracks(const char *file_name,
|
||||
vector<track_spec_t> &tracks) {
|
||||
int upper_lvl_el;
|
||||
// Elements for different levels
|
||||
EbmlElement *l0 = NULL, *l1 = NULL, *l2 = NULL, *l3 = NULL;
|
||||
@ -373,7 +376,7 @@ extract_tracks(const char *file_name) {
|
||||
|
||||
tracks_found = true;
|
||||
l1->Read(*es, KaxTracks::ClassInfos.Context, upper_lvl_el, l2, true);
|
||||
create_extractors(*dynamic_cast<KaxTracks *>(l1));
|
||||
create_extractors(*dynamic_cast<KaxTracks *>(l1), tracks);
|
||||
|
||||
} else if (EbmlId(*l1) == KaxCluster::ClassInfos.GlobalId) {
|
||||
show_element(l1, 1, _("Cluster"));
|
||||
@ -494,7 +497,7 @@ extract_tracks(const char *file_name) {
|
||||
delete es;
|
||||
delete in;
|
||||
|
||||
write_all_cuesheets(all_chapters, all_tags);
|
||||
write_all_cuesheets(all_chapters, all_tags, tracks);
|
||||
|
||||
// Now just close the files and go to sleep. Mummy will sing you a
|
||||
// lullaby. Just close your eyes, listen to her sweet voice, singing,
|
||||
|
Loading…
Reference in New Issue
Block a user