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

Side by Side Diff: content/renderer/media/media_stream_video_source.h

Issue 155853002: Chrome MediaStream VideoTrack implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More cleanup. Created 6 years, 9 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 <vector> 8 #include <vector>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
12 #include "content/renderer/media/media_stream_dependency_factory.h" 12 #include "content/renderer/media/media_stream_dependency_factory.h"
13 #include "content/renderer/media/media_stream_source.h" 13 #include "content/renderer/media/media_stream_source.h"
14 #include "content/renderer/media/media_stream_video_track.h"
14 #include "media/base/video_frame.h" 15 #include "media/base/video_frame.h"
15 #include "media/video/capture/video_capture_types.h" 16 #include "media/video/capture/video_capture_types.h"
16 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" 17 #include "third_party/WebKit/public/platform/WebMediaConstraints.h"
17 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" 18 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h"
18 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" 19 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
19 20
20 namespace media { 21 namespace media {
21 class VideoFrame; 22 class VideoFrame;
22 } 23 }
23 24
24 namespace content { 25 namespace content {
25 26
26 class MediaStreamDependencyFactory; 27 class MediaStreamDependencyFactory;
28 class MediaStreamVideoTrack;
27 class WebRtcVideoCapturerAdapter; 29 class WebRtcVideoCapturerAdapter;
28 30
29 // MediaStreamVideoSource is an interface used for sending video frames to a 31 // MediaStreamVideoSource is an interface used for sending video frames to a
30 // MediaStreamVideoTrack. 32 // MediaStreamVideoTrack.
31 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html 33 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html
32 // The purpose of this base class is to be able to implement different 34 // The purpose of this base class is to be able to implement different
33 // MediaStreaVideoSources such as local video capture, video sources received 35 // MediaStreaVideoSources such as local video capture, video sources received
34 // on a PeerConnection or a source created in NaCl. 36 // on a PeerConnection or a source created in NaCl.
35 // All methods calls will be done from the main render thread. 37 // All methods calls will be done from the main render thread.
36 // 38 //
37 // When the first track is added to the source by calling AddTrack 39 // When the first track is added to the source by calling AddTrack
38 // the MediaStreamVideoSource implementation calls GetCurrentSupportedFormats. 40 // the MediaStreamVideoSource implementation calls GetCurrentSupportedFormats.
39 // the source implementation must call OnSupportedFormats. 41 // the source implementation must call OnSupportedFormats.
40 // MediaStreamVideoSource then match the constraints provided in AddTrack with 42 // MediaStreamVideoSource then match the constraints provided in AddTrack with
41 // the formats and call StartSourceImpl. The source implementation must call 43 // the formats and call StartSourceImpl. The source implementation must call
42 // OnStartDone when the underlying source has been started or failed to 44 // OnStartDone when the underlying source has been started or failed to
43 // start. 45 // start.
44 class CONTENT_EXPORT MediaStreamVideoSource 46 class CONTENT_EXPORT MediaStreamVideoSource
45 : public MediaStreamSource, 47 : public MediaStreamSource,
46 NON_EXPORTED_BASE(public base::NonThreadSafe) { 48 NON_EXPORTED_BASE(public base::NonThreadSafe) {
47 public: 49 public:
48 explicit MediaStreamVideoSource(MediaStreamDependencyFactory* factory); 50 explicit MediaStreamVideoSource(MediaStreamDependencyFactory* factory);
49 virtual ~MediaStreamVideoSource(); 51 virtual ~MediaStreamVideoSource();
50 52
53 static MediaStreamVideoSource* GetVideoSource(
Ronghua Wu (Left Chromium) 2014/03/01 01:26:04 Put comments.
perkj_chrome 2014/03/02 09:20:44 Done.
54 const blink::WebMediaStreamSource& source);
55
51 // Puts |track| in the registered tracks list. 56 // Puts |track| in the registered tracks list.
52 virtual void AddTrack(const blink::WebMediaStreamTrack& track, 57 virtual void AddTrack(const blink::WebMediaStreamTrack& track,
Alpha Left Google 2014/02/28 02:49:22 This is odd. I think it should just take the nativ
Ronghua Wu (Left Chromium) 2014/03/01 01:26:04 Make sense. And I saw you called RemoveTrack from
perkj_chrome 2014/03/02 09:20:44 I can not call AddTrack in the ctor. gUM needs to
perkj_chrome 2014/03/02 09:20:44 ok - but then I need to change the base class and
Alpha Left Google 2014/03/03 06:45:04 Okay.
53 const blink::WebMediaConstraints& constraints, 58 const blink::WebMediaConstraints& constraints,
54 const ConstraintsCallback& callback) OVERRIDE; 59 const ConstraintsCallback& callback) OVERRIDE;
55 virtual void RemoveTrack(const blink::WebMediaStreamTrack& track) OVERRIDE; 60 void RemoveTrack(MediaStreamVideoTrack* track);
56 61
57 // TODO(ronghuawu): Remove webrtc::VideoSourceInterface from the public 62 // TODO(ronghuawu): Remove webrtc::VideoSourceInterface from the public
58 // interface of this class. 63 // interface of this class.
59 // This creates a VideoSourceInterface implementation if it does not already 64 // This creates a VideoSourceInterface implementation if it does not already
60 // exist. 65 // exist.
61 webrtc::VideoSourceInterface* GetAdapter(); 66 webrtc::VideoSourceInterface* GetAdapter();
62 67
63 // Constraint keys used by a video source. 68 // Constraint keys used by a video source.
64 // Specified by draft-alvestrand-constraints-resolution-00b 69 // Specified by draft-alvestrand-constraints-resolution-00b
65 static const char kMinAspectRatio[]; // minAspectRatio 70 static const char kMinAspectRatio[]; // minAspectRatio
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 const ConstraintsCallback& callback); 152 const ConstraintsCallback& callback);
148 ~RequestedConstraints(); 153 ~RequestedConstraints();
149 154
150 blink::WebMediaConstraints constraints; 155 blink::WebMediaConstraints constraints;
151 ConstraintsCallback callback; 156 ConstraintsCallback callback;
152 }; 157 };
153 std::vector<RequestedConstraints> requested_constraints_; 158 std::vector<RequestedConstraints> requested_constraints_;
154 159
155 media::VideoCaptureFormats supported_formats_; 160 media::VideoCaptureFormats supported_formats_;
156 161
162 // Tracks that currently are receiving video frames.
163 std::vector<MediaStreamVideoTrack*> tracks_;
164
157 // TODO(perkj): The below classes use webrtc/libjingle types. The goal is to 165 // TODO(perkj): The below classes use webrtc/libjingle types. The goal is to
158 // get rid of them as far as possible. 166 // get rid of them as far as possible.
159 MediaStreamDependencyFactory* factory_; 167 MediaStreamDependencyFactory* factory_;
160 scoped_refptr<webrtc::VideoSourceInterface> adapter_; 168 scoped_refptr<webrtc::VideoSourceInterface> adapter_;
161 WebRtcVideoCapturerAdapter* capture_adapter_; 169 WebRtcVideoCapturerAdapter* capture_adapter_;
162 170
163 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource); 171 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource);
164 }; 172 };
165 173
166 } // namespace content 174 } // namespace content
167 175
168 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ 176 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698