#define DEFAULT_AUDIO_CHANNELS 1
#define DEFAULT_AUDIO_SAMPLERATE 8000
+#define DEFAULT_DOT_FILE_NAME_PREFIX "webrtc"
+#define DEFAULT_DOT_DIRECTORY "/tmp"
+
typedef enum {
CODEC_TYPE_OPUS,
CODEC_TYPE_VORBIS,
} \
} while (0)
+#define GENERATE_DOT(x_webrtc, x_fmt, x_arg...) \
+do { \
+ gchar *dot_name; \
+ if (!x_webrtc->ini.generate_dot) \
+ break; \
+ dot_name = g_strdup_printf(""x_fmt"", x_arg); \
+ __generate_dot(x_webrtc, dot_name); \
+ g_free(dot_name); \
+} while (0)
+
static const char* __state_str[] = {
"IDLE",
"NEGOTIATING",
"PLAYING",
};
+static void __generate_dot(webrtc_s *webrtc, const gchar *name)
+{
+ gchar *dot_name;
+
+ RET_IF(webrtc == NULL, "webrtc is NULL");
+ RET_IF(webrtc->gst.pipeline == NULL, "pipeline is NULL");
+
+ if (!name)
+ dot_name = g_strdup(DEFAULT_DOT_FILE_NAME_PREFIX);
+ else
+ dot_name = g_strconcat(DEFAULT_DOT_FILE_NAME_PREFIX, ".", name, NULL);
+
+ GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(webrtc->gst.pipeline), GST_DEBUG_GRAPH_SHOW_ALL, dot_name);
+
+ LOG_INFO("dot file[%s] is generated", dot_name);
+
+ g_free(dot_name);
+}
+
/* Use g_free() to release the return value. */
static gchar* __get_string_from_json_object(JsonObject *object)
{
((webrtc_state_changed_cb)(webrtc->state_changed_cb.callback))((webrtc_h)webrtc, old, new, webrtc->state_changed_cb.user_data);
LOG_DEBUG("<<< end of the callback");
}
+
+ GENERATE_DOT(webrtc, "STATE_%s", __state_str[webrtc->state]);
}
static gboolean __bus_watch_cb(GstBus *bus, GstMessage *message, gpointer user_data)
LOG_INFO("GST_MESSAGE_STATE_CHANGED: %s", state_transition_name);
g_free(state_transition_name);
- /* TODO: generate dot */
-
g_mutex_lock(&webrtc->mutex);
if (webrtc->pend_state == webrtc->state) {
LOG_DEBUG("pend_state[%s] is same with current state", __state_str[webrtc->pend_state]);
memset(&webrtc->ini, 0, sizeof(webrtc_ini_s));
/* FIXME: load from ini file */
+ /* set it TRUE temporarily until ini ready */
+ webrtc->ini.generate_dot = TRUE;
- webrtc->ini.generate_dot = FALSE;
+ if (webrtc->ini.generate_dot) {
+ /* FIXME: get path from ini */
+ LOG_INFO("dot file will be stored in [%s]", DEFAULT_DOT_DIRECTORY);
+ g_setenv("GST_DEBUG_DUMP_DOT_DIR", DEFAULT_DOT_DIRECTORY, FALSE);
+ }
return WEBRTC_ERROR_NONE;
}
if (ret != WEBRTC_ERROR_NONE)
LOG_ERROR("failed to build a rendering pipeline");
+
+ GENERATE_DOT(webrtc, "%s", GST_ELEMENT_NAME(decodebin));
}
static int __decodebin_autoplug_select_cb(GstElement *decodebin, GstPad *pad, GstCaps *caps, GstElementFactory *factory, gpointer user_data)
ret = __add_rendering_sink_bin(webrtc, new_pad);
RET_IF(ret != WEBRTC_ERROR_NONE, "failed to __add_rendering_sink_bin()");
+
+ GENERATE_DOT(webrtc, "webrtcbin_%s", GST_PAD_NAME(new_pad));
}
static void __webrtcbin_no_more_pads_cb(GstElement *webrtcbin, gpointer user_data)