diff --git a/pkg/rtcrec/recording_peerconnection.go b/pkg/rtcrec/recording_peerconnection.go index f5230b787..bcfd14b7b 100644 --- a/pkg/rtcrec/recording_peerconnection.go +++ b/pkg/rtcrec/recording_peerconnection.go @@ -52,6 +52,11 @@ func (pc *RecordingPeerConnection) Do(f func()) { } func (pc *RecordingPeerConnection) Close() error { + pc.Do(func() { + // This is sloppy but there might be other goroutines still writing so let's chill for a sec + time.Sleep(10 * time.Second) + pc.file.Close() + }) return pc.pionpc.Close() } diff --git a/pkg/rtcrec/recording_track.go b/pkg/rtcrec/recording_track.go index a6730d1f4..b298ab951 100644 --- a/pkg/rtcrec/recording_track.go +++ b/pkg/rtcrec/recording_track.go @@ -13,10 +13,6 @@ type RecordingTrackRemote struct { pc *RecordingPeerConnection } -func (t *RecordingTrackRemote) do(f func()) { - go f() -} - func (t *RecordingTrackRemote) Read(p []byte) (n int, attrs interceptor.Attributes, err error) { n, attrs, err = t.track.Read(p) now := time.Now() diff --git a/pkg/rtcrec/replay_peerconnection.go b/pkg/rtcrec/replay_peerconnection.go index 835f31ed6..871b8bbf0 100644 --- a/pkg/rtcrec/replay_peerconnection.go +++ b/pkg/rtcrec/replay_peerconnection.go @@ -40,7 +40,7 @@ func (pc *ReplayPeerConnection) wait(label string, t time.Time) <-chan time.Time } func (pc *ReplayPeerConnection) Close() error { - // todo: implment stopping here + // todo: implement stopping here return nil }