StagefrightRecorder.h revision 2dce41ad26cb3e9e15c9e456a84bcf5309548ca0
1/* 2 * Copyright (C) 2009 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef STAGEFRIGHT_RECORDER_H_ 18 19#define STAGEFRIGHT_RECORDER_H_ 20 21#include <media/MediaRecorderBase.h> 22#include <utils/String8.h> 23 24namespace android { 25 26struct MediaSource; 27struct MediaWriter; 28 29struct StagefrightRecorder : public MediaRecorderBase { 30 StagefrightRecorder(); 31 virtual ~StagefrightRecorder(); 32 33 virtual status_t init(); 34 virtual status_t setAudioSource(audio_source as); 35 virtual status_t setVideoSource(video_source vs); 36 virtual status_t setOutputFormat(output_format of); 37 virtual status_t setAudioEncoder(audio_encoder ae); 38 virtual status_t setVideoEncoder(video_encoder ve); 39 virtual status_t setVideoSize(int width, int height); 40 virtual status_t setVideoFrameRate(int frames_per_second); 41 virtual status_t setCamera(const sp<ICamera>& camera); 42 virtual status_t setPreviewSurface(const sp<ISurface>& surface); 43 virtual status_t setOutputFile(const char *path); 44 virtual status_t setOutputFile(int fd, int64_t offset, int64_t length); 45 virtual status_t setParameters(const String8& params); 46 virtual status_t setListener(const sp<IMediaPlayerClient>& listener); 47 virtual status_t prepare(); 48 virtual status_t start(); 49 virtual status_t stop(); 50 virtual status_t close(); 51 virtual status_t reset(); 52 virtual status_t getMaxAmplitude(int *max); 53 54private: 55 sp<ICamera> mCamera; 56 sp<ISurface> mPreviewSurface; 57 sp<IMediaPlayerClient> mListener; 58 sp<MediaWriter> mWriter; 59 60 audio_source mAudioSource; 61 video_source mVideoSource; 62 output_format mOutputFormat; 63 audio_encoder mAudioEncoder; 64 video_encoder mVideoEncoder; 65 int mVideoWidth, mVideoHeight; 66 int mFrameRate; 67 String8 mParams; 68 int mOutputFd; 69 70 status_t startMPEG4Recording(); 71 status_t startAMRRecording(); 72 sp<MediaSource> createAMRAudioSource(); 73 74 StagefrightRecorder(const StagefrightRecorder &); 75 StagefrightRecorder &operator=(const StagefrightRecorder &); 76}; 77 78} // namespace android 79 80#endif // STAGEFRIGHT_RECORDER_H_ 81 82