Functions are added as below.
- webrtc_file_source_set_looping()
- webrtc_file_source_get_looping()
[Version] 0.2.113
[Issue type] API
Change-Id: Ie088db29ac4aeaf19fe2d5f85138787c4da5c9f7
*/
int webrtc_file_source_set_path(webrtc_h webrtc, unsigned int source_id, const char *path);
+/**
+ * @internal
+ * @brief Sets looping state to the file source.
+ * @details If the looping is @c true, the transfer starts again from the beginning of the file source.
+ * If it is @c false, it won't. The default value is @c false.
+ * @since_tizen 6.5
+ * @param[in] webrtc WebRTC handle
+ * @param[in] source_id The file source id
+ * @param[in] looping The new looping state: (@c true = looping, @c false = non-looping)
+ * @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
+ * @see webrtc_file_source_get_looping()
+ */
+int webrtc_file_source_set_looping(webrtc_h webrtc, unsigned int source_id, bool looping);
+
+/**
+ * @internal
+ * @brief Gets looping state to the file source.
+ * @since_tizen 6.5
+ * @param[in] webrtc WebRTC handle
+ * @param[in] source_id The file source id
+ * @param[out] looping The looping state: (@c true = looping, @c false = non-looping)
+ * @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
+ * @see webrtc_file_source_set_looping()
+ */
+int webrtc_file_source_get_looping(webrtc_h webrtc, unsigned int source_id, bool *looping);
+
/**
* @internal
* @brief Sets the crop coordinates of screen source.
GstElement *filesrc_pipeline;
GstBus *filesrc_bus;
guint filesrc_bus_watcher;
+ bool filesrc_loop;
webrtc_display_s *display;
} webrtc_gst_slot_s;
int _check_feature(const char *feature);
int _gst_filesrc_pipeline_set_state(webrtc_s *webrtc, GstState state);
+int _set_filesrc_looping(webrtc_s *webrtc, unsigned int source_id, bool looping);
+int _get_filesrc_looping(webrtc_s *webrtc, unsigned int source_id, bool *looping);
#ifdef __cplusplus
}
Name: capi-media-webrtc
Summary: A WebRTC library in Tizen Native API
-Version: 0.2.112
+Version: 0.2.113
Release: 0
Group: Multimedia/API
License: Apache-2.0
return _set_media_path(_webrtc, source_id, path);
}
+int webrtc_file_source_set_looping(webrtc_h webrtc, unsigned int source_id, bool looping)
+{
+ 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(source_id == 0, WEBRTC_ERROR_INVALID_PARAMETER, "source_id is 0");
+
+ locker = g_mutex_locker_new(&_webrtc->mutex);
+
+ return _set_filesrc_looping(_webrtc, source_id, looping);
+}
+
+int webrtc_file_source_get_looping(webrtc_h webrtc, unsigned int source_id, bool *looping)
+{
+ 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(source_id == 0, WEBRTC_ERROR_INVALID_PARAMETER, "source_id is 0");
+ RET_VAL_IF(looping == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "looping is NULL");
+
+ locker = g_mutex_locker_new(&_webrtc->mutex);
+
+ return _get_filesrc_looping(_webrtc, source_id, looping);
+}
+
int webrtc_screen_source_set_crop(webrtc_h webrtc, unsigned int source_id, int x, int y, int w, int h, bool portrait_mode, int *width, int *height)
{
int ret = WEBRTC_ERROR_NONE;
case GST_MESSAGE_EOS:
LOG_INFO("GST_MESSAGE_EOS end-of-stream");
-#if 0 //ToDo
- gst_element_seek(source->filesrc_pipeline,
- 1.0,
- GST_FORMAT_TIME,
- GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
- GST_SEEK_TYPE_SET, 0,
- GST_SEEK_TYPE_NONE, 0);
-#endif
+ if (source->filesrc_loop) {
+ gst_element_seek(source->filesrc_pipeline,
+ 1.0,
+ GST_FORMAT_TIME,
+ GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
+ GST_SEEK_TYPE_SET, 0,
+ GST_SEEK_TYPE_NONE, 0);
+ }
break;
default:
return WEBRTC_ERROR_NONE;
}
+
+int _set_filesrc_looping(webrtc_s *webrtc, unsigned int source_id, bool looping)
+{
+ webrtc_gst_slot_s *source = 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((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, "invalid source type [%d]", source->type);
+
+ source->filesrc_loop = looping;
+
+ LOG_DEBUG("source_id[%u] looping[%d]", source_id, looping);
+
+ return WEBRTC_ERROR_NONE;
+}
+
+int _get_filesrc_looping(webrtc_s * webrtc, unsigned int source_id, bool *looping)
+{
+ webrtc_gst_slot_s *source = 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(looping == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "looping is NULL");
+
+ 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, "invalid source type [%d]", source->type);
+
+ *looping = source->filesrc_loop;
+
+ LOG_DEBUG("source_id[%u] looping[%d]", source_id, *looping);
+
+ return WEBRTC_ERROR_NONE;
+}
CURRENT_STATUS_START_PUSHING_PACKET_TO_MEDIA_PACKET_SOURCE,
CURRENT_STATUS_STOP_PUSHING_PACKET_TO_MEDIA_PACKET_SOURCE,
CURRENT_STATUS_SET_MEDIA_PATH_TO_MEDIA_FILE_SOURCE,
+ CURRENT_STATUS_MEDIA_SOURCE_SET_FILE_LOOPING,
+ CURRENT_STATUS_MEDIA_SOURCE_GET_FILE_LOOPING,
CURRENT_STATUS_CREATE_PRIVATE_SIGNALING_SERVER,
CURRENT_STATUS_CONNECT_TO_PRIVATE_SIGNALING_SERVER,
CURRENT_STATUS_MUTE_MEDIA_SOURCE,
g_print("webrtc_file_source_set_path() success, source_id[%d]\n", source_id);
}
+static void _webrtc_media_source_set_file_looping(int index, unsigned int source_id, bool looping)
+{
+ int ret = WEBRTC_ERROR_NONE;
+
+ ret = webrtc_file_source_set_looping(g_conns[index].webrtc, source_id, looping);
+ RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
+
+ g_print("webrtc_file_source_set_looping() success, source_id[%u] looping_state[%u]\n", source_id, looping);
+}
+
+static void _webrtc_media_source_get_file_looping(int index, unsigned int source_id)
+{
+ int ret = WEBRTC_ERROR_NONE;
+ bool looping_state;
+
+ ret = webrtc_file_source_get_looping(g_conns[index].webrtc, source_id, &looping_state);
+ RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
+
+ g_print("webrtc_file_source_get_looping() success, source_id[%u] looping_state[%u]\n", source_id, looping_state);
+}
+
static void __close_websocket(connection_s *conn)
{
RET_IF(!conn, "conn is NULL");
_webrtc_signaling_disconnect(g_conn_index);
} else if (strncmp(cmd, "scs", 3) == 0) {
- g_conns[g_conn_index].menu_state = CURRENT_STATUS_SET_CROP_SCREEN_SOURCE;
+ g_conns[g_conn_index].menu_state = CURRENT_STATUS_SET_CROP_SCREEN_SOURCE;
} else if (strncmp(cmd, "ucs", 3) == 0) {
- g_conns[g_conn_index].menu_state = CURRENT_STATUS_UNSET_CROP_SCREEN_SOURCE;
+ g_conns[g_conn_index].menu_state = CURRENT_STATUS_UNSET_CROP_SCREEN_SOURCE;
+
+ } else if (strncmp(cmd, "sfl", 3) == 0) {
+ g_conns[g_conn_index].menu_state = CURRENT_STATUS_MEDIA_SOURCE_SET_FILE_LOOPING;
+
+ } else if (strncmp(cmd, "gfl", 3) == 0) {
+ g_conns[g_conn_index].menu_state = CURRENT_STATUS_MEDIA_SOURCE_GET_FILE_LOOPING;
} else {
g_print("unknown menu \n");
g_print("scs. *Set crop screen source\t");
g_print("ucs. *Unset crop screen source\n");
g_print("pa. *Set media path to file source\n");
+ g_print("sfl. Set file source looping\n");
+ g_print("gfl. Set file source looping\n");
g_print("sf. Set media format to media packet source\n");
g_print("dt. Set display type\t");
g_print("dm. Set display mode\t");
} else if (g_conns[g_conn_index].menu_state == CURRENT_STATUS_MEDIA_SOURCE_SET_VIDEO_LOOPBACK) {
g_print("*** input source id.\n");
+ } else if (g_conns[g_conn_index].menu_state == CURRENT_STATUS_MEDIA_SOURCE_SET_FILE_LOOPING) {
+ if (g_conns[g_conn_index].cnt == 0)
+ g_print("*** input source id.\n");
+ else if (g_conns[g_conn_index].cnt == 1)
+ g_print("*** input looping state.(1:true 0:false)\n");
+
+ } else if (g_conns[g_conn_index].menu_state == CURRENT_STATUS_MEDIA_SOURCE_GET_FILE_LOOPING) {
+ if (g_conns[g_conn_index].cnt == 0)
+ g_print("*** input source id.\n");
+
} else if (g_conns[g_conn_index].menu_state == CURRENT_STATUS_DATA_CHANNEL_SEND_STRING) {
g_print("*** input string to send.\n");
}
break;
}
+ case CURRENT_STATUS_MEDIA_SOURCE_SET_FILE_LOOPING: {
+ static unsigned int id;
+ value = atoi(cmd);
+ switch (g_conns[g_conn_index].cnt) {
+ case 0:
+ id = value;
+ g_conns[g_conn_index].cnt++;
+ break;
+ case 1:
+ _webrtc_media_source_set_file_looping(g_conn_index, id, value);
+ id = 0;
+ g_conns[g_conn_index].cnt = 0;
+ reset_menu_state();
+ break;
+ }
+ break;
+ }
+ case CURRENT_STATUS_MEDIA_SOURCE_GET_FILE_LOOPING: {
+ value = atoi(cmd);
+ _webrtc_media_source_get_file_looping(g_conn_index, value);
+ reset_menu_state();
+ break;
+ }
case CURRENT_STATUS_CREATE_PRIVATE_SIGNALING_SERVER: {
value = atoi(cmd);
_webrtc_signaling_server_create(value);