Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark datachannel specific code explicitly #1666

Merged
merged 1 commit into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ endif()

if (ENABLE_DATA_CHANNEL)
add_definitions(-DENABLE_DATA_CHANNEL)
set (DATACHANNEL_SRC
src/source/PeerConnection/DataChannel.c
src/source/Sctp/Sctp.c
)
endif()

if (INSTRUMENTED_ALLOCATORS)
Expand All @@ -271,14 +275,19 @@ file(
WEBRTC_CLIENT_SOURCE_FILES
"src/source/Crypto/*.c"
"src/source/Ice/*.c"
"src/source/PeerConnection/*.c"
"src/source/PeerConnection/JitterBuffer.c"
"src/source/PeerConnection/jsmn.c"
"src/source/PeerConnection/PeerConnection.c"
"src/source/PeerConnection/Retransmitter.c"
"src/source/PeerConnection/Rtcp.c"
"src/source/PeerConnection/Rtp.c"
"src/source/PeerConnection/SessionDescription.c"
"src/source/Rtcp/*.c"
"src/source/Rtp/*.c"
"src/source/Rtp/Codecs/*.c"
"src/source/Sdp/*.c"
"src/source/Srtp/*.c"
"src/source/Stun/*.c"
"src/source/Sctp/*.c"
"src/source/Metrics/*.c")

if (USE_OPENSSL)
Expand All @@ -295,7 +304,7 @@ include_directories(${OPEN_SRC_INSTALL_PREFIX}/include)
include_directories(${KINESIS_VIDEO_WEBRTC_CLIENT_SRC}/src/include)
include_directories(${KINESIS_VIDEO_WEBRTC_CLIENT_SRC}/src/ice)

add_library(kvsWebrtcClient ${LINKAGE} ${WEBRTC_CLIENT_SOURCE_FILES})
add_library(kvsWebrtcClient ${LINKAGE} ${WEBRTC_CLIENT_SOURCE_FILES} ${DATACHANNEL_SRC})

target_link_libraries(
kvsWebrtcClient
Expand Down
6 changes: 6 additions & 0 deletions src/source/PeerConnection/PeerConnection.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ STATUS allocateSrtp(PKvsPeerConnection pKvsPeerConnection)
return retStatus;
}

#ifdef ENABLE_DATA_CHANNEL
STATUS allocateSctpSortDataChannelsDataCallback(UINT64 customData, PHashEntry pHashEntry)
{
STATUS retStatus = STATUS_SUCCESS;
Expand Down Expand Up @@ -106,6 +107,7 @@ STATUS allocateSctp(PKvsPeerConnection pKvsPeerConnection)
CleanUp:
return retStatus;
}
#endif

VOID onInboundPacket(UINT64 customData, PBYTE buff, UINT32 buffLen)
{
Expand All @@ -130,9 +132,11 @@ VOID onInboundPacket(UINT64 customData, PBYTE buff, UINT32 buffLen)
if (buff[0] > 19 && buff[0] < 64) {
dtlsSessionProcessPacket(pKvsPeerConnection->pDtlsSession, buff, &signedBuffLen);

#ifdef ENABLE_DATA_CHANNEL
if (signedBuffLen > 0) {
CHK_STATUS(putSctpPacket(pKvsPeerConnection->pSctpSession, buff, signedBuffLen));
}
#endif

CHK_STATUS(dtlsSessionIsInitFinished(pKvsPeerConnection->pDtlsSession, &isDtlsConnected));
if (isDtlsConnected) {
Expand Down Expand Up @@ -776,7 +780,9 @@ STATUS freePeerConnection(PRtcPeerConnection* ppPeerConnection)

/* Free structs that have their own thread. SCTP has threads created by SCTP library. IceAgent has the
* connectionListener thread. Free SCTP first so it wont try to send anything through ICE. */
#ifdef ENABLE_DATA_CHANNEL
CHK_LOG_ERR(freeSctpSession(&pKvsPeerConnection->pSctpSession));
#endif
CHK_LOG_ERR(freeIceAgent(&pKvsPeerConnection->pIceAgent));

// free transceivers
Expand Down