android camera recording[转]

  • Post author:
  • Post category:其他


转自:http://leave001.blog.163.com/blog/static/16269129320101016104644615/
配置文件:/etc/media_profiles.xml 参考:

Android平台上从Camera的jpegquality菜单研究JNI接口(三)

Recording:
VideoCamera::startVideoRecording(), VideoCamera.java
MediaRecorder::start(), MediaRecorder.java
android_media_MediaRecorder_start(), android_media_MediaRecorder.cpp
MediaRecorder::start(), mediarecorder.cpp
MediaRecorderClient::start(), MediaRecorderClient.cpp
PVMediaRecorder::stop(), PVMediaRecorder.cpp /* 呼入OpenCore */
PVMediaRecorder::doStart()
AuthorDriver::handleStart()
PVAuthorEngine::Start(), pvauthorengine.cpp
PVAuthorEngine::DoStart()
AndroidCameraInput继承了PvmiMIOControl,因此PVAuthorEngine::DoStart()最终会呼入:
AndroidCameraInput::DoStart(), android_camera_input.cpp
mCamera->setListener(mListener); /* 设置listener。mListener为AndroidCameraInput构造函数中创建的AndroidCameraInputListener对象 */
mCamera->startRecording();
Camera::startRecording(), Camera.cpp
c->startRecording(); // sp <ICamera> c = mCamera, 为connect时创建的CameraService::Client对象
CameraService:
CameraService::Client::startRecording()
mHardware->enableMsgType(CAMERA_MSG_VIDEO_FRAME); /* enable CAMERA_MSG_VIDEO_FRAME消息 */
startCameraMode(CAMERA_RECORDING_MODE);
startRecordingMode();
mHardware->startRecording(recordingCallback, mCameraService.get()); /* 传入recordingCallback */
mRecordingCallback = cb; /* 保存cb到mRecordingCallback */
数据流向:
CameraService:
CameraHardware::previewThread()
mDataCb(CAMERA_MSG_VIDEO_FRAME, mBuffers[index], mCallbackCookie);
c->dataCallbackTimestamp(timestamp, msgType, dataPtr), CameraService.cpp
Camera::dataCallbackTimestamp()
listener->postDataTimestamp(timestamp, msgType, dataPtr);
listener为AndroidCameraInputListener对象
listener->postDataTimestamp(timestamp, msgType, dataPtr); /* listener在AndroidCameraInput::DoStart()中设置 */
AndroidCameraInputListener::postDataTimestamp(), android_camera_input.cpp
mCameraInput->postWriteAsync(timestamp, dataPtr);
AndroidCameraInput::postWriteAsync()
iFrameQueue.push_back(data);
AndroidCameraInput::Run()

iPeer->writeAsync(PVMI_MEDIAXFER_FMT_TYPE_DATA, 0, ptr,…), /* 将数据写入到iPeer中 *