flv: Add `Clone` to `Tag` and `Header`.

Some types also get `Copy` by virtue of being plain data with no pointers.
This commit is contained in:
David Wendt 2023-04-12 19:15:05 -04:00 committed by kmeisthax
parent 8fd80cd173
commit b2dd4d8305
5 changed files with 17 additions and 16 deletions

View File

@ -3,14 +3,14 @@ use bitflags::bitflags;
use std::io::{Seek, SeekFrom};
bitflags! {
#[derive(PartialEq, Eq, Debug)]
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
pub struct TypeFlags: u8 {
const HAS_AUDIO = 0b1000_0000;
const HAS_VIDEO = 0b0010_0000;
}
}
#[derive(PartialEq, Eq, Debug)]
#[derive(PartialEq, Eq, Debug, Clone)]
pub struct Header {
pub version: u8,
pub type_flags: TypeFlags,

View File

@ -11,7 +11,7 @@ fn parse_string<'a>(reader: &mut FlvReader<'a>, is_long_string: bool) -> Option<
}
#[repr(u8)]
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Debug, Clone)]
pub enum Value<'a> {
Number(f64) = 0,
Boolean(bool) = 1,
@ -103,7 +103,7 @@ impl<'a> Value<'a> {
/// This corresponds to both the `SCRIPTDATAOBJECT` and `SCRIPTDATAVARIABLE`
/// structures as defined in the FLV specification. These structures are
/// otherwise identical.
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Debug, Clone)]
pub struct Variable<'a> {
pub name: &'a [u8],
pub data: Value<'a>,
@ -118,7 +118,7 @@ impl<'a> Variable<'a> {
}
}
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Debug, Clone)]
pub struct ScriptData<'a>(pub Vec<Variable<'a>>);
impl<'a> ScriptData<'a> {

View File

@ -2,7 +2,7 @@ use crate::FlvReader;
use std::io::Seek;
#[repr(u8)]
#[derive(PartialEq, Eq, Debug)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum SoundFormat {
LinearPCMPlatformEndian = 0,
Adpcm = 1,
@ -43,7 +43,7 @@ impl TryFrom<u8> for SoundFormat {
}
#[repr(u8)]
#[derive(PartialEq, Eq, Debug)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum SoundRate {
R5_500 = 0,
R11_000 = 1,
@ -66,7 +66,7 @@ impl TryFrom<u8> for SoundRate {
}
#[repr(u8)]
#[derive(PartialEq, Eq, Debug)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum SoundSize {
Bits8 = 0,
Bits16 = 1,
@ -85,7 +85,7 @@ impl TryFrom<u8> for SoundSize {
}
#[repr(u8)]
#[derive(PartialEq, Eq, Debug)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
pub enum SoundType {
Mono = 0,
Stereo = 1,
@ -103,14 +103,14 @@ impl TryFrom<u8> for SoundType {
}
}
#[derive(PartialEq, Eq, Debug)]
#[derive(PartialEq, Eq, Debug, Clone)]
pub enum AudioDataType<'a> {
Raw(&'a [u8]),
AacSequenceHeader(&'a [u8]),
AacRaw(&'a [u8]),
}
#[derive(PartialEq, Eq, Debug)]
#[derive(PartialEq, Eq, Debug, Clone)]
pub struct AudioData<'a> {
pub format: SoundFormat,
pub rate: SoundRate,

View File

@ -6,14 +6,14 @@ use crate::video::VideoData;
use std::io::{Seek, SeekFrom};
#[repr(u8)]
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Debug, Clone)]
pub enum TagData<'a> {
Audio(AudioData<'a>) = 8,
Video(VideoData<'a>) = 9,
Script(ScriptData<'a>) = 18,
}
#[derive(PartialEq, Debug)]
#[derive(PartialEq, Debug, Clone)]
pub struct Tag<'a> {
timestamp: i32,
stream_id: u32, //24 bits max

View File

@ -55,7 +55,8 @@ impl TryFrom<u8> for CodecId {
}
}
#[derive(PartialEq, Eq, Debug)]
#[derive(PartialEq, Eq, Debug, Copy, Clone)]
#[repr(u8)]
pub enum CommandFrame {
StartOfClientSideSeek = 0,
EndOfClientSideSeek = 1,
@ -73,7 +74,7 @@ impl TryFrom<u8> for CommandFrame {
}
}
#[derive(PartialEq, Eq, Debug)]
#[derive(PartialEq, Eq, Debug, Clone)]
pub enum VideoPacket<'a> {
Data(&'a [u8]),
AvcSequenceHeader(&'a [u8]),
@ -85,7 +86,7 @@ pub enum VideoPacket<'a> {
CommandFrame(CommandFrame),
}
#[derive(PartialEq, Eq, Debug)]
#[derive(PartialEq, Eq, Debug, Clone)]
pub struct VideoData<'a> {
pub frame_type: FrameType,
pub codec_id: CodecId,