代码改变世界

Android MediaRecorder 小结

2011-12-27 11:26  shaobin0604  阅读(2488)  评论(0编辑  收藏  举报

调用顺序

MediaRecorder.java
+- android_media_MediaRecorder.cpp
+- MediaRecorder.cpp
+- MediaPlayerService.cpp
+- MediaRecorderClient.cpp
+- StagefrightRecorder.cpp

重要的类

* MediaWriter
+- MPEG4Writer
* MediaSource
+- CameraSource

数据流向

             Camera
|
| CameraListener#postDataTimestamp(raw frame)
|
\ /
CameraSource(MediaSource)
|
| read(raw frame)
|
\ /
OMXCodec Encoder(MediaSource)
|
| read(encoded frame)
|
\ /
MPEG4Writer(MediaWriter)
|
| mux
|
\ /
MP4 File

CameraSource 帧队列

    List<sp<IMemory> > mFrames;   //
List<int64_t> mFrameTimes; // 帖的相对时间戳
  • read 消费者线程
  • dataCallbackTimestamp 生产者线程