Full interpretation of the Android multimedia framework source code

Source: Internet
Author: User
Tags definition constructor

Android is easy to implement for graphical interface and multimedia related operations. And for most mobile phone users, they are mainly based on these aspects of the function to modify the system. We can through the introduction of the Android Multimedia framework of the source code interpretation, to specifically analyze the basic knowledge of this.

The code for the Android multimedia framework is in the following directory: External/opencore/. This directory is the root directory of the Android multimedia framework, which contains subdirectories as follows:

* Android: This is an upper-level library that implements a player and author for Android based on the Pvplayer and Pvauthor SDK.

* Baselibs: The underlying library containing data structure and line Cheng, etc.

* CODECS_V2: This is a more content library, mainly contains the implementation of codec, and a OpenMAX implementation

* Engines: Contains Pvplayer and Pvauthor engine implementations

* EXTERN_LIBS_V2: Header file containing Khronos OpenMAX

* Fileformats: File format According to the specific resolution (parser) class

* Nodes: Each node class for codec and file resolution.

* OSCL: Operating system compatible library

* PVMI: Abstract interface for input/output control

* Protocols: Mainly related to network-related RTSP, RTP, HTTP and other protocols

* Pvcommon:pvcommon library file Android.mk files, no source files.

* Pvplayer:pvplayer library file Android.mk files, no source files.

* Pvauthor:pvauthor library file Android.mk files, no source files.

* TOOLS_V2: Compile tools and some modules that can be registered.

Definition and initialization of splitter

To WAV Splitter as an example, in the Fileformats directory has the resolution WAV file format Pvwavfileparser.cpp file, in the nodes directory has pvmf_wavffparser_factory.cpp,pvmf_ Wavffparser_node.h, Pvmf_wavffparser_port.h and other documents.

We look up from the bottom, vwavfileparser.cpp in the Pv_wav_parser class has Initwavparser (), Getpcmdata (), Retrievefileinfo () and so on to parse WAV format member functions, This class should be the final parsing class. We search the place where the Pv_wav_parser class is used, and there is a pointer member variable in the Pvmfwavffparsernode class that has pv_wav_parser.

Again, the Pvmfwavffparsernode class is generated by the Pvmfwavffparsernodefactory Createpvmfwavffparsernode () member function. The Createpvmfwavffparsernode () function is registered with the Pvplayernodeinfo class in the Pvplayernoderegistry::P vplayernoderegistry () class constructor Oscl_ Vector vector, in this constructor, Amr,mp3 node is also registered.

From the above, the Android multimedia framework for splitter management is similar to the FFmpeg, are registered in the initialization of the framework, but Opencore registered is the factory function of each splitter.

Summarize the definition and initialization process of splitter:

Each splitter has a corresponding subdirectory under the Fileformats directory, with its own analytic classes under it.

Each splitter has a corresponding subdirectory under the nodes directory, with its own node class and Node factory class for the unified interface.

The playback engine Pvplayerengine class has pvplayernoderegistry iplayernoderegistry member variables.

In the constructor of Pvplayernoderegistry, the input and output types of AMR, AAC, MP3 and so on are labeled and create node and release in the Node factory class. The delete interface is pushed through the Pvplayernodeinfo class into the Oscl_vector itype member variable.

Matching process for current splitter

Pvmfstatus pvplayernoderegistry::queryregistry (pvmfformattype& ainputtype, pvmfformattype& AOutputType, The function of the oscl_vector& auuids function is to find out if there is a matching node in the registered node Vector based on the input type and output type, and to return its unique identifier pvuuid.

From Queryregistry this function to the bottom up search can be obtained, in Android splitter matching process is as follows:

Android_media_mediaplayer.cpp defines an array of Jninativemethod (Java native calling method) types Gmethods, To find the corresponding C + + function when calling the Setdatasource member function of the multiplayer class in Java code

1.{"Setdatasource", "(ljava/lang/string;) V", (void *)

Android_media_mediaplayer_setdatasource},

2.static void Android_media_mediaplayer_setdatasource

(JNIEnv *env, jobject thiz, jstring Path)

This function first gets the current MediaPlayer instance, and then calls its Setdatasource function, passing in the path

3.status_t mediaplayer::setdatasource (const char *url)

This function obtains the current mediaplayerservice, the Const sp& service (Getmediaplayerservice ()) by adjusting the Getmediaplayerservice ().

Then create a new Imediaplayer variable, SP player (Service->create (Getpid (), this, FD, offset, length));

In SP mediaplayerservice::create (pid_t PID, const sp& client, const char* URL)

Tune the status_t mediaplayerservice::client::setdatasource (const char *url) function, and the Client is an internal class of Mediaplayerservice.

In Mediaplayerservice::client::setdatasource, adjust the SP mediaplayerservice::client::createplayer (Player_type playerType)

Generates a Pvplayer instance that inherits from Mediaplayerbase.

The above is an explanation of the source code for the Android multimedia framework.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.