gboolean avdtp_stream_set_transport(struct avdtp_stream *stream, int fd,
						size_t imtu, size_t omtu)
{
	GIOChannel *io = g_io_channel_unix_new(fd);

	if (stream != stream->session->pending_open) {
		uint8_t err;

		if (stream->session->pending_open)
			goto failed;

		/* Attempt to Open there is no pending stream set yet */
		if (stream->lsep->ind && stream->lsep->ind->open) {
			if (!stream->lsep->ind->open(stream->session,
						stream->lsep,
						stream, &err,
						stream->lsep->user_data))
				goto failed;
		}

		stream_set_pending_open(stream, io);
		stream->imtu = imtu;
		stream->omtu = omtu;

		return TRUE;
	}

	handle_transport_connect(stream->session, io, imtu, omtu);

	g_io_channel_unref(io);

	return TRUE;

failed:
	g_io_channel_unref(io);
	return FALSE;
}
gboolean avdtp_stream_set_transport(struct avdtp_stream *stream, int fd,
						size_t imtu, size_t omtu)
{
	GIOChannel *io = g_io_channel_unix_new(fd);

	if (stream != stream->session->pending_open) {
		uint8_t err;

		if (stream->session->pending_open)
			goto failed;

		 
		if (stream->lsep->ind && stream->lsep->ind->open) {
			if (!stream->lsep->ind->open(stream->session,
						stream->lsep,
						stream, &err,
						stream->lsep->user_data))
				goto failed;
		}

		stream_set_pending_open(stream, io);
		stream->imtu = imtu;
		stream->omtu = omtu;

		return TRUE;
	}

	handle_transport_connect(stream->session, io, imtu, omtu);

	g_io_channel_unref(io);

	return TRUE;

failed:
	g_io_channel_unref(io);
	return FALSE;
}