Request an IDR frame and reset the decoder if the decoder breaks

This commit is contained in:
Cameron Gutman
2015-01-09 18:02:18 -05:00
parent c1a1dbe881
commit f7fdd7cb45
3 changed files with 67 additions and 29 deletions

View File

@@ -48,22 +48,24 @@ void DrSetup(int width, int height, int fps, void* context, int drFlags)
{
}
void DrSubmitDecodeUnit(PDECODE_UNIT decodeUnit)
int DrSubmitDecodeUnit(PDECODE_UNIT decodeUnit)
{
int offset = 0;
unsigned char* data = (unsigned char*) malloc(decodeUnit->fullLength);
if (data != NULL) {
int offset = 0;
PLENTRY entry = decodeUnit->bufferList;
while (entry != NULL) {
memcpy(&data[offset], entry->data, entry->length);
offset += entry->length;
entry = entry->next;
}
// This function will take our buffer
[renderer submitDecodeBuffer:data length:decodeUnit->fullLength];
if (data == NULL) {
// A frame was lost due to OOM condition
return DR_NEED_IDR;
}
PLENTRY entry = decodeUnit->bufferList;
while (entry != NULL) {
memcpy(&data[offset], entry->data, entry->length);
offset += entry->length;
entry = entry->next;
}
// This function will take our buffer
return [renderer submitDecodeBuffer:data length:decodeUnit->fullLength];
}
void DrStart(void)