MediaEnginePrefs.h (2931B)
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 #include <stdint.h> 11 #include <string.h> 12 13 #include "mozilla/dom/MediaStreamTrackBinding.h" 14 15 namespace mozilla { 16 17 /** 18 * Video source and friends. 19 */ 20 class MediaEnginePrefs { 21 public: 22 static constexpr int DEFAULT_VIDEO_FPS = 30; 23 static constexpr int DEFAULT_43_VIDEO_WIDTH = 640; 24 static constexpr int DEFAULT_43_VIDEO_HEIGHT = 480; 25 static constexpr int DEFAULT_169_VIDEO_WIDTH = 1280; 26 static constexpr int DEFAULT_169_VIDEO_HEIGHT = 720; 27 28 MediaEnginePrefs() 29 : mWidth(0), 30 mHeight(0), 31 mResizeModeEnabled(false), 32 mResizeMode(dom::VideoResizeModeEnum::None), 33 mFPS(0), 34 mFreq(0), 35 mUsePlatformProcessing(false), 36 mAecOn(false), 37 mUseAecMobile(false), 38 mAgcOn(false), 39 mHPFOn(false), 40 mNoiseOn(false), 41 mTransientOn(false), 42 mAgc2Forced(false), 43 mExpectDrift(-1), // auto 44 mAgc(0), 45 mNoise(0), 46 mChannels(0) {} 47 48 int32_t mWidth; 49 int32_t mHeight; 50 bool mResizeModeEnabled; 51 dom::VideoResizeModeEnum mResizeMode; 52 int32_t mFPS; 53 int32_t mFreq; // for test tones (fake:true) 54 bool mUsePlatformProcessing; 55 bool mAecOn; 56 bool mUseAecMobile; 57 bool mAgcOn; 58 bool mHPFOn; 59 bool mNoiseOn; 60 bool mTransientOn; 61 bool mAgc2Forced; 62 int32_t mExpectDrift; 63 int32_t mAgc; 64 int32_t mNoise; 65 int32_t mChannels; 66 67 bool operator==(const MediaEnginePrefs& aRhs) { 68 return memcmp(this, &aRhs, sizeof(MediaEnginePrefs)) == 0; 69 }; 70 71 // mWidth and/or mHeight may be zero (=adaptive default), so use functions. 72 73 int32_t GetWidth(bool aHD = false) const { 74 return mWidth ? mWidth 75 : (mHeight ? (mHeight * GetDefWidth(aHD)) / GetDefHeight(aHD) 76 : GetDefWidth(aHD)); 77 } 78 79 int32_t GetHeight(bool aHD = false) const { 80 return mHeight ? mHeight 81 : (mWidth ? (mWidth * GetDefHeight(aHD)) / GetDefWidth(aHD) 82 : GetDefHeight(aHD)); 83 } 84 85 private: 86 static int32_t GetDefWidth(bool aHD = false) { 87 // It'd be nice if we could use the ternary operator here, but we can't 88 // because of bug 1002729. 89 if (aHD) { 90 return DEFAULT_169_VIDEO_WIDTH; 91 } 92 93 return DEFAULT_43_VIDEO_WIDTH; 94 } 95 96 static int32_t GetDefHeight(bool aHD = false) { 97 // It'd be nice if we could use the ternary operator here, but we can't 98 // because of bug 1002729. 99 if (aHD) { 100 return DEFAULT_169_VIDEO_HEIGHT; 101 } 102 103 return DEFAULT_43_VIDEO_HEIGHT; 104 } 105 }; 106 107 } // namespace mozilla 108 109 #endif // MediaEnginePrefs_h