blob: b1b36b5c581d312ed747e5615c534220669742db [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 RtpReceivers
12// http://w3c.github.io/webrtc-pc/#rtcrtpreceiver-interface
13
Steve Anton10542f22019-01-11 17:11:0014#ifndef API_RTP_RECEIVER_INTERFACE_H_
15#define API_RTP_RECEIVER_INTERFACE_H_
deadbeef70ab1a12015-09-28 23:53:5516
17#include <string>
Harald Alvestrandb0e70572024-04-23 14:04:1818#include <utility>
hbos8d609f62017-04-10 14:39:0519#include <vector>
deadbeef70ab1a12015-09-28 23:53:5520
Harald Alvestrandb0e70572024-04-23 14:04:1821#include "absl/types/optional.h"
Steve Anton10542f22019-01-11 17:11:0022#include "api/crypto/frame_decryptor_interface.h"
Harald Alvestrand4a7b3ac2019-01-17 09:39:4023#include "api/dtls_transport_interface.h"
Marina Ciocea412a31b2020-02-28 15:02:0624#include "api/frame_transformer_interface.h"
Steve Anton10542f22019-01-11 17:11:0025#include "api/media_stream_interface.h"
26#include "api/media_types.h"
Harald Alvestrande8a2b3c2023-10-31 13:30:3027#include "api/ref_count.h"
Steve Anton10542f22019-01-11 17:11:0028#include "api/rtp_parameters.h"
Mirko Bonadeid9708072019-01-25 19:26:4829#include "api/scoped_refptr.h"
Niels Möllera8370302019-09-02 13:16:4930#include "api/transport/rtp/rtp_source.h"
Mirko Bonadei35214fc2019-09-23 12:54:2831#include "rtc_base/system/rtc_export.h"
deadbeef70ab1a12015-09-28 23:53:5532
33namespace webrtc {
34
zhihuang184a3fd2016-06-14 18:47:1435class RtpReceiverObserverInterface {
36 public:
Taylor Brandstetterba29c6a2016-06-27 23:30:3537 // Note: Currently if there are multiple RtpReceivers of the same media type,
38 // they will all call OnFirstPacketReceived at once.
39 //
40 // In the future, it's likely that an RtpReceiver will only call
41 // OnFirstPacketReceived when a packet is received specifically for its
42 // SSRC/mid.
zhihuang184a3fd2016-06-14 18:47:1443 virtual void OnFirstPacketReceived(cricket::MediaType media_type) = 0;
44
45 protected:
46 virtual ~RtpReceiverObserverInterface() {}
47};
48
Harald Alvestrandb0e70572024-04-23 14:04:1849class RTC_EXPORT RtpReceiverInterface : public webrtc::RefCountInterface,
50 public FrameTransformerHost {
deadbeef70ab1a12015-09-28 23:53:5551 public:
52 virtual rtc::scoped_refptr<MediaStreamTrackInterface> track() const = 0;
Harald Alvestrand4a7b3ac2019-01-17 09:39:4053
54 // The dtlsTransport attribute exposes the DTLS transport on which the
55 // media is received. It may be null.
56 // https://w3c.github.io/webrtc-pc/#dom-rtcrtpreceiver-transport
57 // TODO(https://bugs.webrtc.org/907849) remove default implementation
58 virtual rtc::scoped_refptr<DtlsTransportInterface> dtls_transport() const;
59
Artem Titov0e61fdd2021-07-25 19:50:1460 // The list of streams that `track` is associated with. This is the same as
Henrik Boström9e6fd2b2017-11-21 12:41:5161 // the [[AssociatedRemoteMediaStreams]] internal slot in the spec.
Henrik Boström199e27b2018-07-04 18:51:5362 // https://w3c.github.io/webrtc-pc/#dfn-associatedremotemediastreams
Henrik Boström9e6fd2b2017-11-21 12:41:5163 // TODO(hbos): Make pure virtual as soon as Chromium's mock implements this.
Henrik Boström199e27b2018-07-04 18:51:5364 // TODO(https://crbug.com/webrtc/9480): Remove streams() in favor of
65 // stream_ids() as soon as downstream projects are no longer dependent on
66 // stream objects.
67 virtual std::vector<std::string> stream_ids() const;
Danil Chapovalov2a5ce2b2018-02-07 08:38:3168 virtual std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams() const;
deadbeef70ab1a12015-09-28 23:53:5569
Taylor Brandstetterba29c6a2016-06-27 23:30:3570 // Audio or video receiver?
71 virtual cricket::MediaType media_type() const = 0;
72
deadbeef70ab1a12015-09-28 23:53:5573 // Not to be confused with "mid", this is a field we can temporarily use
74 // to uniquely identify a receiver until we implement Unified Plan SDP.
75 virtual std::string id() const = 0;
76
Taylor Brandstetterdb0cd9e2016-05-16 18:40:3077 // The WebRTC specification only defines RTCRtpParameters in terms of senders,
78 // but this API also applies them to receivers, similar to ORTC:
79 // http://ortc.org/wp-content/uploads/2016/03/ortc.html#rtcrtpparameters*.
80 virtual RtpParameters GetParameters() const = 0;
Saurav Das934afc62019-11-21 19:54:1681 // TODO(dinosaurav): Delete SetParameters entirely after rolling to Chromium.
82 // Currently, doesn't support changing any parameters.
83 virtual bool SetParameters(const RtpParameters& parameters) { return false; }
Taylor Brandstetterdb0cd9e2016-05-16 18:40:3084
Taylor Brandstetterba29c6a2016-06-27 23:30:3585 // Does not take ownership of observer.
86 // Must call SetObserver(nullptr) before the observer is destroyed.
zhihuang184a3fd2016-06-14 18:47:1487 virtual void SetObserver(RtpReceiverObserverInterface* observer) = 0;
88
Ruslan Burakov4bac79e2019-04-03 17:55:3389 // Sets the jitter buffer minimum delay until media playout. Actual observed
Artem Titov0e61fdd2021-07-25 19:50:1490 // delay may differ depending on the congestion control. `delay_seconds` is a
91 // positive value including 0.0 measured in seconds. `nullopt` means default
Ruslan Burakov428dcb22019-04-18 15:49:4992 // value must be used.
Ruslan Burakov4bac79e2019-04-03 17:55:3393 virtual void SetJitterBufferMinimumDelay(
Ruslan Burakov428dcb22019-04-18 15:49:4994 absl::optional<double> delay_seconds) = 0;
Ruslan Burakov4bac79e2019-04-03 17:55:3395
hbos8d609f62017-04-10 14:39:0596 // TODO(zhihuang): Remove the default implementation once the subclasses
97 // implement this. Currently, the only relevant subclass is the
98 // content::FakeRtpReceiver in Chromium.
Danil Chapovalov2a5ce2b2018-02-07 08:38:3199 virtual std::vector<RtpSource> GetSources() const;
100
Benjamin Wrightd81ac952018-08-30 00:02:10101 // Sets a user defined frame decryptor that will decrypt the entire frame
102 // before it is sent across the network. This will decrypt the entire frame
103 // using the user provided decryption mechanism regardless of whether SRTP is
104 // enabled or not.
Tommi4ccdf9322021-05-17 12:50:10105 // TODO(bugs.webrtc.org/12772): Remove.
Benjamin Wrightd81ac952018-08-30 00:02:10106 virtual void SetFrameDecryptor(
107 rtc::scoped_refptr<FrameDecryptorInterface> frame_decryptor);
108
109 // Returns a pointer to the frame decryptor set previously by the
110 // user. This can be used to update the state of the object.
Tommi4ccdf9322021-05-17 12:50:10111 // TODO(bugs.webrtc.org/12772): Remove.
Benjamin Wrightd81ac952018-08-30 00:02:10112 virtual rtc::scoped_refptr<FrameDecryptorInterface> GetFrameDecryptor() const;
113
Marina Ciocea412a31b2020-02-28 15:02:06114 // Sets a frame transformer between the depacketizer and the decoder to enable
115 // client code to transform received frames according to their own processing
116 // logic.
Harald Alvestrandb0e70572024-04-23 14:04:18117 // TODO: bugs.webrtc.org/15929 - add [[deprecated("Use SetFrameTransformer")]]
118 // when usage in Chrome is removed
Marina Ciocea412a31b2020-02-28 15:02:06119 virtual void SetDepacketizerToDecoderFrameTransformer(
Harald Alvestrandb0e70572024-04-23 14:04:18120 rtc::scoped_refptr<FrameTransformerInterface> frame_transformer) {
121 SetFrameTransformer(std::move(frame_transformer));
122 }
123
124 // Default implementation of SetFrameTransformer.
125 // TODO: bugs.webrtc.org/15929 - Make pure virtual.
126 void SetFrameTransformer(
127 rtc::scoped_refptr<FrameTransformerInterface> frame_transformer) override;
Marina Ciocea412a31b2020-02-28 15:02:06128
deadbeef70ab1a12015-09-28 23:53:55129 protected:
Danil Chapovalov2a5ce2b2018-02-07 08:38:31130 ~RtpReceiverInterface() override = default;
deadbeef70ab1a12015-09-28 23:53:55131};
132
deadbeef70ab1a12015-09-28 23:53:55133} // namespace webrtc
134
Steve Anton10542f22019-01-11 17:11:00135#endif // API_RTP_RECEIVER_INTERFACE_H_