noop.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
  2. // SPDX-License-Identifier: MIT
  3. package interceptor
  4. // NoOp is an Interceptor that does not modify any packets. It can embedded in other interceptors, so it's
  5. // possible to implement only a subset of the methods.
  6. type NoOp struct{}
  7. // BindRTCPReader lets you modify any incoming RTCP packets. It is called once per sender/receiver, however this might
  8. // change in the future. The returned method will be called once per packet batch.
  9. func (i *NoOp) BindRTCPReader(reader RTCPReader) RTCPReader {
  10. return reader
  11. }
  12. // BindRTCPWriter lets you modify any outgoing RTCP packets. It is called once per PeerConnection. The returned method
  13. // will be called once per packet batch.
  14. func (i *NoOp) BindRTCPWriter(writer RTCPWriter) RTCPWriter {
  15. return writer
  16. }
  17. // BindLocalStream lets you modify any outgoing RTP packets. It is called once for per LocalStream. The returned method
  18. // will be called once per rtp packet.
  19. func (i *NoOp) BindLocalStream(_ *StreamInfo, writer RTPWriter) RTPWriter {
  20. return writer
  21. }
  22. // UnbindLocalStream is called when the Stream is removed. It can be used to clean up any data related to that track.
  23. func (i *NoOp) UnbindLocalStream(_ *StreamInfo) {}
  24. // BindRemoteStream lets you modify any incoming RTP packets. It is called once for per RemoteStream. The returned method
  25. // will be called once per rtp packet.
  26. func (i *NoOp) BindRemoteStream(_ *StreamInfo, reader RTPReader) RTPReader {
  27. return reader
  28. }
  29. // UnbindRemoteStream is called when the Stream is removed. It can be used to clean up any data related to that track.
  30. func (i *NoOp) UnbindRemoteStream(_ *StreamInfo) {}
  31. // Close closes the Interceptor, cleaning up any data if necessary.
  32. func (i *NoOp) Close() error {
  33. return nil
  34. }