| 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 29 matching lines...) Expand all Loading... |
| 40 // When the first track is added to the source by calling AddTrack, the | 40 // When the first track is added to the source by calling AddTrack, the |
| 41 // MediaStreamVideoSource implementation calls GetCurrentSupportedFormats. | 41 // MediaStreamVideoSource implementation calls GetCurrentSupportedFormats. |
| 42 // The source implementation must call OnSupportedFormats. | 42 // The source implementation must call OnSupportedFormats. |
| 43 // MediaStreamVideoSource then match the constraints provided in AddTrack with | 43 // MediaStreamVideoSource then match the constraints provided in AddTrack with |
| 44 // the formats and call StartSourceImpl. The source implementation must call | 44 // the formats and call StartSourceImpl. The source implementation must call |
| 45 // OnStartDone when the underlying source has been started or failed to start. | 45 // OnStartDone when the underlying source has been started or failed to start. |
| 46 class CONTENT_EXPORT MediaStreamVideoSource | 46 class CONTENT_EXPORT MediaStreamVideoSource |
| 47 : public MediaStreamSource, | 47 : public MediaStreamSource, |
| 48 NON_EXPORTED_BASE(public base::NonThreadSafe) { | 48 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
| 49 public: | 49 public: |
| 50 // Constraint keys used by a video source. | |
| 51 // Specified by draft-alvestrand-constraints-resolution-00b | |
| 52 static const char kMinAspectRatio[]; // minAspectRatio | |
| 53 static const char kMaxAspectRatio[]; // maxAspectRatio | |
| 54 static const char kMaxWidth[]; // maxWidth | |
| 55 static const char kMinWidth[]; // minWidth | |
| 56 static const char kMaxHeight[]; // maxHeight | |
| 57 static const char kMinHeight[]; // minHeight | |
| 58 static const char kMaxFrameRate[]; // maxFrameRate | |
| 59 static const char kMinFrameRate[]; // minFrameRate | |
| 60 | |
| 61 enum { | 50 enum { |
| 62 // Default resolution. If no constraints are specified and the delegate | 51 // Default resolution. If no constraints are specified and the delegate |
| 63 // support it, this is the resolution that will be used. | 52 // support it, this is the resolution that will be used. |
| 64 kDefaultWidth = 640, | 53 kDefaultWidth = 640, |
| 65 kDefaultHeight = 480, | 54 kDefaultHeight = 480, |
| 66 | 55 |
| 67 kDefaultFrameRate = 30, | 56 kDefaultFrameRate = 30, |
| 68 kUnknownFrameRate = 0, | 57 kUnknownFrameRate = 0, |
| 69 }; | 58 }; |
| 70 | 59 |
| 71 MediaStreamVideoSource(); | 60 MediaStreamVideoSource(); |
| 72 ~MediaStreamVideoSource() override; | 61 ~MediaStreamVideoSource() override; |
| 73 | 62 |
| 74 // Returns the MediaStreamVideoSource object owned by |source|. | 63 // Returns the MediaStreamVideoSource object owned by |source|. |
| 75 static MediaStreamVideoSource* GetVideoSource( | 64 static MediaStreamVideoSource* GetVideoSource( |
| 76 const blink::WebMediaStreamSource& source); | 65 const blink::WebMediaStreamSource& source); |
| 77 | 66 |
| 78 // Puts |track| in the registered tracks list. | 67 // Puts |track| in the registered tracks list. |
| 79 void AddTrack(MediaStreamVideoTrack* track, | 68 void AddTrack(MediaStreamVideoTrack* track, |
| 80 const VideoCaptureDeliverFrameCB& frame_callback, | 69 const VideoCaptureDeliverFrameCB& frame_callback, |
| 81 const blink::WebMediaConstraints& constraints, | 70 const blink::WebMediaConstraints& constraints, |
| 82 const ConstraintsCallback& callback); | 71 const ConstraintsCallback& callback); |
| 83 void RemoveTrack(MediaStreamVideoTrack* track); | 72 void RemoveTrack(MediaStreamVideoTrack* track); |
| 84 | 73 |
| 85 void UpdateCapturingLinkSecure(MediaStreamVideoTrack* track, bool is_secure); | 74 void UpdateCapturingLinkSecure(MediaStreamVideoTrack* track, bool is_secure); |
| 86 | 75 |
| 87 // Return true if |name| is a constraint supported by MediaStreamVideoSource. | |
| 88 static bool IsConstraintSupported(const std::string& name); | |
| 89 | |
| 90 // Request underlying source to capture a new frame. | 76 // Request underlying source to capture a new frame. |
| 91 virtual void RequestRefreshFrame() {} | 77 virtual void RequestRefreshFrame() {} |
| 92 | 78 |
| 93 // Notify underlying source if the capturing link is secure. | 79 // Notify underlying source if the capturing link is secure. |
| 94 virtual void SetCapturingLinkSecured(bool is_secure) {} | 80 virtual void SetCapturingLinkSecured(bool is_secure) {} |
| 95 | 81 |
| 96 // Returns the task runner where video frames will be delivered on. | 82 // Returns the task runner where video frames will be delivered on. |
| 97 base::SingleThreadTaskRunner* io_task_runner() const; | 83 base::SingleThreadTaskRunner* io_task_runner() const; |
| 98 | 84 |
| 99 const media::VideoCaptureFormat* GetCurrentFormat() const; | 85 const media::VideoCaptureFormat* GetCurrentFormat() const; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 188 |
| 203 // NOTE: Weak pointers must be invalidated before all other member variables. | 189 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 204 base::WeakPtrFactory<MediaStreamVideoSource> weak_factory_; | 190 base::WeakPtrFactory<MediaStreamVideoSource> weak_factory_; |
| 205 | 191 |
| 206 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource); | 192 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource); |
| 207 }; | 193 }; |
| 208 | 194 |
| 209 } // namespace content | 195 } // namespace content |
| 210 | 196 |
| 211 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ | 197 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ |
| OLD | NEW |