StagefrightRecorder.h revision c32cd79d9ad4aba7d959b5b3be7361b4715e6f18
130ab66297501757d745b9ae10da61adcd891f497Andreas Huber/*
230ab66297501757d745b9ae10da61adcd891f497Andreas Huber * Copyright (C) 2009 The Android Open Source Project
330ab66297501757d745b9ae10da61adcd891f497Andreas Huber *
430ab66297501757d745b9ae10da61adcd891f497Andreas Huber * Licensed under the Apache License, Version 2.0 (the "License");
530ab66297501757d745b9ae10da61adcd891f497Andreas Huber * you may not use this file except in compliance with the License.
630ab66297501757d745b9ae10da61adcd891f497Andreas Huber * You may obtain a copy of the License at
730ab66297501757d745b9ae10da61adcd891f497Andreas Huber *
830ab66297501757d745b9ae10da61adcd891f497Andreas Huber *      http://www.apache.org/licenses/LICENSE-2.0
930ab66297501757d745b9ae10da61adcd891f497Andreas Huber *
1030ab66297501757d745b9ae10da61adcd891f497Andreas Huber * Unless required by applicable law or agreed to in writing, software
1130ab66297501757d745b9ae10da61adcd891f497Andreas Huber * distributed under the License is distributed on an "AS IS" BASIS,
1230ab66297501757d745b9ae10da61adcd891f497Andreas Huber * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1330ab66297501757d745b9ae10da61adcd891f497Andreas Huber * See the License for the specific language governing permissions and
1430ab66297501757d745b9ae10da61adcd891f497Andreas Huber * limitations under the License.
1530ab66297501757d745b9ae10da61adcd891f497Andreas Huber */
1630ab66297501757d745b9ae10da61adcd891f497Andreas Huber
1730ab66297501757d745b9ae10da61adcd891f497Andreas Huber#ifndef STAGEFRIGHT_RECORDER_H_
1830ab66297501757d745b9ae10da61adcd891f497Andreas Huber
1930ab66297501757d745b9ae10da61adcd891f497Andreas Huber#define STAGEFRIGHT_RECORDER_H_
2030ab66297501757d745b9ae10da61adcd891f497Andreas Huber
2130ab66297501757d745b9ae10da61adcd891f497Andreas Huber#include <media/MediaRecorderBase.h>
2230ab66297501757d745b9ae10da61adcd891f497Andreas Huber#include <utils/String8.h>
2330ab66297501757d745b9ae10da61adcd891f497Andreas Huber
2430ab66297501757d745b9ae10da61adcd891f497Andreas Hubernamespace android {
2530ab66297501757d745b9ae10da61adcd891f497Andreas Huber
26c32cd79d9ad4aba7d959b5b3be7361b4715e6f18James Dongclass Camera;
272dce41ad26cb3e9e15c9e456a84bcf5309548ca0Andreas Huberstruct MediaSource;
282dce41ad26cb3e9e15c9e456a84bcf5309548ca0Andreas Huberstruct MediaWriter;
2930ab66297501757d745b9ae10da61adcd891f497Andreas Huber
3030ab66297501757d745b9ae10da61adcd891f497Andreas Huberstruct StagefrightRecorder : public MediaRecorderBase {
3130ab66297501757d745b9ae10da61adcd891f497Andreas Huber    StagefrightRecorder();
3230ab66297501757d745b9ae10da61adcd891f497Andreas Huber    virtual ~StagefrightRecorder();
3330ab66297501757d745b9ae10da61adcd891f497Andreas Huber
3430ab66297501757d745b9ae10da61adcd891f497Andreas Huber    virtual status_t init();
3530ab66297501757d745b9ae10da61adcd891f497Andreas Huber    virtual status_t setAudioSource(audio_source as);
3630ab66297501757d745b9ae10da61adcd891f497Andreas Huber    virtual status_t setVideoSource(video_source vs);
3730ab66297501757d745b9ae10da61adcd891f497Andreas Huber    virtual status_t setOutputFormat(output_format of);
3830ab66297501757d745b9ae10da61adcd891f497Andreas Huber    virtual status_t setAudioEncoder(audio_encoder ae);
3930ab66297501757d745b9ae10da61adcd891f497Andreas Huber    virtual status_t setVideoEncoder(video_encoder ve);
4030ab66297501757d745b9ae10da61adcd891f497Andreas Huber    virtual status_t setVideoSize(int width, int height);
4130ab66297501757d745b9ae10da61adcd891f497Andreas Huber    virtual status_t setVideoFrameRate(int frames_per_second);
4230ab66297501757d745b9ae10da61adcd891f497Andreas Huber    virtual status_t setCamera(const sp<ICamera>& camera);
4330ab66297501757d745b9ae10da61adcd891f497Andreas Huber    virtual status_t setPreviewSurface(const sp<ISurface>& surface);
4430ab66297501757d745b9ae10da61adcd891f497Andreas Huber    virtual status_t setOutputFile(const char *path);
4530ab66297501757d745b9ae10da61adcd891f497Andreas Huber    virtual status_t setOutputFile(int fd, int64_t offset, int64_t length);
4630ab66297501757d745b9ae10da61adcd891f497Andreas Huber    virtual status_t setParameters(const String8& params);
4730ab66297501757d745b9ae10da61adcd891f497Andreas Huber    virtual status_t setListener(const sp<IMediaPlayerClient>& listener);
4830ab66297501757d745b9ae10da61adcd891f497Andreas Huber    virtual status_t prepare();
4930ab66297501757d745b9ae10da61adcd891f497Andreas Huber    virtual status_t start();
5030ab66297501757d745b9ae10da61adcd891f497Andreas Huber    virtual status_t stop();
5130ab66297501757d745b9ae10da61adcd891f497Andreas Huber    virtual status_t close();
5230ab66297501757d745b9ae10da61adcd891f497Andreas Huber    virtual status_t reset();
5330ab66297501757d745b9ae10da61adcd891f497Andreas Huber    virtual status_t getMaxAmplitude(int *max);
5430ab66297501757d745b9ae10da61adcd891f497Andreas Huber
5530ab66297501757d745b9ae10da61adcd891f497Andreas Huberprivate:
56c32cd79d9ad4aba7d959b5b3be7361b4715e6f18James Dong    enum CameraFlags {
57c32cd79d9ad4aba7d959b5b3be7361b4715e6f18James Dong        FLAGS_SET_CAMERA = 1L << 0,
58c32cd79d9ad4aba7d959b5b3be7361b4715e6f18James Dong        FLAGS_HOT_CAMERA = 1L << 1,
59c32cd79d9ad4aba7d959b5b3be7361b4715e6f18James Dong    };
60c32cd79d9ad4aba7d959b5b3be7361b4715e6f18James Dong
61c32cd79d9ad4aba7d959b5b3be7361b4715e6f18James Dong    sp<Camera> mCamera;
6230ab66297501757d745b9ae10da61adcd891f497Andreas Huber    sp<ISurface> mPreviewSurface;
6330ab66297501757d745b9ae10da61adcd891f497Andreas Huber    sp<IMediaPlayerClient> mListener;
642dce41ad26cb3e9e15c9e456a84bcf5309548ca0Andreas Huber    sp<MediaWriter> mWriter;
6530ab66297501757d745b9ae10da61adcd891f497Andreas Huber
6630ab66297501757d745b9ae10da61adcd891f497Andreas Huber    audio_source mAudioSource;
6730ab66297501757d745b9ae10da61adcd891f497Andreas Huber    video_source mVideoSource;
6830ab66297501757d745b9ae10da61adcd891f497Andreas Huber    output_format mOutputFormat;
6930ab66297501757d745b9ae10da61adcd891f497Andreas Huber    audio_encoder mAudioEncoder;
7030ab66297501757d745b9ae10da61adcd891f497Andreas Huber    video_encoder mVideoEncoder;
7130ab66297501757d745b9ae10da61adcd891f497Andreas Huber    int mVideoWidth, mVideoHeight;
7230ab66297501757d745b9ae10da61adcd891f497Andreas Huber    int mFrameRate;
7330ab66297501757d745b9ae10da61adcd891f497Andreas Huber    String8 mParams;
7430ab66297501757d745b9ae10da61adcd891f497Andreas Huber    int mOutputFd;
75c32cd79d9ad4aba7d959b5b3be7361b4715e6f18James Dong    int32_t mFlags;
7630ab66297501757d745b9ae10da61adcd891f497Andreas Huber
772dce41ad26cb3e9e15c9e456a84bcf5309548ca0Andreas Huber    status_t startMPEG4Recording();
782dce41ad26cb3e9e15c9e456a84bcf5309548ca0Andreas Huber    status_t startAMRRecording();
792dce41ad26cb3e9e15c9e456a84bcf5309548ca0Andreas Huber    sp<MediaSource> createAMRAudioSource();
802dce41ad26cb3e9e15c9e456a84bcf5309548ca0Andreas Huber
8130ab66297501757d745b9ae10da61adcd891f497Andreas Huber    StagefrightRecorder(const StagefrightRecorder &);
8230ab66297501757d745b9ae10da61adcd891f497Andreas Huber    StagefrightRecorder &operator=(const StagefrightRecorder &);
8330ab66297501757d745b9ae10da61adcd891f497Andreas Huber};
8430ab66297501757d745b9ae10da61adcd891f497Andreas Huber
8530ab66297501757d745b9ae10da61adcd891f497Andreas Huber}  // namespace android
8630ab66297501757d745b9ae10da61adcd891f497Andreas Huber
8730ab66297501757d745b9ae10da61adcd891f497Andreas Huber#endif  // STAGEFRIGHT_RECORDER_H_
8830ab66297501757d745b9ae10da61adcd891f497Andreas Huber
89