2008-10-14 04:36:15

by rakesh agarwal

[permalink] [raw]
Subject: [Bluez-devel] audio service

Hi all,
I was trying to write simple program for a2dp in C language. This is the
program that I m trying to run......



#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <glib.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
#include <dbus/dbus-glib-bindings.h>

#include <bluetooth/bluetooth.h>

#include "marshal.h"
#include "marshal.c"


GMainLoop *loop;

static void
session_created ()
{
g_message ("a2dp device created");
}

static void
session_removed (DBusGProxy *proxy, const char *session_object, gpointer
user_data)
{
g_message ("playing");

}


int
main ()
{


char* address = "00:19:63:EF:83:17";

DBusGConnection *dbus_connection;
DBusGProxy *dbus_proxy;
GError *error = NULL;
int ret;
char *id;
gchar *object_path = NULL;

g_type_init ();
id = (char*) g_malloc0(50);
dbus_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
if (error) {
g_warning ("%s", error->message);
g_clear_error (&error);
}
error = NULL;

dbus_proxy = dbus_g_proxy_new_for_name (dbus_connection, "org.bluez",
"/org/bluez", "org.bluez.Manager");
dbus_g_object_register_marshaller (marshal_STRING__STRING,
G_TYPE_NONE,
G_TYPE_STRING,
G_TYPE_STRING);

dbus_g_proxy_call (dbus_proxy,
"ActivateService",&error,G_TYPE_STRING,"audio",G_TYPE_INVALID,G_TYPE_STRING,id,G_TYPE_INVALID);
if(error != NULL){
g_print("ERROR : %s",error->message);
//exit(0);
}
else
g_print("id = %s",id);

error = NULL;

dbus_proxy = dbus_g_proxy_new_for_name (dbus_connection,id,
"/org/bluez/audio",
"org.bluez.audio.Manager");

ret = dbus_g_proxy_call (dbus_proxy, "CreateDevice", &error,
G_TYPE_STRING, address,
G_TYPE_INVALID,
DBUS_TYPE_G_OBJECT_PATH, &object_path,
G_TYPE_INVALID);
if (!ret) {
g_warning ("Error1: %s", error->message);
g_clear_error (&error);
return FALSE;
} else
g_message ("Object path: %s", object_path);

dbus_proxy = dbus_g_proxy_new_for_name (dbus_connection,
"org.bluez",
object_path,
"org.bluez.audio.Sink");

dbus_g_proxy_add_signal (dbus_proxy, "Connected", G_TYPE_INVALID,
G_TYPE_INVALID);
dbus_g_proxy_connect_signal (dbus_proxy, "Connected", G_CALLBACK
(session_created),
NULL, NULL);

dbus_g_proxy_add_signal (dbus_proxy, "Playing", G_TYPE_INVALID,
G_TYPE_INVALID);
dbus_g_proxy_connect_signal (dbus_proxy, "Playing", G_CALLBACK
(session_removed),
NULL, NULL);


dbus_g_proxy_call (dbus_proxy, "Connect", &error,
G_TYPE_INVALID,
G_TYPE_INVALID);
dbus_g_proxy_call (dbus_proxy, "Play", &error,
G_TYPE_INVALID,
G_TYPE_INVALID);

loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (loop);


return 0;
}


But getting these error message while running........

[Invalid UTF-8] id = \xb0\xe1\x04\x08
** (process:6157): WARNING **: Error1: Method "CreateDevice" with signature
"s" on interface "org.bluez.audio.Manager" doesn't exist


PLz help me out......

Thanks in advance.....

Rakesh


Attachments:
(No filename) (3.46 kB)
(No filename) (7.21 kB)
(No filename) (363.00 B)
(No filename) (164.00 B)
Download all attachments

2008-10-15 12:58:28

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [Bluez-devel] audio service

What version are you using? It seems correct for BlueZ 3.x series but
it wont work if you are using 4.x. You can try using d-feet and
explore the interfaces to get familiar to how it work.

-- =

Luiz Augusto von Dentz
Engenheiro de Computa=E7=E3o

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great priz=
es
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=3D100&url=3D/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel