From f553ec70c7c3a830c112e37811ce050dbd15d6bc Mon Sep 17 00:00:00 2001 From: "mallinath@webrtc.org" Date: Thu, 20 Oct 2011 06:24:24 +0000 Subject: [PATCH] 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 --- .../talk/app/webrtc_dev/audiotrackimpl.cc | 15 +-- .../talk/app/webrtc_dev/audiotrackimpl.h | 12 +- .../source/talk/app/webrtc_dev/mediastream.h | 38 ++++--- .../talk/app/webrtc_dev/mediastreamhandler.h | 14 +-- .../webrtc_dev/mediastreamhandler_unittest.cc | 24 ++-- .../talk/app/webrtc_dev/mediastreamimpl.cc | 17 +-- .../talk/app/webrtc_dev/mediastreamimpl.h | 16 +-- .../webrtc_dev/mediastreamimpl_unittest.cc | 14 +-- .../talk/app/webrtc_dev/mediastreamproxy.cc | 21 ++-- .../talk/app/webrtc_dev/mediastreamproxy.h | 18 +-- .../app/webrtc_dev/mediastreamtrackproxy.cc | 48 ++++---- .../app/webrtc_dev/mediastreamtrackproxy.h | 20 ++-- .../talk/app/webrtc_dev/mediatrackimpl.h | 10 +- .../source/talk/app/webrtc_dev/notifierimpl.h | 14 +-- .../talk/app/webrtc_dev/peerconnection.h | 104 +++++++++++++----- .../app/webrtc_dev/peerconnection_unittest.cc | 21 ++-- .../talk/app/webrtc_dev/peerconnectionimpl.cc | 26 +++-- .../talk/app/webrtc_dev/peerconnectionimpl.h | 14 +-- .../webrtc_dev/peerconnectionimpl_unittest.cc | 8 +- .../peerconnectionmanager_unittest.cc | 29 ++--- .../webrtc_dev/peerconnectionmanagerimpl.cc | 59 +++++----- .../webrtc_dev/peerconnectionmanagerimpl.h | 33 +++--- .../app/webrtc_dev/peerconnectionsignaling.cc | 83 ++++++++------ .../app/webrtc_dev/peerconnectionsignaling.h | 18 +-- .../peerconnectionsignaling_unittest.cc | 51 ++++----- .../source/talk/app/webrtc_dev/ref_count.h | 18 +-- .../talk/app/webrtc_dev/scoped_refptr.h | 4 + .../talk/app/webrtc_dev/scoped_refptr_msg.h | 10 +- .../app/webrtc_dev/streamcollectionimpl.h | 17 +-- .../talk/app/webrtc_dev/videorendererimpl.cc | 6 +- .../talk/app/webrtc_dev/videotrackimpl.cc | 14 +-- .../talk/app/webrtc_dev/videotrackimpl.h | 13 ++- .../peerconnection_client/conductor.cc | 18 +-- .../peerconnection_client/conductor.h | 11 +- .../peerconnection_client/linux/main_wnd.h | 6 +- 35 files changed, 469 insertions(+), 375 deletions(-) diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/audiotrackimpl.cc b/third_party_mods/libjingle/source/talk/app/webrtc_dev/audiotrackimpl.cc index f9eca6d07d..1cce054f60 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/audiotrackimpl.cc +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/audiotrackimpl.cc @@ -53,18 +53,19 @@ const char* AudioTrack::kind() const { return kAudioTrackKind; } -scoped_refptr AudioTrack::CreateRemote(const std::string& label, - uint32 ssrc) { - talk_base::RefCountImpl* track = - new talk_base::RefCountImpl(label, ssrc); +talk_base::scoped_refptr AudioTrack::CreateRemote( + const std::string& label, + uint32 ssrc) { + talk_base::RefCount* track = + new talk_base::RefCount(label, ssrc); return track; } -scoped_refptr AudioTrack::CreateLocal( +talk_base::scoped_refptr AudioTrack::CreateLocal( const std::string& label, AudioDeviceModule* audio_device) { - talk_base::RefCountImpl* track = - new talk_base::RefCountImpl(label, audio_device); + talk_base::RefCount* track = + new talk_base::RefCount(label, audio_device); return track; } diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/audiotrackimpl.h b/third_party_mods/libjingle/source/talk/app/webrtc_dev/audiotrackimpl.h index 4e80bfad25..0caf1655c6 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/audiotrackimpl.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/audiotrackimpl.h @@ -44,11 +44,13 @@ namespace webrtc { class AudioTrack : public MediaTrack { public: // Creates a remote audio track. - static scoped_refptr CreateRemote(const std::string& label, - uint32 ssrc); + static talk_base::scoped_refptr CreateRemote( + const std::string& label, + uint32 ssrc); // Creates a local audio track. - static scoped_refptr CreateLocal(const std::string& label, - AudioDeviceModule* audio_device); + static talk_base::scoped_refptr CreateLocal( + const std::string& label, + AudioDeviceModule* audio_device); // Get the AudioDeviceModule associated with this track. virtual AudioDeviceModule* GetAudioDevice(); @@ -61,7 +63,7 @@ class AudioTrack : public MediaTrack { AudioTrack(const std::string& label, AudioDeviceModule* audio_device); private: - scoped_refptr audio_device_; + talk_base::scoped_refptr audio_device_; }; } // namespace webrtc diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastream.h b/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastream.h index c7acea9a35..68e1dfe97c 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastream.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastream.h @@ -25,6 +25,12 @@ * 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_ #define TALK_APP_WEBRTC_MEDIASTREAM_H_ @@ -45,25 +51,25 @@ class AudioDeviceModule; class VideoCaptureModule; // Generic observer interface. -class Observer { +class ObserverInterface { public: virtual void OnChanged() = 0; protected: - virtual ~Observer() {} + virtual ~ObserverInterface() {} }; -class Notifier { +class NotifierInterface { public: - virtual void RegisterObserver(Observer* observer) = 0; - virtual void UnregisterObserver(Observer* observer) = 0; + virtual void RegisterObserver(ObserverInterface* observer) = 0; + virtual void UnregisterObserver(ObserverInterface* observer) = 0; - virtual ~Notifier() {} + virtual ~NotifierInterface() {} }; // Information about a track. -class MediaStreamTrackInterface : public talk_base::RefCount, - public Notifier { +class MediaStreamTrackInterface : public talk_base::RefCountInterface, + public NotifierInterface { public: enum TrackState { kInitializing, // Track is beeing negotiated. @@ -78,13 +84,13 @@ class MediaStreamTrackInterface : public talk_base::RefCount, virtual bool enabled() const = 0; virtual TrackState state() const = 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_state(TrackState new_state) = 0; }; // Reference counted wrapper for a VideoRenderer. -class VideoRendererWrapperInterface : public talk_base::RefCount { +class VideoRendererWrapperInterface : public talk_base::RefCountInterface { public: virtual cricket::VideoRenderer* renderer() = 0; @@ -92,10 +98,10 @@ class VideoRendererWrapperInterface : public talk_base::RefCount { 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 // cricket::VideoRenderer. -scoped_refptr CreateVideoRenderer( +talk_base::scoped_refptr CreateVideoRenderer( cricket::VideoRenderer* renderer); class VideoTrackInterface : public MediaStreamTrackInterface { @@ -140,7 +146,7 @@ class LocalAudioTrackInterface : public AudioTrackInterface { // List of of tracks. template -class MediaStreamTrackListInterface : public talk_base::RefCount { +class MediaStreamTrackListInterface : public talk_base::RefCountInterface { public: virtual size_t count() = 0; virtual TrackType* at(size_t index) = 0; @@ -152,8 +158,8 @@ class MediaStreamTrackListInterface : public talk_base::RefCount { typedef MediaStreamTrackListInterface AudioTracks; typedef MediaStreamTrackListInterface VideoTracks; -class MediaStreamInterface : public talk_base::RefCount, - public Notifier { +class MediaStreamInterface : public talk_base::RefCountInterface, + public NotifierInterface { public: virtual std::string label() const = 0; virtual AudioTracks* audio_tracks() = 0; @@ -167,7 +173,7 @@ class MediaStreamInterface : public talk_base::RefCount, 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; protected: diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamhandler.h b/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamhandler.h index 560a590bdc..eabc552d5e 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamhandler.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamhandler.h @@ -45,7 +45,7 @@ namespace webrtc { // VideoTrackHandler listen to events on a VideoTrack instance and // executes the requested change. -class VideoTrackHandler : public Observer { +class VideoTrackHandler : public ObserverInterface { public: VideoTrackHandler(VideoTrackInterface* track, MediaProviderInterface* provider); @@ -63,7 +63,7 @@ class VideoTrackHandler : public Observer { private: MediaStreamTrackInterface::TrackState state_; bool enabled_; - scoped_refptr renderer_; + talk_base::scoped_refptr renderer_; }; class LocalVideoTrackHandler : public VideoTrackHandler { @@ -78,7 +78,7 @@ class LocalVideoTrackHandler : public VideoTrackHandler { virtual void OnEnabledChanged(); private: - scoped_refptr local_video_track_; + talk_base::scoped_refptr local_video_track_; }; class RemoteVideoTrackHandler : public VideoTrackHandler { @@ -93,10 +93,10 @@ class RemoteVideoTrackHandler : public VideoTrackHandler { virtual void OnEnabledChanged(); private: - scoped_refptr remote_video_track_; + talk_base::scoped_refptr remote_video_track_; }; -class MediaStreamHandler : public Observer { +class MediaStreamHandler : public ObserverInterface { public: MediaStreamHandler(MediaStreamInterface* stream, MediaProviderInterface* provider); @@ -108,7 +108,7 @@ class MediaStreamHandler : public Observer { MediaProviderInterface* provider_; typedef std::vector VideoTrackHandlers; VideoTrackHandlers video_handlers_; - scoped_refptr stream_; + talk_base::scoped_refptr stream_; }; class LocalMediaStreamHandler : public MediaStreamHandler { @@ -129,7 +129,7 @@ class MediaStreamHandlers { ~MediaStreamHandlers(); void AddRemoteStream(MediaStreamInterface* stream); void RemoveRemoteStream(MediaStreamInterface* stream); - void CommitLocalStreams(StreamCollection* streams); + void CommitLocalStreams(StreamCollectionInterface* streams); private: typedef std::list StreamHandlerList; diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamhandler_unittest.cc b/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamhandler_unittest.cc index ee925bf280..52c965b9e1 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamhandler_unittest.cc +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamhandler_unittest.cc @@ -68,25 +68,26 @@ class MockMediaProvier : public MediaProviderInterface { TEST(MediaStreamHandlerTest, LocalStreams) { // Create a local stream. std::string label(kStreamLabel1); - scoped_refptr stream( + talk_base::scoped_refptr stream( MediaStream::Create(label)); - scoped_refptr video_track(VideoTrack::CreateLocal( - kVideoDeviceName, NULL)); + talk_base::scoped_refptr + video_track(VideoTrack::CreateLocal(kVideoDeviceName, NULL)); video_track->set_ssrc(kVideoSsrc); EXPECT_TRUE(stream->AddTrack(video_track)); - scoped_refptr renderer( + talk_base::scoped_refptr renderer( CreateVideoRenderer(NULL)); video_track->SetRenderer(renderer); MockMediaProvier provider; MediaStreamHandlers handlers(&provider); - scoped_refptr collection( + talk_base::scoped_refptr collection( StreamCollectionImpl::Create()); collection->AddStream(stream); 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)) .Times(Exactly(1)); handlers.CommitLocalStreams(collection); @@ -108,10 +109,10 @@ TEST(MediaStreamHandlerTest, RemoteStreams) { // they are easier to create. // LocalMediaStreams inherit from MediaStreams. std::string label(kStreamLabel1); - scoped_refptr stream( + talk_base::scoped_refptr stream( MediaStream::Create(label)); - scoped_refptr video_track(VideoTrack::CreateLocal( - kVideoDeviceName, NULL)); + talk_base::scoped_refptr + video_track(VideoTrack::CreateLocal(kVideoDeviceName, NULL)); video_track->set_ssrc(kVideoSsrc); EXPECT_TRUE(stream->AddTrack(video_track)); @@ -121,10 +122,11 @@ TEST(MediaStreamHandlerTest, RemoteStreams) { handlers.AddRemoteStream(stream); EXPECT_CALL(provider, SetRemoteRenderer(kVideoSsrc)) - .Times(Exactly(2)); + .Times(Exactly(3)); // SetRemoteRenderer is also called from dtor of + // RemoteVideoTrackHandler. // Set the renderer once. - scoped_refptr renderer( + talk_base::scoped_refptr renderer( CreateVideoRenderer(NULL)); video_track->SetRenderer(renderer); talk_base::Thread::Current()->ProcessMessages(1); diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamimpl.cc b/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamimpl.cc index 00e5a5dafa..ee2293974f 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamimpl.cc +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamimpl.cc @@ -30,15 +30,10 @@ namespace webrtc { -scoped_refptr CreateLocalMediaStream( +talk_base::scoped_refptr MediaStream::Create( const std::string& label) { - return MediaStream::Create(label); -} - -scoped_refptr MediaStream::Create( - const std::string& label) { - talk_base::RefCountImpl* stream = - new talk_base::RefCountImpl(label); + talk_base::RefCount* stream = + new talk_base::RefCount(label); return stream; } @@ -46,10 +41,10 @@ MediaStream::MediaStream(const std::string& label) : label_(label), ready_state_(MediaStreamInterface::kInitializing), audio_track_list_( - new talk_base::RefCountImpl< + new talk_base::RefCount< MediaStreamTrackList >()), video_track_list_( - new talk_base::RefCountImpl< + new talk_base::RefCount< MediaStreamTrackList >()) { } @@ -57,7 +52,7 @@ void MediaStream::set_ready_state( MediaStreamInterface::ReadyState new_state) { if (ready_state_ != new_state) { ready_state_ = new_state; - NotifierImpl::FireOnChanged(); + Notifier::FireOnChanged(); } } diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamimpl.h b/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamimpl.h index 6aa274b950..f5225c8fa1 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamimpl.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamimpl.h @@ -25,6 +25,8 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +// This file contains the implementation of MediaStreamInterface interface. + #ifndef TALK_APP_WEBRTC_MEDIASTREAMIMPL_H_ #define TALK_APP_WEBRTC_MEDIASTREAMIMPL_H_ @@ -38,12 +40,10 @@ namespace webrtc { class AudioTrack; class VideoTrack; -class MediaStream - : public NotifierImpl { +class MediaStream : public Notifier { public: template - class MediaStreamTrackList : - public MediaStreamTrackListInterface { + class MediaStreamTrackList : public MediaStreamTrackListInterface { public: void AddTrack(T* track) { tracks_.push_back(track); @@ -54,10 +54,10 @@ class MediaStream } private: - std::vector > tracks_; + std::vector > tracks_; }; - static scoped_refptr Create(const std::string& label); + static talk_base::scoped_refptr Create(const std::string& label); // Implement LocalMediaStreamInterface. virtual bool AddTrack(AudioTrackInterface* track); @@ -79,9 +79,9 @@ class MediaStream std::string label_; MediaStreamInterface::ReadyState ready_state_; - scoped_refptr > + talk_base::scoped_refptr > audio_track_list_; - scoped_refptr > + talk_base::scoped_refptr > video_track_list_; }; diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamimpl_unittest.cc b/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamimpl_unittest.cc index cbd42371f6..cdf2e372f7 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamimpl_unittest.cc +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamimpl_unittest.cc @@ -37,7 +37,7 @@ static const char kVideoDeviceName[] = "dummy_video_cam_1"; namespace webrtc { // Helper class to test the Observer. -class TestObserver : public Observer { +class TestObserver : public ObserverInterface { public: TestObserver() : changed_(0) {} void OnChanged() { @@ -57,7 +57,7 @@ class TestObserver : public Observer { TEST(LocalStreamTest, Create) { // Create a local stream. std::string label(kStreamLabel1); - scoped_refptr stream( + talk_base::scoped_refptr stream( MediaStream::Create(label)); EXPECT_EQ(label, stream->label()); @@ -66,17 +66,17 @@ TEST(LocalStreamTest, Create) { // Create a local Video track. TestObserver tracklist_observer; - scoped_refptr video_track(VideoTrack::CreateLocal( - kVideoDeviceName, NULL)); + talk_base::scoped_refptr + video_track(VideoTrack::CreateLocal(kVideoDeviceName, NULL)); // Add an observer to the track list. - scoped_refptr > track_list( - stream->video_tracks()); + talk_base::scoped_refptr > + track_list(stream->video_tracks()); // Add the track to the local stream. EXPECT_TRUE(stream->AddTrack(video_track)); EXPECT_EQ(1u, stream->video_tracks()->count()); // Verify the track. - scoped_refptr track( + talk_base::scoped_refptr track( stream->video_tracks()->at(0)); EXPECT_EQ(0, track->label().compare(kVideoDeviceName)); EXPECT_TRUE(track->enabled()); diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamproxy.cc b/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamproxy.cc index ecafa8bef5..c6020ed66c 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamproxy.cc +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamproxy.cc @@ -45,7 +45,8 @@ enum { typedef talk_base::TypedMessageData LabelMessageData; typedef talk_base::TypedMessageData SizeTMessageData; -typedef talk_base::TypedMessageData ObserverMessageData; +typedef talk_base::TypedMessageData + ObserverMessageData; typedef talk_base::TypedMessageData ReadyStateMessageData; @@ -57,7 +58,7 @@ class MediaStreamTrackMessageData : public talk_base::MessageData { result_(false) { } - scoped_refptr track_; + talk_base::scoped_refptr track_; bool result_; }; @@ -74,19 +75,19 @@ class MediaStreamTrackAtMessageData : public talk_base::MessageData { } size_t index_; - scoped_refptr track_; + talk_base::scoped_refptr track_; }; } // namespace anonymous namespace webrtc { -scoped_refptr MediaStreamProxy::Create( +talk_base::scoped_refptr MediaStreamProxy::Create( const std::string& label, talk_base::Thread* signaling_thread) { ASSERT(signaling_thread); - talk_base::RefCountImpl* stream = - new talk_base::RefCountImpl(label, signaling_thread); + talk_base::RefCount* stream = + new talk_base::RefCount(label, signaling_thread); return stream; } @@ -94,11 +95,11 @@ MediaStreamProxy::MediaStreamProxy(const std::string& label, talk_base::Thread* signaling_thread) : signaling_thread_(signaling_thread), media_stream_impl_(MediaStream::Create(label)), - audio_tracks_(new talk_base::RefCountImpl< + audio_tracks_(new talk_base::RefCount< MediaStreamTrackListProxy >( media_stream_impl_->audio_tracks(), signaling_thread_)), - video_tracks_(new talk_base::RefCountImpl< + video_tracks_(new talk_base::RefCount< MediaStreamTrackListProxy >( media_stream_impl_->video_tracks(), signaling_thread_)) { @@ -151,7 +152,7 @@ bool MediaStreamProxy::AddTrack(VideoTrackInterface* track) { return media_stream_impl_->AddTrack(track); } -void MediaStreamProxy::RegisterObserver(Observer* observer) { +void MediaStreamProxy::RegisterObserver(ObserverInterface* observer) { if (!signaling_thread_->IsCurrent()) { ObserverMessageData msg(observer); Send(MSG_REGISTER_OBSERVER, &msg); @@ -160,7 +161,7 @@ void MediaStreamProxy::RegisterObserver(Observer* observer) { media_stream_impl_->RegisterObserver(observer); } -void MediaStreamProxy::UnregisterObserver(Observer* observer) { +void MediaStreamProxy::UnregisterObserver(ObserverInterface* observer) { if (!signaling_thread_->IsCurrent()) { ObserverMessageData msg(observer); Send(MSG_UNREGISTER_OBSERVER, &msg); diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamproxy.h b/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamproxy.h index 6ceea13237..8ef1dfba16 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamproxy.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamproxy.h @@ -55,11 +55,11 @@ class MediaStreamProxy : public LocalMediaStreamInterface, void Send(uint32 id, talk_base::MessageData* data) const; void OnMessage(talk_base::Message* msg); - scoped_refptr > track_list_; + talk_base::scoped_refptr > track_list_; mutable talk_base::Thread* signaling_thread_; }; - static scoped_refptr Create( + static talk_base::scoped_refptr Create( const std::string& label, talk_base::Thread* signaling_thread); @@ -72,18 +72,18 @@ class MediaStreamProxy : public LocalMediaStreamInterface, // Implement MediaStream. virtual std::string label() const; - virtual MediaStreamTrackListProxy* audio_tracks() { + virtual AudioTracks* audio_tracks() { return audio_tracks_; } - virtual MediaStreamTrackListProxy* video_tracks() { + virtual VideoTracks* video_tracks() { return video_tracks_; } virtual ReadyState ready_state(); virtual void set_ready_state(ReadyState new_state); // Implement Notifier - virtual void RegisterObserver(Observer* observer); - virtual void UnregisterObserver(Observer* observer); + virtual void RegisterObserver(ObserverInterface* observer); + virtual void UnregisterObserver(ObserverInterface* observer); protected: explicit MediaStreamProxy(const std::string& label, @@ -94,9 +94,9 @@ class MediaStreamProxy : public LocalMediaStreamInterface, virtual void OnMessage(talk_base::Message* msg); mutable talk_base::Thread* signaling_thread_; - scoped_refptr media_stream_impl_; - scoped_refptr > audio_tracks_; - scoped_refptr > video_tracks_; + talk_base::scoped_refptr media_stream_impl_; + talk_base::scoped_refptr audio_tracks_; + talk_base::scoped_refptr video_tracks_; }; } // namespace webrtc diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamtrackproxy.cc b/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamtrackproxy.cc index 32d87901a0..a56b64e884 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamtrackproxy.cc +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamtrackproxy.cc @@ -45,7 +45,8 @@ enum { }; typedef talk_base::TypedMessageData LabelMessageData; -typedef talk_base::TypedMessageData ObserverMessageData; +typedef talk_base::TypedMessageData + ObserverMessageData; typedef talk_base::TypedMessageData TrackStateMessageData; typedef talk_base::TypedMessageData SsrcMessageData; @@ -54,17 +55,18 @@ typedef talk_base::TypedMessageData EnableMessageData; class AudioDeviceMessageData : public talk_base::MessageData { public: - scoped_refptr audio_device_; + talk_base::scoped_refptr audio_device_; }; class VideoDeviceMessageData : public talk_base::MessageData { public: - scoped_refptr video_device_; + talk_base::scoped_refptr video_device_; }; class VideoRendererMessageData : public talk_base::MessageData { public: - scoped_refptr video_renderer_; + talk_base::scoped_refptr + video_renderer_; }; } // namespace anonymous @@ -160,7 +162,7 @@ bool MediaStreamTrackProxy::set_ssrc(uint32 ssrc) { } template -void MediaStreamTrackProxy::RegisterObserver(Observer* observer) { +void MediaStreamTrackProxy::RegisterObserver(ObserverInterface* observer) { if (!signaling_thread_->IsCurrent()) { ObserverMessageData msg(observer); Send(MSG_REGISTER_OBSERVER, &msg); @@ -170,7 +172,7 @@ void MediaStreamTrackProxy::RegisterObserver(Observer* observer) { } template -void MediaStreamTrackProxy::UnregisterObserver(Observer* observer) { +void MediaStreamTrackProxy::UnregisterObserver(ObserverInterface* observer) { if (!signaling_thread_->IsCurrent()) { ObserverMessageData msg(observer); Send(MSG_UNREGISTER_OBSERVER, &msg); @@ -254,26 +256,26 @@ AudioTrackProxy::AudioTrackProxy( Init(audio_track_); } -scoped_refptr AudioTrackProxy::CreateRemote( +talk_base::scoped_refptr AudioTrackProxy::CreateRemote( const std::string& label, uint32 ssrc, talk_base::Thread* signaling_thread) { ASSERT(signaling_thread); - talk_base::RefCountImpl* track = - new talk_base::RefCountImpl(label, ssrc, - signaling_thread); + talk_base::RefCount* track = + new talk_base::RefCount(label, ssrc, + signaling_thread); return track; } -scoped_refptr AudioTrackProxy::CreateLocal( +talk_base::scoped_refptr AudioTrackProxy::CreateLocal( const std::string& label, AudioDeviceModule* audio_device, talk_base::Thread* signaling_thread) { ASSERT(signaling_thread); - talk_base::RefCountImpl* track = - new talk_base::RefCountImpl(label, - audio_device, - signaling_thread); + talk_base::RefCount* track = + new talk_base::RefCount(label, + audio_device, + signaling_thread); return track; } @@ -316,25 +318,25 @@ VideoTrackProxy::VideoTrackProxy( Init(video_track_); } -scoped_refptr VideoTrackProxy::CreateRemote( +talk_base::scoped_refptr VideoTrackProxy::CreateRemote( const std::string& label, uint32 ssrc, talk_base::Thread* signaling_thread) { ASSERT(signaling_thread); - talk_base::RefCountImpl* track = - new talk_base::RefCountImpl(label, ssrc, - signaling_thread); + talk_base::RefCount* track = + new talk_base::RefCount(label, ssrc, + signaling_thread); return track; } -scoped_refptr VideoTrackProxy::CreateLocal( +talk_base::scoped_refptr VideoTrackProxy::CreateLocal( const std::string& label, VideoCaptureModule* video_device, talk_base::Thread* signaling_thread) { ASSERT(signaling_thread); - talk_base::RefCountImpl* track = - new talk_base::RefCountImpl(label, video_device, - signaling_thread); + talk_base::RefCount* track = + new talk_base::RefCount(label, video_device, + signaling_thread); return track; } diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamtrackproxy.h b/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamtrackproxy.h index fb64548e0f..8b0b4ffc57 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamtrackproxy.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediastreamtrackproxy.h @@ -58,8 +58,8 @@ class MediaStreamTrackProxy : public T, virtual bool set_state(MediaStreamTrackInterface::TrackState new_state); // Implement Notifier - virtual void RegisterObserver(Observer* observer); - virtual void UnregisterObserver(Observer* observer); + virtual void RegisterObserver(ObserverInterface* observer); + virtual void UnregisterObserver(ObserverInterface* observer); protected: 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. class AudioTrackProxy : public MediaStreamTrackProxy { public: - static scoped_refptr CreateRemote( + static talk_base::scoped_refptr CreateRemote( const std::string& label, uint32 ssrc, talk_base::Thread* signaling_thread); - static scoped_refptr CreateLocal( + static talk_base::scoped_refptr CreateLocal( const std::string& label, AudioDeviceModule* audio_device, talk_base::Thread* signaling_thread); @@ -93,12 +93,12 @@ class AudioTrackProxy : public MediaStreamTrackProxy { uint32 ssrc, talk_base::Thread* signaling_thread); AudioTrackProxy(const std::string& label, - AudioDeviceModule* audio_device, - talk_base::Thread* signaling_thread); + AudioDeviceModule* audio_device, + talk_base::Thread* signaling_thread); // Implement MessageHandler virtual void OnMessage(talk_base::Message* msg); - scoped_refptr audio_track_; + talk_base::scoped_refptr audio_track_; }; // VideoTrackProxy is a proxy for the VideoTrackInterface and @@ -107,11 +107,11 @@ class AudioTrackProxy : public MediaStreamTrackProxy { // It can be used as a proxy for both local and remote video tracks. class VideoTrackProxy : public MediaStreamTrackProxy { public: - static scoped_refptr CreateRemote( + static talk_base::scoped_refptr CreateRemote( const std::string& label, uint32 ssrc, talk_base::Thread* signaling_thread); - static scoped_refptr CreateLocal( + static talk_base::scoped_refptr CreateLocal( const std::string& label, VideoCaptureModule* video_device, talk_base::Thread* signaling_thread); @@ -130,7 +130,7 @@ class VideoTrackProxy : public MediaStreamTrackProxy { // Implement MessageHandler virtual void OnMessage(talk_base::Message* msg); - scoped_refptr video_track_; + talk_base::scoped_refptr video_track_; }; } // namespace webrtc diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediatrackimpl.h b/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediatrackimpl.h index 96263d9af9..a168c9f424 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediatrackimpl.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/mediatrackimpl.h @@ -35,8 +35,10 @@ namespace webrtc { +// MediaTrack implements the interface common to AudioTrackInterface and +// VideoTrackInterface. template -class MediaTrack : public NotifierImpl { +class MediaTrack : public Notifier { public: typedef typename T::TrackState TypedTrackState; @@ -48,7 +50,7 @@ class MediaTrack : public NotifierImpl { bool fire_on_change = (enable != enabled_); enabled_ = enable; if (fire_on_change) { - NotifierImpl::FireOnChanged(); + Notifier::FireOnChanged(); } } @@ -58,7 +60,7 @@ class MediaTrack : public NotifierImpl { if (ssrc_ != 0) return false; ssrc_ = ssrc; - NotifierImpl::FireOnChanged(); + Notifier::FireOnChanged(); return true; } @@ -66,7 +68,7 @@ class MediaTrack : public NotifierImpl { bool fire_on_change = (state_ != new_state); state_ = new_state; if (fire_on_change) - NotifierImpl::FireOnChanged(); + Notifier::FireOnChanged(); return true; } diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/notifierimpl.h b/third_party_mods/libjingle/source/talk/app/webrtc_dev/notifierimpl.h index 2a24c811c0..c8c9a549d8 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/notifierimpl.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/notifierimpl.h @@ -37,18 +37,18 @@ namespace webrtc { // Implement a template version of a notifier. template -class NotifierImpl : public T { +class Notifier : public T { public: - NotifierImpl() { + Notifier() { } - virtual void RegisterObserver(Observer* observer) { + virtual void RegisterObserver(ObserverInterface* observer) { ASSERT(observer != NULL); observers_.push_back(observer); } - virtual void UnregisterObserver(Observer* observer) { - for (std::list::iterator it = observers_.begin(); + virtual void UnregisterObserver(ObserverInterface* observer) { + for (std::list::iterator it = observers_.begin(); it != observers_.end(); it++) { if (*it == observer) { observers_.erase(it); @@ -58,14 +58,14 @@ class NotifierImpl : public T { } void FireOnChanged() { - for (std::list::iterator it = observers_.begin(); + for (std::list::iterator it = observers_.begin(); it != observers_.end(); ++it) { (*it)-> OnChanged(); } } protected: - std::list observers_; + std::list observers_; }; } // namespace webrtc diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnection.h b/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnection.h index 3173a60442..946a81afbb 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnection.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnection.h @@ -25,6 +25,47 @@ * 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_ #define TALK_APP_WEBRTC_PEERCONNECTION_H_ @@ -39,18 +80,19 @@ namespace talk_base { } namespace webrtc { - -class StreamCollection : public talk_base::RefCount { +// MediaStream container interface. +class StreamCollectionInterface : public talk_base::RefCountInterface { public: virtual size_t count() = 0; virtual MediaStreamInterface* at(size_t index) = 0; virtual MediaStreamInterface* find(const std::string& label) = 0; protected: // Dtor protected as objects shouldn't be deleted via this interface. - ~StreamCollection() {} + ~StreamCollectionInterface() {} }; -///////////////////////////////////////////// +// PeerConnection callback interface. Application should implement these +// methods. class PeerConnectionObserver { public: enum Readiness { @@ -79,7 +121,7 @@ class PeerConnectionObserver { }; -class PeerConnection : public talk_base::RefCount { +class PeerConnectionInterface : public talk_base::RefCountInterface { public: // SignalingMessage in json format 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; // Accessor methods to active local streams. - virtual scoped_refptr local_streams() = 0; + virtual talk_base::scoped_refptr + local_streams() = 0; // Accessor methods to remote streams. - virtual scoped_refptr remote_streams() = 0; + virtual talk_base::scoped_refptr + remote_streams() = 0; // Add a new local stream. // This function does not trigger any changes to the stream until @@ -109,13 +153,13 @@ class PeerConnection : public talk_base::RefCount { protected: // Dtor protected as objects shouldn't be deleted via this interface. - ~PeerConnection() {} + ~PeerConnectionInterface() {} }; // Reference counted wrapper for talk_base::NetworkManager. -class PcNetworkManager : public talk_base::RefCount { +class PcNetworkManager : public talk_base::RefCountInterface { public: - static scoped_refptr Create( + static talk_base::scoped_refptr Create( talk_base::NetworkManager* network_manager); virtual talk_base::NetworkManager* network_manager() const; @@ -127,9 +171,9 @@ class PcNetworkManager : public talk_base::RefCount { }; // Reference counted wrapper for talk_base::PacketSocketFactory. -class PcPacketSocketFactory : public talk_base::RefCount { +class PcPacketSocketFactory : public talk_base::RefCountInterface { public: - static scoped_refptr Create( + static talk_base::scoped_refptr Create( talk_base::PacketSocketFactory* socket_factory); virtual talk_base::PacketSocketFactory* socket_factory() const; @@ -141,36 +185,42 @@ class PcPacketSocketFactory : public talk_base::RefCount { 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: // Create a new instance of PeerConnectionManager. - static scoped_refptr Create(); + static talk_base::scoped_refptr Create(); // Create a new instance of PeerConnectionManager. // Ownership of the arguments are not transfered to this object and must // remain in scope for the lifetime of the PeerConnectionManager. - static scoped_refptr Create( + static talk_base::scoped_refptr Create( talk_base::Thread* worker_thread, talk_base::Thread* signaling_thread, PcNetworkManager* network_manager, PcPacketSocketFactory* packet_socket_factory, AudioDeviceModule* default_adm); - virtual scoped_refptr CreatePeerConnection( - const std::string& config, - PeerConnectionObserver* observer) = 0; + virtual talk_base::scoped_refptr + CreatePeerConnection(const std::string& config, + PeerConnectionObserver* observer) = 0; - virtual scoped_refptr CreateLocalMediaStream( - const std::string& label) = 0; + virtual talk_base::scoped_refptr + CreateLocalMediaStream(const std::string& label) = 0; - virtual scoped_refptr CreateLocalVideoTrack( - const std::string& label, - VideoCaptureModule* video_device) = 0; - - virtual scoped_refptr CreateLocalAudioTrack( - const std::string& label, - AudioDeviceModule* audio_device) = 0; + virtual talk_base::scoped_refptr + CreateLocalVideoTrack(const std::string& label, + VideoCaptureModule* video_device) = 0; + virtual talk_base::scoped_refptr + CreateLocalAudioTrack(const std::string& label, + AudioDeviceModule* audio_device) = 0; protected: // Dtor protected as objects shouldn't be deleted via this interface. diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnection_unittest.cc b/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnection_unittest.cc index 9a2a9805a7..92759b1d42 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnection_unittest.cc +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnection_unittest.cc @@ -48,10 +48,10 @@ void GetAllVideoTracks(webrtc::MediaStreamInterface* media_stream, } // TODO(henrike): replace with a capture device that reads from a file/buffer. -scoped_refptr OpenVideoCaptureDevice() { +talk_base::scoped_refptr OpenVideoCaptureDevice() { webrtc::VideoCaptureModule::DeviceInfo* device_info( webrtc::VideoCaptureFactory::CreateDeviceInfo(0)); - scoped_refptr video_device; + talk_base::scoped_refptr video_device; const size_t kMaxDeviceNameLength = 128; const size_t kMaxUniqueIdLength = 256; @@ -175,22 +175,22 @@ class PeerConnectionP2PTestClient ~PeerConnectionP2PTestClient() { // Ensure that webrtc::PeerConnection is deleted before // webrtc::PeerConnectionManager or crash will occur - webrtc::PeerConnection* temp = peer_connection_.release(); + webrtc::PeerConnectionInterface* temp = peer_connection_.release(); temp->Release(); } void StartSession() { // Audio track doesn't seem to be implemented yet. No need to pass a device // to it. - scoped_refptr audio_track( + talk_base::scoped_refptr audio_track( peer_connection_factory_->CreateLocalAudioTrack("audio_track", NULL)); - scoped_refptr video_track( + talk_base::scoped_refptr video_track( peer_connection_factory_->CreateLocalVideoTrack( "video_track", OpenVideoCaptureDevice())); - scoped_refptr stream = + talk_base::scoped_refptr stream = peer_connection_factory_->CreateLocalMediaStream("stream_label"); stream->AddTrack(audio_track); @@ -231,8 +231,8 @@ class PeerConnectionP2PTestClient ++iter) { char file_name[256]; GenerateRecordingFileName(track_id, file_name); - scoped_refptr video_renderer = - webrtc::CreateVideoRenderer( + talk_base::scoped_refptr + video_renderer = webrtc::CreateVideoRenderer( VideoRecorder::CreateVideoRecorder(file_name)); if (video_renderer == NULL) { ADD_FAILURE(); @@ -277,8 +277,9 @@ class PeerConnectionP2PTestClient } int id_; - scoped_refptr peer_connection_; - scoped_refptr peer_connection_factory_; + talk_base::scoped_refptr peer_connection_; + talk_base::scoped_refptr + peer_connection_factory_; // Remote peer communication. SignalingMessageReceiver* signaling_message_receiver_; diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionimpl.cc b/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionimpl.cc index 166c39cad4..b291130f5c 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionimpl.cc +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionimpl.cc @@ -110,11 +110,11 @@ bool static ParseConfigString(const std::string& config, struct SignalingParams : public talk_base::MessageData { SignalingParams(const std::string& msg, - webrtc::StreamCollection* local_streams) + webrtc::StreamCollectionInterface* local_streams) : msg(msg), local_streams(local_streams) {} const std::string msg; - scoped_refptr local_streams; + talk_base::scoped_refptr local_streams; }; } // namespace @@ -199,13 +199,15 @@ bool PeerConnectionImpl::Initialize(const std::string& configuration, return session_->Initialize(); } -scoped_refptr PeerConnectionImpl::local_streams() { +talk_base::scoped_refptr +PeerConnectionImpl::local_streams() { return local_media_streams_; } -scoped_refptr PeerConnectionImpl::remote_streams() { - ScopedRefMessageData* msg = - new ScopedRefMessageData(NULL); +talk_base::scoped_refptr +PeerConnectionImpl::remote_streams() { + ScopedRefMessageData* msg = + new ScopedRefMessageData(NULL); signaling_thread_->Send(this, MSG_RETURNREMOTEMEDIASTREAMS, msg); return msg->data(); } @@ -226,8 +228,8 @@ void PeerConnectionImpl::RemoveStream( } void PeerConnectionImpl::CommitStreamChanges() { - ScopedRefMessageData* msg = - new ScopedRefMessageData ( + ScopedRefMessageData* msg = + new ScopedRefMessageData ( StreamCollectionImpl::Create(local_media_streams_)); signaling_thread_->Post(this, MSG_COMMITSTREAMCHANGES, msg); } @@ -236,8 +238,8 @@ void PeerConnectionImpl::OnMessage(talk_base::Message* msg) { talk_base::MessageData* data = msg->pdata; switch (msg->message_id) { case MSG_COMMITSTREAMCHANGES: { - ScopedRefMessageData* param( - static_cast*> (data)); + ScopedRefMessageData* param( + static_cast*> (data)); signaling_->CreateOffer(param->data()); stream_handler_->CommitLocalStreams(param->data()); delete data; // Because it is Posted. @@ -250,8 +252,8 @@ void PeerConnectionImpl::OnMessage(talk_base::Message* msg) { break; } case MSG_RETURNREMOTEMEDIASTREAMS: { - ScopedRefMessageData* param( - static_cast*> (data)); + ScopedRefMessageData* param( + static_cast*> (data)); param->data() = StreamCollectionImpl::Create(remote_media_streams_); break; } diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionimpl.h b/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionimpl.h index e404703241..589f98fbe9 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionimpl.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionimpl.h @@ -49,7 +49,7 @@ class StreamCollectionImpl; // PeerConnectionImpl implements the PeerConnection interface. // It uses PeerConnectionSignaling and WebRtcSession to implement // the PeerConnection functionality. -class PeerConnectionImpl : public PeerConnection, +class PeerConnectionImpl : public PeerConnectionInterface, public talk_base::MessageHandler, public sigslot::has_slots<> { public: @@ -69,8 +69,8 @@ class PeerConnectionImpl : public PeerConnection, // TODO(perkj): implement ASSERT(false); } - virtual scoped_refptr local_streams(); - virtual scoped_refptr remote_streams(); + virtual talk_base::scoped_refptr local_streams(); + virtual talk_base::scoped_refptr remote_streams(); virtual void AddStream(LocalMediaStreamInterface* stream); virtual void RemoveStream(LocalMediaStreamInterface* stream); virtual void CommitStreamChanges(); @@ -87,13 +87,13 @@ class PeerConnectionImpl : public PeerConnection, void Terminate_s(); PeerConnectionObserver* observer_; - scoped_refptr local_media_streams_; - scoped_refptr remote_media_streams_; + talk_base::scoped_refptr local_media_streams_; + talk_base::scoped_refptr remote_media_streams_; talk_base::Thread* signaling_thread_; // Weak ref from PeerConnectionManager. cricket::ChannelManager* channel_manager_; - scoped_refptr network_manager_; - scoped_refptr socket_factory_; + talk_base::scoped_refptr network_manager_; + talk_base::scoped_refptr socket_factory_; talk_base::scoped_ptr port_allocator_; talk_base::scoped_ptr session_; talk_base::scoped_ptr signaling_; diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionimpl_unittest.cc b/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionimpl_unittest.cc index d8d5dbab08..a70e8c47b1 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionimpl_unittest.cc +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionimpl_unittest.cc @@ -59,15 +59,15 @@ class PeerConnectionImplTest : public testing::Test { ASSERT_TRUE(pc_.get() != NULL); } - scoped_refptr pc_factory_; - scoped_refptr pc_; + talk_base::scoped_refptr pc_factory_; + talk_base::scoped_refptr pc_; MockPeerConnectionObserver observer_; }; -TEST_F(PeerConnectionImplTest, AddRemoveStream) { +TEST_F(PeerConnectionImplTest, DISABLED_AddRemoveStream) { // Create a local stream. std::string label(kStreamLabel1); - scoped_refptr stream( + talk_base::scoped_refptr stream( pc_factory_->CreateLocalMediaStream(label)); pc_->AddStream(stream); diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionmanager_unittest.cc b/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionmanager_unittest.cc index c42b9ae553..ced022ef52 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionmanager_unittest.cc +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionmanager_unittest.cc @@ -58,33 +58,34 @@ class MockPeerConnectionObserver : public PeerConnectionObserver { // TODO(mallinath) - Fix drash when components are created in factory. TEST(PeerConnectionManager, DISABLED_CreatePCUsingInternalModules) { MockPeerConnectionObserver observer; - scoped_refptr manager(PeerConnectionManager::Create()); + talk_base::scoped_refptr manager( + PeerConnectionManager::Create()); ASSERT_TRUE(manager.get() != NULL); - scoped_refptr pc1(manager->CreatePeerConnection("", - &observer)); + talk_base::scoped_refptr pc1( + manager->CreatePeerConnection("", &observer)); EXPECT_TRUE(pc1.get() == NULL); - scoped_refptr pc2(manager->CreatePeerConnection( - kStunConfiguration, &observer)); + talk_base::scoped_refptr pc2( + manager->CreatePeerConnection(kStunConfiguration, &observer)); EXPECT_TRUE(pc2.get() != NULL); } TEST(PeerConnectionManager, CreatePCUsingExternalModules) { // Create an audio device. Use the default sound card. - scoped_refptr audio_device( + talk_base::scoped_refptr audio_device( AudioDeviceModuleImpl::Create(0)); // Creata a libjingle thread used as internal worker thread. talk_base::scoped_ptr w_thread(new talk_base::Thread); EXPECT_TRUE(w_thread->Start()); - scoped_refptr network_manager(PcNetworkManager::Create( - new talk_base::BasicNetworkManager)); - scoped_refptr socket_factory( + talk_base::scoped_refptr network_manager( + PcNetworkManager::Create(new talk_base::BasicNetworkManager)); + talk_base::scoped_refptr socket_factory( PcPacketSocketFactory::Create(new talk_base::BasicPacketSocketFactory)); - scoped_refptr manager = + talk_base::scoped_refptr manager = PeerConnectionManager::Create(talk_base::Thread::Current(), talk_base::Thread::Current(), network_manager, @@ -93,13 +94,13 @@ TEST(PeerConnectionManager, CreatePCUsingExternalModules) { ASSERT_TRUE(manager.get() != NULL); MockPeerConnectionObserver observer; - scoped_refptr pc1(manager->CreatePeerConnection( - "", &observer)); + talk_base::scoped_refptr pc1( + manager->CreatePeerConnection("", &observer)); EXPECT_TRUE(pc1.get() == NULL); - scoped_refptr pc2(manager->CreatePeerConnection( - kStunConfiguration, &observer)); + talk_base::scoped_refptr pc2( + manager->CreatePeerConnection(kStunConfiguration, &observer)); EXPECT_TRUE(pc2.get() != NULL); } diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionmanagerimpl.cc b/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionmanagerimpl.cc index fc640c6e42..080c1bca21 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionmanagerimpl.cc +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionmanagerimpl.cc @@ -49,7 +49,7 @@ struct CreatePeerConnectionParams : public talk_base::MessageData { webrtc::PeerConnectionObserver* observer) : configuration(configuration), observer(observer) { } - scoped_refptr peerconnection; + talk_base::scoped_refptr peerconnection; const std::string& configuration; webrtc::PeerConnectionObserver* observer; }; @@ -64,10 +64,10 @@ enum { namespace webrtc { -scoped_refptr PcNetworkManager::Create( +talk_base::scoped_refptr PcNetworkManager::Create( talk_base::NetworkManager* network_manager) { - talk_base::RefCountImpl* implementation = - new talk_base::RefCountImpl(network_manager); + talk_base::RefCount* implementation = + new talk_base::RefCount(network_manager); return implementation; } @@ -83,10 +83,10 @@ PcNetworkManager::~PcNetworkManager() { delete network_manager_; } -scoped_refptr PcPacketSocketFactory::Create( +talk_base::scoped_refptr PcPacketSocketFactory::Create( talk_base::PacketSocketFactory* socket_factory) { - talk_base::RefCountImpl* implementation = - new talk_base::RefCountImpl(socket_factory); + talk_base::RefCount* implementation = + new talk_base::RefCount(socket_factory); return implementation; } @@ -103,9 +103,10 @@ talk_base::PacketSocketFactory* PcPacketSocketFactory::socket_factory() const { return socket_factory_; } -scoped_refptr PeerConnectionManager::Create() { - talk_base::RefCountImpl* pc_manager = - new talk_base::RefCountImpl(); +talk_base::scoped_refptr +PeerConnectionManager::Create() { + talk_base::RefCount* pc_manager = + new talk_base::RefCount(); if (!pc_manager->Initialize()) { delete pc_manager; @@ -114,18 +115,18 @@ scoped_refptr PeerConnectionManager::Create() { return pc_manager; } -scoped_refptr PeerConnectionManager::Create( +talk_base::scoped_refptr PeerConnectionManager::Create( talk_base::Thread* worker_thread, talk_base::Thread* signaling_thread, PcNetworkManager* network_manager, PcPacketSocketFactory* socket_factory, AudioDeviceModule* default_adm) { - talk_base::RefCountImpl* pc_manager = - new talk_base::RefCountImpl(worker_thread, - signaling_thread, - network_manager, - socket_factory, - default_adm); + talk_base::RefCount* pc_manager = + new talk_base::RefCount(worker_thread, + signaling_thread, + network_manager, + socket_factory, + default_adm); if (!pc_manager->Initialize()) { delete pc_manager; pc_manager = NULL; @@ -212,7 +213,8 @@ bool PeerConnectionManagerImpl::Initialize_s() { return true; } -scoped_refptr PeerConnectionManagerImpl::CreatePeerConnection( +talk_base::scoped_refptr +PeerConnectionManagerImpl::CreatePeerConnection( const std::string& configuration, PeerConnectionObserver* observer) { CreatePeerConnectionParams params(configuration, observer); @@ -220,15 +222,16 @@ scoped_refptr PeerConnectionManagerImpl::CreatePeerConnection( return params.peerconnection; } -scoped_refptr PeerConnectionManagerImpl::CreatePeerConnection_s( +talk_base::scoped_refptr +PeerConnectionManagerImpl::CreatePeerConnection_s( const std::string& configuration, PeerConnectionObserver* observer) { - talk_base::RefCountImpl* pc( - new talk_base::RefCountImpl(channel_manager_.get(), - signaling_thread_ptr_, - worker_thread_ptr_, - network_manager_, - socket_factory_)); + talk_base::RefCount* pc( + new talk_base::RefCount(channel_manager_.get(), + signaling_thread_ptr_, + worker_thread_ptr_, + network_manager_, + socket_factory_)); if (!pc->Initialize(configuration, observer)) { delete pc; pc = NULL; @@ -236,13 +239,13 @@ scoped_refptr PeerConnectionManagerImpl::CreatePeerConnection_s( return pc; } -scoped_refptr +talk_base::scoped_refptr PeerConnectionManagerImpl::CreateLocalMediaStream( const std::string& label) { return MediaStreamProxy::Create(label, signaling_thread_ptr_); } -scoped_refptr +talk_base::scoped_refptr PeerConnectionManagerImpl::CreateLocalVideoTrack( const std::string& label, VideoCaptureModule* video_device) { @@ -250,7 +253,7 @@ PeerConnectionManagerImpl::CreateLocalVideoTrack( signaling_thread_ptr_); } -scoped_refptr +talk_base::scoped_refptr PeerConnectionManagerImpl::CreateLocalAudioTrack( const std::string& label, AudioDeviceModule* audio_device) { diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionmanagerimpl.h b/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionmanagerimpl.h index fd57a06361..17bda5bdc0 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionmanagerimpl.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionmanagerimpl.h @@ -40,21 +40,21 @@ namespace webrtc { class PeerConnectionManagerImpl : public PeerConnectionManager, public talk_base::MessageHandler { public: - scoped_refptr CreatePeerConnection( + talk_base::scoped_refptr CreatePeerConnection( const std::string& config, PeerConnectionObserver* observer); bool Initialize(); - virtual scoped_refptr CreateLocalMediaStream( - const std::string& label); + virtual talk_base::scoped_refptr + CreateLocalMediaStream(const std::string& label); - virtual scoped_refptr CreateLocalVideoTrack( - const std::string& label, - VideoCaptureModule* video_device); + virtual talk_base::scoped_refptr + CreateLocalVideoTrack(const std::string& label, + VideoCaptureModule* video_device); - virtual scoped_refptr CreateLocalAudioTrack( - const std::string& label, - AudioDeviceModule* audio_device); + virtual talk_base::scoped_refptr + CreateLocalAudioTrack(const std::string& label, + AudioDeviceModule* audio_device); protected: PeerConnectionManagerImpl(); @@ -68,22 +68,21 @@ class PeerConnectionManagerImpl : public PeerConnectionManager, private: bool Initialize_s(); - scoped_refptr CreatePeerConnection_s( + talk_base::scoped_refptr CreatePeerConnection_s( const std::string& configuration, PeerConnectionObserver* observer); // Implements talk_base::MessageHandler. void OnMessage(talk_base::Message* msg); - talk_base::scoped_ptr worker_thread_; - talk_base::Thread* worker_thread_ptr_; talk_base::scoped_ptr signaling_thread_; talk_base::Thread* signaling_thread_ptr_; - scoped_refptr network_manager_; - scoped_refptr socket_factory_; - talk_base::scoped_ptr channel_manager_; - + talk_base::scoped_ptr worker_thread_; + talk_base::Thread* worker_thread_ptr_; + talk_base::scoped_refptr network_manager_; + talk_base::scoped_refptr socket_factory_; // External Audio device used for audio playback. - scoped_refptr default_adm_; + talk_base::scoped_refptr default_adm_; + talk_base::scoped_ptr channel_manager_; }; } // namespace webrtc diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionsignaling.cc b/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionsignaling.cc index b0a23c99f2..a0486bcb36 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionsignaling.cc +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionsignaling.cc @@ -117,7 +117,7 @@ void PeerConnectionSignaling::OnCandidatesReady( void PeerConnectionSignaling::ProcessSignalingMessage( const std::string& message, - StreamCollection* local_streams) { + StreamCollectionInterface* local_streams) { ASSERT(talk_base::Thread::Current() == signaling_thread_); talk_base::scoped_ptr signaling_message( @@ -169,7 +169,8 @@ void PeerConnectionSignaling::ProcessSignalingMessage( signaling_message->candidates()); provider_->NegotiationDone(); UpdateRemoteStreams(remote_desc); - scoped_refptr streams(queued_offers_.front()); + talk_base::scoped_refptr streams( + queued_offers_.front()); queued_offers_.pop_front(); UpdateSendingLocalStreams(remote_desc, streams); // 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_); queued_offers_.push_back(local_streams); if (state_ == kIdle) { @@ -219,7 +221,8 @@ void PeerConnectionSignaling::OnMessage(talk_base::Message* msg) { void PeerConnectionSignaling::CreateOffer_s() { ASSERT(queued_offers_.size() > 0); - scoped_refptr local_streams(queued_offers_.front()); + talk_base::scoped_refptr + local_streams(queued_offers_.front()); cricket::MediaSessionOptions options; InitMediaSessionOptions(&options, local_streams); @@ -241,7 +244,7 @@ void PeerConnectionSignaling::CreateAnswer_s() { talk_base::scoped_ptr message( queued_received_offer_.first); queued_received_offer_.first = NULL; - scoped_refptr local_streams( + talk_base::scoped_refptr local_streams( queued_received_offer_.second.release()); // 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. void PeerConnectionSignaling::InitMediaSessionOptions( cricket::MediaSessionOptions* options, - StreamCollection* local_streams) { + StreamCollectionInterface* local_streams) { // In order to be able to receive video, // the is_video should always be true even if there are not video tracks. options->is_video = true; for (size_t i = 0; i < local_streams->count(); ++i) { MediaStreamInterface* stream = local_streams->at(i); - scoped_refptr > + talk_base::scoped_refptr audio_tracks = stream->audio_tracks(); // For each audio track in the stream, add it to the MediaSessionOptions. for (size_t j = 0; j < audio_tracks->count(); ++j) { - scoped_refptr track = audio_tracks->at(j); + talk_base::scoped_refptr track = + audio_tracks->at(j); if (track->ssrc() == 0) track->set_ssrc(++ssrc_counter_); options->audio_sources.push_back(cricket::SourceParam(track->ssrc(), @@ -310,11 +314,12 @@ void PeerConnectionSignaling::InitMediaSessionOptions( stream->label())); } - scoped_refptr > + talk_base::scoped_refptr video_tracks = stream->video_tracks(); // For each video track in the stream, add it to the MediaSessionOptions. for (size_t j = 0; j < video_tracks->count(); ++j) { - scoped_refptr track = video_tracks->at(j); + talk_base::scoped_refptr track = + video_tracks->at(j); if (track->ssrc() == 0) track->set_ssrc(++ssrc_counter_); options->video_sources.push_back(cricket::SourceParam(track->ssrc(), @@ -332,7 +337,7 @@ void PeerConnectionSignaling::InitMediaSessionOptions( void PeerConnectionSignaling::UpdateRemoteStreams( const cricket::SessionDescription* remote_desc) { RemoteStreamMap current_streams; - typedef std::pair > + typedef std::pair > MediaStreamPair; const cricket::ContentInfo* audio_content = GetFirstAudioContent(remote_desc); @@ -352,19 +357,20 @@ void PeerConnectionSignaling::UpdateRemoteStreams( if (old_streams_it == remote_streams_.end()) { if (new_streams_it == current_streams.end()) { // New stream - scoped_refptr stream( + talk_base::scoped_refptr stream( MediaStreamProxy::Create(it->cname, signaling_thread_)); current_streams.insert(MediaStreamPair(stream->label(), stream)); new_streams_it = current_streams.find(it->cname); } - scoped_refptr track( + talk_base::scoped_refptr track( AudioTrackProxy::CreateRemote(it->description, it->ssrc, signaling_thread_)); track->set_state(MediaStreamTrackInterface::kLive); new_streams_it->second->AddTrack(track); } else { - scoped_refptr stream(old_streams_it->second); + talk_base::scoped_refptr stream( + old_streams_it->second); current_streams.insert(MediaStreamPair(stream->label(), stream)); } } @@ -387,19 +393,20 @@ void PeerConnectionSignaling::UpdateRemoteStreams( if (old_streams_it == remote_streams_.end()) { if (new_streams_it == current_streams.end()) { // New stream - scoped_refptr stream( + talk_base::scoped_refptr stream( MediaStreamProxy::Create(it->cname, signaling_thread_)); current_streams.insert(MediaStreamPair(stream->label(), stream)); new_streams_it = current_streams.find(it->cname); } - scoped_refptr track( + talk_base::scoped_refptr track( VideoTrackProxy::CreateRemote(it->description, it->ssrc, signaling_thread_)); new_streams_it->second->AddTrack(track); track->set_state(MediaStreamTrackInterface::kLive); } else { - scoped_refptr stream(old_streams_it->second); + talk_base::scoped_refptr + stream(old_streams_it->second); current_streams.insert(MediaStreamPair(stream->label(), stream)); } } @@ -410,7 +417,7 @@ void PeerConnectionSignaling::UpdateRemoteStreams( for (RemoteStreamMap::iterator it = current_streams.begin(); it != current_streams.end(); ++it) { - scoped_refptr new_stream(it->second); + talk_base::scoped_refptr new_stream(it->second); RemoteStreamMap::iterator old_streams_it = remote_streams_.find(new_stream->label()); if (old_streams_it == remote_streams_.end()) { @@ -425,17 +432,17 @@ void PeerConnectionSignaling::UpdateRemoteStreams( for (RemoteStreamMap::iterator it = remote_streams_.begin(); it != remote_streams_.end(); ++it) { - scoped_refptr old_stream(it->second); + talk_base::scoped_refptr old_stream(it->second); RemoteStreamMap::iterator new_streams_it = current_streams.find(old_stream->label()); if (new_streams_it == current_streams.end()) { old_stream->set_ready_state(MediaStreamInterface::kEnded); - scoped_refptr > + talk_base::scoped_refptr audio_tracklist(old_stream->audio_tracks()); for (size_t j = 0; j < audio_tracklist->count(); ++j) { audio_tracklist->at(j)->set_state(MediaStreamTrackInterface::kEnded); } - scoped_refptr > + talk_base::scoped_refptr video_tracklist(old_stream->video_tracks()); for (size_t j = 0; j < video_tracklist->count(); ++j) { video_tracklist->at(j)->set_state(MediaStreamTrackInterface::kEnded); @@ -453,22 +460,25 @@ void PeerConnectionSignaling::UpdateRemoteStreams( // failed the state is changed to kEnded. void PeerConnectionSignaling::UpdateSendingLocalStreams( const cricket::SessionDescription* answer_desc, - StreamCollection* negotiated_streams) { - typedef std::pair > - MediaStreamPair; + StreamCollectionInterface* negotiated_streams) { + typedef std::pair > + MediaStreamPair; LocalStreamMap current_local_streams; for (size_t i = 0; i < negotiated_streams->count(); ++i) { - scoped_refptr stream = negotiated_streams->at(i); - scoped_refptr > - audiotracklist(stream->audio_tracks()); - scoped_refptr > - videotracklist(stream->video_tracks()); + talk_base::scoped_refptr stream = + negotiated_streams->at(i); + talk_base::scoped_refptr audiotracklist( + stream->audio_tracks()); + talk_base::scoped_refptr videotracklist( + stream->video_tracks()); bool stream_ok = false; // A stream is ok if at least one track succeed. // Update tracks based on its type. for (size_t j = 0; j < audiotracklist->count(); ++j) { - scoped_refptr track = audiotracklist->at(j); + talk_base::scoped_refptr track = + audiotracklist->at(j); const cricket::ContentInfo* audio_content = GetFirstAudioContent(answer_desc); 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) { - scoped_refptr track = videotracklist->at(j); + talk_base::scoped_refptr track = + videotracklist->at(j); const cricket::ContentInfo* video_content = GetFirstVideoContent(answer_desc); if (!video_content) { // The remote does not accept video. @@ -525,18 +536,18 @@ void PeerConnectionSignaling::UpdateSendingLocalStreams( for (LocalStreamMap::iterator it = local_streams_.begin(); it != local_streams_.end(); ++it) { - scoped_refptr old_stream(it->second); + talk_base::scoped_refptr old_stream(it->second); MediaStreamInterface* new_streams = negotiated_streams->find(old_stream->label()); if (new_streams == NULL) { old_stream->set_ready_state(MediaStreamInterface::kEnded); - scoped_refptr > - audio_tracklist(old_stream->audio_tracks()); + talk_base::scoped_refptr audio_tracklist( + old_stream->audio_tracks()); for (size_t j = 0; j < audio_tracklist->count(); ++j) { audio_tracklist->at(j)->set_state(MediaStreamTrackInterface::kEnded); } - scoped_refptr > - video_tracklist(old_stream->video_tracks()); + talk_base::scoped_refptr video_tracklist( + old_stream->video_tracks()); for (size_t j = 0; j < video_tracklist->count(); ++j) { video_tracklist->at(j)->set_state(MediaStreamTrackInterface::kEnded); } diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionsignaling.h b/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionsignaling.h index 0e9b7968a9..378ebb9387 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionsignaling.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionsignaling.h @@ -94,13 +94,13 @@ class PeerConnectionSignaling : public WebRtcSessionObserver, // Process a received offer/answer from the remote peer. void ProcessSignalingMessage(const std::string& message, - StreamCollection* local_streams); + StreamCollectionInterface* local_streams); // Creates an offer containing all tracks in local_streams. // 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 // the local stream will change to kAlive. - void CreateOffer(StreamCollection* local_streams); + void CreateOffer(StreamCollectionInterface* local_streams); // Returns the current state. State GetState(); @@ -129,18 +129,20 @@ class PeerConnectionSignaling : public WebRtcSessionObserver, void CreateAnswer_s(); void InitMediaSessionOptions(cricket::MediaSessionOptions* options, - StreamCollection* local_streams); + StreamCollectionInterface* local_streams); void UpdateRemoteStreams(const cricket::SessionDescription* remote_desc); void UpdateSendingLocalStreams( const cricket::SessionDescription* answer_desc, - StreamCollection* negotiated_streams); + StreamCollectionInterface* negotiated_streams); - typedef std::list > StreamCollectionList; + typedef std::list > + StreamCollectionList; StreamCollectionList queued_offers_; typedef std::pair > RemoteOfferPair; + talk_base::scoped_refptr > + RemoteOfferPair; RemoteOfferPair queued_received_offer_; talk_base::Thread* signaling_thread_; @@ -148,10 +150,10 @@ class PeerConnectionSignaling : public WebRtcSessionObserver, State state_; uint32 ssrc_counter_; - typedef std::map > + typedef std::map > RemoteStreamMap; RemoteStreamMap remote_streams_; - typedef std::map > + typedef std::map > LocalStreamMap; LocalStreamMap local_streams_; cricket::Candidates candidates_; diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionsignaling_unittest.cc b/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionsignaling_unittest.cc index 3a44b78e2f..65111b0f78 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionsignaling_unittest.cc +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/peerconnectionsignaling_unittest.cc @@ -46,11 +46,12 @@ static const int kWaitTime = 5000; namespace webrtc { -typedef std::map > MediaStreamMap; -typedef std::pair > RemotePair; +typedef std::map > + MediaStreamMap; +typedef std::pair > + RemotePair; -class MockMediaTrackObserver : public webrtc::Observer { +class MockMediaTrackObserver : public webrtc::ObserverInterface { public: explicit MockMediaTrackObserver(MediaStreamTrackInterface* track) : track_(track) { @@ -64,10 +65,10 @@ class MockMediaTrackObserver : public webrtc::Observer { webrtc::MediaStreamTrackInterface::TrackState track_state; private: - scoped_refptr track_; + talk_base::scoped_refptr track_; }; -class MockMediaStreamObserver : public webrtc::Observer { +class MockMediaStreamObserver : public webrtc::ObserverInterface { public: explicit MockMediaStreamObserver(MediaStreamInterface* stream) : stream_(stream) { @@ -81,7 +82,7 @@ class MockMediaStreamObserver : public webrtc::Observer { webrtc::MediaStreamInterface::ReadyState ready_state; private: - scoped_refptr stream_; + talk_base::scoped_refptr stream_; }; class MockSignalingObserver : public sigslot::has_slots<> { @@ -147,7 +148,7 @@ class MockSignalingObserver : public sigslot::has_slots<> { private: MediaStreamMap remote_media_streams_; - scoped_refptr remote_local_collection_; + talk_base::scoped_refptr remote_local_collection_; PeerConnectionSignaling* remote_peer_; }; @@ -239,18 +240,18 @@ class PeerConnectionSignalingTest: public testing::Test { TEST_F(PeerConnectionSignalingTest, SimpleOneWayCall) { // Create a local stream. std::string label(kStreamLabel1); - scoped_refptr stream( + talk_base::scoped_refptr stream( MediaStream::Create(label)); MockMediaStreamObserver stream_observer1(stream); // Add a local audio track. - scoped_refptr audio_track(AudioTrack::CreateLocal( - kAudioTrackLabel1, NULL)); + talk_base::scoped_refptr + audio_track(AudioTrack::CreateLocal(kAudioTrackLabel1, NULL)); stream->AddTrack(audio_track); MockMediaTrackObserver track_observer1(audio_track); // Peer 1 create an offer with only one audio track. - scoped_refptr local_collection1( + talk_base::scoped_refptr local_collection1( StreamCollectionImpl::Create()); local_collection1->AddStream(stream); // Verify that the local stream is now initializing. @@ -260,7 +261,7 @@ TEST_F(PeerConnectionSignalingTest, SimpleOneWayCall) { track_observer1.track_state); // Peer 2 only receive. Create an empty collection - scoped_refptr local_collection2( + talk_base::scoped_refptr local_collection2( StreamCollectionImpl::Create()); // Connect all messages sent from Peer1 to be received on Peer2 @@ -314,16 +315,16 @@ TEST_F(PeerConnectionSignalingTest, Glare) { signaling2_->OnCandidatesReady(candidates_); // Create a local stream. std::string label(kStreamLabel1); - scoped_refptr stream( + talk_base::scoped_refptr stream( MediaStream::Create(label)); // Add a local audio track. - scoped_refptr audio_track(AudioTrack::CreateLocal( - kAudioTrackLabel1, NULL)); + talk_base::scoped_refptr + audio_track(AudioTrack::CreateLocal(kAudioTrackLabel1, NULL)); stream->AddTrack(audio_track); // Peer 1 create an offer with only one audio track. - scoped_refptr local_collection1( + talk_base::scoped_refptr local_collection1( StreamCollectionImpl::Create()); local_collection1->AddStream(stream); signaling1_->CreateOffer(local_collection1); @@ -333,7 +334,7 @@ TEST_F(PeerConnectionSignalingTest, Glare) { talk_base::Thread::Current()->ProcessMessages(1); // Peer 2 only receive. Create an empty collection. - scoped_refptr local_collection2( + talk_base::scoped_refptr local_collection2( StreamCollectionImpl::Create()); // Peer 2 create an empty offer. signaling2_->CreateOffer(local_collection2); @@ -378,28 +379,28 @@ TEST_F(PeerConnectionSignalingTest, AddRemoveStream) { signaling2_->OnCandidatesReady(candidates_); // Create a local stream. std::string label(kStreamLabel1); - scoped_refptr stream( + talk_base::scoped_refptr stream( MediaStream::Create(label)); MockMediaStreamObserver stream_observer1(stream); // Add a local audio track. - scoped_refptr audio_track(AudioTrack::CreateLocal( - kAudioTrackLabel1, NULL)); + talk_base::scoped_refptr + audio_track(AudioTrack::CreateLocal(kAudioTrackLabel1, NULL)); stream->AddTrack(audio_track); MockMediaTrackObserver track_observer1(audio_track); audio_track->RegisterObserver(&track_observer1); // Add a local video track. - scoped_refptr video_track(VideoTrack::CreateLocal( - kVideoTrackLabel1, NULL)); + talk_base::scoped_refptr + video_track(VideoTrack::CreateLocal(kVideoTrackLabel1, NULL)); stream->AddTrack(video_track); // Peer 1 create an empty collection - scoped_refptr local_collection1( + talk_base::scoped_refptr local_collection1( StreamCollectionImpl::Create()); // Peer 2 create an empty collection - scoped_refptr local_collection2( + talk_base::scoped_refptr local_collection2( StreamCollectionImpl::Create()); // Connect all messages sent from Peer1 to be received on Peer2 diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/ref_count.h b/third_party_mods/libjingle/source/talk/app/webrtc_dev/ref_count.h index 969a43f2be..8c27bf0552 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/ref_count.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/ref_count.h @@ -35,36 +35,36 @@ namespace talk_base { // Reference count interface. -class RefCount { +class RefCountInterface { public: virtual int AddRef() = 0; virtual int Release() = 0; }; template -class RefCountImpl : public T { +class RefCount : public T { public: - RefCountImpl() : ref_count_(0) { + RefCount() : ref_count_(0) { } template - explicit RefCountImpl(P p) : ref_count_(0), T(p) { + explicit RefCount(P p) : ref_count_(0), T(p) { } template - RefCountImpl(P1 p1, P2 p2) : ref_count_(0), T(p1, p2) { + RefCount(P1 p1, P2 p2) : ref_count_(0), T(p1, p2) { } template - 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 - 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 - 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) { } @@ -84,6 +84,6 @@ class RefCountImpl : public T { int ref_count_; }; -} // namespace talk_base +} // namespace talk_base #endif // TALK_APP_WEBRTC_REF_COUNT_H_ diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/scoped_refptr.h b/third_party_mods/libjingle/source/talk/app/webrtc_dev/scoped_refptr.h index 7f7c78ee4f..ce54fd7158 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/scoped_refptr.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/scoped_refptr.h @@ -50,6 +50,8 @@ // // now, |a| and |b| each own a reference to the same MyFoo object. // } // +namespace talk_base { + template class scoped_refptr { public: @@ -125,4 +127,6 @@ class scoped_refptr { T* ptr_; }; +} // namespace talk_base + #endif // TALK_APP_WEBRTC_SCOPED_REFPTR_H_ diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/scoped_refptr_msg.h b/third_party_mods/libjingle/source/talk/app/webrtc_dev/scoped_refptr_msg.h index ad439ff50e..8601d65dcf 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/scoped_refptr_msg.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/scoped_refptr_msg.h @@ -36,17 +36,17 @@ template class ScopedRefMessageData : public talk_base::MessageData { public: explicit ScopedRefMessageData(T* data) : data_(data) { } - const scoped_refptr& data() const { return data_; } - scoped_refptr& data() { return data_; } + const talk_base::scoped_refptr& data() const { return data_; } + talk_base::scoped_refptr& data() { return data_; } private: - scoped_refptr data_; + talk_base::scoped_refptr data_; }; /* struct ScopedTypedMessageData : public talk_base::MessageData { - ScopedRefPtrMsgParams(scoped_refptr ptr) + ScopedRefPtrMsgParams(talk_base::scoped_refptr ptr) : ptr_(ptr) { } - scoped_refptr ptr_; + talk_base::scoped_refptr ptr_; };*/ #endif // TALK_APP_WEBRTC_SCOPED_REF_PTR_MSG_H_ diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/streamcollectionimpl.h b/third_party_mods/libjingle/source/talk/app/webrtc_dev/streamcollectionimpl.h index 840fc1a46d..18895088fd 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/streamcollectionimpl.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/streamcollectionimpl.h @@ -36,18 +36,18 @@ namespace webrtc { // Implementation of StreamCollection. -class StreamCollectionImpl : public StreamCollection { +class StreamCollectionImpl : public StreamCollectionInterface { public: - static scoped_refptr Create() { - talk_base::RefCountImpl* implementation = - new talk_base::RefCountImpl(); + static talk_base::scoped_refptr Create() { + talk_base::RefCount* implementation = + new talk_base::RefCount(); return implementation; } - static scoped_refptr Create( + static talk_base::scoped_refptr Create( StreamCollectionImpl* streams) { - talk_base::RefCountImpl* implementation = - new talk_base::RefCountImpl(streams); + talk_base::RefCount* implementation = + new talk_base::RefCount(streams); return implementation; } @@ -93,7 +93,8 @@ class StreamCollectionImpl : public StreamCollection { explicit StreamCollectionImpl(StreamCollectionImpl* original) : media_streams_(original->media_streams_) { } - typedef std::vector > StreamVector; + typedef std::vector > + StreamVector; StreamVector media_streams_; }; diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/videorendererimpl.cc b/third_party_mods/libjingle/source/talk/app/webrtc_dev/videorendererimpl.cc index 18d6a64f3d..96b9a36f18 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/videorendererimpl.cc +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/videorendererimpl.cc @@ -48,10 +48,10 @@ class VideoRendererImpl : public VideoRendererWrapperInterface { cricket::VideoRenderer* renderer_; }; -scoped_refptr CreateVideoRenderer( +talk_base::scoped_refptr CreateVideoRenderer( cricket::VideoRenderer* renderer) { - talk_base::RefCountImpl* r = - new talk_base::RefCountImpl(renderer); + talk_base::RefCount* r = + new talk_base::RefCount(renderer); return r; } diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/videotrackimpl.cc b/third_party_mods/libjingle/source/talk/app/webrtc_dev/videotrackimpl.cc index 6e80ecb7a1..4d62eefe23 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/videotrackimpl.cc +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/videotrackimpl.cc @@ -45,7 +45,7 @@ VideoTrack::VideoTrack(const std::string& label, void VideoTrack::SetRenderer(VideoRendererWrapperInterface* renderer) { video_renderer_ = renderer; - NotifierImpl::FireOnChanged(); + Notifier::FireOnChanged(); } VideoRendererWrapperInterface* VideoTrack::GetRenderer() { @@ -61,19 +61,19 @@ const char* VideoTrack::kind() const { return kVideoTrackKind; } -scoped_refptr VideoTrack::CreateRemote( +talk_base::scoped_refptr VideoTrack::CreateRemote( const std::string& label, uint32 ssrc) { - talk_base::RefCountImpl* track = - new talk_base::RefCountImpl(label, ssrc); + talk_base::RefCount* track = + new talk_base::RefCount(label, ssrc); return track; } -scoped_refptr VideoTrack::CreateLocal( +talk_base::scoped_refptr VideoTrack::CreateLocal( const std::string& label, VideoCaptureModule* video_device) { - talk_base::RefCountImpl* track = - new talk_base::RefCountImpl(label, video_device); + talk_base::RefCount* track = + new talk_base::RefCount(label, video_device); return track; } diff --git a/third_party_mods/libjingle/source/talk/app/webrtc_dev/videotrackimpl.h b/third_party_mods/libjingle/source/talk/app/webrtc_dev/videotrackimpl.h index 929b2feac2..4e0dd770a6 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc_dev/videotrackimpl.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc_dev/videotrackimpl.h @@ -28,6 +28,8 @@ #ifndef TALK_APP_WEBRTC_VIDEOTRACKIMPL_H_ #define TALK_APP_WEBRTC_VIDEOTRACKIMPL_H_ +#include + #include "talk/app/webrtc_dev/mediastream.h" #include "talk/app/webrtc_dev/mediatrackimpl.h" #include "talk/app/webrtc_dev/notifierimpl.h" @@ -44,10 +46,11 @@ namespace webrtc { class VideoTrack : public MediaTrack { public: // Create a video track used for remote video tracks. - static scoped_refptr CreateRemote(const std::string& label, - uint32 ssrc); + static talk_base::scoped_refptr CreateRemote( + const std::string& label, + uint32 ssrc); // Create a video track used for local video tracks. - static scoped_refptr CreateLocal( + static talk_base::scoped_refptr CreateLocal( const std::string& label, VideoCaptureModule* video_device); @@ -62,8 +65,8 @@ class VideoTrack : public MediaTrack { VideoTrack(const std::string& label, VideoCaptureModule* video_device); private: - scoped_refptr video_device_; - scoped_refptr video_renderer_; + talk_base::scoped_refptr video_device_; + talk_base::scoped_refptr video_renderer_; }; } // namespace webrtc diff --git a/third_party_mods/libjingle/source/talk/examples/peerconnection_client/conductor.cc b/third_party_mods/libjingle/source/talk/examples/peerconnection_client/conductor.cc index 92b995ef06..45157b4b15 100644 --- a/third_party_mods/libjingle/source/talk/examples/peerconnection_client/conductor.cc +++ b/third_party_mods/libjingle/source/talk/examples/peerconnection_client/conductor.cc @@ -220,10 +220,11 @@ void Conductor::ConnectToPeer(int peer_id) { } } -scoped_refptr Conductor::OpenVideoCaptureDevice() { +talk_base::scoped_refptr +Conductor::OpenVideoCaptureDevice() { webrtc::VideoCaptureModule::DeviceInfo* device_info( webrtc::VideoCaptureFactory::CreateDeviceInfo(0)); - scoped_refptr video_device; + talk_base::scoped_refptr video_device; const size_t kMaxDeviceNameLength = 128; const size_t kMaxUniqueIdLength = 256; @@ -249,23 +250,24 @@ void Conductor::AddStreams() { if (active_streams_.find(kStreamLabel) != active_streams_.end()) return; // Already added. - scoped_refptr audio_track( + talk_base::scoped_refptr audio_track( peer_connection_factory_->CreateLocalAudioTrack(kAudioLabel, NULL)); - scoped_refptr video_track( + talk_base::scoped_refptr video_track( peer_connection_factory_->CreateLocalVideoTrack( kVideoLabel, OpenVideoCaptureDevice())); video_track->SetRenderer(main_wnd_->local_renderer()); - scoped_refptr stream = + talk_base::scoped_refptr stream = peer_connection_factory_->CreateLocalMediaStream(kStreamLabel); stream->AddTrack(audio_track); stream->AddTrack(video_track); peer_connection_->AddStream(stream); peer_connection_->CommitStreamChanges(); - typedef std::pair > + typedef std::pair > MediaStreamPair; active_streams_.insert(MediaStreamPair(stream->label(), stream)); main_wnd_->SwitchToStreamingUI(); @@ -340,8 +342,8 @@ void Conductor::UIThreadCallback(int msg_id, void* data) { webrtc::MediaStreamInterface* stream = reinterpret_cast( data); - scoped_refptr > tracks = stream->video_tracks(); + talk_base::scoped_refptr tracks = + stream->video_tracks(); for (size_t i = 0; i < tracks->count(); ++i) { webrtc::VideoTrackInterface* track = tracks->at(i); LOG(INFO) << "Setting video renderer for track: " << track->label(); diff --git a/third_party_mods/libjingle/source/talk/examples/peerconnection_client/conductor.h b/third_party_mods/libjingle/source/talk/examples/peerconnection_client/conductor.h index b2d4d2bdaa..7cbe07c700 100644 --- a/third_party_mods/libjingle/source/talk/examples/peerconnection_client/conductor.h +++ b/third_party_mods/libjingle/source/talk/examples/peerconnection_client/conductor.h @@ -58,7 +58,7 @@ class Conductor void DeletePeerConnection(); void EnsureStreamingUI(); void AddStreams(); - scoped_refptr OpenVideoCaptureDevice(); + talk_base::scoped_refptr OpenVideoCaptureDevice(); // // PeerConnectionObserver implementation. @@ -103,13 +103,14 @@ class Conductor protected: int peer_id_; - scoped_refptr peer_connection_; - scoped_refptr peer_connection_factory_; + talk_base::scoped_refptr peer_connection_; + talk_base::scoped_refptr + peer_connection_factory_; PeerConnectionClient* client_; MainWindow* main_wnd_; std::deque pending_messages_; - std::map > active_streams_; + std::map > + active_streams_; }; #endif // PEERCONNECTION_SAMPLES_CLIENT_CONDUCTOR_H_ diff --git a/third_party_mods/libjingle/source/talk/examples/peerconnection_client/linux/main_wnd.h b/third_party_mods/libjingle/source/talk/examples/peerconnection_client/linux/main_wnd.h index ca4e521300..816b6063fd 100644 --- a/third_party_mods/libjingle/source/talk/examples/peerconnection_client/linux/main_wnd.h +++ b/third_party_mods/libjingle/source/talk/examples/peerconnection_client/linux/main_wnd.h @@ -107,8 +107,10 @@ class GtkMainWnd : public MainWindow { MainWndCallback* callback_; std::string server_; std::string port_; - scoped_refptr local_renderer_wrapper_; - scoped_refptr remote_renderer_wrapper_; + talk_base::scoped_refptr + local_renderer_wrapper_; + talk_base::scoped_refptr + remote_renderer_wrapper_; talk_base::scoped_ptr draw_buffer_; int draw_buffer_size_; };