> For the complete documentation index, see [llms.txt](https://docs.videsk.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.videsk.io/es-developers/componentes-web/webrtc/metodos.md).

# Métodos

Con los métodos de nuestro componente `WebRTC` podrás cambiar el comportamiento de ciertos elementos y conexiones.

## `join`

{% hint style="info" %}
Este método es asíncrono.
{% endhint %}

Este método obtiene acceso a la cámara y/o micrófono para posteriormente añadir las pistas como participante.

Recibe un solo argumento opcional, que corresponde a las restricciones (`constraints`):

```javascript
const constraints = { audio: true, video: true };
await document.querySelector('videsk-webrtc').join(constraints);
```

## `camera`

Este método obtiene acceso a la cámara y micrófono y retorna un stream (`MediaStream`).

Recibe un solo argumento opcional que corresponde a las restricciones (`constraints`). Por defecto el valor es `{ audio: true, video: true }`.

```javascript
const constraints = { audio: true, video: true };
await document.querySelector('videsk-webrtc').camera(constraints);
```

## `display`

Este método obtiene acceso a la función de compartir pantalla y retorna un stream (`MediaStream`).

Recibe un solo argumento que corresponde a las restricciones (`constraints`):

```javascript
const constraints = { audio: true, video: true };
await document.querySelector('videsk-webrtc').display(constraints);
```

## `devices`

Este método obtiene el listado de dispositivos disponibles como cámara, micrófono y altavoz.

No recibe ningún argumento.

{% hint style="info" %}
Podrás usar este método para encontrar un dispositivo en particular o crear una lista seleccionable.
{% endhint %}

```javascript
await document.querySelector('videsk-webrtc').devices();
```

## `changeStream`

Este método cambia el stream actual por uno nuevo reemplazando el existente. Recibe un único argumento el cual corresponde a un `MediaStream`. Adicionalmente, realizará el trabajo de cambiar la pista a nivel local y de red.

{% hint style="danger" %}
No puedes usar este método para cambiar el stream local si aún no hay participantes conectados.
{% endhint %}

{% hint style="info" %}
Te sugerimos utilizar el método [`camera`](#camera) o [`display`](#display) para obtener un nuevo `MediaStream`.
{% endhint %}

```javascript
document.querySelector('videsk-webrtc').changeStream(stream);
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.videsk.io/es-developers/componentes-web/webrtc/metodos.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
