From 2a1f1d790262d2fd7f765cd06e5e795a96087eef Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sat, 26 Apr 2003 11:26:15 +0000 Subject: [PATCH] Support for the mandatory KaxTrackUID. Cosmetics. --- mkvinfo.cpp | 27 ++++++++++++++++++++++++--- pr_generic.cpp | 6 +++++- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/mkvinfo.cpp b/mkvinfo.cpp index ac4bd67da..10bdc5333 100644 --- a/mkvinfo.cpp +++ b/mkvinfo.cpp @@ -12,7 +12,7 @@ /*! \file - \version \$Id: mkvinfo.cpp,v 1.22 2003/04/26 11:07:19 mosu Exp $ + \version \$Id: mkvinfo.cpp,v 1.23 2003/04/26 11:26:15 mosu Exp $ \brief retrieves and displays information about a Matroska file \author Moritz Bunkus */ @@ -72,7 +72,7 @@ using namespace LIBMATROSKA_NAMESPACE; typedef struct track_t { - int tnum; + unsigned int tnum, tuid; char type; int64_t size; } track_t; @@ -99,6 +99,16 @@ track_t *find_track(int tnum) { return NULL; } +track_t *find_track_by_uid(int tuid) { + int i; + + for (i = 0; i < num_tracks; i++) + if (tracks[i]->tuid == tuid) + return tracks[i]; + + return NULL; +} + void usage() { fprintf(stdout, "Usage: mkvinfo [options] inname\n\n" @@ -283,7 +293,7 @@ void process_file() { if (EbmlId(*l3) == KaxTrackNumber::ClassInfos.GlobalId) { KaxTrackNumber &tnum = *static_cast(l3); tnum.ReadData(es->I_O()); - fprintf(stdout, "(%s) | + Track number %d", NAME, + fprintf(stdout, "(%s) | + Track number: %u", NAME, uint8(tnum)); if (verbose > 1) fprintf(stdout, " at %llu", l3->GetElementPosition()); @@ -293,6 +303,17 @@ void process_file() { "track with the number %u.\n", NAME, uint8(tnum)); + } else if (EbmlId(*l3) == KaxTrackUID::ClassInfos.GlobalId) { + KaxTrackUID &tuid = *static_cast(l3); + tuid.ReadData(es->I_O()); + fprintf(stdout, "(%s) | + Track UID: %u", NAME, uint8(tuid)); + if (verbose > 1) + fprintf(stdout, " at %llu", l3->GetElementPosition()); + fprintf(stdout, "\n"); + if (find_track_by_uid(uint8(tuid)) != NULL) + fprintf(stdout, "(%s) | + Warning: There's more than one " + "track with the UID %u.\n", NAME, uint8(tuid)); + } else if (EbmlId(*l3) == KaxTrackType::ClassInfos.GlobalId) { KaxTrackType &ttype = *static_cast(l3); ttype.ReadData(es->I_O()); diff --git a/pr_generic.cpp b/pr_generic.cpp index 7ec7c9da7..1849aeac8 100644 --- a/pr_generic.cpp +++ b/pr_generic.cpp @@ -13,7 +13,7 @@ /*! \file - \version \$Id: pr_generic.cpp,v 1.24 2003/04/21 08:29:50 mosu Exp $ + \version \$Id: pr_generic.cpp,v 1.25 2003/04/26 11:26:15 mosu Exp $ \brief functions common for all readers/packetizers \author Moritz Bunkus */ @@ -187,6 +187,10 @@ void generic_packetizer_c::set_header() { KaxTrackNumber &tnumber = GetChild(static_cast(*track_entry)); *(static_cast(&tnumber)) = hserialno; + + KaxTrackUID &tuid = + GetChild(static_cast(*track_entry)); + *(static_cast(&tuid)) = hserialno; } if (htrack_type != -1)