This repository was archived by the owner on Dec 2, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 519
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
1aa9caf
commit b36eb9a
Showing
23 changed files
with
835 additions
and
829 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package util | ||
|
||
import ( | ||
"strings" | ||
|
||
log "github.com/pion/ion-log" | ||
"github.com/pion/ion/pkg/grpc/ion" | ||
"github.com/pixelbender/go-sdp/sdp" | ||
) | ||
|
||
//ParseSDP . | ||
func ParseSDP(sdpstr string) ([]*ion.Stream, error) { | ||
sess, err := sdp.ParseString(sdpstr) | ||
|
||
if err != nil { | ||
log.Errorf("sdp.Parse erro %v", err) | ||
return nil, err | ||
} | ||
|
||
streams := make(map[string]*ion.Stream) | ||
for _, m := range sess.Media { | ||
//fmt.Printf("type = %v\n", m.Type) | ||
|
||
if m.Type == "audio" || m.Type == "video" { | ||
msid := m.Attributes.Get("msid") | ||
//fmt.Printf("msid id = %v\n", msid) | ||
|
||
strs := strings.Split(msid, " ") | ||
streamID := strs[0] | ||
trackID := msid | ||
trackLabel := strs[1] | ||
|
||
track := &ion.Track{ | ||
Kind: m.Type, | ||
Id: trackID, | ||
Label: trackLabel, | ||
} | ||
|
||
simulcast := make(map[string]string) | ||
for _, attr := range m.Attributes { | ||
//fmt.Printf("attr name = %v, value = %v\n", attr.Name, attr.Value) | ||
|
||
if attr.Name == "rid" { | ||
strs := strings.Split(attr.Value, " ") | ||
rid := strs[0] | ||
dir := strs[1] | ||
//fmt.Printf("rid: rid = %v, dir = %v\n", rid, dir) | ||
simulcast[rid] = dir | ||
} | ||
/* | ||
if attr.Name == "simulcast" { | ||
strs := strings.Split(attr.Value, " ") | ||
dir := strs[0] | ||
rids := strs[1] | ||
fmt.Printf("simulcast: rids = %v, dir = %v\n", rids, dir) | ||
} | ||
*/ | ||
} | ||
track.Simulcast = simulcast | ||
|
||
if stream, ok := streams[streamID]; ok { | ||
stream.Tracks = append(stream.Tracks, track) | ||
} else { | ||
stream = &ion.Stream{ | ||
Id: streamID, | ||
} | ||
stream.Tracks = append(stream.Tracks, track) | ||
streams[streamID] = stream | ||
} | ||
} | ||
} | ||
|
||
var list []*ion.Stream | ||
for _, stream := range streams { | ||
//fmt.Printf("%v\n", stream.String()) | ||
list = append(list, stream) | ||
} | ||
|
||
return list, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters