OLD | NEW |
---|---|
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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 static MediaStreamVideoSource* GetVideoSource( | 64 static MediaStreamVideoSource* GetVideoSource( |
65 const blink::WebMediaStreamSource& source); | 65 const blink::WebMediaStreamSource& source); |
66 | 66 |
67 // Puts |track| in the registered tracks list. | 67 // Puts |track| in the registered tracks list. |
68 void AddTrack(MediaStreamVideoTrack* track, | 68 void AddTrack(MediaStreamVideoTrack* track, |
69 const VideoCaptureDeliverFrameCB& frame_callback, | 69 const VideoCaptureDeliverFrameCB& frame_callback, |
70 const blink::WebMediaConstraints& constraints, | 70 const blink::WebMediaConstraints& constraints, |
71 const ConstraintsCallback& callback); | 71 const ConstraintsCallback& callback); |
72 void RemoveTrack(MediaStreamVideoTrack* track); | 72 void RemoveTrack(MediaStreamVideoTrack* track); |
73 | 73 |
74 // Called by |track| to notify the source whether it has any paths to a | |
75 // consuming endpoint. | |
76 void UpdateHasConsumers(MediaStreamVideoTrack* track, bool has_consumers); | |
77 | |
74 void UpdateCapturingLinkSecure(MediaStreamVideoTrack* track, bool is_secure); | 78 void UpdateCapturingLinkSecure(MediaStreamVideoTrack* track, bool is_secure); |
75 | 79 |
76 // Request underlying source to capture a new frame. | 80 // Request underlying source to capture a new frame. |
77 virtual void RequestRefreshFrame() {} | 81 virtual void RequestRefreshFrame() {} |
78 | 82 |
79 // Notify underlying source if the capturing link is secure. | |
80 virtual void SetCapturingLinkSecured(bool is_secure) {} | |
81 | |
82 // Returns the task runner where video frames will be delivered on. | 83 // Returns the task runner where video frames will be delivered on. |
83 base::SingleThreadTaskRunner* io_task_runner() const; | 84 base::SingleThreadTaskRunner* io_task_runner() const; |
84 | 85 |
85 const media::VideoCaptureFormat* GetCurrentFormat() const; | 86 const media::VideoCaptureFormat* GetCurrentFormat() const; |
86 | 87 |
87 base::WeakPtr<MediaStreamVideoSource> GetWeakPtr() { | 88 base::WeakPtr<MediaStreamVideoSource> GetWeakPtr() { |
88 return weak_factory_.GetWeakPtr(); | 89 return weak_factory_.GetWeakPtr(); |
89 } | 90 } |
90 | 91 |
91 protected: | 92 protected: |
(...skipping 27 matching lines...) Expand all Loading... | |
119 const media::VideoCaptureFormat& format, | 120 const media::VideoCaptureFormat& format, |
120 const blink::WebMediaConstraints& constraints, | 121 const blink::WebMediaConstraints& constraints, |
121 const VideoCaptureDeliverFrameCB& frame_callback) = 0; | 122 const VideoCaptureDeliverFrameCB& frame_callback) = 0; |
122 void OnStartDone(MediaStreamRequestResult result); | 123 void OnStartDone(MediaStreamRequestResult result); |
123 | 124 |
124 // An implementation must immediately stop capture video frames and must not | 125 // An implementation must immediately stop capture video frames and must not |
125 // call OnSupportedFormats after this method has been called. After this | 126 // call OnSupportedFormats after this method has been called. After this |
126 // method has been called, MediaStreamVideoSource may be deleted. | 127 // method has been called, MediaStreamVideoSource may be deleted. |
127 virtual void StopSourceImpl() = 0; | 128 virtual void StopSourceImpl() = 0; |
128 | 129 |
130 // Optionally overridden by subclasses to act on whether there are any | |
131 // consumers present. When none are present, the source can stop delivering | |
132 // frames, giving it the option of running in an "idle" state to minimize | |
133 // resource usage. | |
134 virtual void OnHasConsumers(bool has_consumers) {} | |
135 | |
136 // Optionally overridden by subclasses to act on whether the capturing link | |
137 // has become secure or insecure. | |
138 virtual void OnCapturingLinkSecured(bool is_secure) {} | |
139 | |
129 enum State { | 140 enum State { |
130 NEW, | 141 NEW, |
131 RETRIEVING_CAPABILITIES, | 142 RETRIEVING_CAPABILITIES, |
132 STARTING, | 143 STARTING, |
133 STARTED, | 144 STARTED, |
134 ENDED | 145 ENDED |
135 }; | 146 }; |
136 State state() const { return state_; } | 147 State state() const { return state_; } |
137 | 148 |
138 private: | 149 private: |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 std::vector<TrackDescriptor> track_descriptors_; | 187 std::vector<TrackDescriptor> track_descriptors_; |
177 | 188 |
178 media::VideoCaptureFormats supported_formats_; | 189 media::VideoCaptureFormats supported_formats_; |
179 | 190 |
180 // |track_adapter_| delivers video frames to the tracks on the IO-thread. | 191 // |track_adapter_| delivers video frames to the tracks on the IO-thread. |
181 const scoped_refptr<VideoTrackAdapter> track_adapter_; | 192 const scoped_refptr<VideoTrackAdapter> track_adapter_; |
182 | 193 |
183 // Tracks that currently are connected to this source. | 194 // Tracks that currently are connected to this source. |
184 std::vector<MediaStreamVideoTrack*> tracks_; | 195 std::vector<MediaStreamVideoTrack*> tracks_; |
185 | 196 |
197 // Tracks that have no paths to a consuming endpoint, and so do not need | |
198 // frames delivered from the source. | |
mcasas
2016/09/28 21:34:44
nit: I'd add that |suspended_tracks_| is a subset
miu
2016/09/28 22:35:15
Done.
| |
199 std::vector<MediaStreamVideoTrack*> suspended_tracks_; | |
200 | |
186 // This is used for tracking if all connected video sinks are secure. | 201 // This is used for tracking if all connected video sinks are secure. |
187 SecureDisplayLinkTracker<MediaStreamVideoTrack> secure_tracker_; | 202 SecureDisplayLinkTracker<MediaStreamVideoTrack> secure_tracker_; |
188 | 203 |
189 // NOTE: Weak pointers must be invalidated before all other member variables. | 204 // NOTE: Weak pointers must be invalidated before all other member variables. |
190 base::WeakPtrFactory<MediaStreamVideoSource> weak_factory_; | 205 base::WeakPtrFactory<MediaStreamVideoSource> weak_factory_; |
191 | 206 |
192 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource); | 207 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource); |
193 }; | 208 }; |
194 | 209 |
195 } // namespace content | 210 } // namespace content |
196 | 211 |
197 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ | 212 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ |
OLD | NEW |