> 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
