blob: 96c2669eff44bc8ea0df7764399dd9a53556b1d1 [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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020014#ifndef API_RTPSENDERINTERFACE_H_
15#define API_RTPSENDERINTERFACE_H_
deadbeef70ab1a12015-09-28 16:53:55 -070016
17#include <string>
deadbeefa601f5c2016-06-06 14:27:39 -070018#include <vector>
deadbeef70ab1a12015-09-28 16:53:55 -070019
Benjamin Wrightd81ac952018-08-29 17:02:10 -070020#include "api/crypto/frameencryptorinterface.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020021#include "api/dtmfsenderinterface.h"
22#include "api/mediastreaminterface.h"
23#include "api/mediatypes.h"
24#include "api/proxy.h"
Zach Steinba37b4b2018-01-23 15:02:36 -080025#include "api/rtcerror.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020026#include "api/rtpparameters.h"
Florent Castellicebf50f2018-05-03 15:31:53 +020027#include "rtc_base/deprecation.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020028#include "rtc_base/refcount.h"
29#include "rtc_base/scoped_ref_ptr.h"
deadbeef70ab1a12015-09-28 16:53:55 -070030
31namespace webrtc {
32
33class 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
deadbeefa601f5c2016-06-06 14:27:39 -070040 // Returns primary SSRC used by this sender for sending media.
41 // Returns 0 if not yet determined.
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +020042 // TODO(deadbeef): Change to absl::optional.
deadbeefa601f5c2016-06-06 14:27:39 -070043 // TODO(deadbeef): Remove? With GetParameters this should be redundant.
deadbeeffac06552015-11-25 11:26:01 -080044 virtual uint32_t ssrc() const = 0;
45
46 // Audio or video sender?
47 virtual cricket::MediaType media_type() const = 0;
48
deadbeef70ab1a12015-09-28 16:53:55 -070049 // Not to be confused with "mid", this is a field we can temporarily use
50 // to uniquely identify a receiver until we implement Unified Plan SDP.
51 virtual std::string id() const = 0;
52
Seth Hampson5b4f0752018-04-02 16:31:36 -070053 // Returns a list of media stream ids associated with this sender's track.
54 // These are signalled in the SDP so that the remote side can associate
55 // tracks.
deadbeefa601f5c2016-06-06 14:27:39 -070056 virtual std::vector<std::string> stream_ids() const = 0;
deadbeef70ab1a12015-09-28 16:53:55 -070057
Florent Castelli4c6390a2018-06-04 16:01:22 +020058 virtual RtpParameters GetParameters() = 0;
deadbeefb10f32f2017-02-08 01:38:21 -080059 // Note that only a subset of the parameters can currently be changed. See
60 // rtpparameters.h
Åsa Persson55659812018-06-18 17:51:32 +020061 // The encodings are in increasing quality order for simulcast.
Zach Steinba37b4b2018-01-23 15:02:36 -080062 virtual RTCError SetParameters(const RtpParameters& parameters) = 0;
skvladdc1c62c2016-03-16 19:07:43 -070063
deadbeef20cb0c12017-02-01 20:27:00 -080064 // Returns null for a video sender.
65 virtual rtc::scoped_refptr<DtmfSenderInterface> GetDtmfSender() const = 0;
66
Benjamin Wrightd81ac952018-08-29 17:02:10 -070067 // Sets a user defined frame encryptor that will encrypt the entire frame
68 // before it is sent across the network. This will encrypt the entire frame
69 // using the user provided encryption mechanism regardless of whether SRTP is
70 // enabled or not.
71 virtual void SetFrameEncryptor(
72 rtc::scoped_refptr<FrameEncryptorInterface> frame_encryptor);
73
74 // Returns a pointer to the frame encryptor set previously by the
75 // user. This can be used to update the state of the object.
76 virtual rtc::scoped_refptr<FrameEncryptorInterface> GetFrameEncryptor() const;
77
deadbeef70ab1a12015-09-28 16:53:55 -070078 protected:
Mirko Bonadei79eb4dd2018-07-19 10:39:30 +020079 ~RtpSenderInterface() override = default;
deadbeef70ab1a12015-09-28 16:53:55 -070080};
81
82// Define proxy for RtpSenderInterface.
deadbeefb10f32f2017-02-08 01:38:21 -080083// TODO(deadbeef): Move this to .cc file and out of api/. What threads methods
84// are called on is an implementation detail.
nisse72c8d2b2016-04-15 03:49:07 -070085BEGIN_SIGNALING_PROXY_MAP(RtpSender)
Yves Gerey665174f2018-06-19 15:03:05 +020086PROXY_SIGNALING_THREAD_DESTRUCTOR()
87PROXY_METHOD1(bool, SetTrack, MediaStreamTrackInterface*)
88PROXY_CONSTMETHOD0(rtc::scoped_refptr<MediaStreamTrackInterface>, track)
89PROXY_CONSTMETHOD0(uint32_t, ssrc)
90PROXY_CONSTMETHOD0(cricket::MediaType, media_type)
91PROXY_CONSTMETHOD0(std::string, id)
92PROXY_CONSTMETHOD0(std::vector<std::string>, stream_ids)
93PROXY_METHOD0(RtpParameters, GetParameters);
94PROXY_METHOD1(RTCError, SetParameters, const RtpParameters&)
95PROXY_CONSTMETHOD0(rtc::scoped_refptr<DtmfSenderInterface>, GetDtmfSender);
Benjamin Wrightd81ac952018-08-29 17:02:10 -070096PROXY_METHOD1(void,
97 SetFrameEncryptor,
98 rtc::scoped_refptr<FrameEncryptorInterface>);
99PROXY_CONSTMETHOD0(rtc::scoped_refptr<FrameEncryptorInterface>,
100 GetFrameEncryptor);
Yves Gerey665174f2018-06-19 15:03:05 +0200101END_PROXY_MAP()
deadbeef70ab1a12015-09-28 16:53:55 -0700102
103} // namespace webrtc
104
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200105#endif // API_RTPSENDERINTERFACE_H_