deadbeef | 6979b02 | 2015-09-24 16:47:53 -0700 | [diff] [blame] | 1 | /* |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 2 | * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
deadbeef | 6979b02 | 2015-09-24 16:47:53 -0700 | [diff] [blame] | 3 | * |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [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 16:47:53 -0700 | [diff] [blame] | 9 | */ |
| 10 | |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [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 06:47:31 +0200 | [diff] [blame] | 14 | #ifndef API_RTPSENDERINTERFACE_H_ |
| 15 | #define API_RTPSENDERINTERFACE_H_ |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 16 | |
| 17 | #include <string> |
deadbeef | a601f5c | 2016-06-06 14:27:39 -0700 | [diff] [blame] | 18 | #include <vector> |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 19 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 20 | #include "api/dtmfsenderinterface.h" |
| 21 | #include "api/mediastreaminterface.h" |
| 22 | #include "api/mediatypes.h" |
| 23 | #include "api/proxy.h" |
| 24 | #include "api/rtpparameters.h" |
| 25 | #include "rtc_base/refcount.h" |
| 26 | #include "rtc_base/scoped_ref_ptr.h" |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 27 | |
| 28 | namespace webrtc { |
| 29 | |
| 30 | class RtpSenderInterface : public rtc::RefCountInterface { |
| 31 | public: |
| 32 | // Returns true if successful in setting the track. |
| 33 | // Fails if an audio track is set on a video RtpSender, or vice-versa. |
| 34 | virtual bool SetTrack(MediaStreamTrackInterface* track) = 0; |
| 35 | virtual rtc::scoped_refptr<MediaStreamTrackInterface> track() const = 0; |
| 36 | |
deadbeef | a601f5c | 2016-06-06 14:27:39 -0700 | [diff] [blame] | 37 | // Returns primary SSRC used by this sender for sending media. |
| 38 | // Returns 0 if not yet determined. |
| 39 | // TODO(deadbeef): Change to rtc::Optional. |
| 40 | // TODO(deadbeef): Remove? With GetParameters this should be redundant. |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 41 | virtual uint32_t ssrc() const = 0; |
| 42 | |
| 43 | // Audio or video sender? |
| 44 | virtual cricket::MediaType media_type() const = 0; |
| 45 | |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 46 | // Not to be confused with "mid", this is a field we can temporarily use |
| 47 | // to uniquely identify a receiver until we implement Unified Plan SDP. |
| 48 | virtual std::string id() const = 0; |
| 49 | |
deadbeef | b10f32f | 2017-02-08 01:38:21 -0800 | [diff] [blame] | 50 | // Returns a list of streams associated with this sender's track. Although we |
| 51 | // only support one track per stream, in theory the API allows for multiple. |
deadbeef | a601f5c | 2016-06-06 14:27:39 -0700 | [diff] [blame] | 52 | virtual std::vector<std::string> stream_ids() const = 0; |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 53 | |
skvlad | dc1c62c | 2016-03-16 19:07:43 -0700 | [diff] [blame] | 54 | virtual RtpParameters GetParameters() const = 0; |
deadbeef | b10f32f | 2017-02-08 01:38:21 -0800 | [diff] [blame] | 55 | // Note that only a subset of the parameters can currently be changed. See |
| 56 | // rtpparameters.h |
skvlad | dc1c62c | 2016-03-16 19:07:43 -0700 | [diff] [blame] | 57 | virtual bool SetParameters(const RtpParameters& parameters) = 0; |
| 58 | |
deadbeef | 20cb0c1 | 2017-02-01 20:27:00 -0800 | [diff] [blame] | 59 | // Returns null for a video sender. |
| 60 | virtual rtc::scoped_refptr<DtmfSenderInterface> GetDtmfSender() const = 0; |
| 61 | |
Harald Alvestrand | c72af93 | 2018-01-11 17:18:19 +0100 | [diff] [blame^] | 62 | // Returns an ID that changes every time SetTrack() is called, but |
| 63 | // otherwise remains constant. Used to generate IDs for stats. |
| 64 | // The special value zero means that no track is attached. |
| 65 | // TODO(hta): Remove default implementation when callers have updated, |
| 66 | // or move function to an internal interface. |
| 67 | virtual int AttachmentId() const { return 0; } |
| 68 | |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 69 | protected: |
| 70 | virtual ~RtpSenderInterface() {} |
| 71 | }; |
| 72 | |
| 73 | // Define proxy for RtpSenderInterface. |
deadbeef | b10f32f | 2017-02-08 01:38:21 -0800 | [diff] [blame] | 74 | // TODO(deadbeef): Move this to .cc file and out of api/. What threads methods |
| 75 | // are called on is an implementation detail. |
nisse | 72c8d2b | 2016-04-15 03:49:07 -0700 | [diff] [blame] | 76 | BEGIN_SIGNALING_PROXY_MAP(RtpSender) |
deadbeef | d99a200 | 2017-01-18 08:55:23 -0800 | [diff] [blame] | 77 | PROXY_SIGNALING_THREAD_DESTRUCTOR() |
| 78 | PROXY_METHOD1(bool, SetTrack, MediaStreamTrackInterface*) |
| 79 | PROXY_CONSTMETHOD0(rtc::scoped_refptr<MediaStreamTrackInterface>, track) |
| 80 | PROXY_CONSTMETHOD0(uint32_t, ssrc) |
| 81 | PROXY_CONSTMETHOD0(cricket::MediaType, media_type) |
| 82 | PROXY_CONSTMETHOD0(std::string, id) |
| 83 | PROXY_CONSTMETHOD0(std::vector<std::string>, stream_ids) |
| 84 | PROXY_CONSTMETHOD0(RtpParameters, GetParameters); |
| 85 | PROXY_METHOD1(bool, SetParameters, const RtpParameters&) |
deadbeef | 20cb0c1 | 2017-02-01 20:27:00 -0800 | [diff] [blame] | 86 | PROXY_CONSTMETHOD0(rtc::scoped_refptr<DtmfSenderInterface>, GetDtmfSender); |
Harald Alvestrand | c72af93 | 2018-01-11 17:18:19 +0100 | [diff] [blame^] | 87 | PROXY_CONSTMETHOD0(int, AttachmentId); |
| 88 | END_PROXY_MAP() |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 89 | |
| 90 | } // namespace webrtc |
| 91 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 92 | #endif // API_RTPSENDERINTERFACE_H_ |