use std::io;
use bytes::Bytes;
use enhanced::ExVideoTagBody;
use legacy::LegacyVideoTagBody;
use super::header::{VideoTagHeader, VideoTagHeaderData};
use crate::error::FlvError;
pub mod enhanced;
pub mod legacy;
#[derive(Debug, Clone, PartialEq)]
pub enum VideoTagBody<'a> {
Legacy(LegacyVideoTagBody),
Enhanced(ExVideoTagBody<'a>),
}
impl VideoTagBody<'_> {
pub fn demux(header: &VideoTagHeader, reader: &mut io::Cursor<Bytes>) -> Result<Self, FlvError> {
match &header.data {
VideoTagHeaderData::Legacy(header) => Ok(Self::Legacy(LegacyVideoTagBody::demux(header, reader)?)),
VideoTagHeaderData::Enhanced(header) => ExVideoTagBody::demux(header, reader).map(Self::Enhanced),
}
}
}