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"
9 #include "base/logging.h"
10 #include "base/time/time.h"
15 LoggingRaw::LoggingRaw() {}
17 LoggingRaw::~LoggingRaw() {}
19 void LoggingRaw::InsertFrameEvent(const base::TimeTicks
& time_of_event
,
20 CastLoggingEvent event
,
21 EventMediaType event_media_type
,
24 InsertBaseFrameEvent(time_of_event
, event
, event_media_type
, frame_id
,
25 rtp_timestamp
, base::TimeDelta(), 0, 0, 0, false, 0,
29 void LoggingRaw::InsertCapturedVideoFrameEvent(
30 const base::TimeTicks
& time_of_event
,
34 InsertBaseFrameEvent(time_of_event
, FRAME_CAPTURE_END
, VIDEO_EVENT
,
35 kFrameIdUnknown
, rtp_timestamp
, base::TimeDelta(), width
,
36 height
, 0, false, 0, -1.0, -1.0);
39 void LoggingRaw::InsertEncodedFrameEvent(const base::TimeTicks
& time_of_event
,
40 CastLoggingEvent event
,
41 EventMediaType event_media_type
,
47 double encoder_cpu_utilization
,
48 double idealized_bitrate_utilization
) {
49 InsertBaseFrameEvent(time_of_event
, event
, event_media_type
,
50 frame_id
, rtp_timestamp
, base::TimeDelta(),
51 0, 0, encoded_size
, key_frame
, target_bitrate
,
52 encoder_cpu_utilization
, idealized_bitrate_utilization
);
55 void LoggingRaw::InsertFrameEventWithDelay(const base::TimeTicks
& time_of_event
,
56 CastLoggingEvent event
,
57 EventMediaType event_media_type
,
60 base::TimeDelta delay
) {
61 InsertBaseFrameEvent(time_of_event
, event
, event_media_type
, frame_id
,
62 rtp_timestamp
, delay
, 0, 0, 0, false, 0, -1.0, -1.0);
65 void LoggingRaw::InsertBaseFrameEvent(const base::TimeTicks
& time_of_event
,
66 CastLoggingEvent event
,
67 EventMediaType event_media_type
,
70 base::TimeDelta delay
,
76 double encoder_cpu_utilization
,
77 double idealized_bitrate_utilization
) {
78 FrameEvent frame_event
;
79 frame_event
.rtp_timestamp
= rtp_timestamp
;
80 frame_event
.frame_id
= frame_id
;
81 frame_event
.width
= width
;
82 frame_event
.height
= height
;
83 frame_event
.size
= encoded_size
;
84 frame_event
.timestamp
= time_of_event
;
85 frame_event
.type
= event
;
86 frame_event
.media_type
= event_media_type
;
87 frame_event
.delay_delta
= delay
;
88 frame_event
.key_frame
= key_frame
;
89 frame_event
.target_bitrate
= target_bitrate
;
90 frame_event
.encoder_cpu_utilization
= encoder_cpu_utilization
;
91 frame_event
.idealized_bitrate_utilization
= idealized_bitrate_utilization
;
92 for (std::vector
<RawEventSubscriber
*>::const_iterator it
=
94 it
!= subscribers_
.end(); ++it
) {
95 (*it
)->OnReceiveFrameEvent(frame_event
);
99 void LoggingRaw::InsertPacketEvent(const base::TimeTicks
& time_of_event
,
100 CastLoggingEvent event
,
101 EventMediaType event_media_type
,
102 uint32 rtp_timestamp
,
103 uint32 frame_id
, uint16 packet_id
,
104 uint16 max_packet_id
, size_t size
) {
105 PacketEvent packet_event
;
106 packet_event
.rtp_timestamp
= rtp_timestamp
;
107 packet_event
.frame_id
= frame_id
;
108 packet_event
.max_packet_id
= max_packet_id
;
109 packet_event
.packet_id
= packet_id
;
110 packet_event
.size
= size
;
111 packet_event
.timestamp
= time_of_event
;
112 packet_event
.type
= event
;
113 packet_event
.media_type
= event_media_type
;
114 for (std::vector
<RawEventSubscriber
*>::const_iterator it
=
115 subscribers_
.begin();
116 it
!= subscribers_
.end(); ++it
) {
117 (*it
)->OnReceivePacketEvent(packet_event
);
121 void LoggingRaw::AddSubscriber(RawEventSubscriber
* subscriber
) {
123 DCHECK(std::find(subscribers_
.begin(), subscribers_
.end(), subscriber
) ==
126 subscribers_
.push_back(subscriber
);
129 void LoggingRaw::RemoveSubscriber(RawEventSubscriber
* subscriber
) {
131 DCHECK(std::find(subscribers_
.begin(), subscribers_
.end(), subscriber
) !=
135 std::remove(subscribers_
.begin(), subscribers_
.end(), subscriber
),