dom/camera/GonkRecorderProfiles.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #ifndef DOM_CAMERA_GONK_RECORDER_PROFILES_H
michael@0 6 #define DOM_CAMERA_GONK_RECORDER_PROFILES_H
michael@0 7
michael@0 8 #include <media/MediaProfiles.h>
michael@0 9 #include "CameraRecorderProfiles.h"
michael@0 10 #include "ICameraControl.h"
michael@0 11
michael@0 12 #ifndef CHECK_SETARG
michael@0 13 #define CHECK_SETARG(x) \
michael@0 14 do { \
michael@0 15 if (x) { \
michael@0 16 DOM_CAMERA_LOGE(#x " failed\n"); \
michael@0 17 return NS_ERROR_INVALID_ARG; \
michael@0 18 } \
michael@0 19 } while(0)
michael@0 20 #endif
michael@0 21
michael@0 22
michael@0 23 namespace android {
michael@0 24 class GonkRecorder;
michael@0 25 };
michael@0 26
michael@0 27 namespace mozilla {
michael@0 28
michael@0 29 /**
michael@0 30 * Gonk-specific video profile.
michael@0 31 */
michael@0 32 class GonkRecorderVideoProfile : public RecorderVideoProfile
michael@0 33 {
michael@0 34 public:
michael@0 35 GonkRecorderVideoProfile(uint32_t aCameraId, uint32_t aQualityIndex);
michael@0 36 ~GonkRecorderVideoProfile();
michael@0 37 android::video_encoder GetPlatformCodec() const { return mPlatformCodec; }
michael@0 38
michael@0 39 protected:
michael@0 40 android::video_encoder mPlatformCodec;
michael@0 41 };
michael@0 42
michael@0 43 /**
michael@0 44 * Gonk-specific audio profile.
michael@0 45 */
michael@0 46 class GonkRecorderAudioProfile : public RecorderAudioProfile
michael@0 47 {
michael@0 48 public:
michael@0 49 GonkRecorderAudioProfile(uint32_t aCameraId, uint32_t aQualityIndex);
michael@0 50 ~GonkRecorderAudioProfile();
michael@0 51 android::audio_encoder GetPlatformCodec() const { return mPlatformCodec; }
michael@0 52
michael@0 53 protected:
michael@0 54 android::audio_encoder mPlatformCodec;
michael@0 55 };
michael@0 56
michael@0 57 /**
michael@0 58 * Gonk-specific recorder profile.
michael@0 59 */
michael@0 60 class GonkRecorderProfile : public RecorderProfileBase<GonkRecorderAudioProfile, GonkRecorderVideoProfile>
michael@0 61 {
michael@0 62 public:
michael@0 63 GonkRecorderProfile(uint32_t aCameraId, uint32_t aQualityIndex);
michael@0 64
michael@0 65 GonkRecorderAudioProfile* GetGonkAudioProfile() { return &mAudio; }
michael@0 66 GonkRecorderVideoProfile* GetGonkVideoProfile() { return &mVideo; }
michael@0 67
michael@0 68 android::output_format GetOutputFormat() const { return mPlatformOutputFormat; }
michael@0 69 nsresult ConfigureRecorder(android::GonkRecorder* aRecorder);
michael@0 70
michael@0 71 protected:
michael@0 72 virtual ~GonkRecorderProfile();
michael@0 73
michael@0 74 android::output_format mPlatformOutputFormat;
michael@0 75 };
michael@0 76
michael@0 77 /**
michael@0 78 * Gonk-specific profile manager.
michael@0 79 */
michael@0 80 class GonkRecorderProfileManager : public RecorderProfileManager
michael@0 81 {
michael@0 82 public:
michael@0 83 GonkRecorderProfileManager(uint32_t aCameraId);
michael@0 84
michael@0 85 /**
michael@0 86 * Call this function to indicate that the specified resolutions are in fact
michael@0 87 * supported by the camera hardware. (Just because it appears in a recorder
michael@0 88 * profile doesn't mean the hardware can handle it.)
michael@0 89 */
michael@0 90 void SetSupportedResolutions(const nsTArray<ICameraControl::Size>& aSizes)
michael@0 91 { mSupportedSizes = aSizes; }
michael@0 92
michael@0 93 /**
michael@0 94 * Call this function to remove all resolutions set by calling
michael@0 95 * SetSupportedResolutions().
michael@0 96 */
michael@0 97 void ClearSupportedResolutions() { mSupportedSizes.Clear(); }
michael@0 98
michael@0 99 bool IsSupported(uint32_t aQualityIndex) const;
michael@0 100
michael@0 101 already_AddRefed<RecorderProfile> Get(uint32_t aQualityIndex) const;
michael@0 102 already_AddRefed<GonkRecorderProfile> Get(const char* aProfileName) const;
michael@0 103 nsresult ConfigureRecorder(android::GonkRecorder* aRecorder);
michael@0 104
michael@0 105 protected:
michael@0 106 virtual ~GonkRecorderProfileManager();
michael@0 107
michael@0 108 nsTArray<ICameraControl::Size> mSupportedSizes;
michael@0 109 };
michael@0 110
michael@0 111 }; // namespace mozilla
michael@0 112
michael@0 113 #endif // DOM_CAMERA_GONK_RECORDER_PROFILES_H

mercurial