Connecting PeerConnectionImpl with WebrtcSession and MediaStreamHandlers.
This cl connects PeerConnectionImpl with WebrtcSession and MediaStreamHandlers. BUG= TEST= Review URL: http://webrtc-codereview.appspot.com/190005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@683 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
666f56bd41
commit
1b6ff7adbe
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "talk/app/webrtc_dev/mediastreamhandler.h"
|
||||||
#include "talk/app/webrtc_dev/scoped_refptr_msg.h"
|
#include "talk/app/webrtc_dev/scoped_refptr_msg.h"
|
||||||
#include "talk/app/webrtc_dev/streamcollectionimpl.h"
|
#include "talk/app/webrtc_dev/streamcollectionimpl.h"
|
||||||
#include "talk/base/logging.h"
|
#include "talk/base/logging.h"
|
||||||
@ -122,6 +123,7 @@ namespace webrtc {
|
|||||||
PeerConnectionImpl::PeerConnectionImpl(
|
PeerConnectionImpl::PeerConnectionImpl(
|
||||||
cricket::ChannelManager* channel_manager,
|
cricket::ChannelManager* channel_manager,
|
||||||
talk_base::Thread* signaling_thread,
|
talk_base::Thread* signaling_thread,
|
||||||
|
talk_base::Thread* worker_thread,
|
||||||
PcNetworkManager* network_manager,
|
PcNetworkManager* network_manager,
|
||||||
PcPacketSocketFactory* socket_factory)
|
PcPacketSocketFactory* socket_factory)
|
||||||
: observer_(NULL),
|
: observer_(NULL),
|
||||||
@ -135,7 +137,10 @@ PeerConnectionImpl::PeerConnectionImpl(
|
|||||||
socket_factory->socket_factory(),
|
socket_factory->socket_factory(),
|
||||||
std::string(kUserAgent))),
|
std::string(kUserAgent))),
|
||||||
signaling_(new PeerConnectionSignaling(channel_manager,
|
signaling_(new PeerConnectionSignaling(channel_manager,
|
||||||
signaling_thread)) {
|
signaling_thread)),
|
||||||
|
session_(new WebRtcSession(channel_manager, signaling_thread,
|
||||||
|
worker_thread, port_allocator_.get(), signaling_.get())),
|
||||||
|
stream_handler_(new MediaStreamHandlers(session_.get())) {
|
||||||
signaling_->SignalNewPeerConnectionMessage.connect(
|
signaling_->SignalNewPeerConnectionMessage.connect(
|
||||||
this, &PeerConnectionImpl::OnNewPeerConnectionMessage);
|
this, &PeerConnectionImpl::OnNewPeerConnectionMessage);
|
||||||
signaling_->SignalRemoteStreamAdded.connect(
|
signaling_->SignalRemoteStreamAdded.connect(
|
||||||
@ -176,8 +181,8 @@ bool PeerConnectionImpl::Initialize(const std::string& configuration,
|
|||||||
ASSERT(!"NOT SUPPORTED");
|
ASSERT(!"NOT SUPPORTED");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// Initialize the WebRtcSession. It creates transport channels etc.
|
||||||
return true;
|
return session_->Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
scoped_refptr<StreamCollection> PeerConnectionImpl::local_streams() {
|
scoped_refptr<StreamCollection> PeerConnectionImpl::local_streams() {
|
||||||
@ -219,6 +224,7 @@ void PeerConnectionImpl::OnMessage(talk_base::Message* msg) {
|
|||||||
ScopedRefMessageData<StreamCollection>* param(
|
ScopedRefMessageData<StreamCollection>* param(
|
||||||
static_cast<ScopedRefMessageData<StreamCollection>*> (data));
|
static_cast<ScopedRefMessageData<StreamCollection>*> (data));
|
||||||
signaling_->CreateOffer(param->data());
|
signaling_->CreateOffer(param->data());
|
||||||
|
stream_handler_->CommitLocalStreams(param->data());
|
||||||
delete data; // Because it is Posted.
|
delete data; // Because it is Posted.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -247,6 +253,7 @@ void PeerConnectionImpl::OnRemoteStreamAdded(MediaStream* remote_stream) {
|
|||||||
// remote streams.
|
// remote streams.
|
||||||
// This way we can avoid keeping a separate list of remote_media_streams_.
|
// This way we can avoid keeping a separate list of remote_media_streams_.
|
||||||
remote_media_streams_->AddStream(remote_stream);
|
remote_media_streams_->AddStream(remote_stream);
|
||||||
|
stream_handler_->AddRemoteStream(remote_stream);
|
||||||
observer_->OnAddStream(remote_stream);
|
observer_->OnAddStream(remote_stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,6 +262,7 @@ void PeerConnectionImpl::OnRemoteStreamRemoved(MediaStream* remote_stream) {
|
|||||||
// remote streams.
|
// remote streams.
|
||||||
// This way we can avoid keeping a separate list of remote_media_streams_.
|
// This way we can avoid keeping a separate list of remote_media_streams_.
|
||||||
remote_media_streams_->RemoveStream(remote_stream);
|
remote_media_streams_->RemoveStream(remote_stream);
|
||||||
|
stream_handler_->RemoveRemoteStream(remote_stream);
|
||||||
observer_->OnRemoveStream(remote_stream);
|
observer_->OnRemoveStream(remote_stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
#include "talk/app/webrtc_dev/peerconnection.h"
|
#include "talk/app/webrtc_dev/peerconnection.h"
|
||||||
#include "talk/app/webrtc_dev/peerconnectionsignaling.h"
|
#include "talk/app/webrtc_dev/peerconnectionsignaling.h"
|
||||||
|
#include "talk/app/webrtc_dev/webrtcsession.h"
|
||||||
#include "talk/base/scoped_ptr.h"
|
#include "talk/base/scoped_ptr.h"
|
||||||
#include "talk/p2p/client/httpportallocator.h"
|
#include "talk/p2p/client/httpportallocator.h"
|
||||||
|
|
||||||
@ -41,8 +42,10 @@ class ChannelManager;
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
class MediaStreamHandlers;
|
||||||
class StreamCollectionImpl;
|
class StreamCollectionImpl;
|
||||||
|
|
||||||
|
|
||||||
// PeerConnectionImpl implements the PeerConnection interface.
|
// PeerConnectionImpl implements the PeerConnection interface.
|
||||||
// It uses PeerConnectionSignaling and WebRtcSession to implement
|
// It uses PeerConnectionSignaling and WebRtcSession to implement
|
||||||
// the PeerConnection functionality.
|
// the PeerConnection functionality.
|
||||||
@ -52,6 +55,7 @@ class PeerConnectionImpl : public PeerConnection,
|
|||||||
public:
|
public:
|
||||||
PeerConnectionImpl(cricket::ChannelManager* channel_manager,
|
PeerConnectionImpl(cricket::ChannelManager* channel_manager,
|
||||||
talk_base::Thread* signaling_thread,
|
talk_base::Thread* signaling_thread,
|
||||||
|
talk_base::Thread* worker_thread,
|
||||||
PcNetworkManager* network_manager,
|
PcNetworkManager* network_manager,
|
||||||
PcPacketSocketFactory* socket_factory);
|
PcPacketSocketFactory* socket_factory);
|
||||||
|
|
||||||
@ -90,6 +94,8 @@ class PeerConnectionImpl : public PeerConnection,
|
|||||||
scoped_refptr<PcPacketSocketFactory> socket_factory_;
|
scoped_refptr<PcPacketSocketFactory> socket_factory_;
|
||||||
talk_base::scoped_ptr<cricket::HttpPortAllocator> port_allocator_;
|
talk_base::scoped_ptr<cricket::HttpPortAllocator> port_allocator_;
|
||||||
talk_base::scoped_ptr<PeerConnectionSignaling> signaling_;
|
talk_base::scoped_ptr<PeerConnectionSignaling> signaling_;
|
||||||
|
talk_base::scoped_ptr<WebRtcSession> session_;
|
||||||
|
talk_base::scoped_ptr<MediaStreamHandlers> stream_handler_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -172,6 +172,7 @@ scoped_refptr<PeerConnection> PeerConnectionManagerImpl::CreatePeerConnection(
|
|||||||
RefCountImpl<PeerConnectionImpl>* pc =
|
RefCountImpl<PeerConnectionImpl>* pc =
|
||||||
new RefCountImpl<PeerConnectionImpl>(channel_manager_.get(),
|
new RefCountImpl<PeerConnectionImpl>(channel_manager_.get(),
|
||||||
signaling_thread_ptr_,
|
signaling_thread_ptr_,
|
||||||
|
worker_thread_ptr_,
|
||||||
network_manager_,
|
network_manager_,
|
||||||
socket_factory_);
|
socket_factory_);
|
||||||
if (!pc->Initialize(configuration, observer)) {
|
if (!pc->Initialize(configuration, observer)) {
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include "talk/base/thread.h"
|
#include "talk/base/thread.h"
|
||||||
#include "talk/p2p/base/session.h"
|
#include "talk/p2p/base/session.h"
|
||||||
#include "talk/session/phone/mediasession.h"
|
#include "talk/session/phone/mediasession.h"
|
||||||
|
#include "talk/app/webrtc_dev/mediastreamprovider.h"
|
||||||
|
|
||||||
namespace cricket {
|
namespace cricket {
|
||||||
class ChannelManager;
|
class ChannelManager;
|
||||||
@ -49,7 +50,8 @@ class PeerConnectionMessage;
|
|||||||
class PeerConnectionSignaling;
|
class PeerConnectionSignaling;
|
||||||
class StreamCollection;
|
class StreamCollection;
|
||||||
|
|
||||||
class WebRtcSession : public cricket::BaseSession {
|
class WebRtcSession : public cricket::BaseSession,
|
||||||
|
public MediaProviderInterface {
|
||||||
public:
|
public:
|
||||||
WebRtcSession(cricket::ChannelManager* channel_manager,
|
WebRtcSession(cricket::ChannelManager* channel_manager,
|
||||||
talk_base::Thread* signaling_thread,
|
talk_base::Thread* signaling_thread,
|
||||||
@ -75,6 +77,14 @@ class WebRtcSession : public cricket::BaseSession {
|
|||||||
const cricket::SessionDescription* remote_desc);
|
const cricket::SessionDescription* remote_desc);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Implements MediaProviderInterface.
|
||||||
|
// TODO(mallinath): Add proper implementation.
|
||||||
|
virtual void SetCaptureDevice(uint32 ssrc, VideoCaptureModule* camera) {};
|
||||||
|
virtual void SetLocalRenderer(uint32 ssrc,
|
||||||
|
cricket::VideoRenderer* renderer) {};
|
||||||
|
virtual void SetRemoteRenderer(uint32 ssrc,
|
||||||
|
cricket::VideoRenderer* renderer) {};
|
||||||
|
|
||||||
// Callback handling from PeerConnectionSignaling
|
// Callback handling from PeerConnectionSignaling
|
||||||
void OnSignalUpdateSessionDescription(
|
void OnSignalUpdateSessionDescription(
|
||||||
const cricket::SessionDescription* local_desc,
|
const cricket::SessionDescription* local_desc,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user