Index: media/cast/logging/encoding_event_subscriber.h |
diff --git a/media/cast/logging/encoding_event_subscriber.h b/media/cast/logging/encoding_event_subscriber.h |
index e80061d32422fc8f45834f08ed410c88ebb35965..acd1d14bd003c9bb63effb99b814b5f3b7632fb7 100644 |
--- a/media/cast/logging/encoding_event_subscriber.h |
+++ b/media/cast/logging/encoding_event_subscriber.h |
@@ -9,6 +9,7 @@ |
#include "base/memory/linked_ptr.h" |
#include "base/threading/thread_checker.h" |
+#include "media/cast/logging/logging_defines.h" |
#include "media/cast/logging/proto/raw_events.pb.h" |
#include "media/cast/logging/raw_event_subscriber.h" |
@@ -21,17 +22,21 @@ typedef std::map<RtpTimestamp, |
typedef std::map<RtpTimestamp, |
linked_ptr<media::cast::proto::AggregatedPacketEvent> > |
PacketEventMap; |
-typedef std::map<CastLoggingEvent, |
- linked_ptr<media::cast::proto::AggregatedGenericEvent> > |
- GenericEventMap; |
// A RawEventSubscriber implementation that subscribes to events, |
// encodes them in protocol buffer format, and aggregates them into a more |
// compact structure. |
-// TODO(imcheng): Implement event filtering and windowing based on size. |
class EncodingEventSubscriber : public RawEventSubscriber { |
public: |
- EncodingEventSubscriber(); |
+ // |event_media_type|: The subscriber will only process events that |
+ // corresponds to this type. |
+ // |max_frames|: How many events to keep in the frame / packet map. |
+ // This helps keep memory usage bounded. |
+ // Every time one of |OnReceive[Frame,Packet]Event()| is |
+ // called, it will check if the respective map size has exceeded |max_frames|. |
+ // If so, it will remove the oldest aggregated entry (ordered by RTP |
+ // timestamp). |
+ EncodingEventSubscriber(EventMediaType event_media_type, size_t max_frames); |
virtual ~EncodingEventSubscriber(); |
@@ -49,14 +54,20 @@ class EncodingEventSubscriber : public RawEventSubscriber { |
// from this object. |
void GetPacketEventsAndReset(PacketEventMap* packet_events); |
- // Assigns generic events received so far to |generic_events| and clears them |
- // from this object. |
- void GetGenericEventsAndReset(GenericEventMap* generic_events); |
- |
private: |
+ bool ShouldProcessEvent(CastLoggingEvent event); |
+ |
+ // Removes oldest entry from |frame_event_map_| (ordered by RTP timestamp). |
+ void TruncateFrameEventMapIfNeeded(); |
+ |
+ // Removes oldest entry from |packet_event_map_| (ordered by RTP timestamp). |
+ void TruncatePacketEventMapIfNeeded(); |
+ |
+ const EventMediaType event_media_type_; |
+ const size_t max_frames_; |
+ |
FrameEventMap frame_event_map_; |
PacketEventMap packet_event_map_; |
- GenericEventMap generic_event_map_; |
// All functions must be called on the main thread. |
base::ThreadChecker thread_checker_; |