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
, uint32 rtp_timestamp
,
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
,
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
,
39 base::TimeDelta delay
) {
40 InsertBaseFrameEvent(time_of_event
, event
, frame_id
, rtp_timestamp
, delay
,
44 void LoggingRaw::InsertBaseFrameEvent(const base::TimeTicks
& time_of_event
,
45 CastLoggingEvent event
, uint32 frame_id
,
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
=
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
=
79 it
!= subscribers_
.end(); ++it
) {
80 (*it
)->OnReceivePacketEvent(packet_event
);
84 void LoggingRaw::AddSubscriber(RawEventSubscriber
* subscriber
) {
86 DCHECK(std::find(subscribers_
.begin(), subscribers_
.end(), subscriber
) ==
89 subscribers_
.push_back(subscriber
);
92 void LoggingRaw::RemoveSubscriber(RawEventSubscriber
* subscriber
) {
94 DCHECK(std::find(subscribers_
.begin(), subscribers_
.end(), subscriber
) !=
98 std::remove(subscribers_
.begin(), subscribers_
.end(), subscriber
),