Skip to contentSkip to conversation

Implement AVCTP passthrough commands

DISCUSSION Paolo Medici 1 participant 3 messages Apr 11, 2010 – Apr 15, 2010 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

Hi,
Are there no contraindications to complete the implementation in audio/control.c of other commands (as well as VolumeUp/VolumeDown)? In this case, to try to control my iPod Touch, I would like to add remaining ones.

Paolo

#1 lore raw

Something like that (attached).

Quoted 11 lines · Paolo Medici

Hi,
Are there no contraindications to complete the implementation in audio/control.c of other commands (as well as VolumeUp/VolumeDown)? In this case, to try to control my iPod Touch, I would like to add remaining ones.

Paolo
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

audio/control.c +34 -25
index 1763d60..359b68a 100644
@@ -1002,8 +1002,7 @@ static int avctp_send_passthrough(struct control *control, uint8_t op)
 	return write(sk, buf, sizeof(buf));
 }
 
-static DBusMessage *volume_up(DBusConnection *conn, DBusMessage *msg,
-								void *data)
+static DBusMessage *internal_send_passthrough(DBusConnection *conn, DBusMessage *msg, void *data, uint8_t op)
 {
 	struct audio_device *device = data;
 	struct control *control = device->control;
@@ -1024,7 +1023,7 @@ static DBusMessage *volume_up(DBusConnection *conn, DBusMessage *msg,
 					ERROR_INTERFACE ".NotSupported",
 					"AVRCP Target role not supported");
 
-	err = avctp_send_passthrough(control, VOL_UP_OP);
+	err = avctp_send_passthrough(control, op);
 	if (err < 0)
 		return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
 							strerror(-err));
@@ -1032,34 +1031,40 @@ static DBusMessage *volume_up(DBusConnection *conn, DBusMessage *msg,
 	return dbus_message_new_method_return(msg);
 }
 
-static DBusMessage *volume_down(DBusConnection *conn, DBusMessage *msg,
+static DBusMessage *volume_up(DBusConnection *conn, DBusMessage *msg,
 								void *data)
 {
-	struct audio_device *device = data;
-	struct control *control = device->control;
-	DBusMessage *reply;
-	int err;
+        return internal_send_passthrough(conn, msg, data, VOL_UP_OP);
+}
 
-	reply = dbus_message_new_method_return(msg);
-	if (!reply)
-		return NULL;
+static DBusMessage *volume_down(DBusConnection *conn, DBusMessage *msg,
+								void *data)
+{
+        return internal_send_passthrough(conn, msg, data, VOL_DOWN_OP);
+}
 
-	if (control->state != AVCTP_STATE_CONNECTED)
-		return g_dbus_create_error(msg,
-					ERROR_INTERFACE ".NotConnected",
-					"Device not Connected");
+static DBusMessage *control_play(DBusConnection *conn, DBusMessage *msg,
+								void *data)
+{
+        return internal_send_passthrough(conn, msg, data, PLAY_OP);
+}
 
-	if (!control->target)
-		return g_dbus_create_error(msg,
-					ERROR_INTERFACE ".NotSupported",
-					"AVRCP Target role not supported");
+static DBusMessage *volume_mute(DBusConnection *conn, DBusMessage *msg,
+								void *data)
+{
+        return internal_send_passthrough(conn, msg, data, MUTE_OP);
+}
 
-	err = avctp_send_passthrough(control, VOL_DOWN_OP);
-	if (err < 0)
-		return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
-							strerror(-err));
+static DBusMessage *control_stop(DBusConnection *conn, DBusMessage *msg,
+								void *data)
+{
+        return internal_send_passthrough(conn, msg, data, STOP_OP);
+}
 
-	return dbus_message_new_method_return(msg);
+static DBusMessage *control_pause(DBusConnection *conn, DBusMessage *msg,
+								void *data)
+{
+        return internal_send_passthrough(conn, msg, data, PAUSE_OP);
 }
 
 static DBusMessage *control_get_properties(DBusConnection *conn,
@@ -1097,7 +1102,11 @@ static GDBusMethodTable control_methods[] = {
 	{ "GetProperties",	"",	"a{sv}",control_get_properties },
 	{ "VolumeUp",		"",	"",	volume_up },
 	{ "VolumeDown",		"",	"",	volume_down },
-	{ NULL, NULL, NULL, NULL }
+	{ "Mute",		"",	"",	volume_mute },
+	{ "Play",		"",	"",	control_play },
+	{ "Pause",		"",	"",	control_pause },
+	{ "Stop",		"",	"",	control_stop },
+    { NULL, NULL, NULL, NULL }
 };
 
 static GDBusSignalTable control_signals[] = {
#2 lore raw

Re: Implement AVCTP passthrough commands + iPod Touch

I am currently trying bluez AVRCP on iPod Touch (3G)
It seems, however, that it respond only at the 0x44 OpCode (PASS THROUGH) and performs PLAY correctly. The other codes do not give any action.

Quoted 16 lines · Paolo Medici

Something like that (attached).

Quoted 12 lines · Paolo Medici

Hi,
Are there no contraindications to complete the implementation in
audio/control.c of other commands (as well as VolumeUp/VolumeDown)?
In this case, to try to control my iPod Touch, I would like to add
remaining ones.

Paolo

Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Signature · 7 lines
Paolo Medici - R&D
VisLab srl - P.I. 02516520349
Dipartimento di Ingegneria dell'Informazione
dell'Universita' di Parma - P.I. 00308780345
Via G.P.Usberti 181/A I-43100 Parma ITALY
Tel : +39 0521 90 5792
Web : http://vislab.it/medici