OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MEDIA_CAST_LOGGING_ENCODING_EVENT_SUBSCRIBER_H_ |
| 6 #define MEDIA_CAST_LOGGING_ENCODING_EVENT_SUBSCRIBER_H_ |
| 7 |
| 8 #include <map> |
| 9 |
| 10 #include "base/memory/linked_ptr.h" |
| 11 #include "base/threading/thread_checker.h" |
| 12 #include "media/cast/logging/proto/raw_events.pb.h" |
| 13 #include "media/cast/logging/raw_event_subscriber.h" |
| 14 |
| 15 namespace media { |
| 16 namespace cast { |
| 17 |
| 18 typedef std::map<RtpTimestamp, |
| 19 linked_ptr<media::cast::proto::AggregatedFrameEvent> > |
| 20 FrameEventMap; |
| 21 typedef std::map<RtpTimestamp, |
| 22 linked_ptr<media::cast::proto::AggregatedPacketEvent> > |
| 23 PacketEventMap; |
| 24 typedef std::map<CastLoggingEvent, |
| 25 linked_ptr<media::cast::proto::AggregatedGenericEvent> > |
| 26 GenericEventMap; |
| 27 |
| 28 // A RawEventSubscriber implementation that subscribes to events, |
| 29 // encodes them in protocol buffer format, and aggregates them into a more |
| 30 // compact structure. |
| 31 // TODO(imcheng): Implement event filtering and windowing based on size. |
| 32 class EncodingEventSubscriber : public RawEventSubscriber { |
| 33 public: |
| 34 EncodingEventSubscriber(); |
| 35 |
| 36 virtual ~EncodingEventSubscriber(); |
| 37 |
| 38 // RawReventSubscriber implementations. |
| 39 virtual void OnReceiveFrameEvent(const FrameEvent& frame_event) OVERRIDE; |
| 40 virtual void OnReceivePacketEvent(const PacketEvent& packet_event) OVERRIDE; |
| 41 virtual void OnReceiveGenericEvent(const GenericEvent& generic_event) |
| 42 OVERRIDE; |
| 43 |
| 44 // Assigns frame events received so far to |frame_events| and clears them |
| 45 // from this object. |
| 46 void GetFrameEventsAndReset(FrameEventMap* frame_events); |
| 47 |
| 48 // Assigns packet events received so far to |packet_events| and clears them |
| 49 // from this object. |
| 50 void GetPacketEventsAndReset(PacketEventMap* packet_events); |
| 51 |
| 52 // Assigns generic events received so far to |generic_events| and clears them |
| 53 // from this object. |
| 54 void GetGenericEventsAndReset(GenericEventMap* generic_events); |
| 55 |
| 56 private: |
| 57 FrameEventMap frame_event_map_; |
| 58 PacketEventMap packet_event_map_; |
| 59 GenericEventMap generic_event_map_; |
| 60 |
| 61 // All functions must be called on the main thread. |
| 62 base::ThreadChecker thread_checker_; |
| 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(EncodingEventSubscriber); |
| 65 }; |
| 66 |
| 67 } // namespace cast |
| 68 } // namespace media |
| 69 |
| 70 #endif // MEDIA_CAST_LOGGING_ENCODING_EVENT_SUBSCRIBER_H_ |
OLD | NEW |