Files
platform-external-webrtc/ortc/rtptransportadapter.h
Zhi Huang 365381fdf1 Replace BundleFilter with RtpDemuxer in RtpTransport.
BundleFilter is replaced by RtpDemuxer in RtpTransport for payload
type-based demuxing. RtpTransport will support MID-based demuxing later.

Each BaseChannel has its own RTP demuxing criteria and when connecting
to the RtpTransport, BaseChannel will register itself as a demuxer sink.

The inheritance model is changed. New inheritance chain:
DtlsSrtpTransport->SrtpTransport->RtpTranpsort

The JsepTransport2 is renamed to JsepTransport.

NOTE:
When RTCP packets are received, Call::DeliverRtcp will be called for
multiple times (webrtc:9035) which is an existing issue. With this CL,
it will become more of a problem and should be fixed.

Bug: webrtc:8587
Change-Id: Ibd880e7b744bd912336a691309950bc18e42cf62
Reviewed-on: https://webrtc-review.googlesource.com/65786
Commit-Queue: Zhi Huang <zhihuang@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Reviewed-by: Benjamin Wright <benwright@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22867}
2018-04-14 00:57:11 +00:00

122 lines
4.6 KiB
C++

/*
* Copyright 2017 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 ORTC_RTPTRANSPORTADAPTER_H_
#define ORTC_RTPTRANSPORTADAPTER_H_
#include <memory>
#include <vector>
#include "api/rtcerror.h"
#include "media/base/streamparams.h"
#include "ortc/rtptransportcontrolleradapter.h"
#include "pc/channel.h"
#include "pc/rtptransportinternaladapter.h"
#include "pc/srtptransport.h"
#include "rtc_base/constructormagic.h"
#include "rtc_base/sigslot.h"
namespace webrtc {
// This class is a wrapper over an RtpTransport or an SrtpTransport. The base
// class RtpTransportInternalAdapter keeps a raw pointer, |transport_|, of the
// transport object and implements both the public SrtpTransportInterface and
// RtpTransport internal interface by calling the |transport_| underneath.
//
// This adapter can be used as an unencrypted RTP transport or an SrtpTransport
// with RtpSenderAdapter, RtpReceiverAdapter, and RtpTransportControllerAdapter.
//
// TODO(deadbeef): When BaseChannel is split apart into separate
// "RtpTransport"/"RtpTransceiver"/"RtpSender"/"RtpReceiver" objects, this
// adapter object can be removed.
class RtpTransportAdapter : public RtpTransportInternalAdapter {
public:
// |rtp| can't be null. |rtcp| can if RTCP muxing is used immediately (meaning
// |rtcp_parameters.mux| is also true).
static RTCErrorOr<std::unique_ptr<RtpTransportInterface>> CreateProxied(
const RtpTransportParameters& rtcp_parameters,
PacketTransportInterface* rtp,
PacketTransportInterface* rtcp,
RtpTransportControllerAdapter* rtp_transport_controller);
static RTCErrorOr<std::unique_ptr<SrtpTransportInterface>> CreateSrtpProxied(
const RtpTransportParameters& rtcp_parameters,
PacketTransportInterface* rtp,
PacketTransportInterface* rtcp,
RtpTransportControllerAdapter* rtp_transport_controller);
~RtpTransportAdapter() override;
// RtpTransportInterface implementation.
PacketTransportInterface* GetRtpPacketTransport() const override {
return rtp_packet_transport_;
}
PacketTransportInterface* GetRtcpPacketTransport() const override {
return rtcp_packet_transport_;
}
RTCError SetParameters(const RtpTransportParameters& parameters) override;
RtpTransportParameters GetParameters() const override { return parameters_; }
// SRTP specific implementation.
RTCError SetSrtpSendKey(const cricket::CryptoParams& params) override;
RTCError SetSrtpReceiveKey(const cricket::CryptoParams& params) override;
// Methods used internally by OrtcFactory.
RtpTransportControllerAdapter* rtp_transport_controller() {
return rtp_transport_controller_;
}
void TakeOwnershipOfRtpTransportController(
std::unique_ptr<RtpTransportControllerInterface> controller);
// Used by RtpTransportControllerAdapter to tell when it should stop
// returning this transport from GetTransports().
sigslot::signal1<RtpTransportAdapter*> SignalDestroyed;
bool IsSrtpActive() const override { return transport_->IsSrtpActive(); }
protected:
RtpTransportAdapter* GetInternal() override { return this; }
private:
RtpTransportAdapter(const RtcpParameters& rtcp_params,
PacketTransportInterface* rtp,
PacketTransportInterface* rtcp,
RtpTransportControllerAdapter* rtp_transport_controller,
bool is_srtp_transport);
void OnReadyToSend(bool ready) { SignalReadyToSend(ready); }
void OnRtcpPacketReceived(rtc::CopyOnWriteBuffer* packet,
const rtc::PacketTime& time) {
SignalRtcpPacketReceived(packet, time);
}
void OnWritableState(bool writable) { SignalWritableState(writable); }
PacketTransportInterface* rtp_packet_transport_ = nullptr;
PacketTransportInterface* rtcp_packet_transport_ = nullptr;
RtpTransportControllerAdapter* const rtp_transport_controller_ = nullptr;
// Non-null if this class owns the transport controller.
std::unique_ptr<RtpTransportControllerInterface>
owned_rtp_transport_controller_;
RtpTransportParameters parameters_;
// Only one of them is non-null;
std::unique_ptr<RtpTransport> unencrypted_rtp_transport_;
std::unique_ptr<SrtpTransport> srtp_transport_;
rtc::Thread* network_thread_ = nullptr;
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RtpTransportAdapter);
};
} // namespace webrtc
#endif // ORTC_RTPTRANSPORTADAPTER_H_