Android Multimedia 
    Framework
      on Jelly Bean




     Author: Picker
Introduction to OpenMAX
Resource from Khronos::OpenMAX
Resource from Khronos::OpenMAX
from
Multimedia Framework

        to
     OpenMAX
Resource from Khronos::OpenMAX
Resource from Khronos::OpenMAX
Go through the OpenMAX


                  Operating System
                  Operating System

                 Multimedia Framework
                 Multimedia Framework



                    OpenMAX IL
                    OpenMAX IL


              Software & Hardware Codec
              Software & Hardware Codec
The simple stack architecture

                Developer API (MediaPlayer)
                Developer API (MediaPlayer)

               EventHandler     SurfaceHolder



                         StageFright


                     OpenMAX Interface


                        OpenMAX IL


                  Software & Hardware Codec
Big picture of the StageFright
The Simple Workflow
The StageFright Workflow
Path of All the Components
Path of the Source Files


         frameworks/base/media/java/android/media
         frameworks/base/media/jni


         frameworks/av/media/libmedia
         frameworks/av/media/libmediaplayerservice

         frameworks/av/media/libstagefright
Big Picture
 Class Diagram
High­Level Applications Framework
StageFright Framework
OpenMAX Interface
Four Steps for Playing the Media File


        Step 1:  MediaPlayer mp = new MediaPlayer();
        Step 2:  mp.setDataSource(mediaPath);
                    setDataSource
        Step 3:  mp.prepare();
                    prepare
        Step 4:  mp.start();
                    start
How to set the data source?
The workflow of the setDataSource
The sequence flow of the setDataSource
How to prepare to play?
The workflow of the prepare
The sequence flow of the prepare
How to start the playing?
The workflow of the start
The sequence flow of the start
Synchronization Architecture of StageFright
Synchronization Flow of StageFright
The Synchronization Formula of StageFright

                                                sizedone
                          mNumFramesPlayed+
                                             mFrameSize
 mPositionTimeRealsUs=(                                  )×1000000
                                    mSampleRate
 mTimeSourceDeltaUs=mPositionTimeRealUs−mPositionTimeMediaUs

 nowUs= RealTimeUs−mTimeSourceDeltaUs

 latenessUs=nowUs−timeUs




                             mPositionTimeRealsUs: the time in real playing
                             mPositionTimeMediaUs: the time which is defined in the media source
The Synchronization Conditions
  Conditions of latenessUs
  1. > 500000ll
  2. > 40000
  3. < -10000            1750              if (latenessUs > 500000ll
                              1751                && mAudioPlayer != NULL
                              1752                && mAudioPlayer->getMediaTimeMapping(
                              1753                  &realTimeUs, &mediaTimeUs)) {


                              1757             mVideoBuffer->release();
                              1758             mVideoBuffer = NULL;

                              1763             postVideoEvent_l();
                              1764             return;
                              1765         }




1767   if (latenessUs > 40000) {
1768       // We're more than 40ms late.                 1793        if (latenessUs < -10000) {
                                                         1794            // We're more than 10ms early.
1780        mVideoBuffer->release();                     1795            postVideoEvent_l(10000);
1781        mVideoBuffer = NULL;                         1796            return;
                                                         1797        }
1787
1788        postVideoEvent_l();
1789        return;
1791   }
Conclusion

●Easy for maintaining rather than OpenCore
●Support Software/Hardware Codecs

●Unstable Product

 ● Rough Mechanisms

 ● Create the NuPlayer for playing the 


   multimedia streaming

Android Multimedia Framework