dom/camera/GonkRecorder.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/camera/GonkRecorder.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,190 @@
     1.4 +/*
     1.5 + * Copyright (C) 2009 The Android Open Source Project
     1.6 + *
     1.7 + * Licensed under the Apache License, Version 2.0 (the "License");
     1.8 + * you may not use this file except in compliance with the License.
     1.9 + * You may obtain a copy of the License at
    1.10 + *
    1.11 + *      http://www.apache.org/licenses/LICENSE-2.0
    1.12 + *
    1.13 + * Unless required by applicable law or agreed to in writing, software
    1.14 + * distributed under the License is distributed on an "AS IS" BASIS,
    1.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.16 + * See the License for the specific language governing permissions and
    1.17 + * limitations under the License.
    1.18 + */
    1.19 +
    1.20 +#ifndef GONK_RECORDER_H_
    1.21 +#define GONK_RECORDER_H_
    1.22 +
    1.23 +#include "nsISupportsImpl.h"
    1.24 +#include "GonkCameraHwMgr.h"
    1.25 +
    1.26 +#include <media/MediaRecorderBase.h>
    1.27 +#include <camera/CameraParameters.h>
    1.28 +#include <utils/String8.h>
    1.29 +#include <system/audio.h>
    1.30 +
    1.31 +#include "mozilla/RefPtr.h"
    1.32 +#include "GonkCameraHwMgr.h"
    1.33 +
    1.34 +namespace android {
    1.35 +
    1.36 +class GonkCameraSource;
    1.37 +struct MediaSource;
    1.38 +struct MediaWriter;
    1.39 +class MetaData;
    1.40 +struct AudioSource;
    1.41 +class MediaProfiles;
    1.42 +class GonkCameraHardware;
    1.43 +
    1.44 +struct GonkRecorder {
    1.45 +    NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GonkRecorder)
    1.46 +
    1.47 +    GonkRecorder();
    1.48 +
    1.49 +    virtual status_t init();
    1.50 +    virtual status_t setAudioSource(audio_source_t as);
    1.51 +    virtual status_t setVideoSource(video_source vs);
    1.52 +    virtual status_t setOutputFormat(output_format of);
    1.53 +    virtual status_t setAudioEncoder(audio_encoder ae);
    1.54 +    virtual status_t setVideoEncoder(video_encoder ve);
    1.55 +    virtual status_t setVideoSize(int width, int height);
    1.56 +    virtual status_t setVideoFrameRate(int frames_per_second);
    1.57 +    virtual status_t setOutputFile(const char *path);
    1.58 +    virtual status_t setOutputFile(int fd, int64_t offset, int64_t length);
    1.59 +    virtual status_t setParameters(const String8& params);
    1.60 +    virtual status_t setCamera(const sp<GonkCameraHardware>& aCameraHw);
    1.61 +    virtual status_t setListener(const sp<IMediaRecorderClient>& listener);
    1.62 +    virtual status_t setClientName(const String16& clientName);
    1.63 +    virtual status_t prepare();
    1.64 +    virtual status_t start();
    1.65 +    virtual status_t pause();
    1.66 +    virtual status_t stop();
    1.67 +    virtual status_t close();
    1.68 +    virtual status_t reset();
    1.69 +    virtual status_t getMaxAmplitude(int *max);
    1.70 +    virtual status_t dump(int fd, const Vector<String16>& args) const;
    1.71 +    // Querying a SurfaceMediaSourcer
    1.72 +
    1.73 +protected:
    1.74 +    virtual ~GonkRecorder();
    1.75 +
    1.76 +private:
    1.77 +    sp<IMediaRecorderClient> mListener;
    1.78 +    String16 mClientName;
    1.79 +    uid_t mClientUid;
    1.80 +    sp<MediaWriter> mWriter;
    1.81 +    int mOutputFd;
    1.82 +    sp<AudioSource> mAudioSourceNode;
    1.83 +
    1.84 +    audio_source_t mAudioSource;
    1.85 +    video_source mVideoSource;
    1.86 +    output_format mOutputFormat;
    1.87 +    audio_encoder mAudioEncoder;
    1.88 +    video_encoder mVideoEncoder;
    1.89 +    bool mUse64BitFileOffset;
    1.90 +    int32_t mVideoWidth, mVideoHeight;
    1.91 +    int32_t mFrameRate;
    1.92 +    int32_t mVideoBitRate;
    1.93 +    int32_t mAudioBitRate;
    1.94 +    int32_t mAudioChannels;
    1.95 +    int32_t mSampleRate;
    1.96 +    int32_t mInterleaveDurationUs;
    1.97 +    int32_t mIFramesIntervalSec;
    1.98 +    int32_t mCameraId;
    1.99 +    int32_t mVideoEncoderProfile;
   1.100 +    int32_t mVideoEncoderLevel;
   1.101 +    int32_t mMovieTimeScale;
   1.102 +    int32_t mVideoTimeScale;
   1.103 +    int32_t mAudioTimeScale;
   1.104 +    int64_t mMaxFileSizeBytes;
   1.105 +    int64_t mMaxFileDurationUs;
   1.106 +    int64_t mTrackEveryTimeDurationUs;
   1.107 +    int32_t mRotationDegrees;  // Clockwise
   1.108 +    int32_t mLatitudex10000;
   1.109 +    int32_t mLongitudex10000;
   1.110 +    int32_t mStartTimeOffsetMs;
   1.111 +
   1.112 +    String8 mParams;
   1.113 +
   1.114 +    bool mIsMetaDataStoredInVideoBuffers;
   1.115 +    MediaProfiles *mEncoderProfiles;
   1.116 +
   1.117 +    bool mStarted;
   1.118 +    // Needed when GLFrames are encoded.
   1.119 +    // An <IGraphicBufferProducer> pointer
   1.120 +    // will be sent to the client side using which the
   1.121 +    // frame buffers will be queued and dequeued
   1.122 +
   1.123 +    sp<GonkCameraHardware> mCameraHw;
   1.124 +
   1.125 +    status_t setupMPEG4Recording(
   1.126 +        int outputFd,
   1.127 +        int32_t videoWidth, int32_t videoHeight,
   1.128 +        int32_t videoBitRate,
   1.129 +        int32_t *totalBitRate,
   1.130 +        sp<MediaWriter> *mediaWriter);
   1.131 +    void setupMPEG4MetaData(int64_t startTimeUs, int32_t totalBitRate,
   1.132 +        sp<MetaData> *meta);
   1.133 +    status_t startMPEG4Recording();
   1.134 +    status_t startAMRRecording();
   1.135 +#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
   1.136 +    status_t startAACRecording();
   1.137 +#endif
   1.138 +    status_t startRawAudioRecording();
   1.139 +    status_t startRTPRecording();
   1.140 +    status_t startMPEG2TSRecording();
   1.141 +    sp<MediaSource> createAudioSource();
   1.142 +    status_t checkVideoEncoderCapabilities();
   1.143 +    status_t checkAudioEncoderCapabilities();
   1.144 +    // Generic MediaSource set-up. Returns the appropriate
   1.145 +    // source (CameraSource or SurfaceMediaSource)
   1.146 +    // depending on the videosource type
   1.147 +    status_t setupMediaSource(sp<MediaSource> *mediaSource);
   1.148 +    status_t setupCameraSource(sp<GonkCameraSource> *cameraSource);
   1.149 +    // setup the surfacemediasource for the encoder
   1.150 +
   1.151 +    status_t setupAudioEncoder(const sp<MediaWriter>& writer);
   1.152 +    status_t setupVideoEncoder(
   1.153 +            sp<MediaSource> cameraSource,
   1.154 +            int32_t videoBitRate,
   1.155 +            sp<MediaSource> *source);
   1.156 +
   1.157 +    // Encoding parameter handling utilities
   1.158 +    status_t setParameter(const String8 &key, const String8 &value);
   1.159 +    status_t setParamAudioEncodingBitRate(int32_t bitRate);
   1.160 +    status_t setParamAudioNumberOfChannels(int32_t channles);
   1.161 +    status_t setParamAudioSamplingRate(int32_t sampleRate);
   1.162 +    status_t setParamAudioTimeScale(int32_t timeScale);
   1.163 +    status_t setParamVideoEncodingBitRate(int32_t bitRate);
   1.164 +    status_t setParamVideoIFramesInterval(int32_t seconds);
   1.165 +    status_t setParamVideoEncoderProfile(int32_t profile);
   1.166 +    status_t setParamVideoEncoderLevel(int32_t level);
   1.167 +    status_t setParamVideoCameraId(int32_t cameraId);
   1.168 +    status_t setParamVideoTimeScale(int32_t timeScale);
   1.169 +    status_t setParamVideoRotation(int32_t degrees);
   1.170 +    status_t setParamTrackTimeStatus(int64_t timeDurationUs);
   1.171 +    status_t setParamInterleaveDuration(int32_t durationUs);
   1.172 +    status_t setParam64BitFileOffset(bool use64BitFileOffset);
   1.173 +    status_t setParamMaxFileDurationUs(int64_t timeUs);
   1.174 +    status_t setParamMaxFileSizeBytes(int64_t bytes);
   1.175 +    status_t setParamMovieTimeScale(int32_t timeScale);
   1.176 +    status_t setParamGeoDataLongitude(int64_t longitudex10000);
   1.177 +    status_t setParamGeoDataLatitude(int64_t latitudex10000);
   1.178 +    void clipVideoBitRate();
   1.179 +    void clipVideoFrameRate();
   1.180 +    void clipVideoFrameWidth();
   1.181 +    void clipVideoFrameHeight();
   1.182 +    void clipAudioBitRate();
   1.183 +    void clipAudioSampleRate();
   1.184 +    void clipNumberOfAudioChannels();
   1.185 +    void setDefaultProfileIfNecessary();
   1.186 +
   1.187 +    GonkRecorder(const GonkRecorder &);
   1.188 +    GonkRecorder &operator=(const GonkRecorder &);
   1.189 +};
   1.190 +
   1.191 +}  // namespace android
   1.192 +
   1.193 +#endif  // GONK_RECORDER_H_

mercurial