@@ -11,7 +11,7 @@ use windows::{
1111 Foundation :: TimeSpan ,
1212 Graphics :: SizeInt32 ,
1313 Win32 :: {
14- Foundation :: { E_FAIL , E_NOTIMPL } ,
14+ Foundation :: E_NOTIMPL ,
1515 Graphics :: {
1616 Direct3D11 :: { ID3D11Device , ID3D11Texture2D } ,
1717 Dxgi :: Common :: { DXGI_FORMAT , DXGI_FORMAT_NV12 } ,
@@ -239,10 +239,10 @@ impl H264Encoder {
239239 let mut count = 0 ;
240240 loop {
241241 let result = transform. GetInputAvailableType ( input_stream_id, count) ;
242- if let Err ( error) = & result {
243- if error. code ( ) == MF_E_NO_MORE_TYPES {
244- break Ok ( None ) ;
245- }
242+ if let Err ( error) = & result
243+ && error. code ( ) == MF_E_NO_MORE_TYPES
244+ {
245+ break Ok ( None ) ;
246246 }
247247
248248 let input_type = result?;
@@ -261,11 +261,11 @@ impl H264Encoder {
261261 & input_type,
262262 MFT_SET_TYPE_TEST_ONLY . 0 as u32 ,
263263 ) ;
264- if let Err ( error) = & result {
265- if error. code ( ) == MF_E_INVALIDMEDIATYPE {
266- count += 1 ;
267- continue ;
268- }
264+ if let Err ( error) = & result
265+ && error. code ( ) == MF_E_INVALIDMEDIATYPE
266+ {
267+ count += 1 ;
268+ continue ;
269269 }
270270 result?;
271271 break Ok ( Some ( input_type) ) ;
@@ -404,24 +404,24 @@ impl H264Encoder {
404404 match event_type {
405405 MediaFoundation :: METransformNeedInput => {
406406 should_exit = true ;
407- if !should_stop. load ( Ordering :: SeqCst ) {
408- if let Some ( ( texture, timestamp) ) = get_frame ( ) ? {
409- self . video_processor . process_texture ( & texture ) ? ;
410- let input_buffer = {
411- MFCreateDXGISurfaceBuffer (
412- & ID3D11Texture2D :: IID ,
413- self . video_processor . output_texture ( ) ,
414- 0 ,
415- false ,
416- ) ?
417- } ;
418- let mf_sample = MFCreateSample ( ) ? ;
419- mf_sample . AddBuffer ( & input_buffer ) ?;
420- mf_sample. SetSampleTime ( timestamp . Duration ) ?;
421- self . transform
422- . ProcessInput ( self . input_stream_id , & mf_sample , 0 ) ? ;
423- should_exit = false ;
424- }
407+ if !should_stop. load ( Ordering :: SeqCst )
408+ && let Some ( ( texture, timestamp) ) = get_frame ( ) ?
409+ {
410+ self . video_processor . process_texture ( & texture ) ? ;
411+ let input_buffer = {
412+ MFCreateDXGISurfaceBuffer (
413+ & ID3D11Texture2D :: IID ,
414+ self . video_processor . output_texture ( ) ,
415+ 0 ,
416+ false ,
417+ ) ?
418+ } ;
419+ let mf_sample = MFCreateSample ( ) ?;
420+ mf_sample. AddBuffer ( & input_buffer ) ?;
421+ mf_sample . SetSampleTime ( timestamp . Duration ) ? ;
422+ self . transform
423+ . ProcessInput ( self . input_stream_id , & mf_sample , 0 ) ? ;
424+ should_exit = false ;
425425 }
426426 }
427427 MediaFoundation :: METransformHaveOutput => {
0 commit comments