1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/cast/logging/logging_raw.h"
#include <algorithm>
#include "base/logging.h"
#include "base/time/time.h"
namespace media {
namespace cast {
LoggingRaw::LoggingRaw() {}
LoggingRaw::~LoggingRaw() {}
void LoggingRaw::InsertFrameEvent(const base::TimeTicks& time_of_event,
CastLoggingEvent event,
EventMediaType event_media_type,
uint32 rtp_timestamp,
uint32 frame_id) {
InsertBaseFrameEvent(time_of_event, event, event_media_type, frame_id,
rtp_timestamp, base::TimeDelta(), 0, 0, 0, false, 0,
-1.0, -1.0);
}
void LoggingRaw::InsertCapturedVideoFrameEvent(
const base::TimeTicks& time_of_event,
uint32 rtp_timestamp,
int width,
int height) {
InsertBaseFrameEvent(time_of_event, FRAME_CAPTURE_END, VIDEO_EVENT,
kFrameIdUnknown, rtp_timestamp, base::TimeDelta(), width,
height, 0, false, 0, -1.0, -1.0);
}
void LoggingRaw::InsertEncodedFrameEvent(const base::TimeTicks& time_of_event,
CastLoggingEvent event,
EventMediaType event_media_type,
uint32 rtp_timestamp,
uint32 frame_id,
int encoded_size,
bool key_frame,
int target_bitrate,
double encoder_cpu_utilization,
double idealized_bitrate_utilization) {
InsertBaseFrameEvent(time_of_event, event, event_media_type,
frame_id, rtp_timestamp, base::TimeDelta(),
0, 0, encoded_size, key_frame, target_bitrate,
encoder_cpu_utilization, idealized_bitrate_utilization);
}
void LoggingRaw::InsertFrameEventWithDelay(const base::TimeTicks& time_of_event,
CastLoggingEvent event,
EventMediaType event_media_type,
uint32 rtp_timestamp,
uint32 frame_id,
base::TimeDelta delay) {
InsertBaseFrameEvent(time_of_event, event, event_media_type, frame_id,
rtp_timestamp, delay, 0, 0, 0, false, 0, -1.0, -1.0);
}
void LoggingRaw::InsertBaseFrameEvent(const base::TimeTicks& time_of_event,
CastLoggingEvent event,
EventMediaType event_media_type,
uint32 frame_id,
uint32 rtp_timestamp,
base::TimeDelta delay,
int width,
int height,
int encoded_size,
bool key_frame,
int target_bitrate,
double encoder_cpu_utilization,
double idealized_bitrate_utilization) {
FrameEvent frame_event;
frame_event.rtp_timestamp = rtp_timestamp;
frame_event.frame_id = frame_id;
frame_event.width = width;
frame_event.height = height;
frame_event.size = encoded_size;
frame_event.timestamp = time_of_event;
frame_event.type = event;
frame_event.media_type = event_media_type;
frame_event.delay_delta = delay;
frame_event.key_frame = key_frame;
frame_event.target_bitrate = target_bitrate;
frame_event.encoder_cpu_utilization = encoder_cpu_utilization;
frame_event.idealized_bitrate_utilization = idealized_bitrate_utilization;
for (std::vector<RawEventSubscriber*>::const_iterator it =
subscribers_.begin();
it != subscribers_.end(); ++it) {
(*it)->OnReceiveFrameEvent(frame_event);
}
}
void LoggingRaw::InsertPacketEvent(const base::TimeTicks& time_of_event,
CastLoggingEvent event,
EventMediaType event_media_type,
uint32 rtp_timestamp,
uint32 frame_id, uint16 packet_id,
uint16 max_packet_id, size_t size) {
PacketEvent packet_event;
packet_event.rtp_timestamp = rtp_timestamp;
packet_event.frame_id = frame_id;
packet_event.max_packet_id = max_packet_id;
packet_event.packet_id = packet_id;
packet_event.size = size;
packet_event.timestamp = time_of_event;
packet_event.type = event;
packet_event.media_type = event_media_type;
for (std::vector<RawEventSubscriber*>::const_iterator it =
subscribers_.begin();
it != subscribers_.end(); ++it) {
(*it)->OnReceivePacketEvent(packet_event);
}
}
void LoggingRaw::AddSubscriber(RawEventSubscriber* subscriber) {
DCHECK(subscriber);
DCHECK(std::find(subscribers_.begin(), subscribers_.end(), subscriber) ==
subscribers_.end());
subscribers_.push_back(subscriber);
}
void LoggingRaw::RemoveSubscriber(RawEventSubscriber* subscriber) {
DCHECK(subscriber);
DCHECK(std::find(subscribers_.begin(), subscribers_.end(), subscriber) !=
subscribers_.end());
subscribers_.erase(
std::remove(subscribers_.begin(), subscribers_.end(), subscriber),
subscribers_.end());
}
} // namespace cast
} // namespace media
|