Skip to content

Commit

Permalink
SampleBuilder should Unmarshal after collecting
Browse files Browse the repository at this point in the history
Before we incorrectly ran Unmarshal on every RTP Payload. This worked
for Opus and VP8 because it didn't care about the Payload Headers.
However this would break H264.

Relates to #1652
  • Loading branch information
Sean-Der committed Jan 29, 2021
1 parent bafb7f5 commit 9e6d659
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/media/samplebuilder/samplebuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const secondToNanoseconds = 1000000000
// We have a valid collection of RTP Packets
// walk forwards building a sample if everything looks good clear and update buffer+values
func (s *SampleBuilder) buildSample(firstBuffer uint16) (*media.Sample, uint32) {
data := []byte{}
payloadBuffer := []byte{}

for i := firstBuffer; s.buffer[i] != nil; i++ {
if s.buffer[i].Timestamp != s.buffer[firstBuffer].Timestamp {
Expand All @@ -104,15 +104,15 @@ func (s *SampleBuilder) buildSample(firstBuffer uint16) (*media.Sample, uint32)
s.releasePacket(j)
}

return &media.Sample{Data: data, Duration: time.Duration((float64(samples)/float64(s.sampleRate))*secondToNanoseconds) * time.Nanosecond}, s.lastPopTimestamp
}
data, err := s.depacketizer.Unmarshal(payloadBuffer)
if err != nil {
return nil, 0
}

p, err := s.depacketizer.Unmarshal(s.buffer[i].Payload)
if err != nil {
return nil, 0
return &media.Sample{Data: data, Duration: time.Duration((float64(samples)/float64(s.sampleRate))*secondToNanoseconds) * time.Nanosecond}, s.lastPopTimestamp
}

data = append(data, p...)
payloadBuffer = append(payloadBuffer, s.buffer[i].Payload...)
}
return nil, 0
}
Expand Down

0 comments on commit 9e6d659

Please sign in to comment.