diff --git a/limelight-common/ControlStream.c b/limelight-common/ControlStream.c index e823716..2166925 100644 --- a/limelight-common/ControlStream.c +++ b/limelight-common/ControlStream.c @@ -56,6 +56,12 @@ void destroyControlStream(void) { PltCloseEvent(&resyncEvent); } +/* Resync on demand by the decoder */ +void resyncOnDemand(void) { + // FIXME: Send ranges + PltSetEvent(&resyncEvent); +} + /* Resync if the connection is too slow */ void connectionSinkTooSlow(int startFrame, int endFrame) { // FIXME: Send ranges diff --git a/limelight-common/Limelight-internal.h b/limelight-common/Limelight-internal.h index 074e776..c04b2a7 100644 --- a/limelight-common/Limelight-internal.h +++ b/limelight-common/Limelight-internal.h @@ -12,6 +12,7 @@ int initializeControlStream(IP_ADDRESS host, PSTREAM_CONFIGURATION streamConfig, int startControlStream(void); int stopControlStream(void); void destroyControlStream(void); +void resyncOnDemand(void); void connectionSinkTooSlow(int startFrame, int endFrame); void connectionDetectedFrameLoss(int startFrame, int endFrame); void connectionReceivedFrame(int frameIndex); diff --git a/limelight-common/Limelight.h b/limelight-common/Limelight.h index e5d58f8..9d499b5 100644 --- a/limelight-common/Limelight.h +++ b/limelight-common/Limelight.h @@ -31,7 +31,10 @@ typedef void(*DecoderRendererSetup)(int width, int height, int redrawRate, void* typedef void(*DecoderRendererStart)(void); typedef void(*DecoderRendererStop)(void); typedef void(*DecoderRendererRelease)(void); -typedef void(*DecoderRendererSubmitDecodeUnit)(PDECODE_UNIT decodeUnit); + +#define DR_OK 0 +#define DR_NEED_IDR -1 +typedef int(*DecoderRendererSubmitDecodeUnit)(PDECODE_UNIT decodeUnit); typedef struct _DECODER_RENDERER_CALLBACKS { DecoderRendererSetup setup; diff --git a/limelight-common/VideoStream.c b/limelight-common/VideoStream.c index 4ed08e8..55c5072 100644 --- a/limelight-common/VideoStream.c +++ b/limelight-common/VideoStream.c @@ -99,9 +99,14 @@ static void DecoderThreadProc(void* context) { return; } - callbacks.submitDecodeUnit(du); + int ret = callbacks.submitDecodeUnit(du); freeDecodeUnit(du); + + if (ret == DR_NEED_IDR) { + Limelog("Request IDR frame on behalf of DR\n"); + resyncOnDemand(); + } } }