Review URL: http://webrtc-codereview.appspot.com/113008
git-svn-id: http://webrtc.googlecode.com/svn/trunk@401 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
a2de6060b7
commit
bfc63ae83f
@ -34,7 +34,6 @@
|
||||
#include "talk/base/stringencode.h"
|
||||
#include "talk/base/logging.h"
|
||||
#include "talk/p2p/client/basicportallocator.h"
|
||||
|
||||
#include "talk/app/webrtc/webrtcsession.h"
|
||||
#include "talk/app/webrtc/webrtc_json.h"
|
||||
|
||||
@ -294,13 +293,13 @@ WebRTCSession* PeerConnectionImpl::CreateMediaSession(
|
||||
signaling_thread_.get());
|
||||
|
||||
if (session->Initiate()) {
|
||||
session->SignalRemoveStream.connect(
|
||||
session->SignalRemoveStreamMessage.connect(
|
||||
this,
|
||||
&PeerConnectionImpl::SendRemoveSignal);
|
||||
session->SignalAddStream.connect(
|
||||
this,
|
||||
&PeerConnectionImpl::OnAddStream);
|
||||
session->SignalRemoveStream2.connect(
|
||||
session->SignalRemoveStream.connect(
|
||||
this,
|
||||
&PeerConnectionImpl::OnRemoveStream2);
|
||||
session->SignalRtcMediaChannelCreated.connect(
|
||||
|
@ -132,9 +132,7 @@ bool WebRTCSession::CreateVoiceChannel(const std::string& stream_id) {
|
||||
ASSERT(voice_channel != NULL);
|
||||
stream_info->channel = voice_channel;
|
||||
|
||||
if (incoming()) {
|
||||
SignalAddStream(stream_id, false);
|
||||
} else {
|
||||
if (!incoming()) {
|
||||
SignalRtcMediaChannelCreated(stream_id, false);
|
||||
}
|
||||
return true;
|
||||
@ -151,15 +149,12 @@ bool WebRTCSession::CreateVideoChannel(const std::string& stream_id) {
|
||||
ASSERT(video_channel != NULL);
|
||||
stream_info->channel = video_channel;
|
||||
|
||||
if (incoming()) {
|
||||
SignalAddStream(stream_id, true);
|
||||
} else {
|
||||
if (!incoming()) {
|
||||
SignalRtcMediaChannelCreated(stream_id, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
cricket::TransportChannel* WebRTCSession::CreateChannel(
|
||||
const std::string& content_name,
|
||||
const std::string& name) {
|
||||
@ -354,7 +349,8 @@ void WebRTCSession::RemoveAllStreams() {
|
||||
RemoveStream(*i);
|
||||
}
|
||||
|
||||
SignalRemoveStream(this);
|
||||
SetState(STATE_SENTTERMINATE);
|
||||
SignalRemoveStreamMessage(this);
|
||||
}
|
||||
|
||||
bool WebRTCSession::HasStream(const std::string& stream_id) const {
|
||||
@ -413,8 +409,6 @@ void WebRTCSession::OnWritableState(cricket::Transport* transport) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void WebRTCSession::StartTransportTimeout(int timeout) {
|
||||
talk_base::Thread::Current()->PostDelayed(timeout, this,
|
||||
MSG_CANDIDATE_TIMEOUT,
|
||||
@ -473,17 +467,32 @@ bool WebRTCSession::OnInitiateMessage(
|
||||
|
||||
set_local_description(answer.release());
|
||||
SetState(STATE_SENTACCEPT);
|
||||
|
||||
// Provide remote candidates to the transport
|
||||
transport_->OnRemoteCandidates(candidates);
|
||||
|
||||
// AddStream called only once with Video label
|
||||
if (video_content) {
|
||||
SignalAddStream(video_content->name, true);
|
||||
} else {
|
||||
SignalAddStream(audio_content->name, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebRTCSession::OnRemoteDescription(
|
||||
cricket::SessionDescription* desc,
|
||||
const std::vector<cricket::Candidate>& candidates) {
|
||||
|
||||
if (state() == STATE_SENTTERMINATE) {
|
||||
ProcessTerminateAccept(desc);
|
||||
return true;
|
||||
}
|
||||
if (state() == STATE_SENTACCEPT ||
|
||||
state() == STATE_RECEIVEDACCEPT ||
|
||||
state() == STATE_INPROGRESS) {
|
||||
if (CheckForStreamDeleteMessage(candidates)) {
|
||||
return OnRemoteDescriptionUpdate(desc, candidates);
|
||||
return OnStreamDeleteMessage(desc, candidates);
|
||||
} else {
|
||||
transport_->OnRemoteCandidates(candidates);
|
||||
return true;
|
||||
@ -493,11 +502,35 @@ bool WebRTCSession::OnRemoteDescription(
|
||||
// Session description is always accepted.
|
||||
set_remote_description(desc);
|
||||
SetState(STATE_RECEIVEDACCEPT);
|
||||
// Will trigger OnWritableState() if successfull.
|
||||
|
||||
if (!incoming()) {
|
||||
// Trigger OnAddStream callback at the initiator
|
||||
const cricket::ContentInfo* video_content = GetFirstVideoContent(desc);
|
||||
if (video_content) {
|
||||
SignalAddStream(video_content->name, true);
|
||||
} else {
|
||||
const cricket::ContentInfo* audio_content = GetFirstAudioContent(desc);
|
||||
if (audio_content)
|
||||
SignalAddStream(audio_content->name, false);
|
||||
}
|
||||
}
|
||||
// Will trigger OnWritableState() if successful.
|
||||
transport_->OnRemoteCandidates(candidates);
|
||||
return true;
|
||||
}
|
||||
|
||||
void WebRTCSession::ProcessTerminateAccept(cricket::SessionDescription* desc) {
|
||||
const cricket::ContentInfo* video_content = GetFirstVideoContent(desc);
|
||||
if (video_content) {
|
||||
SignalRemoveStream(video_content->name, true);
|
||||
} else {
|
||||
const cricket::ContentInfo* audio_content = GetFirstAudioContent(desc);
|
||||
if (audio_content) {
|
||||
SignalRemoveStream(audio_content->name, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool WebRTCSession::CheckForStreamDeleteMessage(
|
||||
const std::vector<cricket::Candidate>& candidates) {
|
||||
for (size_t i = 0; i < candidates.size(); ++i) {
|
||||
@ -508,7 +541,7 @@ bool WebRTCSession::CheckForStreamDeleteMessage(
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WebRTCSession::OnRemoteDescriptionUpdate(
|
||||
bool WebRTCSession::OnStreamDeleteMessage(
|
||||
const cricket::SessionDescription* desc,
|
||||
const std::vector<cricket::Candidate>& candidates) {
|
||||
// This will be called when session is in connected state
|
||||
@ -517,11 +550,23 @@ bool WebRTCSession::OnRemoteDescriptionUpdate(
|
||||
// check for candidates port, if its equal to 0, remove that stream
|
||||
// and provide callback OnRemoveStream else keep as it is
|
||||
|
||||
SetState(STATE_RECEIVEDTERMINATE);
|
||||
for (size_t i = 0; i < candidates.size(); ++i) {
|
||||
if (candidates[i].address().port() == 0) {
|
||||
RemoveStreamOnRequest(candidates[i]);
|
||||
}
|
||||
}
|
||||
|
||||
SignalRemoveStreamMessage(this);
|
||||
const cricket::ContentInfo* video_content = GetFirstVideoContent(desc);
|
||||
if (video_content) {
|
||||
SignalRemoveStream(video_content->name, true);
|
||||
} else {
|
||||
const cricket::ContentInfo* audio_content = GetFirstAudioContent(desc);
|
||||
if (audio_content) {
|
||||
SignalRemoveStream(audio_content->name, false);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -547,13 +592,14 @@ void WebRTCSession::RemoveStreamOnRequest(
|
||||
stream_info->channel);
|
||||
channel->Enable(false);
|
||||
channel_manager_->DestroyVoiceChannel(channel);
|
||||
DisableLocalCandidate(stream_info->transport->name());
|
||||
} else {
|
||||
cricket::VideoChannel* channel = static_cast<cricket::VideoChannel*> (
|
||||
stream_info->channel);
|
||||
channel->Enable(false);
|
||||
channel_manager_->DestroyVideoChannel(channel);
|
||||
DisableLocalCandidate(stream_info->transport->name());
|
||||
}
|
||||
SignalRemoveStream2((*siter)->stream_id, (*siter)->video);
|
||||
streams_.erase(siter);
|
||||
break;
|
||||
}
|
||||
|
@ -110,9 +110,9 @@ class WebRTCSession : public cricket::BaseSession {
|
||||
bool SetVideoRenderer(const std::string& stream_id,
|
||||
cricket::VideoRenderer* renderer);
|
||||
|
||||
sigslot::signal1<WebRTCSession*> SignalRemoveStream;
|
||||
sigslot::signal1<WebRTCSession*> SignalRemoveStreamMessage;
|
||||
sigslot::signal2<const std::string&, bool> SignalAddStream;
|
||||
sigslot::signal2<const std::string&, bool> SignalRemoveStream2;
|
||||
sigslot::signal2<const std::string&, bool> SignalRemoveStream;
|
||||
sigslot::signal2<const std::string&, bool> SignalRtcMediaChannelCreated;
|
||||
// Triggered when the local candidate is ready
|
||||
sigslot::signal2<const cricket::SessionDescription*,
|
||||
@ -164,6 +164,7 @@ class WebRTCSession : public cricket::BaseSession {
|
||||
|
||||
bool CheckForStreamDeleteMessage(
|
||||
const std::vector<cricket::Candidate>& candidates);
|
||||
void ProcessTerminateAccept(cricket::SessionDescription* desc);
|
||||
|
||||
void UpdateTransportWritableState();
|
||||
bool CheckAllTransportsWritable();
|
||||
@ -184,7 +185,7 @@ class WebRTCSession : public cricket::BaseSession {
|
||||
|
||||
bool SetVideoCapture(bool capture);
|
||||
void DisableLocalCandidate(const std::string& name);
|
||||
bool OnRemoteDescriptionUpdate(const cricket::SessionDescription* desc,
|
||||
bool OnStreamDeleteMessage(const cricket::SessionDescription* desc,
|
||||
const std::vector<cricket::Candidate>& candidates);
|
||||
void RemoveStreamOnRequest(const cricket::Candidate& candidate);
|
||||
void EnableAllStreams();
|
||||
|
Loading…
x
Reference in New Issue
Block a user