mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-18 01:15:46 +00:00
Add LiGetPendingVideoFrames() and LiGetPendingAudioFrames()
This commit is contained in:
parent
59481c085a
commit
dffe51e885
@ -65,9 +65,7 @@ typedef struct _QUEUED_AUDIO_PACKET {
|
||||
|
||||
// Initialize the audio stream
|
||||
void initializeAudioStream(void) {
|
||||
if ((AudioCallbacks.capabilities & CAPABILITY_DIRECT_SUBMIT) == 0) {
|
||||
LbqInitializeLinkedBlockingQueue(&packetQueue, 30);
|
||||
}
|
||||
LbqInitializeLinkedBlockingQueue(&packetQueue, 30);
|
||||
RtpqInitializeQueue(&rtpReorderQueue, RTPQ_DEFAULT_MAX_SIZE, RTPQ_DEFAULT_QUEUE_TIME);
|
||||
lastSeq = 0;
|
||||
receivedDataFromPeer = 0;
|
||||
@ -88,9 +86,7 @@ static void freePacketList(PLINKED_BLOCKING_QUEUE_ENTRY entry) {
|
||||
|
||||
// Tear down the audio stream once we're done with it
|
||||
void destroyAudioStream(void) {
|
||||
if ((AudioCallbacks.capabilities & CAPABILITY_DIRECT_SUBMIT) == 0) {
|
||||
freePacketList(LbqDestroyLinkedBlockingQueue(&packetQueue));
|
||||
}
|
||||
freePacketList(LbqDestroyLinkedBlockingQueue(&packetQueue));
|
||||
RtpqCleanupQueue(&rtpReorderQueue);
|
||||
}
|
||||
|
||||
@ -404,3 +400,7 @@ int startAudioStream(void* audioContext, int arFlags) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LiGetPendingAudioFrames(void) {
|
||||
return LbqGetItemCount(&packetQueue);
|
||||
}
|
||||
|
@ -444,6 +444,14 @@ uint64_t LiGetMillis(void);
|
||||
// network byte order.
|
||||
int LiFindExternalAddressIP4(const char* stunServer, unsigned short stunPort, unsigned int* wanAddr);
|
||||
|
||||
// Returns the number of queued video frames ready for delivery. Only relevant
|
||||
// if CAPABILITY_DIRECT_SUBMIT is not set for the video renderer.
|
||||
int LiGetPendingVideoFrames(void);
|
||||
|
||||
// Returns the number of queued audio frames ready for delivery. Only relevant
|
||||
// if CAPABILITY_DIRECT_SUBMIT is not set for the audio renderer.
|
||||
int LiGetPendingAudioFrames(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -56,6 +56,10 @@ void LbqSignalQueueShutdown(PLINKED_BLOCKING_QUEUE queueHead) {
|
||||
PltSetEvent(&queueHead->containsDataEvent);
|
||||
}
|
||||
|
||||
int LbqGetItemCount(PLINKED_BLOCKING_QUEUE queueHead) {
|
||||
return queueHead->currentSize;
|
||||
}
|
||||
|
||||
int LbqOfferQueueItem(PLINKED_BLOCKING_QUEUE queueHead, void* data, PLINKED_BLOCKING_QUEUE_ENTRY entry) {
|
||||
if (queueHead->shutdown) {
|
||||
return LBQ_INTERRUPTED;
|
||||
@ -205,4 +209,4 @@ int LbqWaitForQueueElement(PLINKED_BLOCKING_QUEUE queueHead, void** data) {
|
||||
}
|
||||
|
||||
return LBQ_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
@ -33,3 +33,4 @@ int LbqPeekQueueElement(PLINKED_BLOCKING_QUEUE queueHead, void** data);
|
||||
PLINKED_BLOCKING_QUEUE_ENTRY LbqDestroyLinkedBlockingQueue(PLINKED_BLOCKING_QUEUE queueHead);
|
||||
PLINKED_BLOCKING_QUEUE_ENTRY LbqFlushQueueItems(PLINKED_BLOCKING_QUEUE queueHead);
|
||||
void LbqSignalQueueShutdown(PLINKED_BLOCKING_QUEUE queueHead);
|
||||
int LbqGetItemCount(PLINKED_BLOCKING_QUEUE queueHead);
|
||||
|
@ -38,9 +38,7 @@ typedef struct _LENTRY_INTERNAL {
|
||||
|
||||
// Init
|
||||
void initializeVideoDepacketizer(int pktSize) {
|
||||
if ((VideoCallbacks.capabilities & CAPABILITY_DIRECT_SUBMIT) == 0) {
|
||||
LbqInitializeLinkedBlockingQueue(&decodeUnitQueue, 15);
|
||||
}
|
||||
LbqInitializeLinkedBlockingQueue(&decodeUnitQueue, 15);
|
||||
|
||||
nextFrameNumber = 1;
|
||||
startFrameNumber = 0;
|
||||
@ -116,17 +114,12 @@ static void freeDecodeUnitList(PLINKED_BLOCKING_QUEUE_ENTRY entry) {
|
||||
}
|
||||
|
||||
void stopVideoDepacketizer(void) {
|
||||
if ((VideoCallbacks.capabilities & CAPABILITY_DIRECT_SUBMIT) == 0) {
|
||||
LbqSignalQueueShutdown(&decodeUnitQueue);
|
||||
}
|
||||
LbqSignalQueueShutdown(&decodeUnitQueue);
|
||||
}
|
||||
|
||||
// Cleanup video depacketizer and free malloced memory
|
||||
void destroyVideoDepacketizer(void) {
|
||||
if ((VideoCallbacks.capabilities & CAPABILITY_DIRECT_SUBMIT) == 0) {
|
||||
freeDecodeUnitList(LbqDestroyLinkedBlockingQueue(&decodeUnitQueue));
|
||||
}
|
||||
|
||||
freeDecodeUnitList(LbqDestroyLinkedBlockingQueue(&decodeUnitQueue));
|
||||
cleanupFrameState();
|
||||
}
|
||||
|
||||
@ -486,9 +479,7 @@ void requestDecoderRefresh(void) {
|
||||
waitingForIdrFrame = 1;
|
||||
|
||||
// Flush the decode unit queue
|
||||
if ((VideoCallbacks.capabilities & CAPABILITY_DIRECT_SUBMIT) == 0) {
|
||||
freeDecodeUnitList(LbqFlushQueueItems(&decodeUnitQueue));
|
||||
}
|
||||
freeDecodeUnitList(LbqFlushQueueItems(&decodeUnitQueue));
|
||||
|
||||
// Request the receive thread drop its state
|
||||
// on the next call. We can't do it here because
|
||||
@ -695,3 +686,7 @@ void queueRtpPacket(PRTPFEC_QUEUE_ENTRY queueEntryPtr) {
|
||||
free(existingEntry->allocPtr);
|
||||
}
|
||||
}
|
||||
|
||||
int LiGetPendingVideoFrames(void) {
|
||||
return LbqGetItemCount(&decodeUnitQueue);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user