# ViewportStruct

    struct ViewportStruct

Used as the type for the `viewport` \[CameraAvStreamManagementTrait.Attributes.viewport\]
attribute, allowing control over which part of the camera's image is being streamed or
processed. The viewport is defined as these coordinates:  

(x1,y1) (x2,y1)  
(x1,y2)
(x2,y2)
- `


  ### [x1](https://developers.home.google.com/reference/swift/GoogleHomeTypes/Enums/Google/CameraAvStreamManagementTrait/ViewportStruct#/s:15GoogleHomeTypes0A0O29CameraAvStreamManagementTraitV14ViewportStructV2x1s6UInt16Vvp)


  ` Represents the x-coordinate of the left corners of the viewport.

  #### Declaration

  Swift

      let x1: UInt16

- `


  ### [y1](https://developers.home.google.com/reference/swift/GoogleHomeTypes/Enums/Google/CameraAvStreamManagementTrait/ViewportStruct#/s:15GoogleHomeTypes0A0O29CameraAvStreamManagementTraitV14ViewportStructV2y1s6UInt16Vvp)


  ` Represents the y-coordinate of the top corners of the viewport.

  #### Declaration

  Swift

      let y1: UInt16

- `


  ### [x2](https://developers.home.google.com/reference/swift/GoogleHomeTypes/Enums/Google/CameraAvStreamManagementTrait/ViewportStruct#/s:15GoogleHomeTypes0A0O29CameraAvStreamManagementTraitV14ViewportStructV2x2s6UInt16Vvp)


  ` Represents the x-coordinate of the right corners of the viewport.

  #### Declaration

  Swift

      let x2: UInt16

- `


  ### [y2](https://developers.home.google.com/reference/swift/GoogleHomeTypes/Enums/Google/CameraAvStreamManagementTrait/ViewportStruct#/s:15GoogleHomeTypes0A0O29CameraAvStreamManagementTraitV14ViewportStructV2y2s6UInt16Vvp)


  ` Represents the y-coordinate of the bottom corners of the viewport.

  #### Declaration

  Swift

      let y2: UInt16

- `


  ### [init(decoder:)](https://developers.home.google.com/reference/swift/GoogleHomeTypes/Enums/Google/CameraAvStreamManagementTrait/ViewportStruct#/s:15GoogleHomeTypes0A0O29CameraAvStreamManagementTraitV14ViewportStructV7decoderAG0aB3SDK0H7DecoderV_tKcfc)


  ` Creates a new Struct instance using data read from the given `TraitDecoder`.
  Throws
  `HomeError.parseError` when parsing fails.

  #### Declaration

  Swift

      init(decoder: TraitDecoder) throws

  #### Parameters

  |---|---|
  | ` decoder ` | The raw data representing this Struct. |

- `


  ### [encode(with:)](https://developers.home.google.com/reference/swift/GoogleHomeTypes/Enums/Google/CameraAvStreamManagementTrait/ViewportStruct#/s:15GoogleHomeTypes0A0O29CameraAvStreamManagementTraitV14ViewportStructV6encode4withy0aB3SDK0H7EncoderC_tKF)


  ` Writes this Struct to the given `TraitEncoder`.
  Throws `HomeError.parseError` if the data could not be encoded.

  #### Declaration

  Swift

      func encode(with encoder: TraitEncoder) throws

- `


  ### [structField(id:)](https://developers.home.google.com/reference/swift/GoogleHomeTypes/Enums/Google/CameraAvStreamManagementTrait/ViewportStruct#/s:15GoogleHomeTypes0A0O29CameraAvStreamManagementTraitV14ViewportStructV11structField2id0aB3SDK0L0_pSgs6UInt32V_tFZ)


  ` Returns the field corresponding to the given field ID.

  #### Declaration

  Swift

      static func structField(id: UInt32) -> (any Field)?