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.

142 lines
6.1 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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 API_RTP_TRANSCEIVER_INTERFACE_H_
  11. #define API_RTP_TRANSCEIVER_INTERFACE_H_
  12. #include <string>
  13. #include <vector>
  14. #include "absl/types/optional.h"
  15. #include "api/array_view.h"
  16. #include "api/media_types.h"
  17. #include "api/rtp_parameters.h"
  18. #include "api/rtp_receiver_interface.h"
  19. #include "api/rtp_sender_interface.h"
  20. #include "api/scoped_refptr.h"
  21. #include "rtc_base/ref_count.h"
  22. #include "rtc_base/system/rtc_export.h"
  23. namespace webrtc {
  24. // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiverdirection
  25. enum class RtpTransceiverDirection {
  26. kSendRecv,
  27. kSendOnly,
  28. kRecvOnly,
  29. kInactive
  30. };
  31. // Structure for initializing an RtpTransceiver in a call to
  32. // PeerConnectionInterface::AddTransceiver.
  33. // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiverinit
  34. struct RTC_EXPORT RtpTransceiverInit final {
  35. RtpTransceiverInit();
  36. RtpTransceiverInit(const RtpTransceiverInit&);
  37. ~RtpTransceiverInit();
  38. // Direction of the RtpTransceiver. See RtpTransceiverInterface::direction().
  39. RtpTransceiverDirection direction = RtpTransceiverDirection::kSendRecv;
  40. // The added RtpTransceiver will be added to these streams.
  41. std::vector<std::string> stream_ids;
  42. // TODO(bugs.webrtc.org/7600): Not implemented.
  43. std::vector<RtpEncodingParameters> send_encodings;
  44. };
  45. // The RtpTransceiverInterface maps to the RTCRtpTransceiver defined by the
  46. // WebRTC specification. A transceiver represents a combination of an RtpSender
  47. // and an RtpReceiver than share a common mid. As defined in JSEP, an
  48. // RtpTransceiver is said to be associated with a media description if its mid
  49. // property is non-null; otherwise, it is said to be disassociated.
  50. // JSEP: https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-24
  51. //
  52. // Note that RtpTransceivers are only supported when using PeerConnection with
  53. // Unified Plan SDP.
  54. //
  55. // This class is thread-safe.
  56. //
  57. // WebRTC specification for RTCRtpTransceiver, the JavaScript analog:
  58. // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver
  59. class RTC_EXPORT RtpTransceiverInterface : public rtc::RefCountInterface {
  60. public:
  61. // Media type of the transceiver. Any sender(s)/receiver(s) will have this
  62. // type as well.
  63. virtual cricket::MediaType media_type() const = 0;
  64. // The mid attribute is the mid negotiated and present in the local and
  65. // remote descriptions. Before negotiation is complete, the mid value may be
  66. // null. After rollbacks, the value may change from a non-null value to null.
  67. // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-mid
  68. virtual absl::optional<std::string> mid() const = 0;
  69. // The sender attribute exposes the RtpSender corresponding to the RTP media
  70. // that may be sent with the transceiver's mid. The sender is always present,
  71. // regardless of the direction of media.
  72. // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-sender
  73. virtual rtc::scoped_refptr<RtpSenderInterface> sender() const = 0;
  74. // The receiver attribute exposes the RtpReceiver corresponding to the RTP
  75. // media that may be received with the transceiver's mid. The receiver is
  76. // always present, regardless of the direction of media.
  77. // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-receiver
  78. virtual rtc::scoped_refptr<RtpReceiverInterface> receiver() const = 0;
  79. // The stopped attribute indicates that the sender of this transceiver will no
  80. // longer send, and that the receiver will no longer receive. It is true if
  81. // either stop has been called or if setting the local or remote description
  82. // has caused the RtpTransceiver to be stopped.
  83. // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-stopped
  84. virtual bool stopped() const = 0;
  85. // The direction attribute indicates the preferred direction of this
  86. // transceiver, which will be used in calls to CreateOffer and CreateAnswer.
  87. // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-direction
  88. virtual RtpTransceiverDirection direction() const = 0;
  89. // Sets the preferred direction of this transceiver. An update of
  90. // directionality does not take effect immediately. Instead, future calls to
  91. // CreateOffer and CreateAnswer mark the corresponding media descriptions as
  92. // sendrecv, sendonly, recvonly, or inactive.
  93. // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-direction
  94. virtual void SetDirection(RtpTransceiverDirection new_direction) = 0;
  95. // The current_direction attribute indicates the current direction negotiated
  96. // for this transceiver. If this transceiver has never been represented in an
  97. // offer/answer exchange, or if the transceiver is stopped, the value is null.
  98. // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-currentdirection
  99. virtual absl::optional<RtpTransceiverDirection> current_direction() const = 0;
  100. // An internal slot designating for which direction the relevant
  101. // PeerConnection events have been fired. This is to ensure that events like
  102. // OnAddTrack only get fired once even if the same session description is
  103. // applied again.
  104. // Exposed in the public interface for use by Chromium.
  105. virtual absl::optional<RtpTransceiverDirection> fired_direction() const;
  106. // The Stop method irreversibly stops the RtpTransceiver. The sender of this
  107. // transceiver will no longer send, the receiver will no longer receive.
  108. // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-stop
  109. virtual void Stop() = 0;
  110. // The SetCodecPreferences method overrides the default codec preferences used
  111. // by WebRTC for this transceiver.
  112. // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-setcodecpreferences
  113. virtual RTCError SetCodecPreferences(
  114. rtc::ArrayView<RtpCodecCapability> codecs);
  115. virtual std::vector<RtpCodecCapability> codec_preferences() const;
  116. protected:
  117. ~RtpTransceiverInterface() override = default;
  118. };
  119. } // namespace webrtc
  120. #endif // API_RTP_TRANSCEIVER_INTERFACE_H_