webrtc_internal: Add webrtc_get_video_resolution() API 52/284752/1
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 25 Nov 2022 03:02:55 +0000 (12:02 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Fri, 25 Nov 2022 04:38:18 +0000 (13:38 +0900)
Missing preconditions are added to doxygen of some functions.

[Version] 0.3.266
[Issue Type] Internal API

Change-Id: I3ccfbf39e122a753023dafe16e5a13f36513a039

include/webrtc_internal.h
include/webrtc_private.h
packaging/capi-media-webrtc.spec
src/webrtc_internal.c
src/webrtc_sink.c

index 1e5338ec7ed3891e17ef5e9e82f9d493da214fcb..e93702deff214026bc2fe8c2c3cec4e250fbc60d 100644 (file)
@@ -115,6 +115,7 @@ int webrtc_set_ecore_wl_display(webrtc_h webrtc, unsigned int track_id, void *ec
  * @retval #WEBRTC_ERROR_NONE    Successful
  * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation
+ * @pre webrtc_track_added_cb() must be set by calling webrtc_set_track_added_cb().
  * @pre Call webrtc_set_sound_stream_info() before calling this function.
  * @see webrtc_get_audio_mute()
  */
@@ -133,11 +134,29 @@ int webrtc_set_audio_mute(webrtc_h webrtc, unsigned int track_id, bool mute);
  * @retval #WEBRTC_ERROR_NONE    Successful
  * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation
+ * @pre webrtc_track_added_cb() must be set by calling webrtc_set_track_added_cb().
  * @pre Call webrtc_set_sound_stream_info() before calling this function.
  * @see webrtc_set_audio_mute()
  */
 int webrtc_get_audio_mute(webrtc_h webrtc, unsigned int track_id, bool *muted);
 
+/**
+ * @internal
+ * @brief Gets the video resolution of the video track.
+ * @since_tizen 7.0
+ * @param[in] webrtc      WebRTC handle
+ * @param[in] track_id    The track id
+ * @param[out] width      The video width
+ * @param[out] height     The video height
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #WEBRTC_ERROR_NONE    Successful
+ * @retval #WEBRTC_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #WEBRTC_ERROR_INVALID_OPERATION Invalid operation
+ * @pre webrtc_track_added_cb() must be set by calling webrtc_set_track_added_cb().
+ */
+int webrtc_get_video_resolution(webrtc_h webrtc, unsigned int track_id, int *width, int *height);
+
 /**
  * @internal
  * @brief Sets a video loopback to render the video frames of the media source to an ecore wayland display.
index 115c4a76029fe45f215ebe60b193ee2677dfd587..652f90d99181f3bdd9954a7a6fddf755cfd204be 100644 (file)
@@ -764,6 +764,7 @@ int _set_display_visible_to_sink(webrtc_s *webrtc, unsigned int track_id, bool v
 int _get_display_visible_from_sink(webrtc_s *webrtc, unsigned int track_id, bool *visible);
 int _set_audio_mute_to_sink(webrtc_s *webrtc, unsigned int track_id, bool mute);
 int _get_audio_mute_from_sink(webrtc_s *webrtc, unsigned int track_id, bool *muted);
+int _get_video_resolution_from_sink(webrtc_s *webrtc, unsigned int track_id, int *width, int *height);
 
 /* sink dump */
 GstPadProbeReturn _depayloaded_data_probe_cb(GstPad *pad, GstPadProbeInfo *info, gpointer user_data);
index 5e5289628af235ef8a28c0d8da74a0fe4ac81d63..1b87e83d910224592a641bc55fc046590e9c3c30 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.3.265
+Version:    0.3.266
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index bea9050f19b6f8343aa3bfa9b88350717d6ff60e..6b268904aa57854d74a0900743840fbc24f9a293 100644 (file)
@@ -70,6 +70,22 @@ int webrtc_get_audio_mute(webrtc_h webrtc, unsigned int track_id, bool *muted)
        return _get_audio_mute_from_sink(_webrtc, track_id, muted);
 }
 
+int webrtc_get_video_resolution(webrtc_h webrtc, unsigned int track_id, int *width, int *height)
+{
+       g_autoptr(GMutexLocker) locker = NULL;
+       webrtc_s *_webrtc = (webrtc_s *)webrtc;
+
+       RET_VAL_IF(_webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+       RET_VAL_IF(width == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "width is NULL");
+       RET_VAL_IF(height == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "height is NULL");
+
+       locker = g_mutex_locker_new(&_webrtc->mutex);
+
+       RET_VAL_IF(_webrtc->track_added_cb.callback == NULL, WEBRTC_ERROR_INVALID_OPERATION, "track added callback was not set");
+
+       return _get_video_resolution_from_sink(_webrtc, track_id, width, height);
+}
+
 int webrtc_media_source_set_video_loopback_to_ecore_wl(webrtc_h webrtc, unsigned int source_id, void *ecore_wl_window, unsigned int *track_id)
 {
        int ret = WEBRTC_ERROR_NONE;
index aa44f780d879715678e97c2a86793eb842b53216..ff7bba4046b427f0dd9a09856fa9ad9fdcd8cb5f 100644 (file)
@@ -1282,4 +1282,27 @@ int _get_audio_mute_from_sink(webrtc_s *webrtc, unsigned int track_id, bool *mut
        return WEBRTC_ERROR_NONE;
 }
 
+int _get_video_resolution_from_sink(webrtc_s *webrtc, unsigned int track_id, int *width, int *height)
+{
+       webrtc_gst_slot_s *sink;
+
+       RET_VAL_IF(webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+       RET_VAL_IF(track_id == 0, WEBRTC_ERROR_INVALID_PARAMETER, "track id is 0");
+       RET_VAL_IF(width == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "width is NULL");
+       RET_VAL_IF(height == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "height is NULL");
+
+       sink = __find_sink_slot_by_id(webrtc, track_id);
+       RET_VAL_IF(sink == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "sink is NULL");
+       RET_VAL_IF(sink->bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL");
+       RET_VAL_IF(sink->encoded_frame_cb != NULL, WEBRTC_ERROR_INVALID_OPERATION, "it may be a forwarding sink for encoded frame callback");
+       RET_VAL_IF((sink->media_types & MEDIA_TYPE_VIDEO) == 0x0, WEBRTC_ERROR_INVALID_OPERATION, "it's not a video track");
+
+       *width = sink->video_info.width;
+       *height = sink->video_info.height;
+
+       LOG_INFO("webrtc[%p] track_id[%u] width[%d] height[%d]", webrtc, track_id, *width, *height);
+
+       return WEBRTC_ERROR_NONE;
+}
+
 //LCOV_EXCL_STOP