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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | media/cast/logging/encoding_event_subscriber.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 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 <map> 8 #include <map>
9 9
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
11 #include "base/threading/thread_checker.h" 11 #include "base/threading/thread_checker.h"
12 #include "media/cast/logging/logging_defines.h"
12 #include "media/cast/logging/proto/raw_events.pb.h" 13 #include "media/cast/logging/proto/raw_events.pb.h"
13 #include "media/cast/logging/raw_event_subscriber.h" 14 #include "media/cast/logging/raw_event_subscriber.h"
14 15
15 namespace media { 16 namespace media {
16 namespace cast { 17 namespace cast {
17 18
18 typedef std::map<RtpTimestamp, 19 typedef std::map<RtpTimestamp,
19 linked_ptr<media::cast::proto::AggregatedFrameEvent> > 20 linked_ptr<media::cast::proto::AggregatedFrameEvent> >
20 FrameEventMap; 21 FrameEventMap;
21 typedef std::map<RtpTimestamp, 22 typedef std::map<RtpTimestamp,
22 linked_ptr<media::cast::proto::AggregatedPacketEvent> > 23 linked_ptr<media::cast::proto::AggregatedPacketEvent> >
23 PacketEventMap; 24 PacketEventMap;
24 typedef std::map<CastLoggingEvent,
25 linked_ptr<media::cast::proto::AggregatedGenericEvent> >
26 GenericEventMap;
27 25
28 // A RawEventSubscriber implementation that subscribes to events, 26 // A RawEventSubscriber implementation that subscribes to events,
29 // encodes them in protocol buffer format, and aggregates them into a more 27 // encodes them in protocol buffer format, and aggregates them into a more
30 // compact structure. 28 // compact structure.
31 // TODO(imcheng): Implement event filtering and windowing based on size.
32 class EncodingEventSubscriber : public RawEventSubscriber { 29 class EncodingEventSubscriber : public RawEventSubscriber {
33 public: 30 public:
34 EncodingEventSubscriber(); 31 // |event_media_type|: The subscriber will only process events that
32 // corresponds to this type.
33 // |max_frames|: How many events to keep in the frame / packet map.
34 // This helps keep memory usage bounded.
35 // Every time one of |OnReceive[Frame,Packet]Event()| is
36 // called, it will check if the respective map size has exceeded |max_frames|.
37 // If so, it will remove the oldest aggregated entry (ordered by RTP
38 // timestamp).
39 EncodingEventSubscriber(EventMediaType event_media_type, size_t max_frames);
35 40
36 virtual ~EncodingEventSubscriber(); 41 virtual ~EncodingEventSubscriber();
37 42
38 // RawReventSubscriber implementations. 43 // RawReventSubscriber implementations.
39 virtual void OnReceiveFrameEvent(const FrameEvent& frame_event) OVERRIDE; 44 virtual void OnReceiveFrameEvent(const FrameEvent& frame_event) OVERRIDE;
40 virtual void OnReceivePacketEvent(const PacketEvent& packet_event) OVERRIDE; 45 virtual void OnReceivePacketEvent(const PacketEvent& packet_event) OVERRIDE;
41 virtual void OnReceiveGenericEvent(const GenericEvent& generic_event) 46 virtual void OnReceiveGenericEvent(const GenericEvent& generic_event)
42 OVERRIDE; 47 OVERRIDE;
43 48
44 // Assigns frame events received so far to |frame_events| and clears them 49 // Assigns frame events received so far to |frame_events| and clears them
45 // from this object. 50 // from this object.
46 void GetFrameEventsAndReset(FrameEventMap* frame_events); 51 void GetFrameEventsAndReset(FrameEventMap* frame_events);
47 52
48 // Assigns packet events received so far to |packet_events| and clears them 53 // Assigns packet events received so far to |packet_events| and clears them
49 // from this object. 54 // from this object.
50 void GetPacketEventsAndReset(PacketEventMap* packet_events); 55 void GetPacketEventsAndReset(PacketEventMap* packet_events);
51 56
52 // Assigns generic events received so far to |generic_events| and clears them 57 private:
53 // from this object. 58 bool ShouldProcessEvent(CastLoggingEvent event);
54 void GetGenericEventsAndReset(GenericEventMap* generic_events);
55 59
56 private: 60 // Removes oldest entry from |frame_event_map_| (ordered by RTP timestamp).
61 void TruncateFrameEventMapIfNeeded();
62
63 // Removes oldest entry from |packet_event_map_| (ordered by RTP timestamp).
64 void TruncatePacketEventMapIfNeeded();
65
66 const EventMediaType event_media_type_;
67 const size_t max_frames_;
68
57 FrameEventMap frame_event_map_; 69 FrameEventMap frame_event_map_;
58 PacketEventMap packet_event_map_; 70 PacketEventMap packet_event_map_;
59 GenericEventMap generic_event_map_;
60 71
61 // All functions must be called on the main thread. 72 // All functions must be called on the main thread.
62 base::ThreadChecker thread_checker_; 73 base::ThreadChecker thread_checker_;
63 74
64 DISALLOW_COPY_AND_ASSIGN(EncodingEventSubscriber); 75 DISALLOW_COPY_AND_ASSIGN(EncodingEventSubscriber);
65 }; 76 };
66 77
67 } // namespace cast 78 } // namespace cast
68 } // namespace media 79 } // namespace media
69 80
70 #endif // MEDIA_CAST_LOGGING_ENCODING_EVENT_SUBSCRIBER_H_ 81 #endif // MEDIA_CAST_LOGGING_ENCODING_EVENT_SUBSCRIBER_H_
OLDNEW
« 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