Skip to content

Commit 54a6e3e

Browse files
author
Valentin Noel
committed
Wrapping: feed the wrapper when waiting for data (from the same stream) to complete wrapping
1 parent df3ad65 commit 54a6e3e

File tree

1 file changed

+41
-3
lines changed

1 file changed

+41
-3
lines changed

src/AvTranscoder/transcoder/StreamTranscoder.cpp

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,19 @@ bool StreamTranscoder::processRewrap()
303303
if( ! _inputStream->readNextPacket( data ) )
304304
return false;
305305

306-
_outputStream->wrap( data );
306+
IOutputStream::EWrappingStatus wrappingStatus = _outputStream->wrap( data );
307+
308+
switch( wrappingStatus )
309+
{
310+
case IOutputStream::eWrappingSuccess:
311+
return true;
312+
case IOutputStream::eWrappingWaitingForData:
313+
// the wrapper needs more data to write the current packet
314+
return processRewrap();
315+
case IOutputStream::eWrappingError:
316+
return false;
317+
}
318+
307319
return true;
308320
}
309321

@@ -355,7 +367,20 @@ bool StreamTranscoder::processTranscode()
355367

356368
if( _verbose )
357369
std::cout << "wrap (" << data.getSize() << ")" << std::endl;
358-
_outputStream->wrap( data );
370+
371+
IOutputStream::EWrappingStatus wrappingStatus = _outputStream->wrap( data );
372+
373+
switch( wrappingStatus )
374+
{
375+
case IOutputStream::eWrappingSuccess:
376+
return true;
377+
case IOutputStream::eWrappingWaitingForData:
378+
// the wrapper needs more data to write the current packet
379+
return processTranscode();
380+
case IOutputStream::eWrappingError:
381+
return false;
382+
}
383+
359384
return true;
360385
}
361386

@@ -406,7 +431,20 @@ bool StreamTranscoder::processTranscode( const int subStreamIndex )
406431
}
407432
if( _verbose )
408433
std::cout << "wrap (" << data.getSize() << ")" << std::endl;
409-
_outputStream->wrap( data );
434+
435+
IOutputStream::EWrappingStatus wrappingStatus = _outputStream->wrap( data );
436+
437+
switch( wrappingStatus )
438+
{
439+
case IOutputStream::eWrappingSuccess:
440+
return true;
441+
case IOutputStream::eWrappingWaitingForData:
442+
// the wrapper needs more data to write the current packet
443+
return processTranscode( subStreamIndex );
444+
case IOutputStream::eWrappingError:
445+
return false;
446+
}
447+
410448
return true;
411449
}
412450

0 commit comments

Comments
 (0)