Skip to content

Commit

Permalink
Update main.go
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricve committed Feb 6, 2025
1 parent fb876bd commit 0eb77cc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions machinery/src/webrtc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ func WriteToTrack(livestreamCursor *packets.QueueCursor, configuration *models.C
if pkt.IsVideo {

// Calculate the difference
bufferDuration := int64(pkt.TimeLegacy) - previousTimeVideo
bufferDuration := pkt.Time - previousTimeVideo
previousTimeVideo = pkt.Time

// Start at the first keyframe
Expand All @@ -410,7 +410,7 @@ func WriteToTrack(livestreamCursor *packets.QueueCursor, configuration *models.C
}
if start {
bufferDurationCasted := time.Duration(bufferDuration) * time.Millisecond
sample := pionMedia.Sample{Data: pkt.Data, Duration: bufferDurationCasted}
sample := pionMedia.Sample{Data: pkt.Data, Duration: bufferDurationCasted, PacketTimestamp: uint32(pkt.Time)}
//sample = pionMedia.Sample{Data: pkt.Data, Duration: time.Second}
if config.Capture.ForwardWebRTC == "true" {
// We will send the video to a remote peer
Expand All @@ -431,15 +431,16 @@ func WriteToTrack(livestreamCursor *packets.QueueCursor, configuration *models.C
// We will transcode the audio
// TODO..
//d := fdkaac.NewAacDecoder()
continue
}

// Calculate the difference
bufferDuration := int64(pkt.TimeLegacy) - previousTimeAudio
bufferDuration := pkt.Time - previousTimeAudio
previousTimeAudio = pkt.Time

// We will send the audio
bufferDurationCasted := time.Duration(bufferDuration) * time.Millisecond
sample := pionMedia.Sample{Data: pkt.Data, Duration: bufferDurationCasted}
sample := pionMedia.Sample{Data: pkt.Data, Duration: bufferDurationCasted, PacketTimestamp: uint32(pkt.Time)}
//sample = pionMedia.Sample{Data: pkt.Data, Duration: time.Second}
if err := audioTrack.WriteSample(sample); err != nil && err != io.ErrClosedPipe {
log.Log.Error("webrtc.main.WriteToTrack(): something went wrong while writing sample: " + err.Error())
Expand Down

0 comments on commit 0eb77cc

Please sign in to comment.