In-depth analysis of Google's Android Architecture

Source: Internet
Author: User

To fully understand the problems related to the Android architecture, you must understand the nature, statements, variables, functions, pre-processing commands, input and output of the Android architecture, this will improve the efficiency of developers.

For a complete and relatively complex system such as the Android architecture, the implementation of a MediaPlayer function is not specific to its functions, but how to adapt specific functions to Android MediaPlayer is mainly implemented in the Player of OpenCore.

This part is not the focus of this article. This article focuses on the MediaPlayer system architecture. Other Android applications also use similar architectures for the development of open source businesses in China, hanchao3c believes that not only code should be shared, but also documents, design ideas, ideas, and even technical understanding should be fully shared.

The Android architecture provides great opportunities for Chinese people to enter large-scale open-source projects. people at the forefront of technology should not regard technology as private property. Instead, we should devote our understanding to the masses to improve their learning speed and feedback, so as to promote their own progress. I only dedicate this article to all our friends who are interested in technology and hope to inspire others and promote our technological progress together!

In each library, libmedia. so is at the core. It provides the MediaPlayer class for interfaces on the upper layer. libmedia_jni.so provides JAVA interfaces by calling the MediaPlayer class, and implements android. media. mediaPlayer class.

Libmediaplayerservice. so is the Media server, which inherits libmedia. so class implements server functions, while libmedia. in so, another part of the content is through inter-process communication and libmediaplayerservice. so for communication. Libmediaplayerservice. so,

The real function is accomplished by calling OpenCore Player. The header file of MediaPlayer is in the frameworks/base/include/media/directory, which corresponds to the directory of the libmedia. so Library source file frameworks/base/media/libmedia. The main header files include the following:

 
 
  1. notify_callback_f notifyFunc)  
  2. {  
  3.     sp<MediaPlayerBase> p;  
  4.     switch (playerType) {  
  5.         case PV_PLAYER:  
  6.             LOGV(" create PVPlayer");  
  7.             p = new PVPlayer();  
  8.             break;  
  9.         case SONIVOX_PLAYER:  
  10.             LOGV(" create MidiFile");  
  11.             p = new MidiFile();  
  12.             break;  
  13.         case VORBIS_PLAYER:  
  14.             LOGV(" create VorbisPlayer");  
  15.             p = new VorbisPlayer();  
  16.             break;  
  17.     }  
  18. //……  
  19.     return p;  

In these header files, mediaplayer. h provides interfaces for the upper layer, while several other header files provide some interface classes that contain pure virtual functions.) These interface classes must be inherited by implementation classes before they can be used. It has pure virtual functions.

IMediaPlayerService and BnMediaPlayerService must be inherited to use the create and decode interfaces defined in IMediaPlayerService. In fact, it is the content that must be implemented by the successor. Note that the return value type of create is sp <IMediaPlayer>. This IMediaPlayer provides the interface for implementing functions.

(OGG Vobis is an audio compression format, which is similar to MP3 music formats. It is completely free, open, and without patent restrictions .) It is worth noting that PVPlayer, MidiFile, and VorbisPlayer all inherit MediaPlayerInterface.

The Android architecture inherits MediaPlayerBase, so the three have the same interface type. Each constructor is called only when the constructor is created. After the constructor is created, MediaPlayerBase controls them only through the MediaPlayerBase interface. In the frameworks/base/media/libmediaplayerservice directory, MidiFile. h and MidiFile. cpp implement MidiFile, VorbisPlayer. h, and VorbisPlayer. cpp to implement a VorbisPlayer.

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.