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