StagefrightRecorder.h revision ddcc4a66d848deef6fb4689e64e30cd9bd2684fe
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 26class Camera; 27struct MediaSource; 28struct MediaWriter; 29 30struct StagefrightRecorder : public MediaRecorderBase { 31 StagefrightRecorder(); 32 virtual ~StagefrightRecorder(); 33 34 virtual status_t init(); 35 virtual status_t setAudioSource(audio_source as); 36 virtual status_t setVideoSource(video_source vs); 37 virtual status_t setOutputFormat(output_format of); 38 virtual status_t setAudioEncoder(audio_encoder ae); 39 virtual status_t setVideoEncoder(video_encoder ve); 40 virtual status_t setVideoSize(int width, int height); 41 virtual status_t setVideoFrameRate(int frames_per_second); 42 virtual status_t setCamera(const sp<ICamera>& camera); 43 virtual status_t setPreviewSurface(const sp<ISurface>& surface); 44 virtual status_t setOutputFile(const char *path); 45 virtual status_t setOutputFile(int fd, int64_t offset, int64_t length); 46 virtual status_t setParameters(const String8& params); 47 virtual status_t setListener(const sp<IMediaPlayerClient>& listener); 48 virtual status_t prepare(); 49 virtual status_t start(); 50 virtual status_t stop(); 51 virtual status_t close(); 52 virtual status_t reset(); 53 virtual status_t getMaxAmplitude(int *max); 54 55private: 56 enum CameraFlags { 57 FLAGS_SET_CAMERA = 1L << 0, 58 FLAGS_HOT_CAMERA = 1L << 1, 59 }; 60 61 sp<Camera> mCamera; 62 sp<ISurface> mPreviewSurface; 63 sp<IMediaPlayerClient> mListener; 64 sp<MediaWriter> mWriter; 65 66 audio_source mAudioSource; 67 video_source mVideoSource; 68 output_format mOutputFormat; 69 audio_encoder mAudioEncoder; 70 video_encoder mVideoEncoder; 71 int32_t mVideoWidth, mVideoHeight; 72 int32_t mFrameRate; 73 int32_t mVideoBitRate; 74 int32_t mAudioBitRate; 75 int32_t mAudioChannels; 76 int32_t mSampleRate; 77 int32_t mInterleaveDurationUs; 78 int32_t mIFramesInterval; 79 int64_t mMaxFileSizeBytes; 80 int64_t mMaxFileDurationUs; 81 82 String8 mParams; 83 int mOutputFd; 84 int32_t mFlags; 85 86 status_t startMPEG4Recording(); 87 status_t startAMRRecording(); 88 status_t startAACRecording(); 89 sp<MediaSource> createAudioSource(); 90 status_t setParameter(const String8 &key, const String8 &value); 91 status_t setParamVideoEncodingBitRate(int32_t bitRate); 92 status_t setParamAudioEncodingBitRate(int32_t bitRate); 93 status_t setParamAudioNumberOfChannels(int32_t channles); 94 status_t setParamAudioSamplingRate(int32_t sampleRate); 95 status_t setParamInterleaveDuration(int32_t durationUs); 96 status_t setParamIFramesInterval(int32_t interval); 97 status_t setParamMaxDurationOrFileSize(int64_t limit, bool limit_is_duration); 98 99 StagefrightRecorder(const StagefrightRecorder &); 100 StagefrightRecorder &operator=(const StagefrightRecorder &); 101}; 102 103} // namespace android 104 105#endif // STAGEFRIGHT_RECORDER_H_ 106 107