Relay.Calling.TapAction

View as Markdown

This object returned from tapAsync method that represents the running media tapping active on a call.

Methods

getControlId

Return the UUID to identify the action.

Parameters

None

Returns

string - UUID to identify the action.

Examples

Start tapping audio and print the controlId.

1<?php
2
3$tap = [
4 'target_type' => 'rtp',
5 'target_addr' => '192.168.1.1',
6 'target_port' => 1234
7];
8$call->tapAsync($tap)->done(function($action) {
9 echo $action->getControlId();
10});

getResult

Returns the final result of this tapping action.

Parameters

None

Returns

Relay.Calling.TapResult - Final tap result.

Examples

Start tapping audio and grab the result when it’s completed.

1<?php
2
3$tap = [
4 'target_type' => 'rtp',
5 'target_addr' => '192.168.1.1',
6 'target_port' => 1234
7];
8$call->tapAsync($tap)->done(function($action) {
9 // .. later in the code since it's an async method
10 if ($action->isCompleted()) {
11 $result = $action->getResult();
12 }
13});

getPayload

Return the payload sent to Relay to initiate the request. Useful to inspect what you sent to perform this action.

Parameters

None

Returns

Object - Payload sent to Relay.

Examples

Start tapping audio and print out the payload.

1<?php
2
3$tap = [
4 'target_type' => 'rtp',
5 'target_addr' => '192.168.1.1',
6 'target_port' => 1234
7];
8$call->tapAsync($tap)->done(function($action) {
9 print_r($action->getPayload());
10});

getState

Return the current tapping state.

Parameters

None

Returns

string - The current state.

Examples

Start tapping audio and print the state.

1<?php
2
3$tap = [ 'type' => 'audio' ];
4$device = [ 'type' => 'rtp', 'addr' => '192.168.1.1', 'port' => 1234 ];
5$call->tapAsync($tap, $device)->done(function($action) {
6 echo $action->getState();
7});

isCompleted

Return true if tapping has finished, false otherwise.

Parameters

None

Returns

Boolean - True/False accordingly to the state.

Examples

Start tapping audio and check if it has finished.

1<?php
2
3$tap = [
4 'target_type' => 'rtp',
5 'target_addr' => '192.168.1.1',
6 'target_port' => 1234
7];
8$call->tapAsync($tap)->done(function($action) {
9 if ($action->isCompleted()) {
10
11 }
12});

getSourceDevice

Return the source device sending media.

Parameters

None

Returns

Object - The source device.

Examples

Start tapping audio and then inspect the source device.

1<?php
2
3$tap = [
4 'target_type' => 'rtp',
5 'target_addr' => '192.168.1.1',
6 'target_port' => 1234
7];
8$call->tapAsync($tap)->done(function($action) {
9 $source = $action->getSourceDevice();
10});

stop

Stop the action immediately.

Parameters

None

Returns

React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.StopResult object.

Examples

Start tapping audio and then stop the action.

1<?php
2
3$tap = [
4 'target_type' => 'rtp',
5 'target_addr' => '192.168.1.1',
6 'target_port' => 1234
7];
8$call->tapAsync($tap)->done(function($action) {
9 // For demonstration purposes only..
10 $action->stop()->done(function($stopResult) {
11
12 });
13});