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