struct avdtp *avdtp_new(GIOChannel *chan, struct btd_device *device,
							struct queue *lseps)
{
	struct avdtp *session;

	session = g_new0(struct avdtp, 1);

	session->device = btd_device_ref(device);
	/* We don't use avdtp_set_state() here since this isn't a state change
	 * but just setting of the initial state */
	session->state = AVDTP_SESSION_STATE_DISCONNECTED;
	session->lseps = lseps;

	session->version = get_version(session);

	if (!chan)
		return session;

	avdtp_set_state(session, AVDTP_SESSION_STATE_CONNECTING);

	btd_device_add_uuid(device, ADVANCED_AUDIO_UUID);

	session->io = g_io_channel_ref(chan);
	session->io_id = g_io_add_watch(chan, G_IO_ERR | G_IO_HUP | G_IO_NVAL,
					(GIOFunc) session_cb, session);

	/* This is so that avdtp_connect_cb will know to do the right thing
	 * with respect to the disconnect timer */
	session->stream_setup = TRUE;

	session->dc_timeout = DISCONNECT_TIMEOUT;

	avdtp_connect_cb(chan, NULL, session);

	return session;
}
struct avdtp *avdtp_new(GIOChannel *chan, struct btd_device *device,
							struct queue *lseps)
{
	struct avdtp *session;

	session = g_new0(struct avdtp, 1);

	session->device = btd_device_ref(device);
	 
	session->state = AVDTP_SESSION_STATE_DISCONNECTED;
	session->lseps = lseps;

	session->version = get_version(session);

	if (!chan)
		return session;

	avdtp_set_state(session, AVDTP_SESSION_STATE_CONNECTING);

	btd_device_add_uuid(device, ADVANCED_AUDIO_UUID);

	session->io = g_io_channel_ref(chan);
	session->io_id = g_io_add_watch(chan, G_IO_ERR | G_IO_HUP | G_IO_NVAL,
					(GIOFunc) session_cb, session);

	 
	session->stream_setup = TRUE;

	session->dc_timeout = DISCONNECT_TIMEOUT;

	avdtp_connect_cb(chan, NULL, session);

	return session;
}