Skip to content

Commit

Permalink
create data channel sample (#1203)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
niyatim23 authored and disa6302 committed Dec 5, 2023
1 parent 298d3d4 commit beb1a37
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions samples/kvsWebRTCClientViewer.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,28 @@ INT32 main(INT32 argc, CHAR* argv[])
DLOGI("[KVS Viewer] Data Channel open now...");
#endif

#ifdef ENABLE_DATA_CHANNEL
PRtcDataChannel pDataChannel = NULL;
PRtcPeerConnection pPeerConnection = pSampleStreamingSession->pPeerConnection;
SIZE_T datachannelLocalOpenCount = 0;

// Creating a new datachannel on the peer connection of the existing sample streaming session
retStatus = createDataChannel(pPeerConnection, pChannelName, NULL, &pDataChannel);
if(retStatus != STATUS_SUCCESS) {
printf("[KVS Viewer] createDataChannel(): operation returned status code: 0x%08x \n", retStatus);
goto CleanUp;
}
printf("[KVS Viewer] Creating data channel...completed\n");

// Setting a callback for when the data channel is open
retStatus = dataChannelOnOpen(pDataChannel, (UINT64) &datachannelLocalOpenCount, dataChannelOnOpenCallback);
if(retStatus != STATUS_SUCCESS) {
printf("[KVS Viewer] dataChannelOnOpen(): operation returned status code: 0x%08x \n", retStatus);
goto CleanUp;
}
printf("[KVS Viewer] Data Channel open now...\n");
#endif

// Block until interrupted
while (!ATOMIC_LOAD_BOOL(&pSampleConfiguration->interrupted) && !ATOMIC_LOAD_BOOL(&pSampleStreamingSession->terminateFlag)) {
THREAD_SLEEP(HUNDREDS_OF_NANOS_IN_A_SECOND);
Expand Down

0 comments on commit beb1a37

Please sign in to comment.