56 void getStr(
const char *prompt,
char *str)
61 if (fgets(para,
sizeof(para), stdin) != 0) {
62 size_t len = strlen(para);
63 if (len > 0 && para[len - 1] ==
'\n')
68 strncat(str, para, strlen(para));
97 getStr(
"set log level to [info, debug, trace]: ", log_level);
98 if (!strcmp(log_level,
"none")) {
100 }
else if (!strcmp(log_level,
"fatal")) {
102 }
else if (!strcmp(log_level,
"error")) {
104 }
else if (!strcmp(log_level,
"info")) {
106 }
else if (!strcmp(log_level,
"debug")) {
108 }
else if (!strcmp(log_level,
"trace")) {
111 printf(
"unknown log level selected: %s", log_level);
143 return (
float)
atof(para);
175 if (NULL == coders) {
176 fprintf(stderr,
"Error failed to malloc ni_logan_device_info_t * %d\n",
184 for (i = 0; i < count; i++) {
210 if (WAIT_ABANDONED == WaitForSingleObject(p_device_pool->
lock, INFINITE))
212 fprintf(stderr,
"ERROR: listModuleId() failed o obtain mutex: %p", p_device_pool->
lock);
215 #elif defined(__linux__)
216 if( flock(p_device_pool->
lock, LOCK_EX) )
218 fprintf(stderr,
"Error flock() failed\n");
227 printf(
"[%d]. %d (load: %d inst: %d %s.%d)\n", i, ptr->
decoders[i],
234 printf(
"[%d]. %d (load: %d inst: %d %s.%d)\n", i, ptr->
encoders[i],
241 ReleaseMutex(p_device_pool->
lock);
242 #elif defined(__linux__)
243 if( flock(p_device_pool->
lock, LOCK_UN) )
245 fprintf(stderr,
"Error flock() failed\n");
264 if (NULL == coders) {
265 fprintf(stderr,
"Error failed to malloc ni_logan_device_t\n");
302 guid =
getInt(
"Coder module ID: ");
303 load =
getInt(
"load value: ");
304 nb_insts =
getInt(
"Number of s/w instances: ");
305 for (i = 0; i < nb_insts; i++) {
306 sw_insts[i].
id =
getInt(
"s/w inst. id: ");
311 sw_insts[i].
fps =
getInt(
"s/w inst. fps: ");
315 if (p_device_context) {
319 printf(
"Error coder not found ..\n");
337 guid =
getInt(
"Coder module ID: ");
338 printf(
"type: %d id %d\n", type, guid);
355 int guid, width, height, fps;
362 width =
getInt(
"video width: ");
363 height =
getInt(
"video height: ");
364 fps =
getInt(
"video frame rate: ");
367 printf(
"Error coder not found ..\n");
385 unsigned long model_load;
389 printf(
"type: %d rule %d\n", type, rule);
392 if (p_device_context) {
393 printf(
"Successfully auto-allocated s/w instance on:\n");
395 printf(
"Allocated load: %ld\n", model_load);
412 unsigned long model_load;
415 guid =
getInt(
"Coder module ID: ");
416 printf(
"type: %d id %d\n", type, guid);
419 if (p_device_context) {
420 printf(
"Successfully allocated directly the s/w instance ..\n");
439 guid =
getInt(
"Coder module ID: ");
440 load = (
unsigned long)
getLong(
"load value: ");
441 printf(
"id %d load: %ld\n", guid, load);
443 if (p_device_context) {
447 printf(
"Error coder not found ..\n");
461 getStr(
"device name (/dev/*): ", dev);
475 int should_match_rev = 0;
476 getStr(
"device name (/dev/*): ", dev);
477 should_match_rev =
getInt(
"should match current release version, yes (1) no (0): ");
495 guid =
getInt(
"Coder module ID (GUID): ");
496 printf(
"type: %d id %d\n", type, guid);
501 printf(
"%s module ID (GUID) %d is good\n", (type ==0 ?
"decoder":
"encoder"), guid);
505 printf(
"%s module ID (GUID) %d is bad\n", (type ==0 ?
"decoder":
"encoder"), guid);
519 printf(
"**************************************************\n");
525 printf(
"**************************************************\n\n\n");
539 printf(
"Key function\n"
541 "v change libxcoder_logan log level\n"
542 "l list all decoders, or all encoders\n"
543 "L list all coders detailed info\n"
544 "o list all coders' module #, in order of position in queue\n"
545 "g get a coder's info\n"
546 "G get the least used coder for a video stream\n"
547 "u update a coder's load/instances value\n"
548 "A allocate directly a s/w instance on a h/w coder\n"
549 "a allocate automatically a s/w instance\n"
550 "r release encoding resource (load) from a h/w instance\n"
551 "d delete xcoder from host resource pool\n"
552 "x add xcoder into host resource pool\n"
553 "c check hardware status in resource pool\n"
554 "C check hardware device detailed info\n"
@ NI_LOGAN_RETCODE_SUCCESS
#define LOGAN_MAX_DEVICE_CNT
@ NI_LOGAN_DEVICE_TYPE_ENCODER
@ NI_LOGAN_DEVICE_TYPE_DECODER
void ni_log_set_level(ni_log_level_t level)
Set ni_log_level.
ni_logan_retcode_t ni_logan_rsrc_list_all_devices(ni_logan_device_t *p_device)
List all devices with full information including s/w instances on the system.
ni_logan_device_context_t * ni_logan_rsrc_get_device_context(ni_logan_device_type_t device_type, int guid)
Allocates and returns a pointer to ni_logan_device_context_t struct based on provided device_type and...
ni_logan_retcode_t ni_logan_rsrc_list_devices(ni_logan_device_type_t device_type, ni_logan_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.
void ni_logan_rsrc_free_device_pool(ni_logan_device_pool_t *p_device_pool)
Free all resources taken by the device pool.
int ni_logan_rsrc_add_device(const char *dev, int should_match_rev)
Add an NetInt h/w device into resource pool on the host.
void ni_logan_rsrc_release_resource(ni_logan_device_context_t *p_device_context, ni_codec_t codec, unsigned long load)
Release resources allocated for decoding/encoding. function This must be called at the end of transco...
void ni_logan_rsrc_free_device_context(ni_logan_device_context_t *p_device_context)
Free previously allocated device context.
ni_logan_device_context_t * ni_logan_rsrc_allocate_direct(ni_logan_device_type_t device_type, int guid, ni_codec_t codec, int width, int height, int frame_rate, unsigned long *p_load)
Allocate resources for decoding/encoding, by designating explicitly the device to use.
ni_logan_device_context_t * ni_logan_rsrc_allocate_auto(ni_logan_device_type_t device_type, ni_alloc_rule_t rule, ni_codec_t codec, int width, int height, int frame_rate, unsigned long *p_load)
Allocate resources for decoding/encoding, based on the provided rule.
int ni_logan_rsrc_codec_is_available(int guid, ni_logan_device_type_t device_type)
check the NetInt h/w device in resource pool on the host.
int ni_logan_rsrc_remove_device(const char *dev)
Remove an NetInt h/w device from resource pool on the host.
ni_logan_device_info_t * ni_logan_rsrc_get_device_info(ni_logan_device_type_t device_type, int guid)
Query a specific device with detailed information on the system.
int ni_logan_check_hw_info(hw_device_info_t *p_hw_device_info, int task_mode, int load_threshold, int task_num_threshold, ni_logan_device_type_t device_type, int resolution)
check hw info, return the appropriate card number to use depends on the load&task_num&used resource
void ni_logan_rsrc_print_device_info(const ni_logan_device_info_t *p_device_info)
Print the content of the ni_logan_device_info_t struct.
ni_logan_device_pool_t * ni_logan_rsrc_get_device_pool(void)
Create and return the allocated ni_logan_device_pool_t struct.
int ni_logan_rsrc_update_device_load(ni_logan_device_context_t *p_device_context, int load, int sw_instance_cnt, const ni_logan_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 resour...
int ni_logan_rsrc_get_available_device(int width, int height, int frame_rate, ni_codec_t codec, ni_logan_device_type_t device_type, ni_logan_device_info_t *p_device_info)
Get the least used device that can handle decoding or encoding a video stream of certain resolution/f...
Exported definitions related to resource management of NI T-408 devices.
Private definitions related to resource management of NI T-408 devices.
Exported utility routines definition.
ni_logan_device_info_t * p_device_info
char dev_name[NI_LOGAN_MAX_DEVICE_NAME_LEN]
ni_logan_device_queue_t * p_device_queue
int32_t decoders[LOGAN_MAX_DEVICE_CNT]
int32_t encoders[LOGAN_MAX_DEVICE_CNT]
ni_logan_device_info_t encoders[LOGAN_MAX_DEVICE_CNT]
ni_logan_device_info_t decoders[LOGAN_MAX_DEVICE_CNT]
ni_sw_instance_status_t status
int getInt(const char *prompt)
void getLeastUsedCoderForVideo(void)
void change_log_level(void)
int getCmd(const char *prompt)
void getStr(const char *prompt, char *str)
void listAllCodersFull(void)
void updateCoderLoad(void)
void listOneTypeCoders(void)
void releaseEncRsrc(void)
float getFloat(const char *prompt)
void getCoderDetailInfo(void)
long getLong(const char *prompt)