Bluetooth BlueZ analysis and use under Linux (1)

Source: Internet
Author: User
Tags gstreamer

Use of Bluetooth headset

Because Bluetooth is less intuitive than Windows under Linux, there are some minor problems with using it. Although it is a small problem, but because ordinary operations are sequential, the front of the interruption, the back of even simple, can not continue. Just recently work with Bluetooth and the network are related, you can have time and goals to learn a bit. Gossip less, get to the point.
I use Fedora 9, the BlueZ version is

|--bluez-gnome-0.26-1.fc9.i386.rpm
|--bluez-gnome-analyzer-0.26-1.fc9.i386.rpm
|--bluez-gnome-debuginfo-0.26-1.fc9.i386.rpm


Let's talk about the use of Bluetooth headphones:
Turn on the headset so it can be found (company's Motorola headset: Open and long-press until the blue light gradually brightens and does not blink), used on the computer:

[thinkpad]~$ hcitool Scan
Scanning ...
00:07:A4:F3:09:3C Motorola HT820
[thinkpad]~$

You can see that the device has been scanned. Note that the Bluetooth service on the computer is to be opened.
We will record its address: 00:07:a4:f3:09:3c
Go to home directory:

[thinkpad]~$ Cat. ASOUNDRC
Pcm.bluetooth {
Type Bluetooth
Device 00:07:a4:f3:09:3c
}

Create the ALSA configuration file in the format above.
The next thing we do is pair it with the headset (why do we pair it, what exactly does it do, actually build the Bluetooth physical link ACL (asynchronous connectionless), and the other link is SCO (synchronous Connection oriented) is mainly used for transmitting data communication with high time requirements. )。
Right-click on the Bluetooth icon on the status bar (blue, with a scissor pattern), select Browse Device, and make the headset in a state that can be found.
Select headset, connect, enter 0000 (the default PIN Personal information number) in the popup dialog so that the headset is paired with the computer successfully. What's likely to pop up is what host is down, that's okay, because after clicking the connection, the corresponding message handler executes the command Nautilus--no-default-window "Obex://[xx:xx:xx:xx" after the message is reported.
And here we start playing.
First use the mplayer that you are most familiar with.

[thinkpad]/work$ Mplayer-ao Alsa:device=bluetooth Mp3.mp3

So that we can hear the beautiful music through the headphones. OK, let's listen to the music, talk about other players how to use the Bluetooth headset.
GStreamer is also a very well known player in open source software:

[thinkpad]/work$ gst-launch filesrc Location=mp3.mp3! Decodebin! Alsasink Device=bluetooth Sync=false

You can also compile the bluez-utils-3.32 by yourself, please note that add a parameter--enable-gstreamer, so that after compiling there will be a libgstbluetooth.so GStreamer plug-in, put it into/usr/lib Under the/gstreamer directory

Gst-launch filesrc Location=mp3.mp3! Decodebin! Audioconvert! Audioresample! Sbcenc! A2dpsink device=00:07:a4:f3:09:3c

This can also be heard, this is the very famous A2DP Bluetooth (Advance Audio distribution profile), if you have a deeper interest, you can look at the GST on the A2dpsink and Sbcenc parameters of the adjustment, hehe.
Let's see how totem this Linux default installed player uses Bluetooth:

[thinkpad]~$ gconftool-2-T string-s/system/gstreamer/0.10/default/musicaudiosink "Sbcenc! A2dpsink device=00:07:a4:f3:09:3c "

This actually modifies the musicaudiosink in the ~/.gconf/system/gstreamer/0.10/default/%gconf.xml. There must be libgstbluetooth.so here, or

[thinkpad]~$ gconftool-2-T string-s/system/gstreamer/0.10/default/musicaudiosink "Alsasink device=bluetooth"

When no longer used,

[thinkpad]~$ gconftool-2-T string-s/system/gstreamer/0.10/default/musicaudiosink "Autoaudiosink"

There is a small regret that the "forward" and "back" buttons are not available on the headset.

Many of the above are from:
Http://wiki.bluez.org/wiki/HOWTO/AudioDevices
Interested friends can have a look.

Bluetooth BlueZ analysis and use under Linux (1)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.