

# Abilitazione della condivisione dello schermo nella composizione lato server di IVS
<a name="ssc-getting-started-screen-share"></a>

Per utilizzare un layout di condivisione dello schermo fisso, completa la procedura riportata di seguito.

## Creazione della risorsa EncoderConfiguration
<a name="ssc-getting-started-screen-share-create-encoderconfiguration"></a>

Il comando seguente crea una risorsa EncoderConfiguration che configura i parametri di composizione lato server (bitrate video, framerate e risoluzione).

```
aws ivs-realtime create-encoder-configuration --name "test-ssc-with-screen-share" --video={bitrate=2000000,framerate=30,height=720,width=1280}
```

Crea un token per i partecipanti alla fase con un attributo `screen-share`. Poiché specificheremo `screen-share` come nome dello slot `featured`, dobbiamo creare un token di fase con l'attributo `screen-share` impostato su `true`:

```
aws ivs-realtime create-participant-token --stage-arn "arn:aws:ivs:us-east-1:123456789012:stage/u9OiE29bT7Xp" --attributes screen-share=true
```

La risposta è:

```
{
   "participantToken": {
      "attributes": {
         "screen-share": "true"
      },
      "expirationTime": "2023-08-04T05:26:11+00:00",
      "participantId": "E813MFklPWLF",
      "token": "eyJhbGciOiJLTVMiLCJ0eXAiOiJKV1QifQ.eyJleHAiOjE2OTExMjY3NzEsImlhdCI6MTY5MTA4MzU3MSwianRpIjoiRTgxM01Ga2xQV0xGIiwicmVzb3VyY2UiOiJhcm46YXdzOml2czp1cy1lYXN0LTE6OTI3ODEwOTY3Mjk5OnN0YWdlL3U5T2lFMjliVDdYcCIsInRvcGljIjoidTlPaUUyOWJUN1hwIiwiZXZlbnRzX3VybCI6IndzczovL3VzLWVhc3QtMS5ldmVudHMubGl2ZS12aWRlby5uZXQiLCJ3aGlwX3VybCI6Imh0dHBzOi8vYjJlYTVjMmZmMzU1Lmdsb2JhbC53aGlwLmxpdmUtdmlkZW8ubmV0IiwiYXR0cmlidXRlcyI6eyJzY3JlZW4tc2hhcmUiOiJ0cnVlIn0sImNhcGFiaWxpdGllcyI6eyJhbGxvd19wdWJsaXNoIjp0cnVlLCJhbGxvd19zdWJzY3JpYmUiOnRydWV9LCJ2ZXJzaW9uIjoiMC4zIn0.MGUCMFvMzv35O4yVzM9tIWZl7n3mmFQhleqsRSBx_G2qT2YUDlWSNg6H1vL7sAWQMeydSAIxAIvdfqt3Fh1MLiyelc9NnTjI5hL3YPKqDX6J3NDH1fksh8_5y1jztoPDy4yVA5OmtA"
   }
}
```

## Inizio della composizione
<a name="ssc-getting-started-screen-share-start-mediapublish"></a>

Per iniziare la composizione utilizzando la funzione di condivisione dello schermo, utilizziamo questo comando:

```
aws ivs-realtime start-composition --stage-arn "arn:aws:ivs:us-east-1:927810967299:stage/8faHz1SQp0ik" --destinations  '[{"channel": {"channelArn": "arn:aws:ivs:us-east-1:927810967299:channel/DOlMW4dfMR8r", "encoderConfigurationArn": "arn:aws:ivs:us-east-1:927810967299:encoder-configuration/DEkQHWPVaOwO"}}]' --layout '{"grid":{"featuredParticipantAttribute":"screen-share"}}'
```

La risposta è:

```
{
"composition" : {
"arn" : "arn:aws:ivs:us-east-1:927810967299:composition/B19tQcXRgtoz",
"destinations" : [ {
 "configuration" : {
	"channel" : {
	   "channelArn" : "arn:aws:ivs:us-east-1:927810967299:channel/DOlMW4dfMR8r",
	   "encoderConfigurationArn" : "arn:aws:ivs:us-east-1:927810967299:encoder-configuration/DEkQHWPVaOwO"
	},
	"name" : ""
 },
 "id" : "SGmgBXTULuXv",
 "state" : "STARTING"
} ],
"layout" : {
 "grid" : {
	"featuredParticipantAttribute" : "screen-share",
	"gridGap": 2,
	"omitStoppedVideo": false,
	"videoAspectRatio": "VIDEO"
 }
},
"stageArn" : "arn:aws:ivs:us-east-1:927810967299:stage/8faHz1SQp0ik",
"startTime" : "2023-09-27T21:32:38Z",
"state" : "STARTING",
"tags" : { }
}
}
```

Quando il partecipante alla fase `E813MFklPWLF` si unisce alla fase, il video di quel partecipante verrà visualizzato nello slot in evidenza e tutti gli altri publisher della fase saranno visualizzati sotto lo slot:

![\[Inizio della composizione utilizzando la funzione di condivisione dello schermo.\]](http://docs.aws.amazon.com/it_it/ivs/latest/RealTimeUserGuide/images/ssc_StartComposition.png)


## Arresto della composizione
<a name="ssc-getting-started-screen-share-stop-mediapublish"></a>

Per arrestare una composizione in qualsiasi momento, chiama l'operazione StopComposition:

```
aws ivs-realtime stop-composition --arn arn:aws:ivs:us-east-1:927810967299:composition/B19tQcXRgtoz
```