* Make GetReadyState accessible via the PeerConnection interface.
* Update PeerConnection implementations to include "virtual" in the method declarations. * Add a check for a valid signaling thread in webrtcsession.cc. Review URL: http://webrtc-codereview.appspot.com/137001 git-svn-id: http://webrtc.googlecode.com/svn/trunk@445 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
44d356d6df
commit
137ece4ac3
@ -71,6 +71,13 @@ class PeerConnectionObserver {
|
|||||||
|
|
||||||
class PeerConnection {
|
class PeerConnection {
|
||||||
public:
|
public:
|
||||||
|
enum ReadyState {
|
||||||
|
NEW = 0,
|
||||||
|
NEGOTIATING,
|
||||||
|
ACTIVE,
|
||||||
|
CLOSED,
|
||||||
|
};
|
||||||
|
|
||||||
virtual ~PeerConnection() {}
|
virtual ~PeerConnection() {}
|
||||||
|
|
||||||
// Register a listener
|
// Register a listener
|
||||||
@ -121,6 +128,10 @@ class PeerConnection {
|
|||||||
// For standalone app, cam_device is the camera name. It will try to
|
// For standalone app, cam_device is the camera name. It will try to
|
||||||
// set the default capture device when cam_device is "".
|
// set the default capture device when cam_device is "".
|
||||||
virtual bool SetVideoCapture(const std::string& cam_device) = 0;
|
virtual bool SetVideoCapture(const std::string& cam_device) = 0;
|
||||||
|
|
||||||
|
// Returns the state of the PeerConnection object. See the ReadyState
|
||||||
|
// enum for valid values.
|
||||||
|
virtual ReadyState GetReadyState() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -54,26 +54,20 @@ class PeerConnectionImpl : public PeerConnection,
|
|||||||
talk_base::Thread* signaling_thread);
|
talk_base::Thread* signaling_thread);
|
||||||
virtual ~PeerConnectionImpl();
|
virtual ~PeerConnectionImpl();
|
||||||
|
|
||||||
enum ReadyState {
|
|
||||||
NEW = 0,
|
|
||||||
NEGOTIATING,
|
|
||||||
ACTIVE,
|
|
||||||
CLOSED,
|
|
||||||
};
|
|
||||||
|
|
||||||
// PeerConnection interfaces
|
// PeerConnection interfaces
|
||||||
void RegisterObserver(PeerConnectionObserver* observer);
|
virtual void RegisterObserver(PeerConnectionObserver* observer);
|
||||||
bool SignalingMessage(const std::string& msg);
|
virtual bool SignalingMessage(const std::string& msg);
|
||||||
bool AddStream(const std::string& stream_id, bool video);
|
virtual bool AddStream(const std::string& stream_id, bool video);
|
||||||
bool RemoveStream(const std::string& stream_id);
|
virtual bool RemoveStream(const std::string& stream_id);
|
||||||
bool Connect();
|
virtual bool Connect();
|
||||||
bool Close();
|
virtual bool Close();
|
||||||
bool SetAudioDevice(const std::string& wave_in_device,
|
virtual bool SetAudioDevice(const std::string& wave_in_device,
|
||||||
const std::string& wave_out_device, int opts);
|
const std::string& wave_out_device, int opts);
|
||||||
bool SetLocalVideoRenderer(cricket::VideoRenderer* renderer);
|
virtual bool SetLocalVideoRenderer(cricket::VideoRenderer* renderer);
|
||||||
bool SetVideoRenderer(const std::string& stream_id,
|
virtual bool SetVideoRenderer(const std::string& stream_id,
|
||||||
cricket::VideoRenderer* renderer);
|
cricket::VideoRenderer* renderer);
|
||||||
bool SetVideoCapture(const std::string& cam_device);
|
virtual bool SetVideoCapture(const std::string& cam_device);
|
||||||
|
virtual ReadyState GetReadyState();
|
||||||
|
|
||||||
cricket::ChannelManager* channel_manager() {
|
cricket::ChannelManager* channel_manager() {
|
||||||
return channel_manager_;
|
return channel_manager_;
|
||||||
@ -91,7 +85,6 @@ class PeerConnectionImpl : public PeerConnection,
|
|||||||
bool Init();
|
bool Init();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ReadyState GetReadyState();
|
|
||||||
bool ParseConfigString(const std::string& config,
|
bool ParseConfigString(const std::string& config,
|
||||||
talk_base::SocketAddress* stun_addr);
|
talk_base::SocketAddress* stun_addr);
|
||||||
void SendRemoveSignal(WebRtcSession* session);
|
void SendRemoveSignal(WebRtcSession* session);
|
||||||
|
@ -45,6 +45,7 @@ enum {
|
|||||||
MSG_WEBRTC_SETVIDEOCAPTURE,
|
MSG_WEBRTC_SETVIDEOCAPTURE,
|
||||||
MSG_WEBRTC_SETVIDEORENDERER,
|
MSG_WEBRTC_SETVIDEORENDERER,
|
||||||
MSG_WEBRTC_SIGNALINGMESSAGE,
|
MSG_WEBRTC_SIGNALINGMESSAGE,
|
||||||
|
MSG_WEBRTC_GETREADYSTATE,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AddStreamParams : public talk_base::MessageData {
|
struct AddStreamParams : public talk_base::MessageData {
|
||||||
@ -194,6 +195,13 @@ bool PeerConnectionProxy::SetVideoCapture(const std::string& cam_device) {
|
|||||||
return (Send(MSG_WEBRTC_SETVIDEOCAPTURE, ¶ms) && params.result);
|
return (Send(MSG_WEBRTC_SETVIDEOCAPTURE, ¶ms) && params.result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PeerConnection::ReadyState PeerConnectionProxy::GetReadyState() {
|
||||||
|
PeerConnection::ReadyState ready_state = NEW;
|
||||||
|
Send(MSG_WEBRTC_GETREADYSTATE,
|
||||||
|
reinterpret_cast<talk_base::MessageData*>(&ready_state));
|
||||||
|
return ready_state;
|
||||||
|
}
|
||||||
|
|
||||||
bool PeerConnectionProxy::Connect() {
|
bool PeerConnectionProxy::Connect() {
|
||||||
ResultParams params;
|
ResultParams params;
|
||||||
return (Send(MSG_WEBRTC_CONNECT, ¶ms) && params.result);
|
return (Send(MSG_WEBRTC_CONNECT, ¶ms) && params.result);
|
||||||
@ -254,6 +262,12 @@ void PeerConnectionProxy::OnMessage(talk_base::Message* message) {
|
|||||||
params->cam_device);
|
params->cam_device);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case MSG_WEBRTC_GETREADYSTATE: {
|
||||||
|
PeerConnection::ReadyState* ready_state =
|
||||||
|
reinterpret_cast<PeerConnection::ReadyState*>(data);
|
||||||
|
*ready_state = peerconnection_impl_->GetReadyState();
|
||||||
|
break;
|
||||||
|
}
|
||||||
case MSG_WEBRTC_SETVIDEORENDERER: {
|
case MSG_WEBRTC_SETVIDEORENDERER: {
|
||||||
SetVideoRendererParams* params =
|
SetVideoRendererParams* params =
|
||||||
reinterpret_cast<SetVideoRendererParams*>(data);
|
reinterpret_cast<SetVideoRendererParams*>(data);
|
||||||
|
@ -51,19 +51,20 @@ class PeerConnectionProxy : public PeerConnection,
|
|||||||
talk_base::Thread* signaling_thread);
|
talk_base::Thread* signaling_thread);
|
||||||
virtual ~PeerConnectionProxy();
|
virtual ~PeerConnectionProxy();
|
||||||
|
|
||||||
// PeerConnection interfaces
|
// PeerConnection interface implementation.
|
||||||
void RegisterObserver(PeerConnectionObserver* observer);
|
virtual void RegisterObserver(PeerConnectionObserver* observer);
|
||||||
bool SignalingMessage(const std::string& msg);
|
virtual bool SignalingMessage(const std::string& msg);
|
||||||
bool AddStream(const std::string& stream_id, bool video);
|
virtual bool AddStream(const std::string& stream_id, bool video);
|
||||||
bool RemoveStream(const std::string& stream_id);
|
virtual bool RemoveStream(const std::string& stream_id);
|
||||||
bool Connect();
|
virtual bool Connect();
|
||||||
bool Close();
|
virtual bool Close();
|
||||||
bool SetAudioDevice(const std::string& wave_in_device,
|
virtual bool SetAudioDevice(const std::string& wave_in_device,
|
||||||
const std::string& wave_out_device, int opts);
|
const std::string& wave_out_device, int opts);
|
||||||
bool SetLocalVideoRenderer(cricket::VideoRenderer* renderer);
|
virtual bool SetLocalVideoRenderer(cricket::VideoRenderer* renderer);
|
||||||
bool SetVideoRenderer(const std::string& stream_id,
|
virtual bool SetVideoRenderer(const std::string& stream_id,
|
||||||
cricket::VideoRenderer* renderer);
|
cricket::VideoRenderer* renderer);
|
||||||
bool SetVideoCapture(const std::string& cam_device);
|
virtual bool SetVideoCapture(const std::string& cam_device);
|
||||||
|
virtual ReadyState GetReadyState();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -93,10 +93,14 @@ WebRtcSession::~WebRtcSession() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool WebRtcSession::Initiate() {
|
bool WebRtcSession::Initiate() {
|
||||||
signaling_thread_->Send(this, MSG_WEBRTC_CREATE_TRANSPORT, NULL);
|
if (signaling_thread_ == NULL)
|
||||||
if (transport_ == NULL) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
signaling_thread_->Send(this, MSG_WEBRTC_CREATE_TRANSPORT, NULL);
|
||||||
|
|
||||||
|
if (transport_ == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
transport_->set_allow_local_ips(true);
|
transport_->set_allow_local_ips(true);
|
||||||
|
|
||||||
// start transports
|
// start transports
|
||||||
|
Loading…
x
Reference in New Issue
Block a user