Steve Anton | 296a0ce | 2018-03-22 15:17:27 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2018 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 MODULES_RTP_RTCP_SOURCE_MID_ORACLE_H_ |
| 12 | #define MODULES_RTP_RTCP_SOURCE_MID_ORACLE_H_ |
| 13 | |
| 14 | #include <stdint.h> |
| 15 | #include <string> |
| 16 | |
| 17 | #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
| 18 | #include "rtc_base/constructormagic.h" |
| 19 | |
| 20 | namespace webrtc { |
| 21 | |
| 22 | // The MidOracle instructs an RTPSender to send the MID header extension on a |
| 23 | // new SSRC stream until it receives an RTCP report block for that stream (which |
| 24 | // implies that the remote side is able to demultiplex it and can remember the |
| 25 | // MID --> SSRC mapping). |
| 26 | class MidOracle { |
| 27 | public: |
| 28 | explicit MidOracle(const std::string& mid); |
| 29 | ~MidOracle(); |
| 30 | |
| 31 | // MID value to put into the header extension. |
| 32 | const std::string& mid() const { return mid_; } |
| 33 | |
| 34 | // True if the MID header extension should be included on the next outgoing |
| 35 | // packet. |
| 36 | bool send_mid() const { return send_mid_; } |
| 37 | |
| 38 | // Change the RTP stream SSRC. This will cause MIDs to be included until an |
| 39 | // RTCP report block lists this SSRC as received. |
| 40 | void SetSsrc(uint32_t ssrc) { |
| 41 | ssrc_ = ssrc; |
| 42 | send_mid_ = true; |
| 43 | } |
| 44 | |
| 45 | // Feedback to decide when to stop sending the MID header extension. |
| 46 | void OnReceivedRtcpReportBlocks(const ReportBlockList& report_blocks); |
| 47 | |
| 48 | private: |
| 49 | const std::string mid_; |
| 50 | bool send_mid_ = false; |
| 51 | uint32_t ssrc_ = 0; |
| 52 | |
| 53 | RTC_DISALLOW_COPY_AND_ASSIGN(MidOracle); |
| 54 | }; |
| 55 | |
| 56 | } // namespace webrtc |
| 57 | |
| 58 | #endif // MODULES_RTP_RTCP_SOURCE_MID_ORACLE_H_ |