blob: 12e76d80cd49042809b58096d0c52728218a7b0e [file] [log] [blame]
sergeyu360f5bae2016-07-22 18:54:451// Copyright 2016 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.
4
5#include "remoting/protocol/client_video_stats_dispatcher.h"
6
7#include <utility>
8
9#include "base/bind.h"
10#include "base/callback_helpers.h"
11#include "net/socket/stream_socket.h"
12#include "remoting/base/compound_buffer.h"
13#include "remoting/proto/video_stats.pb.h"
14#include "remoting/protocol/frame_stats.h"
15#include "remoting/protocol/message_pipe.h"
16#include "remoting/protocol/message_serialization.h"
17#include "remoting/protocol/video_stats_stub.h"
18
19namespace remoting {
20namespace protocol {
21
22ClientVideoStatsDispatcher::ClientVideoStatsDispatcher(
23 const std::string& stream_name,
24 VideoStatsStub* video_stats_stub)
25 : ChannelDispatcherBase(kVideoStatsChannelNamePrefix + stream_name),
26 video_stats_stub_(video_stats_stub) {}
27
Chris Watkins6fe52aa2017-11-28 03:24:0528ClientVideoStatsDispatcher::~ClientVideoStatsDispatcher() = default;
sergeyu360f5bae2016-07-22 18:54:4529
30void ClientVideoStatsDispatcher::OnIncomingMessage(
31 std::unique_ptr<CompoundBuffer> message) {
32 std::unique_ptr<FrameStatsMessage> stats_proto =
33 ParseMessage<FrameStatsMessage>(message.get());
34 if (!stats_proto)
35 return;
36
37 if (!stats_proto->has_frame_id()) {
38 LOG(ERROR) << "Received invalid FrameStatsMessage.";
39 return;
40 }
41 video_stats_stub_->OnVideoFrameStats(
42 stats_proto->frame_id(),
43 HostFrameStats::FromFrameStatsMessage(*stats_proto));
44}
45
46} // namespace protocol
47} // namespace remoting