Skip to content

Commit

Permalink
Merge branch 'develop' into rtcpWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
moninom1 authored Aug 2, 2024
2 parents 38c90a3 + a4e293d commit 21dd82b
Show file tree
Hide file tree
Showing 16 changed files with 663 additions and 951 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/pr-desc-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@ jobs:
# Extract contents
# Extract contents
what_changed=$(echo "$pr_description" | sed -n -e '/\*What was changed?\*/,/\*/p' | sed '$d' | sed '1d')
why_changed=$(echo "$pr_description" | sed -n -e '/\*Why was it changed?\*/,/\*/p' | sed '$d' | sed '1d')
how_changed=$(echo "$pr_description" | sed -n -e '/\*How was it changed?\*/,/\*/p' | sed '$d' | sed '1d')
testing_done=$(echo "$pr_description" | sed -n -e '/\*What testing was done for the changes?\*/,/\*/p' | sed '$d' | sed '1d')
what_changed=$(echo "$pr_description" | sed -n -e '/\*What was changed?\*/,/\*/p' | wc -c)
why_changed=$(echo "$pr_description" | sed -n -e '/\*Why was it changed?\*/,/\*/p' | wc -c)
how_changed=$(echo "$pr_description" | sed -n -e '/\*How was it changed?\*/,/\*/p' | wc -c)
testing_done=$(echo "$pr_description" | sed -n -e '/\*What testing was done for the changes?\*/,/\*/p' | wc -c)
if [[ ${#what_changed} -lt $MIN_CHARS ]]; then
if [[ $what_changed -lt $MIN_CHARS ]]; then
echo "PR description for what changed section is either missing or too short."
error_occurred=1
fi
if [[ ${#why_changed} -lt $MIN_CHARS ]]; then
if [[ $why_changed -lt $MIN_CHARS ]]; then
echo "PR description for why it changed section is either missing or too short."
error_occurred=1
fi
if [[ ${#how_changed} -lt $MIN_CHARS ]]; then
if [[ $how_changed -lt $MIN_CHARS ]]; then
echo "PR description for how was it changed section is either missing or too short."
error_occurred=1
fi
if [[ ${#testing_done} -lt $MIN_CHARS ]]; then
if [[ $testing_done -lt $MIN_CHARS ]]; then
echo "PR description for testing section are either missing or too short."
error_occurred=1
fi
Expand Down
24 changes: 24 additions & 0 deletions CMake/Dependencies/libcorejson-CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.6.3)

project(libcorejson NONE)

if (BUILD_STATIC_LIBS OR WIN32)
set(LIBCOREJSON_SHARED_LIBS OFF)
else()
set(LIBCOREJSON_SHARED_LIBS ON)
endif()

include(ExternalProject)
ExternalProject_Add(libcorejson
GIT_REPOSITORY https://github.com/FreeRTOS/coreJSON.git
GIT_TAG dc1ab9130a1fb99b801a2a1fa8e9f42239f752be
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/build
PATCH_COMMAND git apply --ignore-whitespace ${CMAKE_CURRENT_LIST_DIR}/libcorejson-add-cmakelists.patch
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${OPEN_SRC_INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DBUILD_SHARED_LIBS=${LIBCOREJSON_SHARED_LIBS}
"-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} -fPIC"
BUILD_ALWAYS TRUE
TEST_COMMAND ""
)
30 changes: 30 additions & 0 deletions CMake/Dependencies/libcorejson-add-cmakelists.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..e48e611
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,24 @@
+cmake_minimum_required(VERSION 3.6.3)
+project(corejson C)
+
+include(jsonFilePaths.cmake)
+
+if(BUILD_SHARED_LIBS)
+ add_library(corejson SHARED ${JSON_SOURCES})
+else()
+ add_library(corejson STATIC ${JSON_SOURCES})
+endif()
+
+target_include_directories(corejson PUBLIC
+ ${JSON_INCLUDE_PUBLIC_DIRS})
+
+# install header files
+install(
+ FILES ${JSON_INCLUDE_PUBLIC_DIRS}/core_json.h
+ DESTINATION include/corejson)
+
+install(
+ TARGETS corejson
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
23 changes: 23 additions & 0 deletions CMake/Dependencies/libkvssignaling-CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 3.6.3)

project(libkvssignaling NONE)

include(ExternalProject)
if (BUILD_STATIC_LIBS OR WIN32)
set(LIBKVSSIGNALING_SHARED_LIBS OFF)
else()
set(LIBKVSSIGNALING_SHARED_LIBS ON)
endif()

ExternalProject_Add(libkvssignaling
GIT_REPOSITORY https://github.com/awslabs/amazon-kinesis-video-streams-signaling.git
GIT_TAG fb54c01f6f03838ed19ad5c1857bb9406e89f4df
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/build
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${OPEN_SRC_INSTALL_PREFIX}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DBUILD_SHARED_LIBS=${LIBKVSSIGNALING_SHARED_LIBS}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
BUILD_ALWAYS TRUE
TEST_COMMAND ""
)
4 changes: 3 additions & 1 deletion CMake/Utilities.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ function(build_dependency lib_name)
kvssdp
kvsstun
kvsrtp
kvsrtcp)
kvsrtcp
kvssignaling
corejson)
list(FIND supported_libs ${lib_name} index)
if(${index} EQUAL -1)
message(WARNING "${lib_name} is not supported to build from source")
Expand Down
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,20 @@ if(BUILD_DEPENDENCIES)
build_dependency(kvsrtp ${BUILD_ARGS})
build_dependency(kvsrtcp ${BUILD_ARGS})

set(BUILD_ARGS
-DBUILD_STATIC_LIBS=${BUILD_STATIC_LIBS}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS})

build_dependency(corejson ${BUILD_ARGS})

set(BUILD_ARGS
-DBUILD_STATIC_LIBS=${BUILD_STATIC_LIBS}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
"-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} -I${OPEN_SRC_INSTALL_PREFIX}/include/corejson")

build_dependency(kvssignaling ${BUILD_ARGS})

set(BUILD_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS})
Expand Down Expand Up @@ -414,6 +428,8 @@ target_link_libraries(
kvsstun
kvsrtp
kvsrtcp
kvssignaling
corejson
${CMAKE_THREAD_LIBS_INIT}
${OPENSSL_SSL_LIBRARY}
${OPENSSL_CRYPTO_LIBRARY}
Expand All @@ -439,6 +455,8 @@ target_link_libraries(
kvsstun
kvsrtp
kvsrtcp
kvssignaling
corejson
PRIVATE kvspicUtils
kvspicState
${CMAKE_THREAD_LIBS_INIT}
Expand Down
38 changes: 29 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,43 +81,63 @@ By default we download all the libraries from GitHub and build them locally, so

### Configuring on Windows

Install [MS Visual Studio Community / Enterprise](https://visualstudio.microsoft.com/vs/community/), [Strawberry perl](https://strawberryperl.com/), and [Chocolatey](https://chocolatey.org/install) if not installed already
#### Installing the dependencies / environment
Install [MS Visual Studio Community / Enterprise](https://visualstudio.microsoft.com/vs/community/), [Strawberry perl](https://strawberryperl.com/), and [Chocolatey](https://chocolatey.org/install) if not installed already.

Get the libraries by running the following in powershell
Install the libraries by running the following in `powershell`
```shell
choco install pkgconfiglite
choco install gstreamer
choco install gstreamer-devel
curl.exe -o C:\tools\pthreads-w32-2-9-1-release.zip ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip
mkdir C:\tools\pthreads-w32-2-9-1-release\
Expand-Archive -Path C:\tools\pthreads-w32-2-9-1-release.zip -DestinationPath C:\tools\pthreads-w32-2-9-1-release
```

Modify the path to the downloaded and unzipped PThreads in cmake in `build_windows_openssl.bat` if needed / unzipped at a path other than the one mentioned above
#### Customizing the `.github\build_windows_openssl.bat` file
If you unzipped at a path other than the one mentioned above / your pkg-config is in a different location, modify the path to the downloaded and unzipped PThreads in cmake in `.github\build_windows_openssl.bat`
```shell
cmake -G "NMake Makefiles" -DBUILD_TEST=TRUE -DEXT_PTHREAD_INCLUDE_DIR="C:/tools/pthreads-w32-2-9-1-release/Pre-built.2/include/" -DEXT_PTHREAD_LIBRARIES="C:/tools/pthreads-w32-2-9-1-release/Pre-built.2/lib/x64/libpthreadGC2.a" ..
cmake -G "NMake Makefiles" -DPKG_CONFIG_EXECUTABLE="D:\\gstreamer\\1.0\\x86_64\\bin\\pkg-config.exe" -DEXT_PTHREAD_INCLUDE_DIR="C:/tools/pthreads-w32-2-9-1-release/Pre-built.2/include/" -DEXT_PTHREAD_LIBRARIES="C:/tools/pthreads-w32-2-9-1-release/Pre-built.2/lib/x64/libpthreadGC2.a" ..
```
Modify the path to MSVC as well in the `build_windows_openssl.bat` if needed / installed a different version / location

If not using MSVC Enterprise 2022 or have MSVC in a different location modify the path to MSVC as well in the `.github\build_windows_openssl.bat`

##### Enterprise
```shell
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64
```

##### Community
```shell
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64
```

##### Custom version
```shell
call "C:\Program Files\Microsoft Visual Studio\<your-version>\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64
```

#### Allowing long paths
Allow long paths before we start the build
```shell
git config --system core.longpaths true
```

Note that if the paths are still too long (which can cause the build to fail unfortunately), we recommend renaming the folders to use shorter names and moving them to `C:/`

Build the SDK
#### Building the SDK

Run the script that we customized above

```shell
.github\build_windows_openssl.bat
```

To run the sample application, make sure that you've exported the following paths and appended them to env:Path for powershell
#### Customizing and setting PATH to run the samples
To run the sample application, make sure that you've exported the following paths and appended them to env:Path for `powershell`.

Modify the `<path-to-webrtc-root>\open-source\bin`, `<path-to-webrtc-root>\build`, `<path-to-pthreads-unzip-location>\pthreads-w32-2-9-1-release\Pre-built.2\dll\x64`
```shell
$env:Path += ';C:\webrtc\open-source\bin;C:\tools\pthreads-w32-2-9-1-release\Pre-built.2\dll\x64;C:\webrtc\build'
$env:Path += ';<path-to-webrtc-root>\open-source\bin;<path-to-pthreads-unzip-location>\pthreads-w32-2-9-1-release\Pre-built.2\dll\x64;<path-to-webrtc-root>\build'
```

### Dependency requirements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,8 @@ extern "C" {
#define STATUS_SIGNALING_JOIN_SESSION_CALL_FAILED STATUS_SIGNALING_BASE + 0x0000004a
#define STATUS_SIGNALING_JOIN_SESSION_CONNECTED_FAILED STATUS_SIGNALING_BASE + 0x0000004b
#define STATUS_SIGNALING_DESCRIBE_MEDIA_CALL_FAILED STATUS_SIGNALING_BASE + 0x0000004c
#define STATUS_SIGNALING_INVALID_OUTPUT_ROLE STATUS_SIGNALING_BASE + 0x0000004d
#define STATUS_SIGNALING_INVALID_OUTPUT_MESSAGE_TYPE STATUS_SIGNALING_BASE + 0x0000004e

/*!@} */

Expand Down
12 changes: 7 additions & 5 deletions src/source/PeerConnection/SessionDescription.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,13 @@ STATUS populateSingleMediaSection(PKvsPeerConnection pKvsPeerConnection, PKvsRtp
{
ENTERS();
STATUS retStatus = STATUS_SUCCESS;
UINT64 payloadType, rtxPayloadType;
UINT64 payloadType, rtxPayloadType, rtpMapValue;
BOOL containRtx = FALSE;
BOOL directionFound = FALSE;
UINT32 i, remoteAttributeCount, attributeCount = 0;
PRtcMediaStreamTrack pRtcMediaStreamTrack = &(pKvsRtpTransceiver->sender.track);
PSdpMediaDescription pSdpMediaDescriptionRemote;
PCHAR currentFmtp = NULL, rtpMapValue = NULL;
PCHAR currentFmtp = NULL, rtpMapValueChar = NULL;
CHAR remoteSdpAttributeValue[MAX_SDP_ATTRIBUTE_VALUE_LENGTH];
INT32 amountWritten = 0;

Expand All @@ -444,7 +444,6 @@ STATUS populateSingleMediaSection(PKvsPeerConnection pKvsPeerConnection, PKvsRtp
retStatus = hashTableGet(pKvsPeerConnection->pRtxTable, RTC_RTX_CODEC_VP8, &rtxPayloadType);
} else if (pRtcMediaStreamTrack->codec == RTC_CODEC_H265) {
retStatus = hashTableGet(pKvsPeerConnection->pRtxTable, RTC_RTX_CODEC_H265, &rtxPayloadType);
payloadType = DEFAULT_PAYLOAD_H265;
} else {
retStatus = STATUS_HASH_KEY_NOT_PRESENT;
}
Expand Down Expand Up @@ -666,6 +665,7 @@ STATUS populateSingleMediaSection(PKvsPeerConnection pKvsPeerConnection, PKvsRtp
amountWritten = SNPRINTF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue,
SIZEOF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue), "%" PRId64 " nack", payloadType);
CHK_ERR(amountWritten > 0, STATUS_INTERNAL_ERROR, "Full H264 rtcp-fb nack value could not be written");
attributeCount++;
amountWritten = SNPRINTF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue,
SIZEOF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue), "%" PRId64 " nack pli", payloadType);
CHK_ERR(amountWritten > 0, STATUS_INTERNAL_ERROR, "Full H264 rtcp-fb nack-pli value could not be written");
Expand Down Expand Up @@ -764,6 +764,7 @@ STATUS populateSingleMediaSection(PKvsPeerConnection pKvsPeerConnection, PKvsRtp
amountWritten = SNPRINTF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue,
SIZEOF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue), "%" PRId64 " nack", payloadType);
CHK_ERR(amountWritten > 0, STATUS_INTERNAL_ERROR, "Full H265 rtcp-fb nack value could not be written");
attributeCount++;
amountWritten = SNPRINTF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue,
SIZEOF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue), "%" PRId64 " nack pli", payloadType);
CHK_ERR(amountWritten > 0, STATUS_INTERNAL_ERROR, "Full H265 rtcp-fb nack-pli value could not be written");
Expand Down Expand Up @@ -795,11 +796,12 @@ STATUS populateSingleMediaSection(PKvsPeerConnection pKvsPeerConnection, PKvsRtp
attributeCount++;
}
} else if (pRtcMediaStreamTrack->codec == RTC_CODEC_UNKNOWN) {
CHK_STATUS(hashTableGet(pUnknownCodecRtpmapTable, unknownCodecHashTableKey, (PUINT64) &rtpMapValue));
CHK_STATUS(hashTableGet(pUnknownCodecRtpmapTable, unknownCodecHashTableKey, &rtpMapValue));
rtpMapValueChar = (PCHAR) rtpMapValue;
STRCPY(pSdpMediaDescription->sdpAttributes[attributeCount].attributeName, "rtpmap");
amountWritten =
SNPRINTF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue,
SIZEOF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue), "%" PRId64 " %s", payloadType, rtpMapValue);
SIZEOF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue), "%" PRId64 " %s", payloadType, rtpMapValueChar);
CHK_ERR(amountWritten > 0, STATUS_INTERNAL_ERROR, "Full Unknown rtpmap could not be written");
attributeCount++;
}
Expand Down
33 changes: 0 additions & 33 deletions src/source/Signaling/ChannelInfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,39 +317,6 @@ PCHAR getStringFromChannelType(SIGNALING_CHANNEL_TYPE type)
return typeStr;
}

SIGNALING_CHANNEL_ROLE_TYPE getChannelRoleTypeFromString(PCHAR type, UINT32 length)
{
// Assume the channel Deleting status first
SIGNALING_CHANNEL_ROLE_TYPE channelRoleType = SIGNALING_CHANNEL_ROLE_TYPE_UNKNOWN;

if (0 == STRNCMP(SIGNALING_CHANNEL_ROLE_TYPE_MASTER_STR, type, length)) {
channelRoleType = SIGNALING_CHANNEL_ROLE_TYPE_MASTER;
} else if (0 == STRNCMP(SIGNALING_CHANNEL_ROLE_TYPE_VIEWER_STR, type, length)) {
channelRoleType = SIGNALING_CHANNEL_ROLE_TYPE_VIEWER;
}

return channelRoleType;
}

PCHAR getStringFromChannelRoleType(SIGNALING_CHANNEL_ROLE_TYPE type)
{
PCHAR typeStr;

switch (type) {
case SIGNALING_CHANNEL_ROLE_TYPE_MASTER:
typeStr = SIGNALING_CHANNEL_ROLE_TYPE_MASTER_STR;
break;
case SIGNALING_CHANNEL_ROLE_TYPE_VIEWER:
typeStr = SIGNALING_CHANNEL_ROLE_TYPE_VIEWER_STR;
break;
default:
typeStr = SIGNALING_CHANNEL_ROLE_TYPE_UNKNOWN_STR;
break;
}

return typeStr;
}

// https://docs.aws.amazon.com/kinesisvideostreams-webrtc-dg/latest/devguide/kvswebrtc-how-iam.html#kinesis-using-iam-arn-format
// Example: arn:aws:kinesisvideo:region:account-id:channel/channel-name/code
STATUS validateKvsSignalingChannelArnAndExtractChannelName(PChannelInfo pChannelInfo, PUINT16 pStart, PUINT16 pNumChars)
Expand Down
24 changes: 0 additions & 24 deletions src/source/Signaling/ChannelInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ extern "C" {
#define SIGNALING_CHANNEL_TYPE_UNKNOWN_STR (PCHAR) "UNKOWN"
#define SIGNALING_CHANNEL_TYPE_SINGLE_MASTER_STR (PCHAR) "SINGLE_MASTER"

// Signaling channel role type string
#define SIGNALING_CHANNEL_ROLE_TYPE_UNKNOWN_STR (PCHAR) "UNKOWN"
#define SIGNALING_CHANNEL_ROLE_TYPE_MASTER_STR (PCHAR) "MASTER"
#define SIGNALING_CHANNEL_ROLE_TYPE_VIEWER_STR (PCHAR) "VIEWER"

// Min and max for the message TTL value
#define MIN_SIGNALING_MESSAGE_TTL_VALUE (5 * HUNDREDS_OF_NANOS_IN_A_SECOND)
#define MAX_SIGNALING_MESSAGE_TTL_VALUE (120 * HUNDREDS_OF_NANOS_IN_A_SECOND)
Expand Down Expand Up @@ -86,25 +81,6 @@ SIGNALING_CHANNEL_TYPE getChannelTypeFromString(PCHAR, UINT32);
*/
PCHAR getStringFromChannelType(SIGNALING_CHANNEL_TYPE);

/**
* Returns the signaling channel Role from a string
*
* @param - PCHAR - IN - String representation of the channel role
* @param - UINT32 - IN - String length
*
* @return - Signaling channel type
*/
SIGNALING_CHANNEL_ROLE_TYPE getChannelRoleTypeFromString(PCHAR, UINT32);

/**
* Returns the signaling channel role type string
*
* @param - SIGNALING_CHANNEL_TYPE - IN - Signaling channel type
*
* @return - Signaling channel type string
*/
PCHAR getStringFromChannelRoleType(SIGNALING_CHANNEL_ROLE_TYPE);

/**
* Determines whether or not the channel arn is valid
* If VALID it extracts the channel name
Expand Down
Loading

0 comments on commit 21dd82b

Please sign in to comment.