Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: media/cast/logging/logging_impl.cc

Issue 270493003: Cast: Deduplicate event types in cast library. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/cast/logging/logging_impl.h ('k') | media/cast/logging/logging_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/big_endian.h" 5 #include "base/big_endian.h"
6 #include "base/debug/trace_event.h" 6 #include "base/debug/trace_event.h"
7 #include "media/cast/logging/logging_impl.h" 7 #include "media/cast/logging/logging_impl.h"
8 8
9 namespace media { 9 namespace media {
10 namespace cast { 10 namespace cast {
11 11
12 // TODO(imcheng): Collapse LoggingRaw onto LoggingImpl. 12 // TODO(imcheng): Collapse LoggingRaw onto LoggingImpl.
13 LoggingImpl::LoggingImpl() { 13 LoggingImpl::LoggingImpl() {
14 // LoggingImpl can be constructed on any thread, but its methods should all be 14 // LoggingImpl can be constructed on any thread, but its methods should all be
15 // called on the same thread. 15 // called on the same thread.
16 thread_checker_.DetachFromThread(); 16 thread_checker_.DetachFromThread();
17 } 17 }
18 18
19 LoggingImpl::~LoggingImpl() {} 19 LoggingImpl::~LoggingImpl() {}
20 20
21 void LoggingImpl::InsertFrameEvent(const base::TimeTicks& time_of_event, 21 void LoggingImpl::InsertFrameEvent(const base::TimeTicks& time_of_event,
22 CastLoggingEvent event, uint32 rtp_timestamp, 22 CastLoggingEvent event,
23 EventMediaType event_media_type,
24 uint32 rtp_timestamp,
23 uint32 frame_id) { 25 uint32 frame_id) {
24 DCHECK(thread_checker_.CalledOnValidThread()); 26 DCHECK(thread_checker_.CalledOnValidThread());
25 raw_.InsertFrameEvent(time_of_event, event, rtp_timestamp, frame_id); 27 raw_.InsertFrameEvent(time_of_event, event, event_media_type,
28 rtp_timestamp, frame_id);
26 } 29 }
27 30
28 void LoggingImpl::InsertEncodedFrameEvent(const base::TimeTicks& time_of_event, 31 void LoggingImpl::InsertEncodedFrameEvent(const base::TimeTicks& time_of_event,
29 CastLoggingEvent event, 32 CastLoggingEvent event,
33 EventMediaType event_media_type,
30 uint32 rtp_timestamp, 34 uint32 rtp_timestamp,
31 uint32 frame_id, int frame_size, 35 uint32 frame_id, int frame_size,
32 bool key_frame, 36 bool key_frame,
33 int target_bitrate) { 37 int target_bitrate) {
34 DCHECK(thread_checker_.CalledOnValidThread()); 38 DCHECK(thread_checker_.CalledOnValidThread());
35 raw_.InsertEncodedFrameEvent(time_of_event, event, rtp_timestamp, frame_id, 39 raw_.InsertEncodedFrameEvent(time_of_event, event, event_media_type,
36 frame_size, key_frame, target_bitrate); 40 rtp_timestamp, frame_id, frame_size, key_frame, target_bitrate);
37 } 41 }
38 42
39 void LoggingImpl::InsertFrameEventWithDelay( 43 void LoggingImpl::InsertFrameEventWithDelay(
40 const base::TimeTicks& time_of_event, CastLoggingEvent event, 44 const base::TimeTicks& time_of_event, CastLoggingEvent event,
41 uint32 rtp_timestamp, uint32 frame_id, base::TimeDelta delay) { 45 EventMediaType event_media_type, uint32 rtp_timestamp, uint32 frame_id,
46 base::TimeDelta delay) {
42 DCHECK(thread_checker_.CalledOnValidThread()); 47 DCHECK(thread_checker_.CalledOnValidThread());
43 raw_.InsertFrameEventWithDelay(time_of_event, event, rtp_timestamp, 48 raw_.InsertFrameEventWithDelay(time_of_event, event, event_media_type,
44 frame_id, delay); 49 rtp_timestamp, frame_id, delay);
45 } 50 }
46 51
47 void LoggingImpl::InsertSinglePacketEvent(const base::TimeTicks& time_of_event, 52 void LoggingImpl::InsertSinglePacketEvent(const base::TimeTicks& time_of_event,
48 CastLoggingEvent event, 53 CastLoggingEvent event,
54 EventMediaType event_media_type,
49 const Packet& packet) { 55 const Packet& packet) {
50 DCHECK(thread_checker_.CalledOnValidThread()); 56 DCHECK(thread_checker_.CalledOnValidThread());
51 57
52 // Parse basic properties. 58 // Parse basic properties.
53 uint32 rtp_timestamp; 59 uint32 rtp_timestamp;
54 uint16 packet_id, max_packet_id; 60 uint16 packet_id, max_packet_id;
55 const uint8* packet_data = &packet[0]; 61 const uint8* packet_data = &packet[0];
56 base::BigEndianReader big_endian_reader( 62 base::BigEndianReader big_endian_reader(
57 reinterpret_cast<const char*>(packet_data + 4), 4); 63 reinterpret_cast<const char*>(packet_data + 4), 4);
58 big_endian_reader.ReadU32(&rtp_timestamp); 64 big_endian_reader.ReadU32(&rtp_timestamp);
59 base::BigEndianReader cast_big_endian_reader( 65 base::BigEndianReader cast_big_endian_reader(
60 reinterpret_cast<const char*>(packet_data + 12 + 2), 4); 66 reinterpret_cast<const char*>(packet_data + 12 + 2), 4);
61 cast_big_endian_reader.ReadU16(&packet_id); 67 cast_big_endian_reader.ReadU16(&packet_id);
62 cast_big_endian_reader.ReadU16(&max_packet_id); 68 cast_big_endian_reader.ReadU16(&max_packet_id);
63 69
64 // rtp_timestamp is enough - no need for frame_id as well. 70 // rtp_timestamp is enough - no need for frame_id as well.
65 InsertPacketEvent(time_of_event, 71 InsertPacketEvent(time_of_event,
66 event, 72 event,
73 event_media_type,
67 rtp_timestamp, 74 rtp_timestamp,
68 kFrameIdUnknown, 75 kFrameIdUnknown,
69 packet_id, 76 packet_id,
70 max_packet_id, 77 max_packet_id,
71 packet.size()); 78 packet.size());
72 } 79 }
73 80
74 void LoggingImpl::InsertPacketListEvent(const base::TimeTicks& time_of_event, 81 void LoggingImpl::InsertPacketListEvent(const base::TimeTicks& time_of_event,
75 CastLoggingEvent event, 82 CastLoggingEvent event,
83 EventMediaType event_media_type,
76 const PacketList& packets) { 84 const PacketList& packets) {
77 DCHECK(thread_checker_.CalledOnValidThread()); 85 DCHECK(thread_checker_.CalledOnValidThread());
78 for (PacketList::const_iterator it = packets.begin(); it != packets.end(); 86 for (PacketList::const_iterator it = packets.begin(); it != packets.end();
79 ++it) { 87 ++it) {
80 InsertSinglePacketEvent(time_of_event, event, (*it)->data); 88 InsertSinglePacketEvent(time_of_event, event, event_media_type,
89 (*it)->data);
81 } 90 }
82 } 91 }
83 92
84 void LoggingImpl::InsertPacketEvent(const base::TimeTicks& time_of_event, 93 void LoggingImpl::InsertPacketEvent(const base::TimeTicks& time_of_event,
85 CastLoggingEvent event, 94 CastLoggingEvent event,
95 EventMediaType event_media_type,
86 uint32 rtp_timestamp, uint32 frame_id, 96 uint32 rtp_timestamp, uint32 frame_id,
87 uint16 packet_id, uint16 max_packet_id, 97 uint16 packet_id, uint16 max_packet_id,
88 size_t size) { 98 size_t size) {
89 DCHECK(thread_checker_.CalledOnValidThread()); 99 DCHECK(thread_checker_.CalledOnValidThread());
90 raw_.InsertPacketEvent(time_of_event, event, rtp_timestamp, frame_id, 100 raw_.InsertPacketEvent(time_of_event, event, event_media_type,
91 packet_id, max_packet_id, size); 101 rtp_timestamp, frame_id, packet_id, max_packet_id, size);
92 } 102 }
93 103
94 void LoggingImpl::AddRawEventSubscriber(RawEventSubscriber* subscriber) { 104 void LoggingImpl::AddRawEventSubscriber(RawEventSubscriber* subscriber) {
95 DCHECK(thread_checker_.CalledOnValidThread()); 105 DCHECK(thread_checker_.CalledOnValidThread());
96 raw_.AddSubscriber(subscriber); 106 raw_.AddSubscriber(subscriber);
97 } 107 }
98 108
99 void LoggingImpl::RemoveRawEventSubscriber(RawEventSubscriber* subscriber) { 109 void LoggingImpl::RemoveRawEventSubscriber(RawEventSubscriber* subscriber) {
100 DCHECK(thread_checker_.CalledOnValidThread()); 110 DCHECK(thread_checker_.CalledOnValidThread());
101 raw_.RemoveSubscriber(subscriber); 111 raw_.RemoveSubscriber(subscriber);
102 } 112 }
103 113
104 } // namespace cast 114 } // namespace cast
105 } // namespace media 115 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/logging/logging_impl.h ('k') | media/cast/logging/logging_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698