blob: 2786a2ac1948f1f6697801a8d8242013ed8bef46 [file] [log] [blame]
deadbeef6979b022015-09-24 23:47:531/*
kjellanderb24317b2016-02-10 15:54:432 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
deadbeef6979b022015-09-24 23:47:533 *
kjellanderb24317b2016-02-10 15:54:434 * 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.
deadbeef6979b022015-09-24 23:47:539 */
10
deadbeef70ab1a12015-09-28 23:53:5511// This file contains interfaces for RtpSenders
12// http://w3c.github.io/webrtc-pc/#rtcrtpsender-interface
13
Steve Anton10542f22019-01-11 17:11:0014#ifndef API_RTP_SENDER_INTERFACE_H_
15#define API_RTP_SENDER_INTERFACE_H_
deadbeef70ab1a12015-09-28 23:53:5516
Jonas Oreland65455162022-06-08 09:25:4617#include <memory>
deadbeef70ab1a12015-09-28 23:53:5518#include <string>
deadbeefa601f5c2016-06-06 21:27:3919#include <vector>
deadbeef70ab1a12015-09-28 23:53:5520
Florent Castelliacabb362022-10-18 15:05:1621#include "absl/functional/any_invocable.h"
Steve Anton10542f22019-01-11 17:11:0022#include "api/crypto/frame_encryptor_interface.h"
Harald Alvestrand4a7b3ac2019-01-17 09:39:4023#include "api/dtls_transport_interface.h"
Steve Anton10542f22019-01-11 17:11:0024#include "api/dtmf_sender_interface.h"
Marina Cioceae77912b2020-02-27 15:16:5525#include "api/frame_transformer_interface.h"
Steve Anton10542f22019-01-11 17:11:0026#include "api/media_stream_interface.h"
27#include "api/media_types.h"
Steve Anton10542f22019-01-11 17:11:0028#include "api/rtc_error.h"
29#include "api/rtp_parameters.h"
Mirko Bonadeid9708072019-01-25 19:26:4830#include "api/scoped_refptr.h"
Jonas Oreland65455162022-06-08 09:25:4631#include "api/video_codecs/video_encoder_factory.h"
Steve Anton10542f22019-01-11 17:11:0032#include "rtc_base/ref_count.h"
Mirko Bonadei35214fc2019-09-23 12:54:2833#include "rtc_base/system/rtc_export.h"
deadbeef70ab1a12015-09-28 23:53:5534
35namespace webrtc {
36
Florent Castelliacabb362022-10-18 15:05:1637using SetParametersCallback = absl::AnyInvocable<void(RTCError) &&>;
38
Mirko Bonadei35214fc2019-09-23 12:54:2839class RTC_EXPORT RtpSenderInterface : public rtc::RefCountInterface {
deadbeef70ab1a12015-09-28 23:53:5540 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
Harald Alvestrand4a7b3ac2019-01-17 09:39:4046 // 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
Andrey Logvin24c10792022-08-31 08:55:3349 virtual rtc::scoped_refptr<DtlsTransportInterface> dtls_transport() const = 0;
Harald Alvestrand4a7b3ac2019-01-17 09:39:4050
deadbeefa601f5c2016-06-06 21:27:3951 // Returns primary SSRC used by this sender for sending media.
52 // Returns 0 if not yet determined.
Danil Chapovalov0bc58cf2018-06-21 11:32:5653 // TODO(deadbeef): Change to absl::optional.
deadbeefa601f5c2016-06-06 21:27:3954 // TODO(deadbeef): Remove? With GetParameters this should be redundant.
deadbeeffac06552015-11-25 19:26:0155 virtual uint32_t ssrc() const = 0;
56
57 // Audio or video sender?
58 virtual cricket::MediaType media_type() const = 0;
59
deadbeef70ab1a12015-09-28 23:53:5560 // 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
Seth Hampson5b4f0752018-04-02 23:31:3664 // 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.
deadbeefa601f5c2016-06-06 21:27:3967 virtual std::vector<std::string> stream_ids() const = 0;
deadbeef70ab1a12015-09-28 23:53:5568
Guido Urdaneta1ff16c82019-05-20 17:31:5369 // 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.
Andrey Logvin24c10792022-08-31 08:55:3372 virtual void SetStreams(const std::vector<std::string>& stream_ids) = 0;
Guido Urdaneta1ff16c82019-05-20 17:31:5373
Florent Castelli892acf02018-10-01 20:47:2074 // 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
Andrey Logvin24c10792022-08-31 08:55:3378 virtual std::vector<RtpEncodingParameters> init_send_encodings() const = 0;
Florent Castelli892acf02018-10-01 20:47:2079
Amit Hilbuche1e789b2019-02-20 18:40:1280 virtual RtpParameters GetParameters() const = 0;
deadbeefb10f32f2017-02-08 09:38:2181 // Note that only a subset of the parameters can currently be changed. See
82 // rtpparameters.h
Åsa Persson55659812018-06-18 15:51:3283 // The encodings are in increasing quality order for simulcast.
Zach Steinba37b4b2018-01-23 23:02:3684 virtual RTCError SetParameters(const RtpParameters& parameters) = 0;
Florent Castelliacabb362022-10-18 15:05:1685 virtual void SetParametersAsync(const RtpParameters& parameters,
86 SetParametersCallback callback);
skvladdc1c62c2016-03-17 02:07:4387
deadbeef20cb0c12017-02-02 04:27:0088 // Returns null for a video sender.
89 virtual rtc::scoped_refptr<DtmfSenderInterface> GetDtmfSender() const = 0;
90
Benjamin Wrightd81ac952018-08-30 00:02:1091 // 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(
Andrey Logvin24c10792022-08-31 08:55:3396 rtc::scoped_refptr<FrameEncryptorInterface> frame_encryptor) = 0;
Benjamin Wrightd81ac952018-08-30 00:02:1097
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.
Andrey Logvin24c10792022-08-31 08:55:33100 virtual rtc::scoped_refptr<FrameEncryptorInterface> GetFrameEncryptor()
101 const = 0;
Benjamin Wrightd81ac952018-08-30 00:02:10102
Marina Cioceae77912b2020-02-27 15:16:55103 virtual void SetEncoderToPacketizerFrameTransformer(
Andrey Logvin24c10792022-08-31 08:55:33104 rtc::scoped_refptr<FrameTransformerInterface> frame_transformer) = 0;
Marina Cioceae77912b2020-02-27 15:16:55105
Jonas Oreland65455162022-06-08 09:25:46106 // 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>
Andrey Logvin24c10792022-08-31 08:55:33110 encoder_selector) = 0;
Jonas Oreland65455162022-06-08 09:25:46111
Philipp Hancked237c2b2022-10-25 07:54:28112 // TODO(crbug.com/1354101): make pure virtual again after Chrome roll.
Philipp Hanckea1b4eb22022-11-04 13:45:23113 virtual RTCError GenerateKeyFrame(const std::vector<std::string>& rids) {
114 return RTCError::OK();
115 }
Philipp Hancked237c2b2022-10-25 07:54:28116
deadbeef70ab1a12015-09-28 23:53:55117 protected:
Mirko Bonadei79eb4dd2018-07-19 08:39:30118 ~RtpSenderInterface() override = default;
deadbeef70ab1a12015-09-28 23:53:55119};
120
deadbeef70ab1a12015-09-28 23:53:55121} // namespace webrtc
122
Steve Anton10542f22019-01-11 17:11:00123#endif // API_RTP_SENDER_INTERFACE_H_