4 * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Hyuntae Kim <ht1211.kim@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #ifndef __MM_STREAMRECORDER_UTIL_H__
23 #define __MM_STREAMRECORDER_UTIL_H__
25 /*=======================================================================================
27 ========================================================================================*/
29 #include <gst/gstutils.h>
30 #include <gst/gstpad.h>
39 /*=======================================================================================
40 | GLOBAL DEFINITIONS AND DECLARATIONS FOR STREAMRECORDER |
41 ========================================================================================*/
43 /*=======================================================================================
45 ========================================================================================*/
47 #define CLEAR(x) memset(&(x), 0, sizeof(x))
50 #define SAFE_FREE(x) \
56 #define _mmstreamrec_dbg_verb(fmt, args...) debug_verbose(" "fmt"\n", ##args);
57 #define _mmstreamrec_dbg_log(fmt, args...) debug_log(" "fmt"\n", ##args);
58 #define _mmstreamrec_dbg_warn(fmt, args...) debug_warning(" "fmt"\n", ##args);
59 #define _mmstreamrec_dbg_err(fmt, args...) debug_error(" "fmt"\n", ##args);
60 #define _mmstreamrec_dbg_crit(fmt, args...) debug_critical(" "fmt"\n", ##args);
63 * Macro for checking validity and debugging
65 #define mmf_return_if_fail(expr) \
67 _mmstreamrec_dbg_err("failed [%s]", #expr); \
72 * Macro for checking validity and debugging
74 #define mmf_return_val_if_fail(expr, val) \
77 _mmstreamrec_dbg_err("failed [%s]", #expr); \
83 * Minimum integer value
85 #define _MMSTREAMRECORDER_MIN_INT (INT_MIN)
88 * Maximum integer value
90 #define _MMSTREAMRECORDER_MAX_INT (INT_MAX)
93 * Minimum double value
95 #define _MMSTREAMRECORDER_MIN_DOUBLE (DBL_MIN)
98 * Maximum integer value
100 #define _MMSTREAMRECORDER_MAX_DOUBLE (DBL_MAX)
102 // TODO : MOVE OTHERS
104 PUSH_ENCODING_BUFFER_INIT = 0,
105 PUSH_ENCODING_BUFFER_RUN,
106 PUSH_ENCODING_BUFFER_STOP,
109 #define FPUTC_CHECK(x_char, x_file)\
111 if (fputc(x_char, x_file) == EOF) {\
112 _mmstreamrec_dbg_err("[Critical] fputc() returns fail.\n"); \
117 #define FPUTS_CHECK(x_str, x_file)\
119 if (fputs(x_str, x_file) == EOF) {\
120 _mmstreamrec_dbg_err("[Critical] fputs() returns fail.\n");\
126 /*=======================================================================================
128 ========================================================================================*/
129 #define MAX_ERROR_MESSAGE_LEN 128
130 #define MM_STREAMRECORDER_MIN_LOG_COUNT 10
132 /*=======================================================================================
133 | STRUCTURE DEFINITIONS |
134 ========================================================================================*/
136 typedef struct __mm_streamrecorder_ini {
137 /* video converter element */
138 gchar video_converter_element[STREAMRECORDER_INI_MAX_STRLEN];
139 } mm_streamrecorder_ini_t;
142 /*=======================================================================================
143 | CONSTANT DEFINITIONS |
144 ========================================================================================*/
146 /*=======================================================================================
147 | GLOBAL FUNCTION PROTOTYPES |
148 ========================================================================================*/
152 int _mmstreamrecorder_get_pixel_format(GstCaps *caps);
153 int _mmstreamrecorder_get_pixtype(unsigned int fourcc);
154 unsigned int _mmstreamrecorder_get_fourcc(int pixtype, int codectype, int use_zero_copy_format);
157 /* find top level tag only, do not use this function for finding sub level tags. tag_fourcc is Four-character-code (FOURCC) */
158 gint32 _mmstreamrecorder_double_to_fix(gdouble d_number);
161 int _mmstreamrecorder_get_freespace(const gchar *path, guint64 *free_space);
162 int _mmstreamrecorder_get_file_size(const char *filename, guint64 *size);
165 void _mmstreamrecorder_err_trace_write(char *str_filename, char *func_name, int line_num, char *fmt, ...);
167 guint16 get_language_code(const char *str);
168 gchar *str_to_utf8(const gchar *str);
169 __attribute__ ((gnu_inline)) inline gboolean write_tag(FILE *f, const gchar *tag);
170 __attribute__ ((gnu_inline)) inline gboolean write_to_32(FILE *f, guint val);
174 #endif /* __MM_STREAMRECORDER_UTIL_H__ */