blob: c070f99d4c9768cc1143b90a592939d5c6727fd0 [file] [log] [blame]
Gong Ke497c4c22020-03-20 10:15:42 +08001/**
2 * \file
3 * \brief Utility functions
4 */
5
Pengfei Liub4734232020-01-17 18:25:10 +08006#ifndef _DVR_UTILS_H_
7#define _DVR_UTILS_H_
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13/**\brief Write a string cmd to a file
Gong Ke497c4c22020-03-20 10:15:42 +080014 * \param[in] name File name
15 * \param[in] cmd String command
Pengfei Liub4734232020-01-17 18:25:10 +080016 * \return DVR_SUCCESS On success
17 * \return Error code On failure
18 */
hualing chena540a7e2020-03-27 16:44:05 +080019int dvr_file_echo(const char *name, const char *cmd);
20
hualing chena540a7e2020-03-27 16:44:05 +080021/**\brief read sysfs file
22 * \param[in] name, File name
23 * \param[out] buf, store sysfs node value
24 * \return DVR_SUCCESS On success
25 * \return Error code On failure
26 */
hualing chena540a7e2020-03-27 16:44:05 +080027int dvr_file_read(const char *name, char *buf, int len);
28
wentao ma7d642782022-10-23 18:26:16 -070029/**\brief read property value
30 * \param[in] name, property name
31 * \param[out] buf, property value
hualing chena540a7e2020-03-27 16:44:05 +080032 * \return DVR_SUCCESS On success
wentao ma7d642782022-10-23 18:26:16 -070033 * \return DVR_FAILURE On failure
hualing chena540a7e2020-03-27 16:44:05 +080034 */
hualing chena540a7e2020-03-27 16:44:05 +080035int dvr_prop_read(const char *name, char *buf, int len);
Gong Ke497c4c22020-03-20 10:15:42 +080036
wentao ma7d642782022-10-23 18:26:16 -070037/**\brief write property value
38 * \param[in] name, property name
39 * \param[in] value, property value
40 * \return DVR_SUCCESS On success
41 * \return DVR_FAILURE On failure
42 */
43int dvr_prop_write(const char *name, char *value);
44
45/**\brief read int type property value
46 * \param[in] name, property name
47 * \param[in] def, default property value in case any failure
48 * \return int type property value. If any failure default value will be returned instead
49 */
50int dvr_prop_read_int(const char *name, int def);
51
Wentao MA907b6432022-08-01 06:23:08 +000052/**\brief calculates the difference between ts1 and ts2
53 * \param[in] ts1, higher bound of the timespec* whose length is calculated
54 * \param[in] ts2, lower bound of the timespec* whose length is calculated
55 * \param[out] ts3, The result timespec* of (ts1-ts2)
56 * \return void
57 */
58void clock_timespec_subtract(struct timespec *ts1, struct timespec *ts2, struct timespec *ts3);
59
Pengfei Liub4734232020-01-17 18:25:10 +080060#ifdef __cplusplus
61}
62#endif
63
64#endif /*END _DVR_UTILS_H_*/