1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef MediaEnginePrefs_h 8 #define MediaEnginePrefs_h 9 10 namespace mozilla { 11 12 /** 13 * Video source and friends. 14 */ 15 class MediaEnginePrefs { 16 public: 17 static const int DEFAULT_VIDEO_FPS = 30; 18 static const int DEFAULT_43_VIDEO_WIDTH = 640; 19 static const int DEFAULT_43_VIDEO_HEIGHT = 480; 20 static const int DEFAULT_169_VIDEO_WIDTH = 1280; 21 static const int DEFAULT_169_VIDEO_HEIGHT = 720; 22 MediaEnginePrefs()23 MediaEnginePrefs() 24 : mWidth(0), 25 mHeight(0), 26 mFPS(0), 27 mFreq(0), 28 mAecOn(false), 29 mUseAecMobile(false), 30 mAgcOn(false), 31 mHPFOn(false), 32 mNoiseOn(false), 33 mAec(0), 34 mAgc(0), 35 mRoutingMode(0), 36 mNoise(0), 37 mExtendedFilter(false), 38 mDelayAgnostic(false), 39 mFakeDeviceChangeEventOn(false), 40 mChannels(0) {} 41 42 int32_t mWidth; 43 int32_t mHeight; 44 int32_t mFPS; 45 int32_t mFreq; // for test tones (fake:true) 46 bool mAecOn; 47 bool mUseAecMobile; 48 bool mAgcOn; 49 bool mHPFOn; 50 bool mNoiseOn; 51 int32_t mAec; 52 int32_t mAgc; 53 int32_t mRoutingMode; 54 int32_t mNoise; 55 bool mExtendedFilter; 56 bool mDelayAgnostic; 57 bool mFakeDeviceChangeEventOn; 58 int32_t mChannels; 59 60 bool operator==(const MediaEnginePrefs& aRhs) { 61 return memcmp(this, &aRhs, sizeof(MediaEnginePrefs)) == 0; 62 }; 63 64 // mWidth and/or mHeight may be zero (=adaptive default), so use functions. 65 66 int32_t GetWidth(bool aHD = false) const { 67 return mWidth ? mWidth 68 : (mHeight ? (mHeight * GetDefWidth(aHD)) / GetDefHeight(aHD) 69 : GetDefWidth(aHD)); 70 } 71 72 int32_t GetHeight(bool aHD = false) const { 73 return mHeight ? mHeight 74 : (mWidth ? (mWidth * GetDefHeight(aHD)) / GetDefWidth(aHD) 75 : GetDefHeight(aHD)); 76 } 77 78 private: 79 static int32_t GetDefWidth(bool aHD = false) { 80 // It'd be nice if we could use the ternary operator here, but we can't 81 // because of bug 1002729. 82 if (aHD) { 83 return DEFAULT_169_VIDEO_WIDTH; 84 } 85 86 return DEFAULT_43_VIDEO_WIDTH; 87 } 88 89 static int32_t GetDefHeight(bool aHD = false) { 90 // It'd be nice if we could use the ternary operator here, but we can't 91 // because of bug 1002729. 92 if (aHD) { 93 return DEFAULT_169_VIDEO_HEIGHT; 94 } 95 96 return DEFAULT_43_VIDEO_HEIGHT; 97 } 98 }; 99 100 } // namespace mozilla 101 102 #endif // MediaEnginePrefs_h 103