@@ -68,7 +68,7 @@ pub struct Config<'a> {
6868 pub resolution : ( u32 , u32 ) ,
6969 /// FourCC of format (e.g. `b"RGB3"`). Note that case matters.
7070 /// Default is `b"YUYV"`.
71- pub format : & ' a [ u8 ] ,
71+ pub format : & ' a [ u8 ; 4 ] ,
7272 /// Storage method of interlaced video. See `FIELD_*` constants.
7373 /// [Details](http://linuxtv.org/downloads/v4l-dvb-apis/uapi/v4l/field-order.html#v4l2-field).
7474 /// Default is `FIELD_NONE` (progressive).
@@ -116,7 +116,7 @@ impl FormatInfo {
116116 }
117117 }
118118
119- fn fourcc ( fmt : & [ u8 ] ) -> u32 {
119+ fn fourcc ( fmt : [ u8 ; 4 ] ) -> u32 {
120120 u32:: from ( fmt[ 0 ] )
121121 | ( u32:: from ( fmt[ 1 ] ) ) << 8
122122 | ( u32:: from ( fmt[ 2 ] ) ) << 16
@@ -271,11 +271,7 @@ impl Camera {
271271 }
272272
273273 /// Get detailed info about the available resolutions.
274- pub fn resolutions ( & self , format : & [ u8 ] ) -> Result < ResolutionInfo > {
275- if format. len ( ) != 4 {
276- return Err ( Error :: BadFormat ) ;
277- }
278-
274+ pub fn resolutions ( & self , format : [ u8 ; 4 ] ) -> Result < ResolutionInfo > {
279275 let fourcc = FormatInfo :: fourcc ( format) ;
280276 let mut size = v4l2:: Frmsizeenum :: new ( fourcc) ;
281277
@@ -310,11 +306,7 @@ impl Camera {
310306 }
311307
312308 /// Get detailed info about the available intervals.
313- pub fn intervals ( & self , format : & [ u8 ] , resolution : ( u32 , u32 ) ) -> Result < IntervalInfo > {
314- if format. len ( ) != 4 {
315- return Err ( Error :: BadFormat ) ;
316- }
317-
309+ pub fn intervals ( & self , format : [ u8 ; 4 ] , resolution : ( u32 , u32 ) ) -> Result < IntervalInfo > {
318310 let fourcc = FormatInfo :: fourcc ( format) ;
319311 let mut ival = v4l2:: Frmivalenum :: new ( fourcc, resolution) ;
320312
@@ -515,7 +507,7 @@ impl Camera {
515507 pub fn start ( & mut self , config : & Config < ' _ > ) -> Result < ( ) > {
516508 assert_eq ! ( self . state, State :: Idle ) ;
517509
518- self . tune_format ( config. resolution , config. format , config. field ) ?;
510+ self . tune_format ( config. resolution , * config. format , config. field ) ?;
519511 self . tune_stream ( config. interval ) ?;
520512 self . alloc_buffers ( config. nbuffers ) ?;
521513
@@ -575,11 +567,7 @@ impl Camera {
575567 Ok ( ( ) )
576568 }
577569
578- fn tune_format ( & self , resolution : ( u32 , u32 ) , format : & [ u8 ] , field : u32 ) -> Result < ( ) > {
579- if format. len ( ) != 4 {
580- return Err ( Error :: BadFormat ) ;
581- }
582-
570+ fn tune_format ( & self , resolution : ( u32 , u32 ) , format : [ u8 ; 4 ] , field : u32 ) -> Result < ( ) > {
583571 let fourcc = FormatInfo :: fourcc ( format) ;
584572 let mut fmt = v4l2:: Format :: new ( resolution, fourcc, field as u32 ) ;
585573
0 commit comments