blob: f285c3e50a756025bf57cb86c2e46482d9fcb79b [file] [log] [blame]
Tom Finegan5c14a3f2014-01-23 10:57:06 -08001// Copyright (c) 2010 The WebM project authors. All Rights Reserved.
2//
3// Use of this source code is governed by a BSD-style license
4// that can be found in the LICENSE file in the root of the source
5// tree. An additional intellectual property rights grant can be found
6// in the file PATENTS. All contributing project authors may
7// be found in the AUTHORS file in the root of the source tree.
8//
9// This sample application demonstrates how to use the Matroska parser
10// library, which allows clients to handle a Matroska format file.
Tom Finegane020ffd2016-03-09 13:55:40 -080011#include <cstdio>
12#include <cstdlib>
Tom Finegan5c14a3f2014-01-23 10:57:06 -080013#include <memory>
Tom Finegane020ffd2016-03-09 13:55:40 -080014#include <new>
Tom Finegan5c14a3f2014-01-23 10:57:06 -080015
Tom Finegan504e0f22016-03-21 11:20:48 -070016#include "mkvparser/mkvparser.h"
17#include "mkvparser/mkvreader.h"
Tom Finegan5c14a3f2014-01-23 10:57:06 -080018
Tom Finegan99981ee2016-02-12 09:19:37 -080019namespace {
20const wchar_t* utf8towcs(const char* str) {
Tom Finegan5440f202014-01-23 15:19:32 -080021 if (str == NULL)
22 return NULL;
Tom Finegan5c14a3f2014-01-23 10:57:06 -080023
24 // TODO: this probably requires that the locale be
25 // configured somehow:
26
27 const size_t size = mbstowcs(NULL, str, 0);
28
James Zern82b7e5f2015-08-14 10:57:48 -070029 if (size == 0 || size == static_cast<size_t>(-1))
Tom Finegan5c14a3f2014-01-23 10:57:06 -080030 return NULL;
31
James Zern04d78092015-08-13 23:06:41 -070032 wchar_t* const val = new (std::nothrow) wchar_t[size + 1];
33 if (val == NULL)
34 return NULL;
Tom Finegan5c14a3f2014-01-23 10:57:06 -080035
36 mbstowcs(val, str, size);
37 val[size] = L'\0';
38
39 return val;
40}
41
Tom Finegancbe5c402016-03-21 12:16:30 -070042bool InputHasCues(const mkvparser::Segment* const segment) {
43 const mkvparser::Cues* const cues = segment->GetCues();
Tom Finegan5440f202014-01-23 15:19:32 -080044 if (cues == NULL)
45 return false;
46
47 while (!cues->DoneParsing())
48 cues->LoadCuePoint();
49
Tom Finegancbe5c402016-03-21 12:16:30 -070050 const mkvparser::CuePoint* const cue_point = cues->GetFirst();
Tom Finegan5440f202014-01-23 15:19:32 -080051 if (cue_point == NULL)
52 return false;
53
54 return true;
55}
56
Tom Finegan99981ee2016-02-12 09:19:37 -080057bool MasteringMetadataValuePresent(double value) {
Tom Finegancbe5c402016-03-21 12:16:30 -070058 return value != mkvparser::MasteringMetadata::kValueNotPresent;
Tom Finegan99981ee2016-02-12 09:19:37 -080059}
60
61bool ColourValuePresent(long long value) {
Tom Finegancbe5c402016-03-21 12:16:30 -070062 return value != mkvparser::Colour::kValueNotPresent;
Tom Finegan99981ee2016-02-12 09:19:37 -080063}
64} // namespace
65
Tom Finegan5c14a3f2014-01-23 10:57:06 -080066int main(int argc, char* argv[]) {
67 if (argc == 1) {
Tom Finegan0ba80bc2016-03-29 09:02:52 -070068 printf("Mkv Parser Sample Application\n");
69 printf(" Usage: %s <input file> \n", argv[0]);
70 return EXIT_FAILURE;
Tom Finegan5c14a3f2014-01-23 10:57:06 -080071 }
72
Tom Finegancbe5c402016-03-21 12:16:30 -070073 mkvparser::MkvReader reader;
Tom Finegan5c14a3f2014-01-23 10:57:06 -080074
75 if (reader.Open(argv[1])) {
76 printf("\n Filename is invalid or error while opening.\n");
Tom Finegan0ba80bc2016-03-29 09:02:52 -070077 return EXIT_FAILURE;
Tom Finegan5c14a3f2014-01-23 10:57:06 -080078 }
79
80 int maj, min, build, rev;
81
Tom Finegancbe5c402016-03-21 12:16:30 -070082 mkvparser::GetVersion(maj, min, build, rev);
Tom Finegan58711e82016-08-24 12:03:08 -070083 printf("\t\t libwebm version: %d.%d.%d.%d\n", maj, min, build, rev);
Tom Finegan5c14a3f2014-01-23 10:57:06 -080084
85 long long pos = 0;
86
Tom Finegancbe5c402016-03-21 12:16:30 -070087 mkvparser::EBMLHeader ebmlHeader;
Tom Finegan5c14a3f2014-01-23 10:57:06 -080088
Tom Finegan714f3c42015-09-04 10:18:20 -070089 long long ret = ebmlHeader.Parse(&reader, pos);
90 if (ret < 0) {
91 printf("\n EBMLHeader::Parse() failed.");
Tom Finegan0ba80bc2016-03-29 09:02:52 -070092 return EXIT_FAILURE;
Tom Finegan714f3c42015-09-04 10:18:20 -070093 }
Tom Finegan5c14a3f2014-01-23 10:57:06 -080094
95 printf("\t\t\t EBML Header\n");
96 printf("\t\tEBML Version\t\t: %lld\n", ebmlHeader.m_version);
97 printf("\t\tEBML MaxIDLength\t: %lld\n", ebmlHeader.m_maxIdLength);
98 printf("\t\tEBML MaxSizeLength\t: %lld\n", ebmlHeader.m_maxSizeLength);
99 printf("\t\tDoc Type\t\t: %s\n", ebmlHeader.m_docType);
100 printf("\t\tPos\t\t\t: %lld\n", pos);
101
Tom Finegancbe5c402016-03-21 12:16:30 -0700102 typedef mkvparser::Segment seg_t;
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800103 seg_t* pSegment_;
104
Tom Finegan714f3c42015-09-04 10:18:20 -0700105 ret = seg_t::CreateInstance(&reader, pos, pSegment_);
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800106 if (ret) {
107 printf("\n Segment::CreateInstance() failed.");
Tom Finegan0ba80bc2016-03-29 09:02:52 -0700108 return EXIT_FAILURE;
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800109 }
110
Lisa Veldend707c672018-01-22 11:41:20 +0100111 const std::unique_ptr<seg_t> pSegment(pSegment_);
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800112
113 ret = pSegment->Load();
114 if (ret < 0) {
115 printf("\n Segment::Load() failed.");
Tom Finegan0ba80bc2016-03-29 09:02:52 -0700116 return EXIT_FAILURE;
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800117 }
118
Tom Finegancbe5c402016-03-21 12:16:30 -0700119 const mkvparser::SegmentInfo* const pSegmentInfo = pSegment->GetInfo();
James Zernd9bdade2015-08-21 16:56:32 -0700120 if (pSegmentInfo == NULL) {
121 printf("\n Segment::GetInfo() failed.");
Tom Finegan0ba80bc2016-03-29 09:02:52 -0700122 return EXIT_FAILURE;
James Zernd9bdade2015-08-21 16:56:32 -0700123 }
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800124
125 const long long timeCodeScale = pSegmentInfo->GetTimeCodeScale();
126 const long long duration_ns = pSegmentInfo->GetDuration();
127
128 const char* const pTitle_ = pSegmentInfo->GetTitleAsUTF8();
129 const wchar_t* const pTitle = utf8towcs(pTitle_);
130
131 const char* const pMuxingApp_ = pSegmentInfo->GetMuxingAppAsUTF8();
132 const wchar_t* const pMuxingApp = utf8towcs(pMuxingApp_);
133
134 const char* const pWritingApp_ = pSegmentInfo->GetWritingAppAsUTF8();
135 const wchar_t* const pWritingApp = utf8towcs(pWritingApp_);
136
137 printf("\n");
138 printf("\t\t\t Segment Info\n");
139 printf("\t\tTimeCodeScale\t\t: %lld \n", timeCodeScale);
140 printf("\t\tDuration\t\t: %lld\n", duration_ns);
141
142 const double duration_sec = double(duration_ns) / 1000000000;
143 printf("\t\tDuration(secs)\t\t: %7.3lf\n", duration_sec);
144
145 if (pTitle == NULL)
146 printf("\t\tTrack Name\t\t: NULL\n");
147 else {
148 printf("\t\tTrack Name\t\t: %ls\n", pTitle);
149 delete[] pTitle;
150 }
151
152 if (pMuxingApp == NULL)
153 printf("\t\tMuxing App\t\t: NULL\n");
154 else {
155 printf("\t\tMuxing App\t\t: %ls\n", pMuxingApp);
156 delete[] pMuxingApp;
157 }
158
159 if (pWritingApp == NULL)
160 printf("\t\tWriting App\t\t: NULL\n");
161 else {
162 printf("\t\tWriting App\t\t: %ls\n", pWritingApp);
163 delete[] pWritingApp;
164 }
165
166 // pos of segment payload
167 printf("\t\tPosition(Segment)\t: %lld\n", pSegment->m_start);
168
169 // size of segment payload
170 printf("\t\tSize(Segment)\t\t: %lld\n", pSegment->m_size);
171
Tom Finegancbe5c402016-03-21 12:16:30 -0700172 const mkvparser::Tracks* pTracks = pSegment->GetTracks();
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800173
Tom Finegan5440f202014-01-23 15:19:32 -0800174 unsigned long track_num = 0;
175 const unsigned long num_tracks = pTracks->GetTracksCount();
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800176
177 printf("\n\t\t\t Track Info\n");
178
Tom Finegan5440f202014-01-23 15:19:32 -0800179 while (track_num != num_tracks) {
Tom Finegancbe5c402016-03-21 12:16:30 -0700180 const mkvparser::Track* const pTrack =
Tom Finegane64bf752016-03-18 09:32:52 -0700181 pTracks->GetTrackByIndex(track_num++);
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800182
Vignesh Venkatasubramanian867f1892014-04-14 12:05:21 -0700183 if (pTrack == NULL)
184 continue;
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800185
186 const long trackType = pTrack->GetType();
187 const long trackNumber = pTrack->GetNumber();
188 const unsigned long long trackUid = pTrack->GetUid();
189 const wchar_t* const pTrackName = utf8towcs(pTrack->GetNameAsUTF8());
190
191 printf("\t\tTrack Type\t\t: %ld\n", trackType);
192 printf("\t\tTrack Number\t\t: %ld\n", trackNumber);
193 printf("\t\tTrack Uid\t\t: %lld\n", trackUid);
194
195 if (pTrackName == NULL)
196 printf("\t\tTrack Name\t\t: NULL\n");
197 else {
198 printf("\t\tTrack Name\t\t: %ls \n", pTrackName);
199 delete[] pTrackName;
200 }
201
202 const char* const pCodecId = pTrack->GetCodecId();
203
204 if (pCodecId == NULL)
205 printf("\t\tCodec Id\t\t: NULL\n");
206 else
207 printf("\t\tCodec Id\t\t: %s\n", pCodecId);
208
Tom Fineganfa182de2016-08-26 21:06:51 -0700209 size_t codec_private_size = 0;
210 if (pTrack->GetCodecPrivate(codec_private_size)) {
211 printf("\t\tCodec private length: %u bytes\n",
212 static_cast<unsigned int>(codec_private_size));
213 }
214
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800215 const char* const pCodecName_ = pTrack->GetCodecNameAsUTF8();
216 const wchar_t* const pCodecName = utf8towcs(pCodecName_);
217
218 if (pCodecName == NULL)
219 printf("\t\tCodec Name\t\t: NULL\n");
220 else {
221 printf("\t\tCodec Name\t\t: %ls\n", pCodecName);
222 delete[] pCodecName;
223 }
224
Tom Finegancbe5c402016-03-21 12:16:30 -0700225 if (trackType == mkvparser::Track::kVideo) {
226 const mkvparser::VideoTrack* const pVideoTrack =
227 static_cast<const mkvparser::VideoTrack*>(pTrack);
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800228
229 const long long width = pVideoTrack->GetWidth();
230 printf("\t\tVideo Width\t\t: %lld\n", width);
231
232 const long long height = pVideoTrack->GetHeight();
233 printf("\t\tVideo Height\t\t: %lld\n", height);
234
235 const double rate = pVideoTrack->GetFrameRate();
236 printf("\t\tVideo Rate\t\t: %f\n", rate);
Tom Finegan99981ee2016-02-12 09:19:37 -0800237
Tom Finegancbe5c402016-03-21 12:16:30 -0700238 const mkvparser::Colour* const colour = pVideoTrack->GetColour();
Tom Finegan99981ee2016-02-12 09:19:37 -0800239 if (colour) {
240 printf("\t\tVideo Colour:\n");
Tom Fineganf2fc28e2016-02-18 10:08:11 -0800241 if (ColourValuePresent(colour->matrix_coefficients))
242 printf("\t\t\tMatrixCoefficients: %lld\n",
243 colour->matrix_coefficients);
Tom Finegan99981ee2016-02-12 09:19:37 -0800244 if (ColourValuePresent(colour->bits_per_channel))
245 printf("\t\t\tBitsPerChannel: %lld\n", colour->bits_per_channel);
Tom Finegand7fc3822016-02-12 11:28:30 -0800246 if (ColourValuePresent(colour->chroma_subsampling_horz))
247 printf("\t\t\tChromaSubsamplingHorz: %lld\n",
248 colour->chroma_subsampling_horz);
249 if (ColourValuePresent(colour->chroma_subsampling_vert))
250 printf("\t\t\tChromaSubsamplingVert: %lld\n",
251 colour->chroma_subsampling_vert);
252 if (ColourValuePresent(colour->cb_subsampling_horz))
253 printf("\t\t\tCbSubsamplingHorz: %lld\n",
254 colour->cb_subsampling_horz);
255 if (ColourValuePresent(colour->cb_subsampling_vert))
256 printf("\t\t\tCbSubsamplingVert: %lld\n",
257 colour->cb_subsampling_vert);
Tom Finegan99981ee2016-02-12 09:19:37 -0800258 if (ColourValuePresent(colour->chroma_siting_horz))
259 printf("\t\t\tChromaSitingHorz: %lld\n", colour->chroma_siting_horz);
260 if (ColourValuePresent(colour->chroma_siting_vert))
261 printf("\t\t\tChromaSitingVert: %lld\n", colour->chroma_siting_vert);
262 if (ColourValuePresent(colour->range))
263 printf("\t\t\tRange: %lld\n", colour->range);
Tom Finegan2d091282016-02-18 12:02:18 -0800264 if (ColourValuePresent(colour->transfer_characteristics))
265 printf("\t\t\tTransferCharacteristics: %lld\n",
266 colour->transfer_characteristics);
Tom Finegan99981ee2016-02-12 09:19:37 -0800267 if (ColourValuePresent(colour->primaries))
268 printf("\t\t\tPrimaries: %lld\n", colour->primaries);
269 if (ColourValuePresent(colour->max_cll))
270 printf("\t\t\tMaxCLL: %lld\n", colour->max_cll);
271 if (ColourValuePresent(colour->max_fall))
272 printf("\t\t\tMaxFALL: %lld\n", colour->max_fall);
273 if (colour->mastering_metadata) {
Tom Finegancbe5c402016-03-21 12:16:30 -0700274 const mkvparser::MasteringMetadata* const mm =
Tom Finegan99981ee2016-02-12 09:19:37 -0800275 colour->mastering_metadata;
276 printf("\t\t\tMastering Metadata:\n");
277 if (MasteringMetadataValuePresent(mm->luminance_max))
278 printf("\t\t\t\tLuminanceMax: %f\n", mm->luminance_max);
279 if (MasteringMetadataValuePresent(mm->luminance_min))
280 printf("\t\t\t\tLuminanceMin: %f\n", mm->luminance_min);
281 if (mm->r) {
282 printf("\t\t\t\t\tPrimaryRChromaticityX: %f\n", mm->r->x);
283 printf("\t\t\t\t\tPrimaryRChromaticityY: %f\n", mm->r->y);
284 }
285 if (mm->g) {
286 printf("\t\t\t\t\tPrimaryGChromaticityX: %f\n", mm->g->x);
287 printf("\t\t\t\t\tPrimaryGChromaticityY: %f\n", mm->g->y);
288 }
289 if (mm->b) {
290 printf("\t\t\t\t\tPrimaryBChromaticityX: %f\n", mm->b->x);
291 printf("\t\t\t\t\tPrimaryBChromaticityY: %f\n", mm->b->y);
292 }
293 if (mm->white_point) {
294 printf("\t\t\t\t\tWhitePointChromaticityX: %f\n",
295 mm->white_point->x);
296 printf("\t\t\t\t\tWhitePointChromaticityY: %f\n",
297 mm->white_point->y);
298 }
299 }
300 }
Tom Finegan9a3f2b52016-08-26 21:07:06 -0700301
302 const mkvparser::Projection* const projection =
303 pVideoTrack->GetProjection();
304 if (projection) {
305 printf("\t\tVideo Projection:\n");
306 if (projection->type != mkvparser::Projection::kTypeNotPresent)
307 printf("\t\t\tProjectionType: %d\n",
308 static_cast<int>(projection->type));
309 if (projection->private_data) {
310 printf("\t\t\tProjectionPrivate: %u bytes\n",
311 static_cast<unsigned int>(projection->private_data_length));
312 }
313 if (projection->pose_yaw != mkvparser::Projection::kValueNotPresent)
314 printf("\t\t\tProjectionPoseYaw: %f\n", projection->pose_yaw);
315 if (projection->pose_pitch != mkvparser::Projection::kValueNotPresent)
316 printf("\t\t\tProjectionPosePitch: %f\n", projection->pose_pitch);
317 if (projection->pose_roll != mkvparser::Projection::kValueNotPresent)
318 printf("\t\t\tProjectionPosePitch: %f\n", projection->pose_roll);
319 }
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800320 }
321
Tom Finegancbe5c402016-03-21 12:16:30 -0700322 if (trackType == mkvparser::Track::kAudio) {
323 const mkvparser::AudioTrack* const pAudioTrack =
324 static_cast<const mkvparser::AudioTrack*>(pTrack);
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800325
326 const long long channels = pAudioTrack->GetChannels();
327 printf("\t\tAudio Channels\t\t: %lld\n", channels);
328
329 const long long bitDepth = pAudioTrack->GetBitDepth();
330 printf("\t\tAudio BitDepth\t\t: %lld\n", bitDepth);
331
332 const double sampleRate = pAudioTrack->GetSamplingRate();
333 printf("\t\tAddio Sample Rate\t: %.3f\n", sampleRate);
334
335 const long long codecDelay = pAudioTrack->GetCodecDelay();
336 printf("\t\tAudio Codec Delay\t\t: %lld\n", codecDelay);
337
338 const long long seekPreRoll = pAudioTrack->GetSeekPreRoll();
339 printf("\t\tAudio Seek Pre Roll\t\t: %lld\n", seekPreRoll);
340 }
341 }
342
343 printf("\n\n\t\t\t Cluster Info\n");
344 const unsigned long clusterCount = pSegment->GetCount();
345
346 printf("\t\tCluster Count\t: %ld\n\n", clusterCount);
347
348 if (clusterCount == 0) {
349 printf("\t\tSegment has no clusters.\n");
Tom Finegan0ba80bc2016-03-29 09:02:52 -0700350 return EXIT_FAILURE;
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800351 }
352
Tom Finegancbe5c402016-03-21 12:16:30 -0700353 const mkvparser::Cluster* pCluster = pSegment->GetFirst();
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800354
Vignesh Venkatasubramanian5d91edf2016-05-13 10:41:16 -0700355 while (pCluster != NULL && !pCluster->EOS()) {
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800356 const long long timeCode = pCluster->GetTimeCode();
357 printf("\t\tCluster Time Code\t: %lld\n", timeCode);
358
359 const long long time_ns = pCluster->GetTime();
360 printf("\t\tCluster Time (ns)\t: %lld\n", time_ns);
361
Tom Finegancbe5c402016-03-21 12:16:30 -0700362 const mkvparser::BlockEntry* pBlockEntry;
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800363
364 long status = pCluster->GetFirst(pBlockEntry);
365
366 if (status < 0) // error
367 {
368 printf("\t\tError parsing first block of cluster\n");
369 fflush(stdout);
Tom Finegan0ba80bc2016-03-29 09:02:52 -0700370 return EXIT_FAILURE;
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800371 }
372
Vignesh Venkatasubramanian5d91edf2016-05-13 10:41:16 -0700373 while (pBlockEntry != NULL && !pBlockEntry->EOS()) {
Tom Finegancbe5c402016-03-21 12:16:30 -0700374 const mkvparser::Block* const pBlock = pBlockEntry->GetBlock();
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800375 const long long trackNum = pBlock->GetTrackNumber();
376 const unsigned long tn = static_cast<unsigned long>(trackNum);
Tom Finegancbe5c402016-03-21 12:16:30 -0700377 const mkvparser::Track* const pTrack = pTracks->GetTrackByNumber(tn);
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800378
379 if (pTrack == NULL)
380 printf("\t\t\tBlock\t\t:UNKNOWN TRACK TYPE\n");
381 else {
382 const long long trackType = pTrack->GetType();
383 const int frameCount = pBlock->GetFrameCount();
384 const long long time_ns = pBlock->GetTime(pCluster);
385 const long long discard_padding = pBlock->GetDiscardPadding();
386
387 printf("\t\t\tBlock\t\t:%s,%s,%15lld,%lld\n",
Tom Finegancbe5c402016-03-21 12:16:30 -0700388 (trackType == mkvparser::Track::kVideo) ? "V" : "A",
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800389 pBlock->IsKey() ? "I" : "P", time_ns, discard_padding);
390
391 for (int i = 0; i < frameCount; ++i) {
Tom Finegancbe5c402016-03-21 12:16:30 -0700392 const mkvparser::Block::Frame& theFrame = pBlock->GetFrame(i);
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800393 const long size = theFrame.len;
394 const long long offset = theFrame.pos;
395 printf("\t\t\t %15ld,%15llx\n", size, offset);
396 }
397 }
398
399 status = pCluster->GetNext(pBlockEntry, pBlockEntry);
400
401 if (status < 0) {
402 printf("\t\t\tError parsing next block of cluster\n");
403 fflush(stdout);
Tom Finegan0ba80bc2016-03-29 09:02:52 -0700404 return EXIT_FAILURE;
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800405 }
406 }
407
408 pCluster = pSegment->GetNext(pCluster);
409 }
410
Tom Finegan5440f202014-01-23 15:19:32 -0800411 if (InputHasCues(pSegment.get())) {
412 // Walk them.
Tom Finegancbe5c402016-03-21 12:16:30 -0700413 const mkvparser::Cues* const cues = pSegment->GetCues();
414 const mkvparser::CuePoint* cue = cues->GetFirst();
Tom Finegan5440f202014-01-23 15:19:32 -0800415 int cue_point_num = 1;
416
417 printf("\t\tCues\n");
418 do {
Leonel Togniollid3a44cd2015-04-09 03:48:38 +0100419 for (track_num = 0; track_num < num_tracks; ++track_num) {
Tom Finegancbe5c402016-03-21 12:16:30 -0700420 const mkvparser::Track* const track =
Leonel Togniollid3a44cd2015-04-09 03:48:38 +0100421 pTracks->GetTrackByIndex(track_num);
Tom Finegancbe5c402016-03-21 12:16:30 -0700422 const mkvparser::CuePoint::TrackPosition* const track_pos =
Tom Finegan5440f202014-01-23 15:19:32 -0800423 cue->Find(track);
424
425 if (track_pos != NULL) {
426 const char track_type =
Tom Finegancbe5c402016-03-21 12:16:30 -0700427 (track->GetType() == mkvparser::Track::kVideo) ? 'V' : 'A';
Vignesh Venkatasubramanian867f1892014-04-14 12:05:21 -0700428 printf(
429 "\t\t\tCue Point %4d Track %3lu(%c) Time %14lld "
430 "Block %4lld Pos %8llx\n",
Leonel Togniollid3a44cd2015-04-09 03:48:38 +0100431 cue_point_num, track->GetNumber(), track_type,
Vignesh Venkatasubramanian867f1892014-04-14 12:05:21 -0700432 cue->GetTime(pSegment.get()), track_pos->m_block,
433 track_pos->m_pos);
Tom Finegan5440f202014-01-23 15:19:32 -0800434 }
435 }
436
437 cue = cues->GetNext(cue);
438 ++cue_point_num;
439 } while (cue != NULL);
440 }
441
Tom Finegancbe5c402016-03-21 12:16:30 -0700442 const mkvparser::Tags* const tags = pSegment->GetTags();
Francisco Facionib6de61a2015-07-14 14:18:09 -0300443 if (tags && tags->GetTagCount() > 0) {
444 printf("\t\tTags\n");
445 for (int i = 0; i < tags->GetTagCount(); ++i) {
Tom Finegancbe5c402016-03-21 12:16:30 -0700446 const mkvparser::Tags::Tag* const tag = tags->GetTag(i);
Francisco Facionib6de61a2015-07-14 14:18:09 -0300447 printf("\t\t\tTag\n");
448 for (int j = 0; j < tag->GetSimpleTagCount(); j++) {
Tom Finegancbe5c402016-03-21 12:16:30 -0700449 const mkvparser::Tags::SimpleTag* const simple_tag =
Francisco Facionib6de61a2015-07-14 14:18:09 -0300450 tag->GetSimpleTag(j);
451 printf("\t\t\t\tSimple Tag \"%s\" Value \"%s\"\n",
452 simple_tag->GetTagName(), simple_tag->GetTagString());
453 }
454 }
455 }
456
Tom Finegan5c14a3f2014-01-23 10:57:06 -0800457 fflush(stdout);
Tom Finegan0ba80bc2016-03-29 09:02:52 -0700458 return EXIT_SUCCESS;
James Zern04d78092015-08-13 23:06:41 -0700459}