Skip to content
Open
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
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pkg_check_modules(UUID REQUIRED uuid)
# option is enabled in the Yocto recipe. This flag determines whether middleware-player-interface
# components should be sourced from external repositories or built from the local aamp repository.
if(CMAKE_EXTERNAL_PLAYER_INTERFACE_DEPENDENCIES)
message("CMAKE_EXTERNAL_PLAYER_INTERFACE_DEPENDENCIES set")
pkg_check_modules(BASECONVERSION REQUIRED libbaseconversion)
pkg_check_modules(PLAYERLOGMANAGER REQUIRED libplayerlogmanager)
pkg_check_modules(PLAYERFBINTERFACE REQUIRED libplayerfbinterface)
Expand Down Expand Up @@ -253,15 +254,15 @@ endif()

add_subdirectory(test/rialtoPOC)

if (CMAKE_INBUILT_AAMP_DEPENDENCIES)
#if (CMAKE_INBUILT_AAMP_DEPENDENCIES)
message("Building aamp support libraries")
include_directories(support/aampmetrics)

# Building ABR for other dependent modules
add_subdirectory(support/aampabr)
add_subdirectory(support/aampmetrics)
set(LIBAAMP_DEPENDS ${LIBAAMP_DEPENDS} metrics)
endif()
#endif()

message("Adding tsb folder")
add_subdirectory(tsb)
Expand Down
255 changes: 175 additions & 80 deletions scripts/install_middleware_interfaces.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@
# PREREQUISITES:
# This script requires the following variables to be set:
# - LOCAL_DEPS_BUILD_DIR: Directory where dependencies will be built and installed
# - MIDDLEWARE_PLAYER_INTERFACE_BRANCH: Git branch to checkout for middleware-player-interface
# - AAMP_DIR: Path to the aamp repository (used to auto-detect sibling middleware-player-interface)
# - INSTALL_STATUS_ARR: Array to store installation status messages
#
# This script requires the following functions to be available:
# Optional variables (from install_options.sh):
# - OPTION_MIDDLEWARE_PLAYER_INTERFACE_LOCAL_PATH: explicit path to a local middleware-player-interface repo
# - MIDDLEWARE_PLAYER_INTERFACE_COMMIT_ID: commit to checkout when cloning from GitHub (fallback only)
#
# This script requires the following functions to be available (for GitHub clone fallback only):
# - do_clone_fn: Function to clone git repositories
#
# Required tools: git, cmake, make, pkg-config
# Required tools: cmake, make, pkg-config (git only needed for GitHub clone fallback)

# Sync internal middleware headers to .libs/include.
# When using --player-interface-source=internal (the default), headers in
Expand Down Expand Up @@ -81,11 +85,6 @@ function install_build_middleware_interface_fn()
return 1
fi

if [[ -z "$MIDDLEWARE_PLAYER_INTERFACE_COMMIT_ID" ]]; then
echo "Error: MIDDLEWARE_PLAYER_INTERFACE_COMMIT_ID variable is not set"
return 1
fi

# Check if LOCAL_DEPS_BUILD_DIR exists or can be created
if [[ ! -d "$LOCAL_DEPS_BUILD_DIR" ]]; then
echo "Creating LOCAL_DEPS_BUILD_DIR: $LOCAL_DEPS_BUILD_DIR"
Expand All @@ -95,14 +94,8 @@ function install_build_middleware_interface_fn()
}
fi

# Check if do_clone_fn function exists
if ! declare -f do_clone_fn > /dev/null; then
echo "Error: do_clone_fn function is not available"
return 1
fi

# Check for required tools
for tool in git cmake make pkg-config; do
for tool in cmake make pkg-config; do
if ! command -v "$tool" &> /dev/null; then
echo "Error: Required tool '$tool' is not installed"
return 1
Expand All @@ -114,86 +107,188 @@ function install_build_middleware_interface_fn()
declare -g -a INSTALL_STATUS_ARR=()
fi

cd "$LOCAL_DEPS_BUILD_DIR" || {
echo "Error: Failed to change directory to $LOCAL_DEPS_BUILD_DIR"
return 1
}
# Resolve the middleware-player-interface source directory.
# Priority: (1) explicit --middleware-player-interface-local-path option,
# (2) sibling repo at <parent-of-AAMP_DIR>/middleware-player-interface,
# (3) clone from GitHub into LOCAL_DEPS_BUILD_DIR.
local mw_src=""
local mw_cloned=false

# $OPTION_CLEAN == true
if [[ "$1" == true ]] ; then
echo "middleware-player-interface clean"
if [ -d middleware-player-interface ] ; then
rm -rf middleware-player-interface || {
echo "Error: Failed to remove middleware-player-interface directory"
return 1
}
# uninstall?
rm -rf "$LOCAL_DEPS_BUILD_DIR/include/middleware-player-interface" || {
echo "Warning: Failed to remove middleware-player-interface include directory"
}
if [[ -n "${OPTION_MIDDLEWARE_PLAYER_INTERFACE_LOCAL_PATH:-}" ]]; then
mw_src="$(cd "${OPTION_MIDDLEWARE_PLAYER_INTERFACE_LOCAL_PATH}" 2>/dev/null && pwd -P)" || {
echo "Error: --middleware-player-interface-local-path '${OPTION_MIDDLEWARE_PLAYER_INTERFACE_LOCAL_PATH}' does not exist"
return 1
}
echo "Using explicit local middleware-player-interface: ${mw_src}"
else
local sibling_path
sibling_path="$(dirname "${AAMP_DIR}")/middleware-player-interface"
if [[ -d "${sibling_path}" ]]; then
mw_src="$(cd "${sibling_path}" && pwd -P)"
echo "Using sibling middleware-player-interface repo: ${mw_src}"
fi
fi

if [ -d "middleware-player-interface" ]; then
echo "middleware-player-interface is already installed"
INSTALL_STATUS_ARR+=("middleware-player-interface was already installed.")
else
echo "Installing middleware-player-interface..."

# Clone the repository with error handling
if ! do_clone_fn https://github.com/rdkcentral/middleware-player-interface.git; then
echo "Error: Failed to clone middleware-player-interface repository"
# If no local source found, clone from GitHub
if [[ -z "${mw_src}" ]]; then
if ! command -v git &> /dev/null; then
echo "Error: git is not installed (needed to clone middleware-player-interface)"
return 1
fi

cd middleware-player-interface || {
echo "Error: Failed to change directory to middleware-player-interface"
return 1
}

local middleware_commit_id="${MIDDLEWARE_PLAYER_INTERFACE_COMMIT_ID}"

echo "Checking out commit: $middleware_commit_id"
if ! git checkout "$middleware_commit_id"; then
echo "Error: Failed to checkout commit '$middleware_commit_id'"
if [[ -z "$MIDDLEWARE_PLAYER_INTERFACE_COMMIT_ID" ]]; then
echo "Error: MIDDLEWARE_PLAYER_INTERFACE_COMMIT_ID variable is not set (needed for GitHub clone)"
return 1
fi

mkdir -p build || {
echo "Error: Failed to create build directory"
if ! declare -f do_clone_fn > /dev/null; then
echo "Error: do_clone_fn function is not available"
return 1
}
cd build || {
echo "Error: Failed to change directory to build"
fi

cd "$LOCAL_DEPS_BUILD_DIR" || {
echo "Error: Failed to change directory to $LOCAL_DEPS_BUILD_DIR"
return 1
}

echo "Running cmake configuration..."
if ! cmake .. -DCMAKE_INSTALL_PREFIX="${LOCAL_DEPS_BUILD_DIR}" -DCMAKE_PLATFORM_UBUNTU=ON; then
echo "Error: CMake configuration failed"
return 1

# $OPTION_CLEAN == true
if [[ "$1" == true ]] ; then
echo "middleware-player-interface clean"
if [ -d middleware-player-interface ] ; then
rm -rf middleware-player-interface || {
echo "Error: Failed to remove middleware-player-interface directory"
return 1
}
fi
fi

echo "Building middleware-player-interface..."
if ! make; then
echo "Error: Build failed"
return 1

if [ -d "middleware-player-interface" ]; then
echo "middleware-player-interface clone already present in .libs"
mw_src="${LOCAL_DEPS_BUILD_DIR}/middleware-player-interface"
else
echo "Cloning middleware-player-interface from GitHub..."
if ! do_clone_fn https://github.com/rdkcentral/middleware-player-interface.git; then
echo "Error: Failed to clone middleware-player-interface repository"
return 1
fi

mw_src="${LOCAL_DEPS_BUILD_DIR}/middleware-player-interface"
mw_cloned=true

cd "${mw_src}" || {
echo "Error: Failed to change directory to middleware-player-interface"
return 1
}

local middleware_commit_id="${MIDDLEWARE_PLAYER_INTERFACE_COMMIT_ID}"
echo "Checking out commit: $middleware_commit_id"
if ! git checkout "$middleware_commit_id"; then
echo "Error: Failed to checkout commit '$middleware_commit_id'"
return 1
fi
fi

echo "Installing middleware-player-interface..."
if ! make install; then
echo "Error: Installation failed"
return 1
fi

# Build and install from mw_src
local mw_build_marker="${LOCAL_DEPS_BUILD_DIR}/.mw_installed"

# On clean, remove installed artifacts so we rebuild
if [[ "$1" == true ]] ; then
rm -f "${mw_build_marker}"
rm -rf "${LOCAL_DEPS_BUILD_DIR}/include/middleware-player-interface" 2>/dev/null || true
fi

if [[ -f "${mw_build_marker}" ]] && [[ "${mw_cloned}" == false ]]; then
echo "middleware-player-interface headers/libs already installed (use clean to force rebuild)"
INSTALL_STATUS_ARR+=("middleware-player-interface was already installed.")
return 0
fi

local mw_build_dir="${mw_src}/build_aamp"
rm -rf "${mw_build_dir}"
mkdir -p "${mw_build_dir}" || {
echo "Error: Failed to create build directory ${mw_build_dir}"
return 1
}

cd "${mw_build_dir}" || {
echo "Error: Failed to change directory to ${mw_build_dir}"
return 1
}

echo "Running cmake configuration for middleware-player-interface..."
local cmake_platform_flag=""
if [[ "$OSTYPE" == "linux"* ]]; then
cmake_platform_flag="-DCMAKE_PLATFORM_UBUNTU=ON"
fi

local pkg_config_path_arg=""
if [[ -d "${LOCAL_DEPS_BUILD_DIR}/lib/pkgconfig" ]]; then
pkg_config_path_arg="${LOCAL_DEPS_BUILD_DIR}/lib/pkgconfig"
fi

# On macOS, add GStreamer pkg-config paths (framework install takes priority, homebrew is fallback)
if [[ "$OSTYPE" == "darwin"* ]]; then
local _GST_FRAMEWORK_PKG="/Library/Frameworks/GStreamer.framework/Versions/1.0/lib/pkgconfig"
if [ -d "${_GST_FRAMEWORK_PKG}" ]; then
pkg_config_path_arg="${_GST_FRAMEWORK_PKG}:${pkg_config_path_arg}"
else
local _GST_BREW_PREFIX
_GST_BREW_PREFIX=$(brew --prefix gstreamer 2>/dev/null) || true
if [ -n "${_GST_BREW_PREFIX}" ] && [ -d "${_GST_BREW_PREFIX}/lib/pkgconfig" ]; then
pkg_config_path_arg="${_GST_BREW_PREFIX}/lib/pkgconfig:${pkg_config_path_arg}"
local _GST_BASE_PREFIX
_GST_BASE_PREFIX=$(brew --prefix gst-plugins-base 2>/dev/null) || true
if [ -n "${_GST_BASE_PREFIX}" ] && [ -d "${_GST_BASE_PREFIX}/lib/pkgconfig" ]; then
pkg_config_path_arg="${_GST_BASE_PREFIX}/lib/pkgconfig:${pkg_config_path_arg}"
fi
fi
fi
fi

# Create pkg-config directory if it doesn't exist
mkdir -p "$LOCAL_DEPS_BUILD_DIR/lib/pkgconfig" || {
echo "Error: Failed to create pkgconfig directory"
return 1
}
local openssl_root_flag=""
if [[ "$OSTYPE" == "darwin"* ]]; then
local _OPENSSL_PREFIX
_OPENSSL_PREFIX=$(brew --prefix openssl@3 2>/dev/null) || true
if [ -n "${_OPENSSL_PREFIX}" ]; then
openssl_root_flag="-DOPENSSL_ROOT_DIR=${_OPENSSL_PREFIX}"
if [ -d "${_OPENSSL_PREFIX}/lib/pkgconfig" ]; then
pkg_config_path_arg="${_OPENSSL_PREFIX}/lib/pkgconfig:${pkg_config_path_arg}"
fi
fi
local _UUID_PREFIX
_UUID_PREFIX=$(brew --prefix ossp-uuid 2>/dev/null) || true
if [ -n "${_UUID_PREFIX}" ] && [ -d "${_UUID_PREFIX}/lib/pkgconfig" ]; then
pkg_config_path_arg="${_UUID_PREFIX}/lib/pkgconfig:${pkg_config_path_arg}"
fi
fi

if ! PKG_CONFIG_PATH="${pkg_config_path_arg}:${PKG_CONFIG_PATH:-}" cmake "${mw_src}" \
-DCMAKE_INSTALL_PREFIX="${LOCAL_DEPS_BUILD_DIR}" \
${cmake_platform_flag} \
${openssl_root_flag} \
-DCMAKE_BUILD_TYPE=Debug; then
echo "Error: CMake configuration failed for middleware-player-interface"
return 1
fi

echo "middleware-player-interface installation completed successfully"
INSTALL_STATUS_ARR+=("middleware was successfully installed.")
echo "Building middleware-player-interface..."
if ! make; then
echo "Error: Build failed for middleware-player-interface"
return 1
fi

echo "Installing middleware-player-interface..."
if ! make install; then
echo "Error: Installation failed for middleware-player-interface"
return 1
fi

# Create pkg-config directory if it doesn't exist
mkdir -p "$LOCAL_DEPS_BUILD_DIR/lib/pkgconfig" || {
echo "Error: Failed to create pkgconfig directory"
return 1
}

touch "${mw_build_marker}"
echo "middleware-player-interface installation completed successfully"
INSTALL_STATUS_ARR+=("middleware was successfully installed.")
}
14 changes: 10 additions & 4 deletions scripts/install_options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@

# default values
OPTION_AAMP_BRANCH="dev_sprint_25_2"
OPTION_MIDDLEWARE_PLAYER_INTERFACE_COMMIT_ID="4c1d90a24338c342599ac098e247a8d644ea28e1"
OPTION_PLAYER_INTERFACE_SOURCE="internal"
OPTION_MIDDLEWARE_PLAYER_INTERFACE_COMMIT_ID="$(git ls-remote https://github.com/rdkcentral/middleware-player-interface.git refs/heads/develop | awk '{print $1}')"
OPTION_PLAYER_INTERFACE_SOURCE="external"
OPTION_MIDDLEWARE_PLAYER_INTERFACE_LOCAL_PATH=""
OPTION_BUILD_DIR=""
OPTION_BUILD_ARGS=""
OPTION_CLEAN=false
Expand Down Expand Up @@ -59,6 +60,10 @@ function install_options_fn()
OPTION_MIDDLEWARE_PLAYER_INTERFACE_COMMIT_ID="${1#*=}"
echo "Middleware player interface commit ID: ${OPTION_MIDDLEWARE_PLAYER_INTERFACE_COMMIT_ID}"
;;
--middleware-player-interface-local-path=*)
OPTION_MIDDLEWARE_PLAYER_INTERFACE_LOCAL_PATH="${1#*=}"
echo "Middleware player interface local path: ${OPTION_MIDDLEWARE_PLAYER_INTERFACE_LOCAL_PATH}"
;;
*)
remaining_args+=("$1")
;;
Expand Down Expand Up @@ -141,8 +146,9 @@ function install_options_fn()
[-s] Skip subtec build and installation]"
echo " Note: Subtec is built by default but can be rebuilt separately with the subtec
[-k] Build aamp-cli Kotlin module (Linux and MacOS only)]
[--player-interface-source=internal|external] Choose player interface source (default: internal)
[--middleware-player-interface-commit-id=<commit>] Specify commit ID when using external (default: 269f2b1a38492c26f2f7cfb41d194029a8ea88d2)
[--player-interface-source=internal|external] Choose player interface source (default: external)
[--middleware-player-interface-commit-id=<commit>] Specify commit ID when using external source (cloned from GitHub)
[--middleware-player-interface-local-path=<path>] Use a local directory instead of cloning (default: auto-detect sibling ../middleware-player-interface)
[-t] Remove .libs and build directories before build (full rebuild)
[-u] Enable Ubuntu address sanitizer (Linux only)"

Expand Down
Loading