webrtc_internal: Add function to get media type by source id 99/306399/2
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 21 Feb 2024 04:23:08 +0000 (13:23 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Wed, 21 Feb 2024 06:00:11 +0000 (15:00 +0900)
webrtc_media_source_get_type() has been added.

[Version] 0.4.44
[Issue Type] Internal API

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

index 7186ae9ad2d983df2f970279cfdbc06813e8cffd..7688d0f8b967b86ff1ea673e051bd5f828ddda26 100644 (file)
@@ -324,7 +324,7 @@ int webrtc_media_source_get_payload_type(webrtc_h webrtc, unsigned int source_id
 /**
  * @internal
  * @brief Adds the transceiver encoding option to the media source.
- * @since_tizen 9.0
+ * @since_tizen 8.0
  * @remarks If @a source_id should be a media source of #WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST or #WEBRTC_MEDIA_SOURCE_TYPE_MIC or #WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST or #WEBRTC_MEDIA_SOURCE_TYPE_NULL,
  *          otherwise this function will return #WEBRTC_ERROR_INVALID_PARAMETER.\n
  *          If @a source_id is a media source of #WEBRTC_MEDIA_SOURCE_TYPE_NULL, @a target_bitrate, @a width, and @a height will be ignored.\n
@@ -350,7 +350,7 @@ int webrtc_media_source_add_transceiver_encoding(webrtc_h webrtc, unsigned int s
 /**
  * @internal
  * @brief Removes the transceiver encoding option from the media source.
- * @since_tizen 9.0
+ * @since_tizen 8.0
  * @param[in] webrtc      WebRTC handle
  * @param[in] source_id   The media source id
  * @param[in] media_type  The media type
@@ -367,7 +367,7 @@ int webrtc_media_source_remove_transceiver_encoding(webrtc_h webrtc, unsigned in
 /**
  * @internal
  * @brief Actives the transceiver encoding option of the media source.
- * @since_tizen 9.0
+ * @since_tizen 8.0
  * @remarks The default value is @c true.
  * @param[in] webrtc      WebRTC handle
  * @param[in] source_id   The media source id
@@ -385,10 +385,27 @@ int webrtc_media_source_remove_transceiver_encoding(webrtc_h webrtc, unsigned in
  */
 int webrtc_media_source_active_transceiver_encoding(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e media_type, const char *rid, bool active);
 
+/**
+ * @internal
+ * @brief Gets the media type of the media source.
+ * @since_tizen 8.0
+ * @remarks If @a source_id is a media source of #WEBRTC_MEDIA_SOURCE_TYPE_FILE, this function will return #WEBRTC_ERROR_INVALID_PARAMETER.
+ * @param[in] webrtc      WebRTC handle
+ * @param[in] source_id   The media source id
+ * @param[out] media_type The media type
+ * @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 Add media source to @a webrtc to get @a source_id by calling webrtc_add_media_source().
+ */
+int webrtc_media_source_get_type(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e *media_type);
+
 /**
  * @internal
  * @brief Gets the local session description.
- * @since_tizen 9.0
+ * @since_tizen 8.0
  * @remarks @a description is a JSON string.\n
  *          It will be {"sdp":{"type":"offer or answer","sdp":"..."}}.\n
  *          The @a description should be released using free() if the value is not NULL.
@@ -406,7 +423,7 @@ int webrtc_get_local_description(webrtc_h webrtc, char **description);
 /**
  * @internal
  * @brief Gets the remote session description.
- * @since_tizen 9.0
+ * @since_tizen 8.0
  * @remarks @a description is a JSON string.\n
  *          It should be {"sdp":{"type":"offer or answer","sdp":"..."}}.\n
  *          The @a description should be released using free() if the value is not NULL.
index d10c2a7b8051504f6f944427b7fbabdb325b861e..5ab2ee9dbde1a0a3e8c3d9b5a8c0757b0ccddf4b 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.4.43
+Version:    0.4.44
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index eb505749518bd3e503f77252d272971cc05d2ed7..3f6e55434798c2ff7cc13d96d702fc2287f2afe3 100644 (file)
@@ -272,6 +272,40 @@ int webrtc_media_source_active_transceiver_encoding(webrtc_h webrtc, unsigned in
        return _active_transceiver_encoding(webrtc, source_id, media_type, rid, active);
 }
 
+int webrtc_media_source_get_type(webrtc_h webrtc, unsigned int source_id, webrtc_media_type_e *media_type)
+{
+       webrtc_s *_webrtc = (webrtc_s *)webrtc;
+       webrtc_gst_slot_s *source;
+       g_autoptr(GMutexLocker) locker = NULL;
+
+       RET_VAL_IF(_webrtc == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "webrtc is NULL");
+       RET_VAL_IF(source_id == 0, WEBRTC_ERROR_INVALID_PARAMETER, "source_id is 0");
+       RET_VAL_IF(media_type == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "media type is NULL");
+
+       locker = g_mutex_locker_new(&_webrtc->mutex);
+
+       RET_VAL_IF((source = _get_slot_by_id(_webrtc->gst.source_slots, source_id)) == NULL,
+               WEBRTC_ERROR_INVALID_PARAMETER, "could not find source");
+       RET_VAL_IF(source->type == WEBRTC_MEDIA_SOURCE_TYPE_FILE, WEBRTC_ERROR_INVALID_PARAMETER, "file source type is not supported");
+       RET_VAL_IF(source->media_types == 0, WEBRTC_ERROR_INVALID_OPERATION, "media_types is not assigned yet");
+
+       switch (source->media_types) {
+       case MEDIA_TYPE_AUDIO:
+               *media_type = WEBRTC_MEDIA_TYPE_AUDIO;
+               break;
+       case MEDIA_TYPE_VIDEO:
+               *media_type = WEBRTC_MEDIA_TYPE_VIDEO;
+               break;
+       default:
+               LOG_ERROR("media_types[0x%x]", source->media_types);
+               return WEBRTC_ERROR_INVALID_OPERATION;
+       }
+
+       LOG_INFO("webrtc[%p] source_id[%u] media_type[%d]", _webrtc, source_id, *media_type);
+
+       return WEBRTC_ERROR_NONE;
+}
+
 int webrtc_get_local_description(webrtc_h webrtc, char **description)
 {
        g_autoptr(GMutexLocker) locker = NULL;