1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "content/renderer/media/peer_connection_handler_base.h" 6 7 #include "base/logging.h" 8 #include "base/strings/utf_string_conversions.h" 9 #include "content/renderer/media/media_stream_dependency_factory.h" 10 #include "content/renderer/media/media_stream_extra_data.h" 11 #include "third_party/WebKit/public/platform/WebMediaStream.h" 12 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" 13 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" 14 #include "third_party/WebKit/public/platform/WebString.h" 15 16 namespace content { 17 18 PeerConnectionHandlerBase::PeerConnectionHandlerBase( 19 MediaStreamDependencyFactory* dependency_factory) 20 : dependency_factory_(dependency_factory), 21 message_loop_proxy_(base::MessageLoopProxy::current()) { 22 } 23 24 PeerConnectionHandlerBase::~PeerConnectionHandlerBase() { 25 } 26 27 bool PeerConnectionHandlerBase::AddStream( 28 const blink::WebMediaStream& stream, 29 const webrtc::MediaConstraintsInterface* constraints) { 30 webrtc::MediaStreamInterface* native_stream = 31 MediaStreamDependencyFactory::GetNativeMediaStream(stream); 32 if (!native_stream) 33 return false; 34 return native_peer_connection_->AddStream(native_stream, constraints); 35 } 36 37 void PeerConnectionHandlerBase::RemoveStream( 38 const blink::WebMediaStream& stream) { 39 webrtc::MediaStreamInterface* native_stream = 40 MediaStreamDependencyFactory::GetNativeMediaStream(stream); 41 if (native_stream) 42 native_peer_connection_->RemoveStream(native_stream); 43 DCHECK(native_stream); 44 } 45 46 } // namespace content 47