コード例 #1
0
ファイル: a2dp.c プロジェクト: tkymgr/semc-qsd8x50
static gboolean a2dp_reconfigure(gpointer data)
{
    struct a2dp_setup *setup = data;
    struct avdtp_local_sep *lsep;
    struct avdtp_remote_sep *rsep;
    struct avdtp_service_capability *cap;
    struct avdtp_media_codec_capability *codec_cap = NULL;
    GSList *l;
    int posix_err;

    for (l = setup->client_caps; l != NULL; l = l->next) {
        cap = l->data;

        if (cap->category != AVDTP_MEDIA_CODEC)
            continue;

        codec_cap = (void *) cap->data;
        break;
    }

    if (!codec_cap) {
        error("Cannot find capabilities to reconfigure");
        posix_err = -EINVAL;
        goto failed;
    }

    posix_err = avdtp_get_seps(setup->session, AVDTP_SEP_TYPE_SINK,
                               codec_cap->media_type,
                               codec_cap->media_codec_type,
                               &lsep, &rsep);
    if (posix_err < 0) {
        error("No matching ACP and INT SEPs found");
        goto failed;
    }

    if (setup->rsep) {
        rsep = setup->rsep;
    }

    posix_err = avdtp_set_configuration(setup->session, rsep, lsep,
                                        setup->client_caps,
                                        &setup->stream);
    if (posix_err < 0) {
        error("avdtp_set_configuration: %s", strerror(-posix_err));
        goto failed;
    }

    return FALSE;

failed:
    finalize_config_errno(setup, posix_err);
    return FALSE;
}
コード例 #2
0
ファイル: sink.c プロジェクト: Jeanlst/Onlive-Source-Backup
static void discovery_complete(struct avdtp *session, GSList *seps, struct avdtp_error *err,
				void *user_data)
{
	struct sink *sink = user_data;
	struct pending_request *pending;
	struct avdtp_local_sep *lsep;
	struct avdtp_remote_sep *rsep;
	GSList *caps = NULL;
	int id;

	pending = sink->connect;

	if (err) {
		avdtp_unref(sink->session);
		sink->session = NULL;
		if (avdtp_error_type(err) == AVDTP_ERROR_ERRNO
				&& avdtp_error_posix_errno(err) != EHOSTDOWN) {
			debug("connect:connect XCASE detected");
			g_timeout_add(STREAM_SETUP_RETRY_TIMER,
					stream_setup_retry, sink);
		} else
			goto failed;
		return;
	}

	debug("Discovery complete");

	if (avdtp_get_seps(session, AVDTP_SEP_TYPE_SINK, AVDTP_MEDIA_TYPE_AUDIO,
				A2DP_CODEC_SBC, &lsep, &rsep) < 0) {
		error("No matching ACP and INT SEPs found");
		goto failed;
	}

	if (!select_capabilities(session, rsep, &caps)) {
		error("Unable to select remote SEP capabilities");
		goto failed;
	}

	id = a2dp_source_config(sink->session, stream_setup_complete,
				caps, sink);
	if (id == 0)
		goto failed;

	pending->id = id;
	return;

failed:
	pending_request_free(pending);
	sink->connect = NULL;
	avdtp_unref(sink->session);
	sink->session = NULL;
	error_failed(pending->conn, pending->msg, "Stream setup failed");
}