webrtc_test: Prepare for test case with esplusplayer to render data when using encode... 15/264415/5
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 17 Sep 2021 07:20:23 +0000 (16:20 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Tue, 28 Sep 2021 04:23:58 +0000 (13:23 +0900)
It'll be the default case to test encoded frame callback.
For now, it is excluded when TV profile build.

[Version] 0.2.107
[Issue Type] Improvement

Change-Id: I85bae50e99bd937daf2e53aa901a1ecd90a6de98
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/capi-media-webrtc.spec
test/CMakeLists.txt
test/webrtc_test.c

index 81c38768bdda1c83ebe615aa3b55b4c8ea5e7ad9..6d2a8258c0743d70f9a7569663db4bfa92ea0d11 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.2.106
+Version:    0.2.107
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
@@ -33,6 +33,7 @@ BuildRequires:  pkgconfig(capi-media-sound-manager)
 BuildRequires:  pkgconfig(bundle)
 %if "%{tizen_profile_name}" != "tv"
 BuildRequires:  pkgconfig(mm-resource-manager)
+BuildRequires:  pkgconfig(esplusplayer)
 %endif
 
 %description
index 35a2783909b6d3de7a2d4ebf7a8681e4b92f4744..4b8fda295226a6527a821579ea3529c628a4ec4b 100644 (file)
@@ -6,7 +6,11 @@ INCLUDE_DIRECTORIES(../include)
 link_directories(${CMAKE_SOURCE_DIR}/../)
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(${fw_test} REQUIRED glib-2.0 appcore-efl elementary libsoup-2.4)
+IF(NOT TIZEN_PROFILE_TV)
+    pkg_check_modules(${fw_test} REQUIRED glib-2.0 appcore-efl elementary libsoup-2.4 esplusplayer)
+ELSE()
+    pkg_check_modules(${fw_test} REQUIRED glib-2.0 appcore-efl elementary libsoup-2.4)
+ENDIF()
 FOREACH(flag ${${fw_test}_CFLAGS})
     SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
index 36d6df2bab8a3d191e911a003f16e56b12f6508c..98958a20d3e03cbd002e6adb547c1d0a9e54ab6f 100644 (file)
@@ -18,6 +18,9 @@
 #include <media_format.h>
 #include <media_packet_internal.h>
 #include <sound_manager.h>
+#ifndef TIZEN_TV
+#include <esplusplayer_capi.h>
+#endif
 #include <appcore-efl.h>
 #include <Elementary.h>
 #include <tbm_surface_internal.h>
@@ -210,8 +213,15 @@ typedef struct _connection_s {
                sound_stream_info_h stream_info;
                webrtc_display_type_e display_type;
                Evas_Object *eo;
+#ifndef TIZEN_TV
+               esplusplayer_handle espp;
+#endif
        } render;
 
+#ifndef TIZEN_TV
+       bool encoded_video_frame_cb_is_set;
+       bool encoded_audio_frame_cb_is_set;
+#endif
 #ifdef __DEBUG_VALIDATE_ENCODED_FRAME_CB__
        GstElement *render_pipeline;
        GstElement *appsrc;
@@ -481,6 +491,18 @@ static void _webrtc_destroy(int index)
                sound_manager_destroy_stream_information(g_conns[index].render.stream_info);
                g_conns[index].render.stream_info = NULL;
        }
+#ifndef TIZEN_TV
+       if (g_conns[index].encoded_audio_frame_cb_is_set)
+               g_conns[index].encoded_audio_frame_cb_is_set = false;
+
+       if (g_conns[index].encoded_video_frame_cb_is_set)
+               g_conns[index].encoded_video_frame_cb_is_set = false;
+
+       if (g_conns[index].render.espp) {
+               g_conns[index].render.espp = NULL;
+               g_print("espp close & destroy\n");
+       }
+#endif
 }
 
 static void _webrtc_start(int index)
@@ -493,6 +515,19 @@ static void _webrtc_start(int index)
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_start() success\n");
+#ifndef TIZEN_TV
+       if (g_conns[index].encoded_audio_frame_cb_is_set ||
+               g_conns[index].encoded_video_frame_cb_is_set) {
+               if (!g_conns[index].render.espp)
+                       g_print("espp create & open\n");
+       }
+
+       if (g_conns[index].encoded_audio_frame_cb_is_set)
+               g_print("espp set audio stream info\n");
+
+       if (g_conns[index].encoded_video_frame_cb_is_set)
+               g_print("espp set video stream info\n");
+#endif
 }
 
 static void _webrtc_stop(int index)
@@ -521,6 +556,15 @@ static void _webrtc_stop(int index)
                g_print("appsrc render pipeline is released\n");
        }
 #endif
+#ifndef TIZEN_TV
+       if (g_conns[index].encoded_audio_frame_cb_is_set ||
+               g_conns[index].encoded_video_frame_cb_is_set) {
+               if (g_conns[index].render.espp) {
+                       g_conns[index].render.espp = NULL;
+                       g_print("espp destroy\n");
+               }
+       }
+#endif
 }
 
 static void _webrtc_get_state(int index)
@@ -1860,6 +1904,22 @@ static void __track_added_cb(webrtc_h webrtc, webrtc_media_type_e type, unsigned
 
        g_print("__track_added_cb() is invoked, webrtc[%p], type[%d], id[%u], conn[%p]\n", webrtc, type, id, conn);
 
+#ifndef TIZEN_TV
+       if (conn->encoded_audio_frame_cb_is_set && type == WEBRTC_MEDIA_TYPE_AUDIO) {
+               if (conn->render.espp) {
+                       /* espp: state check & prepare async */
+                       g_print("espp prepare async\n");
+               }
+               return;
+       }
+       if (conn->encoded_video_frame_cb_is_set && type == WEBRTC_MEDIA_TYPE_VIDEO) {
+               if (conn->render.espp) {
+                       /* espp: state check & prepare async */
+                       g_print("espp prepare async\n");
+               }
+               return;
+       }
+#endif
        if (type == WEBRTC_MEDIA_TYPE_VIDEO) {
 #ifndef __DEBUG_VALIDATE_ENCODED_FRAME_CB__
                if (conn->render.display_type == WEBRTC_DISPLAY_TYPE_OVERLAY) {
@@ -1929,7 +1989,24 @@ static void __encoded_frame_cb(webrtc_h webrtc, webrtc_media_type_e type, unsign
 
        g_print("webrtc[%p] type[%u] track_id[%u] packet[%p, data_ptr:%p] user_data[%p]\n",
                webrtc, type, track_id, packet, data_ptr, user_data);
+#ifndef TIZEN_TV
+       if (type == WEBRTC_MEDIA_TYPE_AUDIO && conn->encoded_audio_frame_cb_is_set) {
+               if (!conn->render.espp) {
+                       g_printerr("render.espp is NULL\n");
+                       media_packet_destroy(packet);
+                       return;
+               }
+               /* TODO: submit data to espp */
 
+       } else if (type == WEBRTC_MEDIA_TYPE_VIDEO && conn->encoded_video_frame_cb_is_set) {
+               if (!conn->render.espp) {
+                       g_printerr("render.espp is NULL\n");
+                       media_packet_destroy(packet);
+                       return;
+               }
+               /* TODO: submit data to espp */
+       }
+#endif
 #ifdef __DEBUG_VALIDATE_ENCODED_FRAME_CB__
        {
                GstFlowReturn gst_ret = GST_FLOW_OK;
@@ -1964,6 +2041,15 @@ static void _webrtc_set_encoded_audio_frame_cb(int index)
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_set_encoded_audio_frame_cb() success\n");
+#ifndef TIZEN_TV
+       if (!g_conns[index].encoded_audio_frame_cb_is_set) {
+               g_conns[index].encoded_audio_frame_cb_is_set = true;
+               if (!g_conns[index].render.espp)
+                       g_print("espp create & open\n");
+
+               g_print("espp set audio stream info\n");
+       }
+#endif
 }
 
 static void _webrtc_unset_encoded_audio_frame_cb(int index)
@@ -1974,6 +2060,12 @@ static void _webrtc_unset_encoded_audio_frame_cb(int index)
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_unset_encoded_audio_frame_cb() success\n");
+#ifndef TIZEN_TV
+       if (g_conns[index].encoded_audio_frame_cb_is_set) {
+               g_conns[index].encoded_audio_frame_cb_is_set = false;
+               g_print("espp close & destroy\n");
+       }
+#endif
 }
 
 static void _webrtc_set_encoded_video_frame_cb(int index)
@@ -1984,6 +2076,15 @@ static void _webrtc_set_encoded_video_frame_cb(int index)
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_set_encoded_video_frame_cb() success\n");
+#ifndef TIZEN_TV
+       if (!g_conns[index].encoded_video_frame_cb_is_set) {
+               g_conns[index].encoded_video_frame_cb_is_set = true;
+               if (!g_conns[index].render.espp) {
+                       g_print("espp create & open\n");
+               }
+               g_print("espp set video stream info\n");
+       }
+#endif
 }
 
 static void _webrtc_unset_encoded_video_frame_cb(int index)
@@ -1991,10 +2092,15 @@ static void _webrtc_unset_encoded_video_frame_cb(int index)
        int ret = WEBRTC_ERROR_NONE;
 
        ret = webrtc_unset_encoded_video_frame_cb(g_conns[index].webrtc);
-       if (ret != WEBRTC_ERROR_NONE)
-               g_print("failed to webrtc_unset_encoded_video_frame_cb()\n");
-       else
-               g_print("webrtc_unset_encoded_video_frame_cb() success\n");
+       RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
+
+       g_print("webrtc_unset_encoded_video_frame_cb() success\n");
+#ifndef TIZEN_TV
+       if (g_conns[index].encoded_video_frame_cb_is_set) {
+               g_conns[index].encoded_video_frame_cb_is_set = false;
+               g_print("espp close & destroy\n");
+       }
+#endif
 }
 
 static void __media_packet_source_buffer_state_changed_cb(unsigned int source_id, webrtc_media_packet_source_buffer_state_e state, void *user_data)