use std::io::{
Error,
ErrorKind,
Result,
};
use crate::{
TranscodeProgress,
TranscodeStatus,
};
pub(super) fn validate_decode_progress(
progress: TranscodeProgress,
input_index: usize,
available_input: usize,
output_index: usize,
available_output: usize,
) -> Result<TranscodeProgress> {
progress
.validate(input_index, available_input, output_index, available_output)
.map_err(|error| Error::new(ErrorKind::InvalidData, error))?;
Ok(progress)
}
pub(super) fn validate_encode_progress(
progress: TranscodeProgress,
input_index: usize,
available_input: usize,
output_index: usize,
available_output: usize,
) -> Result<TranscodeProgress> {
progress
.validate(input_index, available_input, output_index, available_output)
.map_err(|error| Error::new(ErrorKind::InvalidData, error))?;
if matches!(progress.status(), TranscodeStatus::NeedInput { .. }) {
return Err(Error::new(
ErrorKind::InvalidData,
"encoder violated the TranscodeEncoder contract by requesting more input",
));
}
Ok(progress)
}