From accd686b31fdbcd43a7a37b9a86f07668f192cc7 Mon Sep 17 00:00:00 2001 From: "perkj@google.com" Date: Wed, 24 Aug 2011 15:43:42 +0000 Subject: [PATCH] Implementation of media streams. Work in progress. Review URL: http://webrtc-codereview.appspot.com/117002 git-svn-id: http://webrtc.googlecode.com/svn/trunk@436 4adac7df-926f-26a2-2b94-8c16560cd09d --- third_party_mods/libjingle/libjingle.gyp | 24 ++++ .../talk/app/webrtc/local_stream_dev.cc | 30 ++--- .../source/talk/app/webrtc/local_stream_dev.h | 34 +++--- .../app/webrtc/local_stream_dev_unittest.cc | 104 ++++++++++++++++++ .../app/webrtc/local_video_track_impl_dev.cc | 14 ++- .../talk/app/webrtc/media_stream_impl_dev.cc | 64 +++++++++++ .../talk/app/webrtc/media_stream_impl_dev.h | 68 ++++++++++++ .../source/talk/app/webrtc/notifier_impl.h | 69 +++++++++--- .../talk/app/webrtc/peerconnection_dev.cc | 2 +- .../talk/app/webrtc/peerconnection_dev.h | 23 ++-- .../app/webrtc/peerconnection_impl_dev.cc | 77 ++++++------- .../talk/app/webrtc/peerconnection_impl_dev.h | 44 +++----- .../app/webrtc/peerconnection_unittests.cc | 36 ++++++ .../talk/app/webrtc/remote_stream_dev.cc | 72 ++++++++++++ .../talk/app/webrtc/remote_stream_dev.h | 63 +++++++++++ .../app/webrtc/remote_stream_dev_unittest.cc | 62 +++++++++++ .../source/talk/app/webrtc/stream_dev.h | 62 ++++++----- 17 files changed, 677 insertions(+), 171 deletions(-) create mode 100644 third_party_mods/libjingle/source/talk/app/webrtc/local_stream_dev_unittest.cc create mode 100644 third_party_mods/libjingle/source/talk/app/webrtc/media_stream_impl_dev.cc create mode 100644 third_party_mods/libjingle/source/talk/app/webrtc/media_stream_impl_dev.h create mode 100644 third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_unittests.cc create mode 100644 third_party_mods/libjingle/source/talk/app/webrtc/remote_stream_dev.cc create mode 100644 third_party_mods/libjingle/source/talk/app/webrtc/remote_stream_dev.h create mode 100644 third_party_mods/libjingle/source/talk/app/webrtc/remote_stream_dev_unittest.cc diff --git a/third_party_mods/libjingle/libjingle.gyp b/third_party_mods/libjingle/libjingle.gyp index fb3e1e732..05ef9b6cb 100644 --- a/third_party_mods/libjingle/libjingle.gyp +++ b/third_party_mods/libjingle/libjingle.gyp @@ -599,6 +599,8 @@ '<(libjingle_mods)/source/talk/app/webrtc/local_stream_dev.h', '<(libjingle_mods)/source/talk/app/webrtc/local_stream_dev.cc', '<(libjingle_mods)/source/talk/app/webrtc/local_video_track_impl_dev.cc', + '<(libjingle_mods)/source/talk/app/webrtc/media_stream_impl_dev.h', + '<(libjingle_mods)/source/talk/app/webrtc/media_stream_impl_dev.cc', '<(libjingle_mods)/source/talk/app/webrtc/peerconnection_dev.h', '<(libjingle_mods)/source/talk/app/webrtc/peerconnection_impl_dev.cc', '<(libjingle_mods)/source/talk/app/webrtc/peerconnection_impl_dev.h', @@ -607,6 +609,8 @@ '<(libjingle_mods)/source/talk/app/webrtc/peerconnectiontransport.cc', '<(libjingle_mods)/source/talk/app/webrtc/peerconnectiontransport.h', '<(libjingle_mods)/source/talk/app/webrtc/ref_count.h', + '<(libjingle_mods)/source/talk/app/webrtc/remote_stream_dev.h', + '<(libjingle_mods)/source/talk/app/webrtc/remote_stream_dev.cc', '<(libjingle_mods)/source/talk/app/webrtc/stream_dev.h', '<(libjingle_mods)/source/talk/app/webrtc/video_device_dev.cc', '<(libjingle_mods)/source/talk/app/webrtc/video_renderer_dev.cc', @@ -640,5 +644,25 @@ } ], # inside_chromium_build ], # conditions }, + { + 'target_name': 'peerconnection_unittests', + 'dependencies': [ + 'libjingle_app', + '../../testing/gtest.gyp:gtest', + '../../testing/gtest.gyp:gtest_main', + ], + 'conditions': [ + ['peer_connection_dev==1', { + 'type': 'executable', + 'sources': [ + '<(libjingle_mods)/source/talk/app/webrtc/peerconnection_unittests.cc', + '<(libjingle_mods)/source/talk/app/webrtc/local_stream_dev_unittest.cc', + '<(libjingle_mods)/source/talk/app/webrtc/remote_stream_dev_unittest.cc', + ], + }, { + 'type': 'none', + } ], # peer_connection_dev + ], # conditions + }, ], } diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/local_stream_dev.cc b/third_party_mods/libjingle/source/talk/app/webrtc/local_stream_dev.cc index 9b7b3a36d..57bc0a478 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc/local_stream_dev.cc +++ b/third_party_mods/libjingle/source/talk/app/webrtc/local_stream_dev.cc @@ -1,6 +1,6 @@ /* * libjingle - * Copyright 2004--2011, Google Inc. + * Copyright 2011, Google Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -28,44 +28,46 @@ namespace webrtc { -scoped_refptr LocalStream::Create(const std::string& label) { - // To instantiate LocalStream use - RefCountImpl* stream = new RefCountImpl(label); +scoped_refptr LocalMediaStream::Create( + const std::string& label) { + RefCountImpl* stream = + new RefCountImpl(label); return stream; } LocalStreamImpl::LocalStreamImpl(const std::string& label) - : label_(label), - ready_state_(kInitializing) { + : media_stream_impl_(label) { } // Implement MediaStream const std::string& LocalStreamImpl::label() { - return label_; + return media_stream_impl_.label(); } scoped_refptr LocalStreamImpl::tracks() { return this; } -MediaStream::ReadyState LocalStreamImpl::readyState() { - return ready_state_; +MediaStream::ReadyState LocalStreamImpl::ready_state() { + return media_stream_impl_.ready_state(); } // Implement MediaStreamTrackList. size_t LocalStreamImpl::count() { - return tracks_.size(); + return tracks_.count(); } scoped_refptr LocalStreamImpl::at(size_t index) { - return tracks_[index]; + return tracks_.at(index); } bool LocalStreamImpl::AddTrack(MediaStreamTrack* track) { - if(ready_state_ != kInitializing) + if (ready_state() != kInitializing) return false; - tracks_.push_back(track); + bool result = tracks_.AddTrack(track); + NotifierImpl::FireOnChanged(); + return result; } -} // namespace webrtc +} // namespace webrtc diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/local_stream_dev.h b/third_party_mods/libjingle/source/talk/app/webrtc/local_stream_dev.h index a51f9fed6..15b3f32ee 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc/local_stream_dev.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc/local_stream_dev.h @@ -1,6 +1,6 @@ /* * libjingle - * Copyright 2004--2011, Google Inc. + * Copyright 2011, Google Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -28,48 +28,40 @@ #ifndef TALK_APP_WEBRTC_LOCAL_STREAM_H_ #define TALK_APP_WEBRTC_LOCAL_STREAM_H_ -#include - -#include "talk/app/webrtc/notifier_impl.h" -#include "talk/app/webrtc/ref_count.h" +#include "talk/app/webrtc/media_stream_impl_dev.h" #include "talk/app/webrtc/stream_dev.h" -#include "talk/app/webrtc/scoped_refptr.h" - +#include "talk/base/scoped_ptr.h" namespace webrtc { +class MediaStreamImpl; ///////////////////////////////////////////// // Local streams are Created by the PeerConnections client and provided to a // PeerConnection object using the call PeerConnection::AddStream. class LocalStreamImpl - : public LocalStream, - public MediaStreamTrackList { -public: - -// static LocalStream* Create(const std::string& label); - + : public LocalMediaStream, + public NotifierImpl { + public: // Implement LocalStream. virtual bool AddTrack(MediaStreamTrack* track); - // Implement MediaStream + // Implement MediaStream. virtual const std::string& label(); virtual scoped_refptr tracks(); - virtual ReadyState readyState(); + virtual ReadyState ready_state(); // Implement MediaStreamTrackList. virtual size_t count(); virtual scoped_refptr at(size_t index); protected: - LocalStreamImpl(const std::string& label); - std::string label_; - ReadyState ready_state_; - std::vector > tracks_; + explicit LocalStreamImpl(const std::string& label); + + MediaStreamImpl media_stream_impl_; + MediaStreamTrackListImpl tracks_; }; - - } // namespace webrtc #endif // TALK_APP_WEBRTC_LOCAL_STREAM_H_ diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/local_stream_dev_unittest.cc b/third_party_mods/libjingle/source/talk/app/webrtc/local_stream_dev_unittest.cc new file mode 100644 index 000000000..d81c2caa0 --- /dev/null +++ b/third_party_mods/libjingle/source/talk/app/webrtc/local_stream_dev_unittest.cc @@ -0,0 +1,104 @@ +/* + * libjingle + * Copyright 2011, Google Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +#include "gtest/gtest.h" +#include "talk/app/webrtc/local_stream_dev.h" + +static const char kStreamLabel1[] = "local_stream_1"; +const char* kVideoDeviceName = "dummy_video_cam_1"; + +namespace webrtc { + +// Helper class to test the Observer. +class TestObserver : public Observer { + public: + TestObserver() : changed_(0) {} + void OnChanged() { + ++changed_; + } + int NoChanged() { + return changed_; + } + + protected: + int changed_; +}; + +TEST(LocalStreamTest, Create) { + // Create a local stream. + std::string label(kStreamLabel1); + scoped_refptr stream(LocalMediaStream::Create(label)); + + EXPECT_EQ(stream->label().compare(label), 0); + // Check state. + EXPECT_EQ(stream->ready_state(), MediaStream::kInitializing); + + // Create a Video Device. + std::string device_name(kVideoDeviceName); + scoped_refptr device = VideoDevice::Create(device_name, NULL); + EXPECT_EQ(device->name(), device_name); + + // Create a local Video track. + { + TestObserver tracklist_observer; + + scoped_refptr video_track(LocalVideoTrack::Create(device)); + + // Add an observer to the track list. + scoped_refptr track_list(stream->tracks()); + stream->tracks()->RegisterObserver(&tracklist_observer); + + // Add the track to the local stream. + EXPECT_TRUE(stream->AddTrack(video_track)); + + // Verify that the track list observer have been notified + // that the track have been added. + EXPECT_EQ(tracklist_observer.NoChanged(), 1); + } + + EXPECT_EQ(stream->tracks()->count(), 1u); + + // Verify the track. + scoped_refptr track(stream->tracks()->at(0)); + EXPECT_EQ(track->kind().compare(kVideoTrackKind), 0); + EXPECT_EQ(track->label().compare(kVideoDeviceName), 0); + EXPECT_TRUE(track->enabled()); + + // Verify the Track observer. + TestObserver observer1; + TestObserver observer2; + track->RegisterObserver(&observer1); + track->RegisterObserver(&observer2); + track->set_enabled(false); + EXPECT_EQ(observer1.NoChanged(), 1); + EXPECT_EQ(observer2.NoChanged(), 1); + EXPECT_FALSE(track->enabled()); +} + +} // namespace webrtc diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/local_video_track_impl_dev.cc b/third_party_mods/libjingle/source/talk/app/webrtc/local_video_track_impl_dev.cc index 784c7f49e..1bcc8ecaa 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc/local_video_track_impl_dev.cc +++ b/third_party_mods/libjingle/source/talk/app/webrtc/local_video_track_impl_dev.cc @@ -1,6 +1,6 @@ /* * libjingle - * Copyright 2004--2011, Google Inc. + * Copyright 2011, Google Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -30,8 +30,8 @@ namespace webrtc { class LocalVideoTrackImpl : public NotifierImpl { public: - LocalVideoTrackImpl(){}; - LocalVideoTrackImpl(VideoDevice* video_device) + LocalVideoTrackImpl() {} + explicit LocalVideoTrackImpl(VideoDevice* video_device) : enabled_(true), kind_(kVideoTrackKind), video_device_(video_device) { @@ -39,6 +39,7 @@ class LocalVideoTrackImpl : public NotifierImpl { virtual void SetRenderer(VideoRenderer* renderer) { video_renderer_ = renderer; + NotifierImpl::FireOnChanged(); } virtual scoped_refptr GetRenderer() { @@ -70,17 +71,18 @@ class LocalVideoTrackImpl : public NotifierImpl { NotifierImpl::FireOnChanged(); } -private: + private: bool enabled_; std::string kind_; scoped_refptr video_device_; scoped_refptr video_renderer_; }; -scoped_refptr LocalVideoTrack::Create(VideoDevice* video_device) { +scoped_refptr LocalVideoTrack::Create( + VideoDevice* video_device) { RefCountImpl* track = new RefCountImpl(video_device); return track; } -} // namespace webrtc +} // namespace webrtc diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/media_stream_impl_dev.cc b/third_party_mods/libjingle/source/talk/app/webrtc/media_stream_impl_dev.cc new file mode 100644 index 000000000..4946905b4 --- /dev/null +++ b/third_party_mods/libjingle/source/talk/app/webrtc/media_stream_impl_dev.cc @@ -0,0 +1,64 @@ +/* + * libjingle + * Copyright 2011, Google Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "talk/app/webrtc/media_stream_impl_dev.h" + +namespace webrtc { + +MediaStreamImpl::MediaStreamImpl(const std::string& label) + : label_(label), + ready_state_(MediaStream::kInitializing) { +} + +// Implement MediaStream +const std::string& MediaStreamImpl::label() const { + return label_; +} + +MediaStream::ReadyState MediaStreamImpl::ready_state() const { + return ready_state_; +} + +MediaStreamTrackListImpl::MediaStreamTrackListImpl() { +} + +// Implement MediaStreamTrackList. +size_t MediaStreamTrackListImpl::count() const { + return tracks_.size(); +} + +scoped_refptr +MediaStreamTrackListImpl::at(size_t index) const { + return tracks_[index]; +} + +bool MediaStreamTrackListImpl::AddTrack(MediaStreamTrack* track) { + tracks_.push_back(track); + return true; +} + +} // namespace webrtc diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/media_stream_impl_dev.h b/third_party_mods/libjingle/source/talk/app/webrtc/media_stream_impl_dev.h new file mode 100644 index 000000000..73aa5d95d --- /dev/null +++ b/third_party_mods/libjingle/source/talk/app/webrtc/media_stream_impl_dev.h @@ -0,0 +1,68 @@ +/* + * libjingle + * Copyright 2011, Google Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef TALK_APP_WEBRTC_MEDIA_STREAM_IMPL_H_ +#define TALK_APP_WEBRTC_MEDIA_STREAM_IMPL_H_ + +#include +#include + +#include "talk/app/webrtc/notifier_impl.h" +#include "talk/app/webrtc/ref_count.h" +#include "talk/app/webrtc/scoped_refptr.h" +#include "talk/app/webrtc/stream_dev.h" + +namespace webrtc { + +// MediaStreamImpl- help class for implementing the MediaStream interface. +class MediaStreamImpl { + public: + explicit MediaStreamImpl(const std::string& label); + + // Implement MediaStream + const std::string& label() const; + MediaStream::ReadyState ready_state() const; + + protected: + std::string label_; + MediaStream::ReadyState ready_state_; +}; + +class MediaStreamTrackListImpl { + public: + MediaStreamTrackListImpl(); + // Implement MediaStreamTrackList. + bool AddTrack(MediaStreamTrack* track); + size_t count() const; + scoped_refptr at(size_t index) const; + protected: + std::vector > tracks_; +}; + +} // namespace webrtc + +#endif // TALK_APP_WEBRTC_MEDIA_STREAM_IMPL_H_ diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/notifier_impl.h b/third_party_mods/libjingle/source/talk/app/webrtc/notifier_impl.h index 5b9abd1a7..762b71f62 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc/notifier_impl.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc/notifier_impl.h @@ -1,36 +1,73 @@ +/* + * libjingle + * Copyright 2011, Google Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #ifndef TALK_APP_WEBRTC_NOTIFIER_IMPL_H_ #define TALK_APP_WEBRTC_NOTIFIER_IMPL_H_ -// Implement a template version of a notifier. -// TODO - allow multiple observers. -//#include +#include +#include "talk/base/common.h" #include "talk/app/webrtc/stream_dev.h" namespace webrtc { + +// Implement a template version of a notifier. template -class NotifierImpl : public T{ -public: - NotifierImpl(){ +class NotifierImpl : public T { + public: + NotifierImpl() { } virtual void RegisterObserver(Observer* observer) { - observer_ = observer; + ASSERT(observer != NULL); + observers_.push_back(observer); } - virtual void UnregisterObserver(Observer*) { - observer_ = NULL; + virtual void UnregisterObserver(Observer* observer) { + for (std::list::iterator it = observers_.begin(); + it != observers_.end(); it++) { + if (*it == observer) { + observers_.erase(it); + break; + } + } } - void FireOnChanged() { - if(observer_) - observer_->OnChanged(); - } + void FireOnChanged() { + for (std::list::iterator it = observers_.begin(); + it != observers_.end(); ++it) { + (*it)-> OnChanged(); + } + } -protected: - Observer* observer_; + protected: + std::list observers_; }; } // namespace webrtc -#endif // TALK_APP_WEBRTC_REF_COUNT_H_ +#endif // TALK_APP_WEBRTC_NOTIFIER_IMPL_H_ diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_dev.cc b/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_dev.cc index 77dc1f6e5..ca96eac4a 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_dev.cc +++ b/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_dev.cc @@ -1,6 +1,6 @@ /* * libjingle - * Copyright 2004--2011, Google Inc. + * Copyright 2011, Google Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_dev.h b/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_dev.h index b80eb0da9..5563c0add 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_dev.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_dev.h @@ -1,6 +1,6 @@ /* * libjingle - * Copyright 2004--2011, Google Inc. + * Copyright 2011, Google Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -55,18 +55,16 @@ class PeerConnectionObserver { virtual void OnMessage(const std::string& msg) = 0; - // serialized signaling message - // First message will be the initial offer. + // Serialized signaling message virtual void OnSignalingMessage(const std::string& msg) = 0; virtual void OnStateChange(Readiness state) = 0; // Triggered when media is received on a new stream from remote peer. - // The label is unique for a certain peer_id. - virtual void OnAddStream(scoped_refptr stream) = 0; + virtual void OnAddStream(RemoteMediaStream* stream) = 0; // Triggered when a remote peer close a stream. - virtual void OnRemoveStream(scoped_refptr stream) = 0; + virtual void OnRemoveStream(RemoteMediaStream* stream) = 0; protected: // Dtor protected as objects shouldn't be deleted via this interface. @@ -98,13 +96,20 @@ class PeerConnection { virtual scoped_refptr remote_streams() = 0; // Add a new local stream. - virtual void AddStream(LocalStream* stream) = 0; + // This function does not trigger any changes to the stream until + // CommitStreamChanges is called. + virtual void AddStream(LocalMediaStream* stream) = 0; // Remove a local stream and stop sending it. - virtual void RemoveStream(LocalStream* stream) = 0; + // This function does not trigger any changes to the stream until + // CommitStreamChanges is called. + virtual void RemoveStream(LocalMediaStream* stream) = 0; - virtual ~PeerConnection(){}; + // Commit Stream changes. This will start sending media on new streams + // and stop sending media on removed stream. + virtual void CommitStreamChanges() = 0; + virtual ~PeerConnection() {} }; } // namespace webrtc diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_impl_dev.cc b/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_impl_dev.cc index 096e3af51..6e0d9df25 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_impl_dev.cc +++ b/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_impl_dev.cc @@ -1,4 +1,31 @@ +/* + * libjingle + * Copyright 2011, Google Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #include "talk/app/webrtc/peerconnection_impl_dev.h" #include "talk/app/webrtc/webrtcsession.h" @@ -11,63 +38,27 @@ namespace webrtc { PeerConnectionImpl::PeerConnectionImpl( cricket::ChannelManager* channel_manager, cricket::PortAllocator* port_allocator) - : initialized_(false), - ready_state_(NEW), - observer_(NULL), + : observer_(NULL), session_(NULL), - signaling_thread_(new talk_base::Thread()), + worker_thread_(new talk_base::Thread()), channel_manager_(channel_manager), port_allocator_(port_allocator) { + ASSERT(port_allocator_ != NULL); } PeerConnectionImpl::~PeerConnectionImpl() { } -bool PeerConnectionImpl::Init() { - ASSERT(port_allocator_ != NULL); - ASSERT(signaling_thread_.get()); - if (!signaling_thread_->SetName("signaling_thread", this) || - !signaling_thread_->Start()) { - LOG(LS_ERROR) << "Failed to start signalig thread"; - return false; - } - session_.reset(CreateSession()); - ASSERT(session_.get() != NULL); - return true; -} - -WebRtcSession* PeerConnectionImpl::CreateSession() { - // TODO(ronghuawu): when we have the new WebRtcSession we don't need these - std::string id = ""; - std::string direction = ""; - WebRtcSession* session = - new WebRtcSession(id, direction, port_allocator_, - channel_manager_, - // TODO(ronghuawu): implement PeerConnectionImplCallbacks - // this, - NULL, - signaling_thread_.get()); - if (!session->Initiate()) { - delete session; - session = NULL; - } - return session; -} - void PeerConnectionImpl::RegisterObserver(PeerConnectionObserver* observer) { observer_ = observer; } -void PeerConnectionImpl::AddStream(LocalStream* local_stream) { - +void PeerConnectionImpl::AddStream(LocalMediaStream* local_stream) { + add_commit_queue_.push_back(local_stream); } -void PeerConnectionImpl::RemoveStream(LocalStream* remove_stream) { - -} - -void PeerConnectionImpl::OnMessage(talk_base::Message* msg) { - +void PeerConnectionImpl::RemoveStream(LocalMediaStream* remove_stream) { + remove_commit_queue_.push_back(remove_stream); } } // namespace webrtc diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_impl_dev.h b/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_impl_dev.h index ec3aa09b6..d37203139 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_impl_dev.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_impl_dev.h @@ -1,6 +1,6 @@ /* * libjingle - * Copyright 2004--2011, Google Inc. + * Copyright 2011, Google Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -28,6 +28,8 @@ #ifndef TALK_APP_WEBRTC_PEERCONNECTION_IMPL_H_ #define TALK_APP_WEBRTC_PEERCONNECTION_IMPL_H_ +#include + #include "talk/app/webrtc/peerconnection_dev.h" #include "talk/base/scoped_ptr.h" @@ -46,13 +48,6 @@ class WebRtcSession; class PeerConnectionImpl : public PeerConnection { public: - enum ReadyState { - NEW = 0, - NEGOTIATING, - ACTIVE, - CLOSED, - }; - enum Error { ERROR_NONE = 0, // Good ERROR_TIMEOUT = 1, // No Candidates generated for X amount of time @@ -84,34 +79,21 @@ class PeerConnectionImpl : public PeerConnection { virtual scoped_refptr remote_streams() { //TODO: implement } - virtual void AddStream(LocalStream* stream); - virtual void RemoveStream(LocalStream* stream); + virtual void AddStream(LocalMediaStream* stream); + virtual void RemoveStream(LocalMediaStream* stream); + virtual void CommitStreamChanges(); - bool Init(); void RegisterObserver(PeerConnectionObserver* observer); - bool ProcessSignalingMessage(const std::string& msg); - - bool initialized() { - return initialized_; - } - ReadyState ready_state() { - return ready_state_; - } - -private: - WebRtcSession* CreateSession(); - virtual void OnMessage(talk_base::Message* msg); - void AddStream_s(LocalStream* stream); - void RemoveStream_s(LocalStream* stream); - void ProcessSignalingMessage_s(const std::string& msg); - void StartNegotiation_s(); - - bool initialized_; - ReadyState ready_state_; + private: PeerConnectionObserver* observer_; + + // List of media streams to process. + std::list > add_commit_queue_; + std::list > remove_commit_queue_; + talk_base::scoped_ptr session_; - talk_base::scoped_ptr signaling_thread_; + talk_base::scoped_ptr worker_thread_; cricket::ChannelManager* channel_manager_; cricket::PortAllocator* port_allocator_; }; diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_unittests.cc b/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_unittests.cc new file mode 100644 index 000000000..ed0355a96 --- /dev/null +++ b/third_party_mods/libjingle/source/talk/app/webrtc/peerconnection_unittests.cc @@ -0,0 +1,36 @@ +/* + * libjingle + * Copyright 2011, Google Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "gtest/gtest.h" + +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + // Added return_value so that it's convenient to put a breakpoint before + // exiting please note that the return value from RUN_ALL_TESTS() must + // be returned by the main function. + const int return_value = RUN_ALL_TESTS(); + return return_value; +} diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/remote_stream_dev.cc b/third_party_mods/libjingle/source/talk/app/webrtc/remote_stream_dev.cc new file mode 100644 index 000000000..27a291431 --- /dev/null +++ b/third_party_mods/libjingle/source/talk/app/webrtc/remote_stream_dev.cc @@ -0,0 +1,72 @@ +/* + * libjingle + * Copyright 2011, Google Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "talk/app/webrtc/remote_stream_dev.h" + +#include + +namespace webrtc { + +scoped_refptr RemoteMediaStreamImpl::Create( + const std::string& label) { + // To instantiate LocalStream use + RefCountImpl* stream = + new RefCountImpl(label); + return stream; +} + +RemoteMediaStreamImpl::RemoteMediaStreamImpl(const std::string& label) + : media_stream_impl_(label) { +} + +// Implement MediaStream +const std::string& RemoteMediaStreamImpl::label() { + return media_stream_impl_.label(); +} + +scoped_refptr RemoteMediaStreamImpl::tracks() { + return this; +} + +MediaStream::ReadyState RemoteMediaStreamImpl::ready_state() { + return media_stream_impl_.ready_state(); +} + +// Implement MediaStreamTrackList. +size_t RemoteMediaStreamImpl::count() { + return tracks_.count(); +} + +scoped_refptr RemoteMediaStreamImpl::at(size_t index) { + return tracks_.at(index); +} + +bool RemoteMediaStreamImpl::AddTrack(MediaStreamTrack* track) { + tracks_.AddTrack(track); + NotifierImpl::FireOnChanged(); +} + +} // namespace webrtc diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/remote_stream_dev.h b/third_party_mods/libjingle/source/talk/app/webrtc/remote_stream_dev.h new file mode 100644 index 000000000..8e480aeb7 --- /dev/null +++ b/third_party_mods/libjingle/source/talk/app/webrtc/remote_stream_dev.h @@ -0,0 +1,63 @@ +/* + * libjingle + * Copyright 2011, Google Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef TALK_APP_WEBRTC_REMOTE_STREAM_H_ +#define TALK_APP_WEBRTC_REMOTE_STREAM_H_ + +#include "talk/app/webrtc/media_stream_impl_dev.h" +#include "talk/app/webrtc/stream_dev.h" +#include "talk/base/scoped_ptr.h" + +namespace webrtc { + +///////////////////////////////////////////// +// Remote stream +class RemoteMediaStreamImpl + : public RemoteMediaStream, + public NotifierImpl { + public: + static scoped_refptr Create(const std::string& label); + bool AddTrack(MediaStreamTrack* track); + + // Implement MediaStream. + virtual const std::string& label(); + virtual scoped_refptr tracks(); + virtual ReadyState ready_state(); + + // Implement MediaStreamTrackList. + virtual size_t count(); + virtual scoped_refptr at(size_t index); + + protected: + explicit RemoteMediaStreamImpl(const std::string& label); + MediaStreamImpl media_stream_impl_; + MediaStreamTrackListImpl tracks_; +}; + +} // namespace webrtc + +#endif // TALK_APP_WEBRTC_REMOTE_STREAM_H_ diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/remote_stream_dev_unittest.cc b/third_party_mods/libjingle/source/talk/app/webrtc/remote_stream_dev_unittest.cc new file mode 100644 index 000000000..fdc65765d --- /dev/null +++ b/third_party_mods/libjingle/source/talk/app/webrtc/remote_stream_dev_unittest.cc @@ -0,0 +1,62 @@ +/* + * libjingle + * Copyright 2011, Google Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +#include "gtest/gtest.h" +#include "talk/app/webrtc/remote_stream_dev.h" + +static const char kStreamLabel1[] = "remote_stream_1"; + +namespace webrtc { + +// Helper class to test the Observer. +class TestObserver : public Observer { + public: + TestObserver() : changed_(0) {} + void OnChanged() { + ++changed_; + } + int NoChanged() { + return changed_; + } + + protected: + int changed_; +}; + +TEST(RemoteStreamTest, Create) { + // Create a Remote stream. + std::string label(kStreamLabel1); + scoped_refptr stream(RemoteMediaStreamImpl::Create(label)); + + EXPECT_EQ(stream->label().compare(label), 0); + // Check state. + EXPECT_EQ(stream->ready_state(), MediaStream::kInitializing); +} + +} // namespace webrtc diff --git a/third_party_mods/libjingle/source/talk/app/webrtc/stream_dev.h b/third_party_mods/libjingle/source/talk/app/webrtc/stream_dev.h index aab4dc9a9..1c0dedc7c 100644 --- a/third_party_mods/libjingle/source/talk/app/webrtc/stream_dev.h +++ b/third_party_mods/libjingle/source/talk/app/webrtc/stream_dev.h @@ -1,6 +1,6 @@ /* * libjingle - * Copyright 2004--2011, Google Inc. + * Copyright 2011, Google Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -50,13 +50,15 @@ const char kAudioTrackKind[] = "audio"; class Observer { public: virtual void OnChanged() = 0; + + protected: + virtual ~Observer() {} }; class Notifier { - virtual void RegisterObserver(Observer*) = 0; - virtual void UnregisterObserver(Observer*) = 0; - // This method should only be accessible to the owner - //void FireOnChanged() = 0; + public: + virtual void RegisterObserver(Observer* observer) = 0; + virtual void UnregisterObserver(Observer* observer) = 0; }; // Information about a track. @@ -66,12 +68,12 @@ class MediaStreamTrack : public RefCount, virtual const std::string& kind() = 0; virtual const std::string& label() = 0; virtual bool enabled() = 0; - // Enable or disables a track. - // For Remote streams - disable means that the video is not decoded, - // or audio not decoded. - // For local streams this means that video is not captured - // or audio is not captured. - virtual bool set_enabled(bool enable); + // Enable or disables a track. + // For Remote streams - disable means that the video is not decoded, + // or audio not decoded. + // For local streams this means that video is not captured + // or audio is not captured. + virtual bool set_enabled(bool enable) = 0; }; // Reference counted wrapper for an AudioDeviceModule. @@ -86,8 +88,8 @@ class AudioDevice : public RefCount { AudioDeviceModule* module(); protected: - AudioDevice(){}; - virtual ~AudioDevice() {}; + AudioDevice() {} + virtual ~AudioDevice() {} void Initialize(const std::string& name, AudioDeviceModule* adm); std::string name_; @@ -105,8 +107,8 @@ class VideoDevice : public RefCount { VideoCaptureModule* module(); protected: - VideoDevice(){}; - ~VideoDevice() {}; + VideoDevice() {} + ~VideoDevice() {} void Initialize(const std::string& name, VideoCaptureModule* vcm); std::string name_; @@ -120,8 +122,8 @@ class VideoRenderer : public RefCount { virtual cricket::VideoRenderer* module(); protected: - VideoRenderer() {}; - ~VideoRenderer() {}; + VideoRenderer() {} + ~VideoRenderer() {} void Initialize(cricket::VideoRenderer* renderer); cricket::VideoRenderer* renderer_; @@ -137,7 +139,7 @@ class VideoTrack : public MediaStreamTrack { virtual scoped_refptr GetRenderer() = 0; protected: - virtual ~VideoTrack() {}; + virtual ~VideoTrack() {} }; class LocalVideoTrack : public VideoTrack { @@ -148,13 +150,13 @@ class LocalVideoTrack : public VideoTrack { virtual scoped_refptr GetVideoCapture() = 0; protected: - virtual ~LocalVideoTrack() {}; + virtual ~LocalVideoTrack() {} }; class AudioTrack : public MediaStreamTrack { public: protected: - virtual ~AudioTrack() {}; + virtual ~AudioTrack() {} }; class LocalAudioTrack : public AudioTrack { @@ -164,17 +166,17 @@ class LocalAudioTrack : public AudioTrack { // Get the AudioDevice associated with this track. virtual scoped_refptr GetAudioDevice() = 0; protected: - virtual ~LocalAudioTrack() {}; + virtual ~LocalAudioTrack() {} }; // List of of tracks. -class MediaStreamTrackList : public RefCount { +class MediaStreamTrackList : public RefCount, public Notifier { public: virtual size_t count() = 0; virtual scoped_refptr at(size_t index) = 0; protected: - virtual ~MediaStreamTrackList() {}; + virtual ~MediaStreamTrackList() {} }; class MediaStream : public RefCount { @@ -188,15 +190,15 @@ class MediaStream : public RefCount { kEnded = 2, // Stream have ended }; - virtual ReadyState readyState() = 0; + virtual ReadyState ready_state() = 0; protected: - virtual ~MediaStream() {}; + virtual ~MediaStream() {} }; -class LocalStream : public MediaStream { -public: - static scoped_refptr Create(const std::string& label); +class LocalMediaStream : public MediaStream { + public: + static scoped_refptr Create(const std::string& label); virtual bool AddTrack(MediaStreamTrack* track) = 0; }; @@ -204,8 +206,8 @@ public: // client using PeerConnectionObserver::OnAddStream. // The client can provide the renderer to the PeerConnection object calling // VideoTrack::SetRenderer. -class RemoteStream : public MediaStream { -public: +class RemoteMediaStream : public MediaStream { + public: }; } // namespace webrtc