* 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 {
|
||||
public:
|
||||
enum ReadyState {
|
||||
NEW = 0,
|
||||
NEGOTIATING,
|
||||
ACTIVE,
|
||||
CLOSED,
|
||||
};
|
||||
|
||||
virtual ~PeerConnection() {}
|
||||
|
||||
// Register a listener
|
||||
@ -121,6 +128,10 @@ class PeerConnection {
|
||||
// For standalone app, cam_device is the camera name. It will try to
|
||||
// set the default capture device when cam_device is "".
|
||||
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
|
||||
|
@ -54,26 +54,20 @@ class PeerConnectionImpl : public PeerConnection,
|
||||
talk_base::Thread* signaling_thread);
|
||||
virtual ~PeerConnectionImpl();
|
||||
|
||||
enum ReadyState {
|
||||
NEW = 0,
|
||||
NEGOTIATING,
|
||||
ACTIVE,
|
||||
CLOSED,
|
||||
};
|
||||
|
||||
// PeerConnection interfaces
|
||||
void RegisterObserver(PeerConnectionObserver* observer);
|
||||
bool SignalingMessage(const std::string& msg);
|
||||
bool AddStream(const std::string& stream_id, bool video);
|
||||
bool RemoveStream(const std::string& stream_id);
|
||||
bool Connect();
|
||||
bool Close();
|
||||
bool SetAudioDevice(const std::string& wave_in_device,
|
||||
const std::string& wave_out_device, int opts);
|
||||
bool SetLocalVideoRenderer(cricket::VideoRenderer* renderer);
|
||||
bool SetVideoRenderer(const std::string& stream_id,
|
||||
cricket::VideoRenderer* renderer);
|
||||
bool SetVideoCapture(const std::string& cam_device);
|
||||
virtual void RegisterObserver(PeerConnectionObserver* observer);
|
||||
virtual bool SignalingMessage(const std::string& msg);
|
||||
virtual bool AddStream(const std::string& stream_id, bool video);
|
||||
virtual bool RemoveStream(const std::string& stream_id);
|
||||
virtual bool Connect();
|
||||
virtual bool Close();
|
||||
virtual bool SetAudioDevice(const std::string& wave_in_device,
|
||||
const std::string& wave_out_device, int opts);
|
||||
virtual bool SetLocalVideoRenderer(cricket::VideoRenderer* renderer);
|
||||
virtual bool SetVideoRenderer(const std::string& stream_id,
|
||||
cricket::VideoRenderer* renderer);
|
||||
virtual bool SetVideoCapture(const std::string& cam_device);
|
||||
virtual ReadyState GetReadyState();
|
||||
|
||||
cricket::ChannelManager* channel_manager() {
|
||||
return channel_manager_;
|
||||
@ -91,7 +85,6 @@ class PeerConnectionImpl : public PeerConnection,
|
||||
bool Init();
|
||||
|
||||
private:
|
||||
ReadyState GetReadyState();
|
||||
bool ParseConfigString(const std::string& config,
|
||||
talk_base::SocketAddress* stun_addr);
|
||||
void SendRemoveSignal(WebRtcSession* session);
|
||||
|
@ -45,6 +45,7 @@ enum {
|
||||
MSG_WEBRTC_SETVIDEOCAPTURE,
|
||||
MSG_WEBRTC_SETVIDEORENDERER,
|
||||
MSG_WEBRTC_SIGNALINGMESSAGE,
|
||||
MSG_WEBRTC_GETREADYSTATE,
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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() {
|
||||
ResultParams params;
|
||||
return (Send(MSG_WEBRTC_CONNECT, ¶ms) && params.result);
|
||||
@ -254,6 +262,12 @@ void PeerConnectionProxy::OnMessage(talk_base::Message* message) {
|
||||
params->cam_device);
|
||||
break;
|
||||
}
|
||||
case MSG_WEBRTC_GETREADYSTATE: {
|
||||
PeerConnection::ReadyState* ready_state =
|
||||
reinterpret_cast<PeerConnection::ReadyState*>(data);
|
||||
*ready_state = peerconnection_impl_->GetReadyState();
|
||||
break;
|
||||
}
|
||||
case MSG_WEBRTC_SETVIDEORENDERER: {
|
||||
SetVideoRendererParams* params =
|
||||
reinterpret_cast<SetVideoRendererParams*>(data);
|
||||
|
@ -51,19 +51,20 @@ class PeerConnectionProxy : public PeerConnection,
|
||||
talk_base::Thread* signaling_thread);
|
||||
virtual ~PeerConnectionProxy();
|
||||
|
||||
// PeerConnection interfaces
|
||||
void RegisterObserver(PeerConnectionObserver* observer);
|
||||
bool SignalingMessage(const std::string& msg);
|
||||
bool AddStream(const std::string& stream_id, bool video);
|
||||
bool RemoveStream(const std::string& stream_id);
|
||||
bool Connect();
|
||||
bool Close();
|
||||
bool SetAudioDevice(const std::string& wave_in_device,
|
||||
const std::string& wave_out_device, int opts);
|
||||
bool SetLocalVideoRenderer(cricket::VideoRenderer* renderer);
|
||||
bool SetVideoRenderer(const std::string& stream_id,
|
||||
cricket::VideoRenderer* renderer);
|
||||
bool SetVideoCapture(const std::string& cam_device);
|
||||
// PeerConnection interface implementation.
|
||||
virtual void RegisterObserver(PeerConnectionObserver* observer);
|
||||
virtual bool SignalingMessage(const std::string& msg);
|
||||
virtual bool AddStream(const std::string& stream_id, bool video);
|
||||
virtual bool RemoveStream(const std::string& stream_id);
|
||||
virtual bool Connect();
|
||||
virtual bool Close();
|
||||
virtual bool SetAudioDevice(const std::string& wave_in_device,
|
||||
const std::string& wave_out_device, int opts);
|
||||
virtual bool SetLocalVideoRenderer(cricket::VideoRenderer* renderer);
|
||||
virtual bool SetVideoRenderer(const std::string& stream_id,
|
||||
cricket::VideoRenderer* renderer);
|
||||
virtual bool SetVideoCapture(const std::string& cam_device);
|
||||
virtual ReadyState GetReadyState();
|
||||
|
||||
private:
|
||||
|
||||
|
@ -93,10 +93,14 @@ WebRtcSession::~WebRtcSession() {
|
||||
}
|
||||
|
||||
bool WebRtcSession::Initiate() {
|
||||
signaling_thread_->Send(this, MSG_WEBRTC_CREATE_TRANSPORT, NULL);
|
||||
if (transport_ == NULL) {
|
||||
if (signaling_thread_ == NULL)
|
||||
return false;
|
||||
}
|
||||
|
||||
signaling_thread_->Send(this, MSG_WEBRTC_CREATE_TRANSPORT, NULL);
|
||||
|
||||
if (transport_ == NULL)
|
||||
return false;
|
||||
|
||||
transport_->set_allow_local_ips(true);
|
||||
|
||||
// start transports
|
||||
|
Loading…
Reference in New Issue
Block a user