From 831e7713e8f713afee698f3066afce34386f6a6b Mon Sep 17 00:00:00 2001 From: Vyacheslav Valkovoy Date: Thu, 17 Mar 2016 17:33:34 +0200 Subject: [PATCH] Fixed distortion of audio, video at Client part while Streaming. Change-Id: I7edaf17ad9f222c768b5eecda283ff9e9b5e1a91 Signed-off-by: Vyacheslav Valkovoy --- include/media_streamer_util.h | 3 ++- src/media_streamer_gst.c | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/include/media_streamer_util.h b/include/media_streamer_util.h index 4e886e2..b3e898d 100644 --- a/include/media_streamer_util.h +++ b/include/media_streamer_util.h @@ -144,6 +144,7 @@ typedef struct { #define DEFAULT_EVAS_SINK "evaspixmapsink" #define DEFAULT_VIDEO_SCALE "videoscale" #define DEFAULT_VIDEO_CONVERT "videoconvert" +#define DEFAULT_VIDEO_RATE "videorate" #define DEFAULT_TEXT_OVERLAY "textoverlay" #define DEFAULT_AUDIO_CONVERT "audioconvert" #define DEFAULT_AUDIO_RESAMPLE "audioresample" @@ -178,6 +179,7 @@ typedef struct { #define MS_ELEMENT_IS_AUDIO(el) g_strrstr(el, "audio") #define MS_ELEMENT_IS_VIDEO(el) g_strrstr(el, "video") #define MS_ELEMENT_IS_IMAGE(el) g_strrstr(el, "image") +#define MS_ELEMENT_IS_TEXT(el) g_strrstr(el, "text") #define MS_RTP_PAD_VIDEO_IN "video_in" #define MS_RTP_PAD_AUDIO_IN "audio_in" @@ -187,7 +189,6 @@ typedef struct { #define MEDIA_STREAMER_PARAM_AUDIO_IN_FORMAT MS_RTP_PAD_AUDIO_IN"_format" #define MS_ELEMENT_IS_RTP(el) g_strrstr(el, "rtp_container") -#define MS_ELEMENT_IS_TEXT(el) g_strrstr(el, "text") #define MS_ELEMENT_IS_ENCODER(el) g_strrstr(el, "encoder") #define MS_ELEMENT_IS_DECODER(el) g_strrstr(el, "decoder") diff --git a/src/media_streamer_gst.c b/src/media_streamer_gst.c index 640441f..ba65bc6 100755 --- a/src/media_streamer_gst.c +++ b/src/media_streamer_gst.c @@ -984,6 +984,7 @@ GstElement *__ms_video_encoder_element_create(dictionary * dict, media_format_mi GstElement *video_scale = __ms_element_create(DEFAULT_VIDEO_SCALE, NULL); GstElement *video_convert = __ms_element_create(DEFAULT_VIDEO_CONVERT, NULL); + GstElement *video_rate = __ms_element_create(DEFAULT_VIDEO_RATE, 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); @@ -1000,17 +1001,16 @@ GstElement *__ms_video_encoder_element_create(dictionary * dict, media_format_mi gboolean gst_ret = FALSE; GstElement *encoder_bin = gst_bin_new("video_encoder"); GstElement *filter = __ms_element_create("capsfilter", NULL); - ms_retvm_if(!video_convert || !video_scale || !filter || !encoder_elem || !encoder_bin || !encoder_parser, (GstElement *) NULL, "Error: creating elements for video encoder bin"); + ms_retvm_if(!video_convert || !video_rate || !video_scale || !filter || !encoder_elem || !encoder_bin || !encoder_parser, (GstElement *) NULL, "Error: creating elements for video encoder bin"); format_prefix = g_strdup_printf(MEDIA_STREAMER_DEFAULT_ENCODER_FORMAT("%s"), __ms_convert_mime_to_string(mime)); GstCaps *videoCaps = gst_caps_from_string(format_prefix); g_object_set(G_OBJECT(filter), "caps", videoCaps, NULL); MS_SAFE_FREE(format_prefix); - gst_caps_unref(videoCaps); - gst_bin_add_many(GST_BIN(encoder_bin), video_convert, video_scale, encoder_elem, filter, encoder_parser, NULL); - gst_ret = gst_element_link_many(video_convert, video_scale, encoder_elem, filter, encoder_parser, NULL); + gst_bin_add_many(GST_BIN(encoder_bin), video_convert, video_scale, video_rate, encoder_elem, filter, encoder_parser, NULL); + gst_ret = gst_element_link_many(video_convert, video_scale, video_rate, encoder_elem, filter, encoder_parser, NULL); if (gst_ret != TRUE) { ms_error("Failed to link elements into encoder_bin"); MS_SAFE_UNREF(encoder_bin); @@ -1086,23 +1086,25 @@ GstElement *__ms_audio_encoder_element_create(void) { 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_enc_bin = gst_bin_new("audio_encoder"); - ms_retvm_if(!audio_convert || !audio_filter || !audio_enc_bin, (GstElement *) NULL, "Error: creating elements for encoder bin"); + ms_retvm_if(!audio_convert || !audio_postenc_convert || !audio_filter || !audio_enc_bin, (GstElement *) NULL, "Error: creating elements for encoder bin"); GstCaps *audioCaps = gst_caps_from_string(MEDIA_STREAMER_DEFAULT_AUDIO_FORMAT); g_object_set(G_OBJECT(audio_filter), "caps", audioCaps, NULL); gst_caps_unref(audioCaps); - gst_bin_add_many(GST_BIN(audio_enc_bin), audio_convert, audio_filter, NULL); - gst_ret = gst_element_link_many(audio_filter, audio_convert, NULL); + gst_bin_add_many(GST_BIN(audio_enc_bin), audio_convert, audio_postenc_convert, audio_filter, audio_resample, NULL); + gst_ret = gst_element_link_many(audio_convert, audio_resample, audio_filter, audio_postenc_convert, NULL); if (gst_ret != TRUE) { ms_error("Failed to link elements into decoder_bin"); MS_SAFE_UNREF(audio_enc_bin); } - __ms_add_ghostpad(audio_convert, "src", audio_enc_bin, "src"); - __ms_add_ghostpad(audio_filter, "sink", audio_enc_bin, "sink"); + __ms_add_ghostpad(audio_postenc_convert, "src", audio_enc_bin, "src"); + __ms_add_ghostpad(audio_convert, "sink", audio_enc_bin, "sink"); return audio_enc_bin; } -- 2.7.4