I am trying to extract the muxer part of MediaRecorder
, so I am learning the source code of Android 4.2.2 now, anyway, that is not important.
I have a questions here. It's about setOutputFile(String path)
of MediaRecorder.java
.
The call consequence of MediaRecorder.java
is
MediaRecorder.java
+- android_media_MediaRecorder.cpp
+- MediaRecorder.cpp
+- MediaPlayerService.cpp
+- MediaRecorderClient.cpp
+- StagefrightRecorder.cpp
But in the StagefrightRecorder.cpp
, it says
status_t StagefrightRecorder::setOutputFile(const char *path) {
ALOGE("setOutputFile(const char*) must not be called");
// We don't actually support this at all, as the media_server process
// no longer has permissions to create files.
return -EPERM;
}
Then how can we continue to use setOutputFile(String path)
of MediaRecorder
? I really don't understand.
In MediaRecorder.java
, setOutputFile
is handled at the Java
layer itself without a corresponding native implementation. In the Java
implementation, the path is stored into mPath
.
When prepare
is called, a FileOutputStream
is created and passed to the native implementation of setOutputFile
which takes in a File Descriptor
as can be observed from this implementation. This method i.e. taking in a File Descriptor
is supported by the native implementation and hence, the output is generated and stored into the file system.
Hence, in examples such as MediaRecorderTest.java
, one can observe that MediaRecorder
object is initialized with a string
for the output file path.