This source file includes following definitions.
- process_samples_from_track
- main
#include <gpac/tools.h>
#include <gpac/isomedia.h>
static void process_samples_from_track(GF_ISOFile *movie, u32 track_id, u32 *sample_index)
{
u32 track_number;
u32 sample_count;
GF_Err e;
u64 missing_bytes;
track_number = gf_isom_get_track_by_id(movie, track_id);
if (track_number == 0) {
fprintf(stdout, "Could not find track ID=%u. Ignore segment.\n", track_id);
return;
}
sample_count = gf_isom_get_sample_count(movie, track_number);
while (*sample_index <= sample_count) {
GF_ISOSample *iso_sample;
u32 sample_description_index;
iso_sample = gf_isom_get_sample(movie, track_number, *sample_index, &sample_description_index);
if (iso_sample) {
fprintf(stdout, "Found sample #%5d/%5d of length %8d, RAP: %d, DTS: "LLD", CTS: "LLD"\n", *sample_index, sample_count, iso_sample->dataLength, iso_sample->IsRAP, iso_sample->DTS, iso_sample->DTS+iso_sample->CTS_Offset);
(*sample_index)++;
gf_isom_sample_del(&iso_sample);
} else {
e = gf_isom_last_error(movie);
if (e == GF_ISOM_INCOMPLETE_FILE) {
missing_bytes = gf_isom_get_missing_bytes(movie, track_number);
fprintf(stdout, "Missing "LLU" bytes on input file\n", missing_bytes);
gf_sleep(1000);
}
}
}
}
int main(int argc, char **argv)
{
GF_ISOFile *movie;
GF_Err e;
u64 missing_bytes;
int ret = 0;
u32 seg_max = argc-2;
u32 seg_curr = 0;
u32 track_id = 1;
u32 sample_index = 1;
if (argc < 2) {
fprintf(stdout, "Usage: %s filename0 [filename1 filename2 ...]\n", argv[0]);
return 1;
}
#if defined(DEBUG) || defined(_DEBUG)
gf_sys_init(GF_MemTrackerSimple);
gf_log_set_tool_level(GF_LOG_CONTAINER, GF_LOG_INFO);
gf_log_set_tool_level(GF_LOG_MEMORY, GF_LOG_INFO);
#endif
fprintf(stdout, "Process segment %5d/%5d: %s\n", seg_curr, seg_max, argv[seg_curr+1]);
e = gf_isom_open_progressive(argv[seg_curr+1], 0, 0, &movie, &missing_bytes);
if ((e != GF_OK && e != GF_ISOM_INCOMPLETE_FILE) || movie == NULL) {
fprintf(stdout, "Could not open file %s for reading (%s).\n", argv[seg_curr+1], gf_error_to_string(e));
return 1;
}
process_samples_from_track(movie, track_id, &sample_index);
seg_curr++;
while (seg_curr <= seg_max) {
fprintf(stdout, "Process segment %5d/%5d: %s\n", seg_curr, seg_max, argv[seg_curr+1]);
e = gf_isom_open_segment(movie, argv[seg_curr+1], 0, 0, GF_FALSE);
if (e != GF_OK) {
fprintf(stdout, "Could not open segment %s for reading (%s).\n", argv[seg_curr+1], gf_error_to_string(e));
ret = 1;
goto exit;
}
process_samples_from_track(movie, track_id, &sample_index);
gf_isom_release_segment(movie, 1);
seg_curr++;
}
exit:
fprintf(stdout, "Total nb Samples: %d\n", gf_isom_get_sample_count(movie, gf_isom_get_track_by_id(movie, track_id) ) );
gf_isom_release_segment(movie, 1);
gf_isom_close(movie);
#if defined(DEBUG) || defined(_DEBUG)
gf_sys_close();
#endif
return ret;
}