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.
5 #ifndef MEDIA_CAST_LOGGING_ENCODING_EVENT_SUBSCRIBER_H_
6 #define MEDIA_CAST_LOGGING_ENCODING_EVENT_SUBSCRIBER_H_
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"
18 typedef std::map
<RtpTimestamp
,
19 linked_ptr
<media::cast::proto::AggregatedFrameEvent
> >
21 typedef std::map
<RtpTimestamp
,
22 linked_ptr
<media::cast::proto::AggregatedPacketEvent
> >
24 typedef std::map
<CastLoggingEvent
,
25 linked_ptr
<media::cast::proto::AggregatedGenericEvent
> >
28 // A RawEventSubscriber implementation that subscribes to events,
29 // encodes them in protocol buffer format, and aggregates them into a more
31 // TODO(imcheng): Implement event filtering and windowing based on size.
32 class EncodingEventSubscriber
: public RawEventSubscriber
{
34 EncodingEventSubscriber();
36 virtual ~EncodingEventSubscriber();
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
)
44 // Assigns frame events received so far to |frame_events| and clears them
46 void GetFrameEventsAndReset(FrameEventMap
* frame_events
);
48 // Assigns packet events received so far to |packet_events| and clears them
50 void GetPacketEventsAndReset(PacketEventMap
* packet_events
);
52 // Assigns generic events received so far to |generic_events| and clears them
54 void GetGenericEventsAndReset(GenericEventMap
* generic_events
);
57 FrameEventMap frame_event_map_
;
58 PacketEventMap packet_event_map_
;
59 GenericEventMap generic_event_map_
;
61 // All functions must be called on the main thread.
62 base::ThreadChecker thread_checker_
;
64 DISALLOW_COPY_AND_ASSIGN(EncodingEventSubscriber
);
70 #endif // MEDIA_CAST_LOGGING_ENCODING_EVENT_SUBSCRIBER_H_