File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ impl<R: Read> H264Reader<R> {
154
154
}
155
155
}
156
156
157
- fn read ( & mut self , num_to_read : usize ) -> Bytes {
157
+ fn read ( & mut self , num_to_read : usize ) -> Result < Bytes > {
158
158
let buf = & mut self . temp_buf ;
159
159
while self . read_buffer . len ( ) < num_to_read {
160
160
let n = match self . reader . read ( buf) {
@@ -164,7 +164,7 @@ impl<R: Read> H264Reader<R> {
164
164
}
165
165
n
166
166
}
167
- Err ( _ ) => break ,
167
+ Err ( e ) => return Err ( Error :: Io ( e . into ( ) ) ) ,
168
168
} ;
169
169
170
170
self . read_buffer . extend_from_slice ( & buf[ 0 ..n] ) ;
@@ -176,15 +176,15 @@ impl<R: Read> H264Reader<R> {
176
176
self . read_buffer . len ( )
177
177
} ;
178
178
179
- Bytes :: from (
179
+ Ok ( Bytes :: from (
180
180
self . read_buffer
181
181
. drain ( ..num_should_read)
182
182
. collect :: < Vec < u8 > > ( ) ,
183
- )
183
+ ) )
184
184
}
185
185
186
186
fn bit_stream_starts_with_h264prefix ( & mut self ) -> Result < usize > {
187
- let prefix_buffer = self . read ( 4 ) ;
187
+ let prefix_buffer = self . read ( 4 ) ? ;
188
188
189
189
let n = prefix_buffer. len ( ) ;
190
190
if n == 0 {
@@ -228,7 +228,7 @@ impl<R: Read> H264Reader<R> {
228
228
}
229
229
230
230
loop {
231
- let buffer = self . read ( 1 ) ;
231
+ let buffer = self . read ( 1 ) ? ;
232
232
let n = buffer. len ( ) ;
233
233
234
234
if n != 1 {
You can’t perform that action at this time.
0 commit comments