Revert "Remove decoding thread like in Java common"

This reverts commit 50733f6d7a.
This commit is contained in:
Michelle Bergeron
2014-06-29 17:36:03 -07:00
parent 125f81118f
commit f2af6c8bd9
6 changed files with 30 additions and 51 deletions

View File

@@ -18,6 +18,7 @@ static SOCKET firstFrameSocket = INVALID_SOCKET;
static PLT_THREAD udpPingThread;
static PLT_THREAD receiveThread;
static PLT_THREAD decoderThread;
void initializeVideoStream(IP_ADDRESS host, PSTREAM_CONFIGURATION streamConfig, PDECODER_RENDERER_CALLBACKS drCallbacks,
PCONNECTION_LISTENER_CALLBACKS clCallbacks) {
@@ -82,6 +83,20 @@ static void ReceiveThreadProc(void* context) {
free(buffer);
}
static void DecoderThreadProc(void* context) {
PDECODE_UNIT du;
while (!PltIsThreadInterrupted(&decoderThread)) {
if (!getNextDecodeUnit(&du)) {
printf("Decoder thread terminating\n");
return;
}
callbacks.submitDecodeUnit(du);
freeDecodeUnit(du);
}
}
int readFirstFrame(void) {
char* firstFrame;
int err;
@@ -118,6 +133,7 @@ void stopVideoStream(void) {
PltInterruptThread(&udpPingThread);
PltInterruptThread(&receiveThread);
PltInterruptThread(&decoderThread);
if (firstFrameSocket != INVALID_SOCKET) {
closesocket(firstFrameSocket);
@@ -130,9 +146,11 @@ void stopVideoStream(void) {
PltJoinThread(&udpPingThread);
PltJoinThread(&receiveThread);
PltJoinThread(&decoderThread);
PltCloseThread(&udpPingThread);
PltCloseThread(&receiveThread);
PltCloseThread(&decoderThread);
}
int startVideoStream(void* rendererContext, int drFlags) {
@@ -158,6 +176,11 @@ int startVideoStream(void* rendererContext, int drFlags) {
return err;
}
err = PltCreateThread(DecoderThreadProc, NULL, &decoderThread);
if (err != 0) {
return err;
}
callbacks.start();
return 0;