Skip to content
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
64 changes: 64 additions & 0 deletions test/pi-cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Use a base image with git and bash
##################################################################################################################################
# Docker Build Command : docker build -t pi-cli-docker1 . --build-arg EMAIL="<email>" --build-arg PASSWORD="<password>"
# Here <email> is comcast email address and <password> can be generated from https://code.rdkcentral.com/r/settings/
##################################################################################################################################

FROM ubuntu:latest

ARG EMAIL
ARG PASSWORD

# Install required packages
RUN apt-get update && \
apt-get install -y git curl bash && \
apt-get install -y sudo && \
apt-get install -y python3 python3-pip ninja-build bash cmake && \
pip3 install --break-system-packages meson && \
apt-get clean

# Set environment variables to disable Git prompts
ENV GIT_TERMINAL_PROMPT=0
ENV GIT_ASKPASS=echo

# Create /root/.netrc with credentials
RUN mkdir -p /root && \
echo "machine code.rdkcentral.com login $EMAIL password $PASSWORD" > /root/.netrc && \
chmod 600 /root/.netrc

# Set the working directory inside the container
WORKDIR /app

# Clone the middleware-player-interface repo
RUN git clone https://github.com/rdkcentral/middleware-player-interface.git

# Set working directory to the cloned repo
WORKDIR /app/middleware-player-interface


# Run the script
RUN ./install-middleware.sh

# Copy & Apply patch for Ubuntu
WORKDIR /app/middleware-player-interface
RUN git apply ./test/pi-cli/pi-cli-ubuntu.patch

# to find libcjson, your path may vary
RUN PKG_CONFIG_PATH="/app/middleware-player-interface/.libs/lib/pkgconfig"

# Create Build directory for pi-cli
RUN mkdir -p /app/middleware-player-interface/build

# Set working directory to test/pi-cli/build
WORKDIR /app/middleware-player-interface/build

# Enable pi-cli
RUN cmake -DBUILD_PICLI=ON ..

# Build pi-cli
RUN cmake --build .

# RUN ./test/pi-cli/pi-cli

# Keep Container Running
CMD ["tail -f /dev/null"]
73 changes: 67 additions & 6 deletions test/pi-cli/commandProcessing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <iostream>
#include <algorithm>
#include <sstream>
#include <fstream>

// --- CommandExecutor Implementation ---
void CommandExecutor::threadFunction() {
Expand Down Expand Up @@ -182,14 +183,13 @@ void setAudioVolumeCommand(InterfacePlayerRDK& player, const std::vector<std::st
}

void setupStreamCommand(InterfacePlayerRDK& player, const std::vector<std::string>& params) {
if (params.size() != 3) {
std::cout << "Usage: setupstream <streamId> <playerInstance(int)> <url>\n";
if (params.size() != 2) {
std::cout << "Usage: setupstream <streamId> <url>\n";
return;
}
int streamId = std::stoi(params[0]);
void* _this = reinterpret_cast<void*>(std::stoul(params[1]));
std::string url = params[2];
int result = player.SetupStream(streamId, _this, url);
std::string url = params[1];
int result = player.InterfacePlayer_SetupStream(streamId, url);
std::cout << "SetupStream executed. Result: " << result << "\n";
}

Expand Down Expand Up @@ -420,6 +420,66 @@ void setVideoRectangle(InterfacePlayerRDK& player, const std::vector<std::string
}
}

void injectFragmentCommand(InterfacePlayerRDK& player, const std::vector<std::string>& params) {
// Usage: injectfragment <mediaType:int> <filePath> [pts] [dts] [duration] [fragmentPTSoffset]
if (params.size() < 3) {
std::cout << "Usage: injectfragment <mediaType:int> <filePath> <initFragment> [pts] [dts] [duration] [fragmentPTSoffset]\n";
return;
}
int mediaType = std::stoi(params[0]);
std::string filePath = params[1];

bool initFragment = (params[2] == "1" || params[2] == "true");
double pts = params.size() > 3 ? std::stod(params[3]) : 0.0;
double dts = params.size() > 4 ? std::stod(params[4]) : 0.0;
double duration = params.size() > 5 ? std::stod(params[5]) : 0.0;
double fragmentPTSoffset = params.size() > 6 ? std::stod(params[6]) : 0.0;

// Read file into buffer
std::ifstream file(filePath, std::ios::binary | std::ios::ate);
if (!file) {
std::cout << "injectfragment: Failed to open file: " << filePath << "\n";
return;
}
std::streamsize size = file.tellg();
if (size <= 0) {
std::cout << "injectfragment: File is empty: " << filePath << "\n";
return;
}
file.seekg(0, std::ios::beg);
std::vector<char> buffer(size);
if (!file.read(buffer.data(), size)) {
std::cout << "injectfragment: Failed to read file: " << filePath << "\n";
return;
}

// Default flags for SendHelper
bool copy = true;
bool discontinuity = false;
bool notifyFirstBufferProcessed = false;
bool sendNewSegmentEvent = false;
bool resetTrickUTC = false;
bool firstBufferPushed = false;

bool ok = player.SendHelper(
mediaType,
buffer.data(),
buffer.size(),
pts,
dts,
duration,
fragmentPTSoffset,
copy,
initFragment,
discontinuity,
notifyFirstBufferProcessed,
sendNewSegmentEvent,
resetTrickUTC,
firstBufferPushed
);
std::cout << "injectfragment executed. Success: " << (ok ? "true" : "false") << "\n";
}

// --- Register All Commands ---
std::map<std::string, Command> initializeCommands(CommandExecutor& executor, InterfacePlayerRDK& player) {
std::map<std::string, Command> commands;
Expand Down Expand Up @@ -462,6 +522,7 @@ std::map<std::string, Command> initializeCommands(CommandExecutor& executor, Int
commands.emplace("removeprobes", Command("removeprobes", "Remove probes.", [&player](const std::vector<std::string>& params) { removeProbesCommand(player, params); }));
commands.emplace("clearprotectionevent", Command("clearprotectionevent", "Clear protection event.", [&player](const std::vector<std::string>& params) { clearProtectionEventCommand(player, params); }));
commands.emplace("setvideorectangle", Command("setvideorectangle", "Usage: setvideorectangle <x> <y> <width> <height>", [&](const std::vector<std::string>& params) { setVideoRectangle(player, params); }));

commands.emplace("injectfragment", Command("injectfragment", "Inject a fragment into the player. Usage: injectfragment <mediaType:int> <filePath> [pts] [dts] [duration] [fragmentPTSoffset]", [&player](const std::vector<std::string>& params) { injectFragmentCommand(player, params); } ) );

return commands;
}
13 changes: 12 additions & 1 deletion test/pi-cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <readline/readline.h>
#include <readline/history.h>
#include <unistd.h>
#include <gst/gst.h>
#include "InterfacePlayerRDK.h"
#include "commandProcessing.h"

Expand Down Expand Up @@ -76,7 +77,7 @@ void initializeReadline() {
};
}

int main(int argc, char *argv[]) {
int picli_main(int argc, char *argv[]) {
// Create the command executor
CommandExecutor executor;
InterfacePlayerRDK player;
Expand Down Expand Up @@ -131,3 +132,13 @@ int main(int argc, char *argv[]) {

return 0;
}

int
main (int argc, char *argv[])
{
#if defined(__APPLE__)
return gst_macos_main ((GstMainFunc) picli_main, argc, argv, NULL);
#else
return picli_main (argc, argv);
#endif
}
59 changes: 59 additions & 0 deletions test/pi-cli/pi-cli-ubuntu.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 65fd51f..89f9076 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,6 +14,8 @@ pkg_check_modules(GST REQUIRED gstreamer-plugins-base-1.0)
pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0)
pkg_check_modules(GSTREAMERBASE REQUIRED gstreamer-app-1.0)
pkg_check_modules(GSTREAMERVIDEO REQUIRED gstreamer-video-1.0)
+pkg_check_modules(OPENSSL REQUIRED openssl)
+pkg_check_modules(LIBCJSON REQUIRED libcjson)

include_directories(${GST_INCLUDE_DIRS} ${GSTREAMER_INCLUDE_DIRS} ${GSTREAMERBASE_INCLUDE_DIRS} ${GSTREAMERVIDEO_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_SOURCE_DIR} subtitle playerisobmff isobmff
@@ -102,6 +104,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_VARIABLE "YES")
else()
set(USE_MAC_FOR_RANDOM_GEN "-DUSE_MAC_FOR_RANDOM_GEN")
+ pkg_check_modules(GLIB REQUIRED glib-2.0)
+ message("GLIB $GLIB_INCLUDE_DIRS")
+
endif(CMAKE_SYSTEM_NAME STREQUAL Darwin)

set(LIBPLAYERGSTINTERFACE_HEADERS
diff --git a/install-middleware.sh b/install-middleware.sh
index c4488f1..cb5e236 100755
--- a/install-middleware.sh
+++ b/install-middleware.sh
@@ -39,7 +39,7 @@ source scripts/install_dependencies.sh
# gtest install and build
source scripts/install_gtest.sh
# glib install and build
-source scripts/install_glib.sh
+# source scripts/install_glib.sh
# libdash install and build
source scripts/install_libdash.sh
# libcjson install and build
@@ -130,8 +130,8 @@ INSTALL_STATUS_ARR+=("install_build_googletest check passed.")

# Build glib
#
-install_build_glib_fn "${OPTION_CLEAN}"
-INSTALL_STATUS_ARR+=("install_build_glib check passed.")
+# install_build_glib_fn "${OPTION_CLEAN}"
+# INSTALL_STATUS_ARR+=("install_build_glib check passed.")

# Build libcjson
install_build_libcjson_fn "${OPTION_CLEAN}"
diff --git a/scripts/install_dependencies.sh b/scripts/install_dependencies.sh
index 937856b..aaf02ab 100644
--- a/scripts/install_dependencies.sh
+++ b/scripts/install_dependencies.sh
@@ -114,6 +114,7 @@ function install_pkgs_linux_fn()
install_package_fn git
install_package_fn cmake
install_package_fn gcc
+ install_package_fn libglib2.0-dev
install_package_fn g++
install_package_fn libcurl4-openssl-dev
install_package_fn libgstreamer1.0-dev