sessiondescription.go 657 B

123456789101112131415161718192021222324
  1. // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
  2. // SPDX-License-Identifier: MIT
  3. package webrtc
  4. import (
  5. "github.com/pion/sdp/v3"
  6. )
  7. // SessionDescription is used to expose local and remote session descriptions.
  8. type SessionDescription struct {
  9. Type SDPType `json:"type"`
  10. SDP string `json:"sdp"`
  11. // This will never be initialized by callers, internal use only
  12. parsed *sdp.SessionDescription
  13. }
  14. // Unmarshal is a helper to deserialize the sdp
  15. func (sd *SessionDescription) Unmarshal() (*sdp.SessionDescription, error) {
  16. sd.parsed = &sdp.SessionDescription{}
  17. err := sd.parsed.Unmarshal([]byte(sd.SDP))
  18. return sd.parsed, err
  19. }