Fixed Manual Mode according to new node creation logic 28/71528/2 accepted/tizen/common/20160609.145217 accepted/tizen/ivi/20160609.091738 accepted/tizen/mobile/20160609.091957 accepted/tizen/tv/20160609.091609 accepted/tizen/wearable/20160609.091713 submit/tizen/20160609.040222
authorVyacheslav Valkovoy <v.valkovoy@samsung.com>
Wed, 25 May 2016 18:18:57 +0000 (21:18 +0300)
committerVyacheslav Valkovoy <v.valkovoy@samsung.com>
Wed, 25 May 2016 18:29:11 +0000 (21:29 +0300)
Change-Id: I05b07e87225abbd0694219de2d5e0fbb1982b3d6
Signed-off-by: Vyacheslav Valkovoy <v.valkovoy@samsung.com>
include/media_streamer.h
include/media_streamer_gst.h
include/media_streamer_util.h
src/media_streamer_gst.c
src/media_streamer_node.c
test/media_streamer_test.c

index c62f19f2c816157040fd004fef0a885891d214a0..3754fc0ee82179dedc03de7fc216c907a61e94dd 100644 (file)
@@ -70,6 +70,8 @@ typedef enum {
        MEDIA_STREAMER_NODE_TYPE_AUDIO_PAY,            /**<  Rtp audio payloader */
        MEDIA_STREAMER_NODE_TYPE_VIDEO_DEPAY,          /**<  Rtp video depayloader */
        MEDIA_STREAMER_NODE_TYPE_AUDIO_DEPAY,          /**<  Rtp audio depayloader */
+       MEDIA_STREAMER_NODE_TYPE_VIDEO_RATE,           /**<  Rate node type */
+       MEDIA_STREAMER_NODE_TYPE_VIDEO_SCALE,          /**<  Scale node type */
        MEDIA_STREAMER_NODE_TYPE_PARSER,               /**<  Parser node type */
        MEDIA_STREAMER_NODE_TYPE_FILTER,               /**<  Filter node type, to limit formats of data */
        MEDIA_STREAMER_NODE_TYPE_TEE,                  /**<  Tee node type, splits data to multiple path */
index f41b5324a732fd6e7f93cf34879a7d85042f9f55..c5add3c39b0770be7186e2d8dcc6d96080aa2383 100644 (file)
@@ -88,21 +88,21 @@ GstElement *__ms_node_element_create(node_plug_s *plug_info, media_streamer_node
  *
  * @since_tizen 3.0
  */
-GstElement *__ms_video_encoder_element_create(media_format_mimetype_e mime);
+GstElement *__ms_video_encoder_element_create(node_plug_s *plug_info, media_streamer_node_type_e type);
 
 /**
  * @brief Creates decoder GstElement by mime type.
  *
  * @since_tizen 3.0
  */
-GstElement *__ms_video_decoder_element_create(media_format_mimetype_e mime);
+GstElement *__ms_video_decoder_element_create(node_plug_s *plug_info, media_streamer_node_type_e type);
 
 /**
  * @brief Creates audio encoder GstElement.
  *
  * @since_tizen 3.0
  */
-GstElement *__ms_audio_encoder_element_create(void);
+GstElement *__ms_audio_encoder_element_create(node_plug_s *plug_info, media_streamer_node_type_e type);
 
 /**
  * @brief Creates rtp container GstElement.
@@ -207,6 +207,14 @@ int __ms_element_set_fmt(media_streamer_node_s *node, const char *pad_name, medi
  * @since_tizen 3.0
  */
 GstCaps *__ms_create_caps_from_fmt(media_format_h fmt);
+
+/**
+ * @brief Creates mediaformat from GstCaps.
+ *
+ * @since_tizen 3.0
+ */
+media_format_h __ms_create_fmt_from_caps(GstCaps *caps);
+
 /**
  * @brief Seeks GstElement to according time value.
  *
index f7ed569b69074c5974d23b2d5bf68564b17702c1..67bd3103450aef5799a0ea2902c7db23ed953ed4 100644 (file)
@@ -146,7 +146,7 @@ typedef struct {
 #define DEFAULT_FILTER                      "capsfilter"
 #define DEFAULT_TYPEFIND                    "typefind"
 #define DEFAULT_DECODEBIN                   "decodebin"
-#define DEFAULT_AUDIO_SOURCE                "alsasrc"
+#define DEFAULT_AUDIO_SOURCE                "pulsesrc"
 #define DEFAULT_CAMERA_SOURCE               "v4l2src"
 #define DEFAULT_VIDEO_SOURCE                "ximagesrc"
 #define DEFAULT_APP_SOURCE                  "appsrc"
index c3624f66931591747c5a5afe86152d336969603e..f6ace1af5f053b696a8f20855ff279b4e47952eb 100755 (executable)
@@ -433,39 +433,9 @@ GstElement *__ms_bin_find_element_by_klass(GstElement *sink_bin, GstElement *pre
        return element_found ? found_element : NULL;
 }
 
-int __ms_get_rank_increase(const char *factory_name)
-{
-       gint rank_priority = 20;
-       gint rank_second = 10;
-       gint rank_skip = -10;
-       gint ret = 0;
-
-       if (g_strrstr(factory_name, "av"))
-               ret = rank_priority;
-       else if (g_strrstr(factory_name, "omx"))
-               ret = rank_second;
-       else if (g_strrstr(factory_name, "v4l2video"))
-               ret = rank_skip;
-       else if (g_strrstr(factory_name, "rtph263ppay"))
-               ret = rank_skip;
-       else if (g_strrstr(factory_name, "sprd"))
-               ret = rank_skip;
-
-       return ret;
-}
-
 int __ms_factory_rank_compare(GstPluginFeature * first_feature, GstPluginFeature * second_feature)
 {
-       const gchar *name;
-       int first_feature_rank_inc = 0, second_feature_rank_inc = 0;
-
-       name = gst_plugin_feature_get_plugin_name(first_feature);
-       first_feature_rank_inc = __ms_get_rank_increase(name);
-
-       name = gst_plugin_feature_get_plugin_name(second_feature);
-       second_feature_rank_inc = __ms_get_rank_increase(name);
-
-       return (gst_plugin_feature_get_rank(second_feature) + second_feature_rank_inc) - (gst_plugin_feature_get_rank(first_feature) + first_feature_rank_inc);
+       return (gst_plugin_feature_get_rank(second_feature) - gst_plugin_feature_get_rank(first_feature));
 }
 
 gboolean __ms_feature_filter(GstPluginFeature * feature, gpointer data)
@@ -588,15 +558,6 @@ GstElement *__ms_combine_next_element(GstElement * previous_element, GstPad * pr
                if (!found_element && !next_elem_bin_name && default_element) {
                        found_element = __ms_element_create(default_element, NULL);
 
-                       /* Create element by predefined format element type */
-               } else if (!found_element && next_elem_bin_name && MS_ELEMENT_IS_ENCODER(next_elem_bin_name)) {
-
-
-                       if (MS_ELEMENT_IS_VIDEO(next_elem_bin_name))
-                               found_element = __ms_video_encoder_element_create(MEDIA_FORMAT_H263);
-                       else
-                               found_element = __ms_audio_encoder_element_create();
-
                        /* Create element by caps of the previous element */
                } else if (!found_element) {
                        GstPad *src_pad = NULL;
@@ -915,16 +876,24 @@ static gboolean __ms_feature_node_filter(GstPluginFeature *feature, gpointer dat
                return FALSE;
 
        gboolean can_accept = FALSE;
+       gboolean src_can_accept = FALSE;
+       gboolean sink_can_accept = FALSE;
        GstElementFactory *factory = GST_ELEMENT_FACTORY(feature);
        const gchar *factory_klass = gst_element_factory_get_klass(factory);
 
        if (plug_info && g_strrstr(factory_klass, plug_info->info->klass_name)) {
 
                if (GST_IS_CAPS(plug_info->src_caps))
-                       can_accept = can_accept || gst_element_factory_can_src_any_caps(factory, plug_info->src_caps);
+                       src_can_accept = gst_element_factory_can_src_any_caps(factory, plug_info->src_caps);
 
                if (GST_IS_CAPS(plug_info->sink_caps))
-                       can_accept = can_accept || gst_element_factory_can_sink_any_caps(factory, plug_info->sink_caps);
+                       sink_can_accept = gst_element_factory_can_sink_any_caps(factory, plug_info->sink_caps);
+
+               if (GST_IS_CAPS(plug_info->src_caps) && GST_IS_CAPS(plug_info->sink_caps)) {
+                       if (src_can_accept && sink_can_accept)
+                               can_accept = TRUE;
+               } else if (src_can_accept || sink_can_accept)
+                       can_accept = TRUE;
 
                if (can_accept) {
                        int index = 0;
@@ -945,6 +914,64 @@ static gboolean __ms_feature_node_filter(GstPluginFeature *feature, gpointer dat
        return FALSE;
 }
 
+static GstElement *__ms_element_create_from_ini(node_plug_s *plug_info, media_streamer_node_type_e type)
+{
+       const gchar *src_type, *sink_type;
+       const gchar *format_type = NULL;
+       MS_GET_CAPS_TYPE(plug_info->src_caps, src_type);
+       MS_GET_CAPS_TYPE(plug_info->sink_caps, sink_type);
+
+       GstElement *gst_element = NULL;
+       ms_info("Specified node formats types: in[%s] - out[%s]", sink_type, src_type);
+       gchar conf_key[INI_MAX_STRLEN] = {0,};
+
+       if (type == MEDIA_STREAMER_NODE_TYPE_VIDEO_ENCODER || type == MEDIA_STREAMER_NODE_TYPE_AUDIO_ENCODER)
+               format_type = src_type;
+       else if (type == MEDIA_STREAMER_NODE_TYPE_VIDEO_DECODER || type == MEDIA_STREAMER_NODE_TYPE_AUDIO_DECODER)
+               format_type = sink_type;
+       else
+               format_type = sink_type ? sink_type : src_type;
+
+       if (snprintf(conf_key, INI_MAX_STRLEN, "node type %d:%s", type, format_type) >= INI_MAX_STRLEN) {
+               ms_error("Failed to generate config field name, size >= %d", INI_MAX_STRLEN);
+               return 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);
+       }
+       return gst_element;
+}
+
+static GstElement *__ms_element_create_by_registry(node_plug_s *plug_info, media_streamer_node_type_e type)
+{
+       GstElement *gst_element = NULL;
+       const gchar *src_type, *sink_type;
+       MS_GET_CAPS_TYPE(plug_info->src_caps, src_type);
+       MS_GET_CAPS_TYPE(plug_info->sink_caps, sink_type);
+
+       __ms_ini_read_list("general:exclude elements", &plug_info->exclude_names);
+
+       GList *factories = gst_registry_feature_filter(gst_registry_get(),
+               __ms_feature_node_filter, FALSE, plug_info);
+       factories = g_list_sort(factories,(GCompareFunc) __ms_factory_rank_compare);
+
+       if (factories) {
+               GstElementFactory *factory = GST_ELEMENT_FACTORY(factories->data);
+               gst_element = __ms_element_create(GST_OBJECT_NAME(factory), NULL);
+       } else {
+               ms_error("Error: could not found any compatible element for node [%d]: in[%s] - out[%s]",
+                       type, sink_type, src_type);
+       }
+
+       g_strfreev(plug_info->exclude_names);
+       gst_plugin_list_free(factories);
+
+       return gst_element;
+}
+
 GstElement *__ms_node_element_create(node_plug_s *plug_info, media_streamer_node_type_e type)
 {
        GstElement *gst_element = NULL;
@@ -963,23 +990,18 @@ GstElement *__ms_node_element_create(node_plug_s *plug_info, media_streamer_node
                        gst_element = __ms_rtp_element_create();
                else
                        gst_element = __ms_element_create(plug_info->info->default_name, NULL);
-       } else {
+       } else if (type == MEDIA_STREAMER_NODE_TYPE_AUDIO_ENCODER)
+               gst_element = __ms_audio_encoder_element_create(plug_info, type);
+       else if (type == MEDIA_STREAMER_NODE_TYPE_VIDEO_ENCODER)
+               gst_element = __ms_video_encoder_element_create(plug_info, type);
+       else if (type == MEDIA_STREAMER_NODE_TYPE_VIDEO_DECODER)
+               gst_element = __ms_video_decoder_element_create(plug_info, type);
+       else {
+
                /* 2. Second priority:
                 * 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[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;
-               }
-
-               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);
-               }
+               gst_element = __ms_element_create_from_ini(plug_info, type);
        }
 
        /* 3. Third priority:
@@ -988,53 +1010,34 @@ GstElement *__ms_node_element_create(node_plug_s *plug_info, media_streamer_node
         * Elements that are compatible but defined as excluded will be skipped*/
        if(!gst_element) {
                /* Read exclude elements list */
-               __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);
-
-               if (factories) {
-                       GstElementFactory *factory = GST_ELEMENT_FACTORY(factories->data);
-                       gst_element = __ms_element_create(GST_OBJECT_NAME(factory), NULL);
-               } else {
-                       ms_error("Error: could not found any compatible element for node [%d]: in[%s] - out[%s]",
-                               type, sink_type, src_type);
-               }
-
-               g_strfreev(plug_info->exclude_names);
-               gst_plugin_list_free(factories);
+               gst_element = __ms_element_create_by_registry(plug_info, type);
        }
 
        return gst_element;
 }
 
-GstElement *__ms_video_encoder_element_create(media_format_mimetype_e mime)
+GstElement *__ms_video_encoder_element_create(node_plug_s *plug_info, media_streamer_node_type_e type)
 {
-       char *plugin_name = NULL;
-       char *format_prefix = NULL;
+       const gchar *src_type;
+       MS_GET_CAPS_TYPE(plug_info->src_caps, src_type);
 
        GstElement *video_scale = __ms_element_create(DEFAULT_VIDEO_SCALE, 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(format_prefix, DEFAULT_VIDEO_ENCODER);
-       GstElement *encoder_elem = __ms_element_create(plugin_name, NULL);
+       GstElement *encoder_elem = __ms_element_create_from_ini(plug_info, type);
+       media_format_mimetype_e encoder_type = __ms_convert_string_format_to_media_format(src_type);
 
-       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(format_prefix, DEFAULT_VIDEO_PARSER);
-       GstElement *encoder_parser = __ms_element_create(plugin_name, NULL);
-
-       MS_SAFE_FREE(format_prefix);
-       MS_SAFE_FREE(plugin_name);
+       node_info_s nodes_info = {MEDIA_STREAMER_PARSER_KLASS, DEFAULT_VIDEO_PARSER};
+       node_plug_s plug_info_parser = { &nodes_info, plug_info->src_caps, NULL, NULL};
+       GstElement *encoder_parser = __ms_element_create_from_ini(plug_info, MEDIA_STREAMER_NODE_TYPE_PARSER);
+       if (!encoder_parser)
+               encoder_parser = __ms_element_create_by_registry(&plug_info_parser, MEDIA_STREAMER_NODE_TYPE_PARSER);
 
        gboolean gst_ret = FALSE;
        GstElement *encoder_bin = gst_bin_new("video_encoder");
        ms_retvm_if(!video_convert || !video_scale || !encoder_elem || !encoder_bin || !encoder_parser, (GstElement *) NULL, "Error: creating elements for video encoder bin");
 
-       if (mime == MEDIA_FORMAT_H264_SP) {
+       if (encoder_type == MEDIA_FORMAT_H264_SP) {
                g_object_set(GST_OBJECT(encoder_parser), "config-interval", H264_PARSER_CONFIG_INTERVAL, NULL);
                g_object_set(G_OBJECT(encoder_elem), "tune",  H264_ENCODER_ZEROLATENCY, NULL);
                g_object_set(G_OBJECT(encoder_elem), "byte-stream", TRUE, NULL);
@@ -1055,31 +1058,31 @@ GstElement *__ms_video_encoder_element_create(media_format_mimetype_e mime)
        return encoder_bin;
 }
 
-GstElement *__ms_video_decoder_element_create(media_format_mimetype_e mime)
+GstElement *__ms_video_decoder_element_create(node_plug_s *plug_info, media_streamer_node_type_e type)
 {
-       char *plugin_name = NULL;
-       char *format_prefix = NULL;
        gboolean is_hw_codec = FALSE;
        GstElement *last_elem = NULL;
 
-       format_prefix = g_strdup_printf("%s:decoder", __ms_convert_mime_to_string(mime));
-       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);
+       const gchar *sink_type;
+       MS_GET_CAPS_TYPE(plug_info->sink_caps, sink_type);
+
+       GstElement *decoder_elem = __ms_element_create_from_ini(plug_info, MEDIA_STREAMER_NODE_TYPE_VIDEO_DECODER);
+       media_format_mimetype_e encoder_type = __ms_convert_string_format_to_media_format(sink_type);
 
-       format_prefix = g_strdup_printf("%s:parser", __ms_convert_mime_to_string(mime));
-       plugin_name = __ms_ini_get_string(format_prefix, DEFAULT_VIDEO_PARSER);
-       GstElement *decoder_parser = __ms_element_create(plugin_name, NULL);
+       node_info_s nodes_info = {MEDIA_STREAMER_PARSER_KLASS, DEFAULT_VIDEO_PARSER};
+       node_plug_s plug_info_parser = { &nodes_info, plug_info->sink_caps, NULL, NULL};
 
-       if (mime == MEDIA_FORMAT_H264_SP)
+       GstElement *decoder_parser = __ms_element_create_from_ini(plug_info, MEDIA_STREAMER_NODE_TYPE_PARSER);
+       if (!decoder_parser)
+               decoder_parser = __ms_element_create_by_registry(&plug_info_parser, MEDIA_STREAMER_NODE_TYPE_PARSER);
+
+
+       if (encoder_type == MEDIA_FORMAT_H264_SP)
                g_object_set(G_OBJECT(decoder_parser), "config-interval", H264_PARSER_CONFIG_INTERVAL, NULL);
 
-       if (g_strrstr(format_prefix, "omx") || g_strrstr(format_prefix, "sprd"))
+       if (g_strrstr(plug_info->info->default_name, "omx") || g_strrstr(plug_info->info->default_name, "sprd"))
                is_hw_codec = TRUE;
 
-       MS_SAFE_FREE(format_prefix);
-       MS_SAFE_FREE(plugin_name);
 
        gboolean gst_ret = FALSE;
        GstElement *decoder_bin = gst_bin_new("video_decoder");
@@ -1115,14 +1118,18 @@ GstElement *__ms_video_decoder_element_create(media_format_mimetype_e mime)
        return decoder_bin;
 }
 
-GstElement *__ms_audio_encoder_element_create(void)
+GstElement *__ms_audio_encoder_element_create(node_plug_s *plug_info, media_streamer_node_type_e type)
 {
        gboolean gst_ret = FALSE;
-       GstElement *audio_convert = __ms_element_create("audioconvert", NULL);
-       GstElement *audio_resample = __ms_element_create("audioresample", NULL);
-       GstElement *audio_filter = __ms_element_create("capsfilter", NULL);
-       GstElement *audio_postenc_convert = __ms_element_create("audioconvert", NULL);
-       GstElement *audio_encoder = __ms_element_create(DEFAULT_AUDIO_ENCODER, NULL);
+
+       GstElement *audio_convert = __ms_element_create(DEFAULT_AUDIO_CONVERT, NULL);
+       GstElement *audio_resample = __ms_element_create(DEFAULT_AUDIO_RESAMPLE, NULL);
+       GstElement *audio_filter = __ms_element_create(DEFAULT_FILTER, NULL);
+       GstElement *audio_postenc_convert = __ms_element_create(DEFAULT_AUDIO_CONVERT, NULL);
+       GstElement *audio_encoder = __ms_element_create_from_ini(plug_info, type);
+       if (!audio_encoder)
+               audio_encoder = __ms_element_create_by_registry(plug_info, type);
+
        GstElement *audio_enc_bin = gst_bin_new("audio_encoder");
        ms_retvm_if(!audio_convert || !audio_postenc_convert || !audio_filter || !audio_encoder || !audio_enc_bin, (GstElement *) NULL, "Error: creating elements for encoder bin");
 
@@ -1511,7 +1518,7 @@ GstCaps *__ms_create_caps_from_fmt(media_format_h fmt)
        return caps;
 }
 
-static media_format_h __ms_create_fmt_from_caps(GstCaps *caps)
+media_format_h __ms_create_fmt_from_caps(GstCaps *caps)
 {
        media_format_h fmt;
        GstStructure *pad_struct;
index 7a1bdd6fc2b7df60f0f52de1dc4a1ec129b7d9a3..8cb78189e4750e91ee46f6bca1810cca1a819235 100755 (executable)
@@ -57,10 +57,13 @@ node_info_s nodes_info[] = {
        {MEDIA_STREAMER_STRICT, "videoconvert"},   /* MEDIA_STREAMER_NODE_TYPE_VIDEO_CONVERTER */
        {MEDIA_STREAMER_STRICT, "audioconvert"},   /* MEDIA_STREAMER_NODE_TYPE_AUDIO_CONVERTER */
        {MEDIA_STREAMER_STRICT, "audioresample"},  /* MEDIA_STREAMER_NODE_TYPE_AUDIO_RESAMPLE */
-       {"Payloader", "rtph264pay"},               /* MEDIA_STREAMER_NODE_TYPE_VIDEO_PAY */
-       {"Payloader", "rtpamrpay"},                /* MEDIA_STREAMER_NODE_TYPE_AUDIO_PAY */
-       {"Depayloader", "rtph264depay"},           /* MEDIA_STREAMER_NODE_TYPE_VIDEO_DEPAY */
-       {"Depayloader", "rtpamrdepay"},            /* MEDIA_STREAMER_NODE_TYPE_AUDIO_DEPAY */
+       {"Payloader/Network", "rtph264pay"},       /* MEDIA_STREAMER_NODE_TYPE_VIDEO_PAY */
+       {"Payloader/Network", "rtpamrpay"},        /* MEDIA_STREAMER_NODE_TYPE_AUDIO_PAY */
+       {"Depayloader/Network", "rtph264depay"},   /* MEDIA_STREAMER_NODE_TYPE_VIDEO_DEPAY */
+       {"Depayloader/Network", "rtpamrdepay"},    /* MEDIA_STREAMER_NODE_TYPE_AUDIO_DEPAY */
+       {"Filter/Effect/Video", "videorate"},      /* MEDIA_STREAMER_NODE_TYPE_VIDEO_RATE */
+       {"Scaler", "videoscale"},                  /* MEDIA_STREAMER_NODE_TYPE_VIDEO_SCALE */
+       {"Parser", "h264parse"},                   /* MEDIA_STREAMER_NODE_TYPE_PARSER */
        {MEDIA_STREAMER_STRICT, "capsfilter"},     /* MEDIA_STREAMER_NODE_TYPE_FILTER */
        {MEDIA_STREAMER_STRICT, "tee"},            /* MEDIA_STREAMER_NODE_TYPE_TEE */
        {MEDIA_STREAMER_STRICT, "queue"},          /* MEDIA_STREAMER_NODE_TYPE_QUEUE */
index 722afeec69a2b6f78c740d384d9d5d7070a253c7..b0969546ce2a99a4e4eb7251eaa23fd93042065a 100644 (file)
@@ -117,6 +117,7 @@ gboolean g_audio_is_on = FALSE;
 media_format_h vfmt_raw = NULL;
 media_format_h vfmt_encoded = NULL;
 media_format_h afmt_raw = NULL;
+media_format_h afmt_encoded = NULL;
 
 static void streamer_error_cb(media_streamer_h streamer, media_streamer_error_e error, void *user_data)
 {
@@ -264,7 +265,7 @@ static void create_formats(void)
 
        /* Define video raw format */
        media_format_create(&vfmt_raw);
-       if (media_format_set_video_mime(vfmt_raw, MEDIA_FORMAT_YV12) != MEDIA_FORMAT_ERROR_NONE)
+       if (media_format_set_video_mime(vfmt_raw, MEDIA_FORMAT_I420) != MEDIA_FORMAT_ERROR_NONE)
                g_print("media_format_set_video_mime failed!");
 
        media_format_set_video_width(vfmt_raw, 800);
@@ -288,8 +289,15 @@ static void create_formats(void)
                g_print("media_format_set_audio_mime failed!");
 
        media_format_set_audio_channel(afmt_raw, 1);
-       media_format_set_audio_samplerate(afmt_raw, 44100);
-       media_format_set_audio_bit(afmt_raw, 16);
+       media_format_set_audio_samplerate(afmt_raw, 8000);
+
+       /* Define audio encoded format */
+       media_format_create(&afmt_encoded);
+       if (media_format_set_audio_mime(afmt_encoded, MEDIA_FORMAT_AMR_NB) != MEDIA_FORMAT_ERROR_NONE)
+               g_print("media_format_set_audio_mime failed!");
+
+       media_format_set_audio_channel(afmt_encoded, 1);
+       media_format_set_audio_samplerate(afmt_encoded, 8000);
 }
 
 static void set_rtp_params(media_streamer_node_h rtp_node, const char *ip, int video_port, int audio_port, gboolean port_reverse)
@@ -430,13 +438,13 @@ static void _create_rtp_streamer(media_streamer_node_h rtp_bin)
 
                /*********************** encoder **************************************** */
                media_streamer_node_h video_enc = NULL;
-               media_streamer_node_create(MEDIA_STREAMER_NODE_TYPE_VIDEO_ENCODER, NULL, vfmt_encoded, &video_enc);
+               media_streamer_node_create(MEDIA_STREAMER_NODE_TYPE_VIDEO_ENCODER, vfmt_raw, vfmt_encoded, &video_enc);
                media_streamer_node_add(current_media_streamer, video_enc);
                APPEND_NODE(video_enc);
 
                /*********************** videopay *************************************** */
                media_streamer_node_h video_pay = NULL;
-               media_streamer_node_create(MEDIA_STREAMER_NODE_TYPE_VIDEO_PAY, NULL, vfmt_encoded, &video_pay);
+               media_streamer_node_create(MEDIA_STREAMER_NODE_TYPE_VIDEO_PAY, vfmt_encoded, NULL, &video_pay);
                media_streamer_node_add(current_media_streamer, video_pay);
                APPEND_NODE(video_pay);
 
@@ -463,13 +471,13 @@ static void _create_rtp_streamer(media_streamer_node_h rtp_bin)
 
                /*********************** audioencoder *********************************** */
                media_streamer_node_h audio_enc = NULL;
-               media_streamer_node_create(MEDIA_STREAMER_NODE_TYPE_AUDIO_ENCODER, NULL, NULL, &audio_enc);
+               media_streamer_node_create(MEDIA_STREAMER_NODE_TYPE_AUDIO_ENCODER, afmt_raw, afmt_encoded, &audio_enc);
                media_streamer_node_add(current_media_streamer, audio_enc);
                APPEND_NODE(audio_enc);
 
-               /*********************** rtpL16pay *********************************** */
+               /*********************** rtpamrpay *********************************** */
                media_streamer_node_h audio_pay = NULL;
-               media_streamer_node_create(MEDIA_STREAMER_NODE_TYPE_AUDIO_PAY, NULL, NULL, &audio_pay);
+               media_streamer_node_create(MEDIA_STREAMER_NODE_TYPE_AUDIO_PAY, afmt_encoded, NULL, &audio_pay);
                media_streamer_node_add(current_media_streamer, audio_pay);
                APPEND_NODE(audio_pay);
 
@@ -532,13 +540,13 @@ static void _create_rtp_client(media_streamer_node_h rtp_bin)
 
                /* ********************** videodec ************************************ */
                media_streamer_node_h video_dec = NULL;
-               media_streamer_node_create(MEDIA_STREAMER_NODE_TYPE_VIDEO_DECODER, NULL, vfmt_encoded, &video_dec);
+               media_streamer_node_create(MEDIA_STREAMER_NODE_TYPE_VIDEO_DECODER, vfmt_encoded, vfmt_raw, &video_dec);
                media_streamer_node_add(current_media_streamer, video_dec);
                APPEND_NODE(video_dec);
 
                /* ********************** videoqueue ************************************ */
                media_streamer_node_h video_queue = NULL;
-               media_streamer_node_create(MEDIA_STREAMER_NODE_TYPE_QUEUE, NULL, vfmt_encoded, &video_queue);
+               media_streamer_node_create(MEDIA_STREAMER_NODE_TYPE_QUEUE, NULL, NULL, &video_queue);
                media_streamer_node_add(current_media_streamer, video_queue);
                APPEND_NODE(video_queue);
 
@@ -564,11 +572,11 @@ static void _create_rtp_client(media_streamer_node_h rtp_bin)
                media_streamer_node_add(current_media_streamer, audio_depay);
                APPEND_NODE(audio_depay);
 
-               /* ********************** audioconverter ****************************** */
-               media_streamer_node_h audio_conv = NULL;
-               media_streamer_node_create(MEDIA_STREAMER_NODE_TYPE_AUDIO_CONVERTER, NULL, NULL, &audio_conv);
-               media_streamer_node_add(current_media_streamer, audio_conv);
-               APPEND_NODE(audio_conv);
+               /* ********************** audiodecoder ****************************** */
+               media_streamer_node_h audio_dec = NULL;
+               media_streamer_node_create(MEDIA_STREAMER_NODE_TYPE_AUDIO_DECODER, NULL, NULL, &audio_dec);
+               media_streamer_node_add(current_media_streamer, audio_dec);
+               APPEND_NODE(audio_dec);
 
                /* ********************** audioqueue ********************************** */
                media_streamer_node_h audio_queue = NULL;
@@ -583,8 +591,8 @@ static void _create_rtp_client(media_streamer_node_h rtp_bin)
                APPEND_NODE(audio_sink);
 
                /* ====================Linking Audio Client=========================== */
-               media_streamer_node_link(audio_depay, "src", audio_conv, "sink");
-               media_streamer_node_link(audio_conv, "src", audio_queue, "sink");
+               media_streamer_node_link(audio_depay, "src", audio_dec, "sink");
+               media_streamer_node_link(audio_dec, "src", audio_queue, "sink");
                media_streamer_node_link(audio_queue, "src", audio_sink, "sink");
                /* =================================================================== */