Comments (7)
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.
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.
I'm not very sure SDP allows empty lines.
I'll check the RFC and BNF definition of SDP.
from sdp.
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.
OK thanks!
from sdp.
@umbrellary the master branch support SDP with extra newlines now. Please check it out!
from sdp.
it works!
from sdp.
Related Issues (20)
- Support unmarshalling SDP containing unknown attributes or values HOT 3
- Dependency Dashboard
- Add MSRP support HOT 1
- SDP Unmarshal (lexer) syntax errors are unwieldy and difficult to work with HOT 1
- Port old fuzzing code to Go's new fuzzing tools HOT 4
- Migrate entire library to a version with attribute broken down HOT 1
- payload type not found error HOT 2
- SDP session part orders HOT 1
- Please add a new release tag HOT 1
- sdp support transport-cc HOT 1
- Any interest in a direct RFC ABNF generated Go parser??? HOT 3
- NewJSEPSessionDescription: session-version doesn't follow the spec
- Support non-canonical SDP for RTSP HOT 2
- Validate UnicastAddress properly HOT 1
- NewJSEPMediaDescription doesn't process codecPrefs HOT 2
- define the RTP port range HOT 4
- Add GetFingerprint() to SessionDescription HOT 5
- Action Required: Fix Renovate Configuration
- Support more values for the bandwidth types when parsing `b=` attributes HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdp.