![]() |
libxcoder
5.2.0
|
Public definitions for managing NETINT video processing devices. More...
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include "ni_rsrc_api.h"
#include "ni_rsrc_priv.h"
#include "ni_util.h"
Go to the source code of this file.
Functions | |
void | print_device (ni_device_t *p_device) |
ni_retcode_t | ni_rsrc_refresh (int should_match_rev) |
Scan and refresh all resources on the host, taking into account hot-plugged and pulled out cards. More... | |
void | ni_rsrc_free_device_context (ni_device_context_t *p_device_context) |
Free previously allocated device context. More... | |
ni_retcode_t | ni_rsrc_list_devices (ni_device_type_t device_type, ni_device_info_t *p_device_info, int *p_device_count) |
List device(s) based on device type with full information including s/w instances on the system. More... | |
ni_retcode_t | ni_rsrc_list_all_devices (ni_device_t *p_device) |
List all devices with full information including s/w instances on the system. More... | |
ni_retcode_t | ni_rsrc_list_all_devices2 (ni_device_t *p_device, bool list_uninitialized) |
Grabs information for every initialized and uninitialized device. More... | |
void | ni_rsrc_print_device_info (const ni_device_info_t *p_device_info) |
Print the content of the ni_device_info_t struct. More... | |
void | ni_rsrc_print_all_devices_capability (void) |
Print detailed capability information of all devices on the system. More... | |
void | ni_rsrc_print_all_devices_capability2 (bool list_uninitialized) |
Prints detailed capability information for all initialized devices and general information about uninitialized devices. More... | |
ni_device_info_t * | ni_rsrc_get_device_info (ni_device_type_t device_type, int guid) |
Query a specific device with detailed information on the system. More... | |
int | ni_rsrc_get_device_by_block_name (const char *blk_name, ni_device_type_t device_type) |
Get GUID of the device by block device name and type. More... | |
int | ni_rsrc_update_device_load (ni_device_context_t *p_device_context, int load, int sw_instance_cnt, const ni_sw_instance_info_t sw_instance_info[]) |
Update the load value and s/w instances info of a specific decoder or encoder. This is used by resource management daemon to update periodically. More... | |
ni_device_context_t * | ni_rsrc_allocate_simple_direct (ni_device_type_t device_type, int guid) |
Allocate resources for decoding/encoding, by designating explicitly the device to use. do not track the load on the host side. More... | |
void | ni_rsrc_release_resource (ni_device_context_t *p_device_context, uint64_t load) |
Release resources allocated for decoding/encoding. function This must be called at the end of transcoding with previously assigned load value by allocate* functions. More... | |
int | ni_rsrc_check_hw_available (int guid, ni_device_type_t device_type) |
check the NetInt h/w device in resource pool on the host. More... | |
int | ni_rsrc_remove_device (const char *dev) |
Remove an NetInt h/w device from resource pool on the host. More... | |
int | ni_rsrc_remove_all_devices (void) |
Remove all NetInt h/w devices from resource pool on the host. More... | |
int | ni_rsrc_add_device (const char *dev, int should_match_rev) |
Add an NetInt h/w device into resource pool on the host. More... | |
void | ni_rsrc_free_device_pool (ni_device_pool_t *p_device_pool) |
Free all resources taken by the device pool. More... | |
int | ni_rsrc_lock_and_open (int device_type, ni_lock_handle_t *lock) |
lock a file lock and open a session on a device More... | |
int | ni_rsrc_unlock (int device_type, ni_lock_handle_t lock) |
unlock a file lock More... | |
int | ni_rsrc_is_fw_compat (uint8_t fw_rev[8]) |
check if device FW revision is compatible with SW API More... | |
ni_hw_device_info_quadra_coder_param_t * | ni_create_hw_device_info_quadra_coder_param (int mode) |
Create and alloc a pointer to ni_hw_device_info_quadra_coder_param_t This function is used for ni_check_hw_info() More... | |
void | ni_destory_hw_device_info_quadra_coder_param (ni_hw_device_info_quadra_coder_param_t *p_hw_device_info_quadra_coder_param) |
Free resource in p_hw_device_info_quadra_coder_param This function is used for ni_check_hw_info() More... | |
ni_hw_device_info_quadra_t * | ni_hw_device_info_alloc_quadra (int device_type_num, int avaliable_card_num) |
Create a ni_hw_device_info_quadra_t This function is used for ni_check_hw_info() More... | |
void | ni_hw_device_info_free_quadra (ni_hw_device_info_quadra_t *p_hw_device_info) |
Free resource in a pointer of ni_hw_device_info_quadra_t This function is used for ni_check_hw_info() More... | |
int | ni_check_hw_info (ni_hw_device_info_quadra_t **pointer_to_p_hw_device_info, int task_mode, ni_hw_device_info_quadra_threshold_param_t *hw_info_threshold_param, ni_device_type_t preferential_device_type, ni_hw_device_info_quadra_coder_param_t *coder_param, int hw_mode, int consider_mem) |
check hw info, return the appropriate card number to use depends on the load&task_num&used resource More... | |
ni_device_context_t * | ni_rsrc_allocate_auto (ni_device_type_t device_type, ni_alloc_rule_t rule, ni_codec_t codec, int width, int height, int frame_rate, uint64_t *p_load) |
Allocate resources for decoding/encoding, based on the provided rule. More... | |
Variables | |
NI_DEPRECATED char ** | g_xcoder_refresh_dev_names = NULL |
NI_DEPRECATED int | g_xcoder_refresh_dev_count = 0 |
NI_DEPRECATED bool | g_device_in_ctxt = false |
NI_DEPRECATED ni_device_handle_t | g_dev_handle = NI_INVALID_DEVICE_HANDLE |
Public definitions for managing NETINT video processing devices.
Definition in file ni_rsrc_api.cpp.
int ni_check_hw_info | ( | ni_hw_device_info_quadra_t ** | pointer_to_p_hw_device_info, |
int | task_mode, | ||
ni_hw_device_info_quadra_threshold_param_t * | hw_info_threshold_param, | ||
ni_device_type_t | preferential_device_type, | ||
ni_hw_device_info_quadra_coder_param_t * | coder_param, | ||
int | hw_mode, | ||
int | consider_mem | ||
) |
check hw info, return the appropriate card number to use depends on the load&task_num&used resource
[out] | pointer_to_p_hw_device_info | : pointer to user-supplied ni_hw_device_info_quadra_t (allocated by ni_hw_device_info_alloc). May be a ponter to NULL ,in which case a ni_hw_device_info_quadra_coder_param_t is allocated by this function and written to pointer_to_p_hw_device_info. record the device info, including available card num and which card to select, and each card's informaton, such as, the load, task num, device type |
[in] | task_mode | affect the scheduling strategy, 1 - both the load_num and task_num should consider, usually applied to live scenes 0 - only consider the task_num, don not care the load_num |
[in] | hw_info_threshold_param | : an array of threshold including device type task threshold and load threshold in hw_mode fill the arry with both encoder and decoder threshold or fill the arry with preferential device type threshold when don not in hw_mode load threshold in range[0:100] task num threshold in range [0:32] |
[in] | preferential_device_type | : which device type is preferential 0:decode 1:encode . This need to set to encoder/decoder even if in sw_mode to check whether coder_param is wrong. |
[in] | coder_param | : encoder and decoder information that helps to choose card .This coder_param can be created and set to default value by function hw_device_info_coder_param_t * create_hw_device_info_coder_param(). You may change the resolution fps bit_8_10 or other vaule you want to use |
[in] | hw_mode:Set | 1 then this function will choose encoder and decoder in just one card . When no card meets the conditions ,NO card will be choosed. You can try to use set hw_mode 0 to use sw_mode to do encoder/decoder in different card when hw_mode reports an error In hw_mode set both encoder_param and decoder_param in coder_param. Set 0 then just consider sw_mode to choose which card to do encode/decode, In sw_mode set one param in coder_param the other one will be set to NULL. |
[in] | consider_mem | : set 1 this function will consider memory usage extra set 0 this function will not consider memory usage |
Definition at line 3401 of file ni_rsrc_api.cpp.
ni_hw_device_info_quadra_coder_param_t* ni_create_hw_device_info_quadra_coder_param | ( | int | mode | ) |
Create and alloc a pointer to ni_hw_device_info_quadra_coder_param_t This function is used for ni_check_hw_info()
Create a pointer to hw_device_info_coder_param_t instance .This instance will be created and set to default vaule by param mode.You may change the resolution fps bit_8_10 or other vaule you want to set.
[in] | mode | 0 for decoder,1 for encoder,2 for scaler,3 for AI, >= 4 for hw_mode |
Definition at line 3118 of file ni_rsrc_api.cpp.
void ni_destory_hw_device_info_quadra_coder_param | ( | ni_hw_device_info_quadra_coder_param_t * | p_hw_device_info_quadra_coder_param | ) |
Free resource in p_hw_device_info_quadra_coder_param This function is used for ni_check_hw_info()
Release a pointer to hw_device_info_coder_param_t instance created by create_hw_device_info_coder_param.
[in] | device_type_num | |
[in] | avaliable_card_num |
Definition at line 3271 of file ni_rsrc_api.cpp.
ni_hw_device_info_quadra_t* ni_hw_device_info_alloc_quadra | ( | int | device_type_num, |
int | avaliable_card_num | ||
) |
Create a ni_hw_device_info_quadra_t This function is used for ni_check_hw_info()
Create a pointer to ni_hw_device_info_quadra_t instance .
[in] | device_type_num | |
[in] | avaliable_card_num |
Definition at line 3310 of file ni_rsrc_api.cpp.
void ni_hw_device_info_free_quadra | ( | ni_hw_device_info_quadra_t * | p_hw_device_info | ) |
Free resource in a pointer of ni_hw_device_info_quadra_t This function is used for ni_check_hw_info()
Release a pointer to ni_hw_device_info_quadra_t instance created by create_hw_device_info_coder_param.
[in] | p_hw_device_info | Poiner to a ni_hw_device_info_quadra_t struct |
Definition at line 3381 of file ni_rsrc_api.cpp.
int ni_rsrc_add_device | ( | const char * | dev, |
int | should_match_rev | ||
) |
Add an NetInt h/w device into resource pool on the host.
[in] | p_dev | Device name represented as C string. ex "/dev/nvme0" |
[in] | should_match_rev | 0: transcoder firmware revision matching the library's version is NOT required for placing the transcoder into resource pool; 1: otherwise |
Definition at line 2523 of file ni_rsrc_api.cpp.
ni_device_context_t* ni_rsrc_allocate_auto | ( | ni_device_type_t | device_type, |
ni_alloc_rule_t | rule, | ||
ni_codec_t | codec, | ||
int | width, | ||
int | height, | ||
int | frame_rate, | ||
uint64_t * | p_load | ||
) |
Allocate resources for decoding/encoding, based on the provided rule.
[in] | device_type | NI_DEVICE_TYPE_DECODER or NI_DEVICE_TYPE_ENCODER |
[in] | rule | allocation rule |
[in] | codec | EN_H264 or EN_H265 |
[in] | width | width of video resolution |
[in] | height | height of video resolution |
[in] | frame_rate | video stream frame rate |
[out] | p_load | the p_load that will be generated by this encoding task. Returned only for encoder for now. |
Note: codec, width, height, fps need to be supplied for NI_DEVICE_TYPE_ENCODER only, they are ignored otherwize. Note: the returned ni_device_context_t content is not supposed to be used by caller directly: should only be passed to API in the subsequent calls; also after its use, the context should be released by calling ni_rsrc_free_device_context.
retrieve the record and based on the allocation rule specified, find the least loaded or least number of s/w instances among the coders
get the individual device_info info and check the load/num-of-instances
Definition at line 4103 of file ni_rsrc_api.cpp.
ni_device_context_t* ni_rsrc_allocate_simple_direct | ( | ni_device_type_t | device_type, |
int | guid | ||
) |
Allocate resources for decoding/encoding, by designating explicitly the device to use. do not track the load on the host side.
[in] | device_type | NI_DEVICE_TYPE_DECODER or NI_DEVICE_TYPE_ENCODER |
[in] | guid | unique device (decoder or encoder) module id |
Note: only need to specify the device type and guid and codec type
Note: the returned ni_device_context_t content is not supposed to be used by caller directly: should only be passed to API in the subsequent calls; also after its use, the context should be released by calling ni_rsrc_free_device_context.
Definition at line 1932 of file ni_rsrc_api.cpp.
int ni_rsrc_check_hw_available | ( | int | guid, |
ni_device_type_t | device_type | ||
) |
check the NetInt h/w device in resource pool on the host.
[in] | guid | the global unique device index in resource pool device_type NI_DEVICE_TYPE_DECODER or NI_DEVICE_TYPE_ENCODER |
Definition at line 2016 of file ni_rsrc_api.cpp.
void ni_rsrc_free_device_context | ( | ni_device_context_t * | p_device_context | ) |
Free previously allocated device context.
p_device_context | Pointer to previously allocated device context |
Definition at line 1310 of file ni_rsrc_api.cpp.
void ni_rsrc_free_device_pool | ( | ni_device_pool_t * | p_device_pool | ) |
Free all resources taken by the device pool.
[in] | p_device_pool | Poiner to a device pool struct |
Definition at line 2621 of file ni_rsrc_api.cpp.
int ni_rsrc_get_device_by_block_name | ( | const char * | blk_name, |
ni_device_type_t | device_type | ||
) |
Get GUID of the device by block device name and type.
[in] | blk_name | device's block name |
[in] | type | device type |
Definition at line 1799 of file ni_rsrc_api.cpp.
ni_device_info_t* ni_rsrc_get_device_info | ( | ni_device_type_t | device_type, |
int | guid | ||
) |
Query a specific device with detailed information on the system.
[in] | device_type | NI_DEVICE_TYPE_DECODER or NI_DEVICE_TYPE_ENCODER |
[in] | guid | unique device(decoder or encoder) id |
Note: Caller is responsible for releasing memory that was allocated for the returned pointer
Definition at line 1748 of file ni_rsrc_api.cpp.
int ni_rsrc_is_fw_compat | ( | uint8_t | fw_rev[8] | ) |
check if device FW revision is compatible with SW API
fw_rev |
Definition at line 2784 of file ni_rsrc_api.cpp.
ni_retcode_t ni_rsrc_list_all_devices | ( | ni_device_t * | p_device | ) |
List all devices with full information including s/w instances on the system.
[out] | p_device | The device information returned. |
Note: Caller is responsible for allocating memory for "p_device".
Definition at line 1445 of file ni_rsrc_api.cpp.
ni_retcode_t ni_rsrc_list_all_devices2 | ( | ni_device_t * | p_device, |
bool | list_uninitialized | ||
) |
Grabs information for every initialized and uninitialized device.
list_uninitialized | Flag to determine if uninitialized devices should be grabbed. |
Note: Caller is responsible for allocating memory for "p_device".
Definition at line 1487 of file ni_rsrc_api.cpp.
ni_retcode_t ni_rsrc_list_devices | ( | ni_device_type_t | device_type, |
ni_device_info_t * | p_device_info, | ||
int * | p_device_count | ||
) |
List device(s) based on device type with full information including s/w instances on the system.
[in] | device_type | NI_DEVICE_TYPE_DECODER or NI_DEVICE_TYPE_ENCODER |
[out] | p_device | The device information returned. |
[out] | p_device_count | The number of ni_device_info_t structs returned. |
Note: Caller is responsible for allocating memory for "p_device".
Definition at line 1340 of file ni_rsrc_api.cpp.
int ni_rsrc_lock_and_open | ( | int | device_type, |
ni_lock_handle_t * | lock | ||
) |
lock a file lock and open a session on a device
device_type | |
lock |
Definition at line 2652 of file ni_rsrc_api.cpp.
void ni_rsrc_print_all_devices_capability | ( | void | ) |
Print detailed capability information of all devices on the system.
none |
Definition at line 1681 of file ni_rsrc_api.cpp.
void ni_rsrc_print_all_devices_capability2 | ( | bool | list_uninitialized | ) |
Prints detailed capability information for all initialized devices and general information about uninitialized devices.
list_uninitialized | Flag to determine if uninitialized devices should be grabbed. |
Definition at line 1713 of file ni_rsrc_api.cpp.
void ni_rsrc_print_device_info | ( | const ni_device_info_t * | p_device_info | ) |
Print the content of the ni_device_info_t struct.
p_device_info | - pointer to the ni_device_info_t struct to print |
Definition at line 1600 of file ni_rsrc_api.cpp.
ni_retcode_t ni_rsrc_refresh | ( | int | should_match_rev | ) |
Scan and refresh all resources on the host, taking into account hot-plugged and pulled out cards.
[in] | should_match_rev | 0: transcoder firmware revision matching the library's version is NOT required for placing the transcoder into resource pool; 1: otherwise |
Definition at line 159 of file ni_rsrc_api.cpp.
void ni_rsrc_release_resource | ( | ni_device_context_t * | p_device_context, |
uint64_t | load | ||
) |
Release resources allocated for decoding/encoding. function This must be called at the end of transcoding with previously assigned load value by allocate* functions.
[in/out] | p_ctxt the device context | |
[in] | load | the load value returned by allocate* functions |
Definition at line 1953 of file ni_rsrc_api.cpp.
int ni_rsrc_remove_all_devices | ( | void | ) |
Remove all NetInt h/w devices from resource pool on the host.
none |
Definition at line 2407 of file ni_rsrc_api.cpp.
int ni_rsrc_remove_device | ( | const char * | dev | ) |
Remove an NetInt h/w device from resource pool on the host.
[in] | p_dev | the NVMe device name |
Definition at line 2203 of file ni_rsrc_api.cpp.
int ni_rsrc_unlock | ( | int | device_type, |
ni_lock_handle_t | lock | ||
) |
unlock a file lock
device_type | |
lock |
Definition at line 2738 of file ni_rsrc_api.cpp.
int ni_rsrc_update_device_load | ( | ni_device_context_t * | p_device_context, |
int | load, | ||
int | sw_instance_cnt, | ||
const ni_sw_instance_info_t | sw_instance_info[] | ||
) |
Update the load value and s/w instances info of a specific decoder or encoder. This is used by resource management daemon to update periodically.
[in] | p_ctxt | The device context returned by ni_rsrc_get_device_context |
[in] | p_load | The latest load value to update |
[in] | sw_instance_cnt | Number of s/w instances |
[in] | sw_instance_info | Info of s/w instances |
Definition at line 1878 of file ni_rsrc_api.cpp.
void print_device | ( | ni_device_t * | p_device | ) |
Definition at line 82 of file ni_rsrc_api.cpp.
NI_DEPRECATED ni_device_handle_t g_dev_handle = NI_INVALID_DEVICE_HANDLE |
Definition at line 63 of file ni_rsrc_api.cpp.
NI_DEPRECATED bool g_device_in_ctxt = false |
Definition at line 62 of file ni_rsrc_api.cpp.
NI_DEPRECATED int g_xcoder_refresh_dev_count = 0 |
Definition at line 61 of file ni_rsrc_api.cpp.
NI_DEPRECATED char** g_xcoder_refresh_dev_names = NULL |
Definition at line 60 of file ni_rsrc_api.cpp.