rtp_transport_internal.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright 2017 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef PC_RTP_TRANSPORT_INTERNAL_H_
  11. #define PC_RTP_TRANSPORT_INTERNAL_H_
  12. #include <string>
  13. #include "call/rtp_demuxer.h"
  14. #include "p2p/base/ice_transport_internal.h"
  15. #include "pc/session_description.h"
  16. #include "rtc_base/network_route.h"
  17. #include "rtc_base/ssl_stream_adapter.h"
  18. #include "rtc_base/third_party/sigslot/sigslot.h"
  19. namespace rtc {
  20. class CopyOnWriteBuffer;
  21. struct PacketOptions;
  22. } // namespace rtc
  23. namespace webrtc {
  24. // This represents the internal interface beneath SrtpTransportInterface;
  25. // it is not accessible to API consumers but is accessible to internal classes
  26. // in order to send and receive RTP and RTCP packets belonging to a single RTP
  27. // session. Additional convenience and configuration methods are also provided.
  28. class RtpTransportInternal : public sigslot::has_slots<> {
  29. public:
  30. virtual ~RtpTransportInternal() = default;
  31. virtual void SetRtcpMuxEnabled(bool enable) = 0;
  32. virtual const std::string& transport_name() const = 0;
  33. // Sets socket options on the underlying RTP or RTCP transports.
  34. virtual int SetRtpOption(rtc::Socket::Option opt, int value) = 0;
  35. virtual int SetRtcpOption(rtc::Socket::Option opt, int value) = 0;
  36. virtual bool rtcp_mux_enabled() const = 0;
  37. virtual bool IsReadyToSend() const = 0;
  38. // Called whenever a transport's ready-to-send state changes. The argument
  39. // is true if all used transports are ready to send. This is more specific
  40. // than just "writable"; it means the last send didn't return ENOTCONN.
  41. sigslot::signal1<bool> SignalReadyToSend;
  42. // Called whenever an RTCP packet is received. There is no equivalent signal
  43. // for RTP packets because they would be forwarded to the BaseChannel through
  44. // the RtpDemuxer callback.
  45. sigslot::signal2<rtc::CopyOnWriteBuffer*, int64_t> SignalRtcpPacketReceived;
  46. // Called whenever the network route of the P2P layer transport changes.
  47. // The argument is an optional network route.
  48. sigslot::signal1<absl::optional<rtc::NetworkRoute>> SignalNetworkRouteChanged;
  49. // Called whenever a transport's writable state might change. The argument is
  50. // true if the transport is writable, otherwise it is false.
  51. sigslot::signal1<bool> SignalWritableState;
  52. sigslot::signal1<const rtc::SentPacket&> SignalSentPacket;
  53. virtual bool IsWritable(bool rtcp) const = 0;
  54. // TODO(zhihuang): Pass the |packet| by copy so that the original data
  55. // wouldn't be modified.
  56. virtual bool SendRtpPacket(rtc::CopyOnWriteBuffer* packet,
  57. const rtc::PacketOptions& options,
  58. int flags) = 0;
  59. virtual bool SendRtcpPacket(rtc::CopyOnWriteBuffer* packet,
  60. const rtc::PacketOptions& options,
  61. int flags) = 0;
  62. // This method updates the RTP header extension map so that the RTP transport
  63. // can parse the received packets and identify the MID. This is called by the
  64. // BaseChannel when setting the content description.
  65. //
  66. // TODO(zhihuang): Merging and replacing following methods handling header
  67. // extensions with SetParameters:
  68. // UpdateRtpHeaderExtensionMap,
  69. // UpdateSendEncryptedHeaderExtensionIds,
  70. // UpdateRecvEncryptedHeaderExtensionIds,
  71. // CacheRtpAbsSendTimeHeaderExtension,
  72. virtual void UpdateRtpHeaderExtensionMap(
  73. const cricket::RtpHeaderExtensions& header_extensions) = 0;
  74. virtual bool IsSrtpActive() const = 0;
  75. virtual bool RegisterRtpDemuxerSink(const RtpDemuxerCriteria& criteria,
  76. RtpPacketSinkInterface* sink) = 0;
  77. virtual bool UnregisterRtpDemuxerSink(RtpPacketSinkInterface* sink) = 0;
  78. };
  79. } // namespace webrtc
  80. #endif // PC_RTP_TRANSPORT_INTERNAL_H_