*
* @since_tizen 3.0
*/
-GstElement *__ms_video_encoder_element_create(dictionary *dict, media_format_mimetype_e mime);
+GstElement *__ms_video_encoder_element_create(media_format_mimetype_e mime);
/**
* @brief Creates decoder GstElement by mime type.
*
* @since_tizen 3.0
*/
-GstElement *__ms_video_decoder_element_create(dictionary *dict, media_format_mimetype_e mime);
+GstElement *__ms_video_decoder_element_create(media_format_mimetype_e mime);
/**
* @brief Creates audio encoder GstElement.
#define MEDIA_STREAMER_INI_PATH "/etc/media_streamer.ini"
#endif
-#define MEDIA_STREAMER_INI_MAX_STRLEN 100
+#define INI_MAX_STRLEN (100)
#define RTP_STREAM_DISABLED (0)
/**
#define DEFAULT_UDP_SOURCE "udpsrc"
#define DEFAULT_FILE_SOURCE "filesrc"
#define DEFAULT_HTTP_SOURCE "souphttpsrc"
+#define DEFAULT_FILE_SINK "filesink"
#define DEFAULT_UDP_SINK "udpsink"
#define DEFAULT_RTP_BIN "rtpbin"
void __ms_load_ini_settings(media_streamer_ini_t *ini);
/**
- * @brief Load settings from ini file into dictionary object.
+ * @brief Get instance of ini dictionary or create one if it doesn`t exist.
*
* @since_tizen 3.0
*/
-gboolean __ms_load_ini_dictionary(dictionary **dict);
-
-/**
- * @brief Destroys ini dictionary object and frees all resources.
- *
- * @since_tizen 3.0
- */
-gboolean __ms_destroy_ini_dictionary(dictionary *dict);
+dictionary *__ms_get_ini_instance(void);
/**
* @brief Read and copy string reading from ini file.
*
* @since_tizen 3.0
*/
-gchar *__ms_ini_get_string(dictionary *dict, const char *ini_path, char *default_str);
+gchar *__ms_ini_get_string(const char *ini_path, char *default_str);
/**
* @brief Reads comma-separated string list from ini file.
*
* @since_tizen 3.0
*/
-void __ms_ini_read_list(dictionary *dict, const char *key, gchar ***list);
+void __ms_ini_read_list(const char *key, gchar ***list);
/**
* @brief Converts Media Format mime type into Caps media format string.
#define H264_PARSER_CONFIG_INTERVAL 5
#define H264_ENCODER_ZEROLATENCY 0x00000004
-#define NODE_CONF_FIELD_LEN 100
void __ms_generate_dots(GstElement *bin, gchar *name_tag)
{
/* Create element by predefined format element type */
} else if (!found_element && next_elem_bin_name && MS_ELEMENT_IS_ENCODER(next_elem_bin_name)) {
- dictionary *dict = NULL;
-
- __ms_load_ini_dictionary(&dict);
if (MS_ELEMENT_IS_VIDEO(next_elem_bin_name))
- found_element = __ms_video_encoder_element_create(dict, MEDIA_FORMAT_H263);
+ found_element = __ms_video_encoder_element_create(MEDIA_FORMAT_H263);
else
found_element = __ms_audio_encoder_element_create();
- __ms_destroy_ini_dictionary(dict);
-
/* Create element by caps of the previous element */
} else if (!found_element) {
GstPad *src_pad = NULL;
found_element = __ms_combine_next_element(found_element, NULL, ms_streamer->topology_bin, MEDIA_STREAMER_PAYLOADER_KLASS, NULL, NULL);
found_element = __ms_combine_next_element(found_element, NULL, ms_streamer->topology_bin, MEDIA_STREAMER_BIN_KLASS, "rtp_container", NULL);
} else {
+ found_element = __ms_combine_next_element(found_element, src_pad, ms_streamer->topology_bin, MEDIA_STREAMER_CONVERTER_KLASS, NULL, DEFAULT_VIDEO_CONVERT);
found_element = __ms_combine_next_element(found_element, NULL, ms_streamer->sink_bin, MEDIA_STREAMER_QUEUE_KLASS, NULL, DEFAULT_QUEUE);
found_element = __ms_combine_next_element(found_element, NULL, ms_streamer->sink_bin, MEDIA_STREAMER_SINK_KLASS, NULL, NULL);
}
GstElement *__ms_node_element_create(node_plug_s *plug_info, media_streamer_node_type_e type)
{
- dictionary *dict = NULL;
GstElement *gst_element = NULL;
const gchar *src_type, *sink_type;
* Try to get plugin name that defined in ini file
* according with node type and specified format. */
ms_info("Specified node formats types: in[%s] - out[%s]", sink_type, src_type);
- gchar conf_key[NODE_CONF_FIELD_LEN] = {0,};
- if (snprintf(conf_key, NODE_CONF_FIELD_LEN, "node type %d:%s", type, (sink_type ? sink_type : src_type)) >= NODE_CONF_FIELD_LEN) {
- ms_error("Failed to generate config field name, size >= %d", NODE_CONF_FIELD_LEN);
+ gchar conf_key[INI_MAX_STRLEN] = {0,};
+ if (snprintf(conf_key, INI_MAX_STRLEN, "node type %d:%s", type, (sink_type ? sink_type : src_type)) >= INI_MAX_STRLEN) {
+ ms_error("Failed to generate config field name, size >= %d", INI_MAX_STRLEN);
return NULL;
}
- __ms_load_ini_dictionary(&dict);
- gchar *plugin_name = __ms_ini_get_string(dict, conf_key, NULL);
+ gchar *plugin_name = __ms_ini_get_string(conf_key, NULL);
if (plugin_name) {
gst_element = __ms_element_create(plugin_name, NULL);
MS_SAFE_GFREE(plugin_name);
}
- __ms_destroy_ini_dictionary(dict);
}
/* 3. Third priority:
* try to find compatible plugin in gstreamer registry.
* Elements that are compatible but defined as excluded will be skipped*/
if(!gst_element) {
- __ms_load_ini_dictionary(&dict);
-
/* Read exclude elements list */
- __ms_ini_read_list(dict, "general:exclude elements", &plug_info->exclude_names);
+ __ms_ini_read_list("general:exclude elements", &plug_info->exclude_names);
GList *factories = gst_registry_feature_filter(gst_registry_get(),
__ms_feature_node_filter, TRUE, plug_info);
g_strfreev(plug_info->exclude_names);
gst_plugin_list_free(factories);
- __ms_destroy_ini_dictionary(dict);
}
return gst_element;
}
-GstElement *__ms_video_encoder_element_create(dictionary * dict, media_format_mimetype_e mime)
+GstElement *__ms_video_encoder_element_create(media_format_mimetype_e mime)
{
char *plugin_name = NULL;
char *format_prefix = NULL;
GstElement *video_convert = __ms_element_create(DEFAULT_VIDEO_CONVERT, NULL);
format_prefix = g_strdup_printf("%s:encoder", __ms_convert_mime_to_string(mime));
- plugin_name = __ms_ini_get_string(dict, format_prefix, DEFAULT_VIDEO_ENCODER);
+ plugin_name = __ms_ini_get_string(format_prefix, DEFAULT_VIDEO_ENCODER);
GstElement *encoder_elem = __ms_element_create(plugin_name, NULL);
MS_SAFE_FREE(format_prefix);
MS_SAFE_FREE(plugin_name);
format_prefix = g_strdup_printf("%s:parser", __ms_convert_mime_to_string(mime));
- plugin_name = __ms_ini_get_string(dict, format_prefix, DEFAULT_VIDEO_PARSER);
+ plugin_name = __ms_ini_get_string(format_prefix, DEFAULT_VIDEO_PARSER);
GstElement *encoder_parser = __ms_element_create(plugin_name, NULL);
MS_SAFE_FREE(format_prefix);
return encoder_bin;
}
-GstElement *__ms_video_decoder_element_create(dictionary * dict, media_format_mimetype_e mime)
+GstElement *__ms_video_decoder_element_create(media_format_mimetype_e mime)
{
char *plugin_name = NULL;
char *format_prefix = NULL;
GstElement *last_elem = NULL;
format_prefix = g_strdup_printf("%s:decoder", __ms_convert_mime_to_string(mime));
- plugin_name = __ms_ini_get_string(dict, format_prefix, DEFAULT_VIDEO_DECODER);
+ plugin_name = __ms_ini_get_string(format_prefix, DEFAULT_VIDEO_DECODER);
GstElement *decoder_elem = __ms_element_create(plugin_name, NULL);
MS_SAFE_FREE(format_prefix);
MS_SAFE_FREE(plugin_name);
format_prefix = g_strdup_printf("%s:parser", __ms_convert_mime_to_string(mime));
- plugin_name = __ms_ini_get_string(dict, format_prefix, DEFAULT_VIDEO_PARSER);
+ plugin_name = __ms_ini_get_string(format_prefix, DEFAULT_VIDEO_PARSER);
GstElement *decoder_parser = __ms_element_create(plugin_name, NULL);
if (mime == MEDIA_FORMAT_H264_SP)
ms_retvm_if(node == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Handle is NULL");
int ret = MEDIA_STREAMER_ERROR_NONE;
- dictionary *dict = NULL;
char *plugin_name = NULL;
- __ms_load_ini_dictionary(&dict);
-
switch (node->subtype) {
case MEDIA_STREAMER_NODE_SRC_TYPE_FILE:
- node->gst_element = __ms_element_create(DEFAULT_FILE_SOURCE, NULL);
+ plugin_name = __ms_ini_get_string("node type 1:file", DEFAULT_FILE_SOURCE);
+ node->gst_element = __ms_element_create(plugin_name, NULL);
break;
case MEDIA_STREAMER_NODE_SRC_TYPE_RTSP:
- node->gst_element = __ms_element_create(DEFAULT_UDP_SOURCE, NULL);
+ plugin_name = __ms_ini_get_string("node type 1:rtsp", DEFAULT_UDP_SOURCE);
+ node->gst_element = __ms_element_create(plugin_name, NULL);
break;
case MEDIA_STREAMER_NODE_SRC_TYPE_HTTP:
- node->gst_element = __ms_element_create(DEFAULT_HTTP_SOURCE, NULL);
+ plugin_name = __ms_ini_get_string("node type 1:http", DEFAULT_HTTP_SOURCE);
+ node->gst_element = __ms_element_create(plugin_name, NULL);
break;
case MEDIA_STREAMER_NODE_SRC_TYPE_CAMERA:
- plugin_name = __ms_ini_get_string(dict, "sources:camera_source", DEFAULT_CAMERA_SOURCE);
+ plugin_name = __ms_ini_get_string("node type 1:camera", DEFAULT_CAMERA_SOURCE);
node->gst_element = __ms_element_create(plugin_name, NULL);
-
break;
case MEDIA_STREAMER_NODE_SRC_TYPE_AUDIO_CAPTURE:
- plugin_name = __ms_ini_get_string(dict, "sources:audio_source", DEFAULT_AUDIO_SOURCE);
+ plugin_name = __ms_ini_get_string("node type 1:audio capture", DEFAULT_AUDIO_SOURCE);
node->gst_element = __ms_element_create(plugin_name, NULL);
break;
case MEDIA_STREAMER_NODE_SRC_TYPE_VIDEO_CAPTURE:
- plugin_name = __ms_ini_get_string(dict, "sources:video_source", DEFAULT_VIDEO_SOURCE);
+ plugin_name = __ms_ini_get_string("node type 1:video capture", DEFAULT_VIDEO_SOURCE);
node->gst_element = __ms_element_create(plugin_name, NULL);
break;
case MEDIA_STREAMER_NODE_SRC_TYPE_VIDEO_TEST:
- node->gst_element = __ms_element_create(DEFAULT_VIDEO_TEST_SOURCE, NULL);
+ plugin_name = __ms_ini_get_string("node type 1:video test", DEFAULT_VIDEO_TEST_SOURCE);
+ node->gst_element = __ms_element_create(plugin_name, NULL);
break;
case MEDIA_STREAMER_NODE_SRC_TYPE_AUDIO_TEST:
- node->gst_element = __ms_element_create(DEFAULT_AUDIO_TEST_SOURCE, NULL);
+ plugin_name = __ms_ini_get_string("node type 1:audio test", DEFAULT_AUDIO_TEST_SOURCE);
+ node->gst_element = __ms_element_create(plugin_name, NULL);
break;
case MEDIA_STREAMER_NODE_SRC_TYPE_CUSTOM:
+ plugin_name = __ms_ini_get_string("node type 1:custom", DEFAULT_APP_SOURCE);
node->gst_element = __ms_element_create(DEFAULT_APP_SOURCE, NULL);
__ms_signal_create(&node->sig_list, node->gst_element, "need-data", G_CALLBACK(__ms_src_start_feed_cb), node);
__ms_signal_create(&node->sig_list, node->gst_element, "enough-data", G_CALLBACK(__ms_src_stop_feed_cb), node);
}
MS_SAFE_FREE(plugin_name);
- __ms_destroy_ini_dictionary(dict);
if (node->gst_element == NULL)
ret = MEDIA_STREAMER_ERROR_INVALID_OPERATION;
ms_retvm_if(node == NULL, MEDIA_STREAMER_ERROR_INVALID_PARAMETER, "Handle is NULL");
int ret = MEDIA_STREAMER_ERROR_NONE;
- dictionary *dict = NULL;
char *plugin_name = NULL;
- __ms_load_ini_dictionary(&dict);
-
switch (node->subtype) {
case MEDIA_STREAMER_NODE_SINK_TYPE_FILE:
- ms_error("Error: not implemented yet");
+ plugin_name = __ms_ini_get_string("node type 2:file", DEFAULT_FILE_SINK);
+ node->gst_element = __ms_element_create(plugin_name, NULL);
break;
case MEDIA_STREAMER_NODE_SINK_TYPE_RTSP:
- node->gst_element = __ms_element_create(DEFAULT_UDP_SINK, NULL);
+ plugin_name = __ms_ini_get_string("node type 2:rtsp", DEFAULT_UDP_SINK);
+ node->gst_element = __ms_element_create(plugin_name, NULL);
break;
case MEDIA_STREAMER_NODE_SINK_TYPE_HTTP:
ms_error("Error: not implemented yet");
break;
case MEDIA_STREAMER_NODE_SINK_TYPE_AUDIO:
- plugin_name = __ms_ini_get_string(dict, "sinks:audio_sink", DEFAULT_AUDIO_SINK);
+ plugin_name = __ms_ini_get_string("node type 2:audio", DEFAULT_AUDIO_SINK);
node->gst_element = __ms_element_create(plugin_name, NULL);
break;
case MEDIA_STREAMER_NODE_SINK_TYPE_OVERLAY:
- plugin_name = __ms_ini_get_string(dict, "sinks:video_sink", DEFAULT_VIDEO_SINK);
+ plugin_name = __ms_ini_get_string("node type 2:overlay", DEFAULT_VIDEO_SINK);
node->gst_element = __ms_element_create(plugin_name, NULL);
break;
case MEDIA_STREAMER_NODE_SINK_TYPE_EVAS:
- plugin_name = __ms_ini_get_string(dict, "sinks:evas_sink", DEFAULT_EVAS_SINK);
+ plugin_name = __ms_ini_get_string("node type 2:evas", DEFAULT_EVAS_SINK);
node->gst_element = __ms_element_create(plugin_name, NULL);
break;
case MEDIA_STREAMER_NODE_SINK_TYPE_FAKE:
- node->gst_element = __ms_element_create(DEFAULT_FAKE_SINK, NULL);
+ plugin_name = __ms_ini_get_string("node type 2:fake", DEFAULT_FAKE_SINK);
+ node->gst_element = __ms_element_create(plugin_name, NULL);
break;
case MEDIA_STREAMER_NODE_SINK_TYPE_CUSTOM:
- node->gst_element = __ms_element_create(DEFAULT_APP_SINK, NULL);
- g_object_set(G_OBJECT(node->gst_element), "emit-signals", TRUE, NULL);
- __ms_signal_create(&node->sig_list, node->gst_element, "new-sample", G_CALLBACK(__ms_sink_new_buffer_cb), node);
- __ms_signal_create(&node->sig_list, node->gst_element, "eos", G_CALLBACK(sink_eos), node);
+ plugin_name = __ms_ini_get_string("node type 2:custom", DEFAULT_APP_SINK);
+ node->gst_element = __ms_element_create(plugin_name, NULL);
+ if (node->gst_element) {
+ g_object_set(G_OBJECT(node->gst_element), "emit-signals", TRUE, NULL);
+ __ms_signal_create(&node->sig_list, node->gst_element, "new-sample", G_CALLBACK(__ms_sink_new_buffer_cb), node);
+ __ms_signal_create(&node->sig_list, node->gst_element, "eos", G_CALLBACK(sink_eos), node);
+ }
break;
default:
ms_error("Error: invalid Sink node Type [%d]", node->subtype);
}
MS_SAFE_FREE(plugin_name);
- __ms_destroy_ini_dictionary(dict);
if (node->gst_element == NULL)
ret = MEDIA_STREAMER_ERROR_INVALID_OPERATION;
static void __ms_check_ini_status(void);
-gchar *__ms_ini_get_string(dictionary *dict, const char *ini_path, char *default_str)
+gchar *__ms_ini_get_string(const char *ini_path, char *default_str)
{
gchar *result_str = NULL;
ms_retvm_if(ini_path == NULL, NULL, "Invalid ini path");
- if (dict == NULL) {
+ if (__ms_get_ini_instance() == NULL) {
result_str = default_str;
} else {
gchar *str = NULL;
- str = iniparser_getstring(dict, ini_path, default_str);
- if (str && (strlen(str) > 0) && (strlen(str) < MEDIA_STREAMER_INI_MAX_STRLEN))
+ str = iniparser_getstring(__ms_get_ini_instance(), ini_path, default_str);
+ if (str && (strlen(str) > 0) && (strlen(str) < INI_MAX_STRLEN))
result_str = str;
else
result_str = default_str;
return result_str ? g_strdup(result_str) : NULL;
}
-gboolean __ms_load_ini_dictionary(dictionary **dict)
+dictionary *__ms_get_ini_instance(void)
{
- ms_retvm_if(dict == NULL, FALSE, "Handle is NULL");
+ static dictionary *instance = NULL;
+ if (NULL == instance) {
+ dictionary *ms_dict = NULL;
+ __ms_check_ini_status();
- __ms_check_ini_status();
+ /* loading existing ini file */
+ ms_dict = iniparser_load(MEDIA_STREAMER_INI_PATH);
- dictionary *ms_dict = NULL;
-
- /* loading existing ini file */
- ms_dict = iniparser_load(MEDIA_STREAMER_INI_PATH);
-
- /* if no file exists. create one with set of default values */
- if (!ms_dict) {
- ms_debug("Could not open ini [%s]. Media-streamer will use default values.", MEDIA_STREAMER_INI_PATH);
- return FALSE;
- } else {
- ms_debug("Open ini file [%s].", MEDIA_STREAMER_INI_PATH);
+ if (!ms_dict)
+ ms_debug("Could not open ini [%s]. Media-streamer will use default values.", MEDIA_STREAMER_INI_PATH);
+ else
+ ms_debug("Open ini file [%s].", MEDIA_STREAMER_INI_PATH);
+ instance = ms_dict;
}
- *dict = ms_dict;
- return TRUE;
+ return instance;
}
-gboolean __ms_destroy_ini_dictionary(dictionary *dict)
+void __ms_ini_read_list(const char *key, gchar ***list)
{
- ms_retvm_if(dict == NULL, FALSE, "Handle is null");
-
- /* free dict as we got our own structure */
- iniparser_freedict(dict);
-
- return TRUE;
-}
-
-void __ms_ini_read_list(dictionary *dict, const char* key, gchar ***list)
-{
- ms_retm_if(!dict || !list || !key, "Handle is NULL");
+ ms_retm_if(!__ms_get_ini_instance() || !list || !key, "Handle is NULL");
/* Read exclude elements list */
- gchar *str = iniparser_getstring(dict, key, NULL);
+ gchar *str = iniparser_getstring(__ms_get_ini_instance(), key, NULL);
if (str && strlen(str) > 0) {
gchar *strtmp = g_strdup(str);
g_strstrip(strtmp);
void __ms_load_ini_settings(media_streamer_ini_t *ini)
{
- dictionary *dict = NULL;
-
/* get ini values */
memset(ini, 0, sizeof(media_streamer_ini_t));
- if (__ms_load_ini_dictionary(&dict)) {
+ if (__ms_get_ini_instance()) {
/* general */
- ini->generate_dot = iniparser_getboolean(dict, "general:generate dot", DEFAULT_GENERATE_DOT);
+ ini->generate_dot = iniparser_getboolean(__ms_get_ini_instance(), "general:generate dot", DEFAULT_GENERATE_DOT);
if (ini->generate_dot == TRUE) {
- gchar *dot_path = iniparser_getstring(dict, "general:dot dir", MEDIA_STREAMER_DEFAULT_DOT_DIR);
+ gchar *dot_path = iniparser_getstring(__ms_get_ini_instance(), "general:dot dir", MEDIA_STREAMER_DEFAULT_DOT_DIR);
ms_debug("generate_dot is TRUE, dot file will be stored into %s", dot_path);
g_setenv("GST_DEBUG_DUMP_DOT_DIR", dot_path, FALSE);
}
- ini->use_decodebin = iniparser_getboolean(dict, "general:use decodebin", DEFAULT_USE_DECODEBIN);
+ ini->use_decodebin = iniparser_getboolean(__ms_get_ini_instance(), "general:use decodebin", DEFAULT_USE_DECODEBIN);
/* Read exclude elements list */
- __ms_ini_read_list(dict, "general:exclude elements", &ini->exclude_elem_names);
+ __ms_ini_read_list("general:exclude elements", &ini->exclude_elem_names);
/* Read gstreamer arguments list */
- __ms_ini_read_list(dict, "general:gstreamer arguments", &ini->gst_args);
+ __ms_ini_read_list("general:gstreamer arguments", &ini->gst_args);
} else {
/* if dict is not available just fill the structure with default values */
ini->use_decodebin = DEFAULT_USE_DECODEBIN;
}
- __ms_destroy_ini_dictionary(dict);
-
/* general */
ms_debug("Media Streamer param [generate_dot] : %d", ini->generate_dot);
ms_debug("Media Streamer param [use_decodebin] : %d", ini->use_decodebin);