deepstream-services-library icon indicating copy to clipboard operation
deepstream-services-library copied to clipboard

Refactor Remuxer - no longer a Tee - add Metamuxer plugin and auto generate Metamuxer config

Open rjhowell44 opened this issue 1 year ago • 0 comments

Initially, the plan was to derive the Remuxer component from the TeeBintr class and develop a separate Metamuxer component. However, since there is only one way to link the Remuxer and Metamuxer, It seems better to abstract the complexity of linking each Remuxer Branch to a requested Sink Pad of the Metamuxer.

So, the new plan is to add the Metamuxer plugin to the RexmuerBintr and allow the Pipeline to be linked up as

Streammuxer->Remuxer->Tiler->OSD->Sinks

...and with each of the Parallel Inference Branches added to the Remuxer internally.

IMPORTANT! The Metamuxer requires a config file to define the selective streams for each branch. The config-file will be auto generated based on the stream-ids passed into dsl_remuxer_branch_add_to. The file name/path rules are still TBD.

New Return Codes for the Remuxer - as it is no longer derived from Tee.

/**
 * Remuxer API Return Values
 */
#define DSL_RESULT_REMUXER_RESULT                                   0x00C00000
#define DSL_RESULT_REMUXER_NAME_NOT_UNIQUE                          0x00C00001
#define DSL_RESULT_REMUXER_NAME_NOT_FOUND                           0x00C00002
#define DSL_RESULT_REMUXER_NAME_BAD_FORMAT                          0x00C00003
#define DSL_RESULT_REMUXER_THREW_EXCEPTION                          0x00C00004
#define DSL_RESULT_REMUXER_SET_FAILED                               0x00C00005
#define DSL_RESULT_REMUXER_BRANCH_IS_NOT_BRANCH                     0x00C00006
#define DSL_RESULT_REMUXER_BRANCH_IS_NOT_CHILD                      0x00C00007
#define DSL_RESULT_REMUXER_BRANCH_ADD_FAILED                        0x00C00008
#define DSL_RESULT_REMUXER_BRANCH_MOVE_FAILED                       0x00C00009
#define DSL_RESULT_REMUXER_BRANCH_REMOVE_FAILED                     0x00C0000A
#define DSL_RESULT_REMUXER_HANDLER_ADD_FAILED                       0x00C0000B
#define DSL_RESULT_REMUXER_HANDLER_REMOVE_FAILED                    0x00C0000C
#define DSL_RESULT_REMUXER_COMPONENT_IS_NOT_REMUXER                 0x00C0000D

Complete Services API

/**
 * @brief Creates a new, uniquely named Remuxer component.
 * @param[in] name unique name for the new Remuxer.
 * @return DSL_RESULT_SUCCESS on success, one of DSL_RESULT_REMUXER_RESULT on failure.
 */
DslReturnType dsl_remuxer_new(const wchar_t* name);

/**
 * @brief Creates a new Remuxer and adds a list of Branches to it. 
 * IMPORTANT! All branches will be linked to all streams. To add a Branch to a select 
 * set of streams, use dsl_remuxer_branch_add_to.
 * @param[in] name unique name for the new Remuxer.
 * @param[in] branches NULL terminated array of Branch names to add.
 * @return DSL_RESULT_SUCCESS on success, one of DSL_RESULT_REMUXER_RESULT on failure.
 */
DslReturnType dsl_remuxer_new_branch_add_many(const wchar_t* name, 
    const wchar_t** branches);

/**
 * @brief Adds a single Branch to a Remuxer to be linked to a specific set.
 * of streams-ids.
 * @param[in] name name of the Remuxer to update.
 * @param[in] branch name of Branch to add.
 * @param[in] stream_ids array of specific stream-ids to connect to.
 * @param[in] num_stream_ids number of ids in the stream-ids array.
 * @return DSL_RESULT_SUCCESS on success, one of DSL_RESULT_REMUXER_RESULT on failure.
 */
DslReturnType dsl_remuxer_branch_add_to(const wchar_t* name, 
    const wchar_t* branch, uint* stream_ids, uint num_stream_ids);

/**
 * @brief Adds a single Branch to a named Remuxer to be linked to all streams.
 * @param[in] name name of the Remuxer to update.
 * @param[in] branch name of Branch to add.
 * @return DSL_RESULT_SUCCESS on success, one of DSL_RESULT_REMUXER_RESULT on failure.
 */
DslReturnType dsl_remuxer_branch_add(const wchar_t* name, 
    const wchar_t* branch);

/**
 * @brief Adds a list of Branches to a named Remuxer. IMPORTANT! All branches will be
 * linked to all streams. To add a Branch to a select set of streams, use 
 * dsl_remuxer_branch_add_to.
 * @param[in] name name of the Remuxer to update.
 * @param[in] branches NULL terminated array of Branch names to add.
 * @return DSL_RESULT_SUCCESS on success, one of DSL_RESULT_REMUXER_RESULT on failure.
 */
DslReturnType dsl_remuxer_branch_add_many(const wchar_t* name, 
    const wchar_t** branches);

/**
 * @brief Removes a single Branch from a named Remuxer.
 * @param[in] name name of the Remuxer to update.
 * @param[in] branch name of Branch to remove.
 * @return DSL_RESULT_SUCCESS on success, one of DSL_RESULT_REMUXER_RESULT on failure.
 */
DslReturnType dsl_remuxer_branch_remove(const wchar_t* name, 
    const wchar_t* branch);

/**
 * @brief Removes a list of Branches from a named Remuxer.
 * @param[in] name name of the Remuxer to update.
 * @param[in] branches NULL terminated array of Branch names to remove.
 * @return DSL_RESULT_SUCCESS on success, one of DSL_RESULT_REMUXER_RESULT on failure.
 */
DslReturnType dsl_remuxer_branch_remove_many(const wchar_t* name, 
    const wchar_t** branches);

/**
 * @brief Removes all Branches from a named Remuxer.
 * @param[in] name name of the Remuxer to update.
 * @return DSL_RESULT_SUCCESS on success, one of DSL_RESULT_REMUXER_RESULT on failure.
 */
DslReturnType dsl_remuxer_branch_remove_all(const wchar_t* name);

/**
 * @brief Gets the current number of Branches owned by the named Remuxer.
 * @param[in] name name of the Remuxer to query.
 * @param[out] count current number of Branches.
 * @return DSL_RESULT_SUCCESS on success, one of DSL_RESULT_REMUXER_RESULT on failure.
 */
DslReturnType dsl_remuxer_branch_count_get(const wchar_t* name, uint* count);


// -----------------------------------------------------------------------------------
// NEW STREAMMUX SERVICES - Start

/**
 * @brief Gets the current batch-size setting for the named Remuxer.
 * @param[in] name unique name of the Remuxer to query.
 * @param[out] batch_size the current batch size in use.
 * @return DSL_RESULT_SUCCESS on success, one of DSL_RESULT_REMUXER_RESULT on failure.
 */
DslReturnType dsl_remuxer_batch_size_get(const wchar_t* name, 
    uint* batch_size);

/**
 * @brief Updates the named Remuxer's batch-size setting.
 * @param[in] name unique name of the Remuxer to update.
 * @param[out] batch_size the new batch size to use.
 * @return DSL_RESULT_SUCCESS on success, one of DSL_RESULT_REMUXER_RESULT on failure.
 */
DslReturnType dsl_remuxer_batch_size_set(const wchar_t* name, 
    uint batch_size);

/**
 * @brief Gets the current Streammuxer config-file in use by a named Remuxer Branch 
 * owned by a named Remuxer.
 * @param[in] name name of the Remuxer to update.
 * @param[in] branch name of Branch to update.
 * @param[out] config_file path to the Streammuxer config-file currently in use
 * by the named Remuxer Branch.
 * @return DSL_RESULT_SUCCESS on success, one of DSL_RESULT_REMUXER_RESULT on failure.
 */
DslReturnType dsl_remuxer_branch_config_file_get(const wchar_t* name, 
    const wchar_t* branch, const wchar_t** config_file);

/**
 * @brief Sets the Streammuxer config-file to use for a named Remuxer Branch, 
 * owned by a named Remuxer.
 * @param[in] name name of the Remuxer to update.
 * @param[in] branch name of Branch to update.
 * @param[in] config_file absolute or relative path to a Streammuxer config-file for
 * the named Remuxer Branch to use.
 * @return DSL_RESULT_SUCCESS on success, one of DSL_RESULT_REMUXER_RESULT on failure.
 */
DslReturnType dsl_remuxer_branch_config_file_set(const wchar_t* name, 
    const wchar_t* branch, const wchar_t* config_file);

// -----------------------------------------------------------------------------------
// NEW STREAMMUX SERVICES - End

// -----------------------------------------------------------------------------------
// OLD STREAMMUX SERVICES - Start

/**
 * @brief Gets the current batch-size and batch-push-timeout properties for the 
 * named Remuxer.
 * @param[in] name unique name of the Remuxer to query.
 * @param[out] batch_size the current batch size in use.
 * @param[out] batch_timeout the current batch timeout in use. 
 * Default = -1 for no timeout.
 * @return DSL_RESULT_SUCCESS on successful query, one of DSL_RESULT_TEE on failure.
 */
DslReturnType dsl_remuxer_batch_properties_get(const wchar_t* name, 
    uint* batch_size, int* batch_timeout);

/**
 * @brief Updates the named Remuxer's batch-size and batch-push-timeout properties
 * @param[in] name unique name of the Remuxer to update.
 * @param[out] batch_size the new batch size to use.
 * @param[out] batch_timeout the new batch timeout to use. Set to -1 for no timeout.
 * @return DSL_RESULT_SUCCESS on successful query, one of DSL_RESULT_TEE on failure.
 */
DslReturnType dsl_remuxer_batch_properties_set(const wchar_t* name, 
    uint batch_size, int batch_timeout);

/**
 * @brief Get the current output frame dimensions for the named Remuxer.
 * @param[in] name name of the Remuxer to query.
 * @param[out] width current output frame width in units of pixels.
 * @param[out] height current output frame height in units of pixels.
 * @return DSL_RESULT_SUCCESS on successful query, one of DSL_RESULT_TEE on failure.
 */
DslReturnType dsl_remuxer_dimensions_get(const wchar_t* name, 
    uint* width, uint* height);

/**
 * @brief Set the output dimensions for the named Remuxer to use.
 * @param[in] name name of the Remuxer to update.
 * @param[in] width new output frame width to use in units of pixels.
 * @param[in] height new output frame height to use in units of pixels.
 * @return DSL_RESULT_SUCCESS on successful query, one of DSL_RESULT_TEE on failure.
*/
DslReturnType dsl_remuxer_dimensions_set(const wchar_t* name, 
    uint width, uint height);
    
// -----------------------------------------------------------------------------------
// OLD STREAMMUX SERVICES - End

/**
 * @brief Adds a pad-probe-handler to a named Remuxer.
 * One or more Pad Probe Handlers can be added to either the Sink or Source PAD.
 * @param[in] name unique name of the Remuxer to update.
 * @param[in] handler unique name of the pad probe handler to add.
 * @param[in] pad pad to add the handler to; DSL_PAD_SINK | DSL_PAD SRC
 * @return DSL_RESULT_SUCCESS on success, one of DSL_RESULT_REMUXER_RESULT on failure.
 */
DslReturnType dsl_remuxer_pph_add(const wchar_t* name, 
    const wchar_t* handler, uint pad);

/**
 * @brief Removes a pad-probe-handler from a named Remuxer.
 * @param[in] name unique name of the Remuxer to update.
 * @param[in] handler unique name of the pad probe handler to remove.
 * @param[in] pad pad to remove the handler from; DSL_PAD_SINK | DSL_PAD SRC
 * @return DSL_RESULT_SUCCESS on success, one of DSL_RESULT_REMUXER_RESULT on failure.
 */
DslReturnType dsl_remuxer_pph_remove(const wchar_t* name,
    const wchar_t* handler, uint pad);

rjhowell44 avatar Feb 17 '24 22:02 rjhowell44