Different Approaches for Design of Android based Media Player: A Review

Many users like to watch video by a mobile phone, but the media player has many limitations. With a rapid development of communication and network, multimedia based technology is adopted in media player. Different approaches shows in this paper are plug-in extension technology, multimedia based on hierarchy, media player based on file browser, media player based on FFmpeg (Fast Forward Moving Picture Expert Group), media player based on file server.


I. INTRODUCTION
With the continuous development of science and technology, mobile phone is no longer just communication, but a multimedia platform that provides multimedia capabilities. The function of a mobile phone is powerful. Playing a video/audio on a mobile phone has become a basic function, but the media player in Android platform supports only limited format, so a powerful media player based on Android platform with at most supported format is needed.
The decode library is the most complex part of a media player to develop. At present, the decode module of most media players is based on FFmpeg decode library, such as Storm Codec, KMP Codec, etc. and the display module is based on SDL (Simple Direct Media Layer) [1], [2], [4], [14]. This paper shows different approaches for design of media player. First is plug-in extension technology on android multimedia player software platform, second is media player based on hierarchy, third is android media player software development, fourth is android media framework and fifth is continuous media player.
Section II provides an overview of different approaches to be used. Section III describes the comparison of different approaches and finally section IV refers to conclusion.

II. DIFFERENT APPROACHES
Android is an integrated open platform for mobile devices. It includes operating system, middleware, and user interface and core applications.
FFmpeg is an open source that produces libraries and programs used in audio and video areas. It support more than 90 kinds of decoders and also support protocols such as H.261/H.263/H.264 [9], [11] and so on. It provides a complete solution to transcode, record and stream audio/video. It includes an audio/video codec library, an audio/video container mux and demux library, the transplantation and codec quality [1], [2], [4].
SDL is a library used to display audio and video information. Display module of most of the media player is based on SDL [1], [2], [4], [14].
A. Plug-in extension technology on android multimedia player software platform

1) Multimedia player softwareplatform on android
Jin and Jiaming describes multimedia player software platform on Android with the use of the OpenCORE kernel. Packaging the kernel and providing in the form of SDK is used to develop multimedia player application in mobile terminal, such as video player and streaming media player, etc [1]. Wu and Xiao show the development of application needs powerful decoding and container that support more video encoding formats. It describes the upper layer is Java, which provides the application development interface (Android_FFmpeg API). The bottom layer is the C/C++ layer, which is the core layer used to process audio/video data with FFmpeg [8].
The implementation of FFmpeg consist of audio/video which is packed at the bottom layer includes the data source analysis of audio/video, the play of audio/video, paused and callback related mistakes, etc. The implementation of the bottom layer will be provided by Android_FFmpeg API through Java Native Interface (JNI) [1]. J u n e 1 5 , 2 0 1 4 The bottom layer involves the audio/video data processing core (libffmpeg.so). It packages the related audio/video function of FFmpeg. It includes decoding of all major audio/video, synchronization between multiple media streams [13], completing the display and playback features of the audio/video [14], after decoding low-level audio/video equipment libraries (libvideo.so; libaudio.so) [1].
The decoding of selected components achieves the decoding format from the header of the native file or streaming media file. It also selects corresponding decoder to decode compressed media streams [1].

B. Media player based on hierarchy 1) Design of media player
Song et. al., shows to play media files, the media player gather the media data first, decode the audio/video streams later, then display the data after decoding [2].
During the three steps, media player needs to parse the coding format of the media file, decode for the original data by the corresponding decode programs, put the original data to buffer queues, then display the original data after being synchronized. Design reduces the application coupling [2]. The layers of system structure of media player are UI; decode layer, pretreatment layer and data extract layer.

a) UI
UI is used to display the original data on media player for users such as functions of play, pause, page down, page up, etc [7], [8].

b) Decode layer
Decode layer is used to gather information of the media file formats, and then decodes audio/video streams by the corresponding decoder, and then synchronize the audio/video streams. It includes all kinds of decoders, the decoder choosing module and the synchronize module [8], [15].

Fig 3: Flow Chart of Decode layer
Before decoding, registration of all the formats is necessary which can be decoded by the module. Then provide a link to connect the corresponding decode unit and a media format [2].

c) Pretreatment layer
Pretreatment layer is used to demux the media file according to the available format and store the information of the media file into the buffer.

d) Data extract layer
Data extract layer is used to read the media file. Jin et. al., shows common media codec mechanism, so it is easily been integrated to multimedia files such as audio, video and pictures. Android Media Player plays audio files such as local files, resource files and network file streams from many sources. This includes media player plays audio files from SD card and displays the lyrics synchronously [3], [10]. Entering in the initial interface of media player, it consists of three options: All music, recently played list, and most often played list [3].
When Android system is start, media player automatically scan multimedia files in the SD card. Simultaneously, store the received information in a system database. To make the data in the multimedia database, broadcast mechanism is used. Then sending a broadcast in the application to update the multimedia database by scanning the SD card. Then register the scanSd Receiver, Broadcast Receiver [3].

b) Play List module:
Play List is a major part to show the name of audio files, its singers and durations. Play List is used to create a list, when using mouse to click one of the items in List View, it will trigger setOnItemClickListener monitor [3].

c) Recently played module and the most often played module:
Function onCreate() and onUpgrade() is used to create and update the database. Then invoke queryRecently() to realize recently played list by inquiring songs according to play time descending and invoke queryByClicks() to realize Most often played list by inquiring songs according to the hit descending [3].

d) Play module:
The main function is to display the information of title, lyrics and time about the song, and some of the media player's functional keys, such as play, pause, stop, last, next, backward and forward, and then display the lyrics [3]. libmediaplayerservice implements players and the media service which manage player instances.

D. Android media framework
Libmedia defines base interfaces and the inheritance hierarchy. libmedia_jni is the centre between java application and native library. First, it implements the JNI specification so that it can be used by java application [8], [16]. Second, it implements the pattern for the convenience of caller [4].

1) Android media players
Media Player is an important part of Android media framework. It is used to control the playback option of Audio and Video [14].
Methods of Media Player are implemented in C/C++ and then compiled to .so file. JavaTM Native Interface (JNI) is a standard programming interface for writing Java native methods and embedding the JavaTM virtual machine into native applications. Once the components decode the source audio file, the decoded stream is send to audio hardware to turn into sounds [4], [8], [16]. J u n e 1 5 , 2 0 1 4

Fig 7: Android media framework layer 2) FFmpeg decode work flow
FFmpeg provides powerful media encode/decode functions. First of all register all kinds of codec defined in FFmpeg to system. So that the audio/video files can be decoded by FFmpeg. Then open the media file from local files and get the file stream information and the file stream type. After these, choose a appropriate decoder and allocate memory for data structures AVCodec, AVFormatContext, AVStream.. And then divide the file stream into audio stream and video stream [4].
AVFormatContext is used to save the input/output data. AVCodecContext save the pointer of AVCodec and data related with codec. AVCodec is used to store the codec information such as pixels format information. AVStream saves the data segment [4].

3) FFmpeg transplant
FFmpeg is a complete, cross-platform solution to convert record and stream audio/video files. The makefile Android.mk of NDK is different from normal makefile. So the precondition is modify the makefile of FFmpeg. Rowe and Smith shows the playback application is the interface between the user and the CM Server process. The application includes creating windows, responding to input events, and sending commands to CM Server [5].
The CM Server receives CM data from the CM Source and sends it to the appropriate output device. The CM Server has a time-ordered play to synchronize the playing of audio and video packets [12]. It communicates with CM Source processes on the file server through inter process communication channels, and it communicates with the X server through shared memory. The system clocks on the different systems are synchronized so that actions in the CM Server and Sources can be synchronized. The CM Source processes read CM data and send it to the CM Server. CM data is sent in 8k packets on a UDP connection [5].
Meta data about scripts is stored in a database. The Meta data is separated from the raw CM data so that different scripts can include overlapping clips without having to make a copy of the CM data [5].

III. COMPARISON
Time-based multimedia synchronized transmission algorithm is as follows: Jia-ming and Jin shows display and playback the multimedia data (audio or video), it is necessary to extract time stamp information (Tpts) from the multimedia data block, and compared to the current reference time (Tclock). If the timestamp of multimedia data block is less than the current reference time (Tpts< Tclock), play the current data as soon as possible, or even discard the current multimedia data directly; If the multimedia data blocks of time stamp is greater than the reference time stamp (Tpts> Tclock), the data block is transferring immediately to suspended state, and waiting to play [6].

Fig 10: Multimedia Synchronization Performance
Selected 20 video files whose container format is flv and bit rate is 800kbps，to test multimedia synchronization performance.

IV.CONCLUSION
This paper shows different approaches for design of media player. The platform is an extension and improvement on audio/video data processing of Android multimedia player platform. Media player should consider the improvement in scenario such as decode efficiency needs to be improved, synchronization between multiple media streams, and display of the original data. Use of FFmpeg decode library seems to be an alternative method, research shows FFmpeg supports most media formats which gives a high decode efficiency.
Different approaches shown in this paper are plug-in extension technology, multimedia based on hierarchy, media player based on file browser, media player based on FFmpeg, media player based on file server.