StagefrightRecorder.h revision a7d1a2dd776bf356c228785a94ba8e0ff6a2ec7f
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 pause(); 51 virtual status_t stop(); 52 virtual status_t close(); 53 virtual status_t reset(); 54 virtual status_t getMaxAmplitude(int *max); 55 56private: 57 enum CameraFlags { 58 FLAGS_SET_CAMERA = 1L << 0, 59 FLAGS_HOT_CAMERA = 1L << 1, 60 }; 61 62 sp<Camera> mCamera; 63 sp<ISurface> mPreviewSurface; 64 sp<IMediaPlayerClient> mListener; 65 sp<MediaWriter> mWriter; 66 67 audio_source mAudioSource; 68 video_source mVideoSource; 69 output_format mOutputFormat; 70 audio_encoder mAudioEncoder; 71 video_encoder mVideoEncoder; 72 int32_t mVideoWidth, mVideoHeight; 73 int32_t mFrameRate; 74 int32_t mVideoBitRate; 75 int32_t mAudioBitRate; 76 int32_t mAudioChannels; 77 int32_t mSampleRate; 78 int32_t mInterleaveDurationUs; 79 int32_t mIFramesInterval; 80 int64_t mMaxFileSizeBytes; 81 int64_t mMaxFileDurationUs; 82 83 String8 mParams; 84 int mOutputFd; 85 int32_t mFlags; 86 87 status_t startMPEG4Recording(); 88 status_t startAMRRecording(); 89 status_t startAACRecording(); 90 sp<MediaSource> createAudioSource(); 91 status_t setParameter(const String8 &key, const String8 &value); 92 status_t setParamVideoEncodingBitRate(int32_t bitRate); 93 status_t setParamAudioEncodingBitRate(int32_t bitRate); 94 status_t setParamAudioNumberOfChannels(int32_t channles); 95 status_t setParamAudioSamplingRate(int32_t sampleRate); 96 status_t setParamInterleaveDuration(int32_t durationUs); 97 status_t setParamIFramesInterval(int32_t interval); 98 status_t setParamMaxDurationOrFileSize(int64_t limit, bool limit_is_duration); 99 100 StagefrightRecorder(const StagefrightRecorder &); 101 StagefrightRecorder &operator=(const StagefrightRecorder &); 102}; 103 104} // namespace android 105 106#endif // STAGEFRIGHT_RECORDER_H_ 107 108