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.

139 lines
5.8 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 RtpReceivers
  11. // http://w3c.github.io/webrtc-pc/#rtcrtpreceiver-interface
  12. #ifndef API_RTP_RECEIVER_INTERFACE_H_
  13. #define API_RTP_RECEIVER_INTERFACE_H_
  14. #include <string>
  15. #include <vector>
  16. #include "api/crypto/frame_decryptor_interface.h"
  17. #include "api/dtls_transport_interface.h"
  18. #include "api/media_stream_interface.h"
  19. #include "api/media_types.h"
  20. #include "api/proxy.h"
  21. #include "api/rtp_parameters.h"
  22. #include "api/scoped_refptr.h"
  23. #include "api/transport/rtp/rtp_source.h"
  24. #include "rtc_base/deprecation.h"
  25. #include "rtc_base/ref_count.h"
  26. #include "rtc_base/system/rtc_export.h"
  27. namespace webrtc {
  28. class RtpReceiverObserverInterface {
  29. public:
  30. // Note: Currently if there are multiple RtpReceivers of the same media type,
  31. // they will all call OnFirstPacketReceived at once.
  32. //
  33. // In the future, it's likely that an RtpReceiver will only call
  34. // OnFirstPacketReceived when a packet is received specifically for its
  35. // SSRC/mid.
  36. virtual void OnFirstPacketReceived(cricket::MediaType media_type) = 0;
  37. protected:
  38. virtual ~RtpReceiverObserverInterface() {}
  39. };
  40. class RTC_EXPORT RtpReceiverInterface : public rtc::RefCountInterface {
  41. public:
  42. virtual rtc::scoped_refptr<MediaStreamTrackInterface> track() const = 0;
  43. // The dtlsTransport attribute exposes the DTLS transport on which the
  44. // media is received. It may be null.
  45. // https://w3c.github.io/webrtc-pc/#dom-rtcrtpreceiver-transport
  46. // TODO(https://bugs.webrtc.org/907849) remove default implementation
  47. virtual rtc::scoped_refptr<DtlsTransportInterface> dtls_transport() const;
  48. // The list of streams that |track| is associated with. This is the same as
  49. // the [[AssociatedRemoteMediaStreams]] internal slot in the spec.
  50. // https://w3c.github.io/webrtc-pc/#dfn-associatedremotemediastreams
  51. // TODO(hbos): Make pure virtual as soon as Chromium's mock implements this.
  52. // TODO(https://crbug.com/webrtc/9480): Remove streams() in favor of
  53. // stream_ids() as soon as downstream projects are no longer dependent on
  54. // stream objects.
  55. virtual std::vector<std::string> stream_ids() const;
  56. virtual std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams() const;
  57. // Audio or video receiver?
  58. virtual cricket::MediaType media_type() const = 0;
  59. // Not to be confused with "mid", this is a field we can temporarily use
  60. // to uniquely identify a receiver until we implement Unified Plan SDP.
  61. virtual std::string id() const = 0;
  62. // The WebRTC specification only defines RTCRtpParameters in terms of senders,
  63. // but this API also applies them to receivers, similar to ORTC:
  64. // http://ortc.org/wp-content/uploads/2016/03/ortc.html#rtcrtpparameters*.
  65. virtual RtpParameters GetParameters() const = 0;
  66. // Currently, doesn't support changing any parameters, but may in the future.
  67. virtual bool SetParameters(const RtpParameters& parameters) = 0;
  68. // Does not take ownership of observer.
  69. // Must call SetObserver(nullptr) before the observer is destroyed.
  70. virtual void SetObserver(RtpReceiverObserverInterface* observer) = 0;
  71. // Sets the jitter buffer minimum delay until media playout. Actual observed
  72. // delay may differ depending on the congestion control. |delay_seconds| is a
  73. // positive value including 0.0 measured in seconds. |nullopt| means default
  74. // value must be used.
  75. virtual void SetJitterBufferMinimumDelay(
  76. absl::optional<double> delay_seconds) = 0;
  77. // TODO(zhihuang): Remove the default implementation once the subclasses
  78. // implement this. Currently, the only relevant subclass is the
  79. // content::FakeRtpReceiver in Chromium.
  80. virtual std::vector<RtpSource> GetSources() const;
  81. // Sets a user defined frame decryptor that will decrypt the entire frame
  82. // before it is sent across the network. This will decrypt the entire frame
  83. // using the user provided decryption mechanism regardless of whether SRTP is
  84. // enabled or not.
  85. virtual void SetFrameDecryptor(
  86. rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor);
  87. // Returns a pointer to the frame decryptor set previously by the
  88. // user. This can be used to update the state of the object.
  89. virtual rtc::scoped_refptr<FrameDecryptorInterface> GetFrameDecryptor() const;
  90. protected:
  91. ~RtpReceiverInterface() override = default;
  92. };
  93. // Define proxy for RtpReceiverInterface.
  94. // TODO(deadbeef): Move this to .cc file and out of api/. What threads methods
  95. // are called on is an implementation detail.
  96. BEGIN_SIGNALING_PROXY_MAP(RtpReceiver)
  97. PROXY_SIGNALING_THREAD_DESTRUCTOR()
  98. PROXY_CONSTMETHOD0(rtc::scoped_refptr<MediaStreamTrackInterface>, track)
  99. PROXY_CONSTMETHOD0(rtc::scoped_refptr<DtlsTransportInterface>, dtls_transport)
  100. PROXY_CONSTMETHOD0(std::vector<std::string>, stream_ids)
  101. PROXY_CONSTMETHOD0(std::vector<rtc::scoped_refptr<MediaStreamInterface>>,
  102. streams)
  103. PROXY_CONSTMETHOD0(cricket::MediaType, media_type)
  104. PROXY_CONSTMETHOD0(std::string, id)
  105. PROXY_CONSTMETHOD0(RtpParameters, GetParameters)
  106. PROXY_METHOD1(bool, SetParameters, const RtpParameters&)
  107. PROXY_METHOD1(void, SetObserver, RtpReceiverObserverInterface*)
  108. PROXY_METHOD1(void, SetJitterBufferMinimumDelay, absl::optional<double>)
  109. PROXY_CONSTMETHOD0(std::vector<RtpSource>, GetSources)
  110. PROXY_METHOD1(void,
  111. SetFrameDecryptor,
  112. rtc::scoped_refptr<FrameDecryptorInterface>)
  113. PROXY_CONSTMETHOD0(rtc::scoped_refptr<FrameDecryptorInterface>,
  114. GetFrameDecryptor)
  115. END_PROXY_MAP()
  116. } // namespace webrtc
  117. #endif // API_RTP_RECEIVER_INTERFACE_H_