| 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 <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/optional.h" | 15 #include "base/optional.h" |
| 16 #include "base/threading/non_thread_safe.h" | 16 #include "base/sequence_checker.h" |
| 17 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
| 18 #include "content/common/media/video_capture.h" | 18 #include "content/common/media/video_capture.h" |
| 19 #include "content/renderer/media/media_stream_source.h" | 19 #include "content/renderer/media/media_stream_source.h" |
| 20 #include "content/renderer/media/secure_display_link_tracker.h" | 20 #include "content/renderer/media/secure_display_link_tracker.h" |
| 21 #include "media/base/video_frame.h" | 21 #include "media/base/video_frame.h" |
| 22 #include "media/capture/video_capture_types.h" | 22 #include "media/capture/video_capture_types.h" |
| 23 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" | 23 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
| 24 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" | 24 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" |
| 25 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 25 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
| 26 | 26 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 39 // MediaStreaVideoSources such as local video capture, video sources received | 39 // MediaStreaVideoSources such as local video capture, video sources received |
| 40 // on a PeerConnection or a source created in NaCl. | 40 // on a PeerConnection or a source created in NaCl. |
| 41 // All methods calls will be done from the main render thread. | 41 // All methods calls will be done from the main render thread. |
| 42 // | 42 // |
| 43 // When the first track is added to the source by calling AddTrack, the | 43 // When the first track is added to the source by calling AddTrack, the |
| 44 // MediaStreamVideoSource implementation calls GetCurrentSupportedFormats. | 44 // MediaStreamVideoSource implementation calls GetCurrentSupportedFormats. |
| 45 // The source implementation must call OnSupportedFormats. | 45 // The source implementation must call OnSupportedFormats. |
| 46 // MediaStreamVideoSource then match the constraints provided in AddTrack with | 46 // MediaStreamVideoSource then match the constraints provided in AddTrack with |
| 47 // the formats and call StartSourceImpl. The source implementation must call | 47 // the formats and call StartSourceImpl. The source implementation must call |
| 48 // OnStartDone when the underlying source has been started or failed to start. | 48 // OnStartDone when the underlying source has been started or failed to start. |
| 49 class CONTENT_EXPORT MediaStreamVideoSource | 49 class CONTENT_EXPORT MediaStreamVideoSource : public MediaStreamSource { |
| 50 : public MediaStreamSource, | |
| 51 NON_EXPORTED_BASE(public base::NonThreadSafe) { | |
| 52 public: | 50 public: |
| 53 enum { | 51 enum { |
| 54 // Default resolution. If no constraints are specified and the delegate | 52 // Default resolution. If no constraints are specified and the delegate |
| 55 // support it, this is the resolution that will be used. | 53 // support it, this is the resolution that will be used. |
| 56 kDefaultWidth = 640, | 54 kDefaultWidth = 640, |
| 57 kDefaultHeight = 480, | 55 kDefaultHeight = 480, |
| 58 | 56 |
| 59 kDefaultFrameRate = 30, | 57 kDefaultFrameRate = 30, |
| 60 kUnknownFrameRate = 0, | 58 kUnknownFrameRate = 0, |
| 61 }; | 59 }; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 enum State { | 157 enum State { |
| 160 NEW, | 158 NEW, |
| 161 // TODO(guidou): Remove this state. http://crbug.com/706408 | 159 // TODO(guidou): Remove this state. http://crbug.com/706408 |
| 162 RETRIEVING_CAPABILITIES, | 160 RETRIEVING_CAPABILITIES, |
| 163 STARTING, | 161 STARTING, |
| 164 STARTED, | 162 STARTED, |
| 165 ENDED | 163 ENDED |
| 166 }; | 164 }; |
| 167 State state() const { return state_; } | 165 State state() const { return state_; } |
| 168 | 166 |
| 167 SEQUENCE_CHECKER(sequence_checker_); |
| 168 |
| 169 private: | 169 private: |
| 170 void OnSupportedFormats(const media::VideoCaptureFormats& formats); | 170 void OnSupportedFormats(const media::VideoCaptureFormats& formats); |
| 171 | 171 |
| 172 // Finds the first WebMediaConstraints in |track_descriptors_| that allows | 172 // Finds the first WebMediaConstraints in |track_descriptors_| that allows |
| 173 // the use of one of the |formats|. |best_format| and |fulfilled_constraints| | 173 // the use of one of the |formats|. |best_format| and |fulfilled_constraints| |
| 174 // are set to the results of this search-and-match operation. Returns false | 174 // are set to the results of this search-and-match operation. Returns false |
| 175 // if no WebMediaConstraints allow the use any of the |formats|. | 175 // if no WebMediaConstraints allow the use any of the |formats|. |
| 176 bool FindBestFormatWithConstraints( | 176 bool FindBestFormatWithConstraints( |
| 177 const media::VideoCaptureFormats& formats, | 177 const media::VideoCaptureFormats& formats, |
| 178 media::VideoCaptureFormat* best_format, | 178 media::VideoCaptureFormat* best_format, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 235 |
| 236 // NOTE: Weak pointers must be invalidated before all other member variables. | 236 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 237 base::WeakPtrFactory<MediaStreamVideoSource> weak_factory_; | 237 base::WeakPtrFactory<MediaStreamVideoSource> weak_factory_; |
| 238 | 238 |
| 239 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource); | 239 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource); |
| 240 }; | 240 }; |
| 241 | 241 |
| 242 } // namespace content | 242 } // namespace content |
| 243 | 243 |
| 244 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ | 244 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ |
| OLD | NEW |