static gboolean endpoint_init_a2dp_sink(struct media_endpoint *endpoint, gboolean delay_reporting, int *err) { endpoint->sep = a2dp_add_sep(endpoint->adapter->btd_adapter, AVDTP_SEP_TYPE_SINK, endpoint->codec, delay_reporting, &a2dp_endpoint, endpoint, a2dp_destroy_endpoint, err); if (endpoint->sep == NULL) return FALSE; return TRUE; }
int a2dp_init(DBusConnection *conn, GKeyFile *config) { int sbc_srcs = 1, sbc_sinks = 0; int mpeg12_srcs = 0, mpeg12_sinks = 0; gboolean source = TRUE, sink = TRUE; char *str; GError *err = NULL; int i; if (!config) goto proceed; str = g_key_file_get_string(config, "General", "Disable", &err); if (err) { debug("audio.conf: %s", err->message); g_error_free(err); err = NULL; } else { if (strstr(str, "Sink")) source = FALSE; if (strstr(str, "Source")) sink = FALSE; g_free(str); } str = g_key_file_get_string(config, "A2DP", "SBCSources", &err); if (err) { debug("audio.conf: %s", err->message); g_error_free(err); err = NULL; } else { sbc_srcs = atoi(str); g_free(str); } str = g_key_file_get_string(config, "A2DP", "MPEG12Sources", &err); if (err) { debug("audio.conf: %s", err->message); g_error_free(err); err = NULL; } else { mpeg12_srcs = atoi(str); g_free(str); } str = g_key_file_get_string(config, "A2DP", "SBCSinks", &err); if (err) { debug("audio.conf: %s", err->message); g_error_free(err); err = NULL; } else { sbc_sinks = atoi(str); g_free(str); } str = g_key_file_get_string(config, "A2DP", "MPEG12Sinks", &err); if (err) { debug("audio.conf: %s", err->message); g_error_free(err); err = NULL; } else { mpeg12_sinks = atoi(str); g_free(str); } proceed: connection = dbus_connection_ref(conn); avdtp_init(config); if (source) { for (i = 0; i < sbc_srcs; i++) a2dp_add_sep(conn, AVDTP_SEP_TYPE_SOURCE, A2DP_CODEC_SBC); for (i = 0; i < mpeg12_srcs; i++) a2dp_add_sep(conn, AVDTP_SEP_TYPE_SOURCE, A2DP_CODEC_MPEG12); } if (sink) { for (i = 0; i < sbc_sinks; i++) a2dp_add_sep(conn, AVDTP_SEP_TYPE_SINK, A2DP_CODEC_SBC); for (i = 0; i < mpeg12_sinks; i++) a2dp_add_sep(conn, AVDTP_SEP_TYPE_SINK, A2DP_CODEC_MPEG12); } return 0; }