deadbeef | 6979b02 | 2015-09-24 16:47:53 -0700 | [diff] [blame] | 1 | /* |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 2 | * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
deadbeef | 6979b02 | 2015-09-24 16:47:53 -0700 | [diff] [blame] | 3 | * |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 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. |
deadbeef | 6979b02 | 2015-09-24 16:47:53 -0700 | [diff] [blame] | 9 | */ |
| 10 | |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 11 | // This file contains interfaces for RtpSenders |
| 12 | // http://w3c.github.io/webrtc-pc/#rtcrtpsender-interface |
| 13 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 14 | #ifndef API_RTP_SENDER_INTERFACE_H_ |
| 15 | #define API_RTP_SENDER_INTERFACE_H_ |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 16 | |
| 17 | #include <string> |
deadbeef | a601f5c | 2016-06-06 14:27:39 -0700 | [diff] [blame] | 18 | #include <vector> |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 19 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 20 | #include "api/crypto/frame_encryptor_interface.h" |
Harald Alvestrand | 4a7b3ac | 2019-01-17 10:39:40 +0100 | [diff] [blame] | 21 | #include "api/dtls_transport_interface.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 22 | #include "api/dtmf_sender_interface.h" |
| 23 | #include "api/media_stream_interface.h" |
| 24 | #include "api/media_types.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 25 | #include "api/proxy.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 26 | #include "api/rtc_error.h" |
| 27 | #include "api/rtp_parameters.h" |
Mirko Bonadei | d970807 | 2019-01-25 20:26:48 +0100 | [diff] [blame] | 28 | #include "api/scoped_refptr.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 29 | #include "rtc_base/ref_count.h" |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 30 | |
| 31 | namespace webrtc { |
| 32 | |
| 33 | class RtpSenderInterface : public rtc::RefCountInterface { |
| 34 | public: |
| 35 | // Returns true if successful in setting the track. |
| 36 | // Fails if an audio track is set on a video RtpSender, or vice-versa. |
| 37 | virtual bool SetTrack(MediaStreamTrackInterface* track) = 0; |
| 38 | virtual rtc::scoped_refptr<MediaStreamTrackInterface> track() const = 0; |
| 39 | |
Harald Alvestrand | 4a7b3ac | 2019-01-17 10:39:40 +0100 | [diff] [blame] | 40 | // The dtlsTransport attribute exposes the DTLS transport on which the |
| 41 | // media is sent. It may be null. |
| 42 | // https://w3c.github.io/webrtc-pc/#dom-rtcrtpsender-transport |
| 43 | // TODO(https://bugs.webrtc.org/907849) remove default implementation |
| 44 | virtual rtc::scoped_refptr<DtlsTransportInterface> dtls_transport() const; |
| 45 | |
deadbeef | a601f5c | 2016-06-06 14:27:39 -0700 | [diff] [blame] | 46 | // Returns primary SSRC used by this sender for sending media. |
| 47 | // Returns 0 if not yet determined. |
Danil Chapovalov | 0bc58cf | 2018-06-21 13:32:56 +0200 | [diff] [blame] | 48 | // TODO(deadbeef): Change to absl::optional. |
deadbeef | a601f5c | 2016-06-06 14:27:39 -0700 | [diff] [blame] | 49 | // TODO(deadbeef): Remove? With GetParameters this should be redundant. |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 50 | virtual uint32_t ssrc() const = 0; |
| 51 | |
| 52 | // Audio or video sender? |
| 53 | virtual cricket::MediaType media_type() const = 0; |
| 54 | |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 55 | // Not to be confused with "mid", this is a field we can temporarily use |
| 56 | // to uniquely identify a receiver until we implement Unified Plan SDP. |
| 57 | virtual std::string id() const = 0; |
| 58 | |
Seth Hampson | 5b4f075 | 2018-04-02 16:31:36 -0700 | [diff] [blame] | 59 | // Returns a list of media stream ids associated with this sender's track. |
| 60 | // These are signalled in the SDP so that the remote side can associate |
| 61 | // tracks. |
deadbeef | a601f5c | 2016-06-06 14:27:39 -0700 | [diff] [blame] | 62 | virtual std::vector<std::string> stream_ids() const = 0; |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 63 | |
Florent Castelli | 892acf0 | 2018-10-01 22:47:20 +0200 | [diff] [blame] | 64 | // Returns the list of encoding parameters that will be applied when the SDP |
| 65 | // local description is set. These initial encoding parameters can be set by |
| 66 | // PeerConnection::AddTransceiver, and later updated with Get/SetParameters. |
| 67 | // TODO(orphis): Make it pure virtual once Chrome has updated |
| 68 | virtual std::vector<RtpEncodingParameters> init_send_encodings() const; |
| 69 | |
Amit Hilbuch | e1e789b | 2019-02-20 10:40:12 -0800 | [diff] [blame] | 70 | virtual RtpParameters GetParameters() const = 0; |
deadbeef | b10f32f | 2017-02-08 01:38:21 -0800 | [diff] [blame] | 71 | // Note that only a subset of the parameters can currently be changed. See |
| 72 | // rtpparameters.h |
Åsa Persson | 5565981 | 2018-06-18 17:51:32 +0200 | [diff] [blame] | 73 | // The encodings are in increasing quality order for simulcast. |
Zach Stein | ba37b4b | 2018-01-23 15:02:36 -0800 | [diff] [blame] | 74 | virtual RTCError SetParameters(const RtpParameters& parameters) = 0; |
skvlad | dc1c62c | 2016-03-16 19:07:43 -0700 | [diff] [blame] | 75 | |
deadbeef | 20cb0c1 | 2017-02-01 20:27:00 -0800 | [diff] [blame] | 76 | // Returns null for a video sender. |
| 77 | virtual rtc::scoped_refptr<DtmfSenderInterface> GetDtmfSender() const = 0; |
| 78 | |
Benjamin Wright | d81ac95 | 2018-08-29 17:02:10 -0700 | [diff] [blame] | 79 | // Sets a user defined frame encryptor that will encrypt the entire frame |
| 80 | // before it is sent across the network. This will encrypt the entire frame |
| 81 | // using the user provided encryption mechanism regardless of whether SRTP is |
| 82 | // enabled or not. |
| 83 | virtual void SetFrameEncryptor( |
| 84 | rtc::scoped_refptr<FrameEncryptorInterface> frame_encryptor); |
| 85 | |
| 86 | // Returns a pointer to the frame encryptor set previously by the |
| 87 | // user. This can be used to update the state of the object. |
| 88 | virtual rtc::scoped_refptr<FrameEncryptorInterface> GetFrameEncryptor() const; |
| 89 | |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 90 | protected: |
Mirko Bonadei | 79eb4dd | 2018-07-19 10:39:30 +0200 | [diff] [blame] | 91 | ~RtpSenderInterface() override = default; |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | // Define proxy for RtpSenderInterface. |
deadbeef | b10f32f | 2017-02-08 01:38:21 -0800 | [diff] [blame] | 95 | // TODO(deadbeef): Move this to .cc file and out of api/. What threads methods |
| 96 | // are called on is an implementation detail. |
nisse | 72c8d2b | 2016-04-15 03:49:07 -0700 | [diff] [blame] | 97 | BEGIN_SIGNALING_PROXY_MAP(RtpSender) |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 98 | PROXY_SIGNALING_THREAD_DESTRUCTOR() |
| 99 | PROXY_METHOD1(bool, SetTrack, MediaStreamTrackInterface*) |
| 100 | PROXY_CONSTMETHOD0(rtc::scoped_refptr<MediaStreamTrackInterface>, track) |
Harald Alvestrand | 4a7b3ac | 2019-01-17 10:39:40 +0100 | [diff] [blame] | 101 | PROXY_CONSTMETHOD0(rtc::scoped_refptr<DtlsTransportInterface>, dtls_transport) |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 102 | PROXY_CONSTMETHOD0(uint32_t, ssrc) |
| 103 | PROXY_CONSTMETHOD0(cricket::MediaType, media_type) |
| 104 | PROXY_CONSTMETHOD0(std::string, id) |
| 105 | PROXY_CONSTMETHOD0(std::vector<std::string>, stream_ids) |
Florent Castelli | 892acf0 | 2018-10-01 22:47:20 +0200 | [diff] [blame] | 106 | PROXY_CONSTMETHOD0(std::vector<RtpEncodingParameters>, init_send_encodings) |
Nico Weber | 22f9925 | 2019-02-20 10:13:16 -0500 | [diff] [blame] | 107 | PROXY_CONSTMETHOD0(RtpParameters, GetParameters) |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 108 | PROXY_METHOD1(RTCError, SetParameters, const RtpParameters&) |
Nico Weber | 22f9925 | 2019-02-20 10:13:16 -0500 | [diff] [blame] | 109 | PROXY_CONSTMETHOD0(rtc::scoped_refptr<DtmfSenderInterface>, GetDtmfSender) |
Benjamin Wright | d81ac95 | 2018-08-29 17:02:10 -0700 | [diff] [blame] | 110 | PROXY_METHOD1(void, |
| 111 | SetFrameEncryptor, |
Nico Weber | 22f9925 | 2019-02-20 10:13:16 -0500 | [diff] [blame] | 112 | rtc::scoped_refptr<FrameEncryptorInterface>) |
Benjamin Wright | d81ac95 | 2018-08-29 17:02:10 -0700 | [diff] [blame] | 113 | PROXY_CONSTMETHOD0(rtc::scoped_refptr<FrameEncryptorInterface>, |
Nico Weber | 22f9925 | 2019-02-20 10:13:16 -0500 | [diff] [blame] | 114 | GetFrameEncryptor) |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 115 | END_PROXY_MAP() |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 116 | |
| 117 | } // namespace webrtc |
| 118 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 119 | #endif // API_RTP_SENDER_INTERFACE_H_ |