/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ package com.castlabs.dash.dashfragmenter.cmdlines; import com.castlabs.dash.dashfragmenter.sequences.DashFileSetSequence; import com.castlabs.dash.dashfragmenter.FileAndTrackSelector; import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.CmdLineParser; import org.kohsuke.args4j.Option; import java.io.File; import java.util.List; public class DashFileSetEncrypt extends AbstractEncryptOrNotCommand { @Option(name = "--sparse", aliases = "-s", usage = "0=encrypt everything, 1=encrypted if default, some sample clear, 2=clear is default, important samples are encrypted", hidden = true ) protected int sparse = 0; @Option(name = "--clearlead", aliases = "-C", usage = "seconds of unencrypted content after start", hidden = true ) protected int clearLead = 0; @Argument(required = true, multiValued = true, handler = FileAndTrackSelectorOptionHandler.class, usage = "MP4 and bitstream input files. In case that an audio input format cannot convey the input's language the filename is expected to be [basename]-[lang].[ext]", metaVar = "vid1.mp4, vid2.mp4, aud1.mp4, aud2-eng.ec3, aud3-fra.aac ...") protected List<FileAndTrackSelector> inputFiles; @Option(name = "--outputdir", aliases = "-o", usage = "output directory - if no output directory is given the " + "current working directory is used.", metaVar = "PATH") protected File outputDirectory = new File(System.getProperty("user.dir")); @Option(name = "--explode", aliases = "-x", usage = "If this option is set each segement will be written in a single file") protected boolean explode = false; @Option(name = "--dummyIvs", hidden = true) protected boolean dummyIvs = false; @Option(name = "--subtitles", aliases = "-st") protected List<File> subtitles; @Option(name = "--closed-captions", aliases = "-cc") protected List<File> closedCaptions; @Option(name = "--trick-mode-files", aliases = "-tmh", usage = "Add reduced framerate representations here.") protected List<File> trickmodefiles; public void postProcessCmdLineArgs(CmdLineParser cmdLineParser) throws CmdLineException { super.postProcessCmdLineArgs(cmdLineParser); for (FileAndTrackSelector inputFile : inputFiles) { if (inputFile.file.getName().endsWith(".xml") || inputFile.file.getName().endsWith(".vtt") || inputFile.file.getName().endsWith(".dfxp")) { throw new CmdLineException(cmdLineParser, new AbstractEncryptOrNotCommand.Message("Subtitle files must either be supplied via command line option --subtitles or --closed-captions")); } } } public int run() { DashFileSetSequence d = new DashFileSetSequence(); d.setExplode(explode); d.setSparse(sparse); d.setClearlead(clearLead); d.setOutputDirectory(outputDirectory); d.setInputFiles(inputFiles); d.setEncryptionAlgo("cenc"); d.setDummyIvs(dummyIvs); d.setTrickModeFiles(trickmodefiles); d.setSubtitles(subtitles); d.setClosedCaptions(closedCaptions); d.setAudioKeyid(audioKeyId); d.setVideoKeyid(videoKeyId); d.setAudioKey(audioKey); d.setVideoKey(videoKey); return d.run(); } }