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

Unified Diff: content/renderer/media/media_stream_video_source.h

Issue 131763002: Adds MediaStreamSource, MediaStreamAudioSource and MediaStreamVideoCaptureDeviceSource (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 6 years, 11 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
Index: content/renderer/media/media_stream_video_source.h
diff --git a/content/renderer/media/media_stream_video_source.h b/content/renderer/media/media_stream_video_source.h
index f97b9c46a53cb9a755639b273ac6ed165afb6035..063bf0cce89b3216caea98972724051755017fd0 100644
--- a/content/renderer/media/media_stream_video_source.h
+++ b/content/renderer/media/media_stream_video_source.h
@@ -8,7 +8,8 @@
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "content/common/content_export.h"
-#include "content/renderer/media/media_stream_source_extra_data.h"
+#include "content/renderer/media/media_stream_dependency_factory.h"
+#include "content/renderer/media/media_stream_source.h"
#include "third_party/WebKit/public/platform/WebMediaConstraints.h"
#include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
#include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
@@ -26,19 +27,19 @@ class MediaStreamDependencyFactory;
// http://dev.w3.org/2011/webrtc/editor/getusermedia.html
// All methods calls will be done from the main render thread.
class CONTENT_EXPORT MediaStreamVideoSource
- : public MediaStreamSourceExtraData {
+ : public MediaStreamSource,
+ NON_EXPORTED_BASE(public webrtc::ObserverInterface),
+ NON_EXPORTED_BASE(public base::NonThreadSafe) {
public:
explicit MediaStreamVideoSource(
MediaStreamDependencyFactory* factory);
- // Puts |track| in the registered tracks list. Will later
- // deliver frames to it according to |constraints|.
- virtual void AddTrack(const blink::WebMediaStreamTrack& track,
- const blink::WebMediaConstraints& constraints);
- // Removes |track| from the registered tracks list, i.e. will stop delivering
- // frame to |track|.
- virtual void RemoveTrack(const blink::WebMediaStreamTrack& track);
+ // Puts |track| in the registered tracks list.
+ virtual void AddTrack(const blink::WebMediaStreamTrack& track,
+ const blink::WebMediaConstraints& constraints,
+ const ConstraintsCallback& callback) OVERRIDE;
+ virtual void RemoveTrack(const blink::WebMediaStreamTrack& track) OVERRIDE;
// TODO(ronghuawu): Remove webrtc::VideoSourceInterface from the public
// interface of this class.
@@ -47,15 +48,21 @@ class CONTENT_EXPORT MediaStreamVideoSource
}
protected:
- // Sets an external adapter. Must be called before Init, which creates a
- // default adapter if the adapter is not set already.
+ virtual void DoStopSource() OVERRIDE {}
+
+ // Called when the first track is added to this source.
+ // It currently creates a webrtc::VideoSourceInterface.
+ // If a derived class overrides this method, it must call SetAdapter.
+ virtual void InitAdapter(const blink::WebMediaConstraints& constraints);
+
+ // Set the webrtc::VideoSourceInterface adapter used by this class.
+ // It must be called by a derived class that overrides the InitAdapter method.
void SetAdapter(webrtc::VideoSourceInterface* adapter) {
DCHECK(!adapter_);
adapter_ = adapter;
}
- // Called by the derived class before any other methods except SetAdapter.
- void Init();
+ MediaStreamDependencyFactory* factory() { return factory_; }
// Sets ready state and notifies the ready state to all registered tracks.
virtual void SetReadyState(blink::WebMediaStreamSource::ReadyState state);
@@ -65,14 +72,28 @@ class CONTENT_EXPORT MediaStreamVideoSource
// planes and I420.
virtual void DeliverVideoFrame(const scoped_refptr<media::VideoFrame>& frame);
+ // Implements webrtc::Observer.
+ virtual void OnChanged() OVERRIDE;
+
virtual ~MediaStreamVideoSource();
private:
+ // Checks if the underlying source state has changed from an initializing
+ // state to a final state and in that case trigger all callbacks in
+ // |constraints_callbacks_|.
+ void TriggerConstraintsCallbackOnStateChange();
+
+ bool initializing_;
MediaStreamDependencyFactory* factory_;
scoped_refptr<webrtc::VideoSourceInterface> adapter_;
int width_;
int height_;
base::TimeDelta first_frame_timestamp_;
+
+ blink::WebMediaConstraints current_constraints_;
+ std::vector<ConstraintsCallback> constraints_callbacks_;
+
+ DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource);
};
} // namespace content
« no previous file with comments | « content/renderer/media/media_stream_video_capturer_source.cc ('k') | content/renderer/media/media_stream_video_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698