deadbeef | 6979b02 | 2015-09-24 23:47:53 | [diff] [blame] | 1 | /* |
kjellander | b24317b | 2016-02-10 15:54:43 | [diff] [blame] | 2 | * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
deadbeef | 6979b02 | 2015-09-24 23:47:53 | [diff] [blame] | 3 | * |
kjellander | b24317b | 2016-02-10 15:54:43 | [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 23:47:53 | [diff] [blame] | 9 | */ |
| 10 | |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 11 | // This file contains interfaces for RtpReceivers |
| 12 | // http://w3c.github.io/webrtc-pc/#rtcrtpreceiver-interface |
| 13 | |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 14 | #ifndef API_RTP_RECEIVER_INTERFACE_H_ |
| 15 | #define API_RTP_RECEIVER_INTERFACE_H_ |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 16 | |
| 17 | #include <string> |
hbos | 8d609f6 | 2017-04-10 14:39:05 | [diff] [blame] | 18 | #include <vector> |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 19 | |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 20 | #include "api/crypto/frame_decryptor_interface.h" |
Harald Alvestrand | 4a7b3ac | 2019-01-17 09:39:40 | [diff] [blame] | 21 | #include "api/dtls_transport_interface.h" |
Marina Ciocea | 412a31b | 2020-02-28 15:02:06 | [diff] [blame] | 22 | #include "api/frame_transformer_interface.h" |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 23 | #include "api/media_stream_interface.h" |
| 24 | #include "api/media_types.h" |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 25 | #include "api/rtp_parameters.h" |
Mirko Bonadei | d970807 | 2019-01-25 19:26:48 | [diff] [blame] | 26 | #include "api/scoped_refptr.h" |
Niels Möller | a837030 | 2019-09-02 13:16:49 | [diff] [blame] | 27 | #include "api/transport/rtp/rtp_source.h" |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 28 | #include "rtc_base/ref_count.h" |
Mirko Bonadei | 35214fc | 2019-09-23 12:54:28 | [diff] [blame] | 29 | #include "rtc_base/system/rtc_export.h" |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 30 | |
| 31 | namespace webrtc { |
| 32 | |
zhihuang | 184a3fd | 2016-06-14 18:47:14 | [diff] [blame] | 33 | class RtpReceiverObserverInterface { |
| 34 | public: |
Taylor Brandstetter | ba29c6a | 2016-06-27 23:30:35 | [diff] [blame] | 35 | // Note: Currently if there are multiple RtpReceivers of the same media type, |
| 36 | // they will all call OnFirstPacketReceived at once. |
| 37 | // |
| 38 | // In the future, it's likely that an RtpReceiver will only call |
| 39 | // OnFirstPacketReceived when a packet is received specifically for its |
| 40 | // SSRC/mid. |
zhihuang | 184a3fd | 2016-06-14 18:47:14 | [diff] [blame] | 41 | virtual void OnFirstPacketReceived(cricket::MediaType media_type) = 0; |
| 42 | |
| 43 | protected: |
| 44 | virtual ~RtpReceiverObserverInterface() {} |
| 45 | }; |
| 46 | |
Mirko Bonadei | 35214fc | 2019-09-23 12:54:28 | [diff] [blame] | 47 | class RTC_EXPORT RtpReceiverInterface : public rtc::RefCountInterface { |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 48 | public: |
| 49 | virtual rtc::scoped_refptr<MediaStreamTrackInterface> track() const = 0; |
Harald Alvestrand | 4a7b3ac | 2019-01-17 09:39:40 | [diff] [blame] | 50 | |
| 51 | // The dtlsTransport attribute exposes the DTLS transport on which the |
| 52 | // media is received. It may be null. |
| 53 | // https://w3c.github.io/webrtc-pc/#dom-rtcrtpreceiver-transport |
| 54 | // TODO(https://bugs.webrtc.org/907849) remove default implementation |
| 55 | virtual rtc::scoped_refptr<DtlsTransportInterface> dtls_transport() const; |
| 56 | |
Artem Titov | 0e61fdd | 2021-07-25 19:50:14 | [diff] [blame] | 57 | // The list of streams that `track` is associated with. This is the same as |
Henrik Boström | 9e6fd2b | 2017-11-21 12:41:51 | [diff] [blame] | 58 | // the [[AssociatedRemoteMediaStreams]] internal slot in the spec. |
Henrik Boström | 199e27b | 2018-07-04 18:51:53 | [diff] [blame] | 59 | // https://w3c.github.io/webrtc-pc/#dfn-associatedremotemediastreams |
Henrik Boström | 9e6fd2b | 2017-11-21 12:41:51 | [diff] [blame] | 60 | // TODO(hbos): Make pure virtual as soon as Chromium's mock implements this. |
Henrik Boström | 199e27b | 2018-07-04 18:51:53 | [diff] [blame] | 61 | // TODO(https://crbug.com/webrtc/9480): Remove streams() in favor of |
| 62 | // stream_ids() as soon as downstream projects are no longer dependent on |
| 63 | // stream objects. |
| 64 | virtual std::vector<std::string> stream_ids() const; |
Danil Chapovalov | 2a5ce2b | 2018-02-07 08:38:31 | [diff] [blame] | 65 | virtual std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams() const; |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 66 | |
Taylor Brandstetter | ba29c6a | 2016-06-27 23:30:35 | [diff] [blame] | 67 | // Audio or video receiver? |
| 68 | virtual cricket::MediaType media_type() const = 0; |
| 69 | |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 70 | // Not to be confused with "mid", this is a field we can temporarily use |
| 71 | // to uniquely identify a receiver until we implement Unified Plan SDP. |
| 72 | virtual std::string id() const = 0; |
| 73 | |
Taylor Brandstetter | db0cd9e | 2016-05-16 18:40:30 | [diff] [blame] | 74 | // The WebRTC specification only defines RTCRtpParameters in terms of senders, |
| 75 | // but this API also applies them to receivers, similar to ORTC: |
| 76 | // http://ortc.org/wp-content/uploads/2016/03/ortc.html#rtcrtpparameters*. |
| 77 | virtual RtpParameters GetParameters() const = 0; |
Saurav Das | 934afc6 | 2019-11-21 19:54:16 | [diff] [blame] | 78 | // TODO(dinosaurav): Delete SetParameters entirely after rolling to Chromium. |
| 79 | // Currently, doesn't support changing any parameters. |
| 80 | virtual bool SetParameters(const RtpParameters& parameters) { return false; } |
Taylor Brandstetter | db0cd9e | 2016-05-16 18:40:30 | [diff] [blame] | 81 | |
Taylor Brandstetter | ba29c6a | 2016-06-27 23:30:35 | [diff] [blame] | 82 | // Does not take ownership of observer. |
| 83 | // Must call SetObserver(nullptr) before the observer is destroyed. |
zhihuang | 184a3fd | 2016-06-14 18:47:14 | [diff] [blame] | 84 | virtual void SetObserver(RtpReceiverObserverInterface* observer) = 0; |
| 85 | |
Ruslan Burakov | 4bac79e | 2019-04-03 17:55:33 | [diff] [blame] | 86 | // Sets the jitter buffer minimum delay until media playout. Actual observed |
Artem Titov | 0e61fdd | 2021-07-25 19:50:14 | [diff] [blame] | 87 | // delay may differ depending on the congestion control. `delay_seconds` is a |
| 88 | // positive value including 0.0 measured in seconds. `nullopt` means default |
Ruslan Burakov | 428dcb2 | 2019-04-18 15:49:49 | [diff] [blame] | 89 | // value must be used. |
Ruslan Burakov | 4bac79e | 2019-04-03 17:55:33 | [diff] [blame] | 90 | virtual void SetJitterBufferMinimumDelay( |
Ruslan Burakov | 428dcb2 | 2019-04-18 15:49:49 | [diff] [blame] | 91 | absl::optional<double> delay_seconds) = 0; |
Ruslan Burakov | 4bac79e | 2019-04-03 17:55:33 | [diff] [blame] | 92 | |
hbos | 8d609f6 | 2017-04-10 14:39:05 | [diff] [blame] | 93 | // TODO(zhihuang): Remove the default implementation once the subclasses |
| 94 | // implement this. Currently, the only relevant subclass is the |
| 95 | // content::FakeRtpReceiver in Chromium. |
Danil Chapovalov | 2a5ce2b | 2018-02-07 08:38:31 | [diff] [blame] | 96 | virtual std::vector<RtpSource> GetSources() const; |
| 97 | |
Benjamin Wright | d81ac95 | 2018-08-30 00:02:10 | [diff] [blame] | 98 | // Sets a user defined frame decryptor that will decrypt the entire frame |
| 99 | // before it is sent across the network. This will decrypt the entire frame |
| 100 | // using the user provided decryption mechanism regardless of whether SRTP is |
| 101 | // enabled or not. |
Tommi | 4ccdf932 | 2021-05-17 12:50:10 | [diff] [blame] | 102 | // TODO(bugs.webrtc.org/12772): Remove. |
Benjamin Wright | d81ac95 | 2018-08-30 00:02:10 | [diff] [blame] | 103 | virtual void SetFrameDecryptor( |
| 104 | rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor); |
| 105 | |
| 106 | // Returns a pointer to the frame decryptor set previously by the |
| 107 | // user. This can be used to update the state of the object. |
Tommi | 4ccdf932 | 2021-05-17 12:50:10 | [diff] [blame] | 108 | // TODO(bugs.webrtc.org/12772): Remove. |
Benjamin Wright | d81ac95 | 2018-08-30 00:02:10 | [diff] [blame] | 109 | virtual rtc::scoped_refptr<FrameDecryptorInterface> GetFrameDecryptor() const; |
| 110 | |
Marina Ciocea | 412a31b | 2020-02-28 15:02:06 | [diff] [blame] | 111 | // Sets a frame transformer between the depacketizer and the decoder to enable |
| 112 | // client code to transform received frames according to their own processing |
| 113 | // logic. |
| 114 | virtual void SetDepacketizerToDecoderFrameTransformer( |
| 115 | rtc::scoped_refptr<FrameTransformerInterface> frame_transformer); |
| 116 | |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 117 | protected: |
Danil Chapovalov | 2a5ce2b | 2018-02-07 08:38:31 | [diff] [blame] | 118 | ~RtpReceiverInterface() override = default; |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 119 | }; |
| 120 | |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 121 | } // namespace webrtc |
| 122 | |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 123 | #endif // API_RTP_RECEIVER_INTERFACE_H_ |