blob: d6e92b0f33385437da37d8f9a53e8f4073c7290d [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
2 * libjingle
jlmiller@webrtc.org5f93d0a2015-01-20 21:36:13 +00003 * Copyright 2012 Google Inc.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00004 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
wu@webrtc.org967bfff2013-09-19 05:49:50 +000028#include "talk/app/webrtc/videosource.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000029
30#include <vector>
glaznev@webrtc.org3472dcd2014-09-10 19:24:57 +000031#include <cstdlib>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000032
33#include "talk/app/webrtc/mediaconstraintsinterface.h"
34#include "talk/session/media/channelmanager.h"
35
36using cricket::CaptureState;
37using webrtc::MediaConstraintsInterface;
38using webrtc::MediaSourceInterface;
39
henrike@webrtc.org28e20752013-07-10 00:45:36 +000040namespace {
41
42const double kRoundingTruncation = 0.0005;
43
44enum {
45 MSG_VIDEOCAPTURESTATECONNECT,
46 MSG_VIDEOCAPTURESTATEDISCONNECT,
47 MSG_VIDEOCAPTURESTATECHANGE,
48};
49
50// Default resolution. If no constraint is specified, this is the resolution we
51// will use.
wu@webrtc.org967bfff2013-09-19 05:49:50 +000052static const cricket::VideoFormatPod kDefaultFormat =
henrike@webrtc.org28e20752013-07-10 00:45:36 +000053 {640, 480, FPS_TO_INTERVAL(30), cricket::FOURCC_ANY};
54
55// List of formats used if the camera doesn't support capability enumeration.
56static const cricket::VideoFormatPod kVideoFormats[] = {
57 {1920, 1080, FPS_TO_INTERVAL(30), cricket::FOURCC_ANY},
58 {1280, 720, FPS_TO_INTERVAL(30), cricket::FOURCC_ANY},
59 {960, 720, FPS_TO_INTERVAL(30), cricket::FOURCC_ANY},
60 {640, 360, FPS_TO_INTERVAL(30), cricket::FOURCC_ANY},
61 {640, 480, FPS_TO_INTERVAL(30), cricket::FOURCC_ANY},
62 {320, 240, FPS_TO_INTERVAL(30), cricket::FOURCC_ANY},
63 {320, 180, FPS_TO_INTERVAL(30), cricket::FOURCC_ANY}
64};
65
66MediaSourceInterface::SourceState
67GetReadyState(cricket::CaptureState state) {
68 switch (state) {
69 case cricket::CS_STARTING:
70 return MediaSourceInterface::kInitializing;
71 case cricket::CS_RUNNING:
72 return MediaSourceInterface::kLive;
73 case cricket::CS_FAILED:
74 case cricket::CS_NO_DEVICE:
75 case cricket::CS_STOPPED:
76 return MediaSourceInterface::kEnded;
77 case cricket::CS_PAUSED:
78 return MediaSourceInterface::kMuted;
79 default:
80 ASSERT(false && "GetReadyState unknown state");
81 }
82 return MediaSourceInterface::kEnded;
83}
84
85void SetUpperLimit(int new_limit, int* original_limit) {
86 if (*original_limit < 0 || new_limit < *original_limit)
87 *original_limit = new_limit;
88}
89
90// Updates |format_upper_limit| from |constraint|.
91// If constraint.maxFoo is smaller than format_upper_limit.foo,
92// set format_upper_limit.foo to constraint.maxFoo.
93void SetUpperLimitFromConstraint(
94 const MediaConstraintsInterface::Constraint& constraint,
95 cricket::VideoFormat* format_upper_limit) {
96 if (constraint.key == MediaConstraintsInterface::kMaxWidth) {
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000097 int value = rtc::FromString<int>(constraint.value);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000098 SetUpperLimit(value, &(format_upper_limit->width));
99 } else if (constraint.key == MediaConstraintsInterface::kMaxHeight) {
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000100 int value = rtc::FromString<int>(constraint.value);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000101 SetUpperLimit(value, &(format_upper_limit->height));
102 }
103}
104
105// Fills |format_out| with the max width and height allowed by |constraints|.
106void FromConstraintsForScreencast(
107 const MediaConstraintsInterface::Constraints& constraints,
108 cricket::VideoFormat* format_out) {
109 typedef MediaConstraintsInterface::Constraints::const_iterator
110 ConstraintsIterator;
111
112 cricket::VideoFormat upper_limit(-1, -1, 0, 0);
113 for (ConstraintsIterator constraints_it = constraints.begin();
114 constraints_it != constraints.end(); ++constraints_it)
115 SetUpperLimitFromConstraint(*constraints_it, &upper_limit);
116
117 if (upper_limit.width >= 0)
118 format_out->width = upper_limit.width;
119 if (upper_limit.height >= 0)
120 format_out->height = upper_limit.height;
121}
122
123// Returns true if |constraint| is fulfilled. |format_out| can differ from
124// |format_in| if the format is changed by the constraint. Ie - the frame rate
125// can be changed by setting maxFrameRate.
126bool NewFormatWithConstraints(
127 const MediaConstraintsInterface::Constraint& constraint,
128 const cricket::VideoFormat& format_in,
129 bool mandatory,
130 cricket::VideoFormat* format_out) {
131 ASSERT(format_out != NULL);
132 *format_out = format_in;
133
134 if (constraint.key == MediaConstraintsInterface::kMinWidth) {
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000135 int value = rtc::FromString<int>(constraint.value);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000136 return (value <= format_in.width);
137 } else if (constraint.key == MediaConstraintsInterface::kMaxWidth) {
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000138 int value = rtc::FromString<int>(constraint.value);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000139 return (value >= format_in.width);
140 } else if (constraint.key == MediaConstraintsInterface::kMinHeight) {
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000141 int value = rtc::FromString<int>(constraint.value);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000142 return (value <= format_in.height);
143 } else if (constraint.key == MediaConstraintsInterface::kMaxHeight) {
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000144 int value = rtc::FromString<int>(constraint.value);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000145 return (value >= format_in.height);
146 } else if (constraint.key == MediaConstraintsInterface::kMinFrameRate) {
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000147 int value = rtc::FromString<int>(constraint.value);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000148 return (value <= cricket::VideoFormat::IntervalToFps(format_in.interval));
149 } else if (constraint.key == MediaConstraintsInterface::kMaxFrameRate) {
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000150 int value = rtc::FromString<int>(constraint.value);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000151 if (value == 0) {
152 if (mandatory) {
153 // TODO(ronghuawu): Convert the constraint value to float when sub-1fps
154 // is supported by the capturer.
155 return false;
156 } else {
157 value = 1;
158 }
159 }
160 if (value <= cricket::VideoFormat::IntervalToFps(format_in.interval)) {
161 format_out->interval = cricket::VideoFormat::FpsToInterval(value);
162 return true;
163 } else {
164 return false;
165 }
166 } else if (constraint.key == MediaConstraintsInterface::kMinAspectRatio) {
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000167 double value = rtc::FromString<double>(constraint.value);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000168 // The aspect ratio in |constraint.value| has been converted to a string and
169 // back to a double, so it may have a rounding error.
170 // E.g if the value 1/3 is converted to a string, the string will not have
171 // infinite length.
172 // We add a margin of 0.0005 which is high enough to detect the same aspect
173 // ratio but small enough to avoid matching wrong aspect ratios.
174 double ratio = static_cast<double>(format_in.width) / format_in.height;
175 return (value <= ratio + kRoundingTruncation);
176 } else if (constraint.key == MediaConstraintsInterface::kMaxAspectRatio) {
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000177 double value = rtc::FromString<double>(constraint.value);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000178 double ratio = static_cast<double>(format_in.width) / format_in.height;
179 // Subtract 0.0005 to avoid rounding problems. Same as above.
180 const double kRoundingTruncation = 0.0005;
181 return (value >= ratio - kRoundingTruncation);
buildbot@webrtc.org81ddc782014-10-14 22:39:24 +0000182 } else if (constraint.key == MediaConstraintsInterface::kNoiseReduction) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000183 // These are actually options, not constraints, so they can be satisfied
184 // regardless of the format.
185 return true;
186 }
187 LOG(LS_WARNING) << "Found unknown MediaStream constraint. Name:"
188 << constraint.key << " Value:" << constraint.value;
189 return false;
190}
191
192// Removes cricket::VideoFormats from |formats| that don't meet |constraint|.
193void FilterFormatsByConstraint(
194 const MediaConstraintsInterface::Constraint& constraint,
195 bool mandatory,
196 std::vector<cricket::VideoFormat>* formats) {
197 std::vector<cricket::VideoFormat>::iterator format_it =
198 formats->begin();
199 while (format_it != formats->end()) {
200 // Modify the format_it to fulfill the constraint if possible.
201 // Delete it otherwise.
202 if (!NewFormatWithConstraints(constraint, (*format_it),
203 mandatory, &(*format_it))) {
204 format_it = formats->erase(format_it);
205 } else {
206 ++format_it;
207 }
208 }
209}
210
211// Returns a vector of cricket::VideoFormat that best match |constraints|.
212std::vector<cricket::VideoFormat> FilterFormats(
213 const MediaConstraintsInterface::Constraints& mandatory,
214 const MediaConstraintsInterface::Constraints& optional,
215 const std::vector<cricket::VideoFormat>& supported_formats) {
216 typedef MediaConstraintsInterface::Constraints::const_iterator
217 ConstraintsIterator;
218 std::vector<cricket::VideoFormat> candidates = supported_formats;
219
220 for (ConstraintsIterator constraints_it = mandatory.begin();
221 constraints_it != mandatory.end(); ++constraints_it)
222 FilterFormatsByConstraint(*constraints_it, true, &candidates);
223
224 if (candidates.size() == 0)
225 return candidates;
226
227 // Ok - all mandatory checked and we still have a candidate.
228 // Let's try filtering using the optional constraints.
229 for (ConstraintsIterator constraints_it = optional.begin();
230 constraints_it != optional.end(); ++constraints_it) {
231 std::vector<cricket::VideoFormat> current_candidates = candidates;
232 FilterFormatsByConstraint(*constraints_it, false, &current_candidates);
233 if (current_candidates.size() > 0) {
234 candidates = current_candidates;
235 }
236 }
237
238 // We have done as good as we can to filter the supported resolutions.
239 return candidates;
240}
241
242// Find the format that best matches the default video size.
243// Constraints are optional and since the performance of a video call
244// might be bad due to bitrate limitations, CPU, and camera performance,
245// it is better to select a resolution that is as close as possible to our
246// default and still meets the contraints.
247const cricket::VideoFormat& GetBestCaptureFormat(
248 const std::vector<cricket::VideoFormat>& formats) {
249 ASSERT(formats.size() > 0);
250
wu@webrtc.org967bfff2013-09-19 05:49:50 +0000251 int default_area = kDefaultFormat.width * kDefaultFormat.height;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000252
253 std::vector<cricket::VideoFormat>::const_iterator it = formats.begin();
254 std::vector<cricket::VideoFormat>::const_iterator best_it = formats.begin();
glaznev@webrtc.org3472dcd2014-09-10 19:24:57 +0000255 int best_diff_area = std::abs(default_area - it->width * it->height);
256 int64 best_diff_interval = kDefaultFormat.interval;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000257 for (; it != formats.end(); ++it) {
glaznev@webrtc.org3472dcd2014-09-10 19:24:57 +0000258 int diff_area = std::abs(default_area - it->width * it->height);
259 int64 diff_interval = std::abs(kDefaultFormat.interval - it->interval);
260 if (diff_area < best_diff_area ||
261 (diff_area == best_diff_area && diff_interval < best_diff_interval)) {
262 best_diff_area = diff_area;
263 best_diff_interval = diff_interval;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000264 best_it = it;
265 }
266 }
267 return *best_it;
268}
269
270// Set |option| to the highest-priority value of |key| in the constraints.
271// Return false if the key is mandatory, and the value is invalid.
272bool ExtractOption(const MediaConstraintsInterface* all_constraints,
273 const std::string& key, cricket::Settable<bool>* option) {
274 size_t mandatory = 0;
275 bool value;
276 if (FindConstraint(all_constraints, key, &value, &mandatory)) {
277 option->Set(value);
278 return true;
279 }
280
281 return mandatory == 0;
282}
283
284// Search |all_constraints| for known video options. Apply all options that are
285// found with valid values, and return false if any mandatory video option was
286// found with an invalid value.
287bool ExtractVideoOptions(const MediaConstraintsInterface* all_constraints,
288 cricket::VideoOptions* options) {
289 bool all_valid = true;
290
291 all_valid &= ExtractOption(all_constraints,
292 MediaConstraintsInterface::kNoiseReduction,
293 &(options->video_noise_reduction));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000294
295 return all_valid;
296}
297
wu@webrtc.org967bfff2013-09-19 05:49:50 +0000298class FrameInputWrapper : public cricket::VideoRenderer {
299 public:
300 explicit FrameInputWrapper(cricket::VideoCapturer* capturer)
301 : capturer_(capturer) {
302 ASSERT(capturer_ != NULL);
303 }
304
305 virtual ~FrameInputWrapper() {}
306
307 // VideoRenderer implementation.
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000308 bool SetSize(int width, int height, int reserved) override { return true; }
wu@webrtc.org967bfff2013-09-19 05:49:50 +0000309
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000310 bool RenderFrame(const cricket::VideoFrame* frame) override {
wu@webrtc.org967bfff2013-09-19 05:49:50 +0000311 if (!capturer_->IsRunning()) {
312 return true;
313 }
314
315 // This signal will be made on media engine render thread. The clients
316 // of this signal should have no assumptions on what thread this signal
317 // come from.
318 capturer_->SignalVideoFrame(capturer_, frame);
319 return true;
320 }
321
322 private:
323 cricket::VideoCapturer* capturer_;
324 int width_;
325 int height_;
326
327 DISALLOW_COPY_AND_ASSIGN(FrameInputWrapper);
328};
329
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000330} // anonymous namespace
331
332namespace webrtc {
333
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000334rtc::scoped_refptr<VideoSource> VideoSource::Create(
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000335 cricket::ChannelManager* channel_manager,
336 cricket::VideoCapturer* capturer,
337 const webrtc::MediaConstraintsInterface* constraints) {
338 ASSERT(channel_manager != NULL);
339 ASSERT(capturer != NULL);
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000340 rtc::scoped_refptr<VideoSource> source(
341 new rtc::RefCountedObject<VideoSource>(channel_manager,
wu@webrtc.org967bfff2013-09-19 05:49:50 +0000342 capturer));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000343 source->Initialize(constraints);
344 return source;
345}
346
wu@webrtc.org967bfff2013-09-19 05:49:50 +0000347VideoSource::VideoSource(cricket::ChannelManager* channel_manager,
348 cricket::VideoCapturer* capturer)
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000349 : channel_manager_(channel_manager),
350 video_capturer_(capturer),
351 state_(kInitializing) {
352 channel_manager_->SignalVideoCaptureStateChange.connect(
wu@webrtc.org967bfff2013-09-19 05:49:50 +0000353 this, &VideoSource::OnStateChange);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000354}
355
wu@webrtc.org967bfff2013-09-19 05:49:50 +0000356VideoSource::~VideoSource() {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000357 channel_manager_->StopVideoCapture(video_capturer_.get(), format_);
358 channel_manager_->SignalVideoCaptureStateChange.disconnect(this);
359}
360
wu@webrtc.org967bfff2013-09-19 05:49:50 +0000361void VideoSource::Initialize(
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000362 const webrtc::MediaConstraintsInterface* constraints) {
363
hbos@webrtc.org1e642632015-02-25 09:49:41 +0000364 std::vector<cricket::VideoFormat> formats =
365 channel_manager_->GetSupportedFormats(video_capturer_.get());
366 if (formats.empty()) {
367 if (video_capturer_->IsScreencast()) {
368 // The screen capturer can accept any resolution and we will derive the
369 // format from the constraints if any.
370 // Note that this only affects tab capturing, not desktop capturing,
371 // since the desktop capturer does not respect the VideoFormat passed in.
372 formats.push_back(cricket::VideoFormat(kDefaultFormat));
373 } else {
374 // The VideoCapturer implementation doesn't support capability
375 // enumeration. We need to guess what the camera supports.
376 for (int i = 0; i < ARRAY_SIZE(kVideoFormats); ++i) {
377 formats.push_back(cricket::VideoFormat(kVideoFormats[i]));
378 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000379 }
380 }
381
382 if (constraints) {
383 MediaConstraintsInterface::Constraints mandatory_constraints =
384 constraints->GetMandatory();
385 MediaConstraintsInterface::Constraints optional_constraints;
386 optional_constraints = constraints->GetOptional();
387
388 if (video_capturer_->IsScreencast()) {
389 // Use the maxWidth and maxHeight allowed by constraints for screencast.
390 FromConstraintsForScreencast(mandatory_constraints, &(formats[0]));
391 }
392
393 formats = FilterFormats(mandatory_constraints, optional_constraints,
394 formats);
395 }
396
397 if (formats.size() == 0) {
398 LOG(LS_WARNING) << "Failed to find a suitable video format.";
399 SetState(kEnded);
400 return;
401 }
402
403 cricket::VideoOptions options;
404 if (!ExtractVideoOptions(constraints, &options)) {
405 LOG(LS_WARNING) << "Could not satisfy mandatory options.";
406 SetState(kEnded);
407 return;
408 }
409 options_.SetAll(options);
410
411 format_ = GetBestCaptureFormat(formats);
412 // Start the camera with our best guess.
413 // TODO(perkj): Should we try again with another format it it turns out that
414 // the camera doesn't produce frames with the correct format? Or will
415 // cricket::VideCapturer be able to re-scale / crop to the requested
416 // resolution?
417 if (!channel_manager_->StartVideoCapture(video_capturer_.get(), format_)) {
418 SetState(kEnded);
419 return;
420 }
421 // Initialize hasn't succeeded until a successful state change has occurred.
422}
423
wu@webrtc.org967bfff2013-09-19 05:49:50 +0000424cricket::VideoRenderer* VideoSource::FrameInput() {
425 // Defer creation of frame_input_ until it's needed, e.g. the local video
426 // sources will never need it.
427 if (!frame_input_) {
428 frame_input_.reset(new FrameInputWrapper(video_capturer_.get()));
429 }
430 return frame_input_.get();
431}
432
perkj@webrtc.org8f605e82015-02-17 13:53:56 +0000433void VideoSource::Stop() {
434 channel_manager_->StopVideoCapture(video_capturer_.get(), format_);
435}
436
437void VideoSource::Restart() {
438 if (!channel_manager_->StartVideoCapture(video_capturer_.get(), format_)) {
439 SetState(kEnded);
440 return;
441 }
442 for(cricket::VideoRenderer* sink : sinks_) {
443 channel_manager_->AddVideoRenderer(video_capturer_.get(), sink);
444 }
445}
446
wu@webrtc.org967bfff2013-09-19 05:49:50 +0000447void VideoSource::AddSink(cricket::VideoRenderer* output) {
perkj@webrtc.org8f605e82015-02-17 13:53:56 +0000448 sinks_.push_back(output);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000449 channel_manager_->AddVideoRenderer(video_capturer_.get(), output);
450}
451
wu@webrtc.org967bfff2013-09-19 05:49:50 +0000452void VideoSource::RemoveSink(cricket::VideoRenderer* output) {
perkj@webrtc.org8f605e82015-02-17 13:53:56 +0000453 sinks_.remove(output);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000454 channel_manager_->RemoveVideoRenderer(video_capturer_.get(), output);
455}
456
457// OnStateChange listens to the ChannelManager::SignalVideoCaptureStateChange.
458// This signal is triggered for all video capturers. Not only the one we are
459// interested in.
wu@webrtc.org967bfff2013-09-19 05:49:50 +0000460void VideoSource::OnStateChange(cricket::VideoCapturer* capturer,
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000461 cricket::CaptureState capture_state) {
462 if (capturer == video_capturer_.get()) {
463 SetState(GetReadyState(capture_state));
464 }
465}
466
wu@webrtc.org967bfff2013-09-19 05:49:50 +0000467void VideoSource::SetState(SourceState new_state) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000468 if (VERIFY(state_ != new_state)) {
469 state_ = new_state;
470 FireOnChanged();
471 }
472}
473
474} // namespace webrtc