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