Android Mediascanner Masterplan

Source: Internet
Author: User

1. Mediascanner HEAD

2. Application Layer Mediaprovider

Packages\providers\mediaprovider
(1) Mediaprovider
Packages\providers\mediaprovider\mediaprovider.java
Mediaprovider inherits from ContentProvider, which is used primarily to create database tables for the Media Library.
Please see how to create a provider for more details.
Mediaprovider contains a broadcastreceiver for monitoring sdcard mount/unload
(2) Mediareceiver
Listen for scan events, call MSS
Action:
intent.action_boot_completed, intent.action_media_mounted
Scan Volume Mediascannerservice
Else
Scanfile filepath Mediascannerservice
(3) Mediascannerservice MSS
Onstartcommand==>servicehandler==>scanfile
When we call StartService. Assuming that the corresponding service has not been created, the oncreate method = = = method is called.

The Onstartcommand is called every time StartService, so Servicehandler sends a message here.

Call:mediascanner:: Scansinglefile, Scandirectories

3. JAVA Layer

Call Stack:google Annotations

/* * inSummary: * Java mediascannerservice calls * Java Mediascanner scandirectories, which calls * Java Mediascanner processdirectory (nativemethod), which calls *nativeMediascanner processdirectory, which calls *nativeMymediascannerclient Scanfile, which calls * Java Mymediascannerclient scanfile, which calls * Java mediascannerclient DoS Canfile, which calls * Java Mediascanner processfile (nativemethod), which calls *nativeMediascanner Processfile, which calls *nativeParseMP3, ParseMP4, Parsemidi, ParseoggorPARSEWMA, which calls *nativeMymediascanner Handlestringtag, which calls * Java Mymediascanner Handlestringtag. * Once Mediascanner Processfile returns, an entry isInsertedinchto the database. */


(1) Mediascanner
Frameworks/base/media/java/android/media/mediascanner.java

Call JNI

    static {        System.loadLibrary("media_jni");        native_init();    }

Scandirectories? JNI processdirectory
Scansinglefile ==> Mymediascannerclient.doscanfile
Deal with image, audio, video? JNI Processfile

4. JNI Layer

(1) Android_media_mediascanner.cpp
Frameworks\base\media\jni\android_media_mediascanner.cpp
Mediascanner *MP = getnativescanner_l (env, thiz);
Mp->processdirectory (Pathstr, myclient);
Mp->processfile (Pathstr, Mimetypestr, myclient);

The Android_media_mediascanner is more important in the Mymediascannerclient class, which will be passed on to the layer to invoke the Java layer (Mediascanner.java) Scanfile, Handlestringtag, Setmimetype

5. Server Proxyer

Libmedia–libmedia.so
Frameworks\av\media\libmedia\mediascanner.cpp
Working with specific files
Assume that the directory needs to be returned to the Java layer, using scanfile processing

6. Server

Frameworks\av\media\libstagefright\stagefrightmediascanner.cpp
Libstagefright.so
Infer a file that can be processed according to the file suffix
Then get specific information about the video via Mediametadataretriever,
In the end, the handlestring is passed up and down, and the information is written to the database in Mediascannerservice.

Android Mediascanner Masterplan

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.