اعتبارًا من 27 آذار (مارس) 2025، ننصحك باستخدام android-latest-release
بدلاً من aosp-main
لإنشاء AOSP والمساهمة فيه. لمزيد من المعلومات، يُرجى الاطّلاع على التغييرات في AOSP.
الوسائط
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
يتضمّن Android Stagefright، وهو محرّك تشغيل وسائط على المستوى الأصلي
يحتوي على برامج ترميز مدمجة تستند إلى البرامج لتنسيقات الوسائط الشائعة.
تشمل ميزات تشغيل الصوت والفيديو في Stagefright الدمج مع برامج ترميز
OpenMAX وإدارة الجلسات والعرض المتزامن مع الوقت والتحكّم في نقل البيانات
وإدارة حقوق المحتوى الرقمي (DRM).
يتيح Stagefright أيضًا الدمج مع برامج ترميز الأجهزة المخصّصة التي تقدّمها
أنت. لضبط مسار أجهزة لتشفير الوسائط وفك تشفيرها، يجب تنفيذ ملف ترميز
يستند إلى الأجهزة كمكوّن OpenMax IL (طبقة الدمج).
ملاحظة: يمكن أن يتم طرح تحديثات Stagefright من خلال عملية
التحديث الأمني الشهري لنظام التشغيل Android وكجزء من إصدار نظام التشغيل Android.
هندسة معمارية
تتفاعل تطبيقات الوسائط مع إطار عمل الوسائط المتعددة الأصلي في Android
وفقًا للبنية التالية.

الشكل 1: بنية
الوسائط
- إطار عمل التطبيق
- على مستوى إطار عمل التطبيق، يتوفّر رمز التطبيق الذي يستخدم واجهات برمجة التطبيقات
android.media
للتفاعل مع أجهزة الوسائط المتعددة.
- Binder IPC
- تسهِّل الوكلاء لبروتوكول IPC في Binder عملية التواصل عبر حدود العمليات.
يمكن العثور عليها في الدليل
frameworks/av/media/libmedia
وتبدأ بالحرف "I".
- إطار عمل الوسائط المتعددة الأصلي
- على المستوى الأساسي، يقدّم Android إطار عمل للوسائط المتعددة يستخدم
محرك Stagefright لتسجيل الصوت والفيديو وتشغيلهما. تأتي Stagefright
مع قائمة تلقائية ببرامج الترميز المتوافقة، ويمكنك تنفيذ
برنامج ترميز الأجهزة الخاص بك باستخدام معيار طبقة الدمج OpenMax. للحصول على
مزيد من تفاصيل التنفيذ، يُرجى الاطّلاع على مكونات MediaPlayer وStagefright
المتوفّرة في
frameworks/av/media
.
- طبقة دمج OpenMAX (IL)
- يوفّر OpenMAX IL طريقة موحّدة ليتمكّن Stagefright من التعرّف على برامج ترميز الوسائط المتعددة المخصّصة المستندة إلى الأجهزة والتي تُعرف باسم المكوّنات، واستخدامها. يجب توفير
مكوّن إضافي OpenMAX في شكل مكتبة مشتركة باسم
libstagefrighthw.so
. يربط هذا المكوّن الإضافي Stagefright بمكونات الترميز المخصّصة، والتي يجب تنفيذها وفقًا لمعيار مكونات OpenMAX IL.
تنفيذ برامج ترميز مخصّصة
يشتمل Stagefright على برامج ترميز مدمجة لتنسيقات الوسائط الشائعة، ولكن
يمكنك أيضًا إضافة برامج ترميز الأجهزة المخصّصة كمكونات OpenMAX. لتنفيذ
هذا، عليك إنشاء مكوّنات OMX ومكوّن إضافي OMX يربط معًا
برامج الترميز المخصّصة بإطار عمل Stagefright. للحصول على أمثلة على المكوّنات، يُرجى الاطّلاع على hardware/ti/omap4xxx/domx/
. للحصول على مثال على مكوّن إضافي لجهاز
Galaxy Nexus، يُرجى الاطّلاع على hardware/ti/omap4xx/libstagefrighthw
.
لإضافة برامج الترميز الخاصة بك:
- أنشئ المكوّنات وفقًا لمعيار مكوّنات OpenMAX IL. يمكن العثور على واجهة
المكوّن في ملف
frameworks/native/include/media/OpenMAX/OMX_Component.h
. لمزيد من المعلومات عن مواصفات OpenMAX IL، يُرجى الرجوع إلى موقع OpenMAX الإلكتروني.
- أنشئ مكوّنًا إضافيًا OpenMAX يربط مكوّناتك بخدمة Stagefright. للاطّلاع على واجهات إنشاء المكوّن الإضافي، يُرجى الاطّلاع علىملفَي الرأس
frameworks/native/include/media/hardware/OMXPluginBase.h
و
HardwareAPI.h
.
- أنشئ المكوّن الإضافي كمكتبة مشترَكة بالاسم
libstagefrighthw.so
في ملف Makefile الخاص بالمنتج. على سبيل المثال:
LOCAL_MODULE := libstagefrighthw
في ملف Makefile الخاص بالجهاز، تأكَّد من تحديد الوحدة على أنّها ملف ملف برمجي
للمنتج:
PRODUCT_PACKAGES += \
libstagefrighthw \
...
إتاحة برامج الترميز للإطار
تُحلِّل خدمة Stagefright system/etc/media_codecs.xml
وsystem/etc/media_profiles.xml
لعرض برامج الترميز
والملفات الشخصية المتوافقة على الجهاز لمطوّري التطبيقات من خلال فئتَي android.media.MediaCodecList
و
android.media.CamcorderProfile
. يجب إنشاء كلا الملفَّين
في الدليل device/<company>/<device>/
ونسخهما إلى الدليل system/etc
لصورة النظام في
ملف Makefile الخاص بجهازك. مثلاً:
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
.
ملاحظة: اعتبارًا من الإصدار 4.1 من Android، لم يعُد عنصر
<Quirk>
لبرامج ترميز الوسائط متوافقًا.
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ 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,["# 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."]]