Skip to content

Commit

Permalink
Support more data from webrtc stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Tarasiuk authored and aalekseevx committed Oct 3, 2024
1 parent bd2309f commit 7e7cdbe
Show file tree
Hide file tree
Showing 3 changed files with 546 additions and 120 deletions.
56 changes: 49 additions & 7 deletions icetransportstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,53 @@ const (
ICETransportStateClosed
)

const (
iceTransportStateNewStr = "new"
iceTransportStateCheckingStr = "checking"
iceTransportStateConnectedStr = "connected"
iceTransportStateCompletedStr = "completed"
iceTransportStateFailedStr = "failed"
iceTransportStateDisconnectedStr = "disconnected"
iceTransportStateClosedStr = "closed"
)

func newICETransportState(raw string) ICETransportState {
switch raw {
case iceTransportStateNewStr:
return ICETransportStateNew
case iceTransportStateCheckingStr:
return ICETransportStateChecking

Check warning on line 67 in icetransportstate.go

View check run for this annotation

Codecov / codecov/patch

icetransportstate.go#L64-L67

Added lines #L64 - L67 were not covered by tests
case iceTransportStateConnectedStr:
return ICETransportStateConnected
case iceTransportStateCompletedStr:
return ICETransportStateCompleted
case iceTransportStateFailedStr:
return ICETransportStateFailed
case iceTransportStateDisconnectedStr:
return ICETransportStateDisconnected
case iceTransportStateClosedStr:
return ICETransportStateClosed
default:
return ICETransportStateUnknown

Check warning on line 79 in icetransportstate.go

View check run for this annotation

Codecov / codecov/patch

icetransportstate.go#L70-L79

Added lines #L70 - L79 were not covered by tests
}
}

func (c ICETransportState) String() string {
switch c {
case ICETransportStateNew:
return "new"
return iceTransportStateNewStr
case ICETransportStateChecking:
return "checking"
return iceTransportStateCheckingStr
case ICETransportStateConnected:
return "connected"
return iceTransportStateConnectedStr
case ICETransportStateCompleted:
return "completed"
return iceTransportStateCompletedStr
case ICETransportStateFailed:
return "failed"
return iceTransportStateFailedStr
case ICETransportStateDisconnected:
return "disconnected"
return iceTransportStateDisconnectedStr
case ICETransportStateClosed:
return "closed"
return iceTransportStateClosedStr
default:
return ErrUnknownType.Error()
}
Expand Down Expand Up @@ -111,3 +142,14 @@ func (c ICETransportState) toICE() ice.ConnectionState {
return ice.ConnectionStateUnknown
}
}

// MarshalText implements encoding.TextMarshaler
func (t ICETransportState) MarshalText() ([]byte, error) {

Check failure on line 147 in icetransportstate.go

View workflow job for this annotation

GitHub Actions / lint / Go

receiver-naming: receiver name t should be consistent with previous receiver name c for ICETransportState (revive)
return []byte(t.String()), nil
}

// UnmarshalText implements encoding.TextUnmarshaler
func (t *ICETransportState) UnmarshalText(b []byte) error {

Check failure on line 152 in icetransportstate.go

View workflow job for this annotation

GitHub Actions / lint / Go

receiver-naming: receiver name t should be consistent with previous receiver name c for ICETransportState (revive)
*t = newICETransportState(string(b))
return nil
}
Loading

0 comments on commit 7e7cdbe

Please sign in to comment.