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, false, 0);
28 void LoggingRaw::InsertEncodedFrameEvent(const base::TimeTicks
& time_of_event
,
29 CastLoggingEvent event
,
30 EventMediaType event_media_type
,
31 uint32 rtp_timestamp
, uint32 frame_id
,
32 int size
, bool key_frame
,
34 InsertBaseFrameEvent(time_of_event
, event
, event_media_type
,
35 frame_id
, rtp_timestamp
, base::TimeDelta(), size
,
36 key_frame
, target_bitrate
);
39 void LoggingRaw::InsertFrameEventWithDelay(const base::TimeTicks
& time_of_event
,
40 CastLoggingEvent event
,
41 EventMediaType event_media_type
,
44 base::TimeDelta delay
) {
45 InsertBaseFrameEvent(time_of_event
, event
, event_media_type
, frame_id
,
46 rtp_timestamp
, delay
, 0, false, 0);
49 void LoggingRaw::InsertBaseFrameEvent(const base::TimeTicks
& time_of_event
,
50 CastLoggingEvent event
,
51 EventMediaType event_media_type
,
54 base::TimeDelta delay
, int size
,
55 bool key_frame
, int target_bitrate
) {
56 FrameEvent frame_event
;
57 frame_event
.rtp_timestamp
= rtp_timestamp
;
58 frame_event
.frame_id
= frame_id
;
59 frame_event
.size
= size
;
60 frame_event
.timestamp
= time_of_event
;
61 frame_event
.type
= event
;
62 frame_event
.media_type
= event_media_type
;
63 frame_event
.delay_delta
= delay
;
64 frame_event
.key_frame
= key_frame
;
65 frame_event
.target_bitrate
= target_bitrate
;
66 for (std::vector
<RawEventSubscriber
*>::const_iterator it
=
68 it
!= subscribers_
.end(); ++it
) {
69 (*it
)->OnReceiveFrameEvent(frame_event
);
73 void LoggingRaw::InsertPacketEvent(const base::TimeTicks
& time_of_event
,
74 CastLoggingEvent event
,
75 EventMediaType event_media_type
,
77 uint32 frame_id
, uint16 packet_id
,
78 uint16 max_packet_id
, size_t size
) {
79 PacketEvent packet_event
;
80 packet_event
.rtp_timestamp
= rtp_timestamp
;
81 packet_event
.frame_id
= frame_id
;
82 packet_event
.max_packet_id
= max_packet_id
;
83 packet_event
.packet_id
= packet_id
;
84 packet_event
.size
= size
;
85 packet_event
.timestamp
= time_of_event
;
86 packet_event
.type
= event
;
87 packet_event
.media_type
= event_media_type
;
88 for (std::vector
<RawEventSubscriber
*>::const_iterator it
=
90 it
!= subscribers_
.end(); ++it
) {
91 (*it
)->OnReceivePacketEvent(packet_event
);
95 void LoggingRaw::AddSubscriber(RawEventSubscriber
* subscriber
) {
97 DCHECK(std::find(subscribers_
.begin(), subscribers_
.end(), subscriber
) ==
100 subscribers_
.push_back(subscriber
);
103 void LoggingRaw::RemoveSubscriber(RawEventSubscriber
* subscriber
) {
105 DCHECK(std::find(subscribers_
.begin(), subscribers_
.end(), subscriber
) !=
109 std::remove(subscribers_
.begin(), subscribers_
.end(), subscriber
),