mediarecorder调用流程

MediaRecordertest.java
MediaRecorder.java
android_media_mediarecorder.cpp
MediaRecorder.cpp(BpMediaRecorder)
  |
  Binder
  |
 MediaPlayerService::createMediaRecorder
  new MediaRecorderClient(class MediaRecorderClient : public BnMediaRecorder)
   new StagefrightRecorder(struct StagefrightRecorder : public MediaRecorderBase)
     StagefrightRecorder::startMPEG4Recording()
      mWriter = new MPEG4Writer(dup(mOutputFd))
     setupAudioEncoder(const sp& mWriter)
       createAudioSource()
        audioSource=new AudioSource(mAudioSource,mSampleRate,mAudioChannels)-->mRecord = new AudioRecord(inputSource, sampleRate, AudioSystem::PCM_16_BIT,channels > 1? AudioSystem::CHANNEL_IN_STEREO: AudioSystem::CHANNEL_IN_MONO,4 * kMaxBufferSize / sizeof(int16_t), flags);
        audioEncoder =OMXCodec::Create(client.interface(), encMeta,true, audioSource);
     setupVideoEncoder(&encoder)
      mCamera=setupCameraSource
      cameraSource = CameraSource::CreateFromCamera(mCamera)-->new CameraSource(mCamera)
      encoder = OMXCodec::Create(client.interface(), enc_meta,true , cameraSource);
      mWriter->addSource(encoder)--Track *track = new Track(this, source);-->mTracks.push_back(track);
     mWriter->start(meta.get())
     MPEG4Writer::start
       startWriterThread
        pthread_create(&mThread, &attr, ThreadWrapper, this)
        MPEG4Writer::threadFunc()
         mChunkReadyCondition.wait(mLock);
         writeChunks()
          writeFirstChunk
         addSample_l
          fwrite(mFile)
       startTracks
        mTracks.begin().start
        MPEG4Writer::Track::start
         mSource->start
         pthread_create(&mThread, &attr, ThreadWrapper, this)
         MPEG4Writer::Track::ThreadWrapper
          threadEntry
           mSource->read(&buffer))
           mChunkSamples.push_back(buffer);
           bufferChunk
            mChunkReadyCondition.signal()唤醒MPEG4Writer::threadFunc()

你可能感兴趣的:(Android,Framework)