blob: 6fc658f9ee631b14e41c58af17a54c191b5f34e1 [file] [log] [blame]
deadbeef6979b022015-09-24 16:47:53 -07001/*
kjellanderb24317b2016-02-10 07:54:43 -08002 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
deadbeef6979b022015-09-24 16:47:53 -07003 *
kjellanderb24317b2016-02-10 07:54:43 -08004 * 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 16:47:53 -07009 */
10
deadbeef70ab1a12015-09-28 16:53:55 -070011// This file contains interfaces for RtpSenders
12// http://w3c.github.io/webrtc-pc/#rtcrtpsender-interface
13
Steve Anton10542f22019-01-11 09:11:00 -080014#ifndef API_RTP_SENDER_INTERFACE_H_
15#define API_RTP_SENDER_INTERFACE_H_
deadbeef70ab1a12015-09-28 16:53:55 -070016
Jonas Oreland65455162022-06-08 11:25:46 +020017#include <memory>
deadbeef70ab1a12015-09-28 16:53:55 -070018#include <string>
deadbeefa601f5c2016-06-06 14:27:39 -070019#include <vector>
deadbeef70ab1a12015-09-28 16:53:55 -070020
Steve Anton10542f22019-01-11 09:11:00 -080021#include "api/crypto/frame_encryptor_interface.h"
Harald Alvestrand4a7b3ac2019-01-17 10:39:40 +010022#include "api/dtls_transport_interface.h"
Steve Anton10542f22019-01-11 09:11:00 -080023#include "api/dtmf_sender_interface.h"
Marina Cioceae77912b2020-02-27 16:16:55 +010024#include "api/frame_transformer_interface.h"
Steve Anton10542f22019-01-11 09:11:00 -080025#include "api/media_stream_interface.h"
26#include "api/media_types.h"
Steve Anton10542f22019-01-11 09:11:00 -080027#include "api/rtc_error.h"
28#include "api/rtp_parameters.h"
Mirko Bonadeid9708072019-01-25 20:26:48 +010029#include "api/scoped_refptr.h"
Jonas Oreland65455162022-06-08 11:25:46 +020030#include "api/video_codecs/video_encoder_factory.h"
Steve Anton10542f22019-01-11 09:11:00 -080031#include "rtc_base/ref_count.h"
Mirko Bonadei35214fc2019-09-23 14:54:28 +020032#include "rtc_base/system/rtc_export.h"
deadbeef70ab1a12015-09-28 16:53:55 -070033
34namespace webrtc {
35
Mirko Bonadei35214fc2019-09-23 14:54:28 +020036class RTC_EXPORT RtpSenderInterface : public rtc::RefCountInterface {
deadbeef70ab1a12015-09-28 16:53:55 -070037 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
Harald Alvestrand4a7b3ac2019-01-17 10:39:40 +010043 // 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
Andrey Logvin24c10792022-08-31 08:55:33 +000046 virtual rtc::scoped_refptr<DtlsTransportInterface> dtls_transport() const = 0;
Harald Alvestrand4a7b3ac2019-01-17 10:39:40 +010047
deadbeefa601f5c2016-06-06 14:27:39 -070048 // Returns primary SSRC used by this sender for sending media.
49 // Returns 0 if not yet determined.
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +020050 // TODO(deadbeef): Change to absl::optional.
deadbeefa601f5c2016-06-06 14:27:39 -070051 // TODO(deadbeef): Remove? With GetParameters this should be redundant.
deadbeeffac06552015-11-25 11:26:01 -080052 virtual uint32_t ssrc() const = 0;
53
54 // Audio or video sender?
55 virtual cricket::MediaType media_type() const = 0;
56
deadbeef70ab1a12015-09-28 16:53:55 -070057 // 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
Seth Hampson5b4f0752018-04-02 16:31:36 -070061 // 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.
deadbeefa601f5c2016-06-06 14:27:39 -070064 virtual std::vector<std::string> stream_ids() const = 0;
deadbeef70ab1a12015-09-28 16:53:55 -070065
Guido Urdaneta1ff16c82019-05-20 19:31:53 +020066 // 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.
Andrey Logvin24c10792022-08-31 08:55:33 +000069 virtual void SetStreams(const std::vector<std::string>& stream_ids) = 0;
Guido Urdaneta1ff16c82019-05-20 19:31:53 +020070
Florent Castelli892acf02018-10-01 22:47:20 +020071 // 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
Andrey Logvin24c10792022-08-31 08:55:33 +000075 virtual std::vector<RtpEncodingParameters> init_send_encodings() const = 0;
Florent Castelli892acf02018-10-01 22:47:20 +020076
Amit Hilbuche1e789b2019-02-20 10:40:12 -080077 virtual RtpParameters GetParameters() const = 0;
deadbeefb10f32f2017-02-08 01:38:21 -080078 // Note that only a subset of the parameters can currently be changed. See
79 // rtpparameters.h
Åsa Persson55659812018-06-18 17:51:32 +020080 // The encodings are in increasing quality order for simulcast.
Zach Steinba37b4b2018-01-23 15:02:36 -080081 virtual RTCError SetParameters(const RtpParameters& parameters) = 0;
skvladdc1c62c2016-03-16 19:07:43 -070082
deadbeef20cb0c12017-02-01 20:27:00 -080083 // Returns null for a video sender.
84 virtual rtc::scoped_refptr<DtmfSenderInterface> GetDtmfSender() const = 0;
85
Benjamin Wrightd81ac952018-08-29 17:02:10 -070086 // 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(
Andrey Logvin24c10792022-08-31 08:55:33 +000091 rtc::scoped_refptr<FrameEncryptorInterface> frame_encryptor) = 0;
Benjamin Wrightd81ac952018-08-29 17:02:10 -070092
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.
Andrey Logvin24c10792022-08-31 08:55:33 +000095 virtual rtc::scoped_refptr<FrameEncryptorInterface> GetFrameEncryptor()
96 const = 0;
Benjamin Wrightd81ac952018-08-29 17:02:10 -070097
Marina Cioceae77912b2020-02-27 16:16:55 +010098 virtual void SetEncoderToPacketizerFrameTransformer(
Andrey Logvin24c10792022-08-31 08:55:33 +000099 rtc::scoped_refptr<FrameTransformerInterface> frame_transformer) = 0;
Marina Cioceae77912b2020-02-27 16:16:55 +0100100
Jonas Oreland65455162022-06-08 11:25:46 +0200101 // 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>
Andrey Logvin24c10792022-08-31 08:55:33 +0000105 encoder_selector) = 0;
Jonas Oreland65455162022-06-08 11:25:46 +0200106
Philipp Hancked237c2b2022-10-25 09:54:28 +0200107 // TODO(crbug.com/1354101): make pure virtual again after Chrome roll.
108 virtual RTCError GenerateKeyFrame() { return RTCError::OK(); }
109
deadbeef70ab1a12015-09-28 16:53:55 -0700110 protected:
Mirko Bonadei79eb4dd2018-07-19 10:39:30 +0200111 ~RtpSenderInterface() override = default;
deadbeef70ab1a12015-09-28 16:53:55 -0700112};
113
deadbeef70ab1a12015-09-28 16:53:55 -0700114} // namespace webrtc
115
Steve Anton10542f22019-01-11 09:11:00 -0800116#endif // API_RTP_SENDER_INTERFACE_H_