@@ -112,7 +112,7 @@ pub struct Config<'a> {
112112 pub resolution : ( u32 , u32 ) ,
113113 /// FourCC of format (e.g. `b"RGB3"`). Note that case matters.
114114 /// Default is `b"YUYV"`.
115- pub format : & ' a [ u8 ] ,
115+ pub format : & ' a [ u8 ; 4 ] ,
116116 /// Storage method of interlaced video. See `FIELD_*` constants.
117117 /// [Details](http://linuxtv.org/downloads/v4l-dvb-apis/uapi/v4l/field-order.html#v4l2-field).
118118 /// Default is `FIELD_NONE` (progressive).
@@ -160,7 +160,7 @@ impl FormatInfo {
160160 }
161161 }
162162
163- fn fourcc ( fmt : & [ u8 ] ) -> u32 {
163+ fn fourcc ( fmt : [ u8 ; 4 ] ) -> u32 {
164164 u32:: from ( fmt[ 0 ] )
165165 | ( u32:: from ( fmt[ 1 ] ) ) << 8
166166 | ( u32:: from ( fmt[ 2 ] ) ) << 16
@@ -315,11 +315,7 @@ impl Camera {
315315 }
316316
317317 /// Get detailed info about the available resolutions.
318- pub fn resolutions ( & self , format : & [ u8 ] ) -> Result < ResolutionInfo > {
319- if format. len ( ) != 4 {
320- return Err ( Error :: BadFormat ) ;
321- }
322-
318+ pub fn resolutions ( & self , format : [ u8 ; 4 ] ) -> Result < ResolutionInfo > {
323319 let fourcc = FormatInfo :: fourcc ( format) ;
324320 let mut size = v4l2:: Frmsizeenum :: new ( fourcc) ;
325321
@@ -354,11 +350,7 @@ impl Camera {
354350 }
355351
356352 /// Get detailed info about the available intervals.
357- pub fn intervals ( & self , format : & [ u8 ] , resolution : ( u32 , u32 ) ) -> Result < IntervalInfo > {
358- if format. len ( ) != 4 {
359- return Err ( Error :: BadFormat ) ;
360- }
361-
353+ pub fn intervals ( & self , format : [ u8 ; 4 ] , resolution : ( u32 , u32 ) ) -> Result < IntervalInfo > {
362354 let fourcc = FormatInfo :: fourcc ( format) ;
363355 let mut ival = v4l2:: Frmivalenum :: new ( fourcc, resolution) ;
364356
@@ -559,7 +551,7 @@ impl Camera {
559551 pub fn start ( & mut self , config : & Config ) -> Result < ( ) > {
560552 assert_eq ! ( self . state, State :: Idle ) ;
561553
562- self . tune_format ( config. resolution , config. format , config. field ) ?;
554+ self . tune_format ( config. resolution , * config. format , config. field ) ?;
563555 self . tune_stream ( config. interval ) ?;
564556 self . alloc_buffers ( config. nbuffers ) ?;
565557
@@ -619,11 +611,7 @@ impl Camera {
619611 Ok ( ( ) )
620612 }
621613
622- fn tune_format ( & self , resolution : ( u32 , u32 ) , format : & [ u8 ] , field : u32 ) -> Result < ( ) > {
623- if format. len ( ) != 4 {
624- return Err ( Error :: BadFormat ) ;
625- }
626-
614+ fn tune_format ( & self , resolution : ( u32 , u32 ) , format : [ u8 ; 4 ] , field : u32 ) -> Result < ( ) > {
627615 let fourcc = FormatInfo :: fourcc ( format) ;
628616 let mut fmt = v4l2:: Format :: new ( resolution, fourcc, field as u32 ) ;
629617
0 commit comments