Notifier and RefCount interface and implementation class name changed according to the naming convention.

Review URL: http://webrtc-codereview.appspot.com/241003

git-svn-id: http://webrtc.googlecode.com/svn/trunk@781 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
mallinath@webrtc.org
2011-10-20 06:24:24 +00:00
parent ae499a2ac8
commit f553ec70c7
35 changed files with 469 additions and 375 deletions

View File

@ -53,18 +53,19 @@ const char* AudioTrack::kind() const {
return kAudioTrackKind; return kAudioTrackKind;
} }
scoped_refptr<AudioTrack> AudioTrack::CreateRemote(const std::string& label, talk_base::scoped_refptr<AudioTrack> AudioTrack::CreateRemote(
const std::string& label,
uint32 ssrc) { uint32 ssrc) {
talk_base::RefCountImpl<AudioTrack>* track = talk_base::RefCount<AudioTrack>* track =
new talk_base::RefCountImpl<AudioTrack>(label, ssrc); new talk_base::RefCount<AudioTrack>(label, ssrc);
return track; return track;
} }
scoped_refptr<AudioTrack> AudioTrack::CreateLocal( talk_base::scoped_refptr<AudioTrack> AudioTrack::CreateLocal(
const std::string& label, const std::string& label,
AudioDeviceModule* audio_device) { AudioDeviceModule* audio_device) {
talk_base::RefCountImpl<AudioTrack>* track = talk_base::RefCount<AudioTrack>* track =
new talk_base::RefCountImpl<AudioTrack>(label, audio_device); new talk_base::RefCount<AudioTrack>(label, audio_device);
return track; return track;
} }

View File

@ -44,10 +44,12 @@ namespace webrtc {
class AudioTrack : public MediaTrack<LocalAudioTrackInterface> { class AudioTrack : public MediaTrack<LocalAudioTrackInterface> {
public: public:
// Creates a remote audio track. // Creates a remote audio track.
static scoped_refptr<AudioTrack> CreateRemote(const std::string& label, static talk_base::scoped_refptr<AudioTrack> CreateRemote(
const std::string& label,
uint32 ssrc); uint32 ssrc);
// Creates a local audio track. // Creates a local audio track.
static scoped_refptr<AudioTrack> CreateLocal(const std::string& label, static talk_base::scoped_refptr<AudioTrack> CreateLocal(
const std::string& label,
AudioDeviceModule* audio_device); AudioDeviceModule* audio_device);
// Get the AudioDeviceModule associated with this track. // Get the AudioDeviceModule associated with this track.
@ -61,7 +63,7 @@ class AudioTrack : public MediaTrack<LocalAudioTrackInterface> {
AudioTrack(const std::string& label, AudioDeviceModule* audio_device); AudioTrack(const std::string& label, AudioDeviceModule* audio_device);
private: private:
scoped_refptr<AudioDeviceModule> audio_device_; talk_base::scoped_refptr<AudioDeviceModule> audio_device_;
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -25,6 +25,12 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
// This file contains interfaces for MediaStream and MediaTrack. These
// interfaces are used for implementing MediaStream and MediaTrack as defined
// in http://dev.w3.org/2011/webrtc/editor/webrtc.html#stream-api. These
// interfaces must be used only with PeerConnection. PeerConnectionManager
// interface provides the factory methods to create MediaStream and MediaTracks.
#ifndef TALK_APP_WEBRTC_MEDIASTREAM_H_ #ifndef TALK_APP_WEBRTC_MEDIASTREAM_H_
#define TALK_APP_WEBRTC_MEDIASTREAM_H_ #define TALK_APP_WEBRTC_MEDIASTREAM_H_
@ -45,25 +51,25 @@ class AudioDeviceModule;
class VideoCaptureModule; class VideoCaptureModule;
// Generic observer interface. // Generic observer interface.
class Observer { class ObserverInterface {
public: public:
virtual void OnChanged() = 0; virtual void OnChanged() = 0;
protected: protected:
virtual ~Observer() {} virtual ~ObserverInterface() {}
}; };
class Notifier { class NotifierInterface {
public: public:
virtual void RegisterObserver(Observer* observer) = 0; virtual void RegisterObserver(ObserverInterface* observer) = 0;
virtual void UnregisterObserver(Observer* observer) = 0; virtual void UnregisterObserver(ObserverInterface* observer) = 0;
virtual ~Notifier() {} virtual ~NotifierInterface() {}
}; };
// Information about a track. // Information about a track.
class MediaStreamTrackInterface : public talk_base::RefCount, class MediaStreamTrackInterface : public talk_base::RefCountInterface,
public Notifier { public NotifierInterface {
public: public:
enum TrackState { enum TrackState {
kInitializing, // Track is beeing negotiated. kInitializing, // Track is beeing negotiated.
@ -78,13 +84,13 @@ class MediaStreamTrackInterface : public talk_base::RefCount,
virtual bool enabled() const = 0; virtual bool enabled() const = 0;
virtual TrackState state() const = 0; virtual TrackState state() const = 0;
virtual bool set_enabled(bool enable) = 0; virtual bool set_enabled(bool enable) = 0;
// Return false (or assert) if the ssrc is already set. // These methods should be called by implementation only.
virtual bool set_ssrc(uint32 ssrc) = 0; virtual bool set_ssrc(uint32 ssrc) = 0;
virtual bool set_state(TrackState new_state) = 0; virtual bool set_state(TrackState new_state) = 0;
}; };
// Reference counted wrapper for a VideoRenderer. // Reference counted wrapper for a VideoRenderer.
class VideoRendererWrapperInterface : public talk_base::RefCount { class VideoRendererWrapperInterface : public talk_base::RefCountInterface {
public: public:
virtual cricket::VideoRenderer* renderer() = 0; virtual cricket::VideoRenderer* renderer() = 0;
@ -92,10 +98,10 @@ class VideoRendererWrapperInterface : public talk_base::RefCount {
virtual ~VideoRendererWrapperInterface() {} virtual ~VideoRendererWrapperInterface() {}
}; };
// Creates a reference counted object of type webrtc::VideoRenderer. // Creates a reference counted object of type cricket::VideoRenderer.
// webrtc::VideoRendererWrapperInterface take ownership of // webrtc::VideoRendererWrapperInterface take ownership of
// cricket::VideoRenderer. // cricket::VideoRenderer.
scoped_refptr<VideoRendererWrapperInterface> CreateVideoRenderer( talk_base::scoped_refptr<VideoRendererWrapperInterface> CreateVideoRenderer(
cricket::VideoRenderer* renderer); cricket::VideoRenderer* renderer);
class VideoTrackInterface : public MediaStreamTrackInterface { class VideoTrackInterface : public MediaStreamTrackInterface {
@ -140,7 +146,7 @@ class LocalAudioTrackInterface : public AudioTrackInterface {
// List of of tracks. // List of of tracks.
template <class TrackType> template <class TrackType>
class MediaStreamTrackListInterface : public talk_base::RefCount { class MediaStreamTrackListInterface : public talk_base::RefCountInterface {
public: public:
virtual size_t count() = 0; virtual size_t count() = 0;
virtual TrackType* at(size_t index) = 0; virtual TrackType* at(size_t index) = 0;
@ -152,8 +158,8 @@ class MediaStreamTrackListInterface : public talk_base::RefCount {
typedef MediaStreamTrackListInterface<AudioTrackInterface> AudioTracks; typedef MediaStreamTrackListInterface<AudioTrackInterface> AudioTracks;
typedef MediaStreamTrackListInterface<VideoTrackInterface> VideoTracks; typedef MediaStreamTrackListInterface<VideoTrackInterface> VideoTracks;
class MediaStreamInterface : public talk_base::RefCount, class MediaStreamInterface : public talk_base::RefCountInterface,
public Notifier { public NotifierInterface {
public: public:
virtual std::string label() const = 0; virtual std::string label() const = 0;
virtual AudioTracks* audio_tracks() = 0; virtual AudioTracks* audio_tracks() = 0;
@ -167,7 +173,7 @@ class MediaStreamInterface : public talk_base::RefCount,
virtual ReadyState ready_state() = 0; virtual ReadyState ready_state() = 0;
// Only to be used by the implementation. // These methods should be called by implementation only.
virtual void set_ready_state(ReadyState state) = 0; virtual void set_ready_state(ReadyState state) = 0;
protected: protected:

View File

@ -45,7 +45,7 @@ namespace webrtc {
// VideoTrackHandler listen to events on a VideoTrack instance and // VideoTrackHandler listen to events on a VideoTrack instance and
// executes the requested change. // executes the requested change.
class VideoTrackHandler : public Observer { class VideoTrackHandler : public ObserverInterface {
public: public:
VideoTrackHandler(VideoTrackInterface* track, VideoTrackHandler(VideoTrackInterface* track,
MediaProviderInterface* provider); MediaProviderInterface* provider);
@ -63,7 +63,7 @@ class VideoTrackHandler : public Observer {
private: private:
MediaStreamTrackInterface::TrackState state_; MediaStreamTrackInterface::TrackState state_;
bool enabled_; bool enabled_;
scoped_refptr<VideoRendererWrapperInterface> renderer_; talk_base::scoped_refptr<VideoRendererWrapperInterface> renderer_;
}; };
class LocalVideoTrackHandler : public VideoTrackHandler { class LocalVideoTrackHandler : public VideoTrackHandler {
@ -78,7 +78,7 @@ class LocalVideoTrackHandler : public VideoTrackHandler {
virtual void OnEnabledChanged(); virtual void OnEnabledChanged();
private: private:
scoped_refptr<LocalVideoTrackInterface> local_video_track_; talk_base::scoped_refptr<LocalVideoTrackInterface> local_video_track_;
}; };
class RemoteVideoTrackHandler : public VideoTrackHandler { class RemoteVideoTrackHandler : public VideoTrackHandler {
@ -93,10 +93,10 @@ class RemoteVideoTrackHandler : public VideoTrackHandler {
virtual void OnEnabledChanged(); virtual void OnEnabledChanged();
private: private:
scoped_refptr<VideoTrackInterface> remote_video_track_; talk_base::scoped_refptr<VideoTrackInterface> remote_video_track_;
}; };
class MediaStreamHandler : public Observer { class MediaStreamHandler : public ObserverInterface {
public: public:
MediaStreamHandler(MediaStreamInterface* stream, MediaStreamHandler(MediaStreamInterface* stream,
MediaProviderInterface* provider); MediaProviderInterface* provider);
@ -108,7 +108,7 @@ class MediaStreamHandler : public Observer {
MediaProviderInterface* provider_; MediaProviderInterface* provider_;
typedef std::vector<VideoTrackHandler*> VideoTrackHandlers; typedef std::vector<VideoTrackHandler*> VideoTrackHandlers;
VideoTrackHandlers video_handlers_; VideoTrackHandlers video_handlers_;
scoped_refptr<MediaStreamInterface> stream_; talk_base::scoped_refptr<MediaStreamInterface> stream_;
}; };
class LocalMediaStreamHandler : public MediaStreamHandler { class LocalMediaStreamHandler : public MediaStreamHandler {
@ -129,7 +129,7 @@ class MediaStreamHandlers {
~MediaStreamHandlers(); ~MediaStreamHandlers();
void AddRemoteStream(MediaStreamInterface* stream); void AddRemoteStream(MediaStreamInterface* stream);
void RemoveRemoteStream(MediaStreamInterface* stream); void RemoveRemoteStream(MediaStreamInterface* stream);
void CommitLocalStreams(StreamCollection* streams); void CommitLocalStreams(StreamCollectionInterface* streams);
private: private:
typedef std::list<MediaStreamHandler*> StreamHandlerList; typedef std::list<MediaStreamHandler*> StreamHandlerList;

View File

@ -68,25 +68,26 @@ class MockMediaProvier : public MediaProviderInterface {
TEST(MediaStreamHandlerTest, LocalStreams) { TEST(MediaStreamHandlerTest, LocalStreams) {
// Create a local stream. // Create a local stream.
std::string label(kStreamLabel1); std::string label(kStreamLabel1);
scoped_refptr<LocalMediaStreamInterface> stream( talk_base::scoped_refptr<LocalMediaStreamInterface> stream(
MediaStream::Create(label)); MediaStream::Create(label));
scoped_refptr<LocalVideoTrackInterface> video_track(VideoTrack::CreateLocal( talk_base::scoped_refptr<LocalVideoTrackInterface>
kVideoDeviceName, NULL)); video_track(VideoTrack::CreateLocal(kVideoDeviceName, NULL));
video_track->set_ssrc(kVideoSsrc); video_track->set_ssrc(kVideoSsrc);
EXPECT_TRUE(stream->AddTrack(video_track)); EXPECT_TRUE(stream->AddTrack(video_track));
scoped_refptr<VideoRendererWrapperInterface> renderer( talk_base::scoped_refptr<VideoRendererWrapperInterface> renderer(
CreateVideoRenderer(NULL)); CreateVideoRenderer(NULL));
video_track->SetRenderer(renderer); video_track->SetRenderer(renderer);
MockMediaProvier provider; MockMediaProvier provider;
MediaStreamHandlers handlers(&provider); MediaStreamHandlers handlers(&provider);
scoped_refptr<StreamCollectionImpl> collection( talk_base::scoped_refptr<StreamCollectionImpl> collection(
StreamCollectionImpl::Create()); StreamCollectionImpl::Create());
collection->AddStream(stream); collection->AddStream(stream);
EXPECT_CALL(provider, SetLocalRenderer(kVideoSsrc)) EXPECT_CALL(provider, SetLocalRenderer(kVideoSsrc))
.Times(Exactly(1)); .Times(Exactly(2)); // SetLocalRender will also be called from dtor of
// LocalVideoTrackHandler
EXPECT_CALL(provider, SetCaptureDevice(kVideoSsrc)) EXPECT_CALL(provider, SetCaptureDevice(kVideoSsrc))
.Times(Exactly(1)); .Times(Exactly(1));
handlers.CommitLocalStreams(collection); handlers.CommitLocalStreams(collection);
@ -108,10 +109,10 @@ TEST(MediaStreamHandlerTest, RemoteStreams) {
// they are easier to create. // they are easier to create.
// LocalMediaStreams inherit from MediaStreams. // LocalMediaStreams inherit from MediaStreams.
std::string label(kStreamLabel1); std::string label(kStreamLabel1);
scoped_refptr<LocalMediaStreamInterface> stream( talk_base::scoped_refptr<LocalMediaStreamInterface> stream(
MediaStream::Create(label)); MediaStream::Create(label));
scoped_refptr<LocalVideoTrackInterface> video_track(VideoTrack::CreateLocal( talk_base::scoped_refptr<LocalVideoTrackInterface>
kVideoDeviceName, NULL)); video_track(VideoTrack::CreateLocal(kVideoDeviceName, NULL));
video_track->set_ssrc(kVideoSsrc); video_track->set_ssrc(kVideoSsrc);
EXPECT_TRUE(stream->AddTrack(video_track)); EXPECT_TRUE(stream->AddTrack(video_track));
@ -121,10 +122,11 @@ TEST(MediaStreamHandlerTest, RemoteStreams) {
handlers.AddRemoteStream(stream); handlers.AddRemoteStream(stream);
EXPECT_CALL(provider, SetRemoteRenderer(kVideoSsrc)) EXPECT_CALL(provider, SetRemoteRenderer(kVideoSsrc))
.Times(Exactly(2)); .Times(Exactly(3)); // SetRemoteRenderer is also called from dtor of
// RemoteVideoTrackHandler.
// Set the renderer once. // Set the renderer once.
scoped_refptr<VideoRendererWrapperInterface> renderer( talk_base::scoped_refptr<VideoRendererWrapperInterface> renderer(
CreateVideoRenderer(NULL)); CreateVideoRenderer(NULL));
video_track->SetRenderer(renderer); video_track->SetRenderer(renderer);
talk_base::Thread::Current()->ProcessMessages(1); talk_base::Thread::Current()->ProcessMessages(1);

View File

@ -30,15 +30,10 @@
namespace webrtc { namespace webrtc {
scoped_refptr<LocalMediaStreamInterface> CreateLocalMediaStream( talk_base::scoped_refptr<MediaStream> MediaStream::Create(
const std::string& label) { const std::string& label) {
return MediaStream::Create(label); talk_base::RefCount<MediaStream>* stream =
} new talk_base::RefCount<MediaStream>(label);
scoped_refptr<MediaStream> MediaStream::Create(
const std::string& label) {
talk_base::RefCountImpl<MediaStream>* stream =
new talk_base::RefCountImpl<MediaStream>(label);
return stream; return stream;
} }
@ -46,10 +41,10 @@ MediaStream::MediaStream(const std::string& label)
: label_(label), : label_(label),
ready_state_(MediaStreamInterface::kInitializing), ready_state_(MediaStreamInterface::kInitializing),
audio_track_list_( audio_track_list_(
new talk_base::RefCountImpl< new talk_base::RefCount<
MediaStreamTrackList<AudioTrackInterface> >()), MediaStreamTrackList<AudioTrackInterface> >()),
video_track_list_( video_track_list_(
new talk_base::RefCountImpl< new talk_base::RefCount<
MediaStreamTrackList<VideoTrackInterface> >()) { MediaStreamTrackList<VideoTrackInterface> >()) {
} }
@ -57,7 +52,7 @@ void MediaStream::set_ready_state(
MediaStreamInterface::ReadyState new_state) { MediaStreamInterface::ReadyState new_state) {
if (ready_state_ != new_state) { if (ready_state_ != new_state) {
ready_state_ = new_state; ready_state_ = new_state;
NotifierImpl<LocalMediaStreamInterface>::FireOnChanged(); Notifier<LocalMediaStreamInterface>::FireOnChanged();
} }
} }

View File

@ -25,6 +25,8 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
// This file contains the implementation of MediaStreamInterface interface.
#ifndef TALK_APP_WEBRTC_MEDIASTREAMIMPL_H_ #ifndef TALK_APP_WEBRTC_MEDIASTREAMIMPL_H_
#define TALK_APP_WEBRTC_MEDIASTREAMIMPL_H_ #define TALK_APP_WEBRTC_MEDIASTREAMIMPL_H_
@ -38,12 +40,10 @@ namespace webrtc {
class AudioTrack; class AudioTrack;
class VideoTrack; class VideoTrack;
class MediaStream class MediaStream : public Notifier<LocalMediaStreamInterface> {
: public NotifierImpl<LocalMediaStreamInterface> {
public: public:
template<class T> template<class T>
class MediaStreamTrackList : class MediaStreamTrackList : public MediaStreamTrackListInterface<T> {
public MediaStreamTrackListInterface<T> {
public: public:
void AddTrack(T* track) { void AddTrack(T* track) {
tracks_.push_back(track); tracks_.push_back(track);
@ -54,10 +54,10 @@ class MediaStream
} }
private: private:
std::vector<scoped_refptr<T> > tracks_; std::vector<talk_base::scoped_refptr<T> > tracks_;
}; };
static scoped_refptr<MediaStream> Create(const std::string& label); static talk_base::scoped_refptr<MediaStream> Create(const std::string& label);
// Implement LocalMediaStreamInterface. // Implement LocalMediaStreamInterface.
virtual bool AddTrack(AudioTrackInterface* track); virtual bool AddTrack(AudioTrackInterface* track);
@ -79,9 +79,9 @@ class MediaStream
std::string label_; std::string label_;
MediaStreamInterface::ReadyState ready_state_; MediaStreamInterface::ReadyState ready_state_;
scoped_refptr<MediaStreamTrackList<AudioTrackInterface> > talk_base::scoped_refptr<MediaStreamTrackList<AudioTrackInterface> >
audio_track_list_; audio_track_list_;
scoped_refptr<MediaStreamTrackList<VideoTrackInterface> > talk_base::scoped_refptr<MediaStreamTrackList<VideoTrackInterface> >
video_track_list_; video_track_list_;
}; };

View File

@ -37,7 +37,7 @@ static const char kVideoDeviceName[] = "dummy_video_cam_1";
namespace webrtc { namespace webrtc {
// Helper class to test the Observer. // Helper class to test the Observer.
class TestObserver : public Observer { class TestObserver : public ObserverInterface {
public: public:
TestObserver() : changed_(0) {} TestObserver() : changed_(0) {}
void OnChanged() { void OnChanged() {
@ -57,7 +57,7 @@ class TestObserver : public Observer {
TEST(LocalStreamTest, Create) { TEST(LocalStreamTest, Create) {
// Create a local stream. // Create a local stream.
std::string label(kStreamLabel1); std::string label(kStreamLabel1);
scoped_refptr<LocalMediaStreamInterface> stream( talk_base::scoped_refptr<LocalMediaStreamInterface> stream(
MediaStream::Create(label)); MediaStream::Create(label));
EXPECT_EQ(label, stream->label()); EXPECT_EQ(label, stream->label());
@ -66,17 +66,17 @@ TEST(LocalStreamTest, Create) {
// Create a local Video track. // Create a local Video track.
TestObserver tracklist_observer; TestObserver tracklist_observer;
scoped_refptr<LocalVideoTrackInterface> video_track(VideoTrack::CreateLocal( talk_base::scoped_refptr<LocalVideoTrackInterface>
kVideoDeviceName, NULL)); video_track(VideoTrack::CreateLocal(kVideoDeviceName, NULL));
// Add an observer to the track list. // Add an observer to the track list.
scoped_refptr<MediaStreamTrackListInterface<VideoTrackInterface> > track_list( talk_base::scoped_refptr<MediaStreamTrackListInterface<VideoTrackInterface> >
stream->video_tracks()); track_list(stream->video_tracks());
// Add the track to the local stream. // Add the track to the local stream.
EXPECT_TRUE(stream->AddTrack(video_track)); EXPECT_TRUE(stream->AddTrack(video_track));
EXPECT_EQ(1u, stream->video_tracks()->count()); EXPECT_EQ(1u, stream->video_tracks()->count());
// Verify the track. // Verify the track.
scoped_refptr<webrtc::MediaStreamTrackInterface> track( talk_base::scoped_refptr<webrtc::MediaStreamTrackInterface> track(
stream->video_tracks()->at(0)); stream->video_tracks()->at(0));
EXPECT_EQ(0, track->label().compare(kVideoDeviceName)); EXPECT_EQ(0, track->label().compare(kVideoDeviceName));
EXPECT_TRUE(track->enabled()); EXPECT_TRUE(track->enabled());

View File

@ -45,7 +45,8 @@ enum {
typedef talk_base::TypedMessageData<std::string*> LabelMessageData; typedef talk_base::TypedMessageData<std::string*> LabelMessageData;
typedef talk_base::TypedMessageData<size_t> SizeTMessageData; typedef talk_base::TypedMessageData<size_t> SizeTMessageData;
typedef talk_base::TypedMessageData<webrtc::Observer*> ObserverMessageData; typedef talk_base::TypedMessageData<webrtc::ObserverInterface*>
ObserverMessageData;
typedef talk_base::TypedMessageData<webrtc::MediaStreamInterface::ReadyState> typedef talk_base::TypedMessageData<webrtc::MediaStreamInterface::ReadyState>
ReadyStateMessageData; ReadyStateMessageData;
@ -57,7 +58,7 @@ class MediaStreamTrackMessageData : public talk_base::MessageData {
result_(false) { result_(false) {
} }
scoped_refptr<T> track_; talk_base::scoped_refptr<T> track_;
bool result_; bool result_;
}; };
@ -74,19 +75,19 @@ class MediaStreamTrackAtMessageData : public talk_base::MessageData {
} }
size_t index_; size_t index_;
scoped_refptr<TrackType> track_; talk_base::scoped_refptr<TrackType> track_;
}; };
} // namespace anonymous } // namespace anonymous
namespace webrtc { namespace webrtc {
scoped_refptr<MediaStreamProxy> MediaStreamProxy::Create( talk_base::scoped_refptr<MediaStreamProxy> MediaStreamProxy::Create(
const std::string& label, const std::string& label,
talk_base::Thread* signaling_thread) { talk_base::Thread* signaling_thread) {
ASSERT(signaling_thread); ASSERT(signaling_thread);
talk_base::RefCountImpl<MediaStreamProxy>* stream = talk_base::RefCount<MediaStreamProxy>* stream =
new talk_base::RefCountImpl<MediaStreamProxy>(label, signaling_thread); new talk_base::RefCount<MediaStreamProxy>(label, signaling_thread);
return stream; return stream;
} }
@ -94,11 +95,11 @@ MediaStreamProxy::MediaStreamProxy(const std::string& label,
talk_base::Thread* signaling_thread) talk_base::Thread* signaling_thread)
: signaling_thread_(signaling_thread), : signaling_thread_(signaling_thread),
media_stream_impl_(MediaStream::Create(label)), media_stream_impl_(MediaStream::Create(label)),
audio_tracks_(new talk_base::RefCountImpl< audio_tracks_(new talk_base::RefCount<
MediaStreamTrackListProxy<AudioTrackInterface> >( MediaStreamTrackListProxy<AudioTrackInterface> >(
media_stream_impl_->audio_tracks(), media_stream_impl_->audio_tracks(),
signaling_thread_)), signaling_thread_)),
video_tracks_(new talk_base::RefCountImpl< video_tracks_(new talk_base::RefCount<
MediaStreamTrackListProxy<VideoTrackInterface> >( MediaStreamTrackListProxy<VideoTrackInterface> >(
media_stream_impl_->video_tracks(), media_stream_impl_->video_tracks(),
signaling_thread_)) { signaling_thread_)) {
@ -151,7 +152,7 @@ bool MediaStreamProxy::AddTrack(VideoTrackInterface* track) {
return media_stream_impl_->AddTrack(track); return media_stream_impl_->AddTrack(track);
} }
void MediaStreamProxy::RegisterObserver(Observer* observer) { void MediaStreamProxy::RegisterObserver(ObserverInterface* observer) {
if (!signaling_thread_->IsCurrent()) { if (!signaling_thread_->IsCurrent()) {
ObserverMessageData msg(observer); ObserverMessageData msg(observer);
Send(MSG_REGISTER_OBSERVER, &msg); Send(MSG_REGISTER_OBSERVER, &msg);
@ -160,7 +161,7 @@ void MediaStreamProxy::RegisterObserver(Observer* observer) {
media_stream_impl_->RegisterObserver(observer); media_stream_impl_->RegisterObserver(observer);
} }
void MediaStreamProxy::UnregisterObserver(Observer* observer) { void MediaStreamProxy::UnregisterObserver(ObserverInterface* observer) {
if (!signaling_thread_->IsCurrent()) { if (!signaling_thread_->IsCurrent()) {
ObserverMessageData msg(observer); ObserverMessageData msg(observer);
Send(MSG_UNREGISTER_OBSERVER, &msg); Send(MSG_UNREGISTER_OBSERVER, &msg);

View File

@ -55,11 +55,11 @@ class MediaStreamProxy : public LocalMediaStreamInterface,
void Send(uint32 id, talk_base::MessageData* data) const; void Send(uint32 id, talk_base::MessageData* data) const;
void OnMessage(talk_base::Message* msg); void OnMessage(talk_base::Message* msg);
scoped_refptr<MediaStreamTrackListInterface<T> > track_list_; talk_base::scoped_refptr<MediaStreamTrackListInterface<T> > track_list_;
mutable talk_base::Thread* signaling_thread_; mutable talk_base::Thread* signaling_thread_;
}; };
static scoped_refptr<MediaStreamProxy> Create( static talk_base::scoped_refptr<MediaStreamProxy> Create(
const std::string& label, const std::string& label,
talk_base::Thread* signaling_thread); talk_base::Thread* signaling_thread);
@ -72,18 +72,18 @@ class MediaStreamProxy : public LocalMediaStreamInterface,
// Implement MediaStream. // Implement MediaStream.
virtual std::string label() const; virtual std::string label() const;
virtual MediaStreamTrackListProxy<AudioTrackInterface>* audio_tracks() { virtual AudioTracks* audio_tracks() {
return audio_tracks_; return audio_tracks_;
} }
virtual MediaStreamTrackListProxy<VideoTrackInterface>* video_tracks() { virtual VideoTracks* video_tracks() {
return video_tracks_; return video_tracks_;
} }
virtual ReadyState ready_state(); virtual ReadyState ready_state();
virtual void set_ready_state(ReadyState new_state); virtual void set_ready_state(ReadyState new_state);
// Implement Notifier // Implement Notifier
virtual void RegisterObserver(Observer* observer); virtual void RegisterObserver(ObserverInterface* observer);
virtual void UnregisterObserver(Observer* observer); virtual void UnregisterObserver(ObserverInterface* observer);
protected: protected:
explicit MediaStreamProxy(const std::string& label, explicit MediaStreamProxy(const std::string& label,
@ -94,9 +94,9 @@ class MediaStreamProxy : public LocalMediaStreamInterface,
virtual void OnMessage(talk_base::Message* msg); virtual void OnMessage(talk_base::Message* msg);
mutable talk_base::Thread* signaling_thread_; mutable talk_base::Thread* signaling_thread_;
scoped_refptr<MediaStream> media_stream_impl_; talk_base::scoped_refptr<MediaStream> media_stream_impl_;
scoped_refptr<MediaStreamTrackListProxy<AudioTrackInterface> > audio_tracks_; talk_base::scoped_refptr<AudioTracks> audio_tracks_;
scoped_refptr<MediaStreamTrackListProxy<VideoTrackInterface> > video_tracks_; talk_base::scoped_refptr<VideoTracks> video_tracks_;
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -45,7 +45,8 @@ enum {
}; };
typedef talk_base::TypedMessageData<std::string*> LabelMessageData; typedef talk_base::TypedMessageData<std::string*> LabelMessageData;
typedef talk_base::TypedMessageData<webrtc::Observer*> ObserverMessageData; typedef talk_base::TypedMessageData<webrtc::ObserverInterface*>
ObserverMessageData;
typedef talk_base::TypedMessageData typedef talk_base::TypedMessageData
<webrtc::MediaStreamTrackInterface::TrackState> TrackStateMessageData; <webrtc::MediaStreamTrackInterface::TrackState> TrackStateMessageData;
typedef talk_base::TypedMessageData<uint32> SsrcMessageData; typedef talk_base::TypedMessageData<uint32> SsrcMessageData;
@ -54,17 +55,18 @@ typedef talk_base::TypedMessageData<bool> EnableMessageData;
class AudioDeviceMessageData : public talk_base::MessageData { class AudioDeviceMessageData : public talk_base::MessageData {
public: public:
scoped_refptr<webrtc::AudioDeviceModule> audio_device_; talk_base::scoped_refptr<webrtc::AudioDeviceModule> audio_device_;
}; };
class VideoDeviceMessageData : public talk_base::MessageData { class VideoDeviceMessageData : public talk_base::MessageData {
public: public:
scoped_refptr<webrtc::VideoCaptureModule> video_device_; talk_base::scoped_refptr<webrtc::VideoCaptureModule> video_device_;
}; };
class VideoRendererMessageData : public talk_base::MessageData { class VideoRendererMessageData : public talk_base::MessageData {
public: public:
scoped_refptr<webrtc::VideoRendererWrapperInterface> video_renderer_; talk_base::scoped_refptr<webrtc::VideoRendererWrapperInterface>
video_renderer_;
}; };
} // namespace anonymous } // namespace anonymous
@ -160,7 +162,7 @@ bool MediaStreamTrackProxy<T>::set_ssrc(uint32 ssrc) {
} }
template <class T> template <class T>
void MediaStreamTrackProxy<T>::RegisterObserver(Observer* observer) { void MediaStreamTrackProxy<T>::RegisterObserver(ObserverInterface* observer) {
if (!signaling_thread_->IsCurrent()) { if (!signaling_thread_->IsCurrent()) {
ObserverMessageData msg(observer); ObserverMessageData msg(observer);
Send(MSG_REGISTER_OBSERVER, &msg); Send(MSG_REGISTER_OBSERVER, &msg);
@ -170,7 +172,7 @@ void MediaStreamTrackProxy<T>::RegisterObserver(Observer* observer) {
} }
template <class T> template <class T>
void MediaStreamTrackProxy<T>::UnregisterObserver(Observer* observer) { void MediaStreamTrackProxy<T>::UnregisterObserver(ObserverInterface* observer) {
if (!signaling_thread_->IsCurrent()) { if (!signaling_thread_->IsCurrent()) {
ObserverMessageData msg(observer); ObserverMessageData msg(observer);
Send(MSG_UNREGISTER_OBSERVER, &msg); Send(MSG_UNREGISTER_OBSERVER, &msg);
@ -254,24 +256,24 @@ AudioTrackProxy::AudioTrackProxy(
Init(audio_track_); Init(audio_track_);
} }
scoped_refptr<AudioTrackInterface> AudioTrackProxy::CreateRemote( talk_base::scoped_refptr<AudioTrackInterface> AudioTrackProxy::CreateRemote(
const std::string& label, const std::string& label,
uint32 ssrc, uint32 ssrc,
talk_base::Thread* signaling_thread) { talk_base::Thread* signaling_thread) {
ASSERT(signaling_thread); ASSERT(signaling_thread);
talk_base::RefCountImpl<AudioTrackProxy>* track = talk_base::RefCount<AudioTrackProxy>* track =
new talk_base::RefCountImpl<AudioTrackProxy>(label, ssrc, new talk_base::RefCount<AudioTrackProxy>(label, ssrc,
signaling_thread); signaling_thread);
return track; return track;
} }
scoped_refptr<LocalAudioTrackInterface> AudioTrackProxy::CreateLocal( talk_base::scoped_refptr<LocalAudioTrackInterface> AudioTrackProxy::CreateLocal(
const std::string& label, const std::string& label,
AudioDeviceModule* audio_device, AudioDeviceModule* audio_device,
talk_base::Thread* signaling_thread) { talk_base::Thread* signaling_thread) {
ASSERT(signaling_thread); ASSERT(signaling_thread);
talk_base::RefCountImpl<AudioTrackProxy>* track = talk_base::RefCount<AudioTrackProxy>* track =
new talk_base::RefCountImpl<AudioTrackProxy>(label, new talk_base::RefCount<AudioTrackProxy>(label,
audio_device, audio_device,
signaling_thread); signaling_thread);
return track; return track;
@ -316,24 +318,24 @@ VideoTrackProxy::VideoTrackProxy(
Init(video_track_); Init(video_track_);
} }
scoped_refptr<VideoTrackInterface> VideoTrackProxy::CreateRemote( talk_base::scoped_refptr<VideoTrackInterface> VideoTrackProxy::CreateRemote(
const std::string& label, const std::string& label,
uint32 ssrc, uint32 ssrc,
talk_base::Thread* signaling_thread) { talk_base::Thread* signaling_thread) {
ASSERT(signaling_thread); ASSERT(signaling_thread);
talk_base::RefCountImpl<VideoTrackProxy>* track = talk_base::RefCount<VideoTrackProxy>* track =
new talk_base::RefCountImpl<VideoTrackProxy>(label, ssrc, new talk_base::RefCount<VideoTrackProxy>(label, ssrc,
signaling_thread); signaling_thread);
return track; return track;
} }
scoped_refptr<LocalVideoTrackInterface> VideoTrackProxy::CreateLocal( talk_base::scoped_refptr<LocalVideoTrackInterface> VideoTrackProxy::CreateLocal(
const std::string& label, const std::string& label,
VideoCaptureModule* video_device, VideoCaptureModule* video_device,
talk_base::Thread* signaling_thread) { talk_base::Thread* signaling_thread) {
ASSERT(signaling_thread); ASSERT(signaling_thread);
talk_base::RefCountImpl<VideoTrackProxy>* track = talk_base::RefCount<VideoTrackProxy>* track =
new talk_base::RefCountImpl<VideoTrackProxy>(label, video_device, new talk_base::RefCount<VideoTrackProxy>(label, video_device,
signaling_thread); signaling_thread);
return track; return track;
} }

View File

@ -58,8 +58,8 @@ class MediaStreamTrackProxy : public T,
virtual bool set_state(MediaStreamTrackInterface::TrackState new_state); virtual bool set_state(MediaStreamTrackInterface::TrackState new_state);
// Implement Notifier // Implement Notifier
virtual void RegisterObserver(Observer* observer); virtual void RegisterObserver(ObserverInterface* observer);
virtual void UnregisterObserver(Observer* observer); virtual void UnregisterObserver(ObserverInterface* observer);
protected: protected:
explicit MediaStreamTrackProxy(talk_base::Thread* signaling_thread); explicit MediaStreamTrackProxy(talk_base::Thread* signaling_thread);
@ -77,11 +77,11 @@ class MediaStreamTrackProxy : public T,
// It can be used as a proxy for both local and remote audio tracks. // It can be used as a proxy for both local and remote audio tracks.
class AudioTrackProxy : public MediaStreamTrackProxy<LocalAudioTrackInterface> { class AudioTrackProxy : public MediaStreamTrackProxy<LocalAudioTrackInterface> {
public: public:
static scoped_refptr<AudioTrackInterface> CreateRemote( static talk_base::scoped_refptr<AudioTrackInterface> CreateRemote(
const std::string& label, const std::string& label,
uint32 ssrc, uint32 ssrc,
talk_base::Thread* signaling_thread); talk_base::Thread* signaling_thread);
static scoped_refptr<LocalAudioTrackInterface> CreateLocal( static talk_base::scoped_refptr<LocalAudioTrackInterface> CreateLocal(
const std::string& label, const std::string& label,
AudioDeviceModule* audio_device, AudioDeviceModule* audio_device,
talk_base::Thread* signaling_thread); talk_base::Thread* signaling_thread);
@ -98,7 +98,7 @@ class AudioTrackProxy : public MediaStreamTrackProxy<LocalAudioTrackInterface> {
// Implement MessageHandler // Implement MessageHandler
virtual void OnMessage(talk_base::Message* msg); virtual void OnMessage(talk_base::Message* msg);
scoped_refptr<AudioTrack> audio_track_; talk_base::scoped_refptr<AudioTrack> audio_track_;
}; };
// VideoTrackProxy is a proxy for the VideoTrackInterface and // VideoTrackProxy is a proxy for the VideoTrackInterface and
@ -107,11 +107,11 @@ class AudioTrackProxy : public MediaStreamTrackProxy<LocalAudioTrackInterface> {
// It can be used as a proxy for both local and remote video tracks. // It can be used as a proxy for both local and remote video tracks.
class VideoTrackProxy : public MediaStreamTrackProxy<LocalVideoTrackInterface> { class VideoTrackProxy : public MediaStreamTrackProxy<LocalVideoTrackInterface> {
public: public:
static scoped_refptr<VideoTrackInterface> CreateRemote( static talk_base::scoped_refptr<VideoTrackInterface> CreateRemote(
const std::string& label, const std::string& label,
uint32 ssrc, uint32 ssrc,
talk_base::Thread* signaling_thread); talk_base::Thread* signaling_thread);
static scoped_refptr<LocalVideoTrackInterface> CreateLocal( static talk_base::scoped_refptr<LocalVideoTrackInterface> CreateLocal(
const std::string& label, const std::string& label,
VideoCaptureModule* video_device, VideoCaptureModule* video_device,
talk_base::Thread* signaling_thread); talk_base::Thread* signaling_thread);
@ -130,7 +130,7 @@ class VideoTrackProxy : public MediaStreamTrackProxy<LocalVideoTrackInterface> {
// Implement MessageHandler // Implement MessageHandler
virtual void OnMessage(talk_base::Message* msg); virtual void OnMessage(talk_base::Message* msg);
scoped_refptr<VideoTrack> video_track_; talk_base::scoped_refptr<VideoTrack> video_track_;
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -35,8 +35,10 @@
namespace webrtc { namespace webrtc {
// MediaTrack implements the interface common to AudioTrackInterface and
// VideoTrackInterface.
template <typename T> template <typename T>
class MediaTrack : public NotifierImpl<T> { class MediaTrack : public Notifier<T> {
public: public:
typedef typename T::TrackState TypedTrackState; typedef typename T::TrackState TypedTrackState;
@ -48,7 +50,7 @@ class MediaTrack : public NotifierImpl<T> {
bool fire_on_change = (enable != enabled_); bool fire_on_change = (enable != enabled_);
enabled_ = enable; enabled_ = enable;
if (fire_on_change) { if (fire_on_change) {
NotifierImpl<T>::FireOnChanged(); Notifier<T>::FireOnChanged();
} }
} }
@ -58,7 +60,7 @@ class MediaTrack : public NotifierImpl<T> {
if (ssrc_ != 0) if (ssrc_ != 0)
return false; return false;
ssrc_ = ssrc; ssrc_ = ssrc;
NotifierImpl<T>::FireOnChanged(); Notifier<T>::FireOnChanged();
return true; return true;
} }
@ -66,7 +68,7 @@ class MediaTrack : public NotifierImpl<T> {
bool fire_on_change = (state_ != new_state); bool fire_on_change = (state_ != new_state);
state_ = new_state; state_ = new_state;
if (fire_on_change) if (fire_on_change)
NotifierImpl<T>::FireOnChanged(); Notifier<T>::FireOnChanged();
return true; return true;
} }

View File

@ -37,18 +37,18 @@ namespace webrtc {
// Implement a template version of a notifier. // Implement a template version of a notifier.
template <class T> template <class T>
class NotifierImpl : public T { class Notifier : public T {
public: public:
NotifierImpl() { Notifier() {
} }
virtual void RegisterObserver(Observer* observer) { virtual void RegisterObserver(ObserverInterface* observer) {
ASSERT(observer != NULL); ASSERT(observer != NULL);
observers_.push_back(observer); observers_.push_back(observer);
} }
virtual void UnregisterObserver(Observer* observer) { virtual void UnregisterObserver(ObserverInterface* observer) {
for (std::list<Observer*>::iterator it = observers_.begin(); for (std::list<ObserverInterface*>::iterator it = observers_.begin();
it != observers_.end(); it++) { it != observers_.end(); it++) {
if (*it == observer) { if (*it == observer) {
observers_.erase(it); observers_.erase(it);
@ -58,14 +58,14 @@ class NotifierImpl : public T {
} }
void FireOnChanged() { void FireOnChanged() {
for (std::list<Observer*>::iterator it = observers_.begin(); for (std::list<ObserverInterface*>::iterator it = observers_.begin();
it != observers_.end(); ++it) { it != observers_.end(); ++it) {
(*it)-> OnChanged(); (*it)-> OnChanged();
} }
} }
protected: protected:
std::list<Observer*> observers_; std::list<ObserverInterface*> observers_;
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -25,6 +25,47 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
// This file contains the PeerConnection interface as defined in
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#peer-to-peer-connections.
// Applications must use this interface to implement peerconnection.
// PeerConnectionFactory class provides factory methods to create
// peerconnection, mediastream and media tracks objects.
//
// The Following steps are needed to setup a typical call.
// 1. Create a PeerConnectionManager. Check constructors for more information
// about input parameters.
// 2. Create a PeerConnection object. Provide a configuration string which
// points either to stun or turn server to generate ICE candidates and provide
// an object that implements the PeerConnectionObserver interface.
// Now PeerConnection will startcollecting ICE candidates.
// 3. Create local MediaStream and MediaTracks using the PeerConnectionFactory
// and add it to PeerConnection by calling AddStream.
// 4. Once all mediastreams are added to peerconnection, call
// CommitStreamChanges. Now PeerConnection starts generating an offer based on
// the local mediastreams.
// 5. When PeerConnection have generated the ICE candidates it will call the
// observer OnSignalingMessage callback with the initial offer.
// 6. When an Answer from peer received it must be supplied to the
// PeerConnection by calling ProcessSignalingMessage.
// At this point PeerConnection knows remote capabilities and ICE candidates.
// Media will start flowing to the remote peer.
// The Receiver of a call can decide to accept or reject the call.
// This decision will be taken by the application not peerconnection.
// If application decides to accept the call
// 1. Create PeerConnectionManager if it doesn't exist.
// 2. Create new PeerConnection
// 3. Provide the remote offer to the new PeerConnection object by calling
// ProcessSignalingMessage.
// 4. PeerConnection will call the observer function OnAddStream with remote
// MediaStream and tracks information.
// 5. PeerConnection will call the observer function OnSignalingMessage with
// local ICE candidates in a answer message.
// 6. Application can add it's own MediaStreams by calling AddStream.
// When all streams have been added the application must call
// CommitStreamChanges. Streams can be added at any time after the
// PeerConnection object have been created.
#ifndef TALK_APP_WEBRTC_PEERCONNECTION_H_ #ifndef TALK_APP_WEBRTC_PEERCONNECTION_H_
#define TALK_APP_WEBRTC_PEERCONNECTION_H_ #define TALK_APP_WEBRTC_PEERCONNECTION_H_
@ -39,18 +80,19 @@ namespace talk_base {
} }
namespace webrtc { namespace webrtc {
// MediaStream container interface.
class StreamCollection : public talk_base::RefCount { class StreamCollectionInterface : public talk_base::RefCountInterface {
public: public:
virtual size_t count() = 0; virtual size_t count() = 0;
virtual MediaStreamInterface* at(size_t index) = 0; virtual MediaStreamInterface* at(size_t index) = 0;
virtual MediaStreamInterface* find(const std::string& label) = 0; virtual MediaStreamInterface* find(const std::string& label) = 0;
protected: protected:
// Dtor protected as objects shouldn't be deleted via this interface. // Dtor protected as objects shouldn't be deleted via this interface.
~StreamCollection() {} ~StreamCollectionInterface() {}
}; };
///////////////////////////////////////////// // PeerConnection callback interface. Application should implement these
// methods.
class PeerConnectionObserver { class PeerConnectionObserver {
public: public:
enum Readiness { enum Readiness {
@ -79,7 +121,7 @@ class PeerConnectionObserver {
}; };
class PeerConnection : public talk_base::RefCount { class PeerConnectionInterface : public talk_base::RefCountInterface {
public: public:
// SignalingMessage in json format // SignalingMessage in json format
virtual bool ProcessSignalingMessage(const std::string& msg) = 0; virtual bool ProcessSignalingMessage(const std::string& msg) = 0;
@ -88,10 +130,12 @@ class PeerConnection : public talk_base::RefCount {
virtual bool Send(const std::string& msg) = 0; virtual bool Send(const std::string& msg) = 0;
// Accessor methods to active local streams. // Accessor methods to active local streams.
virtual scoped_refptr<StreamCollection> local_streams() = 0; virtual talk_base::scoped_refptr<StreamCollectionInterface>
local_streams() = 0;
// Accessor methods to remote streams. // Accessor methods to remote streams.
virtual scoped_refptr<StreamCollection> remote_streams() = 0; virtual talk_base::scoped_refptr<StreamCollectionInterface>
remote_streams() = 0;
// Add a new local stream. // Add a new local stream.
// This function does not trigger any changes to the stream until // This function does not trigger any changes to the stream until
@ -109,13 +153,13 @@ class PeerConnection : public talk_base::RefCount {
protected: protected:
// Dtor protected as objects shouldn't be deleted via this interface. // Dtor protected as objects shouldn't be deleted via this interface.
~PeerConnection() {} ~PeerConnectionInterface() {}
}; };
// Reference counted wrapper for talk_base::NetworkManager. // Reference counted wrapper for talk_base::NetworkManager.
class PcNetworkManager : public talk_base::RefCount { class PcNetworkManager : public talk_base::RefCountInterface {
public: public:
static scoped_refptr<PcNetworkManager> Create( static talk_base::scoped_refptr<PcNetworkManager> Create(
talk_base::NetworkManager* network_manager); talk_base::NetworkManager* network_manager);
virtual talk_base::NetworkManager* network_manager() const; virtual talk_base::NetworkManager* network_manager() const;
@ -127,9 +171,9 @@ class PcNetworkManager : public talk_base::RefCount {
}; };
// Reference counted wrapper for talk_base::PacketSocketFactory. // Reference counted wrapper for talk_base::PacketSocketFactory.
class PcPacketSocketFactory : public talk_base::RefCount { class PcPacketSocketFactory : public talk_base::RefCountInterface {
public: public:
static scoped_refptr<PcPacketSocketFactory> Create( static talk_base::scoped_refptr<PcPacketSocketFactory> Create(
talk_base::PacketSocketFactory* socket_factory); talk_base::PacketSocketFactory* socket_factory);
virtual talk_base::PacketSocketFactory* socket_factory() const; virtual talk_base::PacketSocketFactory* socket_factory() const;
@ -141,37 +185,43 @@ class PcPacketSocketFactory : public talk_base::RefCount {
talk_base::PacketSocketFactory* socket_factory_; talk_base::PacketSocketFactory* socket_factory_;
}; };
class PeerConnectionManager : public talk_base::RefCount { // PeerConnectionManager is the factory interface use for creating
// PeerConnection, MediaStream and media tracks.
// PeerConnectionManager will create required libjingle threads, socket and
// network manager factory classes for networking.
// If application decides to provide its own implementation of these classes
// it should use alternate create method which accepts these parameters
// as input.
class PeerConnectionManager : public talk_base::RefCountInterface {
public: public:
// Create a new instance of PeerConnectionManager. // Create a new instance of PeerConnectionManager.
static scoped_refptr<PeerConnectionManager> Create(); static talk_base::scoped_refptr<PeerConnectionManager> Create();
// Create a new instance of PeerConnectionManager. // Create a new instance of PeerConnectionManager.
// Ownership of the arguments are not transfered to this object and must // Ownership of the arguments are not transfered to this object and must
// remain in scope for the lifetime of the PeerConnectionManager. // remain in scope for the lifetime of the PeerConnectionManager.
static scoped_refptr<PeerConnectionManager> Create( static talk_base::scoped_refptr<PeerConnectionManager> Create(
talk_base::Thread* worker_thread, talk_base::Thread* worker_thread,
talk_base::Thread* signaling_thread, talk_base::Thread* signaling_thread,
PcNetworkManager* network_manager, PcNetworkManager* network_manager,
PcPacketSocketFactory* packet_socket_factory, PcPacketSocketFactory* packet_socket_factory,
AudioDeviceModule* default_adm); AudioDeviceModule* default_adm);
virtual scoped_refptr<PeerConnection> CreatePeerConnection( virtual talk_base::scoped_refptr<PeerConnectionInterface>
const std::string& config, CreatePeerConnection(const std::string& config,
PeerConnectionObserver* observer) = 0; PeerConnectionObserver* observer) = 0;
virtual scoped_refptr<LocalMediaStreamInterface> CreateLocalMediaStream( virtual talk_base::scoped_refptr<LocalMediaStreamInterface>
const std::string& label) = 0; CreateLocalMediaStream(const std::string& label) = 0;
virtual scoped_refptr<LocalVideoTrackInterface> CreateLocalVideoTrack( virtual talk_base::scoped_refptr<LocalVideoTrackInterface>
const std::string& label, CreateLocalVideoTrack(const std::string& label,
VideoCaptureModule* video_device) = 0; VideoCaptureModule* video_device) = 0;
virtual scoped_refptr<LocalAudioTrackInterface> CreateLocalAudioTrack( virtual talk_base::scoped_refptr<LocalAudioTrackInterface>
const std::string& label, CreateLocalAudioTrack(const std::string& label,
AudioDeviceModule* audio_device) = 0; AudioDeviceModule* audio_device) = 0;
protected: protected:
// Dtor protected as objects shouldn't be deleted via this interface. // Dtor protected as objects shouldn't be deleted via this interface.
~PeerConnectionManager() {} ~PeerConnectionManager() {}

View File

@ -48,10 +48,10 @@ void GetAllVideoTracks(webrtc::MediaStreamInterface* media_stream,
} }
// TODO(henrike): replace with a capture device that reads from a file/buffer. // TODO(henrike): replace with a capture device that reads from a file/buffer.
scoped_refptr<webrtc::VideoCaptureModule> OpenVideoCaptureDevice() { talk_base::scoped_refptr<webrtc::VideoCaptureModule> OpenVideoCaptureDevice() {
webrtc::VideoCaptureModule::DeviceInfo* device_info( webrtc::VideoCaptureModule::DeviceInfo* device_info(
webrtc::VideoCaptureFactory::CreateDeviceInfo(0)); webrtc::VideoCaptureFactory::CreateDeviceInfo(0));
scoped_refptr<webrtc::VideoCaptureModule> video_device; talk_base::scoped_refptr<webrtc::VideoCaptureModule> video_device;
const size_t kMaxDeviceNameLength = 128; const size_t kMaxDeviceNameLength = 128;
const size_t kMaxUniqueIdLength = 256; const size_t kMaxUniqueIdLength = 256;
@ -175,22 +175,22 @@ class PeerConnectionP2PTestClient
~PeerConnectionP2PTestClient() { ~PeerConnectionP2PTestClient() {
// Ensure that webrtc::PeerConnection is deleted before // Ensure that webrtc::PeerConnection is deleted before
// webrtc::PeerConnectionManager or crash will occur // webrtc::PeerConnectionManager or crash will occur
webrtc::PeerConnection* temp = peer_connection_.release(); webrtc::PeerConnectionInterface* temp = peer_connection_.release();
temp->Release(); temp->Release();
} }
void StartSession() { void StartSession() {
// Audio track doesn't seem to be implemented yet. No need to pass a device // Audio track doesn't seem to be implemented yet. No need to pass a device
// to it. // to it.
scoped_refptr<webrtc::LocalAudioTrackInterface> audio_track( talk_base::scoped_refptr<webrtc::LocalAudioTrackInterface> audio_track(
peer_connection_factory_->CreateLocalAudioTrack("audio_track", NULL)); peer_connection_factory_->CreateLocalAudioTrack("audio_track", NULL));
scoped_refptr<webrtc::LocalVideoTrackInterface> video_track( talk_base::scoped_refptr<webrtc::LocalVideoTrackInterface> video_track(
peer_connection_factory_->CreateLocalVideoTrack( peer_connection_factory_->CreateLocalVideoTrack(
"video_track", "video_track",
OpenVideoCaptureDevice())); OpenVideoCaptureDevice()));
scoped_refptr<webrtc::LocalMediaStreamInterface> stream = talk_base::scoped_refptr<webrtc::LocalMediaStreamInterface> stream =
peer_connection_factory_->CreateLocalMediaStream("stream_label"); peer_connection_factory_->CreateLocalMediaStream("stream_label");
stream->AddTrack(audio_track); stream->AddTrack(audio_track);
@ -231,8 +231,8 @@ class PeerConnectionP2PTestClient
++iter) { ++iter) {
char file_name[256]; char file_name[256];
GenerateRecordingFileName(track_id, file_name); GenerateRecordingFileName(track_id, file_name);
scoped_refptr<webrtc::VideoRendererWrapperInterface> video_renderer = talk_base::scoped_refptr<webrtc::VideoRendererWrapperInterface>
webrtc::CreateVideoRenderer( video_renderer = webrtc::CreateVideoRenderer(
VideoRecorder::CreateVideoRecorder(file_name)); VideoRecorder::CreateVideoRecorder(file_name));
if (video_renderer == NULL) { if (video_renderer == NULL) {
ADD_FAILURE(); ADD_FAILURE();
@ -277,8 +277,9 @@ class PeerConnectionP2PTestClient
} }
int id_; int id_;
scoped_refptr<webrtc::PeerConnection> peer_connection_; talk_base::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_;
scoped_refptr<webrtc::PeerConnectionManager> peer_connection_factory_; talk_base::scoped_refptr<webrtc::PeerConnectionManager>
peer_connection_factory_;
// Remote peer communication. // Remote peer communication.
SignalingMessageReceiver* signaling_message_receiver_; SignalingMessageReceiver* signaling_message_receiver_;

View File

@ -110,11 +110,11 @@ bool static ParseConfigString(const std::string& config,
struct SignalingParams : public talk_base::MessageData { struct SignalingParams : public talk_base::MessageData {
SignalingParams(const std::string& msg, SignalingParams(const std::string& msg,
webrtc::StreamCollection* local_streams) webrtc::StreamCollectionInterface* local_streams)
: msg(msg), : msg(msg),
local_streams(local_streams) {} local_streams(local_streams) {}
const std::string msg; const std::string msg;
scoped_refptr<webrtc::StreamCollection> local_streams; talk_base::scoped_refptr<webrtc::StreamCollectionInterface> local_streams;
}; };
} // namespace } // namespace
@ -199,13 +199,15 @@ bool PeerConnectionImpl::Initialize(const std::string& configuration,
return session_->Initialize(); return session_->Initialize();
} }
scoped_refptr<StreamCollection> PeerConnectionImpl::local_streams() { talk_base::scoped_refptr<StreamCollectionInterface>
PeerConnectionImpl::local_streams() {
return local_media_streams_; return local_media_streams_;
} }
scoped_refptr<StreamCollection> PeerConnectionImpl::remote_streams() { talk_base::scoped_refptr<StreamCollectionInterface>
ScopedRefMessageData<StreamCollection>* msg = PeerConnectionImpl::remote_streams() {
new ScopedRefMessageData<StreamCollection>(NULL); ScopedRefMessageData<StreamCollectionInterface>* msg =
new ScopedRefMessageData<StreamCollectionInterface>(NULL);
signaling_thread_->Send(this, MSG_RETURNREMOTEMEDIASTREAMS, msg); signaling_thread_->Send(this, MSG_RETURNREMOTEMEDIASTREAMS, msg);
return msg->data(); return msg->data();
} }
@ -226,8 +228,8 @@ void PeerConnectionImpl::RemoveStream(
} }
void PeerConnectionImpl::CommitStreamChanges() { void PeerConnectionImpl::CommitStreamChanges() {
ScopedRefMessageData<StreamCollection>* msg = ScopedRefMessageData<StreamCollectionInterface>* msg =
new ScopedRefMessageData<StreamCollection> ( new ScopedRefMessageData<StreamCollectionInterface> (
StreamCollectionImpl::Create(local_media_streams_)); StreamCollectionImpl::Create(local_media_streams_));
signaling_thread_->Post(this, MSG_COMMITSTREAMCHANGES, msg); signaling_thread_->Post(this, MSG_COMMITSTREAMCHANGES, msg);
} }
@ -236,8 +238,8 @@ void PeerConnectionImpl::OnMessage(talk_base::Message* msg) {
talk_base::MessageData* data = msg->pdata; talk_base::MessageData* data = msg->pdata;
switch (msg->message_id) { switch (msg->message_id) {
case MSG_COMMITSTREAMCHANGES: { case MSG_COMMITSTREAMCHANGES: {
ScopedRefMessageData<StreamCollection>* param( ScopedRefMessageData<StreamCollectionInterface>* param(
static_cast<ScopedRefMessageData<StreamCollection>*> (data)); static_cast<ScopedRefMessageData<StreamCollectionInterface>*> (data));
signaling_->CreateOffer(param->data()); signaling_->CreateOffer(param->data());
stream_handler_->CommitLocalStreams(param->data()); stream_handler_->CommitLocalStreams(param->data());
delete data; // Because it is Posted. delete data; // Because it is Posted.
@ -250,8 +252,8 @@ void PeerConnectionImpl::OnMessage(talk_base::Message* msg) {
break; break;
} }
case MSG_RETURNREMOTEMEDIASTREAMS: { case MSG_RETURNREMOTEMEDIASTREAMS: {
ScopedRefMessageData<StreamCollection>* param( ScopedRefMessageData<StreamCollectionInterface>* param(
static_cast<ScopedRefMessageData<StreamCollection>*> (data)); static_cast<ScopedRefMessageData<StreamCollectionInterface>*> (data));
param->data() = StreamCollectionImpl::Create(remote_media_streams_); param->data() = StreamCollectionImpl::Create(remote_media_streams_);
break; break;
} }

View File

@ -49,7 +49,7 @@ class StreamCollectionImpl;
// PeerConnectionImpl implements the PeerConnection interface. // PeerConnectionImpl implements the PeerConnection interface.
// It uses PeerConnectionSignaling and WebRtcSession to implement // It uses PeerConnectionSignaling and WebRtcSession to implement
// the PeerConnection functionality. // the PeerConnection functionality.
class PeerConnectionImpl : public PeerConnection, class PeerConnectionImpl : public PeerConnectionInterface,
public talk_base::MessageHandler, public talk_base::MessageHandler,
public sigslot::has_slots<> { public sigslot::has_slots<> {
public: public:
@ -69,8 +69,8 @@ class PeerConnectionImpl : public PeerConnection,
// TODO(perkj): implement // TODO(perkj): implement
ASSERT(false); ASSERT(false);
} }
virtual scoped_refptr<StreamCollection> local_streams(); virtual talk_base::scoped_refptr<StreamCollectionInterface> local_streams();
virtual scoped_refptr<StreamCollection> remote_streams(); virtual talk_base::scoped_refptr<StreamCollectionInterface> remote_streams();
virtual void AddStream(LocalMediaStreamInterface* stream); virtual void AddStream(LocalMediaStreamInterface* stream);
virtual void RemoveStream(LocalMediaStreamInterface* stream); virtual void RemoveStream(LocalMediaStreamInterface* stream);
virtual void CommitStreamChanges(); virtual void CommitStreamChanges();
@ -87,13 +87,13 @@ class PeerConnectionImpl : public PeerConnection,
void Terminate_s(); void Terminate_s();
PeerConnectionObserver* observer_; PeerConnectionObserver* observer_;
scoped_refptr<StreamCollectionImpl> local_media_streams_; talk_base::scoped_refptr<StreamCollectionImpl> local_media_streams_;
scoped_refptr<StreamCollectionImpl> remote_media_streams_; talk_base::scoped_refptr<StreamCollectionImpl> remote_media_streams_;
talk_base::Thread* signaling_thread_; // Weak ref from PeerConnectionManager. talk_base::Thread* signaling_thread_; // Weak ref from PeerConnectionManager.
cricket::ChannelManager* channel_manager_; cricket::ChannelManager* channel_manager_;
scoped_refptr<PcNetworkManager> network_manager_; talk_base::scoped_refptr<PcNetworkManager> network_manager_;
scoped_refptr<PcPacketSocketFactory> socket_factory_; talk_base::scoped_refptr<PcPacketSocketFactory> socket_factory_;
talk_base::scoped_ptr<cricket::HttpPortAllocator> port_allocator_; talk_base::scoped_ptr<cricket::HttpPortAllocator> port_allocator_;
talk_base::scoped_ptr<WebRtcSession> session_; talk_base::scoped_ptr<WebRtcSession> session_;
talk_base::scoped_ptr<PeerConnectionSignaling> signaling_; talk_base::scoped_ptr<PeerConnectionSignaling> signaling_;

View File

@ -59,15 +59,15 @@ class PeerConnectionImplTest : public testing::Test {
ASSERT_TRUE(pc_.get() != NULL); ASSERT_TRUE(pc_.get() != NULL);
} }
scoped_refptr<webrtc::PeerConnectionManager> pc_factory_; talk_base::scoped_refptr<webrtc::PeerConnectionManager> pc_factory_;
scoped_refptr<PeerConnection> pc_; talk_base::scoped_refptr<PeerConnectionInterface> pc_;
MockPeerConnectionObserver observer_; MockPeerConnectionObserver observer_;
}; };
TEST_F(PeerConnectionImplTest, AddRemoveStream) { TEST_F(PeerConnectionImplTest, DISABLED_AddRemoveStream) {
// Create a local stream. // Create a local stream.
std::string label(kStreamLabel1); std::string label(kStreamLabel1);
scoped_refptr<LocalMediaStreamInterface> stream( talk_base::scoped_refptr<LocalMediaStreamInterface> stream(
pc_factory_->CreateLocalMediaStream(label)); pc_factory_->CreateLocalMediaStream(label));
pc_->AddStream(stream); pc_->AddStream(stream);

View File

@ -58,33 +58,34 @@ class MockPeerConnectionObserver : public PeerConnectionObserver {
// TODO(mallinath) - Fix drash when components are created in factory. // TODO(mallinath) - Fix drash when components are created in factory.
TEST(PeerConnectionManager, DISABLED_CreatePCUsingInternalModules) { TEST(PeerConnectionManager, DISABLED_CreatePCUsingInternalModules) {
MockPeerConnectionObserver observer; MockPeerConnectionObserver observer;
scoped_refptr<PeerConnectionManager> manager(PeerConnectionManager::Create()); talk_base::scoped_refptr<PeerConnectionManager> manager(
PeerConnectionManager::Create());
ASSERT_TRUE(manager.get() != NULL); ASSERT_TRUE(manager.get() != NULL);
scoped_refptr<PeerConnection> pc1(manager->CreatePeerConnection("", talk_base::scoped_refptr<PeerConnectionInterface> pc1(
&observer)); manager->CreatePeerConnection("", &observer));
EXPECT_TRUE(pc1.get() == NULL); EXPECT_TRUE(pc1.get() == NULL);
scoped_refptr<PeerConnection> pc2(manager->CreatePeerConnection( talk_base::scoped_refptr<PeerConnectionInterface> pc2(
kStunConfiguration, &observer)); manager->CreatePeerConnection(kStunConfiguration, &observer));
EXPECT_TRUE(pc2.get() != NULL); EXPECT_TRUE(pc2.get() != NULL);
} }
TEST(PeerConnectionManager, CreatePCUsingExternalModules) { TEST(PeerConnectionManager, CreatePCUsingExternalModules) {
// Create an audio device. Use the default sound card. // Create an audio device. Use the default sound card.
scoped_refptr<AudioDeviceModule> audio_device( talk_base::scoped_refptr<AudioDeviceModule> audio_device(
AudioDeviceModuleImpl::Create(0)); AudioDeviceModuleImpl::Create(0));
// Creata a libjingle thread used as internal worker thread. // Creata a libjingle thread used as internal worker thread.
talk_base::scoped_ptr<talk_base::Thread> w_thread(new talk_base::Thread); talk_base::scoped_ptr<talk_base::Thread> w_thread(new talk_base::Thread);
EXPECT_TRUE(w_thread->Start()); EXPECT_TRUE(w_thread->Start());
scoped_refptr<PcNetworkManager> network_manager(PcNetworkManager::Create( talk_base::scoped_refptr<PcNetworkManager> network_manager(
new talk_base::BasicNetworkManager)); PcNetworkManager::Create(new talk_base::BasicNetworkManager));
scoped_refptr<PcPacketSocketFactory> socket_factory( talk_base::scoped_refptr<PcPacketSocketFactory> socket_factory(
PcPacketSocketFactory::Create(new talk_base::BasicPacketSocketFactory)); PcPacketSocketFactory::Create(new talk_base::BasicPacketSocketFactory));
scoped_refptr<PeerConnectionManager> manager = talk_base::scoped_refptr<PeerConnectionManager> manager =
PeerConnectionManager::Create(talk_base::Thread::Current(), PeerConnectionManager::Create(talk_base::Thread::Current(),
talk_base::Thread::Current(), talk_base::Thread::Current(),
network_manager, network_manager,
@ -93,13 +94,13 @@ TEST(PeerConnectionManager, CreatePCUsingExternalModules) {
ASSERT_TRUE(manager.get() != NULL); ASSERT_TRUE(manager.get() != NULL);
MockPeerConnectionObserver observer; MockPeerConnectionObserver observer;
scoped_refptr<webrtc::PeerConnection> pc1(manager->CreatePeerConnection( talk_base::scoped_refptr<webrtc::PeerConnectionInterface> pc1(
"", &observer)); manager->CreatePeerConnection("", &observer));
EXPECT_TRUE(pc1.get() == NULL); EXPECT_TRUE(pc1.get() == NULL);
scoped_refptr<PeerConnection> pc2(manager->CreatePeerConnection( talk_base::scoped_refptr<PeerConnectionInterface> pc2(
kStunConfiguration, &observer)); manager->CreatePeerConnection(kStunConfiguration, &observer));
EXPECT_TRUE(pc2.get() != NULL); EXPECT_TRUE(pc2.get() != NULL);
} }

View File

@ -49,7 +49,7 @@ struct CreatePeerConnectionParams : public talk_base::MessageData {
webrtc::PeerConnectionObserver* observer) webrtc::PeerConnectionObserver* observer)
: configuration(configuration), observer(observer) { : configuration(configuration), observer(observer) {
} }
scoped_refptr<webrtc::PeerConnection> peerconnection; talk_base::scoped_refptr<webrtc::PeerConnectionInterface> peerconnection;
const std::string& configuration; const std::string& configuration;
webrtc::PeerConnectionObserver* observer; webrtc::PeerConnectionObserver* observer;
}; };
@ -64,10 +64,10 @@ enum {
namespace webrtc { namespace webrtc {
scoped_refptr<PcNetworkManager> PcNetworkManager::Create( talk_base::scoped_refptr<PcNetworkManager> PcNetworkManager::Create(
talk_base::NetworkManager* network_manager) { talk_base::NetworkManager* network_manager) {
talk_base::RefCountImpl<PcNetworkManager>* implementation = talk_base::RefCount<PcNetworkManager>* implementation =
new talk_base::RefCountImpl<PcNetworkManager>(network_manager); new talk_base::RefCount<PcNetworkManager>(network_manager);
return implementation; return implementation;
} }
@ -83,10 +83,10 @@ PcNetworkManager::~PcNetworkManager() {
delete network_manager_; delete network_manager_;
} }
scoped_refptr<PcPacketSocketFactory> PcPacketSocketFactory::Create( talk_base::scoped_refptr<PcPacketSocketFactory> PcPacketSocketFactory::Create(
talk_base::PacketSocketFactory* socket_factory) { talk_base::PacketSocketFactory* socket_factory) {
talk_base::RefCountImpl<PcPacketSocketFactory>* implementation = talk_base::RefCount<PcPacketSocketFactory>* implementation =
new talk_base::RefCountImpl<PcPacketSocketFactory>(socket_factory); new talk_base::RefCount<PcPacketSocketFactory>(socket_factory);
return implementation; return implementation;
} }
@ -103,9 +103,10 @@ talk_base::PacketSocketFactory* PcPacketSocketFactory::socket_factory() const {
return socket_factory_; return socket_factory_;
} }
scoped_refptr<PeerConnectionManager> PeerConnectionManager::Create() { talk_base::scoped_refptr<PeerConnectionManager>
talk_base::RefCountImpl<PeerConnectionManagerImpl>* pc_manager = PeerConnectionManager::Create() {
new talk_base::RefCountImpl<PeerConnectionManagerImpl>(); talk_base::RefCount<PeerConnectionManagerImpl>* pc_manager =
new talk_base::RefCount<PeerConnectionManagerImpl>();
if (!pc_manager->Initialize()) { if (!pc_manager->Initialize()) {
delete pc_manager; delete pc_manager;
@ -114,14 +115,14 @@ scoped_refptr<PeerConnectionManager> PeerConnectionManager::Create() {
return pc_manager; return pc_manager;
} }
scoped_refptr<PeerConnectionManager> PeerConnectionManager::Create( talk_base::scoped_refptr<PeerConnectionManager> PeerConnectionManager::Create(
talk_base::Thread* worker_thread, talk_base::Thread* worker_thread,
talk_base::Thread* signaling_thread, talk_base::Thread* signaling_thread,
PcNetworkManager* network_manager, PcNetworkManager* network_manager,
PcPacketSocketFactory* socket_factory, PcPacketSocketFactory* socket_factory,
AudioDeviceModule* default_adm) { AudioDeviceModule* default_adm) {
talk_base::RefCountImpl<PeerConnectionManagerImpl>* pc_manager = talk_base::RefCount<PeerConnectionManagerImpl>* pc_manager =
new talk_base::RefCountImpl<PeerConnectionManagerImpl>(worker_thread, new talk_base::RefCount<PeerConnectionManagerImpl>(worker_thread,
signaling_thread, signaling_thread,
network_manager, network_manager,
socket_factory, socket_factory,
@ -212,7 +213,8 @@ bool PeerConnectionManagerImpl::Initialize_s() {
return true; return true;
} }
scoped_refptr<PeerConnection> PeerConnectionManagerImpl::CreatePeerConnection( talk_base::scoped_refptr<PeerConnectionInterface>
PeerConnectionManagerImpl::CreatePeerConnection(
const std::string& configuration, const std::string& configuration,
PeerConnectionObserver* observer) { PeerConnectionObserver* observer) {
CreatePeerConnectionParams params(configuration, observer); CreatePeerConnectionParams params(configuration, observer);
@ -220,11 +222,12 @@ scoped_refptr<PeerConnection> PeerConnectionManagerImpl::CreatePeerConnection(
return params.peerconnection; return params.peerconnection;
} }
scoped_refptr<PeerConnection> PeerConnectionManagerImpl::CreatePeerConnection_s( talk_base::scoped_refptr<PeerConnectionInterface>
PeerConnectionManagerImpl::CreatePeerConnection_s(
const std::string& configuration, const std::string& configuration,
PeerConnectionObserver* observer) { PeerConnectionObserver* observer) {
talk_base::RefCountImpl<PeerConnectionImpl>* pc( talk_base::RefCount<PeerConnectionImpl>* pc(
new talk_base::RefCountImpl<PeerConnectionImpl>(channel_manager_.get(), new talk_base::RefCount<PeerConnectionImpl>(channel_manager_.get(),
signaling_thread_ptr_, signaling_thread_ptr_,
worker_thread_ptr_, worker_thread_ptr_,
network_manager_, network_manager_,
@ -236,13 +239,13 @@ scoped_refptr<PeerConnection> PeerConnectionManagerImpl::CreatePeerConnection_s(
return pc; return pc;
} }
scoped_refptr<LocalMediaStreamInterface> talk_base::scoped_refptr<LocalMediaStreamInterface>
PeerConnectionManagerImpl::CreateLocalMediaStream( PeerConnectionManagerImpl::CreateLocalMediaStream(
const std::string& label) { const std::string& label) {
return MediaStreamProxy::Create(label, signaling_thread_ptr_); return MediaStreamProxy::Create(label, signaling_thread_ptr_);
} }
scoped_refptr<LocalVideoTrackInterface> talk_base::scoped_refptr<LocalVideoTrackInterface>
PeerConnectionManagerImpl::CreateLocalVideoTrack( PeerConnectionManagerImpl::CreateLocalVideoTrack(
const std::string& label, const std::string& label,
VideoCaptureModule* video_device) { VideoCaptureModule* video_device) {
@ -250,7 +253,7 @@ PeerConnectionManagerImpl::CreateLocalVideoTrack(
signaling_thread_ptr_); signaling_thread_ptr_);
} }
scoped_refptr<LocalAudioTrackInterface> talk_base::scoped_refptr<LocalAudioTrackInterface>
PeerConnectionManagerImpl::CreateLocalAudioTrack( PeerConnectionManagerImpl::CreateLocalAudioTrack(
const std::string& label, const std::string& label,
AudioDeviceModule* audio_device) { AudioDeviceModule* audio_device) {

View File

@ -40,20 +40,20 @@ namespace webrtc {
class PeerConnectionManagerImpl : public PeerConnectionManager, class PeerConnectionManagerImpl : public PeerConnectionManager,
public talk_base::MessageHandler { public talk_base::MessageHandler {
public: public:
scoped_refptr<PeerConnection> CreatePeerConnection( talk_base::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
const std::string& config, const std::string& config,
PeerConnectionObserver* observer); PeerConnectionObserver* observer);
bool Initialize(); bool Initialize();
virtual scoped_refptr<LocalMediaStreamInterface> CreateLocalMediaStream( virtual talk_base::scoped_refptr<LocalMediaStreamInterface>
const std::string& label); CreateLocalMediaStream(const std::string& label);
virtual scoped_refptr<LocalVideoTrackInterface> CreateLocalVideoTrack( virtual talk_base::scoped_refptr<LocalVideoTrackInterface>
const std::string& label, CreateLocalVideoTrack(const std::string& label,
VideoCaptureModule* video_device); VideoCaptureModule* video_device);
virtual scoped_refptr<LocalAudioTrackInterface> CreateLocalAudioTrack( virtual talk_base::scoped_refptr<LocalAudioTrackInterface>
const std::string& label, CreateLocalAudioTrack(const std::string& label,
AudioDeviceModule* audio_device); AudioDeviceModule* audio_device);
protected: protected:
@ -68,22 +68,21 @@ class PeerConnectionManagerImpl : public PeerConnectionManager,
private: private:
bool Initialize_s(); bool Initialize_s();
scoped_refptr<PeerConnection> CreatePeerConnection_s( talk_base::scoped_refptr<PeerConnectionInterface> CreatePeerConnection_s(
const std::string& configuration, const std::string& configuration,
PeerConnectionObserver* observer); PeerConnectionObserver* observer);
// Implements talk_base::MessageHandler. // Implements talk_base::MessageHandler.
void OnMessage(talk_base::Message* msg); void OnMessage(talk_base::Message* msg);
talk_base::scoped_ptr<talk_base::Thread> worker_thread_;
talk_base::Thread* worker_thread_ptr_;
talk_base::scoped_ptr<talk_base::Thread> signaling_thread_; talk_base::scoped_ptr<talk_base::Thread> signaling_thread_;
talk_base::Thread* signaling_thread_ptr_; talk_base::Thread* signaling_thread_ptr_;
scoped_refptr<PcNetworkManager> network_manager_; talk_base::scoped_ptr<talk_base::Thread> worker_thread_;
scoped_refptr<PcPacketSocketFactory> socket_factory_; talk_base::Thread* worker_thread_ptr_;
talk_base::scoped_ptr<cricket::ChannelManager> channel_manager_; talk_base::scoped_refptr<PcNetworkManager> network_manager_;
talk_base::scoped_refptr<PcPacketSocketFactory> socket_factory_;
// External Audio device used for audio playback. // External Audio device used for audio playback.
scoped_refptr<AudioDeviceModule> default_adm_; talk_base::scoped_refptr<AudioDeviceModule> default_adm_;
talk_base::scoped_ptr<cricket::ChannelManager> channel_manager_;
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -117,7 +117,7 @@ void PeerConnectionSignaling::OnCandidatesReady(
void PeerConnectionSignaling::ProcessSignalingMessage( void PeerConnectionSignaling::ProcessSignalingMessage(
const std::string& message, const std::string& message,
StreamCollection* local_streams) { StreamCollectionInterface* local_streams) {
ASSERT(talk_base::Thread::Current() == signaling_thread_); ASSERT(talk_base::Thread::Current() == signaling_thread_);
talk_base::scoped_ptr<PeerConnectionMessage> signaling_message( talk_base::scoped_ptr<PeerConnectionMessage> signaling_message(
@ -169,7 +169,8 @@ void PeerConnectionSignaling::ProcessSignalingMessage(
signaling_message->candidates()); signaling_message->candidates());
provider_->NegotiationDone(); provider_->NegotiationDone();
UpdateRemoteStreams(remote_desc); UpdateRemoteStreams(remote_desc);
scoped_refptr<StreamCollection> streams(queued_offers_.front()); talk_base::scoped_refptr<StreamCollectionInterface> streams(
queued_offers_.front());
queued_offers_.pop_front(); queued_offers_.pop_front();
UpdateSendingLocalStreams(remote_desc, streams); UpdateSendingLocalStreams(remote_desc, streams);
// Check if we have more offers waiting in the queue. // Check if we have more offers waiting in the queue.
@ -194,7 +195,8 @@ void PeerConnectionSignaling::ProcessSignalingMessage(
} }
} }
void PeerConnectionSignaling::CreateOffer(StreamCollection* local_streams) { void PeerConnectionSignaling::CreateOffer(
StreamCollectionInterface* local_streams) {
ASSERT(talk_base::Thread::Current() == signaling_thread_); ASSERT(talk_base::Thread::Current() == signaling_thread_);
queued_offers_.push_back(local_streams); queued_offers_.push_back(local_streams);
if (state_ == kIdle) { if (state_ == kIdle) {
@ -219,7 +221,8 @@ void PeerConnectionSignaling::OnMessage(talk_base::Message* msg) {
void PeerConnectionSignaling::CreateOffer_s() { void PeerConnectionSignaling::CreateOffer_s() {
ASSERT(queued_offers_.size() > 0); ASSERT(queued_offers_.size() > 0);
scoped_refptr<StreamCollection> local_streams(queued_offers_.front()); talk_base::scoped_refptr<StreamCollectionInterface>
local_streams(queued_offers_.front());
cricket::MediaSessionOptions options; cricket::MediaSessionOptions options;
InitMediaSessionOptions(&options, local_streams); InitMediaSessionOptions(&options, local_streams);
@ -241,7 +244,7 @@ void PeerConnectionSignaling::CreateAnswer_s() {
talk_base::scoped_ptr<PeerConnectionMessage> message( talk_base::scoped_ptr<PeerConnectionMessage> message(
queued_received_offer_.first); queued_received_offer_.first);
queued_received_offer_.first = NULL; queued_received_offer_.first = NULL;
scoped_refptr<StreamCollection> local_streams( talk_base::scoped_refptr<StreamCollectionInterface> local_streams(
queued_received_offer_.second.release()); queued_received_offer_.second.release());
// Reset all pending offers. Instead, send the new streams in the answer. // Reset all pending offers. Instead, send the new streams in the answer.
@ -291,18 +294,19 @@ void PeerConnectionSignaling::CreateAnswer_s() {
// corresponding to the MediaStream and a label of the track. // corresponding to the MediaStream and a label of the track.
void PeerConnectionSignaling::InitMediaSessionOptions( void PeerConnectionSignaling::InitMediaSessionOptions(
cricket::MediaSessionOptions* options, cricket::MediaSessionOptions* options,
StreamCollection* local_streams) { StreamCollectionInterface* local_streams) {
// In order to be able to receive video, // In order to be able to receive video,
// the is_video should always be true even if there are not video tracks. // the is_video should always be true even if there are not video tracks.
options->is_video = true; options->is_video = true;
for (size_t i = 0; i < local_streams->count(); ++i) { for (size_t i = 0; i < local_streams->count(); ++i) {
MediaStreamInterface* stream = local_streams->at(i); MediaStreamInterface* stream = local_streams->at(i);
scoped_refptr<MediaStreamTrackListInterface<AudioTrackInterface> > talk_base::scoped_refptr<AudioTracks>
audio_tracks = stream->audio_tracks(); audio_tracks = stream->audio_tracks();
// For each audio track in the stream, add it to the MediaSessionOptions. // For each audio track in the stream, add it to the MediaSessionOptions.
for (size_t j = 0; j < audio_tracks->count(); ++j) { for (size_t j = 0; j < audio_tracks->count(); ++j) {
scoped_refptr<MediaStreamTrackInterface> track = audio_tracks->at(j); talk_base::scoped_refptr<MediaStreamTrackInterface> track =
audio_tracks->at(j);
if (track->ssrc() == 0) if (track->ssrc() == 0)
track->set_ssrc(++ssrc_counter_); track->set_ssrc(++ssrc_counter_);
options->audio_sources.push_back(cricket::SourceParam(track->ssrc(), options->audio_sources.push_back(cricket::SourceParam(track->ssrc(),
@ -310,11 +314,12 @@ void PeerConnectionSignaling::InitMediaSessionOptions(
stream->label())); stream->label()));
} }
scoped_refptr<MediaStreamTrackListInterface<VideoTrackInterface> > talk_base::scoped_refptr<VideoTracks>
video_tracks = stream->video_tracks(); video_tracks = stream->video_tracks();
// For each video track in the stream, add it to the MediaSessionOptions. // For each video track in the stream, add it to the MediaSessionOptions.
for (size_t j = 0; j < video_tracks->count(); ++j) { for (size_t j = 0; j < video_tracks->count(); ++j) {
scoped_refptr<MediaStreamTrackInterface> track = video_tracks->at(j); talk_base::scoped_refptr<MediaStreamTrackInterface> track =
video_tracks->at(j);
if (track->ssrc() == 0) if (track->ssrc() == 0)
track->set_ssrc(++ssrc_counter_); track->set_ssrc(++ssrc_counter_);
options->video_sources.push_back(cricket::SourceParam(track->ssrc(), options->video_sources.push_back(cricket::SourceParam(track->ssrc(),
@ -332,7 +337,7 @@ void PeerConnectionSignaling::InitMediaSessionOptions(
void PeerConnectionSignaling::UpdateRemoteStreams( void PeerConnectionSignaling::UpdateRemoteStreams(
const cricket::SessionDescription* remote_desc) { const cricket::SessionDescription* remote_desc) {
RemoteStreamMap current_streams; RemoteStreamMap current_streams;
typedef std::pair<std::string, scoped_refptr<MediaStreamProxy> > typedef std::pair<std::string, talk_base::scoped_refptr<MediaStreamProxy> >
MediaStreamPair; MediaStreamPair;
const cricket::ContentInfo* audio_content = GetFirstAudioContent(remote_desc); const cricket::ContentInfo* audio_content = GetFirstAudioContent(remote_desc);
@ -352,19 +357,20 @@ void PeerConnectionSignaling::UpdateRemoteStreams(
if (old_streams_it == remote_streams_.end()) { if (old_streams_it == remote_streams_.end()) {
if (new_streams_it == current_streams.end()) { if (new_streams_it == current_streams.end()) {
// New stream // New stream
scoped_refptr<MediaStreamProxy> stream( talk_base::scoped_refptr<MediaStreamProxy> stream(
MediaStreamProxy::Create(it->cname, signaling_thread_)); MediaStreamProxy::Create(it->cname, signaling_thread_));
current_streams.insert(MediaStreamPair(stream->label(), stream)); current_streams.insert(MediaStreamPair(stream->label(), stream));
new_streams_it = current_streams.find(it->cname); new_streams_it = current_streams.find(it->cname);
} }
scoped_refptr<AudioTrackInterface> track( talk_base::scoped_refptr<AudioTrackInterface> track(
AudioTrackProxy::CreateRemote(it->description, it->ssrc, AudioTrackProxy::CreateRemote(it->description, it->ssrc,
signaling_thread_)); signaling_thread_));
track->set_state(MediaStreamTrackInterface::kLive); track->set_state(MediaStreamTrackInterface::kLive);
new_streams_it->second->AddTrack(track); new_streams_it->second->AddTrack(track);
} else { } else {
scoped_refptr<MediaStreamProxy> stream(old_streams_it->second); talk_base::scoped_refptr<MediaStreamProxy> stream(
old_streams_it->second);
current_streams.insert(MediaStreamPair(stream->label(), stream)); current_streams.insert(MediaStreamPair(stream->label(), stream));
} }
} }
@ -387,19 +393,20 @@ void PeerConnectionSignaling::UpdateRemoteStreams(
if (old_streams_it == remote_streams_.end()) { if (old_streams_it == remote_streams_.end()) {
if (new_streams_it == current_streams.end()) { if (new_streams_it == current_streams.end()) {
// New stream // New stream
scoped_refptr<MediaStreamProxy> stream( talk_base::scoped_refptr<MediaStreamProxy> stream(
MediaStreamProxy::Create(it->cname, signaling_thread_)); MediaStreamProxy::Create(it->cname, signaling_thread_));
current_streams.insert(MediaStreamPair(stream->label(), stream)); current_streams.insert(MediaStreamPair(stream->label(), stream));
new_streams_it = current_streams.find(it->cname); new_streams_it = current_streams.find(it->cname);
} }
scoped_refptr<VideoTrackInterface> track( talk_base::scoped_refptr<VideoTrackInterface> track(
VideoTrackProxy::CreateRemote(it->description, it->ssrc, VideoTrackProxy::CreateRemote(it->description, it->ssrc,
signaling_thread_)); signaling_thread_));
new_streams_it->second->AddTrack(track); new_streams_it->second->AddTrack(track);
track->set_state(MediaStreamTrackInterface::kLive); track->set_state(MediaStreamTrackInterface::kLive);
} else { } else {
scoped_refptr<MediaStreamProxy> stream(old_streams_it->second); talk_base::scoped_refptr<MediaStreamProxy>
stream(old_streams_it->second);
current_streams.insert(MediaStreamPair(stream->label(), stream)); current_streams.insert(MediaStreamPair(stream->label(), stream));
} }
} }
@ -410,7 +417,7 @@ void PeerConnectionSignaling::UpdateRemoteStreams(
for (RemoteStreamMap::iterator it = current_streams.begin(); for (RemoteStreamMap::iterator it = current_streams.begin();
it != current_streams.end(); it != current_streams.end();
++it) { ++it) {
scoped_refptr<MediaStreamProxy> new_stream(it->second); talk_base::scoped_refptr<MediaStreamProxy> new_stream(it->second);
RemoteStreamMap::iterator old_streams_it = RemoteStreamMap::iterator old_streams_it =
remote_streams_.find(new_stream->label()); remote_streams_.find(new_stream->label());
if (old_streams_it == remote_streams_.end()) { if (old_streams_it == remote_streams_.end()) {
@ -425,17 +432,17 @@ void PeerConnectionSignaling::UpdateRemoteStreams(
for (RemoteStreamMap::iterator it = remote_streams_.begin(); for (RemoteStreamMap::iterator it = remote_streams_.begin();
it != remote_streams_.end(); it != remote_streams_.end();
++it) { ++it) {
scoped_refptr<MediaStreamProxy> old_stream(it->second); talk_base::scoped_refptr<MediaStreamProxy> old_stream(it->second);
RemoteStreamMap::iterator new_streams_it = RemoteStreamMap::iterator new_streams_it =
current_streams.find(old_stream->label()); current_streams.find(old_stream->label());
if (new_streams_it == current_streams.end()) { if (new_streams_it == current_streams.end()) {
old_stream->set_ready_state(MediaStreamInterface::kEnded); old_stream->set_ready_state(MediaStreamInterface::kEnded);
scoped_refptr<MediaStreamTrackListInterface<AudioTrackInterface> > talk_base::scoped_refptr<AudioTracks>
audio_tracklist(old_stream->audio_tracks()); audio_tracklist(old_stream->audio_tracks());
for (size_t j = 0; j < audio_tracklist->count(); ++j) { for (size_t j = 0; j < audio_tracklist->count(); ++j) {
audio_tracklist->at(j)->set_state(MediaStreamTrackInterface::kEnded); audio_tracklist->at(j)->set_state(MediaStreamTrackInterface::kEnded);
} }
scoped_refptr<MediaStreamTrackListInterface<VideoTrackInterface> > talk_base::scoped_refptr<VideoTracks>
video_tracklist(old_stream->video_tracks()); video_tracklist(old_stream->video_tracks());
for (size_t j = 0; j < video_tracklist->count(); ++j) { for (size_t j = 0; j < video_tracklist->count(); ++j) {
video_tracklist->at(j)->set_state(MediaStreamTrackInterface::kEnded); video_tracklist->at(j)->set_state(MediaStreamTrackInterface::kEnded);
@ -453,22 +460,25 @@ void PeerConnectionSignaling::UpdateRemoteStreams(
// failed the state is changed to kEnded. // failed the state is changed to kEnded.
void PeerConnectionSignaling::UpdateSendingLocalStreams( void PeerConnectionSignaling::UpdateSendingLocalStreams(
const cricket::SessionDescription* answer_desc, const cricket::SessionDescription* answer_desc,
StreamCollection* negotiated_streams) { StreamCollectionInterface* negotiated_streams) {
typedef std::pair<std::string, scoped_refptr<MediaStreamInterface> > typedef std::pair<std::string,
talk_base::scoped_refptr<MediaStreamInterface> >
MediaStreamPair; MediaStreamPair;
LocalStreamMap current_local_streams; LocalStreamMap current_local_streams;
for (size_t i = 0; i < negotiated_streams->count(); ++i) { for (size_t i = 0; i < negotiated_streams->count(); ++i) {
scoped_refptr<MediaStreamInterface> stream = negotiated_streams->at(i); talk_base::scoped_refptr<MediaStreamInterface> stream =
scoped_refptr<MediaStreamTrackListInterface<AudioTrackInterface> > negotiated_streams->at(i);
audiotracklist(stream->audio_tracks()); talk_base::scoped_refptr<AudioTracks> audiotracklist(
scoped_refptr<MediaStreamTrackListInterface<VideoTrackInterface> > stream->audio_tracks());
videotracklist(stream->video_tracks()); talk_base::scoped_refptr<VideoTracks> videotracklist(
stream->video_tracks());
bool stream_ok = false; // A stream is ok if at least one track succeed. bool stream_ok = false; // A stream is ok if at least one track succeed.
// Update tracks based on its type. // Update tracks based on its type.
for (size_t j = 0; j < audiotracklist->count(); ++j) { for (size_t j = 0; j < audiotracklist->count(); ++j) {
scoped_refptr<MediaStreamTrackInterface> track = audiotracklist->at(j); talk_base::scoped_refptr<MediaStreamTrackInterface> track =
audiotracklist->at(j);
const cricket::ContentInfo* audio_content = const cricket::ContentInfo* audio_content =
GetFirstAudioContent(answer_desc); GetFirstAudioContent(answer_desc);
if (!audio_content) { // The remote does not accept audio. if (!audio_content) { // The remote does not accept audio.
@ -489,7 +499,8 @@ void PeerConnectionSignaling::UpdateSendingLocalStreams(
} }
for (size_t j = 0; j < videotracklist->count(); ++j) { for (size_t j = 0; j < videotracklist->count(); ++j) {
scoped_refptr<MediaStreamTrackInterface> track = videotracklist->at(j); talk_base::scoped_refptr<MediaStreamTrackInterface> track =
videotracklist->at(j);
const cricket::ContentInfo* video_content = const cricket::ContentInfo* video_content =
GetFirstVideoContent(answer_desc); GetFirstVideoContent(answer_desc);
if (!video_content) { // The remote does not accept video. if (!video_content) { // The remote does not accept video.
@ -525,18 +536,18 @@ void PeerConnectionSignaling::UpdateSendingLocalStreams(
for (LocalStreamMap::iterator it = local_streams_.begin(); for (LocalStreamMap::iterator it = local_streams_.begin();
it != local_streams_.end(); it != local_streams_.end();
++it) { ++it) {
scoped_refptr<MediaStreamInterface> old_stream(it->second); talk_base::scoped_refptr<MediaStreamInterface> old_stream(it->second);
MediaStreamInterface* new_streams = MediaStreamInterface* new_streams =
negotiated_streams->find(old_stream->label()); negotiated_streams->find(old_stream->label());
if (new_streams == NULL) { if (new_streams == NULL) {
old_stream->set_ready_state(MediaStreamInterface::kEnded); old_stream->set_ready_state(MediaStreamInterface::kEnded);
scoped_refptr<MediaStreamTrackListInterface<AudioTrackInterface> > talk_base::scoped_refptr<AudioTracks> audio_tracklist(
audio_tracklist(old_stream->audio_tracks()); old_stream->audio_tracks());
for (size_t j = 0; j < audio_tracklist->count(); ++j) { for (size_t j = 0; j < audio_tracklist->count(); ++j) {
audio_tracklist->at(j)->set_state(MediaStreamTrackInterface::kEnded); audio_tracklist->at(j)->set_state(MediaStreamTrackInterface::kEnded);
} }
scoped_refptr<MediaStreamTrackListInterface<VideoTrackInterface> > talk_base::scoped_refptr<VideoTracks> video_tracklist(
video_tracklist(old_stream->video_tracks()); old_stream->video_tracks());
for (size_t j = 0; j < video_tracklist->count(); ++j) { for (size_t j = 0; j < video_tracklist->count(); ++j) {
video_tracklist->at(j)->set_state(MediaStreamTrackInterface::kEnded); video_tracklist->at(j)->set_state(MediaStreamTrackInterface::kEnded);
} }

View File

@ -94,13 +94,13 @@ class PeerConnectionSignaling : public WebRtcSessionObserver,
// Process a received offer/answer from the remote peer. // Process a received offer/answer from the remote peer.
void ProcessSignalingMessage(const std::string& message, void ProcessSignalingMessage(const std::string& message,
StreamCollection* local_streams); StreamCollectionInterface* local_streams);
// Creates an offer containing all tracks in local_streams. // Creates an offer containing all tracks in local_streams.
// When the offer is ready it is signaled by SignalNewPeerConnectionMessage. // When the offer is ready it is signaled by SignalNewPeerConnectionMessage.
// When the remote peer is ready to receive media on a stream , the state of // When the remote peer is ready to receive media on a stream , the state of
// the local stream will change to kAlive. // the local stream will change to kAlive.
void CreateOffer(StreamCollection* local_streams); void CreateOffer(StreamCollectionInterface* local_streams);
// Returns the current state. // Returns the current state.
State GetState(); State GetState();
@ -129,18 +129,20 @@ class PeerConnectionSignaling : public WebRtcSessionObserver,
void CreateAnswer_s(); void CreateAnswer_s();
void InitMediaSessionOptions(cricket::MediaSessionOptions* options, void InitMediaSessionOptions(cricket::MediaSessionOptions* options,
StreamCollection* local_streams); StreamCollectionInterface* local_streams);
void UpdateRemoteStreams(const cricket::SessionDescription* remote_desc); void UpdateRemoteStreams(const cricket::SessionDescription* remote_desc);
void UpdateSendingLocalStreams( void UpdateSendingLocalStreams(
const cricket::SessionDescription* answer_desc, const cricket::SessionDescription* answer_desc,
StreamCollection* negotiated_streams); StreamCollectionInterface* negotiated_streams);
typedef std::list<scoped_refptr<StreamCollection> > StreamCollectionList; typedef std::list<talk_base::scoped_refptr<StreamCollectionInterface> >
StreamCollectionList;
StreamCollectionList queued_offers_; StreamCollectionList queued_offers_;
typedef std::pair<PeerConnectionMessage*, typedef std::pair<PeerConnectionMessage*,
scoped_refptr<StreamCollection> > RemoteOfferPair; talk_base::scoped_refptr<StreamCollectionInterface> >
RemoteOfferPair;
RemoteOfferPair queued_received_offer_; RemoteOfferPair queued_received_offer_;
talk_base::Thread* signaling_thread_; talk_base::Thread* signaling_thread_;
@ -148,10 +150,10 @@ class PeerConnectionSignaling : public WebRtcSessionObserver,
State state_; State state_;
uint32 ssrc_counter_; uint32 ssrc_counter_;
typedef std::map<std::string, scoped_refptr<MediaStreamProxy> > typedef std::map<std::string, talk_base::scoped_refptr<MediaStreamProxy> >
RemoteStreamMap; RemoteStreamMap;
RemoteStreamMap remote_streams_; RemoteStreamMap remote_streams_;
typedef std::map<std::string, scoped_refptr<MediaStreamInterface> > typedef std::map<std::string, talk_base::scoped_refptr<MediaStreamInterface> >
LocalStreamMap; LocalStreamMap;
LocalStreamMap local_streams_; LocalStreamMap local_streams_;
cricket::Candidates candidates_; cricket::Candidates candidates_;

View File

@ -46,11 +46,12 @@ static const int kWaitTime = 5000;
namespace webrtc { namespace webrtc {
typedef std::map<std::string, typedef std::map<std::string, talk_base::scoped_refptr<MediaStreamInterface> >
scoped_refptr<MediaStreamInterface> > MediaStreamMap; MediaStreamMap;
typedef std::pair<std::string, scoped_refptr<MediaStreamInterface> > RemotePair; typedef std::pair<std::string, talk_base::scoped_refptr<MediaStreamInterface> >
RemotePair;
class MockMediaTrackObserver : public webrtc::Observer { class MockMediaTrackObserver : public webrtc::ObserverInterface {
public: public:
explicit MockMediaTrackObserver(MediaStreamTrackInterface* track) explicit MockMediaTrackObserver(MediaStreamTrackInterface* track)
: track_(track) { : track_(track) {
@ -64,10 +65,10 @@ class MockMediaTrackObserver : public webrtc::Observer {
webrtc::MediaStreamTrackInterface::TrackState track_state; webrtc::MediaStreamTrackInterface::TrackState track_state;
private: private:
scoped_refptr<MediaStreamTrackInterface> track_; talk_base::scoped_refptr<MediaStreamTrackInterface> track_;
}; };
class MockMediaStreamObserver : public webrtc::Observer { class MockMediaStreamObserver : public webrtc::ObserverInterface {
public: public:
explicit MockMediaStreamObserver(MediaStreamInterface* stream) explicit MockMediaStreamObserver(MediaStreamInterface* stream)
: stream_(stream) { : stream_(stream) {
@ -81,7 +82,7 @@ class MockMediaStreamObserver : public webrtc::Observer {
webrtc::MediaStreamInterface::ReadyState ready_state; webrtc::MediaStreamInterface::ReadyState ready_state;
private: private:
scoped_refptr<MediaStreamInterface> stream_; talk_base::scoped_refptr<MediaStreamInterface> stream_;
}; };
class MockSignalingObserver : public sigslot::has_slots<> { class MockSignalingObserver : public sigslot::has_slots<> {
@ -147,7 +148,7 @@ class MockSignalingObserver : public sigslot::has_slots<> {
private: private:
MediaStreamMap remote_media_streams_; MediaStreamMap remote_media_streams_;
scoped_refptr<StreamCollectionImpl> remote_local_collection_; talk_base::scoped_refptr<StreamCollectionImpl> remote_local_collection_;
PeerConnectionSignaling* remote_peer_; PeerConnectionSignaling* remote_peer_;
}; };
@ -239,18 +240,18 @@ class PeerConnectionSignalingTest: public testing::Test {
TEST_F(PeerConnectionSignalingTest, SimpleOneWayCall) { TEST_F(PeerConnectionSignalingTest, SimpleOneWayCall) {
// Create a local stream. // Create a local stream.
std::string label(kStreamLabel1); std::string label(kStreamLabel1);
scoped_refptr<LocalMediaStreamInterface> stream( talk_base::scoped_refptr<LocalMediaStreamInterface> stream(
MediaStream::Create(label)); MediaStream::Create(label));
MockMediaStreamObserver stream_observer1(stream); MockMediaStreamObserver stream_observer1(stream);
// Add a local audio track. // Add a local audio track.
scoped_refptr<LocalAudioTrackInterface> audio_track(AudioTrack::CreateLocal( talk_base::scoped_refptr<LocalAudioTrackInterface>
kAudioTrackLabel1, NULL)); audio_track(AudioTrack::CreateLocal(kAudioTrackLabel1, NULL));
stream->AddTrack(audio_track); stream->AddTrack(audio_track);
MockMediaTrackObserver track_observer1(audio_track); MockMediaTrackObserver track_observer1(audio_track);
// Peer 1 create an offer with only one audio track. // Peer 1 create an offer with only one audio track.
scoped_refptr<StreamCollectionImpl> local_collection1( talk_base::scoped_refptr<StreamCollectionImpl> local_collection1(
StreamCollectionImpl::Create()); StreamCollectionImpl::Create());
local_collection1->AddStream(stream); local_collection1->AddStream(stream);
// Verify that the local stream is now initializing. // Verify that the local stream is now initializing.
@ -260,7 +261,7 @@ TEST_F(PeerConnectionSignalingTest, SimpleOneWayCall) {
track_observer1.track_state); track_observer1.track_state);
// Peer 2 only receive. Create an empty collection // Peer 2 only receive. Create an empty collection
scoped_refptr<StreamCollectionImpl> local_collection2( talk_base::scoped_refptr<StreamCollectionImpl> local_collection2(
StreamCollectionImpl::Create()); StreamCollectionImpl::Create());
// Connect all messages sent from Peer1 to be received on Peer2 // Connect all messages sent from Peer1 to be received on Peer2
@ -314,16 +315,16 @@ TEST_F(PeerConnectionSignalingTest, Glare) {
signaling2_->OnCandidatesReady(candidates_); signaling2_->OnCandidatesReady(candidates_);
// Create a local stream. // Create a local stream.
std::string label(kStreamLabel1); std::string label(kStreamLabel1);
scoped_refptr<LocalMediaStreamInterface> stream( talk_base::scoped_refptr<LocalMediaStreamInterface> stream(
MediaStream::Create(label)); MediaStream::Create(label));
// Add a local audio track. // Add a local audio track.
scoped_refptr<LocalAudioTrackInterface> audio_track(AudioTrack::CreateLocal( talk_base::scoped_refptr<LocalAudioTrackInterface>
kAudioTrackLabel1, NULL)); audio_track(AudioTrack::CreateLocal(kAudioTrackLabel1, NULL));
stream->AddTrack(audio_track); stream->AddTrack(audio_track);
// Peer 1 create an offer with only one audio track. // Peer 1 create an offer with only one audio track.
scoped_refptr<StreamCollectionImpl> local_collection1( talk_base::scoped_refptr<StreamCollectionImpl> local_collection1(
StreamCollectionImpl::Create()); StreamCollectionImpl::Create());
local_collection1->AddStream(stream); local_collection1->AddStream(stream);
signaling1_->CreateOffer(local_collection1); signaling1_->CreateOffer(local_collection1);
@ -333,7 +334,7 @@ TEST_F(PeerConnectionSignalingTest, Glare) {
talk_base::Thread::Current()->ProcessMessages(1); talk_base::Thread::Current()->ProcessMessages(1);
// Peer 2 only receive. Create an empty collection. // Peer 2 only receive. Create an empty collection.
scoped_refptr<StreamCollectionImpl> local_collection2( talk_base::scoped_refptr<StreamCollectionImpl> local_collection2(
StreamCollectionImpl::Create()); StreamCollectionImpl::Create());
// Peer 2 create an empty offer. // Peer 2 create an empty offer.
signaling2_->CreateOffer(local_collection2); signaling2_->CreateOffer(local_collection2);
@ -378,28 +379,28 @@ TEST_F(PeerConnectionSignalingTest, AddRemoveStream) {
signaling2_->OnCandidatesReady(candidates_); signaling2_->OnCandidatesReady(candidates_);
// Create a local stream. // Create a local stream.
std::string label(kStreamLabel1); std::string label(kStreamLabel1);
scoped_refptr<LocalMediaStreamInterface> stream( talk_base::scoped_refptr<LocalMediaStreamInterface> stream(
MediaStream::Create(label)); MediaStream::Create(label));
MockMediaStreamObserver stream_observer1(stream); MockMediaStreamObserver stream_observer1(stream);
// Add a local audio track. // Add a local audio track.
scoped_refptr<LocalAudioTrackInterface> audio_track(AudioTrack::CreateLocal( talk_base::scoped_refptr<LocalAudioTrackInterface>
kAudioTrackLabel1, NULL)); audio_track(AudioTrack::CreateLocal(kAudioTrackLabel1, NULL));
stream->AddTrack(audio_track); stream->AddTrack(audio_track);
MockMediaTrackObserver track_observer1(audio_track); MockMediaTrackObserver track_observer1(audio_track);
audio_track->RegisterObserver(&track_observer1); audio_track->RegisterObserver(&track_observer1);
// Add a local video track. // Add a local video track.
scoped_refptr<LocalVideoTrackInterface> video_track(VideoTrack::CreateLocal( talk_base::scoped_refptr<LocalVideoTrackInterface>
kVideoTrackLabel1, NULL)); video_track(VideoTrack::CreateLocal(kVideoTrackLabel1, NULL));
stream->AddTrack(video_track); stream->AddTrack(video_track);
// Peer 1 create an empty collection // Peer 1 create an empty collection
scoped_refptr<StreamCollectionImpl> local_collection1( talk_base::scoped_refptr<StreamCollectionImpl> local_collection1(
StreamCollectionImpl::Create()); StreamCollectionImpl::Create());
// Peer 2 create an empty collection // Peer 2 create an empty collection
scoped_refptr<StreamCollectionImpl> local_collection2( talk_base::scoped_refptr<StreamCollectionImpl> local_collection2(
StreamCollectionImpl::Create()); StreamCollectionImpl::Create());
// Connect all messages sent from Peer1 to be received on Peer2 // Connect all messages sent from Peer1 to be received on Peer2

View File

@ -35,36 +35,36 @@
namespace talk_base { namespace talk_base {
// Reference count interface. // Reference count interface.
class RefCount { class RefCountInterface {
public: public:
virtual int AddRef() = 0; virtual int AddRef() = 0;
virtual int Release() = 0; virtual int Release() = 0;
}; };
template <class T> template <class T>
class RefCountImpl : public T { class RefCount : public T {
public: public:
RefCountImpl() : ref_count_(0) { RefCount() : ref_count_(0) {
} }
template<typename P> template<typename P>
explicit RefCountImpl(P p) : ref_count_(0), T(p) { explicit RefCount(P p) : ref_count_(0), T(p) {
} }
template<typename P1, typename P2> template<typename P1, typename P2>
RefCountImpl(P1 p1, P2 p2) : ref_count_(0), T(p1, p2) { RefCount(P1 p1, P2 p2) : ref_count_(0), T(p1, p2) {
} }
template<typename P1, typename P2, typename P3> template<typename P1, typename P2, typename P3>
RefCountImpl(P1 p1, P2 p2, P3 p3) : ref_count_(0), T(p1, p2, p3) { RefCount(P1 p1, P2 p2, P3 p3) : ref_count_(0), T(p1, p2, p3) {
} }
template<typename P1, typename P2, typename P3, typename P4> template<typename P1, typename P2, typename P3, typename P4>
RefCountImpl(P1 p1, P2 p2, P3 p3, P4 p4) : ref_count_(0), T(p1, p2, p3, p4) { RefCount(P1 p1, P2 p2, P3 p3, P4 p4) : ref_count_(0), T(p1, p2, p3, p4) {
} }
template<typename P1, typename P2, typename P3, typename P4, typename P5> template<typename P1, typename P2, typename P3, typename P4, typename P5>
RefCountImpl(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) RefCount(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
: ref_count_(0), T(p1, p2, p3, p4, p5) { : ref_count_(0), T(p1, p2, p3, p4, p5) {
} }

View File

@ -50,6 +50,8 @@
// // now, |a| and |b| each own a reference to the same MyFoo object. // // now, |a| and |b| each own a reference to the same MyFoo object.
// } // }
// //
namespace talk_base {
template <class T> template <class T>
class scoped_refptr { class scoped_refptr {
public: public:
@ -125,4 +127,6 @@ class scoped_refptr {
T* ptr_; T* ptr_;
}; };
} // namespace talk_base
#endif // TALK_APP_WEBRTC_SCOPED_REFPTR_H_ #endif // TALK_APP_WEBRTC_SCOPED_REFPTR_H_

View File

@ -36,17 +36,17 @@ template <class T>
class ScopedRefMessageData : public talk_base::MessageData { class ScopedRefMessageData : public talk_base::MessageData {
public: public:
explicit ScopedRefMessageData(T* data) : data_(data) { } explicit ScopedRefMessageData(T* data) : data_(data) { }
const scoped_refptr<T>& data() const { return data_; } const talk_base::scoped_refptr<T>& data() const { return data_; }
scoped_refptr<T>& data() { return data_; } talk_base::scoped_refptr<T>& data() { return data_; }
private: private:
scoped_refptr<T> data_; talk_base::scoped_refptr<T> data_;
}; };
/* /*
struct ScopedTypedMessageData : public talk_base::MessageData { struct ScopedTypedMessageData : public talk_base::MessageData {
ScopedRefPtrMsgParams(scoped_refptr<T> ptr) ScopedRefPtrMsgParams(talk_base::scoped_refptr<T> ptr)
: ptr_(ptr) { : ptr_(ptr) {
} }
scoped_refptr<T> ptr_; talk_base::scoped_refptr<T> ptr_;
};*/ };*/
#endif // TALK_APP_WEBRTC_SCOPED_REF_PTR_MSG_H_ #endif // TALK_APP_WEBRTC_SCOPED_REF_PTR_MSG_H_

View File

@ -36,18 +36,18 @@
namespace webrtc { namespace webrtc {
// Implementation of StreamCollection. // Implementation of StreamCollection.
class StreamCollectionImpl : public StreamCollection { class StreamCollectionImpl : public StreamCollectionInterface {
public: public:
static scoped_refptr<StreamCollectionImpl> Create() { static talk_base::scoped_refptr<StreamCollectionImpl> Create() {
talk_base::RefCountImpl<StreamCollectionImpl>* implementation = talk_base::RefCount<StreamCollectionImpl>* implementation =
new talk_base::RefCountImpl<StreamCollectionImpl>(); new talk_base::RefCount<StreamCollectionImpl>();
return implementation; return implementation;
} }
static scoped_refptr<StreamCollectionImpl> Create( static talk_base::scoped_refptr<StreamCollectionImpl> Create(
StreamCollectionImpl* streams) { StreamCollectionImpl* streams) {
talk_base::RefCountImpl<StreamCollectionImpl>* implementation = talk_base::RefCount<StreamCollectionImpl>* implementation =
new talk_base::RefCountImpl<StreamCollectionImpl>(streams); new talk_base::RefCount<StreamCollectionImpl>(streams);
return implementation; return implementation;
} }
@ -93,7 +93,8 @@ class StreamCollectionImpl : public StreamCollection {
explicit StreamCollectionImpl(StreamCollectionImpl* original) explicit StreamCollectionImpl(StreamCollectionImpl* original)
: media_streams_(original->media_streams_) { : media_streams_(original->media_streams_) {
} }
typedef std::vector<scoped_refptr<MediaStreamInterface> > StreamVector; typedef std::vector<talk_base::scoped_refptr<MediaStreamInterface> >
StreamVector;
StreamVector media_streams_; StreamVector media_streams_;
}; };

View File

@ -48,10 +48,10 @@ class VideoRendererImpl : public VideoRendererWrapperInterface {
cricket::VideoRenderer* renderer_; cricket::VideoRenderer* renderer_;
}; };
scoped_refptr<VideoRendererWrapperInterface> CreateVideoRenderer( talk_base::scoped_refptr<VideoRendererWrapperInterface> CreateVideoRenderer(
cricket::VideoRenderer* renderer) { cricket::VideoRenderer* renderer) {
talk_base::RefCountImpl<VideoRendererImpl>* r = talk_base::RefCount<VideoRendererImpl>* r =
new talk_base::RefCountImpl<VideoRendererImpl>(renderer); new talk_base::RefCount<VideoRendererImpl>(renderer);
return r; return r;
} }

View File

@ -45,7 +45,7 @@ VideoTrack::VideoTrack(const std::string& label,
void VideoTrack::SetRenderer(VideoRendererWrapperInterface* renderer) { void VideoTrack::SetRenderer(VideoRendererWrapperInterface* renderer) {
video_renderer_ = renderer; video_renderer_ = renderer;
NotifierImpl<LocalVideoTrackInterface>::FireOnChanged(); Notifier<LocalVideoTrackInterface>::FireOnChanged();
} }
VideoRendererWrapperInterface* VideoTrack::GetRenderer() { VideoRendererWrapperInterface* VideoTrack::GetRenderer() {
@ -61,19 +61,19 @@ const char* VideoTrack::kind() const {
return kVideoTrackKind; return kVideoTrackKind;
} }
scoped_refptr<VideoTrack> VideoTrack::CreateRemote( talk_base::scoped_refptr<VideoTrack> VideoTrack::CreateRemote(
const std::string& label, const std::string& label,
uint32 ssrc) { uint32 ssrc) {
talk_base::RefCountImpl<VideoTrack>* track = talk_base::RefCount<VideoTrack>* track =
new talk_base::RefCountImpl<VideoTrack>(label, ssrc); new talk_base::RefCount<VideoTrack>(label, ssrc);
return track; return track;
} }
scoped_refptr<VideoTrack> VideoTrack::CreateLocal( talk_base::scoped_refptr<VideoTrack> VideoTrack::CreateLocal(
const std::string& label, const std::string& label,
VideoCaptureModule* video_device) { VideoCaptureModule* video_device) {
talk_base::RefCountImpl<VideoTrack>* track = talk_base::RefCount<VideoTrack>* track =
new talk_base::RefCountImpl<VideoTrack>(label, video_device); new talk_base::RefCount<VideoTrack>(label, video_device);
return track; return track;
} }

View File

@ -28,6 +28,8 @@
#ifndef TALK_APP_WEBRTC_VIDEOTRACKIMPL_H_ #ifndef TALK_APP_WEBRTC_VIDEOTRACKIMPL_H_
#define TALK_APP_WEBRTC_VIDEOTRACKIMPL_H_ #define TALK_APP_WEBRTC_VIDEOTRACKIMPL_H_
#include <string>
#include "talk/app/webrtc_dev/mediastream.h" #include "talk/app/webrtc_dev/mediastream.h"
#include "talk/app/webrtc_dev/mediatrackimpl.h" #include "talk/app/webrtc_dev/mediatrackimpl.h"
#include "talk/app/webrtc_dev/notifierimpl.h" #include "talk/app/webrtc_dev/notifierimpl.h"
@ -44,10 +46,11 @@ namespace webrtc {
class VideoTrack : public MediaTrack<LocalVideoTrackInterface> { class VideoTrack : public MediaTrack<LocalVideoTrackInterface> {
public: public:
// Create a video track used for remote video tracks. // Create a video track used for remote video tracks.
static scoped_refptr<VideoTrack> CreateRemote(const std::string& label, static talk_base::scoped_refptr<VideoTrack> CreateRemote(
const std::string& label,
uint32 ssrc); uint32 ssrc);
// Create a video track used for local video tracks. // Create a video track used for local video tracks.
static scoped_refptr<VideoTrack> CreateLocal( static talk_base::scoped_refptr<VideoTrack> CreateLocal(
const std::string& label, const std::string& label,
VideoCaptureModule* video_device); VideoCaptureModule* video_device);
@ -62,8 +65,8 @@ class VideoTrack : public MediaTrack<LocalVideoTrackInterface> {
VideoTrack(const std::string& label, VideoCaptureModule* video_device); VideoTrack(const std::string& label, VideoCaptureModule* video_device);
private: private:
scoped_refptr<VideoCaptureModule> video_device_; talk_base::scoped_refptr<VideoCaptureModule> video_device_;
scoped_refptr<VideoRendererWrapperInterface> video_renderer_; talk_base::scoped_refptr<VideoRendererWrapperInterface> video_renderer_;
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -220,10 +220,11 @@ void Conductor::ConnectToPeer(int peer_id) {
} }
} }
scoped_refptr<webrtc::VideoCaptureModule> Conductor::OpenVideoCaptureDevice() { talk_base::scoped_refptr<webrtc::VideoCaptureModule>
Conductor::OpenVideoCaptureDevice() {
webrtc::VideoCaptureModule::DeviceInfo* device_info( webrtc::VideoCaptureModule::DeviceInfo* device_info(
webrtc::VideoCaptureFactory::CreateDeviceInfo(0)); webrtc::VideoCaptureFactory::CreateDeviceInfo(0));
scoped_refptr<webrtc::VideoCaptureModule> video_device; talk_base::scoped_refptr<webrtc::VideoCaptureModule> video_device;
const size_t kMaxDeviceNameLength = 128; const size_t kMaxDeviceNameLength = 128;
const size_t kMaxUniqueIdLength = 256; const size_t kMaxUniqueIdLength = 256;
@ -249,23 +250,24 @@ void Conductor::AddStreams() {
if (active_streams_.find(kStreamLabel) != active_streams_.end()) if (active_streams_.find(kStreamLabel) != active_streams_.end())
return; // Already added. return; // Already added.
scoped_refptr<webrtc::LocalAudioTrackInterface> audio_track( talk_base::scoped_refptr<webrtc::LocalAudioTrackInterface> audio_track(
peer_connection_factory_->CreateLocalAudioTrack(kAudioLabel, NULL)); peer_connection_factory_->CreateLocalAudioTrack(kAudioLabel, NULL));
scoped_refptr<webrtc::LocalVideoTrackInterface> video_track( talk_base::scoped_refptr<webrtc::LocalVideoTrackInterface> video_track(
peer_connection_factory_->CreateLocalVideoTrack( peer_connection_factory_->CreateLocalVideoTrack(
kVideoLabel, OpenVideoCaptureDevice())); kVideoLabel, OpenVideoCaptureDevice()));
video_track->SetRenderer(main_wnd_->local_renderer()); video_track->SetRenderer(main_wnd_->local_renderer());
scoped_refptr<webrtc::LocalMediaStreamInterface> stream = talk_base::scoped_refptr<webrtc::LocalMediaStreamInterface> stream =
peer_connection_factory_->CreateLocalMediaStream(kStreamLabel); peer_connection_factory_->CreateLocalMediaStream(kStreamLabel);
stream->AddTrack(audio_track); stream->AddTrack(audio_track);
stream->AddTrack(video_track); stream->AddTrack(video_track);
peer_connection_->AddStream(stream); peer_connection_->AddStream(stream);
peer_connection_->CommitStreamChanges(); peer_connection_->CommitStreamChanges();
typedef std::pair<std::string, scoped_refptr<webrtc::MediaStreamInterface> > typedef std::pair<std::string,
talk_base::scoped_refptr<webrtc::MediaStreamInterface> >
MediaStreamPair; MediaStreamPair;
active_streams_.insert(MediaStreamPair(stream->label(), stream)); active_streams_.insert(MediaStreamPair(stream->label(), stream));
main_wnd_->SwitchToStreamingUI(); main_wnd_->SwitchToStreamingUI();
@ -340,8 +342,8 @@ void Conductor::UIThreadCallback(int msg_id, void* data) {
webrtc::MediaStreamInterface* stream = webrtc::MediaStreamInterface* stream =
reinterpret_cast<webrtc::MediaStreamInterface*>( reinterpret_cast<webrtc::MediaStreamInterface*>(
data); data);
scoped_refptr<webrtc::MediaStreamTrackListInterface< talk_base::scoped_refptr<webrtc::VideoTracks> tracks =
webrtc::VideoTrackInterface> > tracks = stream->video_tracks(); stream->video_tracks();
for (size_t i = 0; i < tracks->count(); ++i) { for (size_t i = 0; i < tracks->count(); ++i) {
webrtc::VideoTrackInterface* track = tracks->at(i); webrtc::VideoTrackInterface* track = tracks->at(i);
LOG(INFO) << "Setting video renderer for track: " << track->label(); LOG(INFO) << "Setting video renderer for track: " << track->label();

View File

@ -58,7 +58,7 @@ class Conductor
void DeletePeerConnection(); void DeletePeerConnection();
void EnsureStreamingUI(); void EnsureStreamingUI();
void AddStreams(); void AddStreams();
scoped_refptr<webrtc::VideoCaptureModule> OpenVideoCaptureDevice(); talk_base::scoped_refptr<webrtc::VideoCaptureModule> OpenVideoCaptureDevice();
// //
// PeerConnectionObserver implementation. // PeerConnectionObserver implementation.
@ -103,13 +103,14 @@ class Conductor
protected: protected:
int peer_id_; int peer_id_;
scoped_refptr<webrtc::PeerConnection> peer_connection_; talk_base::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_;
scoped_refptr<webrtc::PeerConnectionManager> peer_connection_factory_; talk_base::scoped_refptr<webrtc::PeerConnectionManager>
peer_connection_factory_;
PeerConnectionClient* client_; PeerConnectionClient* client_;
MainWindow* main_wnd_; MainWindow* main_wnd_;
std::deque<std::string*> pending_messages_; std::deque<std::string*> pending_messages_;
std::map<std::string, std::map<std::string, talk_base::scoped_refptr<webrtc::MediaStreamInterface> >
scoped_refptr<webrtc::MediaStreamInterface> > active_streams_; active_streams_;
}; };
#endif // PEERCONNECTION_SAMPLES_CLIENT_CONDUCTOR_H_ #endif // PEERCONNECTION_SAMPLES_CLIENT_CONDUCTOR_H_

View File

@ -107,8 +107,10 @@ class GtkMainWnd : public MainWindow {
MainWndCallback* callback_; MainWndCallback* callback_;
std::string server_; std::string server_;
std::string port_; std::string port_;
scoped_refptr<webrtc::VideoRendererWrapperInterface> local_renderer_wrapper_; talk_base::scoped_refptr<webrtc::VideoRendererWrapperInterface>
scoped_refptr<webrtc::VideoRendererWrapperInterface> remote_renderer_wrapper_; local_renderer_wrapper_;
talk_base::scoped_refptr<webrtc::VideoRendererWrapperInterface>
remote_renderer_wrapper_;
talk_base::scoped_ptr<uint8> draw_buffer_; talk_base::scoped_ptr<uint8> draw_buffer_;
int draw_buffer_size_; int draw_buffer_size_;
}; };