webrtc_sink: Change parameter and use existing macro to print some log 65/268565/2
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 27 Dec 2021 05:23:59 +0000 (14:23 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 27 Dec 2021 05:37:18 +0000 (14:37 +0900)
[Version] 0.3.32
[Issue Type] Refactoring

Change-Id: I46e430d17016bffb4c5b64a88c9597a147564aa2
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
include/webrtc_private.h
packaging/capi-media-webrtc.spec
src/webrtc_private.c
src/webrtc_sink.c
src/webrtc_source.c

index 038639e0d309f346bc9f34d7b0cb52f92abea7b4..d5a960c6e31336041c8f7b88193e07f5961bc987 100644 (file)
@@ -212,6 +212,8 @@ do { \
        g_free(dot_name); \
 } while (0)
 
+#define GET_MEDIA_TYPE_NAME(x_is_audio) (x_is_audio) ? "audio" : "video"
+
 #define DEFAULT_ELEMENT_FAKESINK        "fakesink"
 #define DEFAULT_ELEMENT_AUDIOCONVERT    "audioconvert"
 #define DEFAULT_ELEMENT_AUDIORESAMPLE   "audioresample"
@@ -622,7 +624,7 @@ webrtc_gst_slot_s* _get_slot_by_id(GHashTable *slots, unsigned int id);
 int _add_no_target_ghostpad_to_slot(webrtc_gst_slot_s *slot, bool is_src, GstPad **new_pad);
 int _set_ghost_pad_target(GstPad *ghost_pad, GstElement *target_element, bool is_src);
 int _add_rendering_sink_bin(webrtc_s *webrtc, GstPad *src_pad);
-int _add_forwarding_sink_bin(webrtc_s *webrtc, GstPad *src_pad, bool is_video);
+int _add_forwarding_sink_bin(webrtc_s *webrtc, GstPad *src_pad, bool is_audio);
 int _set_stream_info_to_sink(webrtc_s *webrtc, unsigned int track_id, sound_stream_info_h stream_info);
 int _set_display_to_sink(webrtc_s *webrtc, unsigned int track_id, unsigned int type, void *display);
 int _set_display_mode_to_sink(webrtc_s *webrtc, unsigned int track_id, webrtc_display_mode_e mode);
index 8bb7fcf1d2778f4235a4f8ad00a90681795254b8..05943ab44ecd7b642c58a4f10afb718063a49c4a 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.3.31
+Version:    0.3.32
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 7ca08716a5ebc9ee66da27bc5eec91eff848be7a..d18f38d8c76de44bd39c29b90dff47d3ab77265a 100644 (file)
@@ -1321,7 +1321,7 @@ static void __webrtcbin_pad_added_cb(GstElement *webrtcbin, GstPad *new_pad, gpo
 
        if ((!is_audio && webrtc->encoded_video_frame_cb.callback) ||
                (is_audio && webrtc->encoded_audio_frame_cb.callback)) {
-               ret = _add_forwarding_sink_bin(webrtc, new_pad, !is_audio);
+               ret = _add_forwarding_sink_bin(webrtc, new_pad, is_audio);
                RET_IF(ret != WEBRTC_ERROR_NONE, "failed to _add_forwarding_sink_bin()");
        } else {
                ret = _add_rendering_sink_bin(webrtc, new_pad);
index 46c28c2db3006a4bd3d62ee01c09b9d43887cb04..cacd7f96bedc7f2a662b1ddb118b8c01b08cb017 100644 (file)
@@ -313,12 +313,12 @@ static unsigned int __get_id_from_name(const gchar *name)
        return (unsigned int)id;
 }
 
-static void __invoke_track_added_cb(webrtc_s *webrtc, const gchar *name, bool is_video, bool build_track_context)
+static void __invoke_track_added_cb(webrtc_s *webrtc, const gchar *name, bool is_audio, bool build_track_context)
 {
        RET_IF(webrtc == NULL, "webrtc is NULL");
        RET_IF(name == NULL, "name is NULL");
 
-       LOG_INFO("webrtc[%p] [%s] track[%s] is added", webrtc, is_video ? "video" : "audio", name);
+       LOG_INFO("webrtc[%p] [%s] track[%s] is added", webrtc, GET_MEDIA_TYPE_NAME(is_audio), name);
 
        if (webrtc->track_added_cb.callback) {
                unsigned int id = __get_id_from_name(name);
@@ -332,7 +332,7 @@ static void __invoke_track_added_cb(webrtc_s *webrtc, const gchar *name, bool is
 
                LOG_DEBUG(">>> callback[%p], user_data[%p]", webrtc->track_added_cb.callback, webrtc->track_added_cb.user_data);
                ((webrtc_track_added_cb)(webrtc->track_added_cb.callback))((webrtc_h)webrtc,
-                       is_video ? WEBRTC_MEDIA_TYPE_VIDEO : WEBRTC_MEDIA_TYPE_AUDIO, id, webrtc->track_added_cb.user_data);
+                       is_audio ? WEBRTC_MEDIA_TYPE_AUDIO : WEBRTC_MEDIA_TYPE_VIDEO, id, webrtc->track_added_cb.user_data);
                LOG_DEBUG("<<< end of the callback");
 
                if (build_track_context)
@@ -387,11 +387,11 @@ static void __decodebin_pad_added_cb(GstElement *decodebin, GstPad *new_pad, gpo
 
        if (_is_audio_media_type(media_type)) {
                sink->media_types |= MEDIA_TYPE_AUDIO;
-               __invoke_track_added_cb(webrtc, GST_ELEMENT_NAME(decodebin), false, true);
+               __invoke_track_added_cb(webrtc, GST_ELEMENT_NAME(decodebin), true, true);
                ret = __build_audiosink(webrtc, decodebin, new_pad);
        } else {
                sink->media_types |= MEDIA_TYPE_VIDEO;
-               __invoke_track_added_cb(webrtc, GST_ELEMENT_NAME(decodebin), true, true);
+               __invoke_track_added_cb(webrtc, GST_ELEMENT_NAME(decodebin), false, true);
                ret = __build_videosink(webrtc, decodebin, new_pad);
        }
 
@@ -844,7 +844,7 @@ static GstCaps* __make_caps_if_h264_or_h265(GstPad *pad)
        return new_caps;
 }
 
-int _add_forwarding_sink_bin(webrtc_s *webrtc, GstPad *src_pad, bool is_video)
+int _add_forwarding_sink_bin(webrtc_s *webrtc, GstPad *src_pad, bool is_audio)
 {
        int ret = WEBRTC_ERROR_NONE;
        unsigned int id;
@@ -926,10 +926,10 @@ int _add_forwarding_sink_bin(webrtc_s *webrtc, GstPad *src_pad, bool is_video)
                return WEBRTC_ERROR_INVALID_OPERATION;
        }
 
-       sink->encoded_frame_cb = is_video ? &(webrtc->encoded_video_frame_cb) : &(webrtc->encoded_audio_frame_cb);
-       sink->media_types = is_video ? MEDIA_TYPE_VIDEO : MEDIA_TYPE_AUDIO;
+       sink->encoded_frame_cb = is_audio ? &(webrtc->encoded_audio_frame_cb) : &(webrtc->encoded_video_frame_cb);
+       sink->media_types = is_audio ? MEDIA_TYPE_AUDIO : MEDIA_TYPE_VIDEO;
 
-       __invoke_track_added_cb(webrtc, track_name, is_video, false);
+       __invoke_track_added_cb(webrtc, track_name, is_audio, false);
 
        if (!gst_element_sync_state_with_parent(GST_ELEMENT(sink->bin))) {
                LOG_ERROR("failed to gst_element_sync_state_with_parent() for [%s]", GST_ELEMENT_NAME(sink->bin));
index 01e140f12768e7d9fa502b5e6b02f144793b6fd0..334cd1de4bcc6d5b2a897f0abd957fa148549c88 100644 (file)
@@ -77,7 +77,6 @@ do { \
        LOG_DEBUG("%s is prepended", GST_ELEMENT_NAME(x_element)); \
 } while (0)
 
-#define GET_MEDIA_TYPE_NAME(x_is_audio) (x_is_audio) ? "audio" : "video"
 #define GET_AV_IDX(x_is_audio) (x_is_audio) ? AV_IDX_AUDIO : AV_IDX_VIDEO
 #define GET_AV_IDX_BY_TYPE(x_media_type) GET_AV_IDX(x_media_type == MEDIA_TYPE_AUDIO)