mirror of
https://github.com/jech/galene.git
synced 2024-11-22 16:45:58 +01:00
Fix disk writer when doing simulcast.
This commit is contained in:
parent
1130295e0b
commit
0205695bd7
1 changed files with 40 additions and 10 deletions
|
@ -260,15 +260,50 @@ type diskTrack struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDiskConn(client *Client, directory string, up conn.Up, remoteTracks []conn.UpTrack) (*diskConn, error) {
|
func newDiskConn(client *Client, directory string, up conn.Up, remoteTracks []conn.UpTrack) (*diskConn, error) {
|
||||||
|
var audio, video conn.UpTrack
|
||||||
|
|
||||||
|
for _, remote := range remoteTracks {
|
||||||
|
codec := remote.Codec().MimeType
|
||||||
|
if strings.EqualFold(codec, "audio/opus") {
|
||||||
|
if audio == nil {
|
||||||
|
audio = remote
|
||||||
|
} else {
|
||||||
|
client.group.WallOps("Multiple audio tracks, recording just one")
|
||||||
|
}
|
||||||
|
} else if strings.EqualFold(codec, "video/vp8") ||
|
||||||
|
strings.EqualFold(codec, "video/vp9") {
|
||||||
|
println(remote.Label())
|
||||||
|
if video == nil || video.Label() == "l" {
|
||||||
|
video = remote
|
||||||
|
} else if remote.Label() != "l" {
|
||||||
|
client.group.WallOps("Multiple video tracks, recording just one")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
client.group.WallOps("Unknown codec, " + codec + ", not recording")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if video == nil && audio == nil {
|
||||||
|
return nil, errors.New("no usable tracks found")
|
||||||
|
}
|
||||||
|
|
||||||
|
tracks := make([]conn.UpTrack, 0, 2)
|
||||||
|
if audio != nil {
|
||||||
|
tracks = append(tracks, audio)
|
||||||
|
}
|
||||||
|
if video != nil {
|
||||||
|
tracks = append(tracks, video)
|
||||||
|
}
|
||||||
|
|
||||||
_, username := up.User()
|
_, username := up.User()
|
||||||
conn := diskConn{
|
conn := diskConn{
|
||||||
client: client,
|
client: client,
|
||||||
directory: directory,
|
directory: directory,
|
||||||
username: username,
|
username: username,
|
||||||
tracks: make([]*diskTrack, 0, len(remoteTracks)),
|
tracks: make([]*diskTrack, 0, len(tracks)),
|
||||||
remote: up,
|
remote: up,
|
||||||
}
|
}
|
||||||
for _, remote := range remoteTracks {
|
for _, remote := range tracks {
|
||||||
var builder *samplebuilder.SampleBuilder
|
var builder *samplebuilder.SampleBuilder
|
||||||
codec := remote.Codec()
|
codec := remote.Codec()
|
||||||
if strings.EqualFold(codec.MimeType, "audio/opus") {
|
if strings.EqualFold(codec.MimeType, "audio/opus") {
|
||||||
|
@ -279,9 +314,6 @@ func newDiskConn(client *Client, directory string, up conn.Up, remoteTracks []co
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
} else if strings.EqualFold(codec.MimeType, "video/vp8") {
|
} else if strings.EqualFold(codec.MimeType, "video/vp8") {
|
||||||
if conn.hasVideo {
|
|
||||||
return nil, errors.New("multiple video tracks not supported")
|
|
||||||
}
|
|
||||||
builder = samplebuilder.New(
|
builder = samplebuilder.New(
|
||||||
128, &codecs.VP8Packet{}, codec.ClockRate,
|
128, &codecs.VP8Packet{}, codec.ClockRate,
|
||||||
samplebuilder.WithPartitionHeadChecker(
|
samplebuilder.WithPartitionHeadChecker(
|
||||||
|
@ -290,9 +322,6 @@ func newDiskConn(client *Client, directory string, up conn.Up, remoteTracks []co
|
||||||
)
|
)
|
||||||
conn.hasVideo = true
|
conn.hasVideo = true
|
||||||
} else if strings.EqualFold(codec.MimeType, "video/vp9") {
|
} else if strings.EqualFold(codec.MimeType, "video/vp9") {
|
||||||
if conn.hasVideo {
|
|
||||||
return nil, errors.New("multiple video tracks not supported")
|
|
||||||
}
|
|
||||||
builder = samplebuilder.New(
|
builder = samplebuilder.New(
|
||||||
128, &codecs.VP9Packet{}, codec.ClockRate,
|
128, &codecs.VP9Packet{}, codec.ClockRate,
|
||||||
samplebuilder.WithPartitionHeadChecker(
|
samplebuilder.WithPartitionHeadChecker(
|
||||||
|
@ -301,8 +330,9 @@ func newDiskConn(client *Client, directory string, up conn.Up, remoteTracks []co
|
||||||
)
|
)
|
||||||
conn.hasVideo = true
|
conn.hasVideo = true
|
||||||
} else {
|
} else {
|
||||||
client.group.WallOps(
|
// this shouldn't happen
|
||||||
"Cannot record codec " + codec.MimeType,
|
return nil, errors.New(
|
||||||
|
"cannot record codec " + codec.MimeType,
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue