Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(278)

Side by Side Diff: webrtc/ortc/rtptransportadapter.cc

Issue 2675173003: Adding "adapter" ORTC objects on top of ChannelManager/BaseChannel/etc. (Closed)
Patch Set: Add memcheck suppression for end-to-end tests. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/ortc/rtptransportadapter.h ('k') | webrtc/ortc/rtptransportcontroller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 #include "webrtc/ortc/rtptransportadapter.h"
12
13 #include <algorithm> // For std::find.
14 #include <set>
15 #include <sstream>
16 #include <utility> // For std::move.
17
18 #include "webrtc/api/proxy.h"
19 #include "webrtc/base/logging.h"
20
21 namespace webrtc {
22
23 BEGIN_OWNED_PROXY_MAP(RtpTransport)
24 PROXY_SIGNALING_THREAD_DESTRUCTOR()
25 PROXY_CONSTMETHOD0(PacketTransportInterface*, GetRtpPacketTransport)
26 PROXY_CONSTMETHOD0(PacketTransportInterface*, GetRtcpPacketTransport)
27 PROXY_METHOD1(RTCError, SetRtcpParameters, const RtcpParameters&)
28 PROXY_CONSTMETHOD0(RtcpParameters, GetRtcpParameters)
29 protected:
30 RtpTransportAdapter* GetInternal() override {
31 return internal();
32 }
33 END_PROXY_MAP()
34
35 // static
36 RTCErrorOr<std::unique_ptr<RtpTransportInterface>>
37 RtpTransportAdapter::CreateProxied(
38 const RtcpParameters& rtcp_parameters,
39 PacketTransportInterface* rtp,
40 PacketTransportInterface* rtcp,
41 RtpTransportControllerAdapter* rtp_transport_controller) {
42 if (!rtp) {
43 LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER,
44 "Must provide an RTP packet transport.");
45 }
46 if (!rtcp_parameters.mux && !rtcp) {
47 LOG_AND_RETURN_ERROR(
48 RTCErrorType::INVALID_PARAMETER,
49 "Must provide an RTCP packet transport when RTCP muxing is not used.");
50 }
51 if (rtcp_parameters.mux && rtcp) {
52 LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER,
53 "Creating an RtpTransport with RTCP muxing enabled, "
54 "with a separate RTCP packet transport?");
55 }
56 if (!rtp_transport_controller) {
57 // Since OrtcFactory::CreateRtpTransport creates an RtpTransportController
58 // automatically when one isn't passed in, this should never be reached.
59 RTC_NOTREACHED();
60 LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER,
61 "Must provide an RTP transport controller.");
62 }
63 return RtpTransportProxyWithInternal<RtpTransportAdapter>::Create(
64 rtp_transport_controller->signaling_thread(),
65 rtp_transport_controller->worker_thread(),
66 std::unique_ptr<RtpTransportAdapter>(new RtpTransportAdapter(
67 rtcp_parameters, rtp, rtcp, rtp_transport_controller)));
68 }
69
70 void RtpTransportAdapter::TakeOwnershipOfRtpTransportController(
71 std::unique_ptr<RtpTransportControllerInterface> controller) {
72 RTC_DCHECK_EQ(rtp_transport_controller_, controller->GetInternal());
73 RTC_DCHECK(owned_rtp_transport_controller_.get() == nullptr);
74 owned_rtp_transport_controller_ = std::move(controller);
75 }
76
77 RtpTransportAdapter::RtpTransportAdapter(
78 const RtcpParameters& rtcp_parameters,
79 PacketTransportInterface* rtp,
80 PacketTransportInterface* rtcp,
81 RtpTransportControllerAdapter* rtp_transport_controller)
82 : rtp_packet_transport_(rtp),
83 rtcp_packet_transport_(rtcp),
84 rtp_transport_controller_(rtp_transport_controller),
85 rtcp_parameters_(rtcp_parameters) {
86 RTC_DCHECK(rtp_transport_controller);
87 // CNAME should have been filled by OrtcFactory if empty.
88 RTC_DCHECK(!rtcp_parameters_.cname.empty());
89 }
90
91 RtpTransportAdapter::~RtpTransportAdapter() {
92 SignalDestroyed(this);
93 }
94
95 PacketTransportInterface* RtpTransportAdapter::GetRtpPacketTransport() const {
96 return rtp_packet_transport_;
97 }
98
99 PacketTransportInterface* RtpTransportAdapter::GetRtcpPacketTransport() const {
100 return rtcp_packet_transport_;
101 }
102
103 RTCError RtpTransportAdapter::SetRtcpParameters(
104 const RtcpParameters& parameters) {
105 if (!parameters.mux && rtcp_parameters_.mux) {
106 LOG_AND_RETURN_ERROR(webrtc::RTCErrorType::INVALID_STATE,
107 "Can't disable RTCP muxing after enabling.");
108 }
109 if (!parameters.cname.empty() && parameters.cname != rtcp_parameters_.cname) {
110 LOG_AND_RETURN_ERROR(webrtc::RTCErrorType::UNSUPPORTED_OPERATION,
111 "Changing the RTCP CNAME is currently unsupported.");
112 }
113 // If the CNAME is empty, use the existing one.
114 RtcpParameters copy = parameters;
115 if (copy.cname.empty()) {
116 copy.cname = rtcp_parameters_.cname;
117 }
118 RTCError err = rtp_transport_controller_->SetRtcpParameters(copy, this);
119 if (!err.ok()) {
120 return err;
121 }
122 rtcp_parameters_ = copy;
123 if (rtcp_parameters_.mux) {
124 rtcp_packet_transport_ = nullptr;
125 }
126 return RTCError::OK();
127 }
128
129 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/ortc/rtptransportadapter.h ('k') | webrtc/ortc/rtptransportcontroller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698