Add error condition in media_streamer_prepare() for WebRTC 70/237170/4
authorHyunil <hyunil46.park@samsung.com>
Thu, 25 Jun 2020 11:21:54 +0000 (20:21 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Fri, 26 Jun 2020 02:36:36 +0000 (11:36 +0900)
- After setting media format to audio sink pad of WebRTC,
  if audio sink pad is not linked to peer node then an error will occur.
- The video does the same thing.

[Version] 0.1.75
[Issue Type] Improvement

Change-Id: Iff9a9ce5a73f800e2fa0c9045cd470a9f6305d76
Signed-off-by: Hyunil <hyunil46.park@samsung.com>
packaging/capi-media-streamer.spec
src/media_streamer_node.c

index 50eca83..d753774 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-streamer
 Summary:    A Media Streamer API
-Version:    0.1.74
+Version:    0.1.75
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index a862273..4b25214 100644 (file)
@@ -1547,6 +1547,17 @@ static int __ms_webrtc_prepare_ghost_sink_pad(GstElement *webrtc_container, GstE
                return MEDIA_STREAMER_ERROR_NONE;
        }
 
+       if (!(ghost_pad_in = (GstGhostPad *)gst_element_get_static_pad(webrtc_container, pad_name))) {
+               ms_error("Failed to get ghost pad for webrtc_container");
+               return MEDIA_STREAMER_ERROR_INVALID_OPERATION;
+       }
+
+       if (!gst_pad_is_linked((GstPad *)ghost_pad_in)) {
+               ms_error("[%s] is set media format but not linked to peer node", pad_name);
+               MS_SAFE_UNREF(ghost_pad_in);
+               return MEDIA_STREAMER_ERROR_INVALID_OPERATION;
+       }
+
        ms_info("%s is found, link it with webrtcbin and export the ghost pad[%s] of webrtc_container",
                        capsfilter_name, pad_name);
 
@@ -1563,11 +1574,7 @@ static int __ms_webrtc_prepare_ghost_sink_pad(GstElement *webrtc_container, GstE
                ret = MEDIA_STREAMER_ERROR_INVALID_OPERATION;
                goto end;
        }
-       if (!(ghost_pad_in = (GstGhostPad *)gst_element_get_static_pad(webrtc_container, pad_name))) {
-               ms_error("Failed to get ghost pad for webrtc_container");
-               ret = MEDIA_STREAMER_ERROR_INVALID_OPERATION;
-               goto end;
-       }
+
        if (!(filter_sink_pad = gst_element_get_static_pad(filter, "sink"))) {
                ms_error("Failed to get capsfilter sink pad in webrtc_container");
                ret = MEDIA_STREAMER_ERROR_INVALID_OPERATION;