Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support more data from webrtc stats #2916

Merged
merged 1 commit into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 49 additions & 7 deletions icetransportstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,53 @@
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 @@
return ice.ConnectionStateUnknown
}
}

// MarshalText implements encoding.TextMarshaler
func (c ICETransportState) MarshalText() ([]byte, error) {
return []byte(c.String()), nil
}

// UnmarshalText implements encoding.TextUnmarshaler
func (c *ICETransportState) UnmarshalText(b []byte) error {
*c = newICETransportState(string(b))
return nil
}
Loading
Loading