Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / renderer / media / mock_media_stream_video_sink.cc
blob6292eec55f27b7768df5de16740dffa4da4e1ed5
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
3 // found in the LICENSE file.
5 #include "content/renderer/media/mock_media_stream_video_sink.h"
7 #include "media/base/bind_to_current_loop.h"
9 namespace content {
11 MockMediaStreamVideoSink::MockMediaStreamVideoSink()
12 : number_of_frames_(0),
13 enabled_(true),
14 format_(media::PIXEL_FORMAT_UNKNOWN),
15 state_(blink::WebMediaStreamSource::ReadyStateLive),
16 weak_factory_(this) {
19 MockMediaStreamVideoSink::~MockMediaStreamVideoSink() {
22 VideoCaptureDeliverFrameCB
23 MockMediaStreamVideoSink::GetDeliverFrameCB() {
24 return media::BindToCurrentLoop(
25 base::Bind(
26 &MockMediaStreamVideoSink::DeliverVideoFrame,
27 weak_factory_.GetWeakPtr()));
30 void MockMediaStreamVideoSink::DeliverVideoFrame(
31 const scoped_refptr<media::VideoFrame>& frame,
32 base::TimeTicks estimated_capture_time) {
33 last_frame_ = frame;
34 ++number_of_frames_;
35 format_ = frame->format();
36 frame_size_ = frame->natural_size();
37 OnVideoFrame();
40 void MockMediaStreamVideoSink::OnReadyStateChanged(
41 blink::WebMediaStreamSource::ReadyState state) {
42 state_ = state;
45 void MockMediaStreamVideoSink::OnEnabledChanged(bool enabled) {
46 enabled_ = enabled;
49 } // namespace content