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
26 changes: 23 additions & 3 deletions test/pi-cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)

include_directories(${PI_ROOT})

# Find GStreamer packages
find_package(PkgConfig REQUIRED)
pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0)
pkg_check_modules(GSTREAMERBASE REQUIRED gstreamer-app-1.0)

include_directories(${GSTREAMER_INCLUDE_DIRS})
include_directories(${GSTREAMERBASE_INCLUDE_DIRS})

# Add the executable (now includes commandProcessing.cpp)
add_executable(pi-cli
main.cpp
commandProcessing.cpp
)

# Use pkg-config to locate the readline library
find_package(PkgConfig REQUIRED)
pkg_check_modules(READLINE REQUIRED readline)

if (READLINE_FOUND)
Expand All @@ -29,9 +36,22 @@ else()
message(FATAL_ERROR "Readline library not found. Please install it.")
endif()

target_link_libraries(pi-cli playergstinterface)
# Add OpenSSL requirement so we can link crypto/ssl symbols
find_package(OpenSSL REQUIRED)

target_link_libraries(pi-cli playergstinterface OpenSSL::Crypto OpenSSL::SSL)
if(BUILD_WITH_COVERAGE)
target_compile_options(pi-cli PRIVATE --coverage)
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.13")
target_link_options(pi-cli PRIVATE --coverage)
else()
# Fallback for older CMake versions that do not support target_link_options
set_target_properties(pi-cli PROPERTIES LINK_FLAGS "--coverage")
endif()
message(STATUS "pi-cli: Building with coverage instrumentation")
endif()

# Additional warnings and flags for development
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(pi-cli PRIVATE -Wall -Wextra -pedantic)
endif()
endif()
50 changes: 31 additions & 19 deletions test/pi-cli/commandProcessing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,38 +184,36 @@ void initializeSourceForPlayerCommand(InterfacePlayerRDK& player, const std::vec

void configurePipelineCommand(InterfacePlayerRDK& player, const std::vector<std::string>& params) {
// The signature from InterfacePlayerRDK.h:
// void ConfigurePipeline(int, int, int, int, bool, bool, bool, bool, int32_t, gint, const char *, int, bool, std::string url);
if (params.size() != 14) {
std::cout << "Usage: configurepipeline <int> <int> <int> <int> <bool> <bool> <bool> <bool> <int32> <gint> <pipelineName> <int> <bool> <url>\n";

if (params.size() != 12) {
std::cout << "Usage: configurepipeline <int> <int> <int> <bool> <bool> <bool> <int32> <gint> <pipelineName> <int> <bool> <url>\n";
return;
}

try {
int format = std::stoi(params[0]);
int audioFormat = std::stoi(params[1]);
int auxFormat = std::stoi(params[2]);
int subFormat = std::stoi(params[3]);
bool bESChangeStatus = (params[4] == "1" || params[4] == "true");
bool forwardAudioToAux = (params[5] == "1" || params[5] == "true");
bool setReadyAfterPipelineCreation = (params[6] == "1" || params[6] == "true");
bool isSubEnable = (params[7] == "1" || params[7] == "true");
int32_t trackId = std::stoi(params[8]);
gint rate = std::stoi(params[9]);
std::string pipelineNameStr = params[10];
int subFormat = std::stoi(params[2]);
bool bESChangeStatus = (params[3] == "1" || params[3] == "true");
bool setReadyAfterPipelineCreation = (params[4] == "1" || params[4] == "true");
bool isSubEnable = (params[5] == "1" || params[5] == "true");
int32_t trackId = std::stoi(params[6]);
gint rate = std::stoi(params[7]);
std::string pipelineNameStr = params[8];
const char* pipelineName = pipelineNameStr.c_str();
int PipelinePriority = std::stoi(params[11]);
bool subBool = (params[12] == "1" || params[12] == "true");
std::string url = params[13];
int PipelinePriority = std::stoi(params[9]);
bool subBool = (params[10] == "1" || params[10] == "true");
std::string url = params[11];

player.ConfigurePipeline(
format, audioFormat, auxFormat, subFormat,
bESChangeStatus, forwardAudioToAux, setReadyAfterPipelineCreation, isSubEnable,
format, audioFormat, subFormat,
bESChangeStatus, setReadyAfterPipelineCreation, isSubEnable,
trackId, rate, pipelineName, PipelinePriority, subBool, url
);
std::cout << "ConfigurePipeline executed.\n";
} catch (const std::exception& e) {
std::cout << "Error parsing parameters: " << e.what() << "\n";
std::cout << "Usage: configurepipeline <int> <int> <int> <int> <bool> <bool> <bool> <bool> <int32> <gint> <pipelineName> <int> <bool> <url>\n";
std::cout << "Usage: configurepipeline <int> <int> <int> <bool> <bool> <bool> <int32> <gint> <pipelineName> <int> <bool> <url>\n";
}
}

Expand Down Expand Up @@ -279,6 +277,19 @@ void pauseCommand(InterfacePlayerRDK& player, const std::vector<std::string>& pa
std::cout << "Pause executed. Result: " << (result ? "true" : "false") << "\n";
}

void resumeCommand(InterfacePlayerRDK& player, const std::vector<std::string>& params) {
if (!params.empty()) {
std::cout << "Usage: resume\n";
return;
}
bool result = player.Pause(false, false);
std::cout << "Resume executed. Success: " << (result ? "true" : "false") << "\n";
if (result) {
std::cout << "Pipeline state: " << (player.IsPipelinePaused() ? "Paused" : "Playing") << "\n";
std::cout << "Current position: " << player.GetPositionMilliseconds() << " ms\n";
}
}

void resumeInjectorCommand(InterfacePlayerRDK& player, const std::vector<std::string>& params) {
player.ResumeInjector();
std::cout << "ResumeInjector executed.\n";
Expand Down Expand Up @@ -595,12 +606,13 @@ std::map<std::string, Command> initializeCommands(CommandExecutor& executor, Int
commands.emplace("setplayername", Command("setplayername", "Set player name. Usage: setplayername <name>", [&player](const std::vector<std::string>& params) { setPlayerNameCommand(player, params); }));
commands.emplace("setpreferreddrm", Command("setpreferreddrm", "Set preferred DRM. Usage: setpreferreddrm <drmID>", [&player](const std::vector<std::string>& params) { setPreferredDRMCommand(player, params); }));
commands.emplace("initializesourceforplayer", Command("initializesourceforplayer", "Initialize source. Usage: initializesourceforplayer <playerInstance(int)> <source(int)> <mediaType>", [&player](const std::vector<std::string>& params) { initializeSourceForPlayerCommand(player, params); }));
commands.emplace("configurepipeline", Command("configurepipeline", "Configure pipeline. Usage: configurepipeline <int> <int> <int> <int> <bool> <bool> <bool> <bool> <int32> <gint> <pipelineName> <int> <bool> <url>", [&player](const std::vector<std::string>& params) { configurePipelineCommand(player, params); }));
commands.emplace("configurepipeline", Command("configurepipeline", "Configure pipeline. Usage: configurepipeline <int> <int> <int> <bool> <bool> <bool> <int32> <gint> <pipelineName> <int> <bool> <url>", [&player](const std::vector<std::string>& params) { configurePipelineCommand(player, params); }));
commands.emplace("setpauseonstart", Command("setpauseonstart", "Enable/disable pause on start playback. Usage: setpauseonstart [true|false]", [&player](const std::vector<std::string>& params) { setPauseOnStartCommand(player, params); }));
commands.emplace("setplaybackrate", Command("setplaybackrate", "Set playback rate. Usage: setplaybackrate <rate>", [&player](const std::vector<std::string>& params) { setPlayBackRateCommand(player, params); }));
commands.emplace("setaudiovolume", Command("setaudiovolume", "Set audio volume. Usage: setaudiovolume <volume>", [&player](const std::vector<std::string>& params) { setAudioVolumeCommand(player, params); }));
commands.emplace("setupstream", Command("setupstream", "Setup stream. Usage: setupstream <streamId> <playerInstance(int)> <url>", [&player](const std::vector<std::string>& params) { setupStreamCommand(player, params); }));
commands.emplace("pause", Command("pause", "Pause the pipeline. Usage: pause [pause(bool)] [forceStop(bool)]", [&player](const std::vector<std::string>& params) { pauseCommand(player, params); }));
commands.emplace("resume", Command("resume", "Resume playback. Usage: resume", [&player](const std::vector<std::string>& params) { resumeCommand(player, params); }));
commands.emplace("resumeinjector", Command("resumeinjector", "Resume injector.", [&player](const std::vector<std::string>& params) { resumeInjectorCommand(player, params); }));
commands.emplace("stop", Command("stop", "Stop playback.", [&player](const std::vector<std::string>& params) { stopCommand(player, params); }));
commands.emplace("flush", Command("flush", "Flush pipeline.", [&player](const std::vector<std::string>& params) { flushCommand(player, params); }));
Expand Down
1 change: 1 addition & 0 deletions test/pi-cli/commandProcessing.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ void setPlayBackRateCommand(InterfacePlayerRDK& player, const std::vector<std::s
void setAudioVolumeCommand(InterfacePlayerRDK& player, const std::vector<std::string>& params);
void setupStreamCommand(InterfacePlayerRDK& player, const std::vector<std::string>& params);
void pauseCommand(InterfacePlayerRDK& player, const std::vector<std::string>& params);
void resumeCommand(InterfacePlayerRDK& player, const std::vector<std::string>& params);
void resumeInjectorCommand(InterfacePlayerRDK& player, const std::vector<std::string>& params);
void stopCommand(InterfacePlayerRDK& player, const std::vector<std::string>& params);
void flushCommand(InterfacePlayerRDK& player, const std::vector<std::string>& params);
Expand Down
Loading