001/* 002 * Copyright 2024 Vonage 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package com.vonage.client.conversations; 017 018import com.fasterxml.jackson.annotation.JsonProperty; 019import com.vonage.client.JsonableBaseObject; 020 021/** 022 * Contains the media properties for {@link Member#getMedia()}. 023 */ 024public final class MemberMedia extends JsonableBaseObject { 025 private Boolean audio; 026 private MediaAudioSettings audioSettings; 027 028 MemberMedia(Builder builder) { 029 audio = builder.audio; 030 audioSettings = builder.audioSettings; 031 } 032 033 MemberMedia() { 034 } 035 036 /** 037 * Whether the media has audio. 038 * 039 * @return {@code true} if audio is present, or {@code null} if unspecified. 040 */ 041 @JsonProperty("audio") 042 public Boolean getAudio() { 043 return audio; 044 } 045 046 /** 047 * Audio-related properties. 048 * 049 * @return The audio settings object, or {@code null} if not applicable. 050 */ 051 @JsonProperty("audio_settings") 052 public MediaAudioSettings getAudioSettings() { 053 return audioSettings; 054 } 055 056 057 /** 058 * Entry point for constructing an instance of this class. 059 * 060 * @return A new Builder. 061 */ 062 public static Builder builder() { 063 return new Builder(); 064 } 065 066 /** 067 * Builder for constructing MemberMedia. All fields are optional. 068 */ 069 public static final class Builder { 070 private Boolean audio; 071 private MediaAudioSettings audioSettings; 072 073 private Builder() {} 074 075 private MediaAudioSettings initAudioSettings() { 076 if (audioSettings == null) { 077 audioSettings = new MediaAudioSettings(); 078 } 079 return audioSettings; 080 } 081 082 /** 083 * 084 * @param audio 085 * 086 * @return This builder. 087 */ 088 public Builder audio(boolean audio) { 089 this.audio = audio; 090 return this; 091 } 092 093 /** 094 * 095 * @param enabled 096 * 097 * @return This builder. 098 */ 099 public Builder audioEnabled(boolean enabled) { 100 initAudioSettings().enabled = enabled; 101 return this; 102 } 103 104 /** 105 * 106 * @param earmuffed 107 * 108 * @return This builder. 109 */ 110 public Builder earmuffed(boolean earmuffed) { 111 initAudioSettings().earmuffed = earmuffed; 112 return this; 113 } 114 115 /** 116 * 117 * @param muted 118 * 119 * @return This builder. 120 */ 121 public Builder muted(boolean muted) { 122 initAudioSettings().muted = muted; 123 return this; 124 } 125 126 /** 127 * Builds the {@linkplain MemberMedia}. 128 * 129 * @return An instance of MemberMedia, populated with all fields from this builder. 130 */ 131 public MemberMedia build() { 132 return new MemberMedia(this); 133 } 134 } 135}