You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: header_extension_interceptor.go
    path of file: ./repos/scan4all/vendor/github.com/pion/interceptor/pkg/twcc
    
    the code of the file until where you have to start completion: // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT

package twcc

import (
	"errors"
	"sync/atomic"

	"github.com/pion/interceptor"
	"github.com/pion/rtp"
)

var errHeaderIsNil = error
    
func (h *HeaderExtensionInterceptor) BindLocalStream(info *interceptor.StreamInfo, writer interceptor.RTPWriter) interceptor.RTPWriter {
	var hdrExtID uint8
	for _, e := range info.RTPHeaderExtensions {
		if e.URI == transportCCURI {
			hdrExtID = uint8(e.ID)
			break
		}
	}
	if hdrExtID == 0 { // Don't add header extension if ID is 0, because 0 is an invalid extension ID
		return writer
	}
	return interceptor.RTPWriterFunc(func(header *rtp.Header, payload []byte, attributes interceptor.Attributes) (int, error) {
		sequenceNumber := atomic.AddUint32(&h.nextSequenceNr, 1) - 1

		tcc, err := (&rtp.TransportCCExtension{TransportSequence: uint16(sequenceNumber)}).Marshal()
		if err != nil {
			return 0, err
		}
		if header == nil {
			return 0, errHeaderIsNil
		}
		err = header.SetExtension(hdrExtID, tcc)
		if err != nil {
			return 0, err
		}
		return writer.Write(header, payload, attributes)
	})
}