From 4d69c683a4aeceb361f5a5ef375a0a034de68d66 Mon Sep 17 00:00:00 2001
From: Antoine Villeret <antoine@makula.be>
Date: Thu, 25 May 2023 13:56:03 +0200
Subject: [PATCH 1/2] fix Rivermax version extraction for SDK 1.30.16

---
 cmake/FindRivermax.cmake | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/cmake/FindRivermax.cmake b/cmake/FindRivermax.cmake
index b0dc707..927024e 100644
--- a/cmake/FindRivermax.cmake
+++ b/cmake/FindRivermax.cmake
@@ -180,12 +180,12 @@ endif()
 # Identify Rivermax files and version
 find_library_files(rivermax_api.h rivermax Rivermax_INCLUDE_DIR Rivermax_LIBRARY)
 if (Rivermax_INCLUDE_DIR)
-  file(STRINGS ${Rivermax_INCLUDE_DIR}/rivermax_api.h _RMAX_DEFS REGEX "^#define[ \t]+RMAX_(RELEASE_VERSION|BUILD)[ \t]")
+  file(STRINGS ${Rivermax_INCLUDE_DIR}/rivermax_defs.h _RMAX_DEFS REGEX "^#define[ \t]+RMX_VERSION_(MAJOR|MINOR|PATCH)[ \t]")
   if(_RMAX_DEFS)
-    foreach(_version_item "RELEASE_VERSION" "BUILD")
+    foreach(_version_item "VERSION_MAJOR" "VERSION_MINOR" "VERSION_PATCH")
       string(REGEX REPLACE ".*${_version_item}[ \t]+([0-9]+).*" "\\1" Rivermax_${_version_item} "${_RMAX_DEFS}")
     endforeach()
-    calculate_rivermax_version("${Rivermax_RELEASE_VERSION}" "${Rivermax_BUILD}" Rivermax_VERSION)
+    set(Rivermax_VERSION "${Rivermax_VERSION_MAJOR}.${Rivermax_VERSION_MINOR}.${Rivermax_VERSION_PATCH}")
     mark_as_advanced(Rivermax_VERSION Rivermax_VERSION_MAJOR Rivermax_VERSION_MINOR Rivermax_VERSION_PATCH)
   else()
     message(WARNING "Failed to determine the version of Rivermax!")

From da1f6f4ad1f687549d0902c1cc5841c6251327b2 Mon Sep 17 00:00:00 2001
From: Antoine Villeret <antoine@makula.be>
Date: Thu, 25 May 2023 14:36:11 +0200
Subject: [PATCH 2/2] fix build with SDK 1.30.16

fix https://github.com/NVIDIA/Rivermax/issues/4
the other 2 examples probably need similar changes however I can't build them since I'm running Windows
---
 generic_receiver/generic_receiver.cpp | 17 ++++++-----------
 rivermax_player/rivermax_player.cpp   | 18 +++++++-----------
 2 files changed, 13 insertions(+), 22 deletions(-)

diff --git a/generic_receiver/generic_receiver.cpp b/generic_receiver/generic_receiver.cpp
index d2fee58..d26437b 100644
--- a/generic_receiver/generic_receiver.cpp
+++ b/generic_receiver/generic_receiver.cpp
@@ -74,26 +74,21 @@ int main(int argc, char *argv[])
     // Print the library and app version.
     const char *rmax_version = rmax_get_version_string();
     static std::string app_version =
-        std::to_string(RMAX_API_MAJOR) + std::string(".") +
-        std::to_string(RMAX_API_MINOR) + std::string(".") +
-        std::to_string(RMAX_RELEASE_VERSION) + std::string(".") +
-        std::to_string(RMAX_BUILD);
+        std::to_string(RMX_VERSION_MAJOR) + std::string(".") +
+        std::to_string(RMX_VERSION_MINOR) + std::string(".") +
+        std::to_string(RMX_VERSION_PATCH);
     std::cout << "#########################################\n";
     std::cout << "## Rivermax library version:    " << rmax_version << "\n";
     std::cout << "## Application version:         " << app_version << "\n";
     std::cout << "#########################################\n";
 
     // Verify Rivermax library version matches (or is compatible) with this application.
-    unsigned int api_major;
-    unsigned int api_minor;
-    unsigned int release;
-    unsigned int build;
-    rmax_get_version(&api_major, &api_minor, &release, &build);
-    if (api_major != RMAX_API_MAJOR || api_minor < RMAX_API_MINOR) {
+    const rmx_version* version = rmx_get_version_numbers();
+    if (version->major != RMX_VERSION_MAJOR || version->minor < RMX_VERSION_MINOR) {
         std::cerr << "The current Rivermax version is not compatible with this application." << std::endl;
         exit(-1);
     }
-    if (api_minor > RMAX_API_MINOR || release != RMAX_RELEASE_VERSION || build != RMAX_BUILD) {
+    if (version->minor > RMX_VERSION_MINOR || version->patch != RMX_VERSION_PATCH) {
         std::cout << "WARNING!!! Rivermax and application versions are not aligned" << std::endl;
     }
 
diff --git a/rivermax_player/rivermax_player.cpp b/rivermax_player/rivermax_player.cpp
index e331e37..0a9ee17 100644
--- a/rivermax_player/rivermax_player.cpp
+++ b/rivermax_player/rivermax_player.cpp
@@ -2619,10 +2619,6 @@ static bool set_clock(rmax_clock_types clock_handler_type, std::vector<std::stri
 
 int main(int argc, char *argv[])
 {
-    unsigned int api_major;
-    unsigned int api_minor;
-    unsigned int release;
-    unsigned int build;
     int ret = 0;
 
     std::vector<std::string> sdp_files;
@@ -2756,10 +2752,10 @@ int main(int argc, char *argv[])
         }
     }
 
-    static std::string media_version = std::to_string(RMAX_API_MAJOR) + std::string(".") +
-                                       std::to_string(RMAX_API_MINOR)+ std::string(".") +
-                                       std::to_string(RMAX_RELEASE_VERSION) +
-                                       std::string(".") + std::to_string(RMAX_BUILD);
+    static std::string media_version =
+      std::to_string(RMX_VERSION_MAJOR) + std::string(".") +
+      std::to_string(RMX_VERSION_MINOR) + std::string(".") +
+      std::to_string(RMX_VERSION_PATCH);
 
     std::cout<<"#############################################\n";
     std::cout<<"## Rivermax library version:    " << rmax_version << std::endl;
@@ -2767,12 +2763,12 @@ int main(int argc, char *argv[])
     std::cout<<"#############################################\n";
 
     /* Verify version mismatch */
-    rmax_get_version(&api_major, &api_minor, &release, &build);
-    if (api_major != RMAX_API_MAJOR || api_minor < RMAX_API_MINOR) {
+    const rmx_version* version = rmx_get_version_numbers();
+    if (version->major != RMX_VERSION_MAJOR || version->minor < RMX_VERSION_MINOR) {
       std::cerr << "The current Rivermax version is not compatible with this version of rivermax player\n";
       return -1;
     }
-    if (api_minor > RMAX_API_MINOR || release != RMAX_RELEASE_VERSION || build != RMAX_BUILD) {
+    if (version->minor > RMX_VERSION_MINOR || version->patch != RMX_VERSION_PATCH) {
         void *ctx;
 
         ctx = color_set(COLOR_RED);