2025 年 3 月 27 日より、AOSP のビルドとコントリビューションには aosp-main
ではなく android-latest-release
を使用することをおすすめします。詳細については、AOSP の変更をご覧ください。
メディア
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Android には、ネイティブ レベルのメディア再生エンジンである Stagefright が内蔵されています。これには、一般的なメディア形式に対応するソフトウェアベースのコーデックが組み込まれています。
Stagefright の音声と動画の再生機能には、OpenMAX コーデック、セッション管理、時間同期レンダリング、トランスポート制御、DRM との統合が含まれています。
Stagefright は、カスタム ハードウェア コーデックとの統合もサポートしています。メディアのエンコードとデコードにハードウェア パスを設定するには、ハードウェア ベースのコーデックを OpenMax IL(統合レイヤ)コンポーネントとして実装する必要があります。
注: Stagefright の更新は、Android の月次セキュリティ アップデートのプロセスと Android OS リリースの一部として行われます。
アーキテクチャ
メディア アプリは、次のアーキテクチャに従って Android のネイティブ マルチメディア フレームワークと通信します。

図 1:メディア アーキテクチャ
- アプリケーション フレームワーク
- アプリケーション フレームワーク レベルには、android.media API を利用してマルチメディア ハードウェアと通信するアプリケーション コードがあります。
- Binder IPC
- Binder IPC プロキシは、プロセスの境界を越えた通信を容易にします。
これらは
frameworks/av/media/libmedia
ディレクトリにあり、「I」の文字で始まります。
- ネイティブ マルチメディア フレームワーク
- Android はネイティブ レベルで、音声と動画の記録や再生に Stagefright エンジンを使用するマルチメディア フレームワークを提供します。Stagefright にはデフォルトでサポートされているソフトウェア コーデックがあります。また、OpenMax の統合レイヤ標準を使用して独自のハードウェア コーデックを実装できます。実装について詳しくは、
frameworks/av/media
にある MediaPlayer コンポーネントと Stagefright コンポーネントをご覧ください。
- OpenMAX 統合レイヤ(IL)
- OpenMAX IL は、コンポーネントと呼ばれるカスタム ハードウェア ベースのマルチメディア コーデックを Stagefright が認識して使用するための標準化された方法を提供します。OpenMAX プラグインは、
libstagefrighthw.so
という名前の共有ライブラリの形式で作成する必要があります。このプラグインは、Stagefright とカスタム コーデック コンポーネントをリンクしますが、このコンポーネントは OpenMAX IL コンポーネント標準に従って実装する必要があります。
カスタム コーデックを実装する
Stagefright には一般的なメディア形式用のソフトウェア コーデックが組み込まれていますが、独自のカスタム ハードウェア コーデックを OpenMAX コンポーネントとして追加することもできます。このためには、OMX コンポーネントと、カスタム コーデックを Stagefright フレームワークと一緒にフックする OMX プラグインを作成する必要があります。コンポーネントの例については hardware/ti/omap4xxx/domx/
を、Galaxy Nexus のサンプル プラグインについては hardware/ti/omap4xx/libstagefrighthw
をご覧ください。
カスタム コーデックを追加するには:
- コンポーネントを OpenMAX IL コンポーネント標準に従って作成します。コンポーネント インターフェースは、
frameworks/native/include/media/OpenMAX/OMX_Component.h
ファイル内にあります。OpenMAX IL の仕様について詳しくは、OpenMAX のウェブサイトをご覧ください。
- 作成したコンポーネントと Stagefright サービスをリンクする OpenMAX プラグインを作成します。プラグインを作成するインターフェースについては、ヘッダー ファイル
frameworks/native/include/media/hardware/OMXPluginBase.h
と HardwareAPI.h
をご覧ください。
- 自作プロダクトの Makefile で、プラグインを
libstagefrighthw.so
という名前の共有ライブラリとしてビルドします。次に例を示します。
LOCAL_MODULE := libstagefrighthw
デバイスの Makefile で、このモジュールが PRODUCT_PACKAGES の 一つとして宣言されていることを確認します。
PRODUCT_PACKAGES += \
libstagefrighthw \
...
コーデックをフレームワークに公開する
Stagefright サービスは、system/etc/media_codecs.xml
と system/etc/media_profiles.xml
を解析し、デバイスでサポートされているコーデックとプロファイルを android.media.MediaCodecList
および android.media.CamcorderProfile
クラスを通じてアプリ デベロッパーに知らせます。両方のファイルを device/<company>/<device>/
ディレクトリに作成し、デバイスの Makefile でシステム イメージの system/etc
ディレクトリにコピーする必要があります。次に例を示します。
PRODUCT_COPY_FILES += \
device/samsung/tuna/media_profiles.xml:system/etc/media_profiles.xml \
device/samsung/tuna/media_codecs.xml:system/etc/media_codecs.xml \
完全な例については、device/samsung/tuna/media_codecs.xml
と device/samsung/tuna/media_profiles.xml
をご覧ください。
注: Android 4.1 以降、メディア コーデック用の <Quirk>
要素はサポートされなくなりました。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-27 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-27 UTC。"],[],[],null,["# Media\n\nAndroid includes Stagefright, a media playback engine at the native level\nthat has built-in software-based codecs for popular media formats.\n\nStagefright audio and video playback features include integration with\nOpenMAX codecs, session management, time-synchronized rendering, transport\ncontrol, and DRM.\n\nStagefright also supports integration with custom hardware codecs provided by\nyou. To set a hardware path to encode and decode media, you must implement a\nhardware-based codec as an OpenMax IL (Integration Layer) component.\n\n**Note:** Stagefright updates can occur through the\nAndroid [monthly security\nupdate](/docs/security/bulletin) process and as part of an Android OS release.\n\nArchitecture\n------------\n\nMedia applications interact with the Android native multimedia framework\naccording to the following architecture.\n\n**Figure 1.** Media\narchitecture\n\nApplication Framework\n: At the application framework level is application code that utilizes\n [android.media](http://developer.android.com/reference/android/media/package-summary.html)\n APIs to interact with the multimedia hardware.\n\nBinder IPC\n: The Binder IPC proxies facilitate communication over process boundaries.\n They are located in the `frameworks/av/media/libmedia` directory and\n begin with the letter \"I\".\n\nNative Multimedia Framework\n: At the native level, Android provides a multimedia framework that utilizes\n the Stagefright engine for audio and video recording and playback. Stagefright\n comes with a default list of supported software codecs and you can implement\n your own hardware codec by using the OpenMax integration layer standard. For\n more implementation details, see the MediaPlayer and Stagefright components\n located in `frameworks/av/media`.\n\nOpenMAX Integration Layer (IL)\n: The OpenMAX IL provides a standardized way for Stagefright to recognize and\n use custom hardware-based multimedia codecs called components. You must provide\n an OpenMAX plugin in the form of a shared library named\n `libstagefrighthw.so`. This plugin links Stagefright with your custom\n codec components, which must be implemented according to the OpenMAX IL\n component standard.\n\nImplement custom codecs\n-----------------------\n\nStagefright comes with built-in software codecs for common media formats, but\nyou can also add your own custom hardware codecs as OpenMAX components. To do\nthis, you must create the OMX components and an OMX plugin that hooks together\nyour custom codecs with the Stagefright framework. For example components, see\nthe `hardware/ti/omap4xxx/domx/`; for an example plugin for the\nGalaxy Nexus, see `hardware/ti/omap4xx/libstagefrighthw`.\n\nTo add your own codecs:\n\n1. Create your components according to the OpenMAX IL component standard. The component interface is located in the `frameworks/native/include/media/OpenMAX/OMX_Component.h` file. To learn more about the OpenMAX IL specification, refer to the [OpenMAX website](http://www.khronos.org/openmax/).\n2. Create a OpenMAX plugin that links your components with the Stagefright service. For the interfaces to create the plugin, see `frameworks/native/include/media/hardware/OMXPluginBase.h` and `HardwareAPI.h` header files.\n3. Build your plugin as a shared library with the name `libstagefrighthw.so` in your product Makefile. For example: \n\n ```\n LOCAL_MODULE := libstagefrighthw\n ```\n\n In your device's Makefile, ensure you declare the module as a product\n package: \n\n ```\n PRODUCT_PACKAGES += \\\n libstagefrighthw \\\n ...\n ```\n\nExpose codecs to the framework\n------------------------------\n\nThe Stagefright service parses the `system/etc/media_codecs.xml`\nand `system/etc/media_profiles.xml` to expose the supported codecs\nand profiles on the device to app developers via the\n`android.media.MediaCodecList` and\n`android.media.CamcorderProfile` classes. You must create both files\nin the `device/\u003ccompany\u003e/\u003cdevice\u003e/` directory\nand copy this over to the system image's `system/etc` directory in\nyour device's Makefile. For example: \n\n```\nPRODUCT_COPY_FILES += \\\n device/samsung/tuna/media_profiles.xml:system/etc/media_profiles.xml \\\n device/samsung/tuna/media_codecs.xml:system/etc/media_codecs.xml \\\n```\n\nFor complete examples, see `device/samsung/tuna/media_codecs.xml`\nand `device/samsung/tuna/media_profiles.xml` .\n\n**Note:** As of Android 4.1, the\n`\u003cQuirk\u003e` element for media codecs is no longer supported."]]