SlideShare a Scribd company logo
1
Android's Multimedia
Framework
September 2014
Karim Yaghmour
@karimyaghmour
karim.yaghmour@opersys.com
2
These slides are made available to you under a Creative Commons Share-
Alike 3.0 license. The full terms of this license are here:
https://creativecommons.org/licenses/by-sa/3.0/
Attribution requirements and misc., PLEASE READ:
● This slide must remain as-is in this specific location (slide #2), everything
else you are free to change; including the logo :-)
● Use of figures in other documents must feature the below “Originals at”
URL immediately under that figure and the below copyright notice where
appropriate.
● You are free to fill in the “Delivered and/or customized by” space on the
right as you see fit.
● You are FORBIDEN from using the default “About” slide as-is or any of its
contents.
●
You are FORBIDEN from using any content provided by 3rd
parties without
the EXPLICIT consent from those parties.
(C) Copyright 2013-2014, Opersys inc.
These slides created by: Karim Yaghmour
Originals at: www.opersys.com/community/docs
Delivered and/or customized by
3
About
● Author of:
● Introduced Linux Trace Toolkit in 1999
● Originated Adeos and relayfs (kernel/relay.c)
● Training, Custom Dev, Consulting, ...
4
Agenda
● Architecture Basics
● Display Core
● Multimedia Architecture
● App Dev Model
● Kernel Drivers
● HAL definitions
● HAL modules
● System Services
● Stagefright
● Walkthrough
● Relevant Apps
● References and Pointers
5
1. Architecture Basics
● Hardware used to run Android
● AOSP
● Binder
● System Services
● HAL
6
7
8
9
10
11
/frameworks/base/services/java/...
/frameworks/base/services/jni/
/hardware/libhardware/
/device/[MANUF.]/[DEVICE]
/sdk/emulator/
Kernel or module
/frameworks/base/core/...
AOSP-provided
ASL
Manuf.-provided
Manuf. license
Manuf.-provided
GPL-license
12
2. Display Core
● Display Hardware
● Display stack in Android
● Kernel driver
● HAL definition
● HAL module
● Surface Flinger
● Window Manager
13
2.1. Display Hardware
MMU
IOMMU
14
2.2. Display stack in Android
15
16
From source.android.com - CC-BY 2.5
17
From source.android.com - CC-BY 2.5
18
2.3. Kernel driver
●
Video memory management
●
Mode setting
● Checking of parameters
● Motorola Xoom:
●
/dev/nvhdcp1
● /dev/nvhost-ctrl
● /dev/nvhost-display
● /dev/nvhost-dsi
●
/dev/nvhost-gr2d
● /dev/nvhost-gr3d
●
/dev/nvhost-isp
●
/dev/nvhost-mpe
● /dev/nvhost-vi
● /dev/nvmap
● /dev/tegra-crypto
●
/dev/tegra_avp
●
/dev/tegra_camera
●
/dev/tegra_fuse
● /dev/tegra_rpc
● /dev/tegra_sema
● ... whatever hides in hwcomposer HAL module
19
2.3. HAL Definition
● /hardware/libhardware/include/hardware/hwcomposer.h
● struct hwc_procs:
● invalidate()
● vsync()
● struct hwc_composer_device:
● prepare()
● set()
● dump()
● registerProcs()
● query()
● *()
20
2.5. HAL module
● Skeleton /hardware/libhardware/modules/hwcomposer.cpp
● /system/lib/hw/hwcomposer.BOARD.so
● /system/lib/hw/gralloc.BOARD.so
● Ex. - Mot Xoom:
● hwcomposer.tegra.so
● gralloc.tegra.so
● Surface Flinger hook:
● /frameworks/native/services/surfaceflinger/DisplayHardware
– HWComposer.cpp
– Provides fake vsync if none is provided in HW
21
2.6. Surface Flinger
● Actual server:
● /frameworks/native/services/surfaceflinger
● Client side:
● /frameworks/native/libs/gui
● Client / Server interface:
● ISurfaceComposerClient.cpp
● ISurfaceComposer.cpp
● This is NOT an aidl'ed service
● All communication is manually
marshalled/unmarshalled
22
2.7. Window Manager
● Server side:
● /frameworks/base/services/java/com/android/server/wm/
– WindowManagerService.java
– Session.java
● Client side:
● /frameworks/base/core/java/android/view/
– WindowManager.java
– WindowManagerImpl.java
– ViewRootImpl.java
● Interfaces:
● IWindowManager.aidl
● IWindowSession.aidl
● Parameters (incl. z-order):
● See WindowManager.java
23
3. Multimedia Architecture
● OpenMAX
● Media Playback
● Audio
● Camera
24
3.1. OpenMAX
From Khronos website
25
3.2. Media Playback
From source.android.com - CC-BY 2.5
26
3.3. Audio
From source.android.com - CC-BY 2.5
27
3.4. Camera
From source.android.com - CC-BY 2.5
28
From source.android.com - CC-BY 2.5
29
From source.android.com - CC-BY 2.5
30
4. App Dev Model
● Media Playback
● Audio Record
● Camera
31
4.1. Media Playback
● developer.android.com sample:
Uri myUri = ....; // initialize Uri here
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource(getApplicationContext(), myUri);
mediaPlayer.prepare();
mediaPlayer.start();
32
From developer.android.com - ASL
33
4.2. Audio Record
● developer.android.com steps:
● Create a new instance of android.media.MediaRecorder.
● Set the audio source using MediaRecorder.setAudioSource(). You will probably
want to use MediaRecorder.AudioSource.MIC.
● Set output file format using MediaRecorder.setOutputFormat().
● Set output file name using MediaRecorder.setOutputFile().
● Set the audio encoder using MediaRecorder.setAudioEncoder().
● Call MediaRecorder.prepare() on the MediaRecorder instance.
● To start audio capture, call MediaRecorder.start().
● To stop audio capture, call MediaRecorder.stop().
● When you are done with the MediaRecorder instance, call
MediaRecorder.release() on it. Calling MediaRecorder.release() is always
recommended to free the resource immediately.
34
From developer.android.com - ASL
35
5. Kernel drivers
● Possibly V4Linux
● Possibly ALSA
● ... whatever hides in multimedia HAL modules
36
6. HAL Definition
● /hardware/libhardware/include/hardware/:
● audio_effect.h
● audio.h
● audio_policy.h
● camera.h
● camera2.h
● camera3.h
● camera_common.h
37
7. HAL module
● Audio skeletons in /hardware/libhardware/modules/audio
● USB audio in /hardware/libhardware/modules/usbaudio
● Default implementation in /hardware/libhardware/modules/camera
● /system/lib/hw/:
● audio.a2dp.default.so
● audio_policy.default.so
● audio_policy.mpq8064.so
● audio_policy.msm8960.so
● audio.primary.default.so
● audio.primary.mpq8064.so
● audio.primary.msm8960.so
● audio.usb.default.so
● camera.msm8960.so
38
8. System Services
● Player
● Audio Flinger
● Audio Policy
● Camera
39
8.1. Player
● Actual server:
● frameworks/av/media/libmediaplayerservice
● Client side:
● frameworks/av/media/libmedia
● Client / Server interface:
● IMediaPlayerClient.cpp
● IMediaPlayer.cpp
● IMediaPlayerService.cpp
● IMediaRecorderClient.cpp
● IMediaRecorder.cpp
40
8.2. Audio Flinger
● Actual Server:
● frameworks/av/services/audioflinger
● Client side:
● frameworks/av/media/libmedia
● Client / Server interface:
● IAudioFlingerClient.cpp
● IAudioFlinger.cpp
● IAudioRecord.cpp
● iAudioTrack.cpp
41
8.3. Audio Policy
● Actual Server:
● frameworks/av/services/audioflinger
● Client side:
● frameworks/av/media/libmedia
● Client / Server interface:
● IAudioPolicyService.cpp
42
8.4. Camera
●
Actual Server:
● frameworks/av/services/camera/libcameraservice
● Client Side:
● frameworks/av/camera
● Client / Server interface:
● ICameraClient.cpp
● ICamera.cpp
● ICameraRecordingProxy.cpp
● ICameraRecordingProxyListener.cpp
● ICameraService.cpp
● ICameraServiceListener.cpp
● IProCameraCallbacks.cpp
● IProCameraUser.cpp
43
8.5. Wrapper process
● All media system services run within
“mediaserver” system process.
● Started by init
● Sources:
● frameworks/av/media/mediaserver
44
9. Stagefright
● Multimedia framework
● Houses AwesomePlayer
● Location:
● frameworks/av/media/libstagefright
● Support loadable HW codecs:
● libstagefrighthw.so
45
10. Walkthrough
46
10. Relevant Apps
● Music
● MusicFX
● Gallery2
● SpeechRecorder
● VideoEditor
47
11. References and Pointers
● Google's “official” doumentation:
source.android.com/devices/media.html
source.android.com/devices/audio.html
source.android.com/devices/camera/camera.html
● “Use the source, Luke”
●
Developer doc:
● https://developer.android.com/guide/topics/media/mediaplayer.html
● https://developer.android.com/reference/android/media/MediaPlayer.html
● https://developer.android.com/guide/topics/media/audio-capture.html
● “Android Multimedia Framework”, picker - slideshare
●
“The Android media framework”, Bert Van Dam & Poornachandra Kallare, Android Builders Summit
2014
●
“Android’s Stagefright Media Player Architecture”, Ivo Krka,
http://quandarypeak.com/2013/08/androids-stagefright-media-player-architecture/
●
“Mastering the Android Media Framework”, Google I/O 2009
● https://www.khronos.org/openmax/
48
Thank you ...
karim.yaghmour@opersys.com
49
Acknowledgements:
● Some figures and snippets taken from Google's
Android documentation at
developer.android.com and source.android.com
distributed under the Apache 2.0 license and/or
CC-BY-SA 2.5.

More Related Content

PDF
Android Multimedia Framework
PDF
Android's HIDL: Treble in the HAL
PDF
Android Things : Building Embedded Devices
PDF
Embedded Android : System Development - Part III (Audio / Video HAL)
PDF
PDF
Embedded Android : System Development - Part I
PDF
Embedded Android : System Development - Part II (Linux device drivers)
PDF
Design and Concepts of Android Graphics
Android Multimedia Framework
Android's HIDL: Treble in the HAL
Android Things : Building Embedded Devices
Embedded Android : System Development - Part III (Audio / Video HAL)
Embedded Android : System Development - Part I
Embedded Android : System Development - Part II (Linux device drivers)
Design and Concepts of Android Graphics

What's hot (20)

PDF
Embedded Android : System Development - Part II (HAL)
PPT
Android Audio System
PDF
Embedded Android : System Development - Part IV
PDF
Android media framework overview
PDF
Embedded Android Workshop with Pie
PDF
PPT
Learning AOSP - Android Booting Process
PPTX
Android Booting Sequence
PDF
Android Internals at Linaro Connect Asia 2013
PDF
Android Storage - Vold
PPT
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
PDF
Android Boot Time Optimization
PDF
Jagan Teki - U-boot from scratch
PDF
Understanding the Android System Server
PPTX
Android audio system(audioflinger)
ODP
Embedded Android : System Development - Part III
PDF
Multimedia on android
ODP
Q4.11: Porting Android to new Platforms
 
PDF
Project meeting: Android Graphics Architecture Overview
PDF
Embedded Android : System Development - Part IV (Android System Services)
Embedded Android : System Development - Part II (HAL)
Android Audio System
Embedded Android : System Development - Part IV
Android media framework overview
Embedded Android Workshop with Pie
Learning AOSP - Android Booting Process
Android Booting Sequence
Android Internals at Linaro Connect Asia 2013
Android Storage - Vold
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
Android Boot Time Optimization
Jagan Teki - U-boot from scratch
Understanding the Android System Server
Android audio system(audioflinger)
Embedded Android : System Development - Part III
Multimedia on android
Q4.11: Porting Android to new Platforms
 
Project meeting: Android Graphics Architecture Overview
Embedded Android : System Development - Part IV (Android System Services)
Ad

Viewers also liked (20)

PPTX
Android audio system(audioplicy_service)
PPTX
Android audio system(audio_hardwareinterace)
PPT
Android Audio & OpenSL
PDF
How security broken? - Android internals and malware infection possibilities
PDF
The unconventional devices for the Android video streaming
PDF
HH QUALCOMM ‘hear’ & now qualcomm¼ snapdragonℱ audio
PPT
Unit vi
PPTX
Android audio system(였디였 출렄-튞랙활성화)
PPTX
Android Training (Media)
PDF
Video Streaming: from the native Android player to uncoventional devices
PPT
Android cameraoverview
PDF
Investigation report on 64 bit support in Android Open Source Project
PDF
Design Document Final for HELP application
PDF
Using the Android Native Development Kit (NDK)
PDF
Embedded Android Real-Time Streaming Optimization
PDF
Second-Screen Support in Android 4.2
PDF
Logging system of Android
PDF
Secondary Screen Support Using DisplayManager
PPTX
Surface flingerservice(서플슀플링거서ëč„슀쎈Ʞ화 ics)
Android audio system(audioplicy_service)
Android audio system(audio_hardwareinterace)
Android Audio & OpenSL
How security broken? - Android internals and malware infection possibilities
The unconventional devices for the Android video streaming
HH QUALCOMM ‘hear’ & now qualcomm¼ snapdragonℱ audio
Unit vi
Android audio system(였디였 출렄-튞랙활성화)
Android Training (Media)
Video Streaming: from the native Android player to uncoventional devices
Android cameraoverview
Investigation report on 64 bit support in Android Open Source Project
Design Document Final for HELP application
Using the Android Native Development Kit (NDK)
Embedded Android Real-Time Streaming Optimization
Second-Screen Support in Android 4.2
Logging system of Android
Secondary Screen Support Using DisplayManager
Surface flingerservice(서플슀플링거서ëč„슀쎈Ʞ화 ics)
Ad

Similar to Android's Multimedia Framework (20)

PDF
Inside Android's UI at AnDevCon IV
PDF
Inside Android's UI at AnDevCon VI
PDF
Inside Android's UI at AnDevCon V
PDF
Customizing Android's UI
PDF
Inside Android's UI / ABS 2013
PDF
Customizing Android's UI
PDF
Customizing Android's UI
PDF
Android Platform Debugging and Development
PDF
Android Platform Debugging and Development
PDF
Inside Android's UI
PDF
Android Platform Debugging and Development
PDF
Android Platform Debugging and Development
PDF
Android Platform Debugging and Development
PDF
Android Platform Debugging and Development
PDF
Android Platform Debugging and Development
PDF
Android Platform Debugging and Development
PDF
Security Issues in Android Custom Rom
PDF
Security Issues in Android Custom ROM
PDF
Embedded Android Workshop part I ESC SV 2012
PDF
Android Platform Debugging and Development
Inside Android's UI at AnDevCon IV
Inside Android's UI at AnDevCon VI
Inside Android's UI at AnDevCon V
Customizing Android's UI
Inside Android's UI / ABS 2013
Customizing Android's UI
Customizing Android's UI
Android Platform Debugging and Development
Android Platform Debugging and Development
Inside Android's UI
Android Platform Debugging and Development
Android Platform Debugging and Development
Android Platform Debugging and Development
Android Platform Debugging and Development
Android Platform Debugging and Development
Android Platform Debugging and Development
Security Issues in Android Custom Rom
Security Issues in Android Custom ROM
Embedded Android Workshop part I ESC SV 2012
Android Platform Debugging and Development

More from Opersys inc. (20)

PDF
Android Automotive
PDF
Android 10 Internals Update
PDF
Android Security Internals
PDF
Android Treble: Blessing or Trouble?
PDF
Embedded Android Workshop with Oreo
PDF
Scheduling in Android
PDF
Android Things Internals
PDF
Embedded Android Workshop with Nougat
PDF
Embedded Android Workshop with Nougat
PDF
Android Things: Android for IoT
PDF
Android Things Internals
PDF
Scheduling in Android
PDF
Brillo / Weave Internals
PDF
Memory Management in Android
PDF
Embedded Android Workshop with Nougat
PDF
Brillo / Weave Internals
PDF
Project Ara
PDF
Memory Management in Android
PDF
Brillo/Weave Internals
PDF
Embedded Android Workshop with Marshmallow
Android Automotive
Android 10 Internals Update
Android Security Internals
Android Treble: Blessing or Trouble?
Embedded Android Workshop with Oreo
Scheduling in Android
Android Things Internals
Embedded Android Workshop with Nougat
Embedded Android Workshop with Nougat
Android Things: Android for IoT
Android Things Internals
Scheduling in Android
Brillo / Weave Internals
Memory Management in Android
Embedded Android Workshop with Nougat
Brillo / Weave Internals
Project Ara
Memory Management in Android
Brillo/Weave Internals
Embedded Android Workshop with Marshmallow

Recently uploaded (20)

PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PPTX
L1 - Introduction to python Backend.pptx
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
top salesforce developer skills in 2025.pdf
PPTX
Transform Your Business with a Software ERP System
PPTX
Introduction to Artificial Intelligence
PDF
AI in Product Development-omnex systems
PPTX
history of c programming in notes for students .pptx
PPT
Introduction Database Management System for Course Database
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Nekopoi APK 2025 free lastest update
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
How to Choose the Right IT Partner for Your Business in Malaysia
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
L1 - Introduction to python Backend.pptx
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Wondershare Filmora 15 Crack With Activation Key [2025
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
top salesforce developer skills in 2025.pdf
Transform Your Business with a Software ERP System
Introduction to Artificial Intelligence
AI in Product Development-omnex systems
history of c programming in notes for students .pptx
Introduction Database Management System for Course Database
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Nekopoi APK 2025 free lastest update
VVF-Customer-Presentation2025-Ver1.9.pptx
PTS Company Brochure 2025 (1).pdf.......
How Creative Agencies Leverage Project Management Software.pdf
Which alternative to Crystal Reports is best for small or large businesses.pdf

Android's Multimedia Framework

  • 1. 1 Android's Multimedia Framework September 2014 Karim Yaghmour @karimyaghmour karim.yaghmour@opersys.com
  • 2. 2 These slides are made available to you under a Creative Commons Share- Alike 3.0 license. The full terms of this license are here: https://creativecommons.org/licenses/by-sa/3.0/ Attribution requirements and misc., PLEASE READ: ● This slide must remain as-is in this specific location (slide #2), everything else you are free to change; including the logo :-) ● Use of figures in other documents must feature the below “Originals at” URL immediately under that figure and the below copyright notice where appropriate. ● You are free to fill in the “Delivered and/or customized by” space on the right as you see fit. ● You are FORBIDEN from using the default “About” slide as-is or any of its contents. ● You are FORBIDEN from using any content provided by 3rd parties without the EXPLICIT consent from those parties. (C) Copyright 2013-2014, Opersys inc. These slides created by: Karim Yaghmour Originals at: www.opersys.com/community/docs Delivered and/or customized by
  • 3. 3 About ● Author of: ● Introduced Linux Trace Toolkit in 1999 ● Originated Adeos and relayfs (kernel/relay.c) ● Training, Custom Dev, Consulting, ...
  • 4. 4 Agenda ● Architecture Basics ● Display Core ● Multimedia Architecture ● App Dev Model ● Kernel Drivers ● HAL definitions ● HAL modules ● System Services ● Stagefright ● Walkthrough ● Relevant Apps ● References and Pointers
  • 5. 5 1. Architecture Basics ● Hardware used to run Android ● AOSP ● Binder ● System Services ● HAL
  • 6. 6
  • 7. 7
  • 8. 8
  • 9. 9
  • 10. 10
  • 12. 12 2. Display Core ● Display Hardware ● Display stack in Android ● Kernel driver ● HAL definition ● HAL module ● Surface Flinger ● Window Manager
  • 14. 14 2.2. Display stack in Android
  • 15. 15
  • 18. 18 2.3. Kernel driver ● Video memory management ● Mode setting ● Checking of parameters ● Motorola Xoom: ● /dev/nvhdcp1 ● /dev/nvhost-ctrl ● /dev/nvhost-display ● /dev/nvhost-dsi ● /dev/nvhost-gr2d ● /dev/nvhost-gr3d ● /dev/nvhost-isp ● /dev/nvhost-mpe ● /dev/nvhost-vi ● /dev/nvmap ● /dev/tegra-crypto ● /dev/tegra_avp ● /dev/tegra_camera ● /dev/tegra_fuse ● /dev/tegra_rpc ● /dev/tegra_sema ● ... whatever hides in hwcomposer HAL module
  • 19. 19 2.3. HAL Definition ● /hardware/libhardware/include/hardware/hwcomposer.h ● struct hwc_procs: ● invalidate() ● vsync() ● struct hwc_composer_device: ● prepare() ● set() ● dump() ● registerProcs() ● query() ● *()
  • 20. 20 2.5. HAL module ● Skeleton /hardware/libhardware/modules/hwcomposer.cpp ● /system/lib/hw/hwcomposer.BOARD.so ● /system/lib/hw/gralloc.BOARD.so ● Ex. - Mot Xoom: ● hwcomposer.tegra.so ● gralloc.tegra.so ● Surface Flinger hook: ● /frameworks/native/services/surfaceflinger/DisplayHardware – HWComposer.cpp – Provides fake vsync if none is provided in HW
  • 21. 21 2.6. Surface Flinger ● Actual server: ● /frameworks/native/services/surfaceflinger ● Client side: ● /frameworks/native/libs/gui ● Client / Server interface: ● ISurfaceComposerClient.cpp ● ISurfaceComposer.cpp ● This is NOT an aidl'ed service ● All communication is manually marshalled/unmarshalled
  • 22. 22 2.7. Window Manager ● Server side: ● /frameworks/base/services/java/com/android/server/wm/ – WindowManagerService.java – Session.java ● Client side: ● /frameworks/base/core/java/android/view/ – WindowManager.java – WindowManagerImpl.java – ViewRootImpl.java ● Interfaces: ● IWindowManager.aidl ● IWindowSession.aidl ● Parameters (incl. z-order): ● See WindowManager.java
  • 23. 23 3. Multimedia Architecture ● OpenMAX ● Media Playback ● Audio ● Camera
  • 25. 25 3.2. Media Playback From source.android.com - CC-BY 2.5
  • 30. 30 4. App Dev Model ● Media Playback ● Audio Record ● Camera
  • 31. 31 4.1. Media Playback ● developer.android.com sample: Uri myUri = ....; // initialize Uri here MediaPlayer mediaPlayer = new MediaPlayer(); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mediaPlayer.setDataSource(getApplicationContext(), myUri); mediaPlayer.prepare(); mediaPlayer.start();
  • 33. 33 4.2. Audio Record ● developer.android.com steps: ● Create a new instance of android.media.MediaRecorder. ● Set the audio source using MediaRecorder.setAudioSource(). You will probably want to use MediaRecorder.AudioSource.MIC. ● Set output file format using MediaRecorder.setOutputFormat(). ● Set output file name using MediaRecorder.setOutputFile(). ● Set the audio encoder using MediaRecorder.setAudioEncoder(). ● Call MediaRecorder.prepare() on the MediaRecorder instance. ● To start audio capture, call MediaRecorder.start(). ● To stop audio capture, call MediaRecorder.stop(). ● When you are done with the MediaRecorder instance, call MediaRecorder.release() on it. Calling MediaRecorder.release() is always recommended to free the resource immediately.
  • 35. 35 5. Kernel drivers ● Possibly V4Linux ● Possibly ALSA ● ... whatever hides in multimedia HAL modules
  • 36. 36 6. HAL Definition ● /hardware/libhardware/include/hardware/: ● audio_effect.h ● audio.h ● audio_policy.h ● camera.h ● camera2.h ● camera3.h ● camera_common.h
  • 37. 37 7. HAL module ● Audio skeletons in /hardware/libhardware/modules/audio ● USB audio in /hardware/libhardware/modules/usbaudio ● Default implementation in /hardware/libhardware/modules/camera ● /system/lib/hw/: ● audio.a2dp.default.so ● audio_policy.default.so ● audio_policy.mpq8064.so ● audio_policy.msm8960.so ● audio.primary.default.so ● audio.primary.mpq8064.so ● audio.primary.msm8960.so ● audio.usb.default.so ● camera.msm8960.so
  • 38. 38 8. System Services ● Player ● Audio Flinger ● Audio Policy ● Camera
  • 39. 39 8.1. Player ● Actual server: ● frameworks/av/media/libmediaplayerservice ● Client side: ● frameworks/av/media/libmedia ● Client / Server interface: ● IMediaPlayerClient.cpp ● IMediaPlayer.cpp ● IMediaPlayerService.cpp ● IMediaRecorderClient.cpp ● IMediaRecorder.cpp
  • 40. 40 8.2. Audio Flinger ● Actual Server: ● frameworks/av/services/audioflinger ● Client side: ● frameworks/av/media/libmedia ● Client / Server interface: ● IAudioFlingerClient.cpp ● IAudioFlinger.cpp ● IAudioRecord.cpp ● iAudioTrack.cpp
  • 41. 41 8.3. Audio Policy ● Actual Server: ● frameworks/av/services/audioflinger ● Client side: ● frameworks/av/media/libmedia ● Client / Server interface: ● IAudioPolicyService.cpp
  • 42. 42 8.4. Camera ● Actual Server: ● frameworks/av/services/camera/libcameraservice ● Client Side: ● frameworks/av/camera ● Client / Server interface: ● ICameraClient.cpp ● ICamera.cpp ● ICameraRecordingProxy.cpp ● ICameraRecordingProxyListener.cpp ● ICameraService.cpp ● ICameraServiceListener.cpp ● IProCameraCallbacks.cpp ● IProCameraUser.cpp
  • 43. 43 8.5. Wrapper process ● All media system services run within “mediaserver” system process. ● Started by init ● Sources: ● frameworks/av/media/mediaserver
  • 44. 44 9. Stagefright ● Multimedia framework ● Houses AwesomePlayer ● Location: ● frameworks/av/media/libstagefright ● Support loadable HW codecs: ● libstagefrighthw.so
  • 46. 46 10. Relevant Apps ● Music ● MusicFX ● Gallery2 ● SpeechRecorder ● VideoEditor
  • 47. 47 11. References and Pointers ● Google's “official” doumentation: source.android.com/devices/media.html source.android.com/devices/audio.html source.android.com/devices/camera/camera.html ● “Use the source, Luke” ● Developer doc: ● https://developer.android.com/guide/topics/media/mediaplayer.html ● https://developer.android.com/reference/android/media/MediaPlayer.html ● https://developer.android.com/guide/topics/media/audio-capture.html ● “Android Multimedia Framework”, picker - slideshare ● “The Android media framework”, Bert Van Dam & Poornachandra Kallare, Android Builders Summit 2014 ● “Android’s Stagefright Media Player Architecture”, Ivo Krka, http://quandarypeak.com/2013/08/androids-stagefright-media-player-architecture/ ● “Mastering the Android Media Framework”, Google I/O 2009 ● https://www.khronos.org/openmax/
  • 49. 49 Acknowledgements: ● Some figures and snippets taken from Google's Android documentation at developer.android.com and source.android.com distributed under the Apache 2.0 license and/or CC-BY-SA 2.5.