| 1 | /* |
| 2 | * Copyright (C) 2015 Apple Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer |
| 12 | * in the documentation and/or other materials provided with the |
| 13 | * distribution. |
| 14 | * 3. Neither the name of Google Inc. nor the names of its contributors |
| 15 | * may be used to endorse or promote products derived from this |
| 16 | * software without specific prior written permission. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | */ |
| 30 | |
| 31 | #ifndef RealtimeMediaSourceSupportedConstraints_h |
| 32 | #define RealtimeMediaSourceSupportedConstraints_h |
| 33 | |
| 34 | #if ENABLE(MEDIA_STREAM) |
| 35 | |
| 36 | #include <wtf/text/WTFString.h> |
| 37 | |
| 38 | namespace WebCore { |
| 39 | |
| 40 | enum class MediaConstraintType { |
| 41 | Unknown, |
| 42 | Width, |
| 43 | Height, |
| 44 | AspectRatio, |
| 45 | FrameRate, |
| 46 | FacingMode, |
| 47 | Volume, |
| 48 | SampleRate, |
| 49 | SampleSize, |
| 50 | EchoCancellation, |
| 51 | DeviceId, |
| 52 | GroupId, |
| 53 | DisplaySurface, |
| 54 | LogicalSurface, |
| 55 | }; |
| 56 | |
| 57 | class RealtimeMediaSourceSupportedConstraints { |
| 58 | public: |
| 59 | RealtimeMediaSourceSupportedConstraints() |
| 60 | { |
| 61 | } |
| 62 | |
| 63 | bool supportsWidth() const { return m_supportsWidth; } |
| 64 | void setSupportsWidth(bool value) { m_supportsWidth = value; } |
| 65 | |
| 66 | bool supportsHeight() const { return m_supportsHeight; } |
| 67 | void setSupportsHeight(bool value) { m_supportsHeight = value; } |
| 68 | |
| 69 | bool supportsAspectRatio() const { return m_supportsAspectRatio; } |
| 70 | void setSupportsAspectRatio(bool value) { m_supportsAspectRatio = value; } |
| 71 | |
| 72 | bool supportsFrameRate() const { return m_supportsFrameRate; } |
| 73 | void setSupportsFrameRate(bool value) { m_supportsFrameRate = value; } |
| 74 | |
| 75 | bool supportsFacingMode() const { return m_supportsFacingMode; } |
| 76 | void setSupportsFacingMode(bool value) { m_supportsFacingMode = value; } |
| 77 | |
| 78 | bool supportsVolume() const { return m_supportsVolume; } |
| 79 | void setSupportsVolume(bool value) { m_supportsVolume = value; } |
| 80 | |
| 81 | bool supportsSampleRate() const { return m_supportsSampleRate; } |
| 82 | void setSupportsSampleRate(bool value) { m_supportsSampleRate = value; } |
| 83 | |
| 84 | bool supportsSampleSize() const { return m_supportsSampleSize; } |
| 85 | void setSupportsSampleSize(bool value) { m_supportsSampleSize = value; } |
| 86 | |
| 87 | bool supportsEchoCancellation() const { return m_supportsEchoCancellation; } |
| 88 | void setSupportsEchoCancellation(bool value) { m_supportsEchoCancellation = value; } |
| 89 | |
| 90 | bool supportsDeviceId() const { return m_supportsDeviceId; } |
| 91 | void setSupportsDeviceId(bool value) { m_supportsDeviceId = value; } |
| 92 | |
| 93 | bool supportsGroupId() const { return m_supportsGroupId; } |
| 94 | void setSupportsGroupId(bool value) { m_supportsGroupId = value; } |
| 95 | |
| 96 | bool supportsDisplaySurface() const { return m_supportsDisplaySurface; } |
| 97 | void setSupportsDisplaySurface(bool value) { m_supportsDisplaySurface = value; } |
| 98 | |
| 99 | bool supportsLogicalSurface() const { return m_supportsLogicalSurface; } |
| 100 | void setSupportsLogicalSurface(bool value) { m_supportsLogicalSurface = value; } |
| 101 | |
| 102 | bool supportsConstraint(MediaConstraintType) const; |
| 103 | |
| 104 | template<class Encoder> void encode(Encoder&) const; |
| 105 | template<class Decoder> static bool decode(Decoder&, RealtimeMediaSourceSupportedConstraints&); |
| 106 | |
| 107 | private: |
| 108 | bool m_supportsWidth { false }; |
| 109 | bool m_supportsHeight { false }; |
| 110 | bool m_supportsAspectRatio { false }; |
| 111 | bool m_supportsFrameRate { false }; |
| 112 | bool m_supportsFacingMode { false }; |
| 113 | bool m_supportsVolume { false }; |
| 114 | bool m_supportsSampleRate { false }; |
| 115 | bool m_supportsSampleSize { false }; |
| 116 | bool m_supportsEchoCancellation { false }; |
| 117 | bool m_supportsDeviceId { false }; |
| 118 | bool m_supportsGroupId { false }; |
| 119 | bool m_supportsDisplaySurface { false }; |
| 120 | bool m_supportsLogicalSurface { false }; |
| 121 | }; |
| 122 | |
| 123 | template<class Encoder> |
| 124 | void RealtimeMediaSourceSupportedConstraints::encode(Encoder& encoder) const |
| 125 | { |
| 126 | encoder << m_supportsWidth |
| 127 | << m_supportsHeight |
| 128 | << m_supportsAspectRatio |
| 129 | << m_supportsFrameRate |
| 130 | << m_supportsFacingMode |
| 131 | << m_supportsVolume |
| 132 | << m_supportsSampleRate |
| 133 | << m_supportsSampleSize |
| 134 | << m_supportsEchoCancellation |
| 135 | << m_supportsDeviceId |
| 136 | << m_supportsGroupId |
| 137 | << m_supportsDisplaySurface |
| 138 | << m_supportsLogicalSurface; |
| 139 | } |
| 140 | |
| 141 | template<class Decoder> |
| 142 | bool RealtimeMediaSourceSupportedConstraints::decode(Decoder& decoder, RealtimeMediaSourceSupportedConstraints& constraints) |
| 143 | { |
| 144 | return decoder.decode(constraints.m_supportsWidth) |
| 145 | && decoder.decode(constraints.m_supportsHeight) |
| 146 | && decoder.decode(constraints.m_supportsAspectRatio) |
| 147 | && decoder.decode(constraints.m_supportsFrameRate) |
| 148 | && decoder.decode(constraints.m_supportsFacingMode) |
| 149 | && decoder.decode(constraints.m_supportsVolume) |
| 150 | && decoder.decode(constraints.m_supportsSampleRate) |
| 151 | && decoder.decode(constraints.m_supportsSampleSize) |
| 152 | && decoder.decode(constraints.m_supportsEchoCancellation) |
| 153 | && decoder.decode(constraints.m_supportsDeviceId) |
| 154 | && decoder.decode(constraints.m_supportsGroupId) |
| 155 | && decoder.decode(constraints.m_supportsDisplaySurface) |
| 156 | && decoder.decode(constraints.m_supportsLogicalSurface); |
| 157 | } |
| 158 | |
| 159 | } // namespace WebCore |
| 160 | |
| 161 | #endif // ENABLE(MEDIA_STREAM) |
| 162 | |
| 163 | #endif // RealtimeMediaSourceSupportedConstraints_h |
| 164 | |