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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 // Puts |track| in the registered tracks list. | 57 // Puts |track| in the registered tracks list. |
58 void AddTrack(MediaStreamVideoTrack* track, | 58 void AddTrack(MediaStreamVideoTrack* track, |
59 const blink::WebMediaConstraints& constraints, | 59 const blink::WebMediaConstraints& constraints, |
60 const ConstraintsCallback& callback); | 60 const ConstraintsCallback& callback); |
61 void RemoveTrack(MediaStreamVideoTrack* track); | 61 void RemoveTrack(MediaStreamVideoTrack* track); |
62 | 62 |
63 // TODO(ronghuawu): Remove webrtc::VideoSourceInterface from the public | 63 // TODO(ronghuawu): Remove webrtc::VideoSourceInterface from the public |
64 // interface of this class. | 64 // interface of this class. |
65 // This creates a VideoSourceInterface implementation if it does not already | 65 // This creates a VideoSourceInterface implementation if it does not already |
66 // exist. | 66 // exist. |
67 webrtc::VideoSourceInterface* GetAdapter(); | 67 virtual webrtc::VideoSourceInterface* GetAdapter(); |
68 | 68 |
69 // Constraint keys used by a video source. | 69 // Constraint keys used by a video source. |
70 // Specified by draft-alvestrand-constraints-resolution-00b | 70 // Specified by draft-alvestrand-constraints-resolution-00b |
71 static const char kMinAspectRatio[]; // minAspectRatio | 71 static const char kMinAspectRatio[]; // minAspectRatio |
72 static const char kMaxAspectRatio[]; // maxAspectRatio | 72 static const char kMaxAspectRatio[]; // maxAspectRatio |
73 static const char kMaxWidth[]; // maxWidth | 73 static const char kMaxWidth[]; // maxWidth |
74 static const char kMinWidth[]; // minWidthOnCaptureFormats | 74 static const char kMinWidth[]; // minWidthOnCaptureFormats |
75 static const char kMaxHeight[]; // maxHeight | 75 static const char kMaxHeight[]; // maxHeight |
76 static const char kMinHeight[]; // minHeight | 76 static const char kMinHeight[]; // minHeight |
77 static const char kMaxFrameRate[]; // maxFrameRate | 77 static const char kMaxFrameRate[]; // maxFrameRate |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 // OnStartDone must be called. An implementation must call | 111 // OnStartDone must be called. An implementation must call |
112 // DeliverVideoFrame with the captured frames. | 112 // DeliverVideoFrame with the captured frames. |
113 virtual void StartSourceImpl(const media::VideoCaptureParams& params) = 0; | 113 virtual void StartSourceImpl(const media::VideoCaptureParams& params) = 0; |
114 void OnStartDone(bool success); | 114 void OnStartDone(bool success); |
115 | 115 |
116 // An implementation must immediately stop capture video frames and must not | 116 // An implementation must immediately stop capture video frames and must not |
117 // call OnSupportedFormats after this method has been called. After this | 117 // call OnSupportedFormats after this method has been called. After this |
118 // method has been called, MediaStreamVideoSource may be deleted. | 118 // method has been called, MediaStreamVideoSource may be deleted. |
119 virtual void StopSourceImpl() = 0; | 119 virtual void StopSourceImpl() = 0; |
120 | 120 |
121 enum State { | |
122 NEW, | |
123 RETRIEVING_CAPABILITIES, | |
124 STARTING, | |
125 STARTED, | |
126 ENDED | |
127 }; | |
128 State GetState() const { return state_; } | |
Jói
2014/03/17 22:00:40
Our naming conventions would typically name this m
perkj_chrome
2014/03/19 16:34:48
Done.
| |
129 | |
121 private: | 130 private: |
122 // Creates a webrtc::VideoSourceInterface used by libjingle. | 131 // Creates a webrtc::VideoSourceInterface used by libjingle. |
123 void InitAdapter(); | 132 void InitAdapter(); |
124 | 133 |
125 // Finds the first constraints in |requested_constraints_| that can be | 134 // Finds the first constraints in |requested_constraints_| that can be |
126 // fulfilled. |best_format| is set to the video resolution that can be | 135 // fulfilled. |best_format| is set to the video resolution that can be |
127 // fulfilled. |frame_output_size| is the requested frame size after cropping. | 136 // fulfilled. |frame_output_size| is the requested frame size after cropping. |
128 // |resulting_constraints| is set to the found constraints in | 137 // |resulting_constraints| is set to the found constraints in |
129 // |requested_constraints_|. | 138 // |requested_constraints_|. |
130 bool FindBestFormatWithConstraints( | 139 bool FindBestFormatWithConstraints( |
131 const media::VideoCaptureFormats& formats, | 140 const media::VideoCaptureFormats& formats, |
132 media::VideoCaptureFormat* best_format, | 141 media::VideoCaptureFormat* best_format, |
133 gfx::Size* frame_output_size, | 142 gfx::Size* frame_output_size, |
134 blink::WebMediaConstraints* resulting_constraints); | 143 blink::WebMediaConstraints* resulting_constraints); |
135 | 144 |
136 // Trigger all cached callbacks from AddTrack. AddTrack is successful | 145 // Trigger all cached callbacks from AddTrack. AddTrack is successful |
137 // if the capture delegate has started and the constraints provided in | 146 // if the capture delegate has started and the constraints provided in |
138 // AddTrack match the format that was used to start the device. | 147 // AddTrack match the format that was used to start the device. |
139 void FinalizeAddTrack(); | 148 void FinalizeAddTrack(); |
140 | 149 |
141 enum State { | |
142 NEW, | |
143 RETRIEVING_CAPABILITIES, | |
144 STARTING, | |
145 STARTED, | |
146 ENDED | |
147 }; | |
148 State state_; | 150 State state_; |
149 | 151 |
150 media::VideoCaptureFormat current_format_; | 152 media::VideoCaptureFormat current_format_; |
151 blink::WebMediaConstraints current_constraints_; | 153 blink::WebMediaConstraints current_constraints_; |
152 gfx::Size frame_output_size_; | 154 gfx::Size frame_output_size_; |
153 | 155 |
154 struct RequestedConstraints { | 156 struct RequestedConstraints { |
155 RequestedConstraints(const blink::WebMediaConstraints& constraints, | 157 RequestedConstraints(const blink::WebMediaConstraints& constraints, |
156 const ConstraintsCallback& callback); | 158 const ConstraintsCallback& callback); |
157 ~RequestedConstraints(); | 159 ~RequestedConstraints(); |
(...skipping 13 matching lines...) Expand all Loading... | |
171 MediaStreamDependencyFactory* factory_; | 173 MediaStreamDependencyFactory* factory_; |
172 scoped_refptr<webrtc::VideoSourceInterface> adapter_; | 174 scoped_refptr<webrtc::VideoSourceInterface> adapter_; |
173 WebRtcVideoCapturerAdapter* capture_adapter_; | 175 WebRtcVideoCapturerAdapter* capture_adapter_; |
174 | 176 |
175 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource); | 177 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource); |
176 }; | 178 }; |
177 | 179 |
178 } // namespace content | 180 } // namespace content |
179 | 181 |
180 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ | 182 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ |
OLD | NEW |