播放歌曲到蓝牙耳机--A2DP

===代码请参考btsco中的a2play.c===

基本流程如下:
    1.init sbc
    2.open audio file
        /dev/dsp
        /dev/audio
        snd format file
    3.read[call read()] and encode to sbc[call sbc_encode()]
    4.Detect whether support A2DP Sink by create and connect SDP Session[call detect_a2dp()]
    5.create "cmd_socket"
        (1)call socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP) to create "cmd_socket"
        (2)call bind() to local
        (3)call connect() to remote
        (4)call getsockopt(SOL_L2CAP, L2CAP_OPTIONS) to get MTU
    6.call write(cmd_socket, AVDTP_DISCOVER) to get SEIDs
    7.do follow things to each SEID until success
        (1)call write(cmd_socket, AVDTP_GET_CAPABILITIES) to get Capability of SEID
        (2)call write(cmd_socket, AVDTP_SET_CONFIGURATION) to set Configure of SEID
        (3)call write(cmd_socket, AVDTP_OPEN) to open stream
    8.create "stream_socket"
        (1)call socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP) to create "stream_socket"
        (2)call bind() to local
        (3)call connect() to remote
        (4)call getsockopt(SOL_L2CAP, L2CAP_OPTIONS) to get MTU
    9.call write(cmd_socket, AVDTP_START) to start stream
    10.send AudioContent to stream_socket
        (1)read[call read()] and encode to sbc[call sbc_encode()]
        (2)call write(stream_socket) to sink
    11.call close() to close audio file
    12.call write(cmd_socket, AVDTP_CLOSE) to close stream
    13.call close() to close stream_socket
    14.call close() to close cmd_socket

意见反馈:
    1.输入的声音文件是snd编码格式的
    2.实现过程与ipctest.c基本相同
    3.运行之前,处于断开状态
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值