libxcoder 5.6.0
Loading...
Searching...
No Matches
init_rsrc.c
Go to the documentation of this file.
1/*******************************************************************************
2 *
3 * Copyright (C) 2022 NETINT Technologies
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 * SOFTWARE.
19 *
20 ******************************************************************************/
21
22/*!*****************************************************************************
23 * \file init_rsrc.c
24 *
25 * \brief Application for registering Netint transcoding devices on system
26 * for use by libxcoder
27 ******************************************************************************/
28
29#include <stdio.h>
30
31#if __linux__ || __APPLE__
32#include <unistd.h>
33#include <sys/types.h>
34#elif _WIN32
35#include "ni_getopt.h"
36#endif
37
38#include "ni_defs.h"
39#include "ni_log.h"
40#include "ni_rsrc_api.h"
41#include "ni_rsrc_priv.h"
42
43int main(int argc, char *argv[])
44{
45 int should_match_rev = 1;
46 int opt;
47 int timeout_seconds = 0;
48 ni_log_level_t log_level = NI_LOG_INFO;
49
50 // arg handling
51 while ((opt = getopt(argc, argv, "hrt:l:v")) != -1)
52 {
53 switch (opt)
54 {
55 case 'h':
56 // help message
57 printf("-------- init_rsrc v%s --------\n"
58 "Initialize NetInt transcoder resource pool\n"
59 "\n"
60 "-r Init transcoder card resource regardless of firmware release version to \n"
61 " libxcoder release version compatibility. Default is to only init cards with \n"
62 " compatible firmware version.\n"
63 "-t Set timeout time in seconds for device polling, will exit with failure if \n"
64 " reached. Default 0s which means no timeout.\n"
65 "-l Set loglevel of libxcoder API.\n"
66 " [none, fatal, error, info, debug, trace]\n"
67 " Default: info\n"
68 "-h Display this help and exit.\n"
69 "-v Print version info.\n",
71 return 0;
72 case 'r':
73 should_match_rev = 0;
74 break;
75 case 't':
76 timeout_seconds = atoi(optarg);
77 printf("Timeout will be set %d\n", timeout_seconds);
78 break;
79 case 'l':
80 log_level = arg_to_ni_log_level(optarg);
81 if (log_level != NI_LOG_INVALID)
82 {
83 ni_log_set_level(log_level);
84 } else {
85 fprintf(stderr, "FATAL: invalid log level selected: %s\n",
86 optarg);
87 return 1;
88 }
89 break;
90 case 'v':
91 printf("Release ver: %s\n"
92 "API ver: %s\n"
93 "Date: %s\n"
94 "ID: %s\n",
97 return 0;
98 default:
99 fprintf(stderr, "FATAL: invalid arg '%c'\n", opt);
100 return 1;
101 }
102 }
103
104#if __linux__
105 ni_retcode_t retval = ni_rsrc_init(should_match_rev, timeout_seconds);
106 int ret_ts = system("host_ts.sh");
107 if (ret_ts != 0)
108 {
109 printf("Unable to send Host time\n");
110 }
111 return retval;
112#elif __APPLE__
113 return ni_rsrc_init(should_match_rev, timeout_seconds);
114#elif _WIN32
115 ni_retcode_t retval = ni_rsrc_init(should_match_rev, timeout_seconds);
116 if (NI_RETCODE_SUCCESS == retval)
117 {
118 printf("NETINT Resources Intitialized Successfully\n");
119 }
120
121 while (1)
122 Sleep(1000);
123
124 return retval;
125#endif
126}
int main()
Definition client.cpp:51
Common NETINT definitions used by all modules.
#define NI_XCODER_REVISION
Definition ni_defs.h:98
#define LIBXCODER_API_VERSION
Definition ni_defs.h:115
ni_retcode_t
Definition ni_defs.h:442
@ NI_RETCODE_SUCCESS
Definition ni_defs.h:443
#define atoi(p_str)
int getopt(int argc, char *argv[], const char *optstring)
Definition ni_getopt.c:38
char * optarg
Definition ni_getopt.c:33
Implementation of getopt() and getopt_long() for Windows environment.
ni_log_level_t arg_to_ni_log_level(const char *arg_str)
Convert terminal arg string to ni_log_level_t.
Definition ni_log.c:262
void ni_log_set_level(ni_log_level_t level)
Set ni_log_level.
Definition ni_log.c:202
Logging definitions.
ni_log_level_t
Definition ni_log.h:58
@ NI_LOG_INFO
Definition ni_log.h:63
@ NI_LOG_INVALID
Definition ni_log.h:59
#define NI_SW_RELEASE_ID
#define NI_SW_RELEASE_TIME
Public definitions for managing NETINT video processing devices.
LIB_API int ni_rsrc_init(int should_match_rev, int timeout_seconds)
Initialize and create all resources required to work with NETINT NVMe transcoder devices....
Private definitions used by ni_rsrc_api.cpp for management of NETINT video processing devices.