Android mediaRecorder框架简述(一)

最后更新于:2022-04-01 14:45:58

下面是框架简图: ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-18_56eba9940b98d.jpg) 首先调用mediaRecorder.java中的方法比如start方法,会调用jni: ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-18_56eba9941e691.png) 也就是调用android_media_recorder.cpp的start方法: ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-18_56eba99430e90.png)  接着到mediaRecorder.cpp,mediaRecorder是由mediaplayerService创建的,而mediaRecoder.cpp和mediaplayerService是通过binder机制来进行进程间的通信的,这时client端就是通过操作服务端返回的imediaRecorder来对服务端进行控制的: ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-18_56eba9944128b.png) 这里new mediaRecorderClient这是其实是创建了一个StagefrightRecorder: ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-18_56eba9945761f.png) 其实我们在java层调用start就是调用了StagefrightRecorder中的strat方法,在这里我们可以看到根据传进来的mOutputFormat值(输出格式)会选择不同的编码类型的方法: ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-18_56eba9946783c.png) 假如我们输出的是3gp格式,我们调用:startMPEG4Recording() 方法: ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-18_56eba99486e97.png) 接着调用setupMPEG4Recording: ![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-03-18_56eba9949dfb2.png)
';