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