Android中实现系统声音录制(内置声源的录制)-framework调用流程分析
2023-2-28 09:18:43 Author: 哆啦安全(查看原文) 阅读量:17 收藏

推荐阅读

Android Audio音频系统

Android Framework学习路线

Android Audio音频系统之深入浅出

Android10以上系统Audio音频遇到播放视频无声时的分析方法

干货|Android APP应用工程师转Framework工程师(仅此一篇够了)


定制版(绕过检测安全手机)

Android audio设备的定义

1.C++中audio设备的定义

(1).audio设备的定义在Android Froyo-2.2.3及之前是位于

/frameworks/base/include/media/AudioSystem.h

(2).audio设备的定义在Android ICS-4.0.3及之前是位于

/hardware/libhardware_legacy/include/hardware_legacy/AudioSystemLegacy.h

(3).audio设备的定义在Android JellyBean-4.2及之后是位于

/system/core/include/system/audio.h

(4).audio设备的定义在Android Marshmallow-6.0.0_r1及之后是位于

/system/media/audio/include/system/audio.h

(5).audio设备的定义在Android Oreo-8.0.0_r4及之后是位于

/system/media/audio/include/system/audio-base.h/system/media/audio/include/system/audio-base-utils.hhttp://aospxref.com/android-11.0.0_r21/xref/system/media/audio/include/system/audio-base.h
enum {324      AUDIO_DEVICE_NONE                          = 0x0u,325      AUDIO_DEVICE_BIT_IN                        = 0x80000000u,326      AUDIO_DEVICE_BIT_DEFAULT                   = 0x40000000u,327  328      AUDIO_DEVICE_OUT_EARPIECE                  = 0x1u,  //听筒329      AUDIO_DEVICE_OUT_SPEAKER                   = 0x2u,  //扬声器330      AUDIO_DEVICE_OUT_WIRED_HEADSET             = 0x4u,  //线控耳机,可以通过耳机控制远端播放、暂停、音量调节等功能的耳机331      AUDIO_DEVICE_OUT_WIRED_HEADPHONE           = 0x8u,  //普通耳机,只能听,不能操控播放332      AUDIO_DEVICE_OUT_BLUETOOTH_SCO             = 0x10u,  //单声道蓝牙耳机,十进制16333      AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET     = 0x20u,  //车载免提蓝牙设备,十进制32334      AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT      = 0x40u,  //立体声蓝牙耳机,十进制64335      AUDIO_DEVICE_OUT_BLUETOOTH_A2DP            = 0x80u,  //十进制128336      AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100u, //十进制256337      AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER    = 0x200u, //十进制512338      AUDIO_DEVICE_OUT_AUX_DIGITAL               = 0x400u, //十进制1024339      AUDIO_DEVICE_OUT_HDMI                      = 0x400u,      // OUT_AUX_DIGITAL340      AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET         = 0x800u,341      AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET         = 0x1000u,342      AUDIO_DEVICE_OUT_USB_ACCESSORY             = 0x2000u,343      AUDIO_DEVICE_OUT_USB_DEVICE                = 0x4000u,344      AUDIO_DEVICE_OUT_REMOTE_SUBMIX             = 0x8000u,345      AUDIO_DEVICE_OUT_TELEPHONY_TX              = 0x10000u,346      AUDIO_DEVICE_OUT_LINE                      = 0x20000u,347      AUDIO_DEVICE_OUT_HDMI_ARC                  = 0x40000u,348      AUDIO_DEVICE_OUT_SPDIF                     = 0x80000u,349      AUDIO_DEVICE_OUT_FM                        = 0x100000u,350      AUDIO_DEVICE_OUT_AUX_LINE                  = 0x200000u,351      AUDIO_DEVICE_OUT_SPEAKER_SAFE              = 0x400000u,352      AUDIO_DEVICE_OUT_IP                        = 0x800000u,353      AUDIO_DEVICE_OUT_BUS                       = 0x1000000u,354      AUDIO_DEVICE_OUT_PROXY                     = 0x2000000u,355      AUDIO_DEVICE_OUT_USB_HEADSET               = 0x4000000u,356      AUDIO_DEVICE_OUT_HEARING_AID               = 0x8000000u,357      AUDIO_DEVICE_OUT_ECHO_CANCELLER            = 0x10000000u,358      AUDIO_DEVICE_OUT_DEFAULT                   = 0x40000000u, // BIT_DEFAULT359  360      AUDIO_DEVICE_IN_COMMUNICATION              = 0x80000001u, // BIT_IN | 0x1361      AUDIO_DEVICE_IN_AMBIENT                    = 0x80000002u, // BIT_IN | 0x2362      AUDIO_DEVICE_IN_BUILTIN_MIC                = 0x80000004u, // BIT_IN | 0x4363      AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET      = 0x80000008u, // BIT_IN | 0x8364      AUDIO_DEVICE_IN_WIRED_HEADSET              = 0x80000010u, // BIT_IN | 0x10365      AUDIO_DEVICE_IN_AUX_DIGITAL                = 0x80000020u, // BIT_IN | 0x20366      AUDIO_DEVICE_IN_HDMI                       = 0x80000020u, // IN_AUX_DIGITAL367      AUDIO_DEVICE_IN_VOICE_CALL                 = 0x80000040u, // BIT_IN | 0x40368      AUDIO_DEVICE_IN_TELEPHONY_RX               = 0x80000040u, // IN_VOICE_CALL369      AUDIO_DEVICE_IN_BACK_MIC                   = 0x80000080u, // BIT_IN | 0x80370      AUDIO_DEVICE_IN_REMOTE_SUBMIX              = 0x80000100u, // BIT_IN | 0x100371      AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET          = 0x80000200u, // BIT_IN | 0x200372      AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET          = 0x80000400u, // BIT_IN | 0x400373      AUDIO_DEVICE_IN_USB_ACCESSORY              = 0x80000800u, // BIT_IN | 0x800374      AUDIO_DEVICE_IN_USB_DEVICE                 = 0x80001000u, // BIT_IN | 0x1000375      AUDIO_DEVICE_IN_FM_TUNER                   = 0x80002000u, // BIT_IN | 0x2000376      AUDIO_DEVICE_IN_TV_TUNER                   = 0x80004000u, // BIT_IN | 0x4000377      AUDIO_DEVICE_IN_LINE                       = 0x80008000u, // BIT_IN | 0x8000378      AUDIO_DEVICE_IN_SPDIF                      = 0x80010000u, // BIT_IN | 0x10000379      AUDIO_DEVICE_IN_BLUETOOTH_A2DP             = 0x80020000u, // BIT_IN | 0x20000380      AUDIO_DEVICE_IN_LOOPBACK                   = 0x80040000u, // BIT_IN | 0x40000381      AUDIO_DEVICE_IN_IP                         = 0x80080000u, // BIT_IN | 0x80000382      AUDIO_DEVICE_IN_BUS                        = 0x80100000u, // BIT_IN | 0x100000383      AUDIO_DEVICE_IN_PROXY                      = 0x81000000u, // BIT_IN | 0x1000000384      AUDIO_DEVICE_IN_USB_HEADSET                = 0x82000000u, // BIT_IN | 0x2000000385      AUDIO_DEVICE_IN_BLUETOOTH_BLE              = 0x84000000u, // BIT_IN | 0x4000000386      AUDIO_DEVICE_IN_HDMI_ARC                   = 0x88000000u, // BIT_IN | 0x8000000387      AUDIO_DEVICE_IN_ECHO_REFERENCE             = 0x90000000u, // BIT_IN | 0x10000000388      AUDIO_DEVICE_IN_DEFAULT                    = 0xC0000000u, // BIT_IN | BIT_DEFAULT389  };

(6).audio设备的定义在Android 12.0.0_r3及之后是位于

/system/media/audio/include/system/audio-hal-enums.h/system/media/audio/include/system/audio-base-utils.hhttp://aospxref.com/android-12.0.0_r3/xref/system/media/audio/include/system/

2.Java中aduio设备的定义

audio设备的定义/frameworks/base/media/java/android/media/AudioManager.java/frameworks/base/media/java/android/media/AudioSystem.java

3.Android中实现系统声音录制(内置声源的录制方案)

Android中可以通过使用MediaRecorder.AudioSource.REMOTE_SUBMIX来实现系统声音的录制,这个属性只有系统应用能够使用;而且这个属性会截掉耳机和扬声器的声音,听不到Android设备中播放音乐或者视频时的声音;需要通过修改Android系统源码来解决!


文章来源: http://mp.weixin.qq.com/s?__biz=Mzg2NzUzNzk1Mw==&mid=2247495225&idx=2&sn=9a420b2e5cf78fdedf0945fe1487662f&chksm=ceb8ab77f9cf2261133903a8bca860a9b32048f44874b7b9e48722754f96c94e3205e2c38e7e#rd
如有侵权请联系:admin#unsafe.sh