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.video;
017
018import com.fasterxml.jackson.annotation.JsonProperty;
019import com.vonage.client.JsonableBaseObject;
020import java.util.Arrays;
021import java.util.List;
022import java.util.UUID;
023
024/**
025 * Represents a stream's metadata in a Vonage Video session.
026 * Used for updating the stream layout in {@link VideoClient#setStreamLayout(String, List)}.
027 */
028public class SessionStream extends JsonableBaseObject {
029        private UUID id;
030        private List<String> layoutClassList;
031
032        protected SessionStream() {
033        }
034
035        protected SessionStream(Builder builder) {
036                id = builder.id;
037                layoutClassList = builder.layoutClassList;
038        }
039
040        /**
041         * @return The stream ID.
042         */
043        @JsonProperty("id")
044        public UUID getId() {
045                return id;
046        }
047
048        /**
049         * @return The layout classes for this stream.
050         */
051        @JsonProperty("layoutClassList")
052        public List<String> getLayoutClassList() {
053                return layoutClassList;
054        }
055
056        /**
057         * Entry point for building an instance of .
058         *
059         * @param streamId The ID of the stream.
060         *
061         * @return A new {@linkplain Builder} with the specified streamId property.
062         */
063        public static Builder builder(String streamId) {
064                return new Builder(streamId);
065        }
066
067        public static class Builder {
068                private final UUID id;
069                private List<String> layoutClassList;
070
071                protected Builder(String id) {
072                        this.id = UUID.fromString(id);
073                }
074
075                /**
076                 * Use this method to set the layout classes for the stream.
077                 *
078                 * @param layoutClassList The updated layout classes to use for this stream.
079                 *
080                 * @return This builder.
081                 */
082                public Builder layoutClassList(List<String> layoutClassList) {
083                        this.layoutClassList = layoutClassList;
084                        return this;
085                }
086
087                /**
088                 * Use this method to set the layout classes for the stream.
089                 *
090                 * @param layoutClasses The updated layout classes to use for this stream.
091                 *
092                 * @return This builder.
093                 * @see #layoutClassList(List)
094                 * @since 8.0.0-beta2
095                 */
096                public Builder layoutClassList(String... layoutClasses) {
097                        return layoutClassList(Arrays.asList(layoutClasses));
098                }
099
100                /**
101                 * Constructs an instance of SessionStream.
102                 *
103                 * @return A new {@linkplain SessionStream} object with this builder's properties.
104                 */
105                public SessionStream build() {
106                        return new SessionStream(this);
107                }
108        }
109}