deadbeef | e814a0d | 2017-02-25 18:15:09 -0800 | [diff] [blame^] | 1 | /* |
| 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 WEBRTC_ORTC_RTPTRANSPORTADAPTER_H_ |
| 12 | #define WEBRTC_ORTC_RTPTRANSPORTADAPTER_H_ |
| 13 | |
| 14 | #include <memory> |
| 15 | #include <vector> |
| 16 | |
| 17 | #include "webrtc/api/ortc/rtptransportinterface.h" |
| 18 | #include "webrtc/api/rtcerror.h" |
| 19 | #include "webrtc/base/constructormagic.h" |
| 20 | #include "webrtc/base/sigslot.h" |
| 21 | #include "webrtc/media/base/streamparams.h" |
| 22 | #include "webrtc/ortc/rtptransportcontrolleradapter.h" |
| 23 | #include "webrtc/pc/channel.h" |
| 24 | |
| 25 | namespace webrtc { |
| 26 | |
| 27 | // Implementation of RtpTransportInterface to be used with RtpSenderAdapter, |
| 28 | // RtpReceiverAdapter, and RtpTransportControllerAdapter classes. |
| 29 | // |
| 30 | // TODO(deadbeef): When BaseChannel is split apart into separate |
| 31 | // "RtpTransport"/"RtpTransceiver"/"RtpSender"/"RtpReceiver" objects, this |
| 32 | // adapter object can be removed. |
| 33 | class RtpTransportAdapter : public RtpTransportInterface { |
| 34 | public: |
| 35 | // |rtp| can't be null. |rtcp| can if RTCP muxing is used immediately (meaning |
| 36 | // |rtcp_parameters.mux| is also true). |
| 37 | static RTCErrorOr<std::unique_ptr<RtpTransportInterface>> CreateProxied( |
| 38 | const RtcpParameters& rtcp_parameters, |
| 39 | PacketTransportInterface* rtp, |
| 40 | PacketTransportInterface* rtcp, |
| 41 | RtpTransportControllerAdapter* rtp_transport_controller); |
| 42 | ~RtpTransportAdapter() override; |
| 43 | |
| 44 | // RtpTransportInterface implementation. |
| 45 | PacketTransportInterface* GetRtpPacketTransport() const override; |
| 46 | PacketTransportInterface* GetRtcpPacketTransport() const override; |
| 47 | RTCError SetRtcpParameters(const RtcpParameters& parameters) override; |
| 48 | RtcpParameters GetRtcpParameters() const override { return rtcp_parameters_; } |
| 49 | |
| 50 | // Methods used internally by OrtcFactory. |
| 51 | RtpTransportControllerAdapter* rtp_transport_controller() { |
| 52 | return rtp_transport_controller_; |
| 53 | } |
| 54 | void TakeOwnershipOfRtpTransportController( |
| 55 | std::unique_ptr<RtpTransportControllerInterface> controller); |
| 56 | |
| 57 | // Used by RtpTransportControllerAdapter to tell when it should stop |
| 58 | // returning this transport from GetTransports(). |
| 59 | sigslot::signal1<RtpTransportAdapter*> SignalDestroyed; |
| 60 | |
| 61 | protected: |
| 62 | RtpTransportAdapter* GetInternal() override { return this; } |
| 63 | |
| 64 | private: |
| 65 | RtpTransportAdapter(const RtcpParameters& rtcp_parameters, |
| 66 | PacketTransportInterface* rtp, |
| 67 | PacketTransportInterface* rtcp, |
| 68 | RtpTransportControllerAdapter* rtp_transport_controller); |
| 69 | |
| 70 | PacketTransportInterface* rtp_packet_transport_; |
| 71 | PacketTransportInterface* rtcp_packet_transport_; |
| 72 | RtpTransportControllerAdapter* rtp_transport_controller_; |
| 73 | // Non-null if this class owns the transport controller. |
| 74 | std::unique_ptr<RtpTransportControllerInterface> |
| 75 | owned_rtp_transport_controller_; |
| 76 | RtcpParameters rtcp_parameters_; |
| 77 | |
| 78 | RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RtpTransportAdapter); |
| 79 | }; |
| 80 | |
| 81 | } // namespace webrtc |
| 82 | |
| 83 | #endif // WEBRTC_ORTC_RTPTRANSPORTADAPTER_H_ |