Recently in the camera program (two-process open a camera), involving the use of Mediarecorder for video recording, or a new set of video system. Next I will record the source code analysis of the process.
Binder communication between client and server is analyzed in the next article
(Client)
STEP One (contructor)
1../base/media/java/android/media/mediarecorder.java
In the construction of Mediarecorder, the method of Native_setup () is used (native method).
One way to do this in Androidruntime Registernativemethods is to register the current method with androidruntime, eliminating our work on the load of so.
2../base/media/jni/android_media_mediarecorder.cpp:
One of the SP Mr = New Mediarecorder (String16 (Oppackagenamestr.c_str ())), the method is the key to our Mediarecorder creation. About SP WP suggested that you are interested in the students to see, here can be understood as smart pointers.
3.av/media/libmedia/mediarecorder.cpp
point{
(1) Const SP Service (Getmediaplayerservice ());
(2) Mmediarecorder = Service->createmediarecorder (oppackagename);
}
Getmediaplayerservice () gets to ServiceManager. Get to DISCROOPTOYONGSHIYULE178.COMR (Media.player) services through Servicemanagthd178.comer (this is also Mediarecorder ( jnihuarenyl.cn) did not go to the cause of bpmediaplayerservice.), and then by calling the service's Createmediarecorder () method to get a Mediarecorder object
(Server)
4../av/media/libmediaplayerservice/mediaplayerservice.cpp
An SP retriever = new Metadataretrieverclient (PID) was created in servicer;
5.av/media/libmediaplayerservice/mediarecorderclient.cpp
This way, an instance of Stagefrightrecorder is created, which is primarily performed by Mediarecorder, including {
Receive some camera,audio data, encode the data, write the video file.
}
Android7.0 Mediarecorder Source Analysis