blob: e4ec9b59868f0dd8f8ff81af462b50901f656c37 [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>
hbos8d609f62017-04-10 14:39:0518#include <vector>
deadbeef70ab1a12015-09-28 23:53:5519
Steve Anton10542f22019-01-11 17:11:0020#include "api/crypto/frame_decryptor_interface.h"
Harald Alvestrand4a7b3ac2019-01-17 09:39:4021#include "api/dtls_transport_interface.h"
Marina Ciocea412a31b2020-02-28 15:02:0622#include "api/frame_transformer_interface.h"
Steve Anton10542f22019-01-11 17:11:0023#include "api/media_stream_interface.h"
24#include "api/media_types.h"
Steve Anton10542f22019-01-11 17:11:0025#include "api/rtp_parameters.h"
Mirko Bonadeid9708072019-01-25 19:26:4826#include "api/scoped_refptr.h"
Niels Möllera8370302019-09-02 13:16:4927#include "api/transport/rtp/rtp_source.h"
Steve Anton10542f22019-01-11 17:11:0028#include "rtc_base/ref_count.h"
Mirko Bonadei35214fc2019-09-23 12:54:2829#include "rtc_base/system/rtc_export.h"
deadbeef70ab1a12015-09-28 23:53:5530
31namespace webrtc {
32
zhihuang184a3fd2016-06-14 18:47:1433class RtpReceiverObserverInterface {
34 public:
Taylor Brandstetterba29c6a2016-06-27 23:30:3535 // 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.
zhihuang184a3fd2016-06-14 18:47:1441 virtual void OnFirstPacketReceived(cricket::MediaType media_type) = 0;
42
43 protected:
44 virtual ~RtpReceiverObserverInterface() {}
45};
46
Mirko Bonadei35214fc2019-09-23 12:54:2847class RTC_EXPORT RtpReceiverInterface : public rtc::RefCountInterface {
deadbeef70ab1a12015-09-28 23:53:5548 public:
49 virtual rtc::scoped_refptr<MediaStreamTrackInterface> track() const = 0;
Harald Alvestrand4a7b3ac2019-01-17 09:39:4050
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 Titov0e61fdd2021-07-25 19:50:1457 // The list of streams that `track` is associated with. This is the same as
Henrik Boström9e6fd2b2017-11-21 12:41:5158 // the [[AssociatedRemoteMediaStreams]] internal slot in the spec.
Henrik Boström199e27b2018-07-04 18:51:5359 // https://w3c.github.io/webrtc-pc/#dfn-associatedremotemediastreams
Henrik Boström9e6fd2b2017-11-21 12:41:5160 // TODO(hbos): Make pure virtual as soon as Chromium's mock implements this.
Henrik Boström199e27b2018-07-04 18:51:5361 // 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 Chapovalov2a5ce2b2018-02-07 08:38:3165 virtual std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams() const;
deadbeef70ab1a12015-09-28 23:53:5566
Taylor Brandstetterba29c6a2016-06-27 23:30:3567 // Audio or video receiver?
68 virtual cricket::MediaType media_type() const = 0;
69
deadbeef70ab1a12015-09-28 23:53:5570 // 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 Brandstetterdb0cd9e2016-05-16 18:40:3074 // 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 Das934afc62019-11-21 19:54:1678 // 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 Brandstetterdb0cd9e2016-05-16 18:40:3081
Taylor Brandstetterba29c6a2016-06-27 23:30:3582 // Does not take ownership of observer.
83 // Must call SetObserver(nullptr) before the observer is destroyed.
zhihuang184a3fd2016-06-14 18:47:1484 virtual void SetObserver(RtpReceiverObserverInterface* observer) = 0;
85
Ruslan Burakov4bac79e2019-04-03 17:55:3386 // Sets the jitter buffer minimum delay until media playout. Actual observed
Artem Titov0e61fdd2021-07-25 19:50:1487 // 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 Burakov428dcb22019-04-18 15:49:4989 // value must be used.
Ruslan Burakov4bac79e2019-04-03 17:55:3390 virtual void SetJitterBufferMinimumDelay(
Ruslan Burakov428dcb22019-04-18 15:49:4991 absl::optional<double> delay_seconds) = 0;
Ruslan Burakov4bac79e2019-04-03 17:55:3392
hbos8d609f62017-04-10 14:39:0593 // 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 Chapovalov2a5ce2b2018-02-07 08:38:3196 virtual std::vector<RtpSource> GetSources() const;
97
Benjamin Wrightd81ac952018-08-30 00:02:1098 // 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.
Tommi4ccdf9322021-05-17 12:50:10102 // TODO(bugs.webrtc.org/12772): Remove.
Benjamin Wrightd81ac952018-08-30 00:02:10103 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.
Tommi4ccdf9322021-05-17 12:50:10108 // TODO(bugs.webrtc.org/12772): Remove.
Benjamin Wrightd81ac952018-08-30 00:02:10109 virtual rtc::scoped_refptr<FrameDecryptorInterface> GetFrameDecryptor() const;
110
Marina Ciocea412a31b2020-02-28 15:02:06111 // 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
deadbeef70ab1a12015-09-28 23:53:55117 protected:
Danil Chapovalov2a5ce2b2018-02-07 08:38:31118 ~RtpReceiverInterface() override = default;
deadbeef70ab1a12015-09-28 23:53:55119};
120
deadbeef70ab1a12015-09-28 23:53:55121} // namespace webrtc
122
Steve Anton10542f22019-01-11 17:11:00123#endif // API_RTP_RECEIVER_INTERFACE_H_