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.

michael@0 1 /*
michael@0 2 * Copyright (C) 2009 The Android Open Source Project
michael@0 3 *
michael@0 4 * Licensed under the Apache License, Version 2.0 (the "License");
michael@0 5 * you may not use this file except in compliance with the License.
michael@0 6 * You may obtain a copy of the License at
michael@0 7 *
michael@0 8 * http://www.apache.org/licenses/LICENSE-2.0
michael@0 9 *
michael@0 10 * Unless required by applicable law or agreed to in writing, software
michael@0 11 * distributed under the License is distributed on an "AS IS" BASIS,
michael@0 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
michael@0 13 * See the License for the specific language governing permissions and
michael@0 14 * limitations under the License.
michael@0 15 */
michael@0 16
michael@0 17 #ifndef GONK_RECORDER_H_
michael@0 18 #define GONK_RECORDER_H_
michael@0 19
michael@0 20 #include "nsISupportsImpl.h"
michael@0 21 #include "GonkCameraHwMgr.h"
michael@0 22
michael@0 23 #include <media/MediaRecorderBase.h>
michael@0 24 #include <camera/CameraParameters.h>
michael@0 25 #include <utils/String8.h>
michael@0 26 #include <system/audio.h>
michael@0 27
michael@0 28 #include "mozilla/RefPtr.h"
michael@0 29 #include "GonkCameraHwMgr.h"
michael@0 30
michael@0 31 namespace android {
michael@0 32
michael@0 33 class GonkCameraSource;
michael@0 34 struct MediaSource;
michael@0 35 struct MediaWriter;
michael@0 36 class MetaData;
michael@0 37 struct AudioSource;
michael@0 38 class MediaProfiles;
michael@0 39 class GonkCameraHardware;
michael@0 40
michael@0 41 struct GonkRecorder {
michael@0 42 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GonkRecorder)
michael@0 43
michael@0 44 GonkRecorder();
michael@0 45
michael@0 46 virtual status_t init();
michael@0 47 virtual status_t setAudioSource(audio_source_t as);
michael@0 48 virtual status_t setVideoSource(video_source vs);
michael@0 49 virtual status_t setOutputFormat(output_format of);
michael@0 50 virtual status_t setAudioEncoder(audio_encoder ae);
michael@0 51 virtual status_t setVideoEncoder(video_encoder ve);
michael@0 52 virtual status_t setVideoSize(int width, int height);
michael@0 53 virtual status_t setVideoFrameRate(int frames_per_second);
michael@0 54 virtual status_t setOutputFile(const char *path);
michael@0 55 virtual status_t setOutputFile(int fd, int64_t offset, int64_t length);
michael@0 56 virtual status_t setParameters(const String8& params);
michael@0 57 virtual status_t setCamera(const sp<GonkCameraHardware>& aCameraHw);
michael@0 58 virtual status_t setListener(const sp<IMediaRecorderClient>& listener);
michael@0 59 virtual status_t setClientName(const String16& clientName);
michael@0 60 virtual status_t prepare();
michael@0 61 virtual status_t start();
michael@0 62 virtual status_t pause();
michael@0 63 virtual status_t stop();
michael@0 64 virtual status_t close();
michael@0 65 virtual status_t reset();
michael@0 66 virtual status_t getMaxAmplitude(int *max);
michael@0 67 virtual status_t dump(int fd, const Vector<String16>& args) const;
michael@0 68 // Querying a SurfaceMediaSourcer
michael@0 69
michael@0 70 protected:
michael@0 71 virtual ~GonkRecorder();
michael@0 72
michael@0 73 private:
michael@0 74 sp<IMediaRecorderClient> mListener;
michael@0 75 String16 mClientName;
michael@0 76 uid_t mClientUid;
michael@0 77 sp<MediaWriter> mWriter;
michael@0 78 int mOutputFd;
michael@0 79 sp<AudioSource> mAudioSourceNode;
michael@0 80
michael@0 81 audio_source_t mAudioSource;
michael@0 82 video_source mVideoSource;
michael@0 83 output_format mOutputFormat;
michael@0 84 audio_encoder mAudioEncoder;
michael@0 85 video_encoder mVideoEncoder;
michael@0 86 bool mUse64BitFileOffset;
michael@0 87 int32_t mVideoWidth, mVideoHeight;
michael@0 88 int32_t mFrameRate;
michael@0 89 int32_t mVideoBitRate;
michael@0 90 int32_t mAudioBitRate;
michael@0 91 int32_t mAudioChannels;
michael@0 92 int32_t mSampleRate;
michael@0 93 int32_t mInterleaveDurationUs;
michael@0 94 int32_t mIFramesIntervalSec;
michael@0 95 int32_t mCameraId;
michael@0 96 int32_t mVideoEncoderProfile;
michael@0 97 int32_t mVideoEncoderLevel;
michael@0 98 int32_t mMovieTimeScale;
michael@0 99 int32_t mVideoTimeScale;
michael@0 100 int32_t mAudioTimeScale;
michael@0 101 int64_t mMaxFileSizeBytes;
michael@0 102 int64_t mMaxFileDurationUs;
michael@0 103 int64_t mTrackEveryTimeDurationUs;
michael@0 104 int32_t mRotationDegrees; // Clockwise
michael@0 105 int32_t mLatitudex10000;
michael@0 106 int32_t mLongitudex10000;
michael@0 107 int32_t mStartTimeOffsetMs;
michael@0 108
michael@0 109 String8 mParams;
michael@0 110
michael@0 111 bool mIsMetaDataStoredInVideoBuffers;
michael@0 112 MediaProfiles *mEncoderProfiles;
michael@0 113
michael@0 114 bool mStarted;
michael@0 115 // Needed when GLFrames are encoded.
michael@0 116 // An <IGraphicBufferProducer> pointer
michael@0 117 // will be sent to the client side using which the
michael@0 118 // frame buffers will be queued and dequeued
michael@0 119
michael@0 120 sp<GonkCameraHardware> mCameraHw;
michael@0 121
michael@0 122 status_t setupMPEG4Recording(
michael@0 123 int outputFd,
michael@0 124 int32_t videoWidth, int32_t videoHeight,
michael@0 125 int32_t videoBitRate,
michael@0 126 int32_t *totalBitRate,
michael@0 127 sp<MediaWriter> *mediaWriter);
michael@0 128 void setupMPEG4MetaData(int64_t startTimeUs, int32_t totalBitRate,
michael@0 129 sp<MetaData> *meta);
michael@0 130 status_t startMPEG4Recording();
michael@0 131 status_t startAMRRecording();
michael@0 132 #if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
michael@0 133 status_t startAACRecording();
michael@0 134 #endif
michael@0 135 status_t startRawAudioRecording();
michael@0 136 status_t startRTPRecording();
michael@0 137 status_t startMPEG2TSRecording();
michael@0 138 sp<MediaSource> createAudioSource();
michael@0 139 status_t checkVideoEncoderCapabilities();
michael@0 140 status_t checkAudioEncoderCapabilities();
michael@0 141 // Generic MediaSource set-up. Returns the appropriate
michael@0 142 // source (CameraSource or SurfaceMediaSource)
michael@0 143 // depending on the videosource type
michael@0 144 status_t setupMediaSource(sp<MediaSource> *mediaSource);
michael@0 145 status_t setupCameraSource(sp<GonkCameraSource> *cameraSource);
michael@0 146 // setup the surfacemediasource for the encoder
michael@0 147
michael@0 148 status_t setupAudioEncoder(const sp<MediaWriter>& writer);
michael@0 149 status_t setupVideoEncoder(
michael@0 150 sp<MediaSource> cameraSource,
michael@0 151 int32_t videoBitRate,
michael@0 152 sp<MediaSource> *source);
michael@0 153
michael@0 154 // Encoding parameter handling utilities
michael@0 155 status_t setParameter(const String8 &key, const String8 &value);
michael@0 156 status_t setParamAudioEncodingBitRate(int32_t bitRate);
michael@0 157 status_t setParamAudioNumberOfChannels(int32_t channles);
michael@0 158 status_t setParamAudioSamplingRate(int32_t sampleRate);
michael@0 159 status_t setParamAudioTimeScale(int32_t timeScale);
michael@0 160 status_t setParamVideoEncodingBitRate(int32_t bitRate);
michael@0 161 status_t setParamVideoIFramesInterval(int32_t seconds);
michael@0 162 status_t setParamVideoEncoderProfile(int32_t profile);
michael@0 163 status_t setParamVideoEncoderLevel(int32_t level);
michael@0 164 status_t setParamVideoCameraId(int32_t cameraId);
michael@0 165 status_t setParamVideoTimeScale(int32_t timeScale);
michael@0 166 status_t setParamVideoRotation(int32_t degrees);
michael@0 167 status_t setParamTrackTimeStatus(int64_t timeDurationUs);
michael@0 168 status_t setParamInterleaveDuration(int32_t durationUs);
michael@0 169 status_t setParam64BitFileOffset(bool use64BitFileOffset);
michael@0 170 status_t setParamMaxFileDurationUs(int64_t timeUs);
michael@0 171 status_t setParamMaxFileSizeBytes(int64_t bytes);
michael@0 172 status_t setParamMovieTimeScale(int32_t timeScale);
michael@0 173 status_t setParamGeoDataLongitude(int64_t longitudex10000);
michael@0 174 status_t setParamGeoDataLatitude(int64_t latitudex10000);
michael@0 175 void clipVideoBitRate();
michael@0 176 void clipVideoFrameRate();
michael@0 177 void clipVideoFrameWidth();
michael@0 178 void clipVideoFrameHeight();
michael@0 179 void clipAudioBitRate();
michael@0 180 void clipAudioSampleRate();
michael@0 181 void clipNumberOfAudioChannels();
michael@0 182 void setDefaultProfileIfNecessary();
michael@0 183
michael@0 184 GonkRecorder(const GonkRecorder &);
michael@0 185 GonkRecorder &operator=(const GonkRecorder &);
michael@0 186 };
michael@0 187
michael@0 188 } // namespace android
michael@0 189
michael@0 190 #endif // GONK_RECORDER_H_

mercurial