

# Activation du partage d'écran dans le montage côté serveur IVS
<a name="ssc-getting-started-screen-share"></a>

Pour utiliser une disposition de partage d’écran fixe, suivez les étapes indiquées ci-dessous.

## Création de la ressource EncoderConfiguration
<a name="ssc-getting-started-screen-share-create-encoderconfiguration"></a>

La commande ci-dessous crée une ressource EncoderConfiguration qui configure les paramètres de montage côté serveur (débit vidéo, fréquence d’images et résolution).

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

Créez un jeton de participant à la scène avec un attribut `screen-share`. Comme nous allons spécifier `screen-share` en tant que nom de l’emplacement `featured`, nous devons créer un jeton de scène dont l’attribut `screen-share` est défini sur `true` :

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

La réponse est :

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

## Commencer le montage
<a name="ssc-getting-started-screen-share-start-mediapublish"></a>

Pour démarrer le montage à l’aide de la fonctionnalité de partage d’écran, nous utilisons cette commande :

```
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 réponse est :

```
{
"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" : { }
}
}
```

Lorsque le participant `E813MFklPWLF` rejoint la scène, la vidéo de ce participant sera affichée dans l’emplacement en vedette, et tous les autres diffuseurs de publication d’scène seront affichés en dessous de l’emplacement :

![\[Démarrer le montage à l’aide de la fonctionnalité de partage d’écran.\]](http://docs.aws.amazon.com/fr_fr/ivs/latest/RealTimeUserGuide/images/ssc_StartComposition.png)


## Arrêter le montage
<a name="ssc-getting-started-screen-share-stop-mediapublish"></a>

Pour arrêter un montage à tout moment, appelez l’opération StopComposition :

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