webrtc/modules/rtp_rtcp/source/mid_oracle.h
Steve Anton 296a0ce4c7 Add MID sending to RTPSender
This CL adds the ability to configure RTPSender to include the
MID header extension when sending packets. The MID will be
included on every packet at the start of the stream until an RTCP
acknoledgment is received for that SSRC at which point it will
stop being included. The MID will be included on regular RTP
streams as well as RTX streams.

Bug: webrtc:4050
Change-Id: Ie27ebee1cd00a67f2b931f5363788f523e3e684f
Reviewed-on: https://webrtc-review.googlesource.com/60582
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22574}
2018-03-23 01:50:45 +00:00

58 lines
1.8 KiB
C++

/*
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_RTP_RTCP_SOURCE_MID_ORACLE_H_
#define MODULES_RTP_RTCP_SOURCE_MID_ORACLE_H_
#include <stdint.h>
#include <string>
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "rtc_base/constructormagic.h"
namespace webrtc {
// The MidOracle instructs an RTPSender to send the MID header extension on a
// new SSRC stream until it receives an RTCP report block for that stream (which
// implies that the remote side is able to demultiplex it and can remember the
// MID --> SSRC mapping).
class MidOracle {
public:
explicit MidOracle(const std::string& mid);
~MidOracle();
// MID value to put into the header extension.
const std::string& mid() const { return mid_; }
// True if the MID header extension should be included on the next outgoing
// packet.
bool send_mid() const { return send_mid_; }
// Change the RTP stream SSRC. This will cause MIDs to be included until an
// RTCP report block lists this SSRC as received.
void SetSsrc(uint32_t ssrc) {
ssrc_ = ssrc;
send_mid_ = true;
}
// Feedback to decide when to stop sending the MID header extension.
void OnReceivedRtcpReportBlocks(const ReportBlockList& report_blocks);
private:
const std::string mid_;
bool send_mid_ = false;
uint32_t ssrc_ = 0;
RTC_DISALLOW_COPY_AND_ASSIGN(MidOracle);
};
} // namespace webrtc
#endif // MODULES_RTP_RTCP_SOURCE_MID_ORACLE_H_