Giter Club home page Giter Club logo

Comments (7)

at-wat avatar at-wat commented on May 16, 2024

The SDP looks be able to be parsed by the following code:

package main

import (
  "fmt"

  "github.com/pion/sdp/v2"
)

func main() {
  s := &sdp.SessionDescription{}
  err := s.Unmarshal([]byte(`v=0
o=NVR 1585015269 1585015269 IN IP4 0.0.0.0
s=3GPP Unicast SDP
c=IN IP4 0.0.0.0
t=0 0
a=range:npt=0-
a=control:*
m=video 0 RTP/AVP 96
a=control:video_0
a=rtpmap:96 H264/90000
a=fmtp:96 profile-level-id=42002a;sprop-parameter-sets=Z0IAKp2oHgCJ+WbgICAgQA==,aM48gA==;packetization-mode=0
m=audio 0 RTP/AVP 8
a=control:audio_0
a=rtpmap:8 PCMA/8000`))
  if err != nil {
    panic(err)
  }
  fmt.Printf("parsed:\n%+#v\n\n", s)
  
  b, err := s.Marshal()
  fmt.Printf("roundtrip:\n%s\n", b)
} 

output:

parsed:
&sdp.SessionDescription{Version:0, Origin:sdp.Origin{Username:"NVR", SessionID:0x5e7969e5, SessionVersion:0x5e7969e5, NetworkType:"IN", AddressType:"IP4", UnicastAddress:"0.0.0.0"}, SessionName:"3GPP Unicast SDP", SessionInformation:(*sdp.Information)(nil), URI:(*url.URL)(nil), EmailAddress:(*sdp.EmailAddress)(nil), PhoneNumber:(*sdp.PhoneNumber)(nil), ConnectionInformation:(*sdp.ConnectionInformation)(0xc0001100c0), Bandwidth:[]sdp.Bandwidth(nil), TimeDescriptions:[]sdp.TimeDescription{sdp.TimeDescription{Timing:sdp.Timing{StartTime:0x0, StopTime:0x0}, RepeatTimes:[]sdp.RepeatTime(nil)}}, TimeZones:[]sdp.TimeZone(nil), EncryptionKey:(*sdp.EncryptionKey)(nil), Attributes:[]sdp.Attribute{sdp.Attribute{Key:"range", Value:"npt=0-"}, sdp.Attribute{Key:"control", Value:"*"}}, MediaDescriptions:[]*sdp.MediaDescription{(*sdp.MediaDescription)(0xc000120000), (*sdp.MediaDescription)(0xc0001200a0)}}

roundtrip:
v=0
o=NVR 1585015269 1585015269 IN IP4 0.0.0.0
s=3GPP Unicast SDP
c=IN IP4 0.0.0.0
t=0 0
a=range:npt=0-
a=control:*
m=video 0 RTP/AVP 96
a=control:video_0
a=rtpmap:96 H264/90000
a=fmtp:96 profile-level-id=42002a;sprop-parameter-sets=Z0IAKp2oHgCJ+WbgICAgQA==,aM48gA==;packetization-mode=0
m=audio 0 RTP/AVP 8
a=control:audio_0
a=rtpmap:8 PCMA/8000

Could you post your code and error log?

from sdp.

autoexpect avatar autoexpect commented on May 16, 2024

code:

package main

import (
  "fmt"

  "github.com/pion/sdp/v2"
)

func main() {
  s := &sdp.SessionDescription{}
  err := s.Unmarshal([]byte(`v=0
o=NVR 1585043154 1585043154 IN IP4 0.0.0.0
s=3GPP Unicast SDP
c=IN IP4 0.0.0.0
t=0 0
a=range:npt=0-
a=control:*
m=video 0 RTP/AVP 96
a=control:video_0
a=rtpmap:96 H264/90000
a=fmtp:96 profile-level-id=42002a;sprop-parameter-sets=Z0IAKp2oHgCJ+WbgICAgQA==,aM48gA==;packetization-mode=0
m=audio 0 RTP/AVP 8
a=control:audio_0
a=rtpmap:8 PCMA/8000

`))
  if err != nil {
    panic(err)
  }
  fmt.Printf("parsed:\n%+#v\n\n", s)

  b, err := s.Marshal()
  fmt.Printf("roundtrip:\n%s\n", b)
}

output:

go run main.go
panic: EOF

goroutine 1 [running]:
main.main()
	/Users/harry/Downloads/test/main.go:28 +0x1d4
exit status 2

there are several newline bytes after sdp..

from sdp.

at-wat avatar at-wat commented on May 16, 2024

I'm not very sure SDP allows empty lines.
I'll check the RFC and BNF definition of SDP.

from sdp.

at-wat avatar at-wat commented on May 16, 2024

In my understanding, extra newlines in SDP is not fully adapting the specification. (I'm not 100% sure.)
But other SDP parsers, for example one in VLC media player, allow to have extra newlines.

#46 will fix the issue.

from sdp.

autoexpect avatar autoexpect commented on May 16, 2024

OK thanks!

from sdp.

at-wat avatar at-wat commented on May 16, 2024

@umbrellary the master branch support SDP with extra newlines now. Please check it out!

from sdp.

autoexpect avatar autoexpect commented on May 16, 2024

it works!

from sdp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.