blob: 7c94c216e64efbeb5c4628bebe6925a6f5023e15 [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
Mirko Bonadei92ea95e2017-09-15 04:47:3114#ifndef API_RTPSENDERINTERFACE_H_
15#define API_RTPSENDERINTERFACE_H_
deadbeef70ab1a12015-09-28 23:53:5516
17#include <string>
deadbeefa601f5c2016-06-06 21:27:3918#include <vector>
deadbeef70ab1a12015-09-28 23:53:5519
Benjamin Wrightd81ac952018-08-30 00:02:1020#include "api/crypto/frameencryptorinterface.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3121#include "api/dtmfsenderinterface.h"
22#include "api/mediastreaminterface.h"
23#include "api/mediatypes.h"
24#include "api/proxy.h"
Zach Steinba37b4b2018-01-23 23:02:3625#include "api/rtcerror.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3126#include "api/rtpparameters.h"
27#include "rtc_base/refcount.h"
28#include "rtc_base/scoped_ref_ptr.h"
deadbeef70ab1a12015-09-28 23:53:5529
30namespace webrtc {
31
32class 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
deadbeefa601f5c2016-06-06 21:27:3939 // Returns primary SSRC used by this sender for sending media.
40 // Returns 0 if not yet determined.
Danil Chapovalov0bc58cf2018-06-21 11:32:5641 // TODO(deadbeef): Change to absl::optional.
deadbeefa601f5c2016-06-06 21:27:3942 // TODO(deadbeef): Remove? With GetParameters this should be redundant.
deadbeeffac06552015-11-25 19:26:0143 virtual uint32_t ssrc() const = 0;
44
45 // Audio or video sender?
46 virtual cricket::MediaType media_type() const = 0;
47
deadbeef70ab1a12015-09-28 23:53:5548 // 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 Hampson5b4f0752018-04-02 23:31:3652 // 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.
deadbeefa601f5c2016-06-06 21:27:3955 virtual std::vector<std::string> stream_ids() const = 0;
deadbeef70ab1a12015-09-28 23:53:5556
Florent Castelli892acf02018-10-01 20:47:2057 // 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 Castelli4c6390a2018-06-04 14:01:2263 virtual RtpParameters GetParameters() = 0;
deadbeefb10f32f2017-02-08 09:38:2164 // Note that only a subset of the parameters can currently be changed. See
65 // rtpparameters.h
Åsa Persson55659812018-06-18 15:51:3266 // The encodings are in increasing quality order for simulcast.
Zach Steinba37b4b2018-01-23 23:02:3667 virtual RTCError SetParameters(const RtpParameters& parameters) = 0;
skvladdc1c62c2016-03-17 02:07:4368
deadbeef20cb0c12017-02-02 04:27:0069 // Returns null for a video sender.
70 virtual rtc::scoped_refptr<DtmfSenderInterface> GetDtmfSender() const = 0;
71
Benjamin Wrightd81ac952018-08-30 00:02:1072 // 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
deadbeef70ab1a12015-09-28 23:53:5583 protected:
Mirko Bonadei79eb4dd2018-07-19 08:39:3084 ~RtpSenderInterface() override = default;
deadbeef70ab1a12015-09-28 23:53:5585};
86
87// Define proxy for RtpSenderInterface.
deadbeefb10f32f2017-02-08 09:38:2188// TODO(deadbeef): Move this to .cc file and out of api/. What threads methods
89// are called on is an implementation detail.
nisse72c8d2b2016-04-15 10:49:0790BEGIN_SIGNALING_PROXY_MAP(RtpSender)
Yves Gerey665174f2018-06-19 13:03:0591PROXY_SIGNALING_THREAD_DESTRUCTOR()
92PROXY_METHOD1(bool, SetTrack, MediaStreamTrackInterface*)
93PROXY_CONSTMETHOD0(rtc::scoped_refptr<MediaStreamTrackInterface>, track)
94PROXY_CONSTMETHOD0(uint32_t, ssrc)
95PROXY_CONSTMETHOD0(cricket::MediaType, media_type)
96PROXY_CONSTMETHOD0(std::string, id)
97PROXY_CONSTMETHOD0(std::vector<std::string>, stream_ids)
Florent Castelli892acf02018-10-01 20:47:2098PROXY_CONSTMETHOD0(std::vector<RtpEncodingParameters>, init_send_encodings)
Yves Gerey665174f2018-06-19 13:03:0599PROXY_METHOD0(RtpParameters, GetParameters);
100PROXY_METHOD1(RTCError, SetParameters, const RtpParameters&)
101PROXY_CONSTMETHOD0(rtc::scoped_refptr<DtmfSenderInterface>, GetDtmfSender);
Benjamin Wrightd81ac952018-08-30 00:02:10102PROXY_METHOD1(void,
103 SetFrameEncryptor,
104 rtc::scoped_refptr<FrameEncryptorInterface>);
105PROXY_CONSTMETHOD0(rtc::scoped_refptr<FrameEncryptorInterface>,
106 GetFrameEncryptor);
Yves Gerey665174f2018-06-19 13:03:05107END_PROXY_MAP()
deadbeef70ab1a12015-09-28 23:53:55108
109} // namespace webrtc
110
Mirko Bonadei92ea95e2017-09-15 04:47:31111#endif // API_RTPSENDERINTERFACE_H_