StagefrightRecorder.h revision 050b28a593350047845a45a14cc5026221ac1620
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
78    String8 mParams;
79    int mOutputFd;
80    int32_t mFlags;
81
82    status_t startMPEG4Recording();
83    status_t startAMRRecording();
84    sp<MediaSource> createAudioSource();
85    status_t setParameter(const String8 &key, const String8 &value);
86    status_t setParamVideoEncodingBitRate(int32_t bitRate);
87    status_t setParamAudioEncodingBitRate(int32_t bitRate);
88    status_t setParamAudioNumberOfChannels(int32_t channles);
89    status_t setParamAudioSamplingRate(int32_t sampleRate);
90    status_t setMaxDurationOrFileSize(int32_t limit, bool limit_is_duration);
91
92    StagefrightRecorder(const StagefrightRecorder &);
93    StagefrightRecorder &operator=(const StagefrightRecorder &);
94};
95
96}  // namespace android
97
98#endif  // STAGEFRIGHT_RECORDER_H_
99
100