| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef MEDIA_CAST_LOGGING_ENCODING_EVENT_SUBSCRIBER_H_ | 5 #ifndef MEDIA_CAST_LOGGING_ENCODING_EVENT_SUBSCRIBER_H_ |
| 6 #define MEDIA_CAST_LOGGING_ENCODING_EVENT_SUBSCRIBER_H_ | 6 #define MEDIA_CAST_LOGGING_ENCODING_EVENT_SUBSCRIBER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 // Assigns frame events and packet events received so far to |frame_events| | 61 // Assigns frame events and packet events received so far to |frame_events| |
| 62 // and |packet_events| and resets the internal state. | 62 // and |packet_events| and resets the internal state. |
| 63 // In addition, assign metadata associated with these events to |metadata|. | 63 // In addition, assign metadata associated with these events to |metadata|. |
| 64 // The protos in |frame_events| and |packets_events| are sorted in | 64 // The protos in |frame_events| and |packets_events| are sorted in |
| 65 // ascending RTP timestamp order. | 65 // ascending RTP timestamp order. |
| 66 void GetEventsAndReset(media::cast::proto::LogMetadata* metadata, | 66 void GetEventsAndReset(media::cast::proto::LogMetadata* metadata, |
| 67 FrameEventList* frame_events, | 67 FrameEventList* frame_events, |
| 68 PacketEventList* packet_events); | 68 PacketEventList* packet_events); |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 typedef std::map<RtpTimestamp, | 71 typedef std::map<RtpTimeDelta, |
| 72 linked_ptr<media::cast::proto::AggregatedFrameEvent> > | 72 linked_ptr<media::cast::proto::AggregatedFrameEvent>> |
| 73 FrameEventMap; | 73 FrameEventMap; |
| 74 typedef std::map<RtpTimestamp, | 74 typedef std::map<RtpTimeDelta, |
| 75 linked_ptr<media::cast::proto::AggregatedPacketEvent> > | 75 linked_ptr<media::cast::proto::AggregatedPacketEvent>> |
| 76 PacketEventMap; | 76 PacketEventMap; |
| 77 | 77 |
| 78 // Transfer up to |max_num_entries| smallest entries from |frame_event_map_| | 78 // Transfer up to |max_num_entries| smallest entries from |frame_event_map_| |
| 79 // to |frame_event_storage_|. This helps keep size of |frame_event_map_| small | 79 // to |frame_event_storage_|. This helps keep size of |frame_event_map_| small |
| 80 // and lookup speed fast. | 80 // and lookup speed fast. |
| 81 void TransferFrameEvents(size_t max_num_entries); | 81 void TransferFrameEvents(size_t max_num_entries); |
| 82 // See above. | 82 // See above. |
| 83 void TransferPacketEvents(size_t max_num_entries); | 83 void TransferPacketEvents(size_t max_num_entries); |
| 84 | 84 |
| 85 void AddFrameEventToStorage( | 85 void AddFrameEventToStorage( |
| 86 const linked_ptr<media::cast::proto::AggregatedFrameEvent>& | 86 const linked_ptr<media::cast::proto::AggregatedFrameEvent>& |
| 87 frame_event_proto); | 87 frame_event_proto); |
| 88 void AddPacketEventToStorage( | 88 void AddPacketEventToStorage( |
| 89 const linked_ptr<media::cast::proto::AggregatedPacketEvent>& | 89 const linked_ptr<media::cast::proto::AggregatedPacketEvent>& |
| 90 packet_event_proto); | 90 packet_event_proto); |
| 91 | 91 |
| 92 // Returns the difference between |rtp_timestamp| and |first_rtp_timestamp_|. | 92 // Returns the difference between |rtp_timestamp| and |first_rtp_timestamp_|. |
| 93 // Sets |first_rtp_timestamp_| if it is not already set. | 93 // Sets |first_rtp_timestamp_| if it is not already set. |
| 94 RtpTimestamp GetRelativeRtpTimestamp(RtpTimestamp rtp_timestamp); | 94 RtpTimeDelta GetRelativeRtpTimestamp(RtpTimeTicks rtp_timestamp); |
| 95 | 95 |
| 96 // Clears the maps and first RTP timestamp seen. | 96 // Clears the maps and first RTP timestamp seen. |
| 97 void Reset(); | 97 void Reset(); |
| 98 | 98 |
| 99 const EventMediaType event_media_type_; | 99 const EventMediaType event_media_type_; |
| 100 const size_t max_frames_; | 100 const size_t max_frames_; |
| 101 | 101 |
| 102 FrameEventMap frame_event_map_; | 102 FrameEventMap frame_event_map_; |
| 103 FrameEventList frame_event_storage_; | 103 FrameEventList frame_event_storage_; |
| 104 int frame_event_storage_index_; | 104 int frame_event_storage_index_; |
| 105 | 105 |
| 106 PacketEventMap packet_event_map_; | 106 PacketEventMap packet_event_map_; |
| 107 PacketEventList packet_event_storage_; | 107 PacketEventList packet_event_storage_; |
| 108 int packet_event_storage_index_; | 108 int packet_event_storage_index_; |
| 109 | 109 |
| 110 // All functions must be called on the main thread. | 110 // All functions must be called on the main thread. |
| 111 base::ThreadChecker thread_checker_; | 111 base::ThreadChecker thread_checker_; |
| 112 | 112 |
| 113 // Set to true on first event encountered after a |Reset()|. | 113 // Set to true on first event encountered after a |Reset()|. |
| 114 bool seen_first_rtp_timestamp_; | 114 bool seen_first_rtp_timestamp_; |
| 115 | 115 |
| 116 // Set to RTP timestamp of first event encountered after a |Reset()|. | 116 // Set to RTP timestamp of first event encountered after a |Reset()|. |
| 117 RtpTimestamp first_rtp_timestamp_; | 117 RtpTimeTicks first_rtp_timestamp_; |
| 118 | 118 |
| 119 DISALLOW_COPY_AND_ASSIGN(EncodingEventSubscriber); | 119 DISALLOW_COPY_AND_ASSIGN(EncodingEventSubscriber); |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 } // namespace cast | 122 } // namespace cast |
| 123 } // namespace media | 123 } // namespace media |
| 124 | 124 |
| 125 #endif // MEDIA_CAST_LOGGING_ENCODING_EVENT_SUBSCRIBER_H_ | 125 #endif // MEDIA_CAST_LOGGING_ENCODING_EVENT_SUBSCRIBER_H_ |
| OLD | NEW |