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