typedef struct _ini_item_general_s {
bool generate_dot;
const char *dot_path;
+ int stats_log_period;
bool verbose_log;
bool nice_verbose;
gchar **gst_args;
typedef struct _webrtc_s {
webrtc_ini_s ini;
+ guint stats_timer_src;
GMutex mutex;
GMutex desc_mutex;
int _data_channel_send_bytes(webrtc_data_channel_s *channel, const char *data, unsigned int size);
void _webrtcbin_get_stats(webrtc_s *webrtc);
+void _set_stats_timer(webrtc_s *webrtc);
+void _unset_stats_timer(webrtc_s *webrtc);
typedef int (*_websocket_cb)(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len);
webrtc_websocket_s *_alloc_websocket(const int port, const char *ssl_cert_path, const char *ssl_private_key_path, const char *ssl_ca_path, _websocket_cb callback, void *user_data);
Name: capi-media-webrtc
Summary: A WebRTC library in Tizen Native API
-Version: 0.2.94
+Version: 0.2.95
Release: 0
Group: Multimedia/API
License: Apache-2.0
locker = g_mutex_locker_new(&_webrtc->mutex);
+ _unset_stats_timer(_webrtc);
+
ret = _gst_pipeline_set_state(_webrtc, GST_STATE_NULL);
RET_VAL_IF(ret != WEBRTC_ERROR_NONE, ret, "failed to _gst_pipeline_set_state()");
#define WEBRTC_INI_PATH SYSCONFDIR"/multimedia/mmfw_webrtc.ini"
#define DEFAULT_GENERATE_DOT true
#define DEFAULT_DOT_PATH "/tmp"
+#define DEFAULT_STATS_LOG_PERIOD 0 /* sec */
#define DEFAULT_VERBOSE_LOG false
#define DEFAULT_NICE_VERBOSE false
#define DEFAULT_JITTERBUFFER_LATENCY 200 /* ms */
/* items for general */
#define INI_ITEM_DOT_PATH "dot path"
#define INI_ITEM_DOT_GENERATE "generate dot"
+#define INI_ITEM_STATS_LOG_PERIOD "stats log period"
#define INI_ITEM_VERBOSE_LOG "verbose log"
#define INI_ITEM_NICE_VERBOSE "nice verbose"
#define INI_ITEM_GST_ARGS "gstreamer arguments"
LOG_INFO("[%s]", INI_CATEGORY_GENERAL);
__dump_item(INI_ITEM_DOT_GENERATE, INI_ITEM_TYPE_BOOL, &ini->general.generate_dot);
__dump_item(INI_ITEM_DOT_PATH, INI_ITEM_TYPE_STRING, (void *)ini->general.dot_path);
+ __dump_item(INI_ITEM_STATS_LOG_PERIOD, INI_ITEM_TYPE_INT, &ini->general.stats_log_period);
__dump_item(INI_ITEM_VERBOSE_LOG, INI_ITEM_TYPE_BOOL, &ini->general.verbose_log);
__dump_item(INI_ITEM_NICE_VERBOSE, INI_ITEM_TYPE_BOOL, &ini->general.nice_verbose);
__dump_item(INI_ITEM_GST_ARGS, INI_ITEM_TYPE_STRINGS, ini->general.gst_args);
LOG_INFO("dot file will be stored in [%s]", ini->general.dot_path);
g_setenv("GST_DEBUG_DUMP_DOT_DIR", ini->general.dot_path, FALSE);
}
+ ini->general.stats_log_period = __ini_get_int(ini->dict, INI_CATEGORY_GENERAL, INI_ITEM_STATS_LOG_PERIOD, DEFAULT_STATS_LOG_PERIOD);
ini->general.verbose_log = g_verbose = __ini_get_boolean(ini->dict, INI_CATEGORY_GENERAL, INI_ITEM_VERBOSE_LOG, DEFAULT_VERBOSE_LOG);
ini->general.nice_verbose = __ini_get_boolean(ini->dict, INI_CATEGORY_GENERAL, INI_ITEM_NICE_VERBOSE, DEFAULT_NICE_VERBOSE);
if (ini->general.nice_verbose)
LOG_DEBUG("<<< end of the callback");
}
+ if (new == WEBRTC_STATE_PLAYING)
+ _set_stats_timer(webrtc);
+
GENERATE_DOT(webrtc, "STATE_%s", __state_str[webrtc->state]);
}
RET_VAL_IF(webrtc->state == WEBRTC_STATE_IDLE, WEBRTC_ERROR_INVALID_STATE, "the state should not be IDLE");
+ _unset_stats_timer(webrtc);
+
ret = _gst_pipeline_set_state(webrtc, GST_STATE_NULL);
RET_VAL_IF(ret != WEBRTC_ERROR_NONE, ret, "failed to _gst_pipeline_set_state()");
gst_promise_unref(promise);
}
+
+static gboolean __get_stats_periodically(gpointer user_data)
+{
+ webrtc_s *webrtc = (webrtc_s*)user_data;
+
+ if (webrtc->state == WEBRTC_STATE_PLAYING)
+ _webrtcbin_get_stats(webrtc);
+
+ return G_SOURCE_CONTINUE;
+}
+
+void _set_stats_timer(webrtc_s *webrtc)
+{
+ RET_IF(webrtc == NULL, "webrtc is NULL");
+
+ if (webrtc->ini.general.stats_log_period <= 0) {
+ LOG_DEBUG("ini.general.stats_log_period[%d], skip printing stats", webrtc->ini.general.stats_log_period);
+ return;
+ }
+
+ if (webrtc->stats_timer_src != 0)
+ return;
+
+ webrtc->stats_timer_src = g_timeout_add_seconds(webrtc->ini.general.stats_log_period, __get_stats_periodically, webrtc);
+ LOG_DEBUG("new stats_timer_src[%u]", webrtc->stats_timer_src);
+}
+
+void _unset_stats_timer(webrtc_s *webrtc)
+{
+ RET_IF(webrtc == NULL, "webrtc is NULL");
+
+ if (webrtc->stats_timer_src == 0)
+ return;
+
+ g_source_remove(webrtc->stats_timer_src);
+
+ LOG_DEBUG("remove stats_timer_src[%u]", webrtc->stats_timer_src);
+ webrtc->stats_timer_src = 0;
+}
\ No newline at end of file