blob: c2dad5b7f9c9303c81ea83ced7f3ca3f3e344982 [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
kjellander65c7f672016-02-12 00:05:01 -08002 * Copyright 2004 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003 *
kjellander65c7f672016-02-12 00:05:01 -08004 * 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.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00009 */
10
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef PC_RTCPMUXFILTER_H_
12#define PC_RTCPMUXFILTER_H_
henrike@webrtc.org28e20752013-07-10 00:45:36 +000013
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020014#include "p2p/base/sessiondescription.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000015
16namespace cricket {
17
18// RTCP Muxer, as defined in RFC 5761 (http://tools.ietf.org/html/rfc5761)
19class RtcpMuxFilter {
20 public:
21 RtcpMuxFilter();
22
deadbeef23d947d2016-08-22 16:00:30 -070023 // Whether RTCP mux has been negotiated with a final answer (not provisional).
24 bool IsFullyActive() const;
25
26 // Whether RTCP mux has been negotiated with a provisional answer; this means
27 // a later answer could disable RTCP mux, and so the RTCP transport should
28 // not be disposed yet.
29 bool IsProvisionallyActive() const;
30
31 // Whether the filter is active, i.e. has RTCP mux been properly negotiated,
32 // either with a final or provisional answer.
henrike@webrtc.org28e20752013-07-10 00:45:36 +000033 bool IsActive() const;
34
deadbeef23d947d2016-08-22 16:00:30 -070035 // Make the filter active (fully, not provisionally) regardless of the
36 // current state. This should be used when an endpoint *requires* RTCP mux.
Peter Thatcheraf55ccc2015-05-21 07:48:41 -070037 void SetActive();
38
henrike@webrtc.org28e20752013-07-10 00:45:36 +000039 // Specifies whether the offer indicates the use of RTCP mux.
40 bool SetOffer(bool offer_enable, ContentSource src);
41
42 // Specifies whether the provisional answer indicates the use of RTCP mux.
43 bool SetProvisionalAnswer(bool answer_enable, ContentSource src);
44
45 // Specifies whether the answer indicates the use of RTCP mux.
46 bool SetAnswer(bool answer_enable, ContentSource src);
47
henrike@webrtc.org28e20752013-07-10 00:45:36 +000048 private:
49 bool ExpectOffer(bool offer_enable, ContentSource source);
50 bool ExpectAnswer(ContentSource source);
51 enum State {
52 // RTCP mux filter unused.
53 ST_INIT,
54 // Offer with RTCP mux enabled received.
55 // RTCP mux filter is not active.
56 ST_RECEIVEDOFFER,
57 // Offer with RTCP mux enabled sent.
58 // RTCP mux filter can demux incoming packets but is not active.
59 ST_SENTOFFER,
60 // RTCP mux filter is active but the sent answer is only provisional.
61 // When the final answer is set, the state transitions to ST_ACTIVE or
62 // ST_INIT.
63 ST_SENTPRANSWER,
64 // RTCP mux filter is active but the received answer is only provisional.
65 // When the final answer is set, the state transitions to ST_ACTIVE or
66 // ST_INIT.
67 ST_RECEIVEDPRANSWER,
68 // Offer and answer set, RTCP mux enabled. It is not possible to de-activate
69 // the filter.
70 ST_ACTIVE
71 };
72 State state_;
73 bool offer_enable_;
74};
75
76} // namespace cricket
77
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020078#endif // PC_RTCPMUXFILTER_H_