scuffle_ffmpeg/enums/av_seek.rs
1use nutype_enum::{bitwise_enum, nutype_enum};
2
3use crate::ffi::*;
4
5const _: () = {
6 assert!(std::mem::size_of::<AVSeekFlag>() == std::mem::size_of_val(&AVSEEK_FLAG_BACKWARD));
7};
8
9nutype_enum! {
10 /// Seek flags used in FFmpeg's `av_seek_frame` function.
11 ///
12 /// These flags modify how seeking is performed in media files.
13 ///
14 /// See the official FFmpeg documentation:
15 /// <https://ffmpeg.org/doxygen/trunk/group__lavf__decoding.html#gaa59bdaec0590cc36300753c5cf6c9d49>
16 pub enum AVSeekFlag(i32) {
17 /// Seek to the closest keyframe before the specified timestamp.
18 /// - **Used for**: Ensuring accurate decoding by seeking to a valid keyframe.
19 /// - **Binary representation**: `0b0000000000000001`
20 /// - **Equivalent to**: `AVSEEK_FLAG_BACKWARD`
21 Backward = AVSEEK_FLAG_BACKWARD as _,
22
23 /// Seek by byte position instead of timestamp.
24 /// - **Used for**: Formats where byte offsets are more reliable than timestamps.
25 /// - **Binary representation**: `0b0000000000000010`
26 /// - **Equivalent to**: `AVSEEK_FLAG_BYTE`
27 Byte = AVSEEK_FLAG_BYTE as _,
28
29 /// Seek to any frame, not just keyframes.
30 /// - **Used for**: Allowing finer seeking granularity at the cost of possible decoding artifacts.
31 /// - **Binary representation**: `0b0000000000000100`
32 /// - **Equivalent to**: `AVSEEK_FLAG_ANY`
33 Any = AVSEEK_FLAG_ANY as _,
34
35 /// Seek based on frame numbers rather than timestamps.
36 /// - **Used for**: Direct frame-based seeking in formats that support it.
37 /// - **Binary representation**: `0b0000000000001000`
38 /// - **Equivalent to**: `AVSEEK_FLAG_FRAME`
39 Frame = AVSEEK_FLAG_FRAME as _,
40 }
41}
42
43bitwise_enum!(AVSeekFlag);
44
45impl PartialEq<i32> for AVSeekFlag {
46 fn eq(&self, other: &i32) -> bool {
47 self.0 == *other
48 }
49}
50
51impl From<u32> for AVSeekFlag {
52 fn from(value: u32) -> Self {
53 AVSeekFlag(value as _)
54 }
55}
56
57impl From<AVSeekFlag> for u32 {
58 fn from(value: AVSeekFlag) -> Self {
59 value.0 as u32
60 }
61}
62
63const _: () = {
64 assert!(std::mem::size_of::<AVSeekWhence>() == std::mem::size_of_val(&SEEK_SET));
65};
66
67nutype_enum! {
68 /// Seek flags used in FFmpeg's `av_seek_frame` function.
69 ///
70 /// These flags modify how seeking is performed in media files.
71 ///
72 /// See the official FFmpeg documentation:
73 /// <https://ffmpeg.org/doxygen/trunk/group__lavf__decoding.html#gaa59bdaec0590cc36300753c5cf6c9d49>
74 pub enum AVSeekWhence(i32) {
75 /// Seek from the beginning of the file.
76 /// - **Used for**: Seeking from the start of the file.
77 /// - **Binary representation**: `0b0000000000000001`
78 /// - **Equivalent to**: `SEEK_SET`
79 Start = SEEK_SET as _,
80
81 /// Seek from the current position.
82 /// - **Used for**: Seeking from the current position.
83 /// - **Binary representation**: `0b0000000000000010`
84 /// - **Equivalent to**: `SEEK_CUR`
85 Current = SEEK_CUR as _,
86
87 /// Seek from the end of the file.
88 /// - **Used for**: Seeking from the end of the file.
89 /// - **Binary representation**: `0b0000000000000100`
90 /// - **Equivalent to**: `SEEK_END`
91 End = SEEK_END as _,
92
93 /// Return the file size instead of performing a seek.
94 /// - **Used for**: Querying the total file size.
95 /// - **Binary representation**: `0b00000000000000010000000000000000`
96 /// - **Equivalent to**: `AVSEEK_SIZE`
97 Size = AVSEEK_SIZE as _,
98
99 /// Force seeking, even if the demuxer does not indicate it supports it.
100 /// - **Used for**: Forcing a seek operation when the demuxer might otherwise refuse.
101 /// - **Binary representation**: `0b00000000000000100000000000000000`
102 /// - **Equivalent to**: `AVSEEK_FORCE`
103 Force = AVSEEK_FORCE as _,
104 }
105}
106
107bitwise_enum!(AVSeekWhence);
108
109impl PartialEq<i32> for AVSeekWhence {
110 fn eq(&self, other: &i32) -> bool {
111 self.0 == *other
112 }
113}
114
115impl From<u32> for AVSeekWhence {
116 fn from(value: u32) -> Self {
117 AVSeekWhence(value as _)
118 }
119}
120
121impl From<AVSeekWhence> for u32 {
122 fn from(value: AVSeekWhence) -> Self {
123 value.0 as u32
124 }
125}