Commit 2601dc14 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Modernize media::cast::EncodingEventSubscriber code.

Change-Id: Ie55e502c78d9b5b5c834587f2b88d2ea19315f57
Reviewed-on: https://chromium-review.googlesource.com/1112769Reviewed-by: default avatarXiangjun Zhang <xjz@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570224}
parent 3985dbe0
...@@ -43,7 +43,7 @@ BasePacketEvent* GetNewBasePacketEvent(AggregatedPacketEvent* event_proto, ...@@ -43,7 +43,7 @@ BasePacketEvent* GetNewBasePacketEvent(AggregatedPacketEvent* event_proto,
return base; return base;
} }
} } // namespace
namespace media { namespace media {
namespace cast { namespace cast {
...@@ -150,7 +150,7 @@ void EncodingEventSubscriber::OnReceivePacketEvent( ...@@ -150,7 +150,7 @@ void EncodingEventSubscriber::OnReceivePacketEvent(
PacketEventMap::iterator it = PacketEventMap::iterator it =
packet_event_map_.find(relative_rtp_timestamp); packet_event_map_.find(relative_rtp_timestamp);
linked_ptr<AggregatedPacketEvent> event_proto; linked_ptr<AggregatedPacketEvent> event_proto;
BasePacketEvent* base_packet_event_proto = NULL; BasePacketEvent* base_packet_event_proto = nullptr;
// Look up existing entry. If not found, create a new entry and add to map. // Look up existing entry. If not found, create a new entry and add to map.
if (it == packet_event_map_.end()) { if (it == packet_event_map_.end()) {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <stddef.h> #include <stddef.h>
#include <map> #include <map>
#include <vector>
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/linked_ptr.h" #include "base/memory/linked_ptr.h"
...@@ -32,10 +33,8 @@ static const int kMaxEventsPerProto = 16; ...@@ -32,10 +33,8 @@ static const int kMaxEventsPerProto = 16;
// further events for that frame will be dropped. // further events for that frame will be dropped.
static const int kMaxProtosPerFrame = 10; static const int kMaxProtosPerFrame = 10;
typedef std::vector<linked_ptr<media::cast::proto::AggregatedFrameEvent> > using FrameEventList = std::vector<linked_ptr<proto::AggregatedFrameEvent>>;
FrameEventList; using PacketEventList = std::vector<linked_ptr<proto::AggregatedPacketEvent>>;
typedef std::vector<linked_ptr<media::cast::proto::AggregatedPacketEvent> >
PacketEventList;
// A RawEventSubscriber implementation that subscribes to events, // A RawEventSubscriber implementation that subscribes to events,
// encodes them in protocol buffer format, and aggregates them into a more // encodes them in protocol buffer format, and aggregates them into a more
...@@ -67,17 +66,15 @@ class EncodingEventSubscriber : public RawEventSubscriber { ...@@ -67,17 +66,15 @@ class EncodingEventSubscriber : public RawEventSubscriber {
// In addition, assign metadata associated with these events to |metadata|. // In addition, assign metadata associated with these events to |metadata|.
// The protos in |frame_events| and |packets_events| are sorted in // The protos in |frame_events| and |packets_events| are sorted in
// ascending RTP timestamp order. // ascending RTP timestamp order.
void GetEventsAndReset(media::cast::proto::LogMetadata* metadata, void GetEventsAndReset(proto::LogMetadata* metadata,
FrameEventList* frame_events, FrameEventList* frame_events,
PacketEventList* packet_events); PacketEventList* packet_events);
private: private:
typedef std::map<RtpTimeDelta, using FrameEventMap =
linked_ptr<media::cast::proto::AggregatedFrameEvent>> std::map<RtpTimeDelta, linked_ptr<proto::AggregatedFrameEvent>>;
FrameEventMap; using PacketEventMap =
typedef std::map<RtpTimeDelta, std::map<RtpTimeDelta, linked_ptr<proto::AggregatedPacketEvent>>;
linked_ptr<media::cast::proto::AggregatedPacketEvent>>
PacketEventMap;
// Transfer up to |max_num_entries| smallest entries from |frame_event_map_| // Transfer up to |max_num_entries| smallest entries from |frame_event_map_|
// to |frame_event_storage_|. This helps keep size of |frame_event_map_| small // to |frame_event_storage_|. This helps keep size of |frame_event_map_| small
...@@ -87,11 +84,9 @@ class EncodingEventSubscriber : public RawEventSubscriber { ...@@ -87,11 +84,9 @@ class EncodingEventSubscriber : public RawEventSubscriber {
void TransferPacketEvents(size_t max_num_entries); void TransferPacketEvents(size_t max_num_entries);
void AddFrameEventToStorage( void AddFrameEventToStorage(
const linked_ptr<media::cast::proto::AggregatedFrameEvent>& const linked_ptr<proto::AggregatedFrameEvent>& frame_event_proto);
frame_event_proto);
void AddPacketEventToStorage( void AddPacketEventToStorage(
const linked_ptr<media::cast::proto::AggregatedPacketEvent>& const linked_ptr<proto::AggregatedPacketEvent>& packet_event_proto);
packet_event_proto);
bool ShouldCreateNewProto( bool ShouldCreateNewProto(
uint32_t relative_rtp_timestamp_lower_32_bits) const; uint32_t relative_rtp_timestamp_lower_32_bits) const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment