Skip to main content

Relay.Calling.TapAction

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

var tapdevice signalwire.TapDevice
tapdevice.Type = signalwire.TapRTP.String()
tapdevice.Params.Addr = "X.X.X.X"
tapdevice.Params.Port = 1234
tapdevice.Params.Codec = "PCMU"
/* direction can be TapDirectionListen, TapDirectionSpeak or TapDirectionBoth */
tapAction, err := resultDial.Call.TapAudioAsync(signalwire.TapDirectionListen, &tapdevice)
if err != nil {
signalwire.Log.Fatal("Error occurred while trying to tap audio: %v\n", err)
}
// tap for 10 seconds
time.Sleep(10 * time.Second)
tapAction.Stop()
signalwire.Log.Info("Tap: %v Result :%v\n", tapAction.GetTap(), tapAction.GetResult())
signalwire.Log.Info("SourceDevice: %v\n", tapAction.GetSourceDevice()) // comes from the Signalwire platform
signalwire.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).

var tapdevice signalwire.TapDevice
tapdevice.Type = signalwire.TapWS.String()
tapdevice.Params.URI = "wss://X.X.X.X:1234" // ws or wss URI
tapdevice.Params.Codec = "PCMU"
/* direction can be TapDirectionListen, TapDirectionSpeak or TapDirectionBoth */
tapAction, err := resultDial.Call.TapAudioAsync(signalwire.TapDirectionListen, &tapdevice)
if err != nil {
signalwire.Log.Fatal("Error occurred while trying to tap audio: %v\n", err)
}
// tap for 10 seconds
time.Sleep(10 * time.Second)
tapAction.Stop()
signalwire.Log.Info("Tap: %v Result :%v\n", tapAction.GetTap(), tapAction.GetResult())
signalwire.Log.Info("SourceDevice: %v\n", tapAction.GetSourceDevice()) // comes from the Signalwire platform
signalwire.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.

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

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.

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

GetSourceDevice​

Return the source device sending media.

Parameters

None

Returns

Object - The source device.

Examples

Start tapping audio and then inspect the source device.

var tapdevice signalwire.TapDevice
tapdevice.Type = signalwire.TapRTP.String()
tapdevice.Params.Addr = "X.X.X.X"
tapdevice.Params.Port = 1234
tapdevice.Params.Codec = "PCMU"
tapAction, err := resultDial.Call.TapAudioAsync(signalwire.TapDirectionListen, &tapdevice)
if err != nil {
signalwire.Log.Fatal("Error occurred while trying to tap audio: %v\n", err)
}
// tap for 10 seconds
time.Sleep(10 * time.Second)
tapAction.Stop()
signalwire.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.

tapAction.Stop()
signalwire.Log.Info("Tap: %v Result :%v\n", tapAction.GetTap(), tapAction.GetResult())
signalwire.Log.Info("SourceDevice: %v\n", tapAction.GetSourceDevice()) // comes from the Signalwire platform
signalwire.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.