mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-18 01:15:46 +00:00
Add some method comments
This commit is contained in:
parent
129951975f
commit
4d4a6c236e
@ -8,12 +8,13 @@ static char rtspTargetUrl[256];
|
|||||||
static char sessionIdString[16];
|
static char sessionIdString[16];
|
||||||
static int hasSessionId = 0;
|
static int hasSessionId = 0;
|
||||||
|
|
||||||
// GFE 2.1.1
|
/* GFE 2.1.1 */
|
||||||
#define RTSP_CLIENT_VERSION 10
|
#define RTSP_CLIENT_VERSION 10
|
||||||
#define RTSP_CLIENT_VERSION_S "10"
|
#define RTSP_CLIENT_VERSION_S "10"
|
||||||
|
|
||||||
#define RTSP_MAX_RESP_SIZE 16384
|
#define RTSP_MAX_RESP_SIZE 16384
|
||||||
|
|
||||||
|
/* Create RTSP Option */
|
||||||
static POPTION_ITEM createOptionItem(char* option, char* content)
|
static POPTION_ITEM createOptionItem(char* option, char* content)
|
||||||
{
|
{
|
||||||
POPTION_ITEM item = malloc(sizeof(*item));
|
POPTION_ITEM item = malloc(sizeof(*item));
|
||||||
@ -44,6 +45,7 @@ static POPTION_ITEM createOptionItem(char* option, char* content)
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Add an option to the RTSP Message */
|
||||||
static int addOption(PRTSP_MESSAGE msg, char* option, char* content)
|
static int addOption(PRTSP_MESSAGE msg, char* option, char* content)
|
||||||
{
|
{
|
||||||
POPTION_ITEM item = createOptionItem(option, content);
|
POPTION_ITEM item = createOptionItem(option, content);
|
||||||
@ -57,6 +59,7 @@ static int addOption(PRTSP_MESSAGE msg, char* option, char* content)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Create an RTSP Request */
|
||||||
static int initializeRtspRequest(PRTSP_MESSAGE msg, char* command, char* target)
|
static int initializeRtspRequest(PRTSP_MESSAGE msg, char* command, char* target)
|
||||||
{
|
{
|
||||||
char sequenceNumberStr[16];
|
char sequenceNumberStr[16];
|
||||||
@ -137,6 +140,7 @@ Exit:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Terminate the RTSP Handshake process by closing the socket */
|
||||||
void terminateRtspHandshake(void) {
|
void terminateRtspHandshake(void) {
|
||||||
if (sock != INVALID_SOCKET) {
|
if (sock != INVALID_SOCKET) {
|
||||||
closesocket(sock);
|
closesocket(sock);
|
||||||
@ -144,6 +148,7 @@ void terminateRtspHandshake(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Send RTSP OPTIONS request */
|
||||||
static int requestOptions(PRTSP_MESSAGE response) {
|
static int requestOptions(PRTSP_MESSAGE response) {
|
||||||
RTSP_MESSAGE request;
|
RTSP_MESSAGE request;
|
||||||
int ret;
|
int ret;
|
||||||
@ -157,6 +162,7 @@ static int requestOptions(PRTSP_MESSAGE response) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Send RTSP DESCRIBE request */
|
||||||
static int requestDescribe(PRTSP_MESSAGE response) {
|
static int requestDescribe(PRTSP_MESSAGE response) {
|
||||||
RTSP_MESSAGE request;
|
RTSP_MESSAGE request;
|
||||||
int ret;
|
int ret;
|
||||||
@ -178,6 +184,7 @@ static int requestDescribe(PRTSP_MESSAGE response) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Send RTSP SETUP request */
|
||||||
static int setupStream(PRTSP_MESSAGE response, char* target) {
|
static int setupStream(PRTSP_MESSAGE response, char* target) {
|
||||||
RTSP_MESSAGE request;
|
RTSP_MESSAGE request;
|
||||||
int ret;
|
int ret;
|
||||||
@ -207,6 +214,7 @@ static int setupStream(PRTSP_MESSAGE response, char* target) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Send RTSP PLAY request*/
|
||||||
static int playStream(PRTSP_MESSAGE response, char* target) {
|
static int playStream(PRTSP_MESSAGE response, char* target) {
|
||||||
RTSP_MESSAGE request;
|
RTSP_MESSAGE request;
|
||||||
int ret;
|
int ret;
|
||||||
@ -225,6 +233,7 @@ static int playStream(PRTSP_MESSAGE response, char* target) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Send RTSP ANNOUNCE message */
|
||||||
static int sendVideoAnnounce(PRTSP_MESSAGE response, PSTREAM_CONFIGURATION streamConfig) {
|
static int sendVideoAnnounce(PRTSP_MESSAGE response, PSTREAM_CONFIGURATION streamConfig) {
|
||||||
RTSP_MESSAGE request;
|
RTSP_MESSAGE request;
|
||||||
int ret;
|
int ret;
|
||||||
@ -263,6 +272,7 @@ static int sendVideoAnnounce(PRTSP_MESSAGE response, PSTREAM_CONFIGURATION strea
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Perform RTSP Handshake with the streaming server machine as part of the connection process */
|
||||||
int performRtspHandshake(IP_ADDRESS addr, PSTREAM_CONFIGURATION streamConfigPtr) {
|
int performRtspHandshake(IP_ADDRESS addr, PSTREAM_CONFIGURATION streamConfigPtr) {
|
||||||
struct in_addr inaddr;
|
struct in_addr inaddr;
|
||||||
|
|
||||||
|
@ -26,11 +26,13 @@ typedef struct _BUFFER_DESC {
|
|||||||
unsigned int length;
|
unsigned int length;
|
||||||
} BUFFER_DESC, *PBUFFER_DESC;
|
} BUFFER_DESC, *PBUFFER_DESC;
|
||||||
|
|
||||||
|
/* Init */
|
||||||
void initializeVideoDepacketizer(int pktSize) {
|
void initializeVideoDepacketizer(int pktSize) {
|
||||||
LbqInitializeLinkedBlockingQueue(&decodeUnitQueue, 15);
|
LbqInitializeLinkedBlockingQueue(&decodeUnitQueue, 15);
|
||||||
nominalPacketDataLength = pktSize - sizeof(NV_VIDEO_PACKET);
|
nominalPacketDataLength = pktSize - sizeof(NV_VIDEO_PACKET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Free malloced memory in AvcFrameState*/
|
||||||
static void cleanupAvcFrameState(void) {
|
static void cleanupAvcFrameState(void) {
|
||||||
PLENTRY lastEntry;
|
PLENTRY lastEntry;
|
||||||
|
|
||||||
@ -49,6 +51,7 @@ static void dropAvcFrameState(void) {
|
|||||||
cleanupAvcFrameState();
|
cleanupAvcFrameState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Cleanup video depacketizer and free malloced memory */
|
||||||
void destroyVideoDepacketizer(void) {
|
void destroyVideoDepacketizer(void) {
|
||||||
PLINKED_BLOCKING_QUEUE_ENTRY entry, nextEntry;
|
PLINKED_BLOCKING_QUEUE_ENTRY entry, nextEntry;
|
||||||
|
|
||||||
@ -63,18 +66,22 @@ void destroyVideoDepacketizer(void) {
|
|||||||
cleanupAvcFrameState();
|
cleanupAvcFrameState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Returns 1 if candidate is a frame start and 0 otherwise */
|
||||||
static int isSeqFrameStart(PBUFFER_DESC candidate) {
|
static int isSeqFrameStart(PBUFFER_DESC candidate) {
|
||||||
return (candidate->length == 4 && candidate->data[candidate->offset + candidate->length - 1] == 1);
|
return (candidate->length == 4 && candidate->data[candidate->offset + candidate->length - 1] == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Returns 1 if candidate an AVC start and 0 otherwise */
|
||||||
static int isSeqAvcStart(PBUFFER_DESC candidate) {
|
static int isSeqAvcStart(PBUFFER_DESC candidate) {
|
||||||
return (candidate->data[candidate->offset + candidate->length - 1] == 1);
|
return (candidate->data[candidate->offset + candidate->length - 1] == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Returns 1 if candidate is padding and 0 otherwise */
|
||||||
static int isSeqPadding(PBUFFER_DESC candidate) {
|
static int isSeqPadding(PBUFFER_DESC candidate) {
|
||||||
return (candidate->data[candidate->offset + candidate->length - 1] == 0);
|
return (candidate->data[candidate->offset + candidate->length - 1] == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Returns 1 on success, 0 otherwise */
|
||||||
static int getSpecialSeq(PBUFFER_DESC current, PBUFFER_DESC candidate) {
|
static int getSpecialSeq(PBUFFER_DESC current, PBUFFER_DESC candidate) {
|
||||||
if (current->length < 3) {
|
if (current->length < 3) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -111,6 +118,7 @@ static int getSpecialSeq(PBUFFER_DESC current, PBUFFER_DESC candidate) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Reassemble the frame with the given frame number */
|
||||||
static void reassembleAvcFrame(int frameNumber) {
|
static void reassembleAvcFrame(int frameNumber) {
|
||||||
if (nalChainHead != NULL) {
|
if (nalChainHead != NULL) {
|
||||||
PDECODE_UNIT du = (PDECODE_UNIT) malloc(sizeof(*du));
|
PDECODE_UNIT du = (PDECODE_UNIT) malloc(sizeof(*du));
|
||||||
@ -142,6 +150,7 @@ static void reassembleAvcFrame(int frameNumber) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Given a decode unit, get the next one in the linked blocking queue */
|
||||||
int getNextDecodeUnit(PDECODE_UNIT *du) {
|
int getNextDecodeUnit(PDECODE_UNIT *du) {
|
||||||
int err = LbqWaitForQueueElement(&decodeUnitQueue, (void**)du);
|
int err = LbqWaitForQueueElement(&decodeUnitQueue, (void**)du);
|
||||||
if (err == LBQ_SUCCESS) {
|
if (err == LBQ_SUCCESS) {
|
||||||
@ -152,6 +161,7 @@ int getNextDecodeUnit(PDECODE_UNIT *du) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Cleanup a decode unit by freeing malloced memory */
|
||||||
void freeDecodeUnit(PDECODE_UNIT decodeUnit) {
|
void freeDecodeUnit(PDECODE_UNIT decodeUnit) {
|
||||||
PLENTRY lastEntry;
|
PLENTRY lastEntry;
|
||||||
|
|
||||||
@ -259,6 +269,7 @@ static void processRtpPayloadSlow(PNV_VIDEO_PACKET videoPacket, PBUFFER_DESC cur
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return 1 if packet is the first one in the frame */
|
||||||
static int isFirstPacket(char flags) {
|
static int isFirstPacket(char flags) {
|
||||||
// Clear the picture data flag
|
// Clear the picture data flag
|
||||||
flags &= ~FLAG_CONTAINS_PIC_DATA;
|
flags &= ~FLAG_CONTAINS_PIC_DATA;
|
||||||
@ -268,7 +279,9 @@ static int isFirstPacket(char flags) {
|
|||||||
flags == FLAG_SOF);
|
flags == FLAG_SOF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Adds a fragment directly to the queue */
|
||||||
static void processRtpPayloadFast(PNV_VIDEO_PACKET videoPacket, BUFFER_DESC location) {
|
static void processRtpPayloadFast(PNV_VIDEO_PACKET videoPacket, BUFFER_DESC location) {
|
||||||
|
// FIXME not using videoPacket parameter??
|
||||||
queueFragment(location.data, location.offset, location.length);
|
queueFragment(location.data, location.offset, location.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,6 +452,7 @@ void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Add an RTP Packet to the queue */
|
||||||
void queueRtpPacket(PRTP_PACKET rtpPacket, int length) {
|
void queueRtpPacket(PRTP_PACKET rtpPacket, int length) {
|
||||||
int dataOffset;
|
int dataOffset;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user