Changes based on the review comments.
* Rename WebRTCSession to WebRtcSession. * Add comments to the signal. Review URL: http://webrtc-codereview.appspot.com/114009 git-svn-id: http://webrtc.googlecode.com/svn/trunk@402 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
bfc63ae83f
commit
765c918677
@ -285,10 +285,10 @@ bool PeerConnectionImpl::SignalingMessage_s(const std::string& msg) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
WebRTCSession* PeerConnectionImpl::CreateMediaSession(
|
||||
WebRtcSession* PeerConnectionImpl::CreateMediaSession(
|
||||
const std::string& id, const std::string& dir) {
|
||||
ASSERT(port_allocator_ != NULL);
|
||||
WebRTCSession* session = new WebRTCSession(id, dir,
|
||||
WebRtcSession* session = new WebRtcSession(id, dir,
|
||||
port_allocator_, channel_manager_.get(),
|
||||
signaling_thread_.get());
|
||||
|
||||
@ -318,7 +318,7 @@ WebRTCSession* PeerConnectionImpl::CreateMediaSession(
|
||||
return session;
|
||||
}
|
||||
|
||||
void PeerConnectionImpl::SendRemoveSignal(WebRTCSession* session) {
|
||||
void PeerConnectionImpl::SendRemoveSignal(WebRtcSession* session) {
|
||||
if (event_callback_) {
|
||||
std::string message;
|
||||
if (GetJSONSignalingMessage(session->remote_description(),
|
||||
|
@ -53,7 +53,7 @@ namespace webrtc {
|
||||
|
||||
class AudioDeviceModule;
|
||||
class ExternalRenderer;
|
||||
class WebRTCSession;
|
||||
class WebRtcSession;
|
||||
|
||||
class PeerConnectionImpl : public PeerConnection,
|
||||
public talk_base::MessageHandler,
|
||||
@ -114,8 +114,8 @@ class PeerConnectionImpl : public PeerConnection,
|
||||
bool ParseConfigString(const std::string& config,
|
||||
talk_base::SocketAddress* stun_addr);
|
||||
void WrapChromiumThread();
|
||||
void SendRemoveSignal(WebRTCSession* session);
|
||||
WebRTCSession* CreateMediaSession(const std::string& id,
|
||||
void SendRemoveSignal(WebRtcSession* session);
|
||||
WebRtcSession* CreateMediaSession(const std::string& id,
|
||||
const std::string& dir);
|
||||
|
||||
virtual void OnMessage(talk_base::Message* message);
|
||||
@ -161,7 +161,7 @@ class PeerConnectionImpl : public PeerConnection,
|
||||
|
||||
ServiceType service_type_;
|
||||
PeerConnectionObserver* event_callback_;
|
||||
talk_base::scoped_ptr<WebRTCSession> session_;
|
||||
talk_base::scoped_ptr<WebRtcSession> session_;
|
||||
// TODO(ronghua): There's no such concept as "incoming" and "outgoing"
|
||||
// according to the spec. This will be removed in the new PeerConnection.
|
||||
bool incoming_;
|
||||
|
@ -36,12 +36,12 @@ bool PeerConnectionImpl::Init() {
|
||||
return true;
|
||||
}
|
||||
|
||||
WebRTCSession* PeerConnectionImpl::CreateSession() {
|
||||
// TODO(ronghuawu): when we have the new WebRTCSession we don't need these
|
||||
WebRtcSession* PeerConnectionImpl::CreateSession() {
|
||||
// TODO(ronghuawu): when we have the new WebRtcSession we don't need these
|
||||
std::string id = "";
|
||||
std::string direction = "";
|
||||
WebRTCSession* session =
|
||||
new WebRTCSession(id, direction, port_allocator_,
|
||||
WebRtcSession* session =
|
||||
new WebRtcSession(id, direction, port_allocator_,
|
||||
channel_manager_,
|
||||
// TODO(ronghuawu): implement PeerConnectionImplCallbacks
|
||||
// this,
|
||||
|
@ -42,7 +42,7 @@ class Message;
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class WebRTCSession;
|
||||
class WebRtcSession;
|
||||
|
||||
class PeerConnectionImpl : public PeerConnection {
|
||||
public:
|
||||
@ -100,7 +100,7 @@ class PeerConnectionImpl : public PeerConnection {
|
||||
}
|
||||
|
||||
private:
|
||||
WebRTCSession* CreateSession();
|
||||
WebRtcSession* CreateSession();
|
||||
virtual void OnMessage(talk_base::Message* msg);
|
||||
void AddStream_s(LocalStream* stream);
|
||||
void RemoveStream_s(LocalStream* stream);
|
||||
@ -110,7 +110,7 @@ private:
|
||||
bool initialized_;
|
||||
ReadyState ready_state_;
|
||||
PeerConnectionObserver* observer_;
|
||||
talk_base::scoped_ptr<WebRTCSession> session_;
|
||||
talk_base::scoped_ptr<WebRtcSession> session_;
|
||||
talk_base::scoped_ptr<talk_base::Thread> signaling_thread_;
|
||||
cricket::ChannelManager* channel_manager_;
|
||||
cricket::PortAllocator* port_allocator_;
|
||||
|
@ -53,7 +53,7 @@ class PeerConnectionTransport : public talk_base::MessageHandler,
|
||||
void ConnectChannels();
|
||||
|
||||
// methods to handle transport channels. These methods are relayed from
|
||||
// WebRTCSessionImpl which implements cricket::BaseSession methods
|
||||
// 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,
|
||||
|
@ -64,10 +64,10 @@ typedef std::vector<StreamInfo*> StreamMap; // not really a map (vector)
|
||||
static const char kVideoStream[] = "video_rtp";
|
||||
static const char kAudioStream[] = "rtp";
|
||||
|
||||
const char WebRTCSession::kOutgoingDirection[] = "s";
|
||||
const char WebRTCSession::kIncomingDirection[] = "r";
|
||||
const char WebRtcSession::kOutgoingDirection[] = "s";
|
||||
const char WebRtcSession::kIncomingDirection[] = "r";
|
||||
|
||||
WebRTCSession::WebRTCSession(
|
||||
WebRtcSession::WebRtcSession(
|
||||
const std::string& id,
|
||||
const std::string& direction,
|
||||
cricket::PortAllocator* allocator,
|
||||
@ -76,7 +76,7 @@ WebRTCSession::WebRTCSession(
|
||||
: BaseSession(signaling_thread),
|
||||
transport_(NULL),
|
||||
channel_manager_(channelmgr),
|
||||
all_transports_writable_(false),
|
||||
transports_writable_(false),
|
||||
muted_(false),
|
||||
camera_muted_(false),
|
||||
setup_timeout_(kCallSetupTimeout),
|
||||
@ -87,7 +87,7 @@ WebRTCSession::WebRTCSession(
|
||||
BaseSession::sid_ = id;
|
||||
}
|
||||
|
||||
WebRTCSession::~WebRTCSession() {
|
||||
WebRtcSession::~WebRtcSession() {
|
||||
RemoveAllStreams();
|
||||
if (state_ != STATE_RECEIVEDTERMINATE) {
|
||||
Terminate();
|
||||
@ -95,7 +95,7 @@ WebRTCSession::~WebRTCSession() {
|
||||
signaling_thread_->Send(this, MSG_WEBRTC_DELETE_TRANSPORT, NULL);
|
||||
}
|
||||
|
||||
bool WebRTCSession::Initiate() {
|
||||
bool WebRtcSession::Initiate() {
|
||||
signaling_thread_->Send(this, MSG_WEBRTC_CREATE_TRANSPORT, NULL);
|
||||
if (transport_ == NULL) {
|
||||
return false;
|
||||
@ -104,24 +104,24 @@ bool WebRTCSession::Initiate() {
|
||||
|
||||
// start transports
|
||||
transport_->SignalRequestSignaling.connect(
|
||||
this, &WebRTCSession::OnRequestSignaling);
|
||||
this, &WebRtcSession::OnRequestSignaling);
|
||||
transport_->SignalCandidatesReady.connect(
|
||||
this, &WebRTCSession::OnCandidatesReady);
|
||||
this, &WebRtcSession::OnCandidatesReady);
|
||||
transport_->SignalWritableState.connect(
|
||||
this, &WebRTCSession::OnWritableState);
|
||||
this, &WebRtcSession::OnWritableState);
|
||||
// Limit the amount of time that setting up a call may take.
|
||||
StartTransportTimeout(kCallSetupTimeout);
|
||||
return true;
|
||||
}
|
||||
|
||||
cricket::Transport* WebRTCSession::CreateTransport() {
|
||||
cricket::Transport* WebRtcSession::CreateTransport() {
|
||||
ASSERT(signaling_thread()->IsCurrent());
|
||||
return new cricket::P2PTransport(
|
||||
talk_base::Thread::Current(),
|
||||
channel_manager_->worker_thread(), port_allocator());
|
||||
}
|
||||
|
||||
bool WebRTCSession::CreateVoiceChannel(const std::string& stream_id) {
|
||||
bool WebRtcSession::CreateVoiceChannel(const std::string& stream_id) {
|
||||
StreamInfo* stream_info = new StreamInfo(stream_id);
|
||||
stream_info->video = false;
|
||||
streams_.push_back(stream_info);
|
||||
@ -138,7 +138,7 @@ bool WebRTCSession::CreateVoiceChannel(const std::string& stream_id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebRTCSession::CreateVideoChannel(const std::string& stream_id) {
|
||||
bool WebRtcSession::CreateVideoChannel(const std::string& stream_id) {
|
||||
StreamInfo* stream_info = new StreamInfo(stream_id);
|
||||
stream_info->video = true;
|
||||
streams_.push_back(stream_info);
|
||||
@ -155,7 +155,7 @@ bool WebRTCSession::CreateVideoChannel(const std::string& stream_id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
cricket::TransportChannel* WebRTCSession::CreateChannel(
|
||||
cricket::TransportChannel* WebRtcSession::CreateChannel(
|
||||
const std::string& content_name,
|
||||
const std::string& name) {
|
||||
if (!transport_) {
|
||||
@ -184,7 +184,7 @@ cricket::TransportChannel* WebRTCSession::CreateChannel(
|
||||
return transport_channel;
|
||||
}
|
||||
|
||||
cricket::TransportChannel* WebRTCSession::GetChannel(
|
||||
cricket::TransportChannel* WebRtcSession::GetChannel(
|
||||
const std::string& content_name, const std::string& name) {
|
||||
if (!transport_)
|
||||
return NULL;
|
||||
@ -198,7 +198,7 @@ cricket::TransportChannel* WebRTCSession::GetChannel(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void WebRTCSession::DestroyChannel(
|
||||
void WebRtcSession::DestroyChannel(
|
||||
const std::string& content_name, const std::string& name) {
|
||||
if (!transport_)
|
||||
return;
|
||||
@ -214,7 +214,7 @@ void WebRTCSession::DestroyChannel(
|
||||
}
|
||||
}
|
||||
|
||||
void WebRTCSession::OnMessage(talk_base::Message* message) {
|
||||
void WebRtcSession::OnMessage(talk_base::Message* message) {
|
||||
switch (message->message_id) {
|
||||
case MSG_CANDIDATE_TIMEOUT:
|
||||
if (transport_->writable()) {
|
||||
@ -239,7 +239,7 @@ void WebRTCSession::OnMessage(talk_base::Message* message) {
|
||||
}
|
||||
}
|
||||
|
||||
bool WebRTCSession::Connect() {
|
||||
bool WebRtcSession::Connect() {
|
||||
if (streams_.empty()) {
|
||||
// nothing to initiate
|
||||
return false;
|
||||
@ -259,7 +259,7 @@ bool WebRTCSession::Connect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebRTCSession::SetVideoRenderer(const std::string& stream_id,
|
||||
bool WebRtcSession::SetVideoRenderer(const std::string& stream_id,
|
||||
cricket::VideoRenderer* renderer) {
|
||||
bool ret = false;
|
||||
StreamMap::iterator iter;
|
||||
@ -277,12 +277,12 @@ bool WebRTCSession::SetVideoRenderer(const std::string& stream_id,
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool WebRTCSession::SetVideoCapture(bool capture) {
|
||||
bool WebRtcSession::SetVideoCapture(bool capture) {
|
||||
channel_manager_->SetVideoCapture(capture);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebRTCSession::RemoveStream(const std::string& stream_id) {
|
||||
bool WebRtcSession::RemoveStream(const std::string& stream_id) {
|
||||
bool ret = false;
|
||||
StreamMap::iterator iter;
|
||||
for (iter = streams_.begin(); iter != streams_.end(); ++iter) {
|
||||
@ -313,7 +313,7 @@ bool WebRTCSession::RemoveStream(const std::string& stream_id) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void WebRTCSession::DisableLocalCandidate(const std::string& name) {
|
||||
void WebRtcSession::DisableLocalCandidate(const std::string& name) {
|
||||
for (size_t i = 0; i < local_candidates_.size(); ++i) {
|
||||
if (local_candidates_[i].name().compare(name) == 0) {
|
||||
talk_base::SocketAddress address(local_candidates_[i].address().ip(), 0);
|
||||
@ -322,7 +322,7 @@ void WebRTCSession::DisableLocalCandidate(const std::string& name) {
|
||||
}
|
||||
}
|
||||
|
||||
void WebRTCSession::EnableAllStreams() {
|
||||
void WebRtcSession::EnableAllStreams() {
|
||||
StreamMap::const_iterator i;
|
||||
for (i = streams_.begin(); i != streams_.end(); ++i) {
|
||||
cricket::BaseChannel* channel = (*i)->channel;
|
||||
@ -331,7 +331,7 @@ void WebRTCSession::EnableAllStreams() {
|
||||
}
|
||||
}
|
||||
|
||||
void WebRTCSession::RemoveAllStreams() {
|
||||
void WebRtcSession::RemoveAllStreams() {
|
||||
// signaling_thread_->Post(this, MSG_RTC_REMOVEALLSTREAMS);
|
||||
// First build a list of streams to remove and then remove them.
|
||||
// The reason we do this is that if we remove the streams inside the
|
||||
@ -353,7 +353,7 @@ void WebRTCSession::RemoveAllStreams() {
|
||||
SignalRemoveStreamMessage(this);
|
||||
}
|
||||
|
||||
bool WebRTCSession::HasStream(const std::string& stream_id) const {
|
||||
bool WebRtcSession::HasStream(const std::string& stream_id) const {
|
||||
StreamMap::const_iterator iter;
|
||||
for (iter = streams_.begin(); iter != streams_.end(); ++iter) {
|
||||
StreamInfo* sinfo = (*iter);
|
||||
@ -364,7 +364,7 @@ bool WebRTCSession::HasStream(const std::string& stream_id) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WebRTCSession::HasStream(bool video) const {
|
||||
bool WebRtcSession::HasStream(bool video) const {
|
||||
StreamMap::const_iterator iter;
|
||||
for (iter = streams_.begin(); iter != streams_.end(); ++iter) {
|
||||
StreamInfo* sinfo = (*iter);
|
||||
@ -375,27 +375,27 @@ bool WebRTCSession::HasStream(bool video) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WebRTCSession::HasAudioStream() const {
|
||||
bool WebRtcSession::HasAudioStream() const {
|
||||
return HasStream(false);
|
||||
}
|
||||
|
||||
bool WebRTCSession::HasVideoStream() const {
|
||||
bool WebRtcSession::HasVideoStream() const {
|
||||
return HasStream(true);
|
||||
}
|
||||
|
||||
talk_base::Thread* WebRTCSession::worker_thread() {
|
||||
talk_base::Thread* WebRtcSession::worker_thread() {
|
||||
return channel_manager_->worker_thread();
|
||||
}
|
||||
|
||||
void WebRTCSession::OnRequestSignaling(cricket::Transport* transport) {
|
||||
void WebRtcSession::OnRequestSignaling(cricket::Transport* transport) {
|
||||
transport->OnSignalingReady();
|
||||
}
|
||||
|
||||
void WebRTCSession::OnWritableState(cricket::Transport* transport) {
|
||||
void WebRtcSession::OnWritableState(cricket::Transport* transport) {
|
||||
ASSERT(transport == transport_);
|
||||
const bool all_transports_writable = transport_->writable();
|
||||
if (all_transports_writable) {
|
||||
if (all_transports_writable != all_transports_writable_) {
|
||||
const bool transports_writable = transport_->writable();
|
||||
if (transports_writable) {
|
||||
if (transports_writable != transports_writable_) {
|
||||
signaling_thread_->Clear(this, MSG_CANDIDATE_TIMEOUT);
|
||||
} else {
|
||||
// At one point all channels were writable and we had full connectivity,
|
||||
@ -403,22 +403,22 @@ void WebRTCSession::OnWritableState(cricket::Transport* transport) {
|
||||
// doesn't come back.
|
||||
StartTransportTimeout(kCallLostTimeout);
|
||||
}
|
||||
all_transports_writable_ = all_transports_writable;
|
||||
transports_writable_ = transports_writable;
|
||||
}
|
||||
NotifyTransportState();
|
||||
return;
|
||||
}
|
||||
|
||||
void WebRTCSession::StartTransportTimeout(int timeout) {
|
||||
void WebRtcSession::StartTransportTimeout(int timeout) {
|
||||
talk_base::Thread::Current()->PostDelayed(timeout, this,
|
||||
MSG_CANDIDATE_TIMEOUT,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void WebRTCSession::NotifyTransportState() {
|
||||
void WebRtcSession::NotifyTransportState() {
|
||||
}
|
||||
|
||||
bool WebRTCSession::OnInitiateMessage(
|
||||
bool WebRtcSession::OnInitiateMessage(
|
||||
cricket::SessionDescription* offer,
|
||||
const std::vector<cricket::Candidate>& candidates) {
|
||||
if (!offer) {
|
||||
@ -480,7 +480,7 @@ bool WebRTCSession::OnInitiateMessage(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebRTCSession::OnRemoteDescription(
|
||||
bool WebRtcSession::OnRemoteDescription(
|
||||
cricket::SessionDescription* desc,
|
||||
const std::vector<cricket::Candidate>& candidates) {
|
||||
|
||||
@ -519,7 +519,7 @@ bool WebRTCSession::OnRemoteDescription(
|
||||
return true;
|
||||
}
|
||||
|
||||
void WebRTCSession::ProcessTerminateAccept(cricket::SessionDescription* desc) {
|
||||
void WebRtcSession::ProcessTerminateAccept(cricket::SessionDescription* desc) {
|
||||
const cricket::ContentInfo* video_content = GetFirstVideoContent(desc);
|
||||
if (video_content) {
|
||||
SignalRemoveStream(video_content->name, true);
|
||||
@ -531,7 +531,7 @@ void WebRTCSession::ProcessTerminateAccept(cricket::SessionDescription* desc) {
|
||||
}
|
||||
}
|
||||
|
||||
bool WebRTCSession::CheckForStreamDeleteMessage(
|
||||
bool WebRtcSession::CheckForStreamDeleteMessage(
|
||||
const std::vector<cricket::Candidate>& candidates) {
|
||||
for (size_t i = 0; i < candidates.size(); ++i) {
|
||||
if (candidates[i].address().port() == 0) {
|
||||
@ -541,7 +541,7 @@ bool WebRTCSession::CheckForStreamDeleteMessage(
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WebRTCSession::OnStreamDeleteMessage(
|
||||
bool WebRtcSession::OnStreamDeleteMessage(
|
||||
const cricket::SessionDescription* desc,
|
||||
const std::vector<cricket::Candidate>& candidates) {
|
||||
// This will be called when session is in connected state
|
||||
@ -570,7 +570,7 @@ bool WebRTCSession::OnStreamDeleteMessage(
|
||||
return true;
|
||||
}
|
||||
|
||||
void WebRTCSession::RemoveStreamOnRequest(
|
||||
void WebRtcSession::RemoveStreamOnRequest(
|
||||
const cricket::Candidate& candidate) {
|
||||
// 1. Get Transport corresponding to candidate name
|
||||
// 2. Get StreamInfo for the transport found in step 1
|
||||
@ -606,7 +606,7 @@ void WebRTCSession::RemoveStreamOnRequest(
|
||||
}
|
||||
}
|
||||
|
||||
cricket::SessionDescription* WebRTCSession::CreateOffer() {
|
||||
cricket::SessionDescription* WebRtcSession::CreateOffer() {
|
||||
cricket::SessionDescription* offer = new cricket::SessionDescription();
|
||||
StreamMap::iterator iter;
|
||||
for (iter = streams_.begin(); iter != streams_.end(); ++iter) {
|
||||
@ -641,7 +641,7 @@ cricket::SessionDescription* WebRTCSession::CreateOffer() {
|
||||
return offer;
|
||||
}
|
||||
|
||||
cricket::SessionDescription* WebRTCSession::CreateAnswer(
|
||||
cricket::SessionDescription* WebRtcSession::CreateAnswer(
|
||||
const cricket::SessionDescription* offer) {
|
||||
cricket::SessionDescription* answer = new cricket::SessionDescription();
|
||||
|
||||
@ -699,35 +699,11 @@ cricket::SessionDescription* WebRTCSession::CreateAnswer(
|
||||
return answer;
|
||||
}
|
||||
|
||||
void WebRTCSession::OnMute(bool mute) {
|
||||
StreamMap::iterator iter;
|
||||
for (iter = streams_.begin(); iter != streams_.end(); ++iter) {
|
||||
if (!(*iter)->video) {
|
||||
cricket::VoiceChannel* voice_channel =
|
||||
static_cast<cricket::VoiceChannel*>((*iter)->channel);
|
||||
ASSERT(voice_channel != NULL);
|
||||
voice_channel->Mute(mute);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WebRTCSession::OnCameraMute(bool mute) {
|
||||
StreamMap::iterator iter;
|
||||
for (iter = streams_.begin(); iter != streams_.end(); ++iter) {
|
||||
if ((*iter)->video) {
|
||||
cricket::VideoChannel* video_channel =
|
||||
static_cast<cricket::VideoChannel*>((*iter)->channel);
|
||||
ASSERT(video_channel != NULL);
|
||||
video_channel->Mute(mute);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WebRTCSession::SetError(Error error) {
|
||||
void WebRtcSession::SetError(Error error) {
|
||||
BaseSession::SetError(error);
|
||||
}
|
||||
|
||||
void WebRTCSession::OnCandidatesReady(
|
||||
void WebRtcSession::OnCandidatesReady(
|
||||
cricket::Transport* transport,
|
||||
const std::vector<cricket::Candidate>& candidates) {
|
||||
std::vector<cricket::Candidate>::const_iterator iter;
|
||||
|
@ -74,15 +74,15 @@ struct StreamInfo {
|
||||
typedef std::vector<cricket::AudioCodec> AudioCodecs;
|
||||
typedef std::vector<cricket::VideoCodec> VideoCodecs;
|
||||
|
||||
class WebRTCSession : public cricket::BaseSession {
|
||||
class WebRtcSession : public cricket::BaseSession {
|
||||
public:
|
||||
WebRTCSession(const std::string& id,
|
||||
WebRtcSession(const std::string& id,
|
||||
const std::string& direction,
|
||||
cricket::PortAllocator* allocator,
|
||||
cricket::ChannelManager* channelmgr,
|
||||
talk_base::Thread* signaling_thread);
|
||||
|
||||
~WebRTCSession();
|
||||
~WebRtcSession();
|
||||
|
||||
bool Initiate();
|
||||
bool Connect();
|
||||
@ -90,8 +90,6 @@ class WebRTCSession : public cricket::BaseSession {
|
||||
const std::vector<cricket::Candidate>& candidates);
|
||||
bool OnInitiateMessage(cricket::SessionDescription* sdp,
|
||||
const std::vector<cricket::Candidate>& candidates);
|
||||
void OnMute(bool mute);
|
||||
void OnCameraMute(bool mute);
|
||||
bool CreateVoiceChannel(const std::string& stream_id);
|
||||
bool CreateVideoChannel(const std::string& stream_id);
|
||||
bool RemoveStream(const std::string& stream_id);
|
||||
@ -110,14 +108,31 @@ class WebRTCSession : public cricket::BaseSession {
|
||||
bool SetVideoRenderer(const std::string& stream_id,
|
||||
cricket::VideoRenderer* renderer);
|
||||
|
||||
sigslot::signal1<WebRTCSession*> SignalRemoveStreamMessage;
|
||||
// This signal occurs when all the streams have been removed.
|
||||
// It is triggered by a successful call to the RemoveAllStream or
|
||||
// the OnRemoteDescription with stream deleted signaling message with the
|
||||
// candidates port equal to 0.
|
||||
sigslot::signal1<WebRtcSession*> SignalRemoveStreamMessage;
|
||||
|
||||
// This signal indicates a stream has been added properly.
|
||||
// It is triggered by a successful call to the OnInitiateMessage or
|
||||
// the OnRemoteDescription and if it's going to the STATE_RECEIVEDACCEPT.
|
||||
sigslot::signal2<const std::string&, bool> SignalAddStream;
|
||||
|
||||
// This signal occurs when one stream is removed with the signaling
|
||||
// message from the remote peer with the candidates port equal to 0.
|
||||
sigslot::signal2<const std::string&, bool> SignalRemoveStream;
|
||||
|
||||
// This signal occurs when audio/video channel has been created for the
|
||||
// new added stream.
|
||||
sigslot::signal2<const std::string&, bool> SignalRtcMediaChannelCreated;
|
||||
// Triggered when the local candidate is ready
|
||||
|
||||
// This signal occurs when the local candidate is ready
|
||||
sigslot::signal2<const cricket::SessionDescription*,
|
||||
const std::vector<cricket::Candidate>&> SignalLocalDescription;
|
||||
// This callback will trigger if setting up a call times out.
|
||||
|
||||
// This signal triggers when setting up or resuming a call has not been
|
||||
// successful before a certain time out.
|
||||
sigslot::signal0<> SignalFailedCall;
|
||||
|
||||
bool muted() const { return muted_; }
|
||||
@ -194,7 +209,7 @@ class WebRTCSession : public cricket::BaseSession {
|
||||
cricket::ChannelManager* channel_manager_;
|
||||
std::vector<StreamInfo*> streams_;
|
||||
TransportChannelMap transport_channels_;
|
||||
bool all_transports_writable_;
|
||||
bool transports_writable_;
|
||||
bool muted_;
|
||||
bool camera_muted_;
|
||||
int setup_timeout_;
|
||||
|
@ -168,7 +168,7 @@ class OnSignalImpl
|
||||
enum CallbackId {
|
||||
kNone,
|
||||
kOnAddStream,
|
||||
kOnRemoveStream2,
|
||||
kOnRemoveStream,
|
||||
kOnRtcMediaChannelCreated,
|
||||
kOnLocalDescription,
|
||||
kOnFailedCall,
|
||||
@ -190,8 +190,8 @@ class OnSignalImpl
|
||||
last_stream_id_ = stream_id;
|
||||
last_was_video_ = video;
|
||||
}
|
||||
void OnRemoveStream2(const std::string& stream_id, bool video) {
|
||||
callback_ids_.push_back(kOnRemoveStream2);
|
||||
void OnRemoveStream(const std::string& stream_id, bool video) {
|
||||
callback_ids_.push_back(kOnRemoveStream);
|
||||
last_stream_id_ = stream_id;
|
||||
last_was_video_ = video;
|
||||
}
|
||||
@ -310,14 +310,14 @@ typedef ReturnBoolPassArgument<
|
||||
std::pair<std::string, cricket::VideoRenderer*> >
|
||||
ReturnBoolPassStringVideoRenderer;
|
||||
|
||||
class WebRTCSessionExtendedForTest : public webrtc::WebRTCSession {
|
||||
class WebRtcSessionExtendedForTest : public webrtc::WebRtcSession {
|
||||
public:
|
||||
WebRTCSessionExtendedForTest(const std::string& id,
|
||||
WebRtcSessionExtendedForTest(const std::string& id,
|
||||
const std::string& direction,
|
||||
cricket::PortAllocator* allocator,
|
||||
cricket::ChannelManager* channelmgr,
|
||||
talk_base::Thread* signaling_thread)
|
||||
: WebRTCSession(id, direction, allocator, channelmgr, signaling_thread),
|
||||
: WebRtcSession(id, direction, allocator, channelmgr, signaling_thread),
|
||||
worker_thread_(channelmgr->worker_thread()) {
|
||||
}
|
||||
private:
|
||||
@ -330,7 +330,7 @@ class WebRTCSessionExtendedForTest : public webrtc::WebRTCSession {
|
||||
talk_base::Thread* worker_thread_;
|
||||
};
|
||||
|
||||
class WebRTCSessionTest : public OnSignalImpl,
|
||||
class WebRtcSessionTest : public OnSignalImpl,
|
||||
public talk_base::MessageHandler {
|
||||
public:
|
||||
enum FunctionCallId {
|
||||
@ -338,8 +338,6 @@ class WebRTCSessionTest : public OnSignalImpl,
|
||||
kCallConnect,
|
||||
kCallOnRemoteDescription,
|
||||
kCallOnInitiateMessage,
|
||||
kCallOnMute,
|
||||
kCallOnCameraMute,
|
||||
kCallMuted,
|
||||
kCallCameraMuted,
|
||||
kCallCreateVoiceChannel,
|
||||
@ -356,9 +354,9 @@ class WebRTCSessionTest : public OnSignalImpl,
|
||||
enum {kInit = kCallLocalCandidates + 1};
|
||||
enum {kTerminate = kInit + 1};
|
||||
|
||||
static WebRTCSessionTest* CreateWebRTCSessionTest(bool receiving) {
|
||||
WebRTCSessionTest* return_value =
|
||||
new WebRTCSessionTest();
|
||||
static WebRtcSessionTest* CreateWebRtcSessionTest(bool receiving) {
|
||||
WebRtcSessionTest* return_value =
|
||||
new WebRtcSessionTest();
|
||||
if (return_value == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@ -436,16 +434,16 @@ class WebRTCSessionTest : public OnSignalImpl,
|
||||
|
||||
talk_base::CreateRandomString(8, &id_);
|
||||
|
||||
session_ = new webrtc::WebRTCSession(
|
||||
session_ = new webrtc::WebRtcSession(
|
||||
id_, DirectionAsString() , allocator_,
|
||||
channel_manager_,
|
||||
signaling_thread_);
|
||||
session_->SignalAddStream.connect(
|
||||
static_cast<OnSignalImpl*> (this),
|
||||
&OnSignalImpl::OnAddStream);
|
||||
session_->SignalRemoveStream2.connect(
|
||||
session_->SignalRemoveStream.connect(
|
||||
static_cast<OnSignalImpl*> (this),
|
||||
&OnSignalImpl::OnRemoveStream2);
|
||||
&OnSignalImpl::OnRemoveStream);
|
||||
session_->SignalRtcMediaChannelCreated.connect(
|
||||
static_cast<OnSignalImpl*> (this),
|
||||
&OnSignalImpl::OnRtcMediaChannelCreated);
|
||||
@ -466,7 +464,7 @@ class WebRTCSessionTest : public OnSignalImpl,
|
||||
delete allocator_;
|
||||
}
|
||||
|
||||
~WebRTCSessionTest() {
|
||||
~WebRtcSessionTest() {
|
||||
if (signaling_thread_ != NULL) {
|
||||
signaling_thread_->Send(this, kTerminate, NULL);
|
||||
signaling_thread_->Stop();
|
||||
@ -509,28 +507,6 @@ class WebRTCSessionTest : public OnSignalImpl,
|
||||
return return_value.return_value_;
|
||||
}
|
||||
|
||||
void CallOnMute(bool mute) {
|
||||
PassBool return_value(mute);
|
||||
signaling_thread_->Send(this, kCallOnMute, &return_value);
|
||||
}
|
||||
|
||||
void CallOnCameraMute(bool mute) {
|
||||
PassBool return_value(mute);
|
||||
signaling_thread_->Send(this, kCallOnCameraMute, &return_value);
|
||||
}
|
||||
|
||||
bool CallMuted() {
|
||||
ReturnBool return_value;
|
||||
signaling_thread_->Send(this, kCallMuted, &return_value);
|
||||
return return_value.return_value_;
|
||||
}
|
||||
|
||||
bool CallCameraMuted() {
|
||||
ReturnBool return_value;
|
||||
signaling_thread_->Send(this, kCallCameraMuted, &return_value);
|
||||
return return_value.return_value_;
|
||||
}
|
||||
|
||||
bool CallCreateVoiceChannel(const std::string& stream_id) {
|
||||
ReturnBoolPassString return_value(stream_id);
|
||||
signaling_thread_->Send(this, kCallCreateVoiceChannel, &return_value);
|
||||
@ -641,16 +617,6 @@ class WebRTCSessionTest : public OnSignalImpl,
|
||||
return_value->return_value_ = true;
|
||||
}
|
||||
|
||||
void OnMute_s(talk_base::Message* message) {
|
||||
PassBool* return_value = reinterpret_cast<PassBool*>(message->pdata);
|
||||
session_->OnMute(return_value->argument());
|
||||
}
|
||||
|
||||
void OnCameraMute_s(talk_base::Message* message) {
|
||||
PassBool* return_value = reinterpret_cast<PassBool*>(message->pdata);
|
||||
session_->OnCameraMute(return_value->argument());
|
||||
}
|
||||
|
||||
void Muted_s(talk_base::Message* message) {
|
||||
ReturnBool* return_value = reinterpret_cast<ReturnBool*>(message->pdata);
|
||||
return_value->return_value_ = session_->muted();
|
||||
@ -747,12 +713,6 @@ class WebRTCSessionTest : public OnSignalImpl,
|
||||
case kCallOnInitiateMessage:
|
||||
OnInitiateMessage_s(message);
|
||||
return;
|
||||
case kCallOnMute:
|
||||
OnMute_s(message);
|
||||
return;
|
||||
case kCallOnCameraMute:
|
||||
OnCameraMute_s(message);
|
||||
return;
|
||||
case kCallMuted:
|
||||
Muted_s(message);
|
||||
return;
|
||||
@ -802,7 +762,7 @@ class WebRTCSessionTest : public OnSignalImpl,
|
||||
}
|
||||
|
||||
private:
|
||||
WebRTCSessionTest()
|
||||
WebRtcSessionTest()
|
||||
: session_(NULL),
|
||||
id_(),
|
||||
receiving_(false),
|
||||
@ -812,7 +772,7 @@ class WebRTCSessionTest : public OnSignalImpl,
|
||||
signaling_thread_(NULL) {
|
||||
}
|
||||
|
||||
webrtc::WebRTCSession* session_;
|
||||
webrtc::WebRtcSession* session_;
|
||||
std::string id_;
|
||||
bool receiving_;
|
||||
|
||||
@ -824,7 +784,7 @@ class WebRTCSessionTest : public OnSignalImpl,
|
||||
talk_base::Thread* signaling_thread_;
|
||||
};
|
||||
|
||||
bool CallbackReceived(WebRTCSessionTest* session, int timeout) {
|
||||
bool CallbackReceived(WebRtcSessionTest* session, int timeout) {
|
||||
talk_base::Thread::SleepMs(timeout);
|
||||
const OnSignalImpl::CallbackId peek_id =
|
||||
session->PeekOldestCallback();
|
||||
@ -837,8 +797,8 @@ void SleepMs(int timeout_ms) {
|
||||
|
||||
TEST(WebRtcSessionTest, InitializationReceiveSanity) {
|
||||
const bool kReceiving = true;
|
||||
talk_base::scoped_ptr<WebRTCSessionTest> my_session;
|
||||
my_session.reset(WebRTCSessionTest::CreateWebRTCSessionTest(kReceiving));
|
||||
talk_base::scoped_ptr<WebRtcSessionTest> my_session;
|
||||
my_session.reset(WebRtcSessionTest::CreateWebRtcSessionTest(kReceiving));
|
||||
|
||||
ASSERT_TRUE(my_session.get() != NULL);
|
||||
ASSERT_TRUE(my_session->CallInitiate());
|
||||
@ -854,10 +814,11 @@ TEST(WebRtcSessionTest, InitializationReceiveSanity) {
|
||||
my_session->PopOldestCallback());
|
||||
}
|
||||
|
||||
// TODO(ronghuawu): Add tests for video calls and incoming calls.
|
||||
TEST(WebRtcSessionTest, SendCallSetUp) {
|
||||
const bool kReceiving = false;
|
||||
talk_base::scoped_ptr<WebRTCSessionTest> my_session;
|
||||
my_session.reset(WebRTCSessionTest::CreateWebRTCSessionTest(kReceiving));
|
||||
talk_base::scoped_ptr<WebRtcSessionTest> my_session;
|
||||
my_session.reset(WebRtcSessionTest::CreateWebRtcSessionTest(kReceiving));
|
||||
|
||||
ASSERT_TRUE(my_session.get() != NULL);
|
||||
ASSERT_TRUE(my_session->CallInitiate());
|
||||
|
Loading…
x
Reference in New Issue
Block a user