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
This commit is contained in:
perkj@google.com 2011-08-24 15:43:42 +00:00
parent 49cbc512ae
commit accd686b31
17 changed files with 677 additions and 171 deletions

View File

@ -599,6 +599,8 @@
'<(libjingle_mods)/source/talk/app/webrtc/local_stream_dev.h', '<(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_stream_dev.cc',
'<(libjingle_mods)/source/talk/app/webrtc/local_video_track_impl_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_dev.h',
'<(libjingle_mods)/source/talk/app/webrtc/peerconnection_impl_dev.cc', '<(libjingle_mods)/source/talk/app/webrtc/peerconnection_impl_dev.cc',
'<(libjingle_mods)/source/talk/app/webrtc/peerconnection_impl_dev.h', '<(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.cc',
'<(libjingle_mods)/source/talk/app/webrtc/peerconnectiontransport.h', '<(libjingle_mods)/source/talk/app/webrtc/peerconnectiontransport.h',
'<(libjingle_mods)/source/talk/app/webrtc/ref_count.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/stream_dev.h',
'<(libjingle_mods)/source/talk/app/webrtc/video_device_dev.cc', '<(libjingle_mods)/source/talk/app/webrtc/video_device_dev.cc',
'<(libjingle_mods)/source/talk/app/webrtc/video_renderer_dev.cc', '<(libjingle_mods)/source/talk/app/webrtc/video_renderer_dev.cc',
@ -640,5 +644,25 @@
} ], # inside_chromium_build } ], # inside_chromium_build
], # conditions ], # 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
},
], ],
} }

View File

@ -1,6 +1,6 @@
/* /*
* libjingle * libjingle
* Copyright 2004--2011, Google Inc. * Copyright 2011, Google Inc.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@ -28,44 +28,46 @@
namespace webrtc { namespace webrtc {
scoped_refptr<LocalStream> LocalStream::Create(const std::string& label) { scoped_refptr<LocalMediaStream> LocalMediaStream::Create(
// To instantiate LocalStream use const std::string& label) {
RefCountImpl<LocalStreamImpl>* stream = new RefCountImpl<LocalStreamImpl>(label); RefCountImpl<LocalStreamImpl>* stream =
new RefCountImpl<LocalStreamImpl>(label);
return stream; return stream;
} }
LocalStreamImpl::LocalStreamImpl(const std::string& label) LocalStreamImpl::LocalStreamImpl(const std::string& label)
: label_(label), : media_stream_impl_(label) {
ready_state_(kInitializing) {
} }
// Implement MediaStream // Implement MediaStream
const std::string& LocalStreamImpl::label() { const std::string& LocalStreamImpl::label() {
return label_; return media_stream_impl_.label();
} }
scoped_refptr<MediaStreamTrackList> LocalStreamImpl::tracks() { scoped_refptr<MediaStreamTrackList> LocalStreamImpl::tracks() {
return this; return this;
} }
MediaStream::ReadyState LocalStreamImpl::readyState() { MediaStream::ReadyState LocalStreamImpl::ready_state() {
return ready_state_; return media_stream_impl_.ready_state();
} }
// Implement MediaStreamTrackList. // Implement MediaStreamTrackList.
size_t LocalStreamImpl::count() { size_t LocalStreamImpl::count() {
return tracks_.size(); return tracks_.count();
} }
scoped_refptr<MediaStreamTrack> LocalStreamImpl::at(size_t index) { scoped_refptr<MediaStreamTrack> LocalStreamImpl::at(size_t index) {
return tracks_[index]; return tracks_.at(index);
} }
bool LocalStreamImpl::AddTrack(MediaStreamTrack* track) { bool LocalStreamImpl::AddTrack(MediaStreamTrack* track) {
if(ready_state_ != kInitializing) if (ready_state() != kInitializing)
return false; return false;
tracks_.push_back(track); bool result = tracks_.AddTrack(track);
NotifierImpl<MediaStreamTrackList>::FireOnChanged();
return result;
} }
} // namespace webrtc } // namespace webrtc

View File

@ -1,6 +1,6 @@
/* /*
* libjingle * libjingle
* Copyright 2004--2011, Google Inc. * Copyright 2011, Google Inc.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@ -28,48 +28,40 @@
#ifndef TALK_APP_WEBRTC_LOCAL_STREAM_H_ #ifndef TALK_APP_WEBRTC_LOCAL_STREAM_H_
#define TALK_APP_WEBRTC_LOCAL_STREAM_H_ #define TALK_APP_WEBRTC_LOCAL_STREAM_H_
#include <vector> #include "talk/app/webrtc/media_stream_impl_dev.h"
#include "talk/app/webrtc/notifier_impl.h"
#include "talk/app/webrtc/ref_count.h"
#include "talk/app/webrtc/stream_dev.h" #include "talk/app/webrtc/stream_dev.h"
#include "talk/app/webrtc/scoped_refptr.h" #include "talk/base/scoped_ptr.h"
namespace webrtc { namespace webrtc {
class MediaStreamImpl;
///////////////////////////////////////////// /////////////////////////////////////////////
// Local streams are Created by the PeerConnections client and provided to a // Local streams are Created by the PeerConnections client and provided to a
// PeerConnection object using the call PeerConnection::AddStream. // PeerConnection object using the call PeerConnection::AddStream.
class LocalStreamImpl class LocalStreamImpl
: public LocalStream, : public LocalMediaStream,
public MediaStreamTrackList { public NotifierImpl<MediaStreamTrackList> {
public: public:
// static LocalStream* Create(const std::string& label);
// Implement LocalStream. // Implement LocalStream.
virtual bool AddTrack(MediaStreamTrack* track); virtual bool AddTrack(MediaStreamTrack* track);
// Implement MediaStream // Implement MediaStream.
virtual const std::string& label(); virtual const std::string& label();
virtual scoped_refptr<MediaStreamTrackList> tracks(); virtual scoped_refptr<MediaStreamTrackList> tracks();
virtual ReadyState readyState(); virtual ReadyState ready_state();
// Implement MediaStreamTrackList. // Implement MediaStreamTrackList.
virtual size_t count(); virtual size_t count();
virtual scoped_refptr<MediaStreamTrack> at(size_t index); virtual scoped_refptr<MediaStreamTrack> at(size_t index);
protected: protected:
LocalStreamImpl(const std::string& label); explicit LocalStreamImpl(const std::string& label);
std::string label_;
ReadyState ready_state_; MediaStreamImpl media_stream_impl_;
std::vector<scoped_refptr<MediaStreamTrack> > tracks_; MediaStreamTrackListImpl tracks_;
}; };
} // namespace webrtc } // namespace webrtc
#endif // TALK_APP_WEBRTC_LOCAL_STREAM_H_ #endif // TALK_APP_WEBRTC_LOCAL_STREAM_H_

View File

@ -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 <string>
#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<LocalMediaStream> 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<VideoDevice> device = VideoDevice::Create(device_name, NULL);
EXPECT_EQ(device->name(), device_name);
// Create a local Video track.
{
TestObserver tracklist_observer;
scoped_refptr<LocalVideoTrack> video_track(LocalVideoTrack::Create(device));
// Add an observer to the track list.
scoped_refptr<MediaStreamTrackList> 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<webrtc::MediaStreamTrack> 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

View File

@ -1,6 +1,6 @@
/* /*
* libjingle * libjingle
* Copyright 2004--2011, Google Inc. * Copyright 2011, Google Inc.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@ -30,8 +30,8 @@ namespace webrtc {
class LocalVideoTrackImpl : public NotifierImpl<LocalVideoTrack> { class LocalVideoTrackImpl : public NotifierImpl<LocalVideoTrack> {
public: public:
LocalVideoTrackImpl(){}; LocalVideoTrackImpl() {}
LocalVideoTrackImpl(VideoDevice* video_device) explicit LocalVideoTrackImpl(VideoDevice* video_device)
: enabled_(true), : enabled_(true),
kind_(kVideoTrackKind), kind_(kVideoTrackKind),
video_device_(video_device) { video_device_(video_device) {
@ -39,6 +39,7 @@ class LocalVideoTrackImpl : public NotifierImpl<LocalVideoTrack> {
virtual void SetRenderer(VideoRenderer* renderer) { virtual void SetRenderer(VideoRenderer* renderer) {
video_renderer_ = renderer; video_renderer_ = renderer;
NotifierImpl<LocalVideoTrack>::FireOnChanged();
} }
virtual scoped_refptr<VideoRenderer> GetRenderer() { virtual scoped_refptr<VideoRenderer> GetRenderer() {
@ -70,14 +71,15 @@ class LocalVideoTrackImpl : public NotifierImpl<LocalVideoTrack> {
NotifierImpl<LocalVideoTrack>::FireOnChanged(); NotifierImpl<LocalVideoTrack>::FireOnChanged();
} }
private: private:
bool enabled_; bool enabled_;
std::string kind_; std::string kind_;
scoped_refptr<VideoDevice> video_device_; scoped_refptr<VideoDevice> video_device_;
scoped_refptr<VideoRenderer> video_renderer_; scoped_refptr<VideoRenderer> video_renderer_;
}; };
scoped_refptr<LocalVideoTrack> LocalVideoTrack::Create(VideoDevice* video_device) { scoped_refptr<LocalVideoTrack> LocalVideoTrack::Create(
VideoDevice* video_device) {
RefCountImpl<LocalVideoTrackImpl>* track = RefCountImpl<LocalVideoTrackImpl>* track =
new RefCountImpl<LocalVideoTrackImpl>(video_device); new RefCountImpl<LocalVideoTrackImpl>(video_device);
return track; return track;

View File

@ -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<MediaStreamTrack>
MediaStreamTrackListImpl::at(size_t index) const {
return tracks_[index];
}
bool MediaStreamTrackListImpl::AddTrack(MediaStreamTrack* track) {
tracks_.push_back(track);
return true;
}
} // namespace webrtc

View File

@ -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 <string>
#include <vector>
#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<MediaStreamTrack> at(size_t index) const;
protected:
std::vector<scoped_refptr<MediaStreamTrack> > tracks_;
};
} // namespace webrtc
#endif // TALK_APP_WEBRTC_MEDIA_STREAM_IMPL_H_

View File

@ -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_ #ifndef TALK_APP_WEBRTC_NOTIFIER_IMPL_H_
#define TALK_APP_WEBRTC_NOTIFIER_IMPL_H_ #define TALK_APP_WEBRTC_NOTIFIER_IMPL_H_
// Implement a template version of a notifier. #include <list>
// TODO - allow multiple observers.
//#include <list>
#include "talk/base/common.h"
#include "talk/app/webrtc/stream_dev.h" #include "talk/app/webrtc/stream_dev.h"
namespace webrtc { namespace webrtc {
// Implement a template version of a notifier.
template <class T> template <class T>
class NotifierImpl : public T{ class NotifierImpl : public T {
public: public:
NotifierImpl(){ NotifierImpl() {
} }
virtual void RegisterObserver(Observer* observer) { virtual void RegisterObserver(Observer* observer) {
observer_ = observer; ASSERT(observer != NULL);
observers_.push_back(observer);
} }
virtual void UnregisterObserver(Observer*) { virtual void UnregisterObserver(Observer* observer) {
observer_ = NULL; for (std::list<Observer*>::iterator it = observers_.begin();
it != observers_.end(); it++) {
if (*it == observer) {
observers_.erase(it);
break;
}
}
} }
void FireOnChanged() { void FireOnChanged() {
if(observer_) for (std::list<Observer*>::iterator it = observers_.begin();
observer_->OnChanged(); it != observers_.end(); ++it) {
(*it)-> OnChanged();
}
} }
protected: protected:
Observer* observer_; std::list<Observer*> observers_;
}; };
} // namespace webrtc } // namespace webrtc
#endif // TALK_APP_WEBRTC_REF_COUNT_H_ #endif // TALK_APP_WEBRTC_NOTIFIER_IMPL_H_

View File

@ -1,6 +1,6 @@
/* /*
* libjingle * libjingle
* Copyright 2004--2011, Google Inc. * Copyright 2011, Google Inc.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:

View File

@ -1,6 +1,6 @@
/* /*
* libjingle * libjingle
* Copyright 2004--2011, Google Inc. * Copyright 2011, Google Inc.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@ -55,18 +55,16 @@ class PeerConnectionObserver {
virtual void OnMessage(const std::string& msg) = 0; virtual void OnMessage(const std::string& msg) = 0;
// serialized signaling message // Serialized signaling message
// First message will be the initial offer.
virtual void OnSignalingMessage(const std::string& msg) = 0; virtual void OnSignalingMessage(const std::string& msg) = 0;
virtual void OnStateChange(Readiness state) = 0; virtual void OnStateChange(Readiness state) = 0;
// Triggered when media is received on a new stream from remote peer. // Triggered when media is received on a new stream from remote peer.
// The label is unique for a certain peer_id. virtual void OnAddStream(RemoteMediaStream* stream) = 0;
virtual void OnAddStream(scoped_refptr<RemoteStream> stream) = 0;
// Triggered when a remote peer close a stream. // Triggered when a remote peer close a stream.
virtual void OnRemoveStream(scoped_refptr<RemoteStream> stream) = 0; virtual void OnRemoveStream(RemoteMediaStream* stream) = 0;
protected: protected:
// Dtor protected as objects shouldn't be deleted via this interface. // Dtor protected as objects shouldn't be deleted via this interface.
@ -98,13 +96,20 @@ class PeerConnection {
virtual scoped_refptr<StreamCollection> remote_streams() = 0; virtual scoped_refptr<StreamCollection> remote_streams() = 0;
// Add a new local stream. // 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. // 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 } // namespace webrtc

View File

@ -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/peerconnection_impl_dev.h"
#include "talk/app/webrtc/webrtcsession.h" #include "talk/app/webrtc/webrtcsession.h"
@ -11,63 +38,27 @@ namespace webrtc {
PeerConnectionImpl::PeerConnectionImpl( PeerConnectionImpl::PeerConnectionImpl(
cricket::ChannelManager* channel_manager, cricket::ChannelManager* channel_manager,
cricket::PortAllocator* port_allocator) cricket::PortAllocator* port_allocator)
: initialized_(false), : observer_(NULL),
ready_state_(NEW),
observer_(NULL),
session_(NULL), session_(NULL),
signaling_thread_(new talk_base::Thread()), worker_thread_(new talk_base::Thread()),
channel_manager_(channel_manager), channel_manager_(channel_manager),
port_allocator_(port_allocator) { port_allocator_(port_allocator) {
ASSERT(port_allocator_ != NULL);
} }
PeerConnectionImpl::~PeerConnectionImpl() { 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) { void PeerConnectionImpl::RegisterObserver(PeerConnectionObserver* observer) {
observer_ = 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::RemoveStream(LocalMediaStream* remove_stream) {
remove_commit_queue_.push_back(remove_stream);
}
void PeerConnectionImpl::OnMessage(talk_base::Message* msg) {
} }
} // namespace webrtc } // namespace webrtc

View File

@ -1,6 +1,6 @@
/* /*
* libjingle * libjingle
* Copyright 2004--2011, Google Inc. * Copyright 2011, Google Inc.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@ -28,6 +28,8 @@
#ifndef TALK_APP_WEBRTC_PEERCONNECTION_IMPL_H_ #ifndef TALK_APP_WEBRTC_PEERCONNECTION_IMPL_H_
#define TALK_APP_WEBRTC_PEERCONNECTION_IMPL_H_ #define TALK_APP_WEBRTC_PEERCONNECTION_IMPL_H_
#include <list>
#include "talk/app/webrtc/peerconnection_dev.h" #include "talk/app/webrtc/peerconnection_dev.h"
#include "talk/base/scoped_ptr.h" #include "talk/base/scoped_ptr.h"
@ -46,13 +48,6 @@ class WebRtcSession;
class PeerConnectionImpl : public PeerConnection { class PeerConnectionImpl : public PeerConnection {
public: public:
enum ReadyState {
NEW = 0,
NEGOTIATING,
ACTIVE,
CLOSED,
};
enum Error { enum Error {
ERROR_NONE = 0, // Good ERROR_NONE = 0, // Good
ERROR_TIMEOUT = 1, // No Candidates generated for X amount of time ERROR_TIMEOUT = 1, // No Candidates generated for X amount of time
@ -84,34 +79,21 @@ class PeerConnectionImpl : public PeerConnection {
virtual scoped_refptr<StreamCollection> remote_streams() { virtual scoped_refptr<StreamCollection> remote_streams() {
//TODO: implement //TODO: implement
} }
virtual void AddStream(LocalStream* stream); virtual void AddStream(LocalMediaStream* stream);
virtual void RemoveStream(LocalStream* stream); virtual void RemoveStream(LocalMediaStream* stream);
virtual void CommitStreamChanges();
bool Init();
void RegisterObserver(PeerConnectionObserver* observer); void RegisterObserver(PeerConnectionObserver* observer);
bool ProcessSignalingMessage(const std::string& msg); private:
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_;
PeerConnectionObserver* observer_; PeerConnectionObserver* observer_;
// List of media streams to process.
std::list<scoped_refptr<LocalMediaStream> > add_commit_queue_;
std::list<scoped_refptr<LocalMediaStream> > remove_commit_queue_;
talk_base::scoped_ptr<WebRtcSession> session_; talk_base::scoped_ptr<WebRtcSession> session_;
talk_base::scoped_ptr<talk_base::Thread> signaling_thread_; talk_base::scoped_ptr<talk_base::Thread> worker_thread_;
cricket::ChannelManager* channel_manager_; cricket::ChannelManager* channel_manager_;
cricket::PortAllocator* port_allocator_; cricket::PortAllocator* port_allocator_;
}; };

View File

@ -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;
}

View File

@ -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 <string>
namespace webrtc {
scoped_refptr<RemoteMediaStream> RemoteMediaStreamImpl::Create(
const std::string& label) {
// To instantiate LocalStream use
RefCountImpl<RemoteMediaStreamImpl>* stream =
new RefCountImpl<RemoteMediaStreamImpl>(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<MediaStreamTrackList> 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<MediaStreamTrack> RemoteMediaStreamImpl::at(size_t index) {
return tracks_.at(index);
}
bool RemoteMediaStreamImpl::AddTrack(MediaStreamTrack* track) {
tracks_.AddTrack(track);
NotifierImpl<MediaStreamTrackList>::FireOnChanged();
}
} // namespace webrtc

View File

@ -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<MediaStreamTrackList> {
public:
static scoped_refptr<RemoteMediaStream> Create(const std::string& label);
bool AddTrack(MediaStreamTrack* track);
// Implement MediaStream.
virtual const std::string& label();
virtual scoped_refptr<MediaStreamTrackList> tracks();
virtual ReadyState ready_state();
// Implement MediaStreamTrackList.
virtual size_t count();
virtual scoped_refptr<MediaStreamTrack> 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_

View File

@ -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 <string>
#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<RemoteMediaStream> stream(RemoteMediaStreamImpl::Create(label));
EXPECT_EQ(stream->label().compare(label), 0);
// Check state.
EXPECT_EQ(stream->ready_state(), MediaStream::kInitializing);
}
} // namespace webrtc

View File

@ -1,6 +1,6 @@
/* /*
* libjingle * libjingle
* Copyright 2004--2011, Google Inc. * Copyright 2011, Google Inc.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@ -50,13 +50,15 @@ const char kAudioTrackKind[] = "audio";
class Observer { class Observer {
public: public:
virtual void OnChanged() = 0; virtual void OnChanged() = 0;
protected:
virtual ~Observer() {}
}; };
class Notifier { class Notifier {
virtual void RegisterObserver(Observer*) = 0; public:
virtual void UnregisterObserver(Observer*) = 0; virtual void RegisterObserver(Observer* observer) = 0;
// This method should only be accessible to the owner virtual void UnregisterObserver(Observer* observer) = 0;
//void FireOnChanged() = 0;
}; };
// Information about a track. // Information about a track.
@ -71,7 +73,7 @@ class MediaStreamTrack : public RefCount,
// or audio not decoded. // or audio not decoded.
// For local streams this means that video is not captured // For local streams this means that video is not captured
// or audio is not captured. // or audio is not captured.
virtual bool set_enabled(bool enable); virtual bool set_enabled(bool enable) = 0;
}; };
// Reference counted wrapper for an AudioDeviceModule. // Reference counted wrapper for an AudioDeviceModule.
@ -86,8 +88,8 @@ class AudioDevice : public RefCount {
AudioDeviceModule* module(); AudioDeviceModule* module();
protected: protected:
AudioDevice(){}; AudioDevice() {}
virtual ~AudioDevice() {}; virtual ~AudioDevice() {}
void Initialize(const std::string& name, AudioDeviceModule* adm); void Initialize(const std::string& name, AudioDeviceModule* adm);
std::string name_; std::string name_;
@ -105,8 +107,8 @@ class VideoDevice : public RefCount {
VideoCaptureModule* module(); VideoCaptureModule* module();
protected: protected:
VideoDevice(){}; VideoDevice() {}
~VideoDevice() {}; ~VideoDevice() {}
void Initialize(const std::string& name, VideoCaptureModule* vcm); void Initialize(const std::string& name, VideoCaptureModule* vcm);
std::string name_; std::string name_;
@ -120,8 +122,8 @@ class VideoRenderer : public RefCount {
virtual cricket::VideoRenderer* module(); virtual cricket::VideoRenderer* module();
protected: protected:
VideoRenderer() {}; VideoRenderer() {}
~VideoRenderer() {}; ~VideoRenderer() {}
void Initialize(cricket::VideoRenderer* renderer); void Initialize(cricket::VideoRenderer* renderer);
cricket::VideoRenderer* renderer_; cricket::VideoRenderer* renderer_;
@ -137,7 +139,7 @@ class VideoTrack : public MediaStreamTrack {
virtual scoped_refptr<VideoRenderer> GetRenderer() = 0; virtual scoped_refptr<VideoRenderer> GetRenderer() = 0;
protected: protected:
virtual ~VideoTrack() {}; virtual ~VideoTrack() {}
}; };
class LocalVideoTrack : public VideoTrack { class LocalVideoTrack : public VideoTrack {
@ -148,13 +150,13 @@ class LocalVideoTrack : public VideoTrack {
virtual scoped_refptr<VideoDevice> GetVideoCapture() = 0; virtual scoped_refptr<VideoDevice> GetVideoCapture() = 0;
protected: protected:
virtual ~LocalVideoTrack() {}; virtual ~LocalVideoTrack() {}
}; };
class AudioTrack : public MediaStreamTrack { class AudioTrack : public MediaStreamTrack {
public: public:
protected: protected:
virtual ~AudioTrack() {}; virtual ~AudioTrack() {}
}; };
class LocalAudioTrack : public AudioTrack { class LocalAudioTrack : public AudioTrack {
@ -164,17 +166,17 @@ class LocalAudioTrack : public AudioTrack {
// Get the AudioDevice associated with this track. // Get the AudioDevice associated with this track.
virtual scoped_refptr<AudioDevice> GetAudioDevice() = 0; virtual scoped_refptr<AudioDevice> GetAudioDevice() = 0;
protected: protected:
virtual ~LocalAudioTrack() {}; virtual ~LocalAudioTrack() {}
}; };
// List of of tracks. // List of of tracks.
class MediaStreamTrackList : public RefCount { class MediaStreamTrackList : public RefCount, public Notifier {
public: public:
virtual size_t count() = 0; virtual size_t count() = 0;
virtual scoped_refptr<MediaStreamTrack> at(size_t index) = 0; virtual scoped_refptr<MediaStreamTrack> at(size_t index) = 0;
protected: protected:
virtual ~MediaStreamTrackList() {}; virtual ~MediaStreamTrackList() {}
}; };
class MediaStream : public RefCount { class MediaStream : public RefCount {
@ -188,15 +190,15 @@ class MediaStream : public RefCount {
kEnded = 2, // Stream have ended kEnded = 2, // Stream have ended
}; };
virtual ReadyState readyState() = 0; virtual ReadyState ready_state() = 0;
protected: protected:
virtual ~MediaStream() {}; virtual ~MediaStream() {}
}; };
class LocalStream : public MediaStream { class LocalMediaStream : public MediaStream {
public: public:
static scoped_refptr<LocalStream> Create(const std::string& label); static scoped_refptr<LocalMediaStream> Create(const std::string& label);
virtual bool AddTrack(MediaStreamTrack* track) = 0; virtual bool AddTrack(MediaStreamTrack* track) = 0;
}; };
@ -204,8 +206,8 @@ public:
// client using PeerConnectionObserver::OnAddStream. // client using PeerConnectionObserver::OnAddStream.
// The client can provide the renderer to the PeerConnection object calling // The client can provide the renderer to the PeerConnection object calling
// VideoTrack::SetRenderer. // VideoTrack::SetRenderer.
class RemoteStream : public MediaStream { class RemoteMediaStream : public MediaStream {
public: public:
}; };
} // namespace webrtc } // namespace webrtc