@@ -24,7 +24,7 @@ use windows::Storage::Streams::{
2424 Buffer , DataReader , IRandomAccessStream , InMemoryRandomAccessStream , InputStreamOptions ,
2525} ;
2626use windows:: Storage :: { FileAccessMode , StorageFile } ;
27- use windows:: core:: { HSTRING , Interface } ;
27+ use windows:: core:: { Array , HSTRING , Interface } ;
2828
2929use crate :: d3d11:: SendDirectX ;
3030use crate :: frame:: { Frame , ImageFormat } ;
@@ -1408,10 +1408,11 @@ impl StreamingVideoEncoder {
14081408
14091409 // Extract encoded audio data and send to callback
14101410 let audio_data = sample. Buffer ( ) ?;
1411- let audio_buffer = CryptographicBuffer :: CopyToByteArray ( & audio_data) ?;
1412-
1411+ let mut audio_array: Array < u8 > = Array :: new ( ) ;
1412+ CryptographicBuffer :: CopyToByteArray ( & audio_data, & mut audio_array) ?;
1413+
14131414 let encoded_audio = EncodedAudioFrame {
1414- data : audio_buffer . to_vec ( ) ,
1415+ data : audio_array . as_slice ( ) . to_vec ( ) ,
14151416 timestamp : timestamp. Duration ,
14161417 sample_count : audio_encoding_properties. SampleRate ( ) ? / 1000 , // Approximate
14171418 } ;
@@ -1461,10 +1462,11 @@ impl StreamingVideoEncoder {
14611462
14621463 // Extract encoded video data and send to callback
14631464 let video_data = sample. Buffer ( ) ?;
1464- let video_buffer = CryptographicBuffer :: CopyToByteArray ( & video_data) ?;
1465-
1465+ let mut video_array: Array < u8 > = Array :: new ( ) ;
1466+ CryptographicBuffer :: CopyToByteArray ( & video_data, & mut video_array) ?;
1467+
14661468 let encoded_frame = EncodedFrame {
1467- data : video_buffer . to_vec ( ) ,
1469+ data : video_array . as_slice ( ) . to_vec ( ) ,
14681470 timestamp : timestamp. Duration ,
14691471 frame_type : FrameType :: DeltaFrame , // Default, could be determined from sample properties
14701472 width : video_encoding_properties. Width ( ) ?,
@@ -1745,4 +1747,4 @@ impl Drop for StreamingVideoEncoder {
17451747}
17461748
17471749#[ allow( clippy:: non_send_fields_in_send_ty) ]
1748- unsafe impl Send for StreamingVideoEncoder { }
1750+ unsafe impl Send for StreamingVideoEncoder { }
0 commit comments