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

Unified Diff: media/cast/logging/encoding_event_subscriber.h

Issue 165723002: Cast: Implemented size limiting and event filtering in EncodingEventSubscriber. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/cast/logging/encoding_event_subscriber.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_;
« no previous file with comments | « no previous file | media/cast/logging/encoding_event_subscriber.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698