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) \
59 #define LOG_TAG "MM_STREAMRECORDER"
61 #define _mmstreamrec_dbg_verb(fmt, args...) SLOGI(fmt, ##args);
62 #define _mmstreamrec_dbg_log(fmt, args...) SLOGD(fmt, ##args);
63 #define _mmstreamrec_dbg_warn(fmt, args...) SLOGW(fmt, ##args);
64 #define _mmstreamrec_dbg_err(fmt, args...) SLOGE(fmt, ##args);
65 #define _mmstreamrec_dbg_crit(fmt, args...) SLOGF(fmt, ##args);
68 * Macro for checking validity and debugging
70 #define mmf_return_if_fail(expr) \
72 _mmstreamrec_dbg_err("failed [%s]", #expr); \
77 * Macro for checking validity and debugging
79 #define mmf_return_val_if_fail(expr, val) \
82 _mmstreamrec_dbg_err("failed [%s]", #expr); \
88 * Minimum integer value
90 #define _MMSTREAMRECORDER_MIN_INT (INT_MIN)
93 * Maximum integer value
95 #define _MMSTREAMRECORDER_MAX_INT (INT_MAX)
98 * Minimum double value
100 #define _MMSTREAMRECORDER_MIN_DOUBLE (DBL_MIN)
103 * Maximum integer value
105 #define _MMSTREAMRECORDER_MAX_DOUBLE (DBL_MAX)
107 // TODO : MOVE OTHERS
109 PUSH_ENCODING_BUFFER_INIT = 0,
110 PUSH_ENCODING_BUFFER_RUN,
111 PUSH_ENCODING_BUFFER_STOP,
114 #define FPUTC_CHECK(x_char, x_file)\
116 if (fputc(x_char, x_file) == EOF) {\
117 _mmstreamrec_dbg_err("[Critical] fputc() returns fail.\n"); \
122 #define FPUTS_CHECK(x_str, x_file)\
124 if (fputs(x_str, x_file) == EOF) {\
125 _mmstreamrec_dbg_err("[Critical] fputs() returns fail.\n");\
131 /*=======================================================================================
133 ========================================================================================*/
134 #define MAX_ERROR_MESSAGE_LEN 128
135 #define MM_STREAMRECORDER_MIN_LOG_COUNT 10
137 /*=======================================================================================
138 | STRUCTURE DEFINITIONS |
139 ========================================================================================*/
141 typedef struct __mm_streamrecorder_ini {
142 /* video converter element */
143 gchar video_converter_element[STREAMRECORDER_INI_MAX_STRLEN];
144 } mm_streamrecorder_ini_t;
147 /*=======================================================================================
148 | CONSTANT DEFINITIONS |
149 ========================================================================================*/
151 /*=======================================================================================
152 | GLOBAL FUNCTION PROTOTYPES |
153 ========================================================================================*/
157 int _mmstreamrecorder_get_pixel_format(GstCaps *caps);
158 int _mmstreamrecorder_get_pixtype(unsigned int fourcc);
159 unsigned int _mmstreamrecorder_get_fourcc(int pixtype, int codectype, int use_zero_copy_format);
162 /* find top level tag only, do not use this function for finding sub level tags. tag_fourcc is Four-character-code (FOURCC) */
163 gint32 _mmstreamrecorder_double_to_fix(gdouble d_number);
166 int _mmstreamrecorder_get_freespace(const gchar *path, guint64 *free_space);
167 int _mmstreamrecorder_get_file_size(const char *filename, guint64 *size);
170 void _mmstreamrecorder_err_trace_write(char *str_filename, char *func_name, int line_num, char *fmt, ...);
172 guint16 get_language_code(const char *str);
173 gchar *str_to_utf8(const gchar *str);
174 __attribute__ ((gnu_inline)) inline gboolean write_tag(FILE *f, const gchar *tag);
175 __attribute__ ((gnu_inline)) inline gboolean write_to_32(FILE *f, guint val);
179 #endif /* __MM_STREAMRECORDER_UTIL_H__ */