Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Commit

Permalink
Update #208 start debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
hdsdi3g committed Apr 4, 2017
1 parent 92b10f4 commit e2dbdb4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
37 changes: 36 additions & 1 deletion app/hd3gtv/mydmam/transcode/kit/PKitOpAtomTo1A_XMLBased.java
Expand Up @@ -20,6 +20,7 @@
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -101,7 +102,7 @@ public List<File> process(File physical_source, Container source_indexing_result

ArrayList<File> all_mxf_files = new ArrayList<>(5);

all_mxf_files.add(new File(FilenameUtils.removeExtension(physical_source.getAbsolutePath()) + ".mxf").getCanonicalFile());
all_mxf_files.add(new File(FilenameUtils.removeExtension(physical_source.getAbsolutePath()) + ".mxf").getCanonicalFile());// TODO must check this content
URL dest_archive = null;
String outputfile_basename = "(error).mxf";

Expand Down Expand Up @@ -142,6 +143,10 @@ public List<File> process(File physical_source, Container source_indexing_result
result_op1a = new File(new File(chroot_ftp).getAbsolutePath() + File.separator + dest_archive.getPath() + File.separator + outputfile_basename);
}

if (Loggers.Transcode.isDebugEnabled()) {
Loggers.Transcode.debug("Found some atoms declared by " + physical_source.getName() + ": " + all_mxf_files);
}

FileUtils.forceMkdir(result_op1a.getParentFile());
if (result_op1a.exists()) {
FileUtils.forceDelete(result_op1a);
Expand Down Expand Up @@ -220,6 +225,33 @@ public List<File> process(File physical_source, Container source_indexing_result
return "";
});

/**
* Remove duplicate streams
*/
HashSet<Integer> actual_atom_indexes = new HashSet<>(5);
ArrayList<PKitOpAtomTo1A_XMLBasedAtom> duplicate_atoms_to_delete = new ArrayList<>(1);

all_atoms.removeIf(atom -> {
Integer index = atom.getMXFStreamMap();
if (actual_atom_indexes.contains(index)) {
duplicate_atoms_to_delete.add(atom);
Loggers.Transcode.debug("Duplicate atom index (" + index + "), don't use it: " + atom);
return true;
}
actual_atom_indexes.add(index);
return false;
});

/**
* Check stream indexes order
*/
for (int pos = 0; pos < all_atoms.size(); pos++) {
int map = all_atoms.get(pos).getMXFStreamMap();
if (map != pos) {
throw new IOException("Invalid stream map: atom #" + pos + " have a index == " + map + ". " + all_atoms.get(pos).toString());
}
}

/**
* Prepare bmxtranswrap process exec
*/
Expand Down Expand Up @@ -320,6 +352,9 @@ public List<File> process(File physical_source, Container source_indexing_result
all_atoms.forEach(atom -> {
atom.clean();
});
duplicate_atoms_to_delete.forEach(atom -> {
atom.clean();
});

return null;
}
Expand Down
Expand Up @@ -275,9 +275,14 @@ void clean() {
}
}
}
try {
FileUtils.forceDelete(original_atom);
} catch (IOException e) {
Loggers.Transcode.error("Can't delete atom file", e);
}
}

public String toString() {
return this.original_atom.getPath();
return original_atom.getPath();
}
}

0 comments on commit e2dbdb4

Please sign in to comment.