#include <glib/gstdio.h>
#include <stdlib.h>
#include <iniparser.h>
-#include <mm_debug.h>
#include <mm_error.h>
#include "mm_streamrecorder_ini.h"
if (str) { \
length = strlen(str); \
if ((length > 1) && (length < STREAMRECORDER_INI_MAX_STRLEN)) \
- strncpy(x_item, str, length+1); \
+ strncpy(x_item, str, STREAMRECORDER_INI_MAX_STRLEN-1); \
else \
strncpy(x_item, x_default, STREAMRECORDER_INI_MAX_STRLEN-1); \
} else { \
token = strtok_r(temp_arr, delimiters, &usr_ptr); \
while (token) { \
if (index > x_list_max -1) { \
- debug_error("%d is not valid index\n", index); \
+ _mmstreamrec_dbg_err("%d is not valid index\n", index); \
break; \
} else { \
value = atoi(token); \
{
dictionary *dict = NULL;
- debug_fenter();
+ _mmstreamrec_dbg_warn("enter");
__mm_streamrecorder_ini_check_status();
/* first, try to load existing ini file */
dict = iniparser_load(MM_STREAMRECORDER_INI_DEFAULT_PATH);
- /* if no file exists. create one with set of default values */
- if (!dict) {
- _mmstreamrec_dbg_err("No ini file found. \n");
- return MM_ERROR_FILE_NOT_FOUND;
- }
-
/* get ini values */
memset(ini, 0, sizeof(mm_streamrecorder_ini_t));
ini->convert_output_buffer_num = iniparser_getint(dict, "general:convert output buffer num", DEFAULT_CONVERT_OUTPUT_BUFFER_NUM);
ini->reset_pause_time = iniparser_getint(dict, "general:reset pause time", DEFAULT_RESET_PAUSE_TIME);
ini->screen_record = iniparser_getint(dict, "general:screen record", DEFAULT_SCREEN_RECORD);
+ ini->hw_encoder_supported = iniparser_getboolean(dict, "general:hw encoder supported", DEFAULT_HW_ENCODER_SUPPORTED);
+ MM_STREAMRECORDER_INI_GET_STRING(dict, ini->video_codec_element_hw, (const char *)"general:video codec element hw", (char *)DEFAULT_VIDEO_SOURCE);
/*encodebin */
ini->encsink_bin_profile = iniparser_getint(dict, "encodebin:encsink bin profile", DEFAULT_ENCSINK_BIN_PROFILE);
ini->video_frame_wait_time = iniparser_getint(dict, "video param:video frame wait time", DEFAULT_VIDEO_FRAME_WAIT_TIME);
/*supported attribute*/
- MMSTREAMRECORDER_INI_GET_INT_FROM_LIST(dict, ini->supported_video_width, STREAMRECORDER_ATTRIBUTE_NUM_MAX, "attribute:supported width", DEFAULT_SUPPORTED_WIDTH);
- MMSTREAMRECORDER_INI_GET_INT_FROM_LIST(dict, ini->supported_video_height, STREAMRECORDER_ATTRIBUTE_NUM_MAX, "attribute:supported height", DEFAULT_SUPPORTED_HEIGHT);
- __get_element_list(ini, iniparser_getstring(dict, "attribute:supported audio encoders", DEFAULT_SUPPORTED_AUDIO_ENCODERS), KEYWORD_AUDIO_ENCODERS);
- __get_element_list(ini, iniparser_getstring(dict, "attribute:supported video encoders", DEFAULT_SUPPORTED_VIDEO_ENCODERS), KEYWORD_VIDEO_ENCODERS);
- __get_element_list(ini, iniparser_getstring(dict, "attribute:supported file formats", DEFAULT_SUPPORTED_FILE_FORMATS), KEYWORD_FILE_FORMATS);
+ MMSTREAMRECORDER_INI_GET_INT_FROM_LIST(dict, ini->supported_video_width, STREAMRECORDER_ATTRIBUTE_NUM_MAX, "attribute:supported width", (char *)DEFAULT_SUPPORTED_WIDTH);
+ MMSTREAMRECORDER_INI_GET_INT_FROM_LIST(dict, ini->supported_video_height, STREAMRECORDER_ATTRIBUTE_NUM_MAX, "attribute:supported height", (char *)DEFAULT_SUPPORTED_HEIGHT);
+ __get_element_list(ini, iniparser_getstring(dict, "attribute:supported audio encoders", (char*)DEFAULT_SUPPORTED_AUDIO_ENCODERS), KEYWORD_AUDIO_ENCODERS);
+ __get_element_list(ini, iniparser_getstring(dict, "attribute:supported video encoders", (char*)DEFAULT_SUPPORTED_VIDEO_ENCODERS), KEYWORD_VIDEO_ENCODERS);
+ __get_element_list(ini, iniparser_getstring(dict, "attribute:supported file formats", (char*)DEFAULT_SUPPORTED_FILE_FORMATS), KEYWORD_FILE_FORMATS);
+
+ /* debug */
+ ini->generate_dot = iniparser_getboolean(dict, "debug:generate dot", DEFAULT_GENERATE_DOT);
} else { /* if dict is not available just fill the structure with default value */
_mmstreamrec_dbg_err("failed to load ini. using hardcoded default\n");
ini->convert_output_buffer_num = DEFAULT_CONVERT_OUTPUT_BUFFER_NUM;
ini->reset_pause_time = DEFAULT_RESET_PAUSE_TIME;
ini->screen_record = DEFAULT_SCREEN_RECORD;
+ ini->hw_encoder_supported = DEFAULT_HW_ENCODER_SUPPORTED;
+ strncpy(ini->video_codec_element_hw, DEFAULT_VIDEO_CODEC_ELEMENT_HW, STREAMRECORDER_INI_MAX_STRLEN - 1);
/*encodebin */
ini->encsink_bin_profile = DEFAULT_ENCSINK_BIN_PROFILE;
ini->video_frame_wait_time = DEFAULT_VIDEO_FRAME_WAIT_TIME;
/*supported attributes*/
- __get_element_list(ini, DEFAULT_SUPPORTED_AUDIO_ENCODERS, KEYWORD_AUDIO_ENCODERS);
- __get_element_list(ini, DEFAULT_SUPPORTED_VIDEO_ENCODERS, KEYWORD_VIDEO_ENCODERS);
- __get_element_list(ini, DEFAULT_SUPPORTED_FILE_FORMATS, KEYWORD_FILE_FORMATS);
+ __get_element_list(ini, (char *)DEFAULT_SUPPORTED_HEIGHT, KEYWORD_VIDEO_HEIGHT);
+ __get_element_list(ini, (char *)DEFAULT_SUPPORTED_WIDTH, KEYWORD_VIDEO_WIDTH);
+ __get_element_list(ini, (char *)DEFAULT_SUPPORTED_AUDIO_ENCODERS, KEYWORD_AUDIO_ENCODERS);
+ __get_element_list(ini, (char *)DEFAULT_SUPPORTED_VIDEO_ENCODERS, KEYWORD_VIDEO_ENCODERS);
+ __get_element_list(ini, (char *)DEFAULT_SUPPORTED_FILE_FORMATS, KEYWORD_FILE_FORMATS);
+
+ /* debug */
+ ini->generate_dot = DEFAULT_GENERATE_DOT;
}
/* free dict as we got our own structure */
- iniparser_freedict(dict);
+ if (dict)
+ iniparser_freedict(dict);
/* dump structure */
_mmstreamrec_dbg_log("[Stream Recorder initial setting][Start]");
_mmstreamrec_dbg_log("convert_output_buffer_num : %d", ini->convert_output_buffer_num);
_mmstreamrec_dbg_log("reset_pause_time : %d", ini->reset_pause_time);
_mmstreamrec_dbg_log("screen_record : %d", ini->screen_record);
+ _mmstreamrec_dbg_log("hw_encoder_supported : %d", ini->hw_encoder_supported);
+ _mmstreamrec_dbg_log("video_codec_element_hw : %s", ini->video_codec_element_hw);
/*encodebin */
_mmstreamrec_dbg_log("encode bin profile : %d", ini->encsink_bin_profile);
/* video parameter */
_mmstreamrec_dbg_log("video_frame_wait_time : %d", ini->video_frame_wait_time);
+ /* debug */
+ _mmstreamrec_dbg_log("generate_dot : %d", ini->generate_dot);
+ if (ini->generate_dot == TRUE) {
+ _mmstreamrec_dbg_log("generate_dot is TRUE, dot file will be stored into /tmp/");
+ g_setenv("GST_DEBUG_DUMP_DOT_DIR", "/tmp/", TRUE);
+ }
_mmstreamrec_dbg_log("[Stream Recorder initial setting][End]");
loaded = TRUE;
- debug_fleave();
+ _mmstreamrec_dbg_warn("leave");
return MM_ERROR_NONE;
}
/* copy list */
switch (keyword_type) {
+ case KEYWORD_VIDEO_HEIGHT:
+ {
+ for (walk = list; *walk; walk++) {
+ ini->supported_video_height[i] = atoi(*walk);
+ i++;
+ }
+ break;
+ }
+ case KEYWORD_VIDEO_WIDTH:
+ {
+ for (walk = list; *walk; walk++) {
+ ini->supported_video_width[i] = atoi(*walk);
+ i++;
+ }
+ break;
+ }
case KEYWORD_AUDIO_ENCODERS:
{
for (walk = list; *walk; walk++) {
static
void __mm_streamrecorder_ini_check_status(void)
{
- struct stat ini_buff;
+ GStatBuf ini_buff;
+ char buf[255] = {0, };
- debug_fenter();
+ _mmstreamrec_dbg_warn("enter");
if (g_stat(MM_STREAMRECORDER_INI_DEFAULT_PATH, &ini_buff) < 0) {
_mmstreamrec_dbg_err("failed to get mmfw_streamrecorder.ini status\n");
} else {
if (ini_buff.st_size < 5) {
_mmstreamrec_dbg_err("mmfw_streamrecorder.ini file size=%d, Corrupted! So, Removed\n", (int)ini_buff.st_size);
- g_remove(MM_STREAMRECORDER_INI_DEFAULT_PATH);
+ if (g_remove(MM_STREAMRECORDER_INI_DEFAULT_PATH) == -1) {
+ strerror_r(errno, buf, sizeof(buf));
+ _mmstreamrec_dbg_err("failed to delete corrupted ini [%s]", buf);
+ }
}
}
- debug_fleave();
+ _mmstreamrec_dbg_warn("leave");
}
int _mm_streamrecorder_ini_unload(mm_streamrecorder_ini_t *ini)
{
- debug_fenter();
+ _mmstreamrec_dbg_warn("enter");
loaded = FALSE;
- debug_fleave();
+ _mmstreamrec_dbg_warn("leave");
return MM_ERROR_NONE;
}