| 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 17 matching lines...) Expand all Loading... |
| 28 class VideoTrackAdapter; | 28 class VideoTrackAdapter; |
| 29 | 29 |
| 30 // MediaStreamVideoSource is an interface used for sending video frames to a | 30 // MediaStreamVideoSource is an interface used for sending video frames to a |
| 31 // MediaStreamVideoTrack. | 31 // MediaStreamVideoTrack. |
| 32 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html | 32 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html |
| 33 // The purpose of this base class is to be able to implement different | 33 // The purpose of this base class is to be able to implement different |
| 34 // MediaStreaVideoSources such as local video capture, video sources received | 34 // MediaStreaVideoSources such as local video capture, video sources received |
| 35 // on a PeerConnection or a source created in NaCl. | 35 // on a PeerConnection or a source created in NaCl. |
| 36 // All methods calls will be done from the main render thread. | 36 // All methods calls will be done from the main render thread. |
| 37 // | 37 // |
| 38 // When the first track is added to the source by calling AddTrack | 38 // When the first track is added to the source by calling AddTrack the |
| 39 // the MediaStreamVideoSource implementation calls GetCurrentSupportedFormats. | 39 // MediaStreamVideoSource implementation calls GetCurrentSupportedFormats. |
| 40 // the source implementation must call OnSupportedFormats. | 40 // The source implementation must call OnSupportedFormats. |
| 41 // MediaStreamVideoSource then match the constraints provided in AddTrack with | 41 // MediaStreamVideoSource then match the constraints provided in AddTrack with |
| 42 // the formats and call StartSourceImpl. The source implementation must call | 42 // the formats and call StartSourceImpl. The source implementation must call |
| 43 // OnStartDone when the underlying source has been started or failed to start. | 43 // OnStartDone when the underlying source has been started or failed to start. |
| 44 class CONTENT_EXPORT MediaStreamVideoSource | 44 class CONTENT_EXPORT MediaStreamVideoSource |
| 45 : public MediaStreamSource, | 45 : public MediaStreamSource, |
| 46 NON_EXPORTED_BASE(public base::NonThreadSafe) { | 46 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
| 47 public: | 47 public: |
| 48 MediaStreamVideoSource(); | 48 MediaStreamVideoSource(); |
| 49 virtual ~MediaStreamVideoSource(); | 49 virtual ~MediaStreamVideoSource(); |
| 50 | 50 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 81 static const int kDefaultWidth; | 81 static const int kDefaultWidth; |
| 82 static const int kDefaultHeight; | 82 static const int kDefaultHeight; |
| 83 static const int kDefaultFrameRate; | 83 static const int kDefaultFrameRate; |
| 84 | 84 |
| 85 protected: | 85 protected: |
| 86 virtual void DoStopSource() OVERRIDE; | 86 virtual void DoStopSource() OVERRIDE; |
| 87 | 87 |
| 88 // Sets ready state and notifies the ready state to all registered tracks. | 88 // Sets ready state and notifies the ready state to all registered tracks. |
| 89 virtual void SetReadyState(blink::WebMediaStreamSource::ReadyState state); | 89 virtual void SetReadyState(blink::WebMediaStreamSource::ReadyState state); |
| 90 | 90 |
| 91 // Sets muted state and notifies it to all registered tracks. |
| 92 virtual void SetMutedState(bool state); |
| 93 |
| 91 // An implementation must fetch the formats that can currently be used by | 94 // An implementation must fetch the formats that can currently be used by |
| 92 // the source and call OnSupportedFormats when done. | 95 // the source and call OnSupportedFormats when done. |
| 93 // |max_requested_height| and |max_requested_width| is the max height and | 96 // |max_requested_height| and |max_requested_width| is the max height and |
| 94 // width set as a mandatory constraint if set when calling | 97 // width set as a mandatory constraint if set when calling |
| 95 // MediaStreamVideoSource::AddTrack. If max height and max width is not set | 98 // MediaStreamVideoSource::AddTrack. If max height and max width is not set |
| 96 // |max_requested_height| and |max_requested_width| are 0. | 99 // |max_requested_height| and |max_requested_width| are 0. |
| 97 virtual void GetCurrentSupportedFormats( | 100 virtual void GetCurrentSupportedFormats( |
| 98 int max_requested_width, | 101 int max_requested_width, |
| 99 int max_requested_height, | 102 int max_requested_height, |
| 100 const VideoCaptureDeviceFormatsCB& callback) = 0; | 103 const VideoCaptureDeviceFormatsCB& callback) = 0; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 // Trigger all cached callbacks from AddTrack. AddTrack is successful | 140 // Trigger all cached callbacks from AddTrack. AddTrack is successful |
| 138 // if the capture delegate has started and the constraints provided in | 141 // if the capture delegate has started and the constraints provided in |
| 139 // AddTrack match the format that was used to start the device. | 142 // AddTrack match the format that was used to start the device. |
| 140 // Note that it must be ok to delete the MediaStreamVideoSource object | 143 // Note that it must be ok to delete the MediaStreamVideoSource object |
| 141 // in the context of the callback. If gUM fail, the implementation will | 144 // in the context of the callback. If gUM fail, the implementation will |
| 142 // simply drop the references to the blink source and track which will lead | 145 // simply drop the references to the blink source and track which will lead |
| 143 // to that this object is deleted. | 146 // to that this object is deleted. |
| 144 void FinalizeAddTrack(); | 147 void FinalizeAddTrack(); |
| 145 | 148 |
| 146 State state_; | 149 State state_; |
| 150 bool muted_state_; |
| 147 | 151 |
| 148 media::VideoCaptureFormat current_format_; | 152 media::VideoCaptureFormat current_format_; |
| 149 | 153 |
| 150 struct RequestedConstraints { | 154 struct RequestedConstraints { |
| 151 RequestedConstraints(MediaStreamVideoTrack* track, | 155 RequestedConstraints(MediaStreamVideoTrack* track, |
| 152 const VideoCaptureDeliverFrameCB& frame_callback, | 156 const VideoCaptureDeliverFrameCB& frame_callback, |
| 153 const blink::WebMediaConstraints& constraints, | 157 const blink::WebMediaConstraints& constraints, |
| 154 const ConstraintsCallback& callback); | 158 const ConstraintsCallback& callback); |
| 155 ~RequestedConstraints(); | 159 ~RequestedConstraints(); |
| 156 | 160 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 171 | 175 |
| 172 // NOTE: Weak pointers must be invalidated before all other member variables. | 176 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 173 base::WeakPtrFactory<MediaStreamVideoSource> weak_factory_; | 177 base::WeakPtrFactory<MediaStreamVideoSource> weak_factory_; |
| 174 | 178 |
| 175 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource); | 179 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource); |
| 176 }; | 180 }; |
| 177 | 181 |
| 178 } // namespace content | 182 } // namespace content |
| 179 | 183 |
| 180 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ | 184 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ |
| OLD | NEW |