Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SBC pod launcher JSON based configuration parser #40

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

walidbarakat
Copy link
Collaborator

@walidbarakat walidbarakat commented Jan 9, 2025

Description :

  • A library to be plugged to gRPC service executable. currently the expected behavior is that the client sends NMOS configuration and once the service receives this info, this library being invoked to read a JSON configuration file, process the configuration data, and constructs a command string. then the returned string to the main thread to execute the ffmpeg command-line tool with the specified parameters. The application is designed to handle various configuration keys dynamically and includes error handling mechanisms to ensure robustness.

Prerequisite :
before launching the pod service, an environment variable CONFIG_FILE is expected to be set to hold the absolute path for the json configuration file i.e /tmp/config.json

Functionality :
1 - Reading the Configuration File:

  • The application takes a single command-line argument, which is the path to the JSON configuration file.
    It opens and reads the content of the specified JSON configuration file.

2- Parsing the JSON Configuration:

  • The application parses the JSON content using nlohmann library.
    It extracts the appParams section from the ffmpegPipelineDefinition object within the JSON structure.

3 - Processing Configuration Parameters:

  • The application defines a set of handler functions to process specific keys in the appParams section.
    Each handler function prints the key and value, performs any necessary processing, and returns a formatted string in the format "-key value".

  • The handleKeyValue function handles generic key-value pairs, while the handleFrameRate function specifically handles the frame_rate key by calculating the frame rate from its numerator and denominator values.

4 - Constructing the Command String:

  • The application collects the formatted strings returned by the handler functions and constructs a single command string by joining them with spaces.

6 - Error Handling:

  • The application includes error handling mechanisms to handle various error conditions, such as missing keys, invalid values, and command execution failures. It logs fatal error messages and exits gracefully if any error occurs during the execution.

Compilation and usage :
it compiles as part of the whole cmake project in gRPC folder. so just compiling gRPC service will be enough for compilation and linking : ./compile.sh

Example JSON file :

{
    "ffmpegPipelineDefinition" : {
        "appParams" : {
            "codec" : "rawvideo",
            "pixel_format" : "yuv420p",
            "height" : "1080",
            "width" : "1920",
            "frame_rate" : {
                "numerator" : 60,
                "denominator" : 1
            },
            "socket_name" : "NULL",
            "ip_addr" : "192.168.10.1",
            "port" : "9001",
            "payload_type" : "st20",
            "protocol_type" : "auto",
            "video_size" : "1920x1080",
            "interface_id" : "0"
        }
    }
}

@walidbarakat walidbarakat self-assigned this Jan 9, 2025
@walidbarakat walidbarakat marked this pull request as draft January 9, 2025 17:59
@walidbarakat walidbarakat marked this pull request as ready for review January 10, 2025 11:28
@walidbarakat walidbarakat changed the title [DRAFT] SBC pod launcher JSON based configuration parser SBC pod launcher JSON based configuration parser Jan 10, 2025
Copy link
Collaborator

@awilczyns awilczyns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Building with ./compile.sh --unit_testing is resulting in missing include errors. Please investigate and resolve the issue.

Copy link
Collaborator

@awilczyns awilczyns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide a usage example demonstrating how to run the full pipeline, starting from the Dockerfile entrypoint (ffmpeg_wrapper_service)

@walidbarakat
Copy link
Collaborator Author

Please provide a usage example demonstrating how to run the full pipeline, starting from the Dockerfile entrypoint (ffmpeg_wrapper_service)

This change doesn't affect the way of running the full pipeline. so from Dockerfile entrypoint still need just to run as it is docker <image_name> <ip> <port> as we know implicitly once the NMOS configuration is sent - which contains an IP and PORT for transmission - the functionality added here will be triggered and processing the json configuration can be considered as a sub-process of processing the incoming message - NMOS configuration -.

in short words, the pipeline can run the same with and without this change.

define expected json entries by their key name and
assign a handling function for each. this gives
a flexibility for either update the key table or
the function that handles the entry.

Signed-off-by: Aly, Walid <[email protected]>
parsing functions - ffmpeg json based config parser
add the CMakeLists.txt for building the parser.

Signed-off-by: Aly, Walid <[email protected]>
ffmpeg json based config parser - integrate to service class
the call to the parsing function here isn't the best option
but this can be considered when the final idea about the service
is setteled. however, it's required to defined the configuration
file path as a environment variable.

Signed-off-by: Aly, Walid <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants