Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c0535c1bdc70dcbe1072fa5927a35af5a6023b7a |
| --- /dev/null |
| +++ b/media/cast/logging/encoding_event_subscriber.h |
| @@ -0,0 +1,75 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
|
Alpha Left Google
2014/02/11 22:14:03
Isn't this subscriber specific to Cast Streaming A
Alpha Left Google
2014/02/11 22:49:13
Nevermind my previous comment. Putting it in this
imcheng
2014/02/12 08:44:13
Ack.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef MEDIA_CAST_LOGGING_ENCODING_EVENT_SUBSCRIBER_H_ |
| +#define MEDIA_CAST_LOGGING_ENCODING_EVENT_SUBSCRIBER_H_ |
| + |
| +#include <map> |
| + |
| +#include "base/memory/linked_ptr.h" |
| +#include "base/single_thread_task_runner.h" |
| +#include "base/threading/thread_checker.h" |
| +#include "media/cast/logging/proto/raw_events.pb.h" |
| +#include "media/cast/logging/raw_event_subscriber.h" |
| + |
| +namespace media { |
| +namespace cast { |
| + |
| +typedef std::map<RtpTimestamp, |
| + linked_ptr<media::cast::proto::AggregatedFrameEvent> > |
| + FrameEventMap; |
| +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: |
| + // |main_thread_proxy|: Only used for ensuring the subscriber is only called |
|
Alpha Left Google
2014/02/11 22:49:13
This is not very useful. I suggest you remove this
imcheng
2014/02/12 08:44:13
I suppose that's true. The only difference it will
|
| + // on the main thread. This object does not keep a reference on it. |
| + explicit EncodingEventSubscriber( |
| + const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_proxy); |
| + |
| + virtual ~EncodingEventSubscriber(); |
| + |
| + virtual void OnReceiveFrameEvent(const FrameEvent& frame_event) OVERRIDE; |
|
Alpha Left Google
2014/02/11 22:49:13
nit:
// RawReventSubscriber implementations.
imcheng
2014/02/12 08:44:13
Done.
|
| + |
| + virtual void OnReceivePacketEvent(const PacketEvent& packet_event) OVERRIDE; |
| + |
| + virtual void OnReceiveGenericEvent(const GenericEvent& generic_event) |
| + OVERRIDE; |
| + |
| + // Assigns frame events received so far to |frame_events| and clears them |
| + // from this object. |
| + void GetFrameEventsAndReset(FrameEventMap* frame_events); |
| + |
| + // Assigns packet events received so far to |packet_events| and clears them |
| + // 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: |
| + 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_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(EncodingEventSubscriber); |
| +}; |
| + |
| +} // namespace cast |
| +} // namespace media |
| + |
| +#endif // MEDIA_CAST_LOGGING_ENCODING_EVENT_SUBSCRIBER_H_ |