Skip to content

Commit 49b1cac

Browse files
jdelaplaniyatim23disa6302ela34
authored
Realign branches during transition (#1257)
* create data channel sample (#1203) * create data channel sample * moved variables to Samples.h, encapsulated with ENABLE_DATA_CHANNEL directive * removed unused variables, moved variable declarations to the top of a block * create data channel sample * moved variables to Samples.h, encapsulated with ENABLE_DATA_CHANNEL directive * Cancel the thread once mediaThreadStarted flag is set to false (#1227) * Initial stale PR template (#1226) * Update stale issue template * Testing every minute * Fix stale issue PR template (#1234) No code changed. Just a template change. So merging * Add bug and question label * Switch stale PR action to daily cadence * [FIX] When protocol in DCEP header of data channel open command is not empty, there is a check preventing the data channel to be opened. Now protocol length is correctly handled to avoid check failing. (#1228) Co-authored-by: Niyati Maheshwari <niyatim23@gmail.com> Co-authored-by: Divya Sampath Kumar <disa6302@colorado.edu> Co-authored-by: ela34 <8700736+ela34@users.noreply.github.com>
1 parent 00e00b2 commit 49b1cac

File tree

5 files changed

+100
-5
lines changed

5 files changed

+100
-5
lines changed
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Close Stale Issues
2+
3+
# Controls when the action will be run
4+
on:
5+
schedule:
6+
- cron: "0 0 * * *"
7+
8+
jobs:
9+
cleanup:
10+
runs-on: ubuntu-latest
11+
name: Close stale issues
12+
steps:
13+
- uses: actions/stale@v4.0.0
14+
with:
15+
stale-issue-message: It looks like this issue has not been active for a long time. If the issue is not resolved, please add an update to the ticket, else it will be automatically resolved in a few days.
16+
close-issue-message: The issue has been stale for a while and hence it has been auto-closed. If the issue persists, feel free to open a new issue with details.
17+
18+
# labels to be added
19+
stale-issue-label: closing-soon
20+
any-of-labels: question,bug
21+
22+
# SLAs
23+
days-before-issue-stale: 7
24+
days-before-issue-close: 3
25+
26+
27+
repo-token: ${{ secrets.GITHUB_TOKEN }}
28+
loglevel: DEBUG
29+
# Set dry-run to true to not perform label or close actions.
30+
dry-run: false
31+
32+

samples/Common.c

+12
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ VOID onDataChannelMessage(UINT64 customData, PRtcDataChannel pDataChannel, BOOL
2121
} else {
2222
DLOGI("DataChannel String Message: %.*s\n", pMessageLen, pMessage);
2323
}
24+
// Send a response to the message sent by the viewer
25+
STATUS retStatus = STATUS_SUCCESS;
26+
retStatus = dataChannelSend(pDataChannel, FALSE, (PBYTE) MASTER_DATA_CHANNEL_MESSAGE, STRLEN(MASTER_DATA_CHANNEL_MESSAGE));
27+
if(retStatus != STATUS_SUCCESS) {
28+
DLOGI("[KVS Master] dataChannelSend(): operation returned status code: 0x%08x \n", retStatus);
29+
}
2430
}
2531

2632
VOID onDataChannel(UINT64 customData, PRtcDataChannel pRtcDataChannel)
@@ -1019,6 +1025,12 @@ STATUS freeSampleConfiguration(PSampleConfiguration* ppSampleConfiguration)
10191025
MUTEX_LOCK(pSampleConfiguration->sampleConfigurationObjLock);
10201026
locked = TRUE;
10211027
}
1028+
// Cancel the media thread
1029+
if(!(pSampleConfiguration->mediaThreadStarted)) {
1030+
DLOGD("Canceling media thread");
1031+
THREAD_CANCEL(pSampleConfiguration->mediaSenderTid);
1032+
}
1033+
10221034
for (i = 0; i < pSampleConfiguration->streamingSessionCount; ++i) {
10231035
retStatus = gatherIceServerStats(pSampleConfiguration->sampleStreamingSessionList[i]);
10241036
if (STATUS_FAILED(retStatus)) {

samples/Samples.h

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ extern "C" {
4646
#define IOT_CORE_ROLE_ALIAS ((PCHAR) "AWS_IOT_CORE_ROLE_ALIAS")
4747
#define IOT_CORE_THING_NAME ((PCHAR) "AWS_IOT_CORE_THING_NAME")
4848

49+
#define MASTER_DATA_CHANNEL_MESSAGE "This message is from the KVS Master"
50+
#define VIEWER_DATA_CHANNEL_MESSAGE "This message is from the KVS Viewer"
51+
4952
/* Uncomment the following line in order to enable IoT credentials checks in the provided samples */
5053
//#define IOT_CORE_ENABLE_CREDENTIALS 1
5154

samples/kvsWebRTCClientViewer.c

+47-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,31 @@
22

33
extern PSampleConfiguration gSampleConfiguration;
44

5+
// onMessage callback for a message received by the viewer on a data channel
6+
VOID dataChannelOnMessageCallback(UINT64 customData, PRtcDataChannel pDataChannel, BOOL isBinary, PBYTE pMessage, UINT32 pMessageLen)
7+
{
8+
UNUSED_PARAM(customData);
9+
UNUSED_PARAM(pDataChannel);
10+
if (isBinary) {
11+
DLOGI("DataChannel Binary Message");
12+
} else {
13+
DLOGI("DataChannel String Message: %.*s\n", pMessageLen, pMessage);
14+
}
15+
}
16+
17+
// onOpen callback for the onOpen event of a viewer created data channel
18+
VOID dataChannelOnOpenCallback(UINT64 customData, PRtcDataChannel pDataChannel) {
19+
STATUS retStatus = STATUS_SUCCESS;
20+
DLOGI("New DataChannel has been opened %s \n", pDataChannel->name);
21+
dataChannelOnMessage(pDataChannel, customData, dataChannelOnMessageCallback);
22+
ATOMIC_INCREMENT((PSIZE_T) customData);
23+
// Sending first message to the master over the data channel
24+
retStatus = dataChannelSend(pDataChannel, FALSE, (PBYTE) VIEWER_DATA_CHANNEL_MESSAGE, STRLEN(VIEWER_DATA_CHANNEL_MESSAGE));
25+
if(retStatus != STATUS_SUCCESS){
26+
DLOGI("[KVS Viewer] dataChannelSend(): operation returned status code: 0x%08x \n", retStatus);
27+
}
28+
}
29+
530
INT32 main(INT32 argc, CHAR* argv[])
631
{
732
STATUS retStatus = STATUS_SUCCESS;
@@ -81,13 +106,11 @@ INT32 main(INT32 argc, CHAR* argv[])
81106
// Initialize streaming session
82107
MUTEX_LOCK(pSampleConfiguration->sampleConfigurationObjLock);
83108
locked = TRUE;
84-
85109
retStatus = createSampleStreamingSession(pSampleConfiguration, NULL, FALSE, &pSampleStreamingSession);
86110
if (retStatus != STATUS_SUCCESS) {
87111
printf("[KVS Viewer] createSampleStreamingSession(): operation returned status code: 0x%08x \n", retStatus);
88112
goto CleanUp;
89113
}
90-
91114
printf("[KVS Viewer] Creating streaming session...completed\n");
92115
pSampleConfiguration->sampleStreamingSessionList[pSampleConfiguration->streamingSessionCount++] = pSampleStreamingSession;
93116

@@ -165,6 +188,28 @@ INT32 main(INT32 argc, CHAR* argv[])
165188
goto CleanUp;
166189
}
167190

191+
#ifdef ENABLE_DATA_CHANNEL
192+
PRtcDataChannel pDataChannel = NULL;
193+
PRtcPeerConnection pPeerConnection = pSampleStreamingSession->pPeerConnection;
194+
SIZE_T datachannelLocalOpenCount = 0;
195+
196+
// Creating a new datachannel on the peer connection of the existing sample streaming session
197+
retStatus = createDataChannel(pPeerConnection, pChannelName, NULL, &pDataChannel);
198+
if(retStatus != STATUS_SUCCESS) {
199+
printf("[KVS Viewer] createDataChannel(): operation returned status code: 0x%08x \n", retStatus);
200+
goto CleanUp;
201+
}
202+
printf("[KVS Viewer] Creating data channel...completed\n");
203+
204+
// Setting a callback for when the data channel is open
205+
retStatus = dataChannelOnOpen(pDataChannel, (UINT64) &datachannelLocalOpenCount, dataChannelOnOpenCallback);
206+
if(retStatus != STATUS_SUCCESS) {
207+
printf("[KVS Viewer] dataChannelOnOpen(): operation returned status code: 0x%08x \n", retStatus);
208+
goto CleanUp;
209+
}
210+
printf("[KVS Viewer] Data Channel open now...\n");
211+
#endif
212+
168213
// Block until interrupted
169214
while (!ATOMIC_LOAD_BOOL(&pSampleConfiguration->interrupted) && !ATOMIC_LOAD_BOOL(&pSampleStreamingSession->terminateFlag)) {
170215
THREAD_SLEEP(HUNDREDS_OF_NANOS_IN_A_SECOND);

src/source/Sctp/Sctp.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,17 @@ STATUS handleDcepPacket(PSctpSession pSctpSession, UINT32 streamId, PBYTE data,
305305
ENTERS();
306306
STATUS retStatus = STATUS_SUCCESS;
307307
UINT16 labelLength = 0;
308+
UINT16 protocolLength = 0;
308309

309310
// Assert that is DCEP of type DataChannelOpen
310311
CHK(length > SCTP_DCEP_HEADER_LENGTH && data[0] == DCEP_DATA_CHANNEL_OPEN, STATUS_SUCCESS);
311312

312-
MEMCPY(&labelLength, data + 8, SIZEOF(UINT16));
313-
putInt16((PINT16) &labelLength, labelLength);
313+
MEMCPY(&labelLength, data + 8, SIZEOF(UINT16));
314+
MEMCPY(&protocolLength, data + 10, SIZEOF(UINT16));
315+
putInt16((PINT16) &labelLength, labelLength);
316+
putInt16((PINT16) &protocolLength, protocolLength);
314317

315-
CHK((labelLength + SCTP_DCEP_HEADER_LENGTH) >= length, STATUS_SCTP_INVALID_DCEP_PACKET);
318+
CHK((labelLength + protocolLength + SCTP_DCEP_HEADER_LENGTH) >= length, STATUS_SCTP_INVALID_DCEP_PACKET);
316319

317320
pSctpSession->sctpSessionCallbacks.dataChannelOpenFunc(pSctpSession->sctpSessionCallbacks.customData, streamId, data + SCTP_DCEP_HEADER_LENGTH,
318321
labelLength);

0 commit comments

Comments
 (0)