blob: 88607b2ed49f4949466147bffc00a35081d014ae [file] [log] [blame]
Steve Anton6e634bf2017-11-13 10:44:53 -08001/*
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved.
3 *
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.
9 */
10
11#ifndef API_RTPTRANSCEIVERINTERFACE_H_
12#define API_RTPTRANSCEIVERINTERFACE_H_
13
14#include <string>
Steve Anton9158ef62017-11-27 13:01:52 -080015#include <vector>
Steve Anton6e634bf2017-11-13 10:44:53 -080016
17#include "api/optional.h"
18#include "api/rtpreceiverinterface.h"
19#include "api/rtpsenderinterface.h"
20#include "rtc_base/refcount.h"
21
22namespace webrtc {
23
Steve Anton9158ef62017-11-27 13:01:52 -080024// https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiverdirection
Steve Anton6e634bf2017-11-13 10:44:53 -080025enum class RtpTransceiverDirection {
26 kSendRecv,
27 kSendOnly,
28 kRecvOnly,
29 kInactive
30};
31
Steve Anton9158ef62017-11-27 13:01:52 -080032// Structure for initializing an RtpTransceiver in a call to
33// PeerConnectionInterface::AddTransceiver.
34// https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiverinit
35struct RtpTransceiverInit final {
36 // Direction of the RtpTransceiver. See RtpTransceiverInterface::direction().
37 RtpTransceiverDirection direction = RtpTransceiverDirection::kSendRecv;
38
39 // The added RtpTransceiver will be added to these streams.
40 // TODO(bugs.webrtc.org/7600): Not implemented.
41 std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams;
42
43 // TODO(bugs.webrtc.org/7600): Not implemented.
44 std::vector<RtpEncodingParameters> send_encodings;
45};
46
Steve Anton6e634bf2017-11-13 10:44:53 -080047// The RtpTransceiverInterface maps to the RTCRtpTransceiver defined by the
48// WebRTC specification. A transceiver represents a combination of an RtpSender
49// and an RtpReceiver than share a common mid. As defined in JSEP, an
50// RtpTransceiver is said to be associated with a media description if its mid
51// property is non-null; otherwise, it is said to be disassociated.
52// JSEP: https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-24
53//
54// Note that RtpTransceivers are only supported when using PeerConnection with
55// Unified Plan SDP.
56//
57// This class is thread-safe.
58//
59// WebRTC specification for RTCRtpTransceiver, the JavaScript analog:
60// https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver
61class RtpTransceiverInterface : public rtc::RefCountInterface {
62 public:
63 // The mid attribute is the mid negotiated and present in the local and
64 // remote descriptions. Before negotiation is complete, the mid value may be
65 // null. After rollbacks, the value may change from a non-null value to null.
66 // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-mid
67 virtual rtc::Optional<std::string> mid() const = 0;
68
69 // The sender attribute exposes the RtpSender corresponding to the RTP media
70 // that may be sent with the transceiver's mid. The sender is always present,
71 // regardless of the direction of media.
72 // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-sender
73 virtual rtc::scoped_refptr<RtpSenderInterface> sender() const = 0;
74
75 // The receiver attribute exposes the RtpReceiver corresponding to the RTP
76 // media that may be received with the transceiver's mid. The receiver is
77 // always present, regardless of the direction of media.
78 // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-receiver
79 virtual rtc::scoped_refptr<RtpReceiverInterface> receiver() const = 0;
80
81 // The stopped attribute indicates that the sender of this transceiver will no
82 // longer send, and that the receiver will no longer receive. It is true if
83 // either stop has been called or if setting the local or remote description
84 // has caused the RtpTransceiver to be stopped.
85 // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-stopped
86 virtual bool stopped() const = 0;
87
88 // The direction attribute indicates the preferred direction of this
89 // transceiver, which will be used in calls to CreateOffer and CreateAnswer.
90 // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-direction
91 virtual RtpTransceiverDirection direction() const = 0;
92
93 // Sets the preferred direction of this transceiver. An update of
94 // directionality does not take effect immediately. Instead, future calls to
95 // CreateOffer and CreateAnswer mark the corresponding media descriptions as
96 // sendrecv, sendonly, recvonly, or inactive.
97 // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-direction
98 virtual void SetDirection(RtpTransceiverDirection new_direction) = 0;
99
100 // The current_direction attribute indicates the current direction negotiated
101 // for this transceiver. If this transceiver has never been represented in an
102 // offer/answer exchange, or if the transceiver is stopped, the value is null.
103 // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-currentdirection
104 virtual rtc::Optional<RtpTransceiverDirection> current_direction() const = 0;
105
106 // The Stop method irreversibly stops the RtpTransceiver. The sender of this
107 // transceiver will no longer send, the receiver will no longer receive.
108 // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-stop
109 virtual void Stop() = 0;
110
111 // The SetCodecPreferences method overrides the default codec preferences used
112 // by WebRTC for this transceiver.
113 // https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-setcodecpreferences
114 // TODO(steveanton): Not implemented.
115 virtual void SetCodecPreferences(
116 rtc::ArrayView<RtpCodecCapability> codecs) = 0;
117
118 protected:
119 virtual ~RtpTransceiverInterface() = default;
120};
121
122} // namespace webrtc
123
124#endif // API_RTPTRANSCEIVERINTERFACE_H_