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 "remoting/protocol/monitored_video_stub.h"
8 #include "base/logging.h"
9 #include "remoting/proto/video.pb.h"
14 MonitoredVideoStub::MonitoredVideoStub(VideoStub
* video_stub
,
15 base::TimeDelta connectivity_check_delay
,
16 const ChannelStateCallback
& callback
)
17 : video_stub_(video_stub
),
20 connectivity_check_timer_(
22 connectivity_check_delay
,
24 &MonitoredVideoStub::OnConnectivityCheckTimeout
) {
27 MonitoredVideoStub::~MonitoredVideoStub() {
30 void MonitoredVideoStub::ProcessVideoPacket(scoped_ptr
<VideoPacket
> packet
,
31 const base::Closure
& done
) {
32 DCHECK(thread_checker_
.CalledOnValidThread());
34 connectivity_check_timer_
.Reset();
36 NotifyChannelState(true);
38 video_stub_
->ProcessVideoPacket(packet
.Pass(), done
);
41 void MonitoredVideoStub::OnConnectivityCheckTimeout() {
42 DCHECK(thread_checker_
.CalledOnValidThread());
43 NotifyChannelState(false);
46 void MonitoredVideoStub::NotifyChannelState(bool connected
) {
47 if (is_connected_
!= connected
) {
48 is_connected_
= connected
;
49 callback_
.Run(is_connected_
);
53 } // namespace protocol
54 } // namespace remoting