Relay.Calling.TapAction

View as Markdown

Relay.Calling.TapAction

This object returned from tapAsync method that represents the running media tapping active on a call. Signalwire will send RTP or Websocket Audio (WS or WSS).

Methods-submenu

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 (RTP).

1var tapdevice signalwire.TapDevice
2tapdevice.Type = signalwire.TapRTP.String()
3tapdevice.Params.Addr = "X.X.X.X"
4tapdevice.Params.Port = 1234
5tapdevice.Params.Codec = "PCMU"
6/* direction can be TapDirectionListen, TapDirectionSpeak or TapDirectionBoth */
7tapAction, err := resultDial.Call.TapAudioAsync(signalwire.TapDirectionListen, &tapdevice)
8if err != nil {
9 signalwire.Log.Fatal("Error occurred while trying to tap audio: %v\n", err)
10}
11// tap for 10 seconds
12time.Sleep(10 * time.Second)
13tapAction.Stop()
14signalwire.Log.Info("Tap: %v Result :%v\n", tapAction.GetTap(), tapAction.GetResult())
15signalwire.Log.Info("SourceDevice: %v\n", tapAction.GetSourceDevice()) // comes from the Signalwire platform
16signalwire.Log.Info("DestinationDevice: %v\n", tapAction.GetDestinationDevice()) // the device passed above

Start tapping audio and grab the result when it’s completed (WS or WSS).

1var tapdevice signalwire.TapDevice
2tapdevice.Type = signalwire.TapWS.String()
3tapdevice.Params.URI = "wss://X.X.X.X:1234" // ws or wss URI
4tapdevice.Params.Codec = "PCMU"
5/* direction can be TapDirectionListen, TapDirectionSpeak or TapDirectionBoth */
6tapAction, err := resultDial.Call.TapAudioAsync(signalwire.TapDirectionListen, &tapdevice)
7if err != nil {
8 signalwire.Log.Fatal("Error occurred while trying to tap audio: %v\n", err)
9}
10// tap for 10 seconds
11time.Sleep(10 * time.Second)
12tapAction.Stop()
13signalwire.Log.Info("Tap: %v Result :%v\n", tapAction.GetTap(), tapAction.GetResult())
14signalwire.Log.Info("SourceDevice: %v\n", tapAction.GetSourceDevice()) // comes from the Signalwire platform
15signalwire.Log.Info("DestinationDevice: %v\n", tapAction.GetDestinationDevice()) // the device passed above

GetState

Return the current tapping state.

Parameters

None

Returns

string - The current state.

Examples

Start tapping audio and print the state.

1tapAction, err := resultDial.Call.TapAudioAsync(signalwire.TapDirectionListen, &tapdevice)
2if err != nil {
3 signalwire.Log.Fatal("Error occurred while trying to tap audio: %v\n", err)
4}
5if !tapAction.GetCompleted() {
6 // 'while' loop for Go
7 for ok := true; ok; ok = !(tapAction.GetState() == signalwire.TapFinished) {
8 signalwire.Log.Info("Completed: %v State: %s\n", tapAction.GetCompleted(), tapAction.GetCompleted().String())
9 time.Sleep(1 * time.Second)
10 }
11}

GetCompleted

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.

1tapAction, err := resultDial.Call.TapAudioAsync(signalwire.TapDirectionListen, &tapdevice)
2if err != nil {
3 signalwire.Log.Fatal("Error occurred while trying to tap audio: %v\n", err)
4}
5if !tapAction.GetCompleted() {
6 // 'while' loop for Go
7 for ok := true; ok; ok = !(tapAction.GetState() == signalwire.TapFinished) {
8 signalwire.Log.Info("Completed: %v State: %s\n", tapAction.GetCompleted(), tapAction.GetCompleted().String())
9 time.Sleep(1 * time.Second)
10 }
11}

GetSourceDevice

Return the source device sending media.

Parameters

None

Returns

Object - The source device.

Examples

Start tapping audio and then inspect the source device.

1var tapdevice signalwire.TapDevice
2tapdevice.Type = signalwire.TapRTP.String()
3tapdevice.Params.Addr = "X.X.X.X"
4tapdevice.Params.Port = 1234
5tapdevice.Params.Codec = "PCMU"
6tapAction, err := resultDial.Call.TapAudioAsync(signalwire.TapDirectionListen, &tapdevice)
7if err != nil {
8 signalwire.Log.Fatal("Error occurred while trying to tap audio: %v\n", err)
9}
10// tap for 10 seconds
11time.Sleep(10 * time.Second)
12tapAction.Stop()
13signalwire.Log.Info("SourceDevice: %v\n", tapAction.GetSourceDevice())

Stop

Stop the action immediately.

Parameters

None

Returns

error

Examples

Start tapping audio and then stop the action.

1tapAction.Stop()
2signalwire.Log.Info("Tap: %v Result :%v\n", tapAction.GetTap(), tapAction.GetResult())
3signalwire.Log.Info("SourceDevice: %v\n", tapAction.GetSourceDevice()) // comes from the Signalwire platform
4signalwire.Log.Info("DestinationDevice: %v\n", tapAction.GetDestinationDevice()) // the device passed above

GetControlID

Return the UUID to identify the action.

Parameters

None

Returns

string - UUID to identify the action.