2222class Layout implements \JsonSerializable
2323{
2424 public const LAYOUT_BESTFIT = 'bestFit ' ;
25+ public const LAYOUT_CUSTOM = 'custom ' ;
26+ public const LAYOUT_HORIZONTAL = 'horizontalPresentation ' ;
2527 public const LAYOUT_PIP = 'pip ' ;
2628 public const LAYOUT_VERTICAL = 'verticalPresentation ' ;
27- public const LAYOUT_HORIZONTAL = 'horizontalPresentation ' ;
2829
2930 /**
3031 * Type of layout that we are sending
@@ -33,6 +34,13 @@ class Layout implements \JsonSerializable
3334 * */
3435 private $ type ;
3536
37+ /**
38+ * Type of layout to use for screen sharing
39+ * @var string
40+ * @ignore
41+ */
42+ private $ screenshareType ;
43+
3644 /**
3745 * Custom stylesheet if our type is 'custom'
3846 * @var string
@@ -59,14 +67,14 @@ public static function createCustom(array $options): Layout
5967 // NOTE: the default value of stylesheet=null will not pass validation, this essentially
6068 // means that stylesheet is not optional. its still purposely left as part of the
6169 // $options argument so that it can become truly optional in the future.
62- $ defaults = array ( 'stylesheet ' => null ) ;
70+ $ defaults = [ 'stylesheet ' => null ] ;
6371 $ options = array_merge ($ defaults , array_intersect_key ($ options , $ defaults ));
6472 list ($ stylesheet ) = array_values ($ options );
6573
6674 // validate arguments
6775 Validators::validateLayoutStylesheet ($ stylesheet );
6876
69- return new Layout (' custom ' , $ stylesheet );
77+ return new Layout (static :: LAYOUT_CUSTOM , $ stylesheet );
7078 }
7179
7280 /** @ignore */
@@ -111,6 +119,27 @@ public static function getHorizontalPresentation(): Layout
111119 return new Layout (static ::LAYOUT_HORIZONTAL );
112120 }
113121
122+ public function setScreenshareType (string $ screenshareType ): Layout
123+ {
124+ if ($ this ->type === Layout::LAYOUT_BESTFIT ) {
125+ $ layouts = [
126+ Layout::LAYOUT_BESTFIT ,
127+ Layout::LAYOUT_HORIZONTAL ,
128+ Layout::LAYOUT_PIP ,
129+ Layout::LAYOUT_VERTICAL
130+ ];
131+
132+ if (!in_array ($ screenshareType , $ layouts )) {
133+ throw new \RuntimeException ('Screenshare type must be of a valid layout type ' );
134+ }
135+
136+ $ this ->screenshareType = $ screenshareType ;
137+ return $ this ;
138+ }
139+
140+ throw new \RuntimeException ('Screenshare type cannot be set on a layout type other than bestFit ' );
141+ }
142+
114143 public function jsonSerialize ()
115144 {
116145 return $ this ->toArray ();
@@ -134,6 +163,12 @@ public function toArray(): array
134163 if (isset ($ this ->stylesheet )) {
135164 $ data ['stylesheet ' ] = $ this ->stylesheet ;
136165 }
166+
167+ // omit 'screenshareType' property unless it is explicitly defined
168+ if (isset ($ this ->screenshareType )) {
169+ $ data ['screenshareType ' ] = $ this ->screenshareType ;
170+ }
171+
137172 return $ data ;
138173 }
139174}
0 commit comments