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

Side by Side 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: Removed unused file. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "content/common/content_export.h" 10 #include "content/common/content_export.h"
11 #include "content/renderer/media/media_stream_source_extra_data.h" 11 #include "content/renderer/media/media_stream_dependency_factory.h"
12 #include "content/renderer/media/media_stream_source.h"
12 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" 13 #include "third_party/WebKit/public/platform/WebMediaConstraints.h"
13 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" 14 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
14 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" 15 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
15 16
16 namespace media { 17 namespace media {
17 class VideoFrame; 18 class VideoFrame;
18 } 19 }
19 20
20 namespace content { 21 namespace content {
21 22
22 class MediaStreamDependencyFactory; 23 class MediaStreamDependencyFactory;
23 24
24 // MediaStreamVideoSource is an interface used for sending video frames to a 25 // MediaStreamVideoSource is an interface used for sending video frames to a
25 // MediaStreamVideoTrack. 26 // MediaStreamVideoTrack.
26 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html 27 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html
27 // All methods calls will be done from the main render thread. 28 // All methods calls will be done from the main render thread.
28 class CONTENT_EXPORT MediaStreamVideoSource 29 class CONTENT_EXPORT MediaStreamVideoSource
29 : public MediaStreamSourceExtraData { 30 : public MediaStreamSource,
31 NON_EXPORTED_BASE(public webrtc::ObserverInterface),
32 NON_EXPORTED_BASE(public base::NonThreadSafe) {
30 public: 33 public:
31 explicit MediaStreamVideoSource( 34 explicit MediaStreamVideoSource(
32 MediaStreamDependencyFactory* factory); 35 MediaStreamDependencyFactory* factory);
33 36
34 // Puts |track| in the registered tracks list. Will later 37
35 // deliver frames to it according to |constraints|. 38 // Puts |track| in the registered tracks list.
36 virtual void AddTrack(const blink::WebMediaStreamTrack& track, 39 virtual void AddTrack(const blink::WebMediaStreamTrack& track,
37 const blink::WebMediaConstraints& constraints); 40 const blink::WebMediaConstraints& constraints,
38 41 const ConstraintsCallback& callback) OVERRIDE;
39 // Removes |track| from the registered tracks list, i.e. will stop delivering 42 virtual void RemoveTrack(const blink::WebMediaStreamTrack& track) OVERRIDE;
40 // frame to |track|.
41 virtual void RemoveTrack(const blink::WebMediaStreamTrack& track);
42 43
43 // TODO(ronghuawu): Remove webrtc::VideoSourceInterface from the public 44 // TODO(ronghuawu): Remove webrtc::VideoSourceInterface from the public
44 // interface of this class. 45 // interface of this class.
45 webrtc::VideoSourceInterface* GetAdapter() { 46 webrtc::VideoSourceInterface* GetAdapter() {
46 return adapter_; 47 return adapter_;
47 } 48 }
48 49
49 protected: 50 protected:
50 // Sets an external adapter. Must be called before Init, which creates a 51 virtual void DoStopSource() OVERRIDE {}
52
51 // default adapter if the adapter is not set already. 53 // default adapter if the adapter is not set already.
Ronghua Wu (Left Chromium) 2014/01/16 23:02:37 add back the line above this line
perkj_chrome 2014/01/17 13:19:45 Ptal. Note that SetAdapter can be removed once loc
52 void SetAdapter(webrtc::VideoSourceInterface* adapter) { 54 void SetAdapter(webrtc::VideoSourceInterface* adapter) {
53 DCHECK(!adapter_); 55 DCHECK(!adapter_);
54 adapter_ = adapter; 56 adapter_ = adapter;
55 } 57 }
56 58
57 // Called by the derived class before any other methods except SetAdapter. 59 // Called when the first track is added to this source.
58 void Init(); 60 // It currently creates a webrtc::VideoSourceInterface.
61 // If a derived class overrides this method, it must call SetAdapter.
62 virtual void Init(const blink::WebMediaConstraints& constraints);
63
64 MediaStreamDependencyFactory* factory() { return factory_; }
59 65
60 // Sets ready state and notifies the ready state to all registered tracks. 66 // Sets ready state and notifies the ready state to all registered tracks.
61 virtual void SetReadyState(blink::WebMediaStreamSource::ReadyState state); 67 virtual void SetReadyState(blink::WebMediaStreamSource::ReadyState state);
62 68
63 // Delivers |frame| to registered tracks according to their constraints. 69 // Delivers |frame| to registered tracks according to their constraints.
64 // Note: current implementation assumes |frame| be contiguous layout of image 70 // Note: current implementation assumes |frame| be contiguous layout of image
65 // planes and I420. 71 // planes and I420.
66 virtual void DeliverVideoFrame(const scoped_refptr<media::VideoFrame>& frame); 72 virtual void DeliverVideoFrame(const scoped_refptr<media::VideoFrame>& frame);
67 73
74 // Implements webrtc::Observer.
75 virtual void OnChanged() OVERRIDE;
76
68 virtual ~MediaStreamVideoSource(); 77 virtual ~MediaStreamVideoSource();
69 78
70 private: 79 private:
80 void CheckIfAdapterIsLive();
81
82 bool initializing_;
71 MediaStreamDependencyFactory* factory_; 83 MediaStreamDependencyFactory* factory_;
72 scoped_refptr<webrtc::VideoSourceInterface> adapter_; 84 scoped_refptr<webrtc::VideoSourceInterface> adapter_;
73 int width_; 85 int width_;
74 int height_; 86 int height_;
75 base::TimeDelta first_frame_timestamp_; 87 base::TimeDelta first_frame_timestamp_;
88
89 blink::WebMediaConstraints current_constraints_;
90 std::vector<ConstraintsCallback> constraints_callbacks_;
91
92 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource);
76 }; 93 };
77 94
78 } // namespace content 95 } // namespace content
79 96
80 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ 97 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698