From: Andrey Shelest Date: Thu, 17 Dec 2015 09:33:18 +0000 (+0200) Subject: Added installation default ini file. X-Git-Tag: submit/tizen/20151218.053239^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=db436c67b445c64559ece6c1ca93698a4b9e96f4;p=platform%2Fcore%2Fapi%2Fmediastreamer.git Added installation default ini file. Change-Id: I64f4e552e0a445db5af91159f772c4a93acbd3e5 Signed-off-by: Andrey Shelest --- diff --git a/CMakeLists.txt b/CMakeLists.txt index e3d5fcc..434752a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ FOREACH(flag ${${fw_name}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(CMAKE_C_FLAGS "-I./include -I./include/headers ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") IF("${ARCH}" STREQUAL "arm") @@ -27,7 +27,6 @@ IF("${ARCH}" STREQUAL "arm") ENDIF("${ARCH}" STREQUAL "arm") ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") -ADD_DEFINITIONS("-DTIZEN_DEBUG") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}") diff --git a/config/media_streamer.ini b/config/media_streamer.ini new file mode 100644 index 0000000..107c922 --- /dev/null +++ b/config/media_streamer.ini @@ -0,0 +1,41 @@ +[general] +; generating dot file representing pipeline state +generate dot = no +use decodebin = yes +dot dir = /tmp + + +[sources] + +audio_source = pulsesrc +camera_source = v4l2src +video_source = ximagesrc +udp_source = udpsrc + + +[sinks] +audio_sink = pulsesink +video_sink = waylandsink +evas_sink = evaspixmapsink +udp_sink = udpsink + + +[h263] +encoder = avenc_h263 +decoder = avdec_h263 +rtppay = rtph263pay +rtpdepay = rtph263depay +parser = h263parse + + +[h264] +encoder = avenc_h264 +decoder = avdec_h264 +rtppay = rtph264pay +rtpdepay = rtph264depay +parser = h264parse + + +[audio-raw] +rtppay = rtpL16pay +rtpdepay = rtpL16depay diff --git a/include/media_streamer_util.h b/include/media_streamer_util.h index 434b6d5..49e4f13 100644 --- a/include/media_streamer_util.h +++ b/include/media_streamer_util.h @@ -85,7 +85,10 @@ extern "C" { #define MS_TIME_NONE ((int)-1) /* Ini Utils */ -#define MEDIA_STREAMER_INI_DEFAULT_PATH "/usr/etc/media_streamer.ini" +#ifndef MEDIA_STREAMER_INI_PATH + #define MEDIA_STREAMER_INI_PATH "/etc/media_streamer.ini" +#endif + #define MEDIA_STREAMER_INI_MAX_STRLEN 100 /** @@ -182,56 +185,6 @@ typedef struct { } #define MEDIA_STREAMER_DEFAULT_DOT_DIR "/tmp" -#define MEDIA_STREAMER_DEFAULT_INI "\ -[general] \n\ -; generating dot file representing pipeline state \n\ -generate dot = no \n\ -use decodebin = yes \n\ -dot dir = /tmp \n\ -\n\ -\n\ -[sources] \n\ -\n\ -audio_source = "DEFAULT_AUDIO_SOURCE" \n\ -camera_source = "DEFAULT_CAMERA_SOURCE" \n\ -video_source = "DEFAULT_VIDEO_SOURCE" \n\ -udp_source = "DEFAULT_UDP_SOURCE" \n\ -\n\ -\n\ -[sinks] \n\ -\n\ -audio_sink = "DEFAULT_AUDIO_SINK" \n\ -video_sink = "DEFAULT_VIDEO_SINK" \n\ -evas_sink = "DEFAULT_EVAS_SINK" \n\ -udp_sink = "DEFAULT_UDP_SINK" \n\ -\n\ -\n\ -[h263] \n\ -\n\ -encoder = avenc_h263 \n\ -decoder = avdec_h263 \n\ -rtppay = rtph263pay \n\ -rtpdepay = rtph263depay \n\ -parser = h263parse \n\ -\n\ -\n\ -[h264] \n\ -\n\ -encoder = omxh264enc \n\ -decoder = avdec_h264 \n\ -rtppay = rtph264pay \n\ -rtpdepay = rtph264depay \n\ -parser = h264parse \n\ -\n\ -\n\ -[audio-raw] \n\ -\n\ -encoder = \n\ -decoder = \n\ -rtppay = rtpL16pay \n\ -rtpdepay = rtpL16depay \n\ -\n\ -" /** * @brief Loads media streamer settings from ini file. diff --git a/packaging/capi-media-streamer.spec b/packaging/capi-media-streamer.spec index 7251a8a..d94ec49 100755 --- a/packaging/capi-media-streamer.spec +++ b/packaging/capi-media-streamer.spec @@ -36,12 +36,19 @@ MediaStreamer Library in Tizen Native API (DEV). %setup -q cp %{SOURCE1001} . +%define ini_path /usr/etc/media_streamer.ini + %build +flags="-DMEDIA_STREAMER_INI_PATH=\\\"%{ini_path}\\\"" + %if 0%{?sec_build_binary_debug_enable} -export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE" -export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE" -export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE" +flags="$flags -DTIZEN_DEBUG_ENABLE" %endif + +export CFLAGS="$CFLAGS $flags" +export CXXFLAGS="$CXXFLAGS $flags" +export FFLAGS="$FFLAGS $flags" + MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` %cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER} @@ -54,10 +61,14 @@ mkdir -p %{buildroot}/usr/bin cp LICENSE.APLv2 %{buildroot}%{_datadir}/license/%{name} cp test/media_streamer_test %{buildroot}/usr/bin +mkdir -p %{buildroot}/usr/etc +cp -rf config/media_streamer.ini %{buildroot}%{ini_path} + %make_install %post /sbin/ldconfig +chsmack -a "_" %{ini_path} %postun -p /sbin/ldconfig @@ -68,6 +79,7 @@ cp test/media_streamer_test %{buildroot}/usr/bin %{_libdir}/libcapi-media-streamer.so.* %{_datadir}/license/%{name} %{_bindir}/* +%config %{ini_path} %files devel %manifest %{name}.manifest @@ -75,4 +87,3 @@ cp test/media_streamer_test %{buildroot}/usr/bin %{_libdir}/pkgconfig/*.pc %{_libdir}/libcapi-media-streamer.so - diff --git a/src/media_streamer_util.c b/src/media_streamer_util.c index 2f6411c..aa53c6c 100644 --- a/src/media_streamer_util.c +++ b/src/media_streamer_util.c @@ -19,10 +19,6 @@ #include #include -#ifdef MEDIA_STREAMER_DEFAULT_INI -static gboolean __ms_generate_default_ini(void); -#endif - static void __ms_check_ini_status(void); gchar *__ms_ini_get_string(dictionary * dict, const char *ini_path, char *default_str) @@ -53,22 +49,14 @@ gboolean __ms_load_ini_dictionary(dictionary ** dict) dictionary *ms_dict = NULL; /* loading existing ini file */ - ms_dict = iniparser_load(MEDIA_STREAMER_INI_DEFAULT_PATH); + ms_dict = iniparser_load(MEDIA_STREAMER_INI_PATH); /* if no file exists. create one with set of default values */ if (!ms_dict) { -#ifdef MEDIA_STREAMER_DEFAULT_INI - ms_debug("No inifile found. Media streamer will create default inifile."); - if (FALSE == __ms_generate_default_ini()) { - ms_debug("Creating default .ini file failed. Media-streamer will use default values."); - } else { - /* load default ini */ - ms_dict = iniparser_load(MEDIA_STREAMER_INI_DEFAULT_PATH); - } -#else - ms_debug("No ini file found."); + ms_debug("Could not open ini [%s]. Media-streamer will use default values.", MEDIA_STREAMER_INI_PATH); return FALSE; -#endif + } else { + ms_debug("Open ini file [%s].", MEDIA_STREAMER_INI_PATH); } *dict = ms_dict; @@ -104,9 +92,6 @@ void __ms_load_ini_settings(media_streamer_ini_t * ini) ini->use_decodebin = iniparser_getboolean(dict, "general:use decodebin", DEFAULT_USE_DECODEBIN); } else { /* if dict is not available just fill the structure with default values */ - ms_debug("failed to load ini. using hardcoded default"); - - /* general settings */ ini->generate_dot = DEFAULT_GENERATE_DOT; ini->use_decodebin = DEFAULT_USE_DECODEBIN; } @@ -120,7 +105,7 @@ void __ms_load_ini_settings(media_streamer_ini_t * ini) static void __ms_check_ini_status(void) { - FILE *fp = fopen(MEDIA_STREAMER_INI_DEFAULT_PATH, "r"); + FILE *fp = fopen(MEDIA_STREAMER_INI_PATH, "r"); int file_size = 0; int status = 0; @@ -132,36 +117,13 @@ static void __ms_check_ini_status(void) fclose(fp); if (file_size < 5) { ms_debug("media_streamer.ini file size=%d, Corrupted! Removed", file_size); - status = g_remove(MEDIA_STREAMER_INI_DEFAULT_PATH); + status = g_remove(MEDIA_STREAMER_INI_PATH); if (status == -1) ms_error("failed to delete corrupted ini"); } } } -#ifdef MEDIA_STREAMER_DEFAULT_INI -static gboolean __ms_generate_default_ini(void) -{ - FILE *fp = NULL; - gchar *default_ini = MEDIA_STREAMER_DEFAULT_INI; - - /* create new file */ - fp = fopen(MEDIA_STREAMER_INI_DEFAULT_PATH, "wt"); - - if (!fp) - return FALSE; - - /* writing default ini file */ - if (strlen(default_ini) != fwrite(default_ini, 1, strlen(default_ini), fp)) { - fclose(fp); - return FALSE; - } - - fclose(fp); - return TRUE; -} -#endif - const gchar *__ms_convert_mime_to_string(media_format_mimetype_e mime) { switch (mime) {