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

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: Move initialization of the audio source object to MediaStreamAudioSource::AddTrack and check result. Created 6 years, 10 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 {}
51 // default adapter if the adapter is not set already. 52
53 // Called when the first track is added to this source.
54 // It currently creates a webrtc::VideoSourceInterface.
55 // If a derived class overrides this method, it must call SetAdapter.
56 virtual void InitAdapter(const blink::WebMediaConstraints& constraints);
57
58 // Set the webrtc::VideoSourceInterface adapter used by this class.
59 // It must be called by a derived class that overrides the Init method.
Jói 2014/01/27 22:14:57 Init method -> InitAdapter method
perkj_chrome 2014/01/28 08:31:43 Done.
52 void SetAdapter(webrtc::VideoSourceInterface* adapter) { 60 void SetAdapter(webrtc::VideoSourceInterface* adapter) {
53 DCHECK(!adapter_); 61 DCHECK(!adapter_);
54 adapter_ = adapter; 62 adapter_ = adapter;
55 } 63 }
56 64
57 // Called by the derived class before any other methods except SetAdapter. 65 MediaStreamDependencyFactory* factory() { return factory_; }
58 void Init();
59 66
60 // Sets ready state and notifies the ready state to all registered tracks. 67 // Sets ready state and notifies the ready state to all registered tracks.
61 virtual void SetReadyState(blink::WebMediaStreamSource::ReadyState state); 68 virtual void SetReadyState(blink::WebMediaStreamSource::ReadyState state);
62 69
63 // Delivers |frame| to registered tracks according to their constraints. 70 // Delivers |frame| to registered tracks according to their constraints.
64 // Note: current implementation assumes |frame| be contiguous layout of image 71 // Note: current implementation assumes |frame| be contiguous layout of image
65 // planes and I420. 72 // planes and I420.
66 virtual void DeliverVideoFrame(const scoped_refptr<media::VideoFrame>& frame); 73 virtual void DeliverVideoFrame(const scoped_refptr<media::VideoFrame>& frame);
67 74
75 // Implements webrtc::Observer.
76 virtual void OnChanged() OVERRIDE;
77
68 virtual ~MediaStreamVideoSource(); 78 virtual ~MediaStreamVideoSource();
69 79
70 private: 80 private:
81 void CheckIfAdapterIsLive();
82
83 bool initializing_;
71 MediaStreamDependencyFactory* factory_; 84 MediaStreamDependencyFactory* factory_;
72 scoped_refptr<webrtc::VideoSourceInterface> adapter_; 85 scoped_refptr<webrtc::VideoSourceInterface> adapter_;
73 int width_; 86 int width_;
74 int height_; 87 int height_;
75 base::TimeDelta first_frame_timestamp_; 88 base::TimeDelta first_frame_timestamp_;
89
90 blink::WebMediaConstraints current_constraints_;
91 std::vector<ConstraintsCallback> constraints_callbacks_;
92
93 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource);
76 }; 94 };
77 95
78 } // namespace content 96 } // namespace content
79 97
80 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ 98 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698