| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/ortc/ortcfactory.h" | 11 #include "webrtc/ortc/ortcfactory.h" |
| 12 | 12 |
| 13 #include <sstream> | 13 #include <sstream> |
| 14 #include <utility> // For std::move. |
| 14 #include <vector> | 15 #include <vector> |
| 15 #include <utility> // For std::move. | |
| 16 | 16 |
| 17 #include "webrtc/api/mediastreamtrackproxy.h" |
| 17 #include "webrtc/api/proxy.h" | 18 #include "webrtc/api/proxy.h" |
| 18 #include "webrtc/api/mediastreamtrackproxy.h" | |
| 19 #include "webrtc/api/rtcerror.h" | 19 #include "webrtc/api/rtcerror.h" |
| 20 #include "webrtc/api/videosourceproxy.h" | 20 #include "webrtc/api/videosourceproxy.h" |
| 21 #include "webrtc/base/asyncpacketsocket.h" | 21 #include "webrtc/base/asyncpacketsocket.h" |
| 22 #include "webrtc/base/bind.h" | 22 #include "webrtc/base/bind.h" |
| 23 #include "webrtc/base/checks.h" | 23 #include "webrtc/base/checks.h" |
| 24 #include "webrtc/base/helpers.h" | 24 #include "webrtc/base/helpers.h" |
| 25 #include "webrtc/base/logging.h" | 25 #include "webrtc/base/logging.h" |
| 26 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 26 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
| 27 #include "webrtc/media/base/mediaconstants.h" | 27 #include "webrtc/media/base/mediaconstants.h" |
| 28 #include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h" | 28 #include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h" |
| 29 #include "webrtc/ortc/ortcrtpreceiveradapter.h" | 29 #include "webrtc/ortc/ortcrtpreceiveradapter.h" |
| 30 #include "webrtc/ortc/ortcrtpsenderadapter.h" | 30 #include "webrtc/ortc/ortcrtpsenderadapter.h" |
| 31 #include "webrtc/ortc/rtpparametersconversion.h" | 31 #include "webrtc/ortc/rtpparametersconversion.h" |
| 32 #include "webrtc/ortc/rtptransportadapter.h" | 32 #include "webrtc/ortc/rtptransportadapter.h" |
| 33 #include "webrtc/ortc/rtptransportcontrolleradapter.h" | 33 #include "webrtc/ortc/rtptransportcontrolleradapter.h" |
| 34 #include "webrtc/p2p/base/basicpacketsocketfactory.h" | 34 #include "webrtc/p2p/base/basicpacketsocketfactory.h" |
| 35 #include "webrtc/p2p/base/udptransport.h" | 35 #include "webrtc/p2p/base/udptransport.h" |
| 36 #include "webrtc/pc/audiotrack.h" |
| 36 #include "webrtc/pc/channelmanager.h" | 37 #include "webrtc/pc/channelmanager.h" |
| 37 #include "webrtc/pc/localaudiosource.h" | 38 #include "webrtc/pc/localaudiosource.h" |
| 38 #include "webrtc/pc/audiotrack.h" | |
| 39 #include "webrtc/pc/videocapturertracksource.h" | 39 #include "webrtc/pc/videocapturertracksource.h" |
| 40 #include "webrtc/pc/videotrack.h" | 40 #include "webrtc/pc/videotrack.h" |
| 41 | 41 |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 const int kDefaultRtcpCnameLength = 16; | 44 const int kDefaultRtcpCnameLength = 16; |
| 45 | 45 |
| 46 // Asserts that all of the built-in capabilities can be converted to | 46 // Asserts that all of the built-in capabilities can be converted to |
| 47 // RtpCapabilities. If they can't, something's wrong (for example, maybe a new | 47 // RtpCapabilities. If they can't, something's wrong (for example, maybe a new |
| 48 // feedback mechanism is supported, but an enum value wasn't added to | 48 // feedback mechanism is supported, but an enum value wasn't added to |
| (...skipping 22 matching lines...) Expand all Loading... |
| 71 BEGIN_OWNED_PROXY_MAP(OrtcFactory) | 71 BEGIN_OWNED_PROXY_MAP(OrtcFactory) |
| 72 PROXY_SIGNALING_THREAD_DESTRUCTOR() | 72 PROXY_SIGNALING_THREAD_DESTRUCTOR() |
| 73 PROXY_METHOD0(RTCErrorOr<std::unique_ptr<RtpTransportControllerInterface>>, | 73 PROXY_METHOD0(RTCErrorOr<std::unique_ptr<RtpTransportControllerInterface>>, |
| 74 CreateRtpTransportController) | 74 CreateRtpTransportController) |
| 75 PROXY_METHOD4(RTCErrorOr<std::unique_ptr<RtpTransportInterface>>, | 75 PROXY_METHOD4(RTCErrorOr<std::unique_ptr<RtpTransportInterface>>, |
| 76 CreateRtpTransport, | 76 CreateRtpTransport, |
| 77 const RtcpParameters&, | 77 const RtcpParameters&, |
| 78 PacketTransportInterface*, | 78 PacketTransportInterface*, |
| 79 PacketTransportInterface*, | 79 PacketTransportInterface*, |
| 80 RtpTransportControllerInterface*) | 80 RtpTransportControllerInterface*) |
| 81 |
| 82 PROXY_METHOD4(RTCErrorOr<std::unique_ptr<SrtpTransportInterface>>, |
| 83 CreateSrtpTransport, |
| 84 const RtcpParameters&, |
| 85 PacketTransportInterface*, |
| 86 PacketTransportInterface*, |
| 87 RtpTransportControllerInterface*) |
| 88 |
| 81 PROXY_CONSTMETHOD1(RtpCapabilities, | 89 PROXY_CONSTMETHOD1(RtpCapabilities, |
| 82 GetRtpSenderCapabilities, | 90 GetRtpSenderCapabilities, |
| 83 cricket::MediaType) | 91 cricket::MediaType) |
| 84 PROXY_METHOD2(RTCErrorOr<std::unique_ptr<OrtcRtpSenderInterface>>, | 92 PROXY_METHOD2(RTCErrorOr<std::unique_ptr<OrtcRtpSenderInterface>>, |
| 85 CreateRtpSender, | 93 CreateRtpSender, |
| 86 rtc::scoped_refptr<MediaStreamTrackInterface>, | 94 rtc::scoped_refptr<MediaStreamTrackInterface>, |
| 87 RtpTransportInterface*) | 95 RtpTransportInterface*) |
| 88 PROXY_METHOD2(RTCErrorOr<std::unique_ptr<OrtcRtpSenderInterface>>, | 96 PROXY_METHOD2(RTCErrorOr<std::unique_ptr<OrtcRtpSenderInterface>>, |
| 89 CreateRtpSender, | 97 CreateRtpSender, |
| 90 cricket::MediaType, | 98 cricket::MediaType, |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 // deleted automatically. | 251 // deleted automatically. |
| 244 if (transport_result.ok()) { | 252 if (transport_result.ok()) { |
| 245 transport_result.value() | 253 transport_result.value() |
| 246 ->GetInternal() | 254 ->GetInternal() |
| 247 ->TakeOwnershipOfRtpTransportController(std::move(controller)); | 255 ->TakeOwnershipOfRtpTransportController(std::move(controller)); |
| 248 } | 256 } |
| 249 return transport_result; | 257 return transport_result; |
| 250 } | 258 } |
| 251 } | 259 } |
| 252 | 260 |
| 261 RTCErrorOr<std::unique_ptr<SrtpTransportInterface>> |
| 262 OrtcFactory::CreateSrtpTransport( |
| 263 const RtcpParameters& rtcp_parameters, |
| 264 PacketTransportInterface* rtp, |
| 265 PacketTransportInterface* rtcp, |
| 266 RtpTransportControllerInterface* transport_controller) { |
| 267 RTC_DCHECK_RUN_ON(signaling_thread_); |
| 268 RtcpParameters copied_parameters = rtcp_parameters; |
| 269 if (copied_parameters.cname.empty()) { |
| 270 copied_parameters.cname = default_cname_; |
| 271 } |
| 272 if (transport_controller) { |
| 273 return transport_controller->GetInternal()->CreateProxiedSrtpTransport( |
| 274 copied_parameters, rtp, rtcp); |
| 275 } else { |
| 276 // If |transport_controller| is null, create one automatically, which the |
| 277 // returned SrtpTransport will own. |
| 278 auto controller_result = CreateRtpTransportController(); |
| 279 if (!controller_result.ok()) { |
| 280 return controller_result.MoveError(); |
| 281 } |
| 282 auto controller = controller_result.MoveValue(); |
| 283 auto transport_result = |
| 284 controller->GetInternal()->CreateProxiedSrtpTransport(copied_parameters, |
| 285 rtp, rtcp); |
| 286 // If SrtpTransport was successfully created, transfer ownership of |
| 287 // |rtp_transport_controller|. Otherwise it will go out of scope and be |
| 288 // deleted automatically. |
| 289 if (transport_result.ok()) { |
| 290 transport_result.value() |
| 291 ->GetInternal() |
| 292 ->TakeOwnershipOfRtpTransportController(std::move(controller)); |
| 293 } |
| 294 return transport_result; |
| 295 } |
| 296 } |
| 297 |
| 253 RtpCapabilities OrtcFactory::GetRtpSenderCapabilities( | 298 RtpCapabilities OrtcFactory::GetRtpSenderCapabilities( |
| 254 cricket::MediaType kind) const { | 299 cricket::MediaType kind) const { |
| 255 RTC_DCHECK_RUN_ON(signaling_thread_); | 300 RTC_DCHECK_RUN_ON(signaling_thread_); |
| 256 switch (kind) { | 301 switch (kind) { |
| 257 case cricket::MEDIA_TYPE_AUDIO: { | 302 case cricket::MEDIA_TYPE_AUDIO: { |
| 258 cricket::AudioCodecs cricket_codecs; | 303 cricket::AudioCodecs cricket_codecs; |
| 259 cricket::RtpHeaderExtensions cricket_extensions; | 304 cricket::RtpHeaderExtensions cricket_extensions; |
| 260 channel_manager_->GetSupportedAudioSendCodecs(&cricket_codecs); | 305 channel_manager_->GetSupportedAudioSendCodecs(&cricket_codecs); |
| 261 channel_manager_->GetSupportedAudioRtpHeaderExtensions( | 306 channel_manager_->GetSupportedAudioRtpHeaderExtensions( |
| 262 &cricket_extensions); | 307 &cricket_extensions); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 // OrtcFactory, but aren't yet. | 540 // OrtcFactory, but aren't yet. |
| 496 // | 541 // |
| 497 // Note that |adm_| may be null, in which case the platform-specific default | 542 // Note that |adm_| may be null, in which case the platform-specific default |
| 498 // AudioDeviceModule will be used. | 543 // AudioDeviceModule will be used. |
| 499 return std::unique_ptr<cricket::MediaEngineInterface>( | 544 return std::unique_ptr<cricket::MediaEngineInterface>( |
| 500 cricket::WebRtcMediaEngineFactory::Create(adm_, audio_decoder_factory_, | 545 cricket::WebRtcMediaEngineFactory::Create(adm_, audio_decoder_factory_, |
| 501 nullptr, nullptr, nullptr)); | 546 nullptr, nullptr, nullptr)); |
| 502 } | 547 } |
| 503 | 548 |
| 504 } // namespace webrtc | 549 } // namespace webrtc |
| OLD | NEW |