summaryrefslogtreecommitdiffstats
path: root/dom/media/webrtc/MediaEnginePrefs.h
blob: e3eff7eba5eb0184fba090dd47b9794c870874c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef MediaEnginePrefs_h
#define MediaEnginePrefs_h

#include <stdint.h>
#include <string.h>

namespace mozilla {

/**
 * Video source and friends.
 */
class MediaEnginePrefs {
 public:
  static const int DEFAULT_VIDEO_FPS = 30;
  static const int DEFAULT_43_VIDEO_WIDTH = 640;
  static const int DEFAULT_43_VIDEO_HEIGHT = 480;
  static const int DEFAULT_169_VIDEO_WIDTH = 1280;
  static const int DEFAULT_169_VIDEO_HEIGHT = 720;

  MediaEnginePrefs()
      : mWidth(0),
        mHeight(0),
        mFPS(0),
        mFreq(0),
        mUsePlatformProcessing(false),
        mAecOn(false),
        mUseAecMobile(false),
        mAgcOn(false),
        mHPFOn(false),
        mNoiseOn(false),
        mTransientOn(false),
        mAgc2Forced(false),
        mExpectDrift(-1),  // auto
        mAgc(0),
        mNoise(0),
        mChannels(0) {}

  int32_t mWidth;
  int32_t mHeight;
  int32_t mFPS;
  int32_t mFreq;  // for test tones (fake:true)
  bool mUsePlatformProcessing;
  bool mAecOn;
  bool mUseAecMobile;
  bool mAgcOn;
  bool mHPFOn;
  bool mNoiseOn;
  bool mTransientOn;
  bool mAgc2Forced;
  int32_t mExpectDrift;
  int32_t mAgc;
  int32_t mNoise;
  int32_t mChannels;

  bool operator==(const MediaEnginePrefs& aRhs) {
    return memcmp(this, &aRhs, sizeof(MediaEnginePrefs)) == 0;
  };

  // mWidth and/or mHeight may be zero (=adaptive default), so use functions.

  int32_t GetWidth(bool aHD = false) const {
    return mWidth ? mWidth
                  : (mHeight ? (mHeight * GetDefWidth(aHD)) / GetDefHeight(aHD)
                             : GetDefWidth(aHD));
  }

  int32_t GetHeight(bool aHD = false) const {
    return mHeight ? mHeight
                   : (mWidth ? (mWidth * GetDefHeight(aHD)) / GetDefWidth(aHD)
                             : GetDefHeight(aHD));
  }

 private:
  static int32_t GetDefWidth(bool aHD = false) {
    // It'd be nice if we could use the ternary operator here, but we can't
    // because of bug 1002729.
    if (aHD) {
      return DEFAULT_169_VIDEO_WIDTH;
    }

    return DEFAULT_43_VIDEO_WIDTH;
  }

  static int32_t GetDefHeight(bool aHD = false) {
    // It'd be nice if we could use the ternary operator here, but we can't
    // because of bug 1002729.
    if (aHD) {
      return DEFAULT_169_VIDEO_HEIGHT;
    }

    return DEFAULT_43_VIDEO_HEIGHT;
  }
};

}  // namespace mozilla

#endif  // MediaEnginePrefs_h