*/
int webrtc_screen_source_unset_crop(webrtc_h webrtc, unsigned int source_id);
-/**
- * @internal
- * @brief Sets the probability of RTP packet dropping.
- * @since_tizen 7.0
- * @param[in] webrtc WebRTC handle
- * @param[in] source_id The file source id
- * @param[in] probability The probability to be dropped (from @c 0 to @c 1.0 = 100%)
- * @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 screen source to @a webrtc to get @a source_id by calling webrtc_add_media_source().
- * @see webrtc_media_source_get_rtp_packet_drop_probability()
- */
-int webrtc_media_source_set_rtp_packet_drop_probability(webrtc_h webrtc, unsigned int source_id, float probability);
-
-/**
- * @internal
- * @brief Gets the probability of RTP packet dropping.
- * @since_tizen 7.0
- * @remarks The default value is 0.
- * @param[in] webrtc WebRTC handle
- * @param[in] source_id The file source id
- * @param[out] probability The probability to be dropped (from @c 0 to @c 1.0 = 100%)
- * @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 screen source to @a webrtc to get @a source_id by calling webrtc_add_media_source().
- * @see webrtc_media_source_set_rtp_packet_drop_probability()
- */
-int webrtc_media_source_get_rtp_packet_drop_probability(webrtc_h webrtc, unsigned int source_id, float *probability);
-
/**
* @internal
* @brief Sets the probability of RTP packet dropping.
return _unset_screen_source_crop(_webrtc, source_id);
}
-int webrtc_media_source_set_rtp_packet_drop_probability(webrtc_h webrtc, unsigned int source_id, float probability)
-{
- webrtc_s *_webrtc = (webrtc_s*)webrtc;
- 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(probability > 1.0, WEBRTC_ERROR_INVALID_PARAMETER, "probability > 1.0");
- RET_VAL_IF(probability < 0, WEBRTC_ERROR_INVALID_PARAMETER, "probability < 0");
-
- locker = g_mutex_locker_new(&_webrtc->mutex);
-
- return _set_rtp_packet_drop_probability(webrtc, source_id, probability);
-}
-
-int webrtc_media_source_get_rtp_packet_drop_probability(webrtc_h webrtc, unsigned int source_id, float *probability)
-{
- webrtc_s *_webrtc = (webrtc_s*)webrtc;
- 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(probability == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "probability is NULL");
-
- locker = g_mutex_locker_new(&_webrtc->mutex);
-
- return _get_rtp_packet_drop_probability(webrtc, source_id, probability);
-}
-
int webrtc_set_rtp_packet_drop_probability(webrtc_h webrtc, bool sender, float probability)
{
webrtc_s *_webrtc = (webrtc_s*)webrtc;
#define DEFAULT_ELEMENT_INPUT_SELECTOR "input-selector"
#define DEFAULT_ELEMENT_VIDEOCROP "videocrop"
#define DEFAULT_ELEMENT_FILESRC "filesrc"
-#define DEFAULT_ELEMENT_NETWORK_SIMULATOR "netsim"
#define ELEMENT_NAME_FIRST_CAPSFILTER "firstCapsfilter"
#define ELEMENT_NAME_RTP_CAPSFILTER "rtpCapsfilter"
#define ELEMENT_NAME_VIDEO_FAKESINK "videoFakeSink"
#define ELEMENT_NAME_AUDIO_APPSRC "audioAppsrc"
#define ELEMENT_NAME_VIDEO_APPSRC "videoAppsrc"
-#define ELEMENT_NAME_AUDIO_NETWORK_SIMULATOR "audioNetSim"
-#define ELEMENT_NAME_VIDEO_NETWORK_SIMULATOR "videoNetSim"
#define APPEND_ELEMENT(x_list, x_element) \
do { \
const char *payloader_name;
const char *capsfilter_name;
const char *fakesink_name;
- const char *network_simulator_name;
} av_mapping_table_s;
static av_mapping_table_s _av_tbl[AV_IDX_MAX] = {
ELEMENT_NAME_AUDIO_PAYLOADER,
ELEMENT_NAME_AUDIO_CAPSFILTER,
ELEMENT_NAME_AUDIO_FAKESINK,
- ELEMENT_NAME_AUDIO_NETWORK_SIMULATOR
},
{
ELEMENT_NAME_VIDEO_APPSRC,
ELEMENT_NAME_VIDEO_PAYLOADER,
ELEMENT_NAME_VIDEO_CAPSFILTER,
ELEMENT_NAME_VIDEO_FAKESINK,
- ELEMENT_NAME_VIDEO_NETWORK_SIMULATOR
}
};
goto error;
APPEND_ELEMENT(*element_list, payloader);
- if (webrtc->ini.general.network_simulator) {
- GstElement *netsim = _create_element(DEFAULT_ELEMENT_NETWORK_SIMULATOR, NULL);
- if (!netsim)
- goto error;
- APPEND_ELEMENT(*element_list, netsim);
- }
-
if (!(queue = _create_element(DEFAULT_ELEMENT_QUEUE, NULL)))
goto error;
APPEND_ELEMENT(*element_list, queue);
goto error;
APPEND_ELEMENT(*element_list, payloader);
- if (webrtc->ini.general.network_simulator) {
- GstElement *netsim = _create_element(DEFAULT_ELEMENT_NETWORK_SIMULATOR, NULL);
- if (!netsim)
- goto error;
- APPEND_ELEMENT(*element_list, netsim);
- }
-
if (!(queue = _create_element(DEFAULT_ELEMENT_QUEUE, NULL)))
goto error;
APPEND_ELEMENT(*element_list, queue);
GstElement *payloader;
GstElement *capsfilter;
GstElement *fakesink;
- GstElement *netsim;
GList *element_list = NULL;
int av_idx = GET_AV_IDX(is_audio);
else
LOG_ERROR("fakesink is NULL");
- if (source->webrtc->ini.general.network_simulator) {
- if ((netsim = gst_bin_get_by_name(bin, _av_tbl[av_idx].network_simulator_name)))
- APPEND_ELEMENT(element_list, netsim);
- else
- LOG_ERROR("netsim is NULL");
- }
-
__remove_elements_from_bin(bin, element_list);
SAFE_G_LIST_FREE(element_list);
GstBin *bin;
GstElement *queue;
GstElement *payloader;
- GstElement *netsim;
GstElement *capsfilter;
GstElement *fakesink;
GList *element_list = NULL;
RET_VAL_IF(source == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
- RET_VAL_IF(source->webrtc == NULL, WEBRTC_ERROR_INVALID_OPERATION, "webrtc is NULL");
RET_VAL_IF(source->filesrc_pipeline == NULL, WEBRTC_ERROR_INVALID_OPERATION, "filesrc_pipeline is NULL");
bin = GST_BIN(source->filesrc_pipeline);
goto exit;
APPEND_ELEMENT(element_list, payloader);
- if (source->webrtc->ini.general.network_simulator) {
- if (!(netsim = _create_element(DEFAULT_ELEMENT_NETWORK_SIMULATOR, _av_tbl[GET_AV_IDX(is_audio)].network_simulator_name)))
- goto exit;
- APPEND_ELEMENT(element_list, netsim);
- }
-
if (!(capsfilter = __prepare_capsfilter_for_filesrc_pipeline(source, is_audio)))
goto exit;
APPEND_ELEMENT(element_list, capsfilter);
return WEBRTC_ERROR_NONE;
}
-int _set_rtp_packet_drop_probability(webrtc_s *webrtc, unsigned int source_id, float probability)
-{
- webrtc_gst_slot_s *source;
- GstElement *netsim;
- GstBin *bin;
-
- 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(probability > 1.0, WEBRTC_ERROR_INVALID_PARAMETER, "probability > 1.0");
- RET_VAL_IF(probability < 0, WEBRTC_ERROR_INVALID_PARAMETER, "probability < 0");
- RET_VAL_IF((source = _get_slot_by_id(webrtc->gst.source_slots, source_id)) == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
- RET_VAL_IF(webrtc->ini.general.network_simulator == false, WEBRTC_ERROR_INVALID_OPERATION, "network simulator is disabled, please check the ini");
- bin = (source->type == WEBRTC_MEDIA_SOURCE_TYPE_FILE) ? GST_BIN(source->filesrc_pipeline) : GST_BIN(source->bin);
- RET_VAL_IF(bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL");
-
- if (source->type == WEBRTC_MEDIA_SOURCE_TYPE_FILE) {
- int count = 0;
- int av_idx = 0;
- for (av_idx = 0; av_idx < AV_IDX_MAX; av_idx++) {
- if ((netsim = gst_bin_get_by_name(bin, _av_tbl[av_idx].network_simulator_name))) {
- g_object_set(G_OBJECT(netsim), "drop-probability", probability, NULL);
- LOG_INFO("webrtc[%p] source_id[%u] probability[%f] applies to [%s]", webrtc, source_id, probability, GST_ELEMENT_NAME(netsim));
- count++;
- }
- }
- RET_VAL_IF(count == 0, WEBRTC_ERROR_INVALID_OPERATION, "could not find any element for network simulator");
- return WEBRTC_ERROR_NONE;
- }
-
- if (!(netsim = __find_element_in_bin(bin, DEFAULT_ELEMENT_NETWORK_SIMULATOR))) {
- LOG_ERROR("could not find any element for network simulator");
- return WEBRTC_ERROR_INVALID_OPERATION;
- }
- g_object_set(G_OBJECT(netsim), "drop-probability", probability, NULL);
-
- LOG_INFO("webrtc[%p] source_id[%u] probability[%f] applies to [%s]", webrtc, source_id, probability, GST_ELEMENT_NAME(netsim));
-
- return WEBRTC_ERROR_NONE;
-}
-
-int _get_rtp_packet_drop_probability(webrtc_s *webrtc, unsigned int source_id, float *probability)
-{
- webrtc_gst_slot_s *source;
- GstElement *netsim;
- GstBin *bin;
-
- 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(probability == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "probability is NULL");
- RET_VAL_IF((source = _get_slot_by_id(webrtc->gst.source_slots, source_id)) == NULL, WEBRTC_ERROR_INVALID_PARAMETER, "source is NULL");
- RET_VAL_IF(webrtc->ini.general.network_simulator == false, WEBRTC_ERROR_INVALID_OPERATION, "network simulator is disabled, please check the ini");
- bin = (source->type == WEBRTC_MEDIA_SOURCE_TYPE_FILE) ? GST_BIN(source->filesrc_pipeline) : GST_BIN(source->bin);
- RET_VAL_IF(bin == NULL, WEBRTC_ERROR_INVALID_OPERATION, "bin is NULL");
-
- if (source->type == WEBRTC_MEDIA_SOURCE_TYPE_FILE) {
- int av_idx = 0;
- for (av_idx = 0; av_idx < AV_IDX_MAX; av_idx++) {
- if ((netsim = gst_bin_get_by_name(bin, _av_tbl[av_idx].network_simulator_name)))
- break;
- }
-
- } else {
- netsim = __find_element_in_bin(bin, DEFAULT_ELEMENT_NETWORK_SIMULATOR);
- }
- RET_VAL_IF(!netsim, WEBRTC_ERROR_INVALID_OPERATION, "could not find any element for network simulator");
-
- g_object_get(G_OBJECT(netsim), "drop-probability", (gfloat *)probability, NULL);
- LOG_INFO("webrtc[%p] source_id[%u] probability[%f]", webrtc, source_id, *probability);
-
- return WEBRTC_ERROR_NONE;
-}
-
static void __remove_filesrc_pad_block_foreach_cb(gpointer key, gpointer value, gpointer user_data)
{
webrtc_gst_slot_s *source = (webrtc_gst_slot_s *)value;
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_MEDIA_SOURCE_SET_RTP_PACKET_DROP_PROBABILITY,
- CURRENT_STATUS_MEDIA_SOURCE_GET_RTP_PACKET_DROP_PROBABILITY,
CURRENT_STATUS_CREATE_PRIVATE_SIGNALING_SERVER,
CURRENT_STATUS_CONNECT_TO_PRIVATE_SIGNALING_SERVER,
CURRENT_STATUS_MUTE_MEDIA_SOURCE,
g_print("webrtc_file_source_get_looping() success, source_id[%u] looping_state[%u]\n", source_id, looping_state);
}
-static void _webrtc_media_source_set_rtp_packet_drop_probability(unsigned int source_id, float probability)
-{
- int ret = WEBRTC_ERROR_NONE;
-
- ret = webrtc_media_source_set_rtp_packet_drop_probability(g_conns[0].webrtc, source_id, probability);
- RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
-
- g_print("webrtc_media_source_set_rtp_packet_drop_probability() success, source_id[%u] probability[%f]\n", source_id, probability);
-}
-
-static void _webrtc_media_source_get_rtp_packet_drop_probability(unsigned int source_id)
-{
- int ret = WEBRTC_ERROR_NONE;
- float probability;
-
- ret = webrtc_media_source_get_rtp_packet_drop_probability(g_conns[0].webrtc, source_id, &probability);
- RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
-
- g_print("webrtc_media_source_get_rtp_packet_drop_probability() success, source_id[%u] probability[%f]\n", source_id, probability);
-}
-
static void __close_websocket(signaling_server_s *ss)
{
RET_IF(!ss, "ss is NULL");
} else if (strncmp(cmd, "gfl", 3) == 0) {
g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_GET_FILE_LOOPING;
- } else if (strncmp(cmd, "sdp", 3) == 0) {
- g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_SET_RTP_PACKET_DROP_PROBABILITY;
-
- } else if (strncmp(cmd, "gdp", 3) == 0) {
- g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_GET_RTP_PACKET_DROP_PROBABILITY;
-
} else {
g_print("unknown menu \n");
}
g_print("sfl. *Set file source looping\t");
g_print("gfl. *Set file source looping\n");
g_print("sf. Set media format to media packet source\n");
- g_print("sdp. *Set RTP packet drop probility\t");
- g_print("gdp. *Get RTP packet drop probility\n");
g_print("dt. Set display type\t");
g_print("dm. Set display mode\t");
g_print("gm. Get display mode\n");
if (g_cnt == 0)
g_print("*** input source id.\n");
- } else if (g_menu_state == CURRENT_STATUS_MEDIA_SOURCE_SET_RTP_PACKET_DROP_PROBABILITY) {
- if (g_cnt == 0)
- g_print("*** input source id.\n");
- else if (g_cnt == 1)
- g_print("*** input drop probability.(0 ~ 1.0)\n");
-
- } else if (g_menu_state == CURRENT_STATUS_MEDIA_SOURCE_GET_RTP_PACKET_DROP_PROBABILITY) {
- if (g_cnt == 0)
- g_print("*** input source id.\n");
-
} else if (g_menu_state == CURRENT_STATUS_DATA_CHANNEL_SEND_STRING) {
g_print("*** input string to send.\n");
reset_menu_state();
break;
}
- case CURRENT_STATUS_MEDIA_SOURCE_SET_RTP_PACKET_DROP_PROBABILITY: {
- static unsigned int id;
- switch (g_cnt) {
- case 0:
- value = atoi(cmd);
- id = value;
- g_cnt++;
- break;
- case 1: {
- float fvalue = strtof(cmd, NULL);
- _webrtc_media_source_set_rtp_packet_drop_probability(id, fvalue);
- id = 0;
- g_cnt = 0;
- reset_menu_state();
- break;
- }
- }
- break;
- }
- case CURRENT_STATUS_MEDIA_SOURCE_GET_RTP_PACKET_DROP_PROBABILITY: {
- value = atoi(cmd);
- _webrtc_media_source_get_rtp_packet_drop_probability(value);
- reset_menu_state();
- break;
- }
case CURRENT_STATUS_CREATE_PRIVATE_SIGNALING_SERVER: {
value = atoi(cmd);
_webrtc_signaling_server_create(value);