dom/camera/GonkCameraSource.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_CAMERA_SOURCE_H_
    19 #define GONK_CAMERA_SOURCE_H_
    21 #include <media/stagefright/MediaBuffer.h>
    22 #include <media/stagefright/MediaSource.h>
    23 #include <camera/CameraParameters.h>
    24 #include <utils/List.h>
    25 #include <utils/RefBase.h>
    26 #include <utils/String16.h>
    28 #include "GonkCameraHwMgr.h"
    30 namespace android {
    32 class IMemory;
    34 class GonkCameraSource : public MediaSource, public MediaBufferObserver {
    35 public:
    37     static GonkCameraSource *Create(const sp<GonkCameraHardware>& aCameraHw,
    38                                     Size videoSize,
    39                                     int32_t frameRate,
    40                                     bool storeMetaDataInVideoBuffers = false);
    42     virtual ~GonkCameraSource();
    44     virtual status_t start(MetaData *params = NULL);
    45     virtual status_t stop() { return reset(); }
    46     virtual status_t read(
    47             MediaBuffer **buffer, const ReadOptions *options = NULL);
    49     /**
    50      * Check whether a GonkCameraSource object is properly initialized.
    51      * Must call this method before stop().
    52      * @return OK if initialization has successfully completed.
    53      */
    54     virtual status_t initCheck() const;
    56     /**
    57      * Returns the MetaData associated with the GonkCameraSource,
    58      * including:
    59      * kKeyColorFormat: YUV color format of the video frames
    60      * kKeyWidth, kKeyHeight: dimension (in pixels) of the video frames
    61      * kKeySampleRate: frame rate in frames per second
    62      * kKeyMIMEType: always fixed to be MEDIA_MIMETYPE_VIDEO_RAW
    63      */
    64     virtual sp<MetaData> getFormat();
    66     /**
    67      * Tell whether this camera source stores meta data or real YUV
    68      * frame data in video buffers.
    69      *
    70      * @return true if meta data is stored in the video
    71      *      buffers; false if real YUV data is stored in
    72      *      the video buffers.
    73      */
    74     bool isMetaDataStoredInVideoBuffers() const;
    76     virtual void signalBufferReturned(MediaBuffer* buffer);
    78 protected:
    80     enum CameraFlags {
    81         FLAGS_SET_CAMERA = 1L << 0,
    82         FLAGS_HOT_CAMERA = 1L << 1,
    83     };
    85     int32_t  mCameraFlags;
    86     Size     mVideoSize;
    87     int32_t  mNumInputBuffers;
    88     int32_t  mVideoFrameRate;
    89     int32_t  mColorFormat;
    90     status_t mInitCheck;
    92     sp<MetaData> mMeta;
    94     int64_t mStartTimeUs;
    95     int32_t mNumFramesReceived;
    96     int64_t mLastFrameTimestampUs;
    97     bool mStarted;
    98     int32_t mNumFramesEncoded;
   100     // Time between capture of two frames.
   101     int64_t mTimeBetweenFrameCaptureUs;
   103     GonkCameraSource(const sp<GonkCameraHardware>& aCameraHw,
   104                  Size videoSize, int32_t frameRate,
   105                  bool storeMetaDataInVideoBuffers = false);
   107     virtual int startCameraRecording();
   108     virtual void stopCameraRecording();
   109     virtual void releaseRecordingFrame(const sp<IMemory>& frame);
   111     // Returns true if need to skip the current frame.
   112     // Called from dataCallbackTimestamp.
   113     virtual bool skipCurrentFrame(int64_t timestampUs) {return false;}
   115     friend class GonkCameraSourceListener;
   116     // Callback called when still camera raw data is available.
   117     virtual void dataCallback(int32_t msgType, const sp<IMemory> &data) {}
   119     virtual void dataCallbackTimestamp(int64_t timestampUs, int32_t msgType,
   120             const sp<IMemory> &data);
   122 private:
   124     Mutex mLock;
   125     Condition mFrameAvailableCondition;
   126     Condition mFrameCompleteCondition;
   127     List<sp<IMemory> > mFramesReceived;
   128     List<sp<IMemory> > mFramesBeingEncoded;
   129     List<int64_t> mFrameTimes;
   131     int64_t mFirstFrameTimeUs;
   132     int32_t mNumFramesDropped;
   133     int32_t mNumGlitches;
   134     int64_t mGlitchDurationThresholdUs;
   135     bool mCollectStats;
   136     bool mIsMetaDataStoredInVideoBuffers;
   137     sp<GonkCameraHardware> mCameraHw;
   139     void releaseQueuedFrames();
   140     void releaseOneRecordingFrame(const sp<IMemory>& frame);
   142     status_t init(Size videoSize, int32_t frameRate,
   143                   bool storeMetaDataInVideoBuffers);
   144     status_t isCameraColorFormatSupported(const CameraParameters& params);
   145     status_t configureCamera(CameraParameters* params,
   146                     int32_t width, int32_t height,
   147                     int32_t frameRate);
   149     status_t checkVideoSize(const CameraParameters& params,
   150                     int32_t width, int32_t height);
   152     status_t checkFrameRate(const CameraParameters& params,
   153                     int32_t frameRate);
   155     void releaseCamera();
   156     status_t reset();
   158     GonkCameraSource(const GonkCameraSource &);
   159     GonkCameraSource &operator=(const GonkCameraSource &);
   160 };
   162 }  // namespace android
   164 #endif  // GONK_CAMERA_SOURCE_H_

mercurial