dom/camera/GonkRecorder.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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  */
    17 #ifndef GONK_RECORDER_H_
    18 #define GONK_RECORDER_H_
    20 #include "nsISupportsImpl.h"
    21 #include "GonkCameraHwMgr.h"
    23 #include <media/MediaRecorderBase.h>
    24 #include <camera/CameraParameters.h>
    25 #include <utils/String8.h>
    26 #include <system/audio.h>
    28 #include "mozilla/RefPtr.h"
    29 #include "GonkCameraHwMgr.h"
    31 namespace android {
    33 class GonkCameraSource;
    34 struct MediaSource;
    35 struct MediaWriter;
    36 class MetaData;
    37 struct AudioSource;
    38 class MediaProfiles;
    39 class GonkCameraHardware;
    41 struct GonkRecorder {
    42     NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GonkRecorder)
    44     GonkRecorder();
    46     virtual status_t init();
    47     virtual status_t setAudioSource(audio_source_t as);
    48     virtual status_t setVideoSource(video_source vs);
    49     virtual status_t setOutputFormat(output_format of);
    50     virtual status_t setAudioEncoder(audio_encoder ae);
    51     virtual status_t setVideoEncoder(video_encoder ve);
    52     virtual status_t setVideoSize(int width, int height);
    53     virtual status_t setVideoFrameRate(int frames_per_second);
    54     virtual status_t setOutputFile(const char *path);
    55     virtual status_t setOutputFile(int fd, int64_t offset, int64_t length);
    56     virtual status_t setParameters(const String8& params);
    57     virtual status_t setCamera(const sp<GonkCameraHardware>& aCameraHw);
    58     virtual status_t setListener(const sp<IMediaRecorderClient>& listener);
    59     virtual status_t setClientName(const String16& clientName);
    60     virtual status_t prepare();
    61     virtual status_t start();
    62     virtual status_t pause();
    63     virtual status_t stop();
    64     virtual status_t close();
    65     virtual status_t reset();
    66     virtual status_t getMaxAmplitude(int *max);
    67     virtual status_t dump(int fd, const Vector<String16>& args) const;
    68     // Querying a SurfaceMediaSourcer
    70 protected:
    71     virtual ~GonkRecorder();
    73 private:
    74     sp<IMediaRecorderClient> mListener;
    75     String16 mClientName;
    76     uid_t mClientUid;
    77     sp<MediaWriter> mWriter;
    78     int mOutputFd;
    79     sp<AudioSource> mAudioSourceNode;
    81     audio_source_t mAudioSource;
    82     video_source mVideoSource;
    83     output_format mOutputFormat;
    84     audio_encoder mAudioEncoder;
    85     video_encoder mVideoEncoder;
    86     bool mUse64BitFileOffset;
    87     int32_t mVideoWidth, mVideoHeight;
    88     int32_t mFrameRate;
    89     int32_t mVideoBitRate;
    90     int32_t mAudioBitRate;
    91     int32_t mAudioChannels;
    92     int32_t mSampleRate;
    93     int32_t mInterleaveDurationUs;
    94     int32_t mIFramesIntervalSec;
    95     int32_t mCameraId;
    96     int32_t mVideoEncoderProfile;
    97     int32_t mVideoEncoderLevel;
    98     int32_t mMovieTimeScale;
    99     int32_t mVideoTimeScale;
   100     int32_t mAudioTimeScale;
   101     int64_t mMaxFileSizeBytes;
   102     int64_t mMaxFileDurationUs;
   103     int64_t mTrackEveryTimeDurationUs;
   104     int32_t mRotationDegrees;  // Clockwise
   105     int32_t mLatitudex10000;
   106     int32_t mLongitudex10000;
   107     int32_t mStartTimeOffsetMs;
   109     String8 mParams;
   111     bool mIsMetaDataStoredInVideoBuffers;
   112     MediaProfiles *mEncoderProfiles;
   114     bool mStarted;
   115     // Needed when GLFrames are encoded.
   116     // An <IGraphicBufferProducer> pointer
   117     // will be sent to the client side using which the
   118     // frame buffers will be queued and dequeued
   120     sp<GonkCameraHardware> mCameraHw;
   122     status_t setupMPEG4Recording(
   123         int outputFd,
   124         int32_t videoWidth, int32_t videoHeight,
   125         int32_t videoBitRate,
   126         int32_t *totalBitRate,
   127         sp<MediaWriter> *mediaWriter);
   128     void setupMPEG4MetaData(int64_t startTimeUs, int32_t totalBitRate,
   129         sp<MetaData> *meta);
   130     status_t startMPEG4Recording();
   131     status_t startAMRRecording();
   132 #if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
   133     status_t startAACRecording();
   134 #endif
   135     status_t startRawAudioRecording();
   136     status_t startRTPRecording();
   137     status_t startMPEG2TSRecording();
   138     sp<MediaSource> createAudioSource();
   139     status_t checkVideoEncoderCapabilities();
   140     status_t checkAudioEncoderCapabilities();
   141     // Generic MediaSource set-up. Returns the appropriate
   142     // source (CameraSource or SurfaceMediaSource)
   143     // depending on the videosource type
   144     status_t setupMediaSource(sp<MediaSource> *mediaSource);
   145     status_t setupCameraSource(sp<GonkCameraSource> *cameraSource);
   146     // setup the surfacemediasource for the encoder
   148     status_t setupAudioEncoder(const sp<MediaWriter>& writer);
   149     status_t setupVideoEncoder(
   150             sp<MediaSource> cameraSource,
   151             int32_t videoBitRate,
   152             sp<MediaSource> *source);
   154     // Encoding parameter handling utilities
   155     status_t setParameter(const String8 &key, const String8 &value);
   156     status_t setParamAudioEncodingBitRate(int32_t bitRate);
   157     status_t setParamAudioNumberOfChannels(int32_t channles);
   158     status_t setParamAudioSamplingRate(int32_t sampleRate);
   159     status_t setParamAudioTimeScale(int32_t timeScale);
   160     status_t setParamVideoEncodingBitRate(int32_t bitRate);
   161     status_t setParamVideoIFramesInterval(int32_t seconds);
   162     status_t setParamVideoEncoderProfile(int32_t profile);
   163     status_t setParamVideoEncoderLevel(int32_t level);
   164     status_t setParamVideoCameraId(int32_t cameraId);
   165     status_t setParamVideoTimeScale(int32_t timeScale);
   166     status_t setParamVideoRotation(int32_t degrees);
   167     status_t setParamTrackTimeStatus(int64_t timeDurationUs);
   168     status_t setParamInterleaveDuration(int32_t durationUs);
   169     status_t setParam64BitFileOffset(bool use64BitFileOffset);
   170     status_t setParamMaxFileDurationUs(int64_t timeUs);
   171     status_t setParamMaxFileSizeBytes(int64_t bytes);
   172     status_t setParamMovieTimeScale(int32_t timeScale);
   173     status_t setParamGeoDataLongitude(int64_t longitudex10000);
   174     status_t setParamGeoDataLatitude(int64_t latitudex10000);
   175     void clipVideoBitRate();
   176     void clipVideoFrameRate();
   177     void clipVideoFrameWidth();
   178     void clipVideoFrameHeight();
   179     void clipAudioBitRate();
   180     void clipAudioSampleRate();
   181     void clipNumberOfAudioChannels();
   182     void setDefaultProfileIfNecessary();
   184     GonkRecorder(const GonkRecorder &);
   185     GonkRecorder &operator=(const GonkRecorder &);
   186 };
   188 }  // namespace android
   190 #endif  // GONK_RECORDER_H_

mercurial