@@ -33,7 +33,7 @@ pub enum ParserError {
33
33
Cea608AfterCea708 ,
34
34
/// Failed to validate the checksum
35
35
ChecksumFailed ,
36
- /// Sequence count differs between the header and the footer. Usuall indicates this packet was
36
+ /// Sequence count differs between the header and the footer. Usually indicates this packet was
37
37
/// spliced together incorrectly.
38
38
SequenceCountMismatch ,
39
39
}
@@ -109,32 +109,39 @@ static FRAMERATES: [Framerate; 8] = [
109
109
} ,
110
110
] ;
111
111
112
+ /// A framerate as found in a CDP.
112
113
#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
113
114
pub struct Framerate {
114
115
id : u8 ,
115
116
numer : u32 ,
116
117
denom : u32 ,
117
118
}
118
119
120
+ /// A CDP framerate.
119
121
impl Framerate {
122
+ /// Create a [`Framerate`] from an identifier as found in a CDP.
120
123
pub fn from_id ( id : u8 ) -> Option < Framerate > {
121
124
FRAMERATES . iter ( ) . find ( |f| f. id == id) . copied ( )
122
125
}
123
126
127
+ /// The identifier for this [`Framerate`] in a CDP.
124
128
pub fn id ( & self ) -> u8 {
125
129
self . id
126
130
}
127
131
132
+ /// The numerator component of this [`Framerate`]
128
133
pub fn numer ( & self ) -> u32 {
129
134
self . numer
130
135
}
131
136
137
+ /// The denominator component of this [`Framerate`]
132
138
pub fn denom ( & self ) -> u32 {
133
139
self . denom
134
140
}
135
141
}
136
142
137
- pub struct Flags {
143
+ /// A set of flags available in a CDP.
144
+ struct Flags {
138
145
time_code : bool ,
139
146
cc_data : bool ,
140
147
svc_info : bool ,
@@ -198,6 +205,7 @@ impl From<Flags> for u8 {
198
205
}
199
206
}
200
207
208
+ /// A time code as available in a CDP.
201
209
#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
202
210
pub struct TimeCode {
203
211
hours : u8 ,
@@ -208,6 +216,7 @@ pub struct TimeCode {
208
216
drop_frame : bool ,
209
217
}
210
218
219
+ /// Parses CDP packets.
211
220
#[ derive( Debug , Default ) ]
212
221
pub struct CDPParser {
213
222
cc_data_parser : cea708_types:: CCDataParser ,
@@ -446,14 +455,17 @@ impl CDPParser {
446
455
* self = Self :: default ( ) ;
447
456
}
448
457
458
+ /// The latest CDP time code that has been parsed
449
459
pub fn time_code ( & self ) -> Option < TimeCode > {
450
460
self . time_code
451
461
}
452
462
463
+ /// The latest CDP framerate that has been parsed
453
464
pub fn framerate ( & self ) -> Option < Framerate > {
454
465
self . framerate
455
466
}
456
467
468
+ /// The latest CDP sequence number that has been parsed
457
469
pub fn sequence ( & self ) -> u16 {
458
470
self . sequence
459
471
}
@@ -463,6 +475,7 @@ impl CDPParser {
463
475
self . cc_data_parser . pop_packet ( )
464
476
}
465
477
478
+ /// Pop the list of [`cea708_types::Cea608`] contained in this packet
466
479
pub fn cea608 ( & mut self ) -> Option < & [ cea708_types:: Cea608 ] > {
467
480
self . cc_data_parser . cea608 ( )
468
481
}
0 commit comments