first cut of webrtcsession. Doesn't do much other than creating files and empty function bodies.
Review URL: http://webrtc-codereview.appspot.com/186002 git-svn-id: http://webrtc.googlecode.com/svn/trunk@667 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
5eec6cf29a
commit
9a1249d9e0
@ -696,8 +696,6 @@
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnectionmanagerimpl.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnectionsignaling.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnectionsignaling.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnectiontransport.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnectiontransport.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/ref_count.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/streamcollectionimpl.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/videorendererimpl.cc',
|
||||
@ -705,6 +703,8 @@
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/videotrackimpl.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/webrtc_devicemanager.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/webrtc_devicemanager.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/webrtcsession.h',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/webrtcsession.cc',
|
||||
],
|
||||
}], # peer_connection_dev
|
||||
], # conditions
|
||||
@ -764,6 +764,7 @@
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnectionimpl_unittest.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnectionmanager_unittest.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/peerconnectionsignaling_unittest.cc',
|
||||
'<(libjingle_mods)/source/talk/app/webrtc_dev/webrtcsession_unittest.cc',
|
||||
],
|
||||
}, { # peer_connection_dev != 1
|
||||
'type': 'none',
|
||||
|
@ -1,148 +0,0 @@
|
||||
|
||||
#include "talk/app/webrtc_dev/peerconnectiontransport.h"
|
||||
|
||||
#include "talk/base/common.h"
|
||||
#include "talk/base/logging.h"
|
||||
#include "talk/base/thread.h"
|
||||
#include "talk/p2p/base/p2ptransport.h"
|
||||
#include "talk/p2p/base/portallocator.h"
|
||||
#include "talk/p2p/base/transportchannelimpl.h"
|
||||
|
||||
namespace {
|
||||
static const int MSG_TRANSPORT_TIMEOUT = 1;
|
||||
// TODO(mallinath) - This value is not finalized yet. For now 30 seconds
|
||||
// timeout value is taken from magicflute.
|
||||
static const int kCallSetupTimeout = 30 * 1000;
|
||||
}
|
||||
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
PeerConnectionTransport::PeerConnectionTransport(
|
||||
talk_base::Thread* signaling_thread,
|
||||
talk_base::Thread* worker_thread,
|
||||
cricket::PortAllocator* port_allocator)
|
||||
: state_(INIT),
|
||||
all_writable_(false),
|
||||
signaling_thread_(signaling_thread),
|
||||
transport_(new cricket::P2PTransport(
|
||||
signaling_thread, worker_thread, port_allocator)) {
|
||||
}
|
||||
|
||||
PeerConnectionTransport::~PeerConnectionTransport() {
|
||||
}
|
||||
|
||||
bool PeerConnectionTransport::Initialize() {
|
||||
ASSERT(transport_.get());
|
||||
transport_->SignalCandidatesReady.connect(
|
||||
this, &PeerConnectionTransport::OnCandidatesReady);
|
||||
transport_->SignalRequestSignaling.connect(
|
||||
this, &PeerConnectionTransport::OnRequestSignaling);
|
||||
transport_->SignalWritableState.connect(
|
||||
this, &PeerConnectionTransport::OnWritableState);
|
||||
transport_->SignalRouteChange.connect(
|
||||
this, &PeerConnectionTransport::OnRouteChange);
|
||||
transport_->SignalConnecting.connect(
|
||||
this, &PeerConnectionTransport::OnConnecting);
|
||||
return true;
|
||||
}
|
||||
|
||||
void PeerConnectionTransport::ConnectChannels() {
|
||||
transport_->ConnectChannels();
|
||||
state_ = CONNECTING;
|
||||
}
|
||||
|
||||
cricket::TransportChannel* PeerConnectionTransport::CreateChannel(
|
||||
const std::string& channel_name,
|
||||
const std::string& content_type) {
|
||||
cricket::TransportChannel* channel = FindChannel(channel_name);
|
||||
if (channel) {
|
||||
LOG(LS_INFO) << "Channel alreary exists";
|
||||
return channel;
|
||||
} else {
|
||||
channel = transport_->CreateChannel(channel_name, content_type);
|
||||
channels_[channel_name] = channel;
|
||||
return channel;
|
||||
}
|
||||
}
|
||||
|
||||
cricket::TransportChannel* PeerConnectionTransport::FindChannel(
|
||||
const std::string& name) const {
|
||||
TransportChannelMap::const_iterator iter = channels_.find(name);
|
||||
return (iter != channels_.end()) ? iter->second : NULL;
|
||||
}
|
||||
|
||||
cricket::TransportChannel* PeerConnectionTransport::GetChannel(
|
||||
const std::string& channel_name,
|
||||
const std::string& content_type) {
|
||||
return FindChannel(channel_name);
|
||||
}
|
||||
|
||||
void PeerConnectionTransport::DestroyChannel(const std::string& channel_name,
|
||||
const std::string& content_type) {
|
||||
TransportChannelMap::iterator iter = channels_.find(channel_name);
|
||||
if (iter != channels_.end()) {
|
||||
channels_.erase(iter);
|
||||
}
|
||||
transport_->DestroyChannel(channel_name);
|
||||
return;
|
||||
}
|
||||
|
||||
void PeerConnectionTransport::OnRequestSignaling(
|
||||
cricket::Transport* transport) {
|
||||
transport_->OnSignalingReady();
|
||||
}
|
||||
|
||||
void PeerConnectionTransport::OnCandidatesReady(
|
||||
cricket::Transport* transport,
|
||||
const std::vector<cricket::Candidate>& candidates) {
|
||||
std::vector<cricket::Candidate>::const_iterator iter;
|
||||
for (iter = candidates.begin(); iter != candidates.end(); ++iter) {
|
||||
local_candidates_.push_back(*iter);
|
||||
}
|
||||
}
|
||||
|
||||
void PeerConnectionTransport::OnWritableState(cricket::Transport* transport) {
|
||||
bool all_writable = transport->writable();
|
||||
if (all_writable != all_writable_) {
|
||||
if (all_writable) {
|
||||
signaling_thread_->Clear(this, MSG_TRANSPORT_TIMEOUT);
|
||||
} else {
|
||||
signaling_thread_->PostDelayed(
|
||||
kCallSetupTimeout, this, MSG_TRANSPORT_TIMEOUT);
|
||||
}
|
||||
all_writable_ = all_writable;
|
||||
}
|
||||
}
|
||||
|
||||
void PeerConnectionTransport::OnRouteChange(
|
||||
cricket::Transport* transport,
|
||||
const std::string& name,
|
||||
const cricket::Candidate& remote_candidate) {
|
||||
channel_best_remote_candidate_[name] = remote_candidate;
|
||||
}
|
||||
|
||||
void PeerConnectionTransport::OnConnecting(cricket::Transport* transport) {
|
||||
ASSERT(signaling_thread_->IsCurrent());
|
||||
if (transport->HasChannels() && !transport->writable()) {
|
||||
signaling_thread_->PostDelayed(
|
||||
kCallSetupTimeout, this, MSG_TRANSPORT_TIMEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
void PeerConnectionTransport::OnRemoteCandidates(const Candidates candidates) {
|
||||
transport_->OnRemoteCandidates(candidates);
|
||||
state_ = CONNECTED;
|
||||
}
|
||||
|
||||
void PeerConnectionTransport::OnMessage(talk_base::Message* message) {
|
||||
switch(message->message_id) {
|
||||
case MSG_TRANSPORT_TIMEOUT: {
|
||||
LOG(LS_ERROR) << "Transport Timeout";
|
||||
SignalTransportTimeout();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,94 +0,0 @@
|
||||
|
||||
|
||||
#ifndef TALK_APP_WEBRTC_PEERCONNECTIONTRANSPORT_H_
|
||||
#define TALK_APP_WEBRTC_PEERCONNECTIONTRANSPORT_H_
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "talk/base/messagequeue.h"
|
||||
#include "talk/base/sigslot.h"
|
||||
#include "talk/p2p/base/candidate.h"
|
||||
|
||||
namespace talk_base {
|
||||
class Thread;
|
||||
class Message;
|
||||
}
|
||||
|
||||
namespace cricket {
|
||||
class PortAllocator;
|
||||
class Transport;
|
||||
class TransportChannel;
|
||||
}
|
||||
|
||||
namespace webrtc {
|
||||
typedef std::vector<cricket::Candidate> Candidates;
|
||||
|
||||
class PeerConnectionTransport : public talk_base::MessageHandler,
|
||||
public sigslot::has_slots<> {
|
||||
public:
|
||||
PeerConnectionTransport(talk_base::Thread* signaling_thread,
|
||||
talk_base::Thread* worker_thread,
|
||||
cricket::PortAllocator* port_allocator);
|
||||
~PeerConnectionTransport();
|
||||
|
||||
enum TransportState {
|
||||
INIT,
|
||||
CONNECTING,
|
||||
CONNECTED,
|
||||
};
|
||||
|
||||
bool Initialize();
|
||||
|
||||
// methods signaled by the cricket::Transport
|
||||
void OnRequestSignaling(cricket::Transport* transport);
|
||||
void OnCandidatesReady(cricket::Transport* transport,
|
||||
const std::vector<cricket::Candidate>& candidates);
|
||||
void OnWritableState(cricket::Transport* transport);
|
||||
void OnRouteChange(cricket::Transport* transport,
|
||||
const std::string& name,
|
||||
const cricket::Candidate& remote_candidate);
|
||||
void OnConnecting(cricket::Transport* transport);
|
||||
void ConnectChannels();
|
||||
|
||||
// methods to handle transport channels. These methods are relayed from
|
||||
// WebRtcSession which implements cricket::BaseSession methods
|
||||
cricket::TransportChannel* CreateChannel(const std::string& channel_name,
|
||||
const std::string& content_type);
|
||||
cricket::TransportChannel* GetChannel(const std::string& channel_name,
|
||||
const std::string& content_type);
|
||||
void DestroyChannel(const std::string& channel_name,
|
||||
const std::string& content_type);
|
||||
|
||||
Candidates local_candidates() {
|
||||
return local_candidates_;
|
||||
}
|
||||
Candidates remote_candidates() {
|
||||
return remote_candidates_;
|
||||
}
|
||||
|
||||
void OnRemoteCandidates(const Candidates candidates);
|
||||
sigslot::signal0<> SignalTransportTimeout;
|
||||
|
||||
private:
|
||||
typedef std::map<std::string, cricket::TransportChannel*> TransportChannelMap;
|
||||
|
||||
virtual void OnMessage(talk_base::Message* message);
|
||||
void StartTransportTimeout();
|
||||
void ClearTransportTimeout();
|
||||
cricket::TransportChannel* FindChannel(const std::string& name) const;
|
||||
|
||||
TransportState state_;
|
||||
bool all_writable_;
|
||||
TransportChannelMap channels_;
|
||||
talk_base::scoped_ptr<cricket::Transport> transport_;
|
||||
talk_base::Thread* signaling_thread_;
|
||||
Candidates local_candidates_;
|
||||
Candidates remote_candidates_;
|
||||
std::map<std::string, cricket::Candidate> channel_best_remote_candidate_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // TALK_APP_WEBRTC_PEERCONNECTIONTRANSPORT_H_
|
@ -0,0 +1,150 @@
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2011, Google Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "talk/app/webrtc_dev/webrtcsession.h"
|
||||
|
||||
#include "talk/base/helpers.h"
|
||||
#include "talk/base/logging.h"
|
||||
#include "talk/session/phone/channel.h"
|
||||
#include "talk/session/phone/channelmanager.h"
|
||||
#include "talk/app/webrtc_dev/mediastream.h"
|
||||
#include "talk/app/webrtc_dev/peerconnectionsignaling.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
enum {
|
||||
MSG_CANDIDATE_TIMEOUT = 101,
|
||||
};
|
||||
|
||||
// We allow 30 seconds to establish a connection, otherwise it's an error.
|
||||
static const int kCallSetupTimeout = 30 * 1000;
|
||||
|
||||
WebRtcSession::WebRtcSession(cricket::ChannelManager* channel_manager,
|
||||
talk_base::Thread* worker_thread,
|
||||
cricket::PortAllocator* port_allocator,
|
||||
PeerConnectionSignaling* pc_signaling)
|
||||
: cricket::BaseSession(pc_signaling->signaling_thread(), worker_thread,
|
||||
port_allocator,
|
||||
talk_base::ToString(talk_base::CreateRandomId()),
|
||||
cricket::NS_JINGLE_RTP, true) {
|
||||
// TODO(mallinath) - Remove initiator flag from BaseSession. As it's being
|
||||
// used only by cricket::Session.
|
||||
channel_manager_ = channel_manager;
|
||||
pc_signaling_ = pc_signaling;
|
||||
}
|
||||
|
||||
WebRtcSession::~WebRtcSession() {
|
||||
Terminate();
|
||||
}
|
||||
|
||||
bool WebRtcSession::Initialize() {
|
||||
ASSERT(pc_signaling_ != NULL);
|
||||
pc_signaling_->SignalUpdateSessionDescription.connect(
|
||||
this, &WebRtcSession::OnSignalUpdateSessionDescription);
|
||||
return CreateChannels();
|
||||
}
|
||||
|
||||
void WebRtcSession::Terminate() {
|
||||
if (voice_channel_.get()) {
|
||||
channel_manager_->DestroyVoiceChannel(voice_channel_.release());
|
||||
}
|
||||
if (video_channel_.get()) {
|
||||
channel_manager_->DestroyVideoChannel(video_channel_.release());
|
||||
}
|
||||
}
|
||||
|
||||
void WebRtcSession::OnSignalUpdateSessionDescription(
|
||||
const cricket::SessionDescription* local_desc,
|
||||
const cricket::SessionDescription* remote_desc,
|
||||
StreamCollection* streams) {
|
||||
if (state() == STATE_INPROGRESS) {
|
||||
// TODO(mallinath) - Handling of session updates is not ready yet.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool WebRtcSession::CreateChannels() {
|
||||
voice_channel_.reset(channel_manager_->CreateVoiceChannel(
|
||||
this, cricket::CN_AUDIO, true));
|
||||
if (!voice_channel_.get()) {
|
||||
LOG(LS_ERROR) << "Failed to create voice channel";
|
||||
return false;
|
||||
}
|
||||
|
||||
video_channel_.reset(channel_manager_->CreateVideoChannel(
|
||||
this, cricket::CN_VIDEO, true, voice_channel_.get()));
|
||||
if (!video_channel_.get()) {
|
||||
LOG(LS_ERROR) << "Failed to create video channel";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void WebRtcSession::OnTransportRequestSignaling(
|
||||
cricket::Transport* transport) {
|
||||
ASSERT(signaling_thread()->IsCurrent());
|
||||
transport->OnSignalingReady();
|
||||
}
|
||||
|
||||
void WebRtcSession::OnTransportConnecting(cricket::Transport* transport) {
|
||||
ASSERT(signaling_thread()->IsCurrent());
|
||||
// start monitoring for the write state of the transport.
|
||||
OnTransportWritable(transport);
|
||||
}
|
||||
|
||||
void WebRtcSession::OnTransportWritable(cricket::Transport* transport) {
|
||||
ASSERT(signaling_thread()->IsCurrent());
|
||||
// If the transport is not in writable state, start a timer to monitor
|
||||
// the state. If the transport doesn't become writable state in 30 seconds
|
||||
// then we are assuming call can't be continued.
|
||||
signaling_thread()->Clear(this, MSG_CANDIDATE_TIMEOUT);
|
||||
if (transport->HasChannels() && !transport->writable()) {
|
||||
signaling_thread()->PostDelayed(
|
||||
kCallSetupTimeout, this, MSG_CANDIDATE_TIMEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
void WebRtcSession::OnTransportCandidatesReady(
|
||||
cricket::Transport* transport, const cricket::Candidates& candidates) {
|
||||
ASSERT(signaling_thread()->IsCurrent());
|
||||
pc_signaling_->Initialize(candidates);
|
||||
}
|
||||
|
||||
void WebRtcSession::OnTransportChannelGone(cricket::Transport* transport) {
|
||||
ASSERT(signaling_thread()->IsCurrent());
|
||||
}
|
||||
|
||||
void WebRtcSession::OnMessage(talk_base::Message* msg) {
|
||||
switch (msg->message_id) {
|
||||
case MSG_CANDIDATE_TIMEOUT:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2011, Google Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef TALK_APP_WEBRTC_WEBRTCSESSION_H_
|
||||
#define TALK_APP_WEBRTC_WEBRTCSESSION_H_
|
||||
|
||||
#include "talk/base/sigslot.h"
|
||||
#include "talk/base/thread.h"
|
||||
#include "talk/p2p/base/session.h"
|
||||
|
||||
namespace cricket {
|
||||
class ChannelManager;
|
||||
class Transport;
|
||||
class VideoChannel;
|
||||
class VoiceChannel;
|
||||
}
|
||||
|
||||
namespace webrtc {
|
||||
class MediaStream;
|
||||
class PeerConnectionMessage;
|
||||
class PeerConnectionSignaling;
|
||||
|
||||
class WebRtcSession : public cricket::BaseSession {
|
||||
public:
|
||||
WebRtcSession(cricket::ChannelManager* channel_manager,
|
||||
talk_base::Thread* worker_thread,
|
||||
cricket::PortAllocator* port_allocator,
|
||||
PeerConnectionSignaling* pc_signaling);
|
||||
~WebRtcSession();
|
||||
|
||||
bool Initialize();
|
||||
|
||||
const cricket::VoiceChannel* voice_channel() const {
|
||||
return voice_channel_.get();
|
||||
}
|
||||
const cricket::VideoChannel* video_channel() const {
|
||||
return video_channel_.get();
|
||||
}
|
||||
|
||||
private:
|
||||
// Callback handling from PeerConnectionSignaling
|
||||
void OnSignalUpdateSessionDescription(
|
||||
const cricket::SessionDescription* local_desc,
|
||||
const cricket::SessionDescription* remote_desc,
|
||||
StreamCollection* streams);
|
||||
|
||||
// Transport related callbacks, override from cricket::BaseSession.
|
||||
virtual void OnTransportRequestSignaling(cricket::Transport* transport);
|
||||
virtual void OnTransportConnecting(cricket::Transport* transport);
|
||||
virtual void OnTransportWritable(cricket::Transport* transport);
|
||||
virtual void OnTransportCandidatesReady(cricket::Transport* transport,
|
||||
const cricket::Candidates& candidates);
|
||||
virtual void OnTransportChannelGone(cricket::Transport* transport);
|
||||
|
||||
// Creates channels for voice and video.
|
||||
bool CreateChannels();
|
||||
virtual void OnMessage(talk_base::Message* msg);
|
||||
|
||||
void Terminate();
|
||||
|
||||
private:
|
||||
PeerConnectionSignaling* pc_signaling_;
|
||||
talk_base::scoped_ptr<cricket::VoiceChannel> voice_channel_;
|
||||
talk_base::scoped_ptr<cricket::VideoChannel> video_channel_;
|
||||
cricket::ChannelManager* channel_manager_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // TALK_APP_WEBRTC_WEBRTCSESSION_H_
|
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* libjingle
|
||||
* Copyright 2011, Google Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "talk/app/webrtc_dev/webrtcsession.h"
|
||||
#include "talk/app/webrtc_dev/peerconnectionsignaling.h"
|
||||
#include "talk/base/thread.h"
|
||||
#include "talk/session/phone/channelmanager.h"
|
||||
#include "talk/p2p/client/fakeportallocator.h"
|
||||
|
||||
class WebRtcSessionTest : public testing::Test {
|
||||
public:
|
||||
WebRtcSessionTest() {
|
||||
signaling_thread_ = talk_base::Thread::Current();
|
||||
worker_thread_ = talk_base::Thread::Current();
|
||||
channel_manager_.reset(new cricket::ChannelManager(worker_thread_));
|
||||
port_allocator_.reset(
|
||||
new cricket::FakePortAllocator(worker_thread_, NULL));
|
||||
pc_signaling_.reset(
|
||||
new webrtc::PeerConnectionSignaling(channel_manager_.get()));
|
||||
ASSERT_TRUE(channel_manager_.get() != NULL);
|
||||
ASSERT_TRUE(session_.get() == NULL);
|
||||
}
|
||||
|
||||
~WebRtcSessionTest() {
|
||||
}
|
||||
|
||||
bool InitializeSession() {
|
||||
return session_.get()->Initialize();
|
||||
}
|
||||
bool CheckChannels() {
|
||||
return (session_->voice_channel() != NULL &&
|
||||
session_->video_channel() != NULL);
|
||||
}
|
||||
|
||||
void Init() {
|
||||
EXPECT_TRUE(channel_manager_.get()->Init());
|
||||
session_.reset(new webrtc::WebRtcSession(
|
||||
channel_manager_.get(), worker_thread_,
|
||||
port_allocator_.get(), pc_signaling_.get()));
|
||||
EXPECT_TRUE(InitializeSession());
|
||||
EXPECT_TRUE(CheckChannels());
|
||||
}
|
||||
|
||||
private:
|
||||
talk_base::Thread* signaling_thread_;
|
||||
talk_base::Thread* worker_thread_;
|
||||
talk_base::scoped_ptr<cricket::PortAllocator> port_allocator_;
|
||||
talk_base::scoped_ptr<webrtc::PeerConnectionSignaling> pc_signaling_;
|
||||
talk_base::scoped_ptr<webrtc::WebRtcSession> session_;
|
||||
talk_base::scoped_ptr<cricket::ChannelManager> channel_manager_;
|
||||
};
|
||||
|
||||
TEST_F(WebRtcSessionTest, TestInitialize) {
|
||||
WebRtcSessionTest::Init();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user