Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / media / cast / logging / logging_raw.cc
blob272f734b848bb6bd7a700acffac60dab97474462
1 // Copyright 2013 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 "media/cast/logging/logging_raw.h"
7 #include <algorithm>
9 #include "base/logging.h"
10 #include "base/time/time.h"
12 namespace media {
13 namespace cast {
15 LoggingRaw::LoggingRaw() {}
17 LoggingRaw::~LoggingRaw() {}
19 void LoggingRaw::InsertFrameEvent(const base::TimeTicks& time_of_event,
20 CastLoggingEvent event, uint32 rtp_timestamp,
21 uint32 frame_id) {
22 InsertBaseFrameEvent(time_of_event, event, frame_id, rtp_timestamp,
23 base::TimeDelta(), 0, false, 0);
26 void LoggingRaw::InsertEncodedFrameEvent(const base::TimeTicks& time_of_event,
27 CastLoggingEvent event,
28 uint32 rtp_timestamp, uint32 frame_id,
29 int size, bool key_frame,
30 int target_bitrate) {
31 InsertBaseFrameEvent(time_of_event, event, frame_id, rtp_timestamp,
32 base::TimeDelta(), size, key_frame, target_bitrate);
35 void LoggingRaw::InsertFrameEventWithDelay(const base::TimeTicks& time_of_event,
36 CastLoggingEvent event,
37 uint32 rtp_timestamp,
38 uint32 frame_id,
39 base::TimeDelta delay) {
40 InsertBaseFrameEvent(time_of_event, event, frame_id, rtp_timestamp, delay,
41 0, false, 0);
44 void LoggingRaw::InsertBaseFrameEvent(const base::TimeTicks& time_of_event,
45 CastLoggingEvent event, uint32 frame_id,
46 uint32 rtp_timestamp,
47 base::TimeDelta delay, int size,
48 bool key_frame, int target_bitrate) {
49 FrameEvent frame_event;
50 frame_event.rtp_timestamp = rtp_timestamp;
51 frame_event.frame_id = frame_id;
52 frame_event.size = size;
53 frame_event.timestamp = time_of_event;
54 frame_event.type = event;
55 frame_event.delay_delta = delay;
56 frame_event.key_frame = key_frame;
57 frame_event.target_bitrate = target_bitrate;
58 for (std::vector<RawEventSubscriber*>::const_iterator it =
59 subscribers_.begin();
60 it != subscribers_.end(); ++it) {
61 (*it)->OnReceiveFrameEvent(frame_event);
65 void LoggingRaw::InsertPacketEvent(const base::TimeTicks& time_of_event,
66 CastLoggingEvent event, uint32 rtp_timestamp,
67 uint32 frame_id, uint16 packet_id,
68 uint16 max_packet_id, size_t size) {
69 PacketEvent packet_event;
70 packet_event.rtp_timestamp = rtp_timestamp;
71 packet_event.frame_id = frame_id;
72 packet_event.max_packet_id = max_packet_id;
73 packet_event.packet_id = packet_id;
74 packet_event.size = size;
75 packet_event.timestamp = time_of_event;
76 packet_event.type = event;
77 for (std::vector<RawEventSubscriber*>::const_iterator it =
78 subscribers_.begin();
79 it != subscribers_.end(); ++it) {
80 (*it)->OnReceivePacketEvent(packet_event);
84 void LoggingRaw::AddSubscriber(RawEventSubscriber* subscriber) {
85 DCHECK(subscriber);
86 DCHECK(std::find(subscribers_.begin(), subscribers_.end(), subscriber) ==
87 subscribers_.end());
89 subscribers_.push_back(subscriber);
92 void LoggingRaw::RemoveSubscriber(RawEventSubscriber* subscriber) {
93 DCHECK(subscriber);
94 DCHECK(std::find(subscribers_.begin(), subscribers_.end(), subscriber) !=
95 subscribers_.end());
97 subscribers_.erase(
98 std::remove(subscribers_.begin(), subscribers_.end(), subscriber),
99 subscribers_.end());
102 } // namespace cast
103 } // namespace media