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

Side by Side Diff: media/cast/logging/encoding_event_subscriber.h

Issue 168933002: Cast: Implemented relative RTP timestamp in EncodingEventSubscriber. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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"
(...skipping 28 matching lines...) Expand all
39 EncodingEventSubscriber(EventMediaType event_media_type, size_t max_frames); 39 EncodingEventSubscriber(EventMediaType event_media_type, size_t max_frames);
40 40
41 virtual ~EncodingEventSubscriber(); 41 virtual ~EncodingEventSubscriber();
42 42
43 // RawReventSubscriber implementations. 43 // RawReventSubscriber implementations.
44 virtual void OnReceiveFrameEvent(const FrameEvent& frame_event) OVERRIDE; 44 virtual void OnReceiveFrameEvent(const FrameEvent& frame_event) OVERRIDE;
45 virtual void OnReceivePacketEvent(const PacketEvent& packet_event) OVERRIDE; 45 virtual void OnReceivePacketEvent(const PacketEvent& packet_event) OVERRIDE;
46 virtual void OnReceiveGenericEvent(const GenericEvent& generic_event) 46 virtual void OnReceiveGenericEvent(const GenericEvent& generic_event)
47 OVERRIDE; 47 OVERRIDE;
48 48
49 // Assigns frame events received so far to |frame_events| and clears them 49 // Assigns frame events and packet events received so far to |frame_events|
50 // from this object. 50 // and clears them |packet_events| respectively, assigns the first seen RTP
51 void GetFrameEventsAndReset(FrameEventMap* frame_events); 51 // timestamp (which is used as a reference for all event entries) to
52 52 // |first_rtp_timestamp|, and reset this object's internal states.
53 // Assigns packet events received so far to |packet_events| and clears them 53 // All RTP timestamp values returned in the maps are relative to
54 // from this object. 54 // |first_rtp_timestamp|, i.e. suppose |first_rtp_timestamp| is X,
55 void GetPacketEventsAndReset(PacketEventMap* packet_events); 55 // then the first event will be recorded with a relative
56 // RTP timestamp value of 0. If the next event has original RTP timestamp
57 // X+20, it will be recorded with a relative RTP timestamp of 20.
58 void GetEventsAndReset(FrameEventMap* frame_events,
59 PacketEventMap* packet_events,
60 RtpTimestamp* first_rtp_timestamp);
56 61
57 private: 62 private:
58 bool ShouldProcessEvent(CastLoggingEvent event); 63 bool ShouldProcessEvent(CastLoggingEvent event);
59 64
60 // Removes oldest entry from |frame_event_map_| (ordered by RTP timestamp). 65 // Removes oldest entry from |frame_event_map_| (ordered by RTP timestamp).
61 void TruncateFrameEventMapIfNeeded(); 66 void TruncateFrameEventMapIfNeeded();
62 67
63 // Removes oldest entry from |packet_event_map_| (ordered by RTP timestamp). 68 // Removes oldest entry from |packet_event_map_| (ordered by RTP timestamp).
64 void TruncatePacketEventMapIfNeeded(); 69 void TruncatePacketEventMapIfNeeded();
65 70
71 // Returns the difference between |rtp_timestamp| and |first_rtp_timestamp_|.
72 // Sets |first_rtp_timestamp_| if it is not already set.
73 RtpTimestamp GetRelativeRtpTimestamp(RtpTimestamp rtp_timestamp);
74
75 // Clears the maps and first RTP timestamp seen.
76 void Reset();
77
66 const EventMediaType event_media_type_; 78 const EventMediaType event_media_type_;
67 const size_t max_frames_; 79 const size_t max_frames_;
68 80
69 FrameEventMap frame_event_map_; 81 FrameEventMap frame_event_map_;
70 PacketEventMap packet_event_map_; 82 PacketEventMap packet_event_map_;
71 83
72 // All functions must be called on the main thread. 84 // All functions must be called on the main thread.
73 base::ThreadChecker thread_checker_; 85 base::ThreadChecker thread_checker_;
74 86
87 // Set to true on first event encountered after a |Reset()|.
88 bool seen_first_rtp_timestamp_;
89 // Set to RTP timestamp of first event encountered after a |Reset()|.
Alpha Left Google 2014/02/18 21:54:28 nit: an empty line before this.
imcheng 2014/02/19 01:12:27 Done.
90 RtpTimestamp first_rtp_timestamp_;
91
75 DISALLOW_COPY_AND_ASSIGN(EncodingEventSubscriber); 92 DISALLOW_COPY_AND_ASSIGN(EncodingEventSubscriber);
76 }; 93 };
77 94
78 } // namespace cast 95 } // namespace cast
79 } // namespace media 96 } // namespace media
80 97
81 #endif // MEDIA_CAST_LOGGING_ENCODING_EVENT_SUBSCRIBER_H_ 98 #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