安卓>4.0:想法如何记录/捕获内部音频(例如 STREAM_MUSIC)? [英] Android > 4.0 : Ideas how to record/capture internal audio (e.g. STREAM_MUSIC)?

查看:30
本文介绍了安卓>4.0:想法如何记录/捕获内部音频(例如 STREAM_MUSIC)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几个月前,使用 Android ICS (4.0),我开发了一个 android 内核模块,它拦截了pcmC0D0p"模块以获取所有系统音频.

Some months ago, with Android ICS (4.0), I developed an android kernel module which intercepted the "pcmC0D0p"-module to fetch all system audio.

我的目标是通过 AirPlay 将所有音频(或至少播放的音乐)流式传输到远程扬声器.

My target is to stream ALL audio (or at least the played music) to a remote speaker via AirPlay.

内核模块工作正常,但有几个问题(内核版本、root 权限等)所以我停止了这个工作.

The kernel module worked, but there where several problems (kernel-versions, root-privileges etc.) so I stopped working on this.

现在,我们有了 Android 4.1 和 4.2,我有了新的希望!

Now, we have Android 4.1 and 4.2 and I have new hope!

谁知道如何在 Android 中捕获音频?

Who has an idea how to capture the audio in Android?

我有以下想法:

  1. 通过蓝牙连接同一部手机,将路由设置为 BT 并在另一端"获取音频:这不应该工作

  1. Connect via bluetooth to the same phone, set routing to BT and grab the audio on the "other end": this shouldn't work

像以前那样用内核模块拦截音频:硬核,让它工作但不适用

Intercept the audio with a kernel module like done before: hardcore, get it worked but not applicable

JACK 音频连接套件:遗憾的是,Android 使用tinyALSA"而不是ALSA".TinyALSA 不支持像 JACK 这样的任何过滤器(但这带来了内核模块的想法)

JACK Audio Connection Kit: sadly Android uses "tinyALSA" and not "ALSA". TinyALSA does NOT support any filters like JACK (but this brought the idea with the kernel module)

使用PulseAudio代替AudioFlinger,但这也不适用

Use PulseAudio as a replacement for AudioFlinger, but this is also not applicable

<小时>

编辑(忘记了):


EDIT (forgot them):

  1. 我从 tinyALSA 编译了tinymix"(ALSA 混合器的婴儿版)(Android 上的 ALSA)并尝试将音频输出路由到麦克风输入 - 但没有成功(我无法理解).而且这也需要root:不适用

  1. I compiled "tinymix" (baby-version of ALSA-mixer) from tinyALSA (the ALSA on Android) and tried to route the audio-out to mic-in - but with no success (not understandable for me). And this also needs rooting: not applicable

我测试了 OpenSL ES,但我不是 C-crack 和它以我可以录制麦克风,但不能再录制"结尾(也许我错了?)

I tested OpenSL ES, but I'm not a C-crack and it ended in "I can record microphone, but no more" (maybe I was wrong?)

<小时>

我刚刚找到了 ROUTE_TYPE_LIVE_AUDIO:

支持实时音频路由的设备将允许媒体音频流被路由到支持的目的地.这可以包括设备本身的内部扬声器或音频插孔、A2DP 设备、以及更多.

A device that supports live audio routing will allow the media audio stream to be routed to supported destinations. This can include internal speakers or audio jacks on the device itself, A2DP devices, and more.

一旦启动,此路由对应用程序是透明的.全部在媒体流上播放的音频将被路由到选定的目的地.

Once initiated this routing is transparent to the application. All audio played on the media stream will be routed to the selected destination.

也许这有任何帮助?

我的想法不多了,但想破解这个难题",也许有人可以帮助我?

I'm running out of ideas but want to "crack this nut", maybe someone can help me?

我是 C & 的新手内核编码(但我成功创建了一个交叉编译的音频拦截模块)-但是在 PCM 数据从用户空间(JAVA,C 层?)到内核空间(tinyALSA,内核模块),无需黑客攻击生根?

I'm really new in C & kernel-coding (but I successfully created a cross-compiled audio-interception-module) - but isn't it in any way possible to listen at the point the PCM-data goes from userspace (JAVA, C-layer?) to the kernel-space (tinyALSA, kernel-module), without hacking & rooting?

推荐答案

您必须通过本地套接字服务器传递音频流量:

You must pass audio traffic through your local socket server:

  1. 创建本地套接字服务器

  1. Create local socket server

将音频 http 流地址修改为通过本地套接字服务器的路径,例如地址

Modify audio http stream address to path is thru your local socket server, for example for address

http://example.com/stream.mp3  ->

http://127.0.0.1:8888/http://example.com/stream.mp3

其中 8888 是您的套接字端口.

where 8888 is your socket port.

播放

http://127.0.0.1:8888/http://example.com/stream.mp3 

使用默认媒体播放器

在您的本地套接字服务器中读取到端口 8888 的所有传入请求,对其进行分析并传递给 example.com 服务器.

Read all incoming requests to port 8888 in your local socket server, analyze it and pass to example.com server.

从 example.com 读取响应并将其传递给本地客户端(媒体播放器).在这里您可以捕获音频流!

Read response from example.com and pass it to local client (media player). HERE you can capture audio stream!

这篇关于安卓&gt;4.0:想法如何记录/捕获内部音频(例如 STREAM_MUSIC)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆