Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Unified Diff: content/renderer/media/mock_media_stream_dependency_factory.cc

Issue 14346002: Connect webrtc MediaSourceInterface ready states with webkit WebMediaStreamSource (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: revised according to comments from tommi Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/media/mock_media_stream_dependency_factory.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/mock_media_stream_dependency_factory.cc
diff --git a/content/renderer/media/mock_media_stream_dependency_factory.cc b/content/renderer/media/mock_media_stream_dependency_factory.cc
index 53c0e762cef4cb4e30f7a3f80bbfef2ef5196ff4..f88a74a481560dd0ad7ad93fdea481425306663f 100644
--- a/content/renderer/media/mock_media_stream_dependency_factory.cc
+++ b/content/renderer/media/mock_media_stream_dependency_factory.cc
@@ -148,8 +148,7 @@ webrtc::MediaSourceInterface::SourceState MockAudioSource::state() const {
}
MockVideoSource::MockVideoSource()
- : observer_(NULL),
- state_(MediaSourceInterface::kInitializing) {
+ : state_(MediaSourceInterface::kInitializing) {
}
MockVideoSource::~MockVideoSource() {}
@@ -168,26 +167,37 @@ void MockVideoSource::RemoveSink(cricket::VideoRenderer* output) {
}
void MockVideoSource::RegisterObserver(webrtc::ObserverInterface* observer) {
- observer_ = observer;
+ observers_.push_back(observer);
}
void MockVideoSource::UnregisterObserver(webrtc::ObserverInterface* observer) {
- DCHECK(observer_ == observer);
- observer_ = NULL;
+ for (std::vector<ObserverInterface*>::iterator it = observers_.begin();
+ it != observers_.end(); ++it) {
+ if (*it == observer) {
+ observers_.erase(it);
+ break;
+ }
+ }
+}
+
+void MockVideoSource::FireOnChanged() {
+ std::vector<ObserverInterface*> observers(observers_);
+ for (std::vector<ObserverInterface*>::iterator it = observers.begin();
+ it != observers.end(); ++it) {
+ (*it)->OnChanged();
+ }
}
void MockVideoSource::SetLive() {
DCHECK_EQ(MediaSourceInterface::kInitializing, state_);
state_ = MediaSourceInterface::kLive;
- if (observer_)
- observer_->OnChanged();
+ FireOnChanged();
}
void MockVideoSource::SetEnded() {
DCHECK_NE(MediaSourceInterface::kEnded, state_);
state_ = MediaSourceInterface::kEnded;
- if (observer_)
- observer_->OnChanged();
+ FireOnChanged();
}
webrtc::MediaSourceInterface::SourceState MockVideoSource::state() const {
« no previous file with comments | « content/renderer/media/mock_media_stream_dependency_factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698