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