rtp_sender_interface.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright 2015 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. // This file contains interfaces for RtpSenders
  11. // http://w3c.github.io/webrtc-pc/#rtcrtpsender-interface
  12. #ifndef API_RTP_SENDER_INTERFACE_H_
  13. #define API_RTP_SENDER_INTERFACE_H_
  14. #include <string>
  15. #include <vector>
  16. #include "api/crypto/frame_encryptor_interface.h"
  17. #include "api/dtls_transport_interface.h"
  18. #include "api/dtmf_sender_interface.h"
  19. #include "api/frame_transformer_interface.h"
  20. #include "api/media_stream_interface.h"
  21. #include "api/media_types.h"
  22. #include "api/proxy.h"
  23. #include "api/rtc_error.h"
  24. #include "api/rtp_parameters.h"
  25. #include "api/scoped_refptr.h"
  26. #include "rtc_base/ref_count.h"
  27. #include "rtc_base/system/rtc_export.h"
  28. namespace webrtc {
  29. class RTC_EXPORT RtpSenderInterface : public rtc::RefCountInterface {
  30. public:
  31. // Returns true if successful in setting the track.
  32. // Fails if an audio track is set on a video RtpSender, or vice-versa.
  33. virtual bool SetTrack(MediaStreamTrackInterface* track) = 0;
  34. virtual rtc::scoped_refptr<MediaStreamTrackInterface> track() const = 0;
  35. // The dtlsTransport attribute exposes the DTLS transport on which the
  36. // media is sent. It may be null.
  37. // https://w3c.github.io/webrtc-pc/#dom-rtcrtpsender-transport
  38. // TODO(https://bugs.webrtc.org/907849) remove default implementation
  39. virtual rtc::scoped_refptr<DtlsTransportInterface> dtls_transport() const;
  40. // Returns primary SSRC used by this sender for sending media.
  41. // Returns 0 if not yet determined.
  42. // TODO(deadbeef): Change to absl::optional.
  43. // TODO(deadbeef): Remove? With GetParameters this should be redundant.
  44. virtual uint32_t ssrc() const = 0;
  45. // Audio or video sender?
  46. virtual cricket::MediaType media_type() const = 0;
  47. // Not to be confused with "mid", this is a field we can temporarily use
  48. // to uniquely identify a receiver until we implement Unified Plan SDP.
  49. virtual std::string id() const = 0;
  50. // Returns a list of media stream ids associated with this sender's track.
  51. // These are signalled in the SDP so that the remote side can associate
  52. // tracks.
  53. virtual std::vector<std::string> stream_ids() const = 0;
  54. // Sets the IDs of the media streams associated with this sender's track.
  55. // These are signalled in the SDP so that the remote side can associate
  56. // tracks.
  57. virtual void SetStreams(const std::vector<std::string>& stream_ids) {}
  58. // Returns the list of encoding parameters that will be applied when the SDP
  59. // local description is set. These initial encoding parameters can be set by
  60. // PeerConnection::AddTransceiver, and later updated with Get/SetParameters.
  61. // TODO(orphis): Make it pure virtual once Chrome has updated
  62. virtual std::vector<RtpEncodingParameters> init_send_encodings() const;
  63. virtual RtpParameters GetParameters() const = 0;
  64. // Note that only a subset of the parameters can currently be changed. See
  65. // rtpparameters.h
  66. // The encodings are in increasing quality order for simulcast.
  67. virtual RTCError SetParameters(const RtpParameters& parameters) = 0;
  68. // Returns null for a video sender.
  69. virtual rtc::scoped_refptr<DtmfSenderInterface> GetDtmfSender() const = 0;
  70. // Sets a user defined frame encryptor that will encrypt the entire frame
  71. // before it is sent across the network. This will encrypt the entire frame
  72. // using the user provided encryption mechanism regardless of whether SRTP is
  73. // enabled or not.
  74. virtual void SetFrameEncryptor(
  75. rtc::scoped_refptr<FrameEncryptorInterface> frame_encryptor);
  76. // Returns a pointer to the frame encryptor set previously by the
  77. // user. This can be used to update the state of the object.
  78. virtual rtc::scoped_refptr<FrameEncryptorInterface> GetFrameEncryptor() const;
  79. virtual void SetEncoderToPacketizerFrameTransformer(
  80. rtc::scoped_refptr<FrameTransformerInterface> frame_transformer);
  81. protected:
  82. ~RtpSenderInterface() override = default;
  83. };
  84. // Define proxy for RtpSenderInterface.
  85. // TODO(deadbeef): Move this to .cc file and out of api/. What threads methods
  86. // are called on is an implementation detail.
  87. BEGIN_SIGNALING_PROXY_MAP(RtpSender)
  88. PROXY_SIGNALING_THREAD_DESTRUCTOR()
  89. PROXY_METHOD1(bool, SetTrack, MediaStreamTrackInterface*)
  90. PROXY_CONSTMETHOD0(rtc::scoped_refptr<MediaStreamTrackInterface>, track)
  91. PROXY_CONSTMETHOD0(rtc::scoped_refptr<DtlsTransportInterface>, dtls_transport)
  92. PROXY_CONSTMETHOD0(uint32_t, ssrc)
  93. BYPASS_PROXY_CONSTMETHOD0(cricket::MediaType, media_type)
  94. BYPASS_PROXY_CONSTMETHOD0(std::string, id)
  95. PROXY_CONSTMETHOD0(std::vector<std::string>, stream_ids)
  96. PROXY_CONSTMETHOD0(std::vector<RtpEncodingParameters>, init_send_encodings)
  97. PROXY_CONSTMETHOD0(RtpParameters, GetParameters)
  98. PROXY_METHOD1(RTCError, SetParameters, const RtpParameters&)
  99. PROXY_CONSTMETHOD0(rtc::scoped_refptr<DtmfSenderInterface>, GetDtmfSender)
  100. PROXY_METHOD1(void,
  101. SetFrameEncryptor,
  102. rtc::scoped_refptr<FrameEncryptorInterface>)
  103. PROXY_CONSTMETHOD0(rtc::scoped_refptr<FrameEncryptorInterface>,
  104. GetFrameEncryptor)
  105. PROXY_METHOD1(void, SetStreams, const std::vector<std::string>&)
  106. PROXY_METHOD1(void,
  107. SetEncoderToPacketizerFrameTransformer,
  108. rtc::scoped_refptr<FrameTransformerInterface>)
  109. END_PROXY_MAP()
  110. } // namespace webrtc
  111. #endif // API_RTP_SENDER_INTERFACE_H_