自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
MediaCodec 中的低延遲解碼
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
這項功能已在 Android 11 中新增,可啟用低延遲的媒體解碼功能,這對即時應用程式至關重要。SoC 合作夥伴必須提供解碼器驅動程式,才能支援這項功能。媒體架構會使用 AOSP 提供的 Codec 2.0/OMX 設定參數,發出這個模式的信號。如要啟用這項功能,請參閱
參考實作程序。
實作
SoC 合作夥伴必須實作解碼器驅動程式,才能支援這項功能。應用程式開發人員可以使用新的 API 使用這項功能。合作夥伴需要提供解碼器驅動程式。這是尚未使用的全新公用 API。您不需要為這項功能實作系統 UI 或擴充功能。
自訂
使用者可以透過 API 開啟或關閉這項功能。如果開啟,解碼器必須根據編碼標準盡快傳回解碼影格 (無須等待進一步輸入),且必須保持運作。如果關閉,解碼器可以使用電源最佳化功能,這可能會導致解碼框架的傳回時間比實際需要的時間晚,且解碼器可能會在停滯時關閉。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","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 (世界標準時間)。"],[],[],null,["# Low-latency decoding in MediaCodec\n\nThis feature was added in Android 11 to enable media decoding with low\nlatency, which is critical for real-time apps. The SoC partners need to provide a\ndecoder driver to support this feature. The media framework signals this mode using\nCodec 2.0/OMX configuration parameters available in AOSP.\nSee the [reference implementation](https://android.googlesource.com/platform/cts/+/android11-release/tests/tests/media/src/android/media/cts/DecoderTest.java) for enabling this feature.\n\nImplementation\n--------------\n\n\nThe SoC partners need to implement decoder drivers to support this feature. App\ndevelopers can use the new API to use the feature. Partners need to provide decoder\ndrivers. This is a new public API that hasn't been used. There's no need to implement a\nsystem UI or an extension for this feature.\n\nCustomization\n-------------\n\nThe API allows users to turn this feature on or off. If turned on, the decoder must return\ndecoded frames as soon as possible based on the coding standard\n(without waiting for further input) and must stay awake. If turned off, the decoder\ncan use power optimizations that may result in decoded frames being returned later\nthan strictly necessary, and the decoder may power down when stalled."]]