You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
5.2 KiB

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