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

Side by Side Diff: media/cast/rtcp/receiver_rtcp_event_subscriber.h

Issue 270493003: Cast: Deduplicate event types in cast library. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 7 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
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_RTCP_RECEIVER_RTCP_EVENT_SUBSCRIBER_H_ 5 #ifndef MEDIA_CAST_RTCP_RECEIVER_RTCP_EVENT_SUBSCRIBER_H_
6 #define MEDIA_CAST_RTCP_RECEIVER_RTCP_EVENT_SUBSCRIBER_H_ 6 #define MEDIA_CAST_RTCP_RECEIVER_RTCP_EVENT_SUBSCRIBER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/threading/thread_checker.h" 10 #include "base/threading/thread_checker.h"
11 #include "media/cast/logging/logging_defines.h" 11 #include "media/cast/logging/logging_defines.h"
12 #include "media/cast/logging/raw_event_subscriber.h" 12 #include "media/cast/logging/raw_event_subscriber.h"
13 #include "media/cast/rtcp/rtcp_defines.h" 13 #include "media/cast/rtcp/rtcp_defines.h"
14 14
15 namespace base {
16 class SingleThreadTaskRunner;
17 }
18
19 namespace media { 15 namespace media {
20 namespace cast { 16 namespace cast {
21 17
22 // A RawEventSubscriber implementation with the following properties: 18 // A RawEventSubscriber implementation with the following properties:
23 // - Only processes raw event types that are relevant for sending from cast 19 // - Only processes raw event types that are relevant for sending from cast
24 // receiver to cast sender via RTCP. 20 // receiver to cast sender via RTCP.
25 // - Captures information to be sent over to RTCP from raw event logs into the 21 // - Captures information to be sent over to RTCP from raw event logs into the
26 // more compact RtcpEvent struct. 22 // more compact RtcpEvent struct.
27 // - Orders events by RTP timestamp with a multimap. 23 // - Orders events by RTP timestamp with a multimap.
28 // - Internally, the map is capped at a maximum size configurable by the caller. 24 // - Internally, the map is capped at a maximum size configurable by the caller.
29 // The subscriber only keeps the most recent events (determined by RTP 25 // The subscriber only keeps the most recent events (determined by RTP
30 // timestamp) up to the size limit. 26 // timestamp) up to the size limit.
31 class ReceiverRtcpEventSubscriber : public RawEventSubscriber { 27 class ReceiverRtcpEventSubscriber : public RawEventSubscriber {
32 public: 28 public:
33 typedef std::multimap<RtpTimestamp, RtcpEvent> RtcpEventMultiMap; 29 typedef std::multimap<RtpTimestamp, RtcpEvent> RtcpEventMultiMap;
34 30
35 // Identifies whether the subscriber will process audio or video related
36 // frame events.
37 enum Type {
38 kAudioEventSubscriber, // Only processes audio events
39 kVideoEventSubscriber // Only processes video events
40 };
41
42 // |max_size_to_retain|: The object will keep up to |max_size_to_retain| 31 // |max_size_to_retain|: The object will keep up to |max_size_to_retain|
43 // events 32 // events
44 // in the map. Once threshold has been reached, an event with the smallest 33 // in the map. Once threshold has been reached, an event with the smallest
45 // RTP timestamp will be removed. 34 // RTP timestamp will be removed.
46 // |type|: Determines whether the subscriber will process only audio or video 35 // |type|: Determines whether the subscriber will process only audio or video
47 // events. 36 // events.
48 ReceiverRtcpEventSubscriber(const size_t max_size_to_retain, Type type); 37 ReceiverRtcpEventSubscriber(const size_t max_size_to_retain,
38 EventMediaType type);
49 39
50 virtual ~ReceiverRtcpEventSubscriber(); 40 virtual ~ReceiverRtcpEventSubscriber();
51 41
52 // RawEventSubscriber implementation. 42 // RawEventSubscriber implementation.
53 virtual void OnReceiveFrameEvent(const FrameEvent& frame_event) OVERRIDE; 43 virtual void OnReceiveFrameEvent(const FrameEvent& frame_event) OVERRIDE;
54 virtual void OnReceivePacketEvent(const PacketEvent& packet_event) OVERRIDE; 44 virtual void OnReceivePacketEvent(const PacketEvent& packet_event) OVERRIDE;
55 45
56 // Assigns events collected to |rtcp_events| and clears them from this 46 // Assigns events collected to |rtcp_events| and clears them from this
57 // object. 47 // object.
58 void GetRtcpEventsAndReset(RtcpEventMultiMap* rtcp_events); 48 void GetRtcpEventsAndReset(RtcpEventMultiMap* rtcp_events);
59 49
60 private: 50 private:
61 // If |rtcp_events_.size()| exceeds |max_size_to_retain_|, remove an oldest 51 // If |rtcp_events_.size()| exceeds |max_size_to_retain_|, remove an oldest
62 // entry (determined by RTP timestamp) so its size no greater than 52 // entry (determined by RTP timestamp) so its size no greater than
63 // |max_size_to_retain_|. 53 // |max_size_to_retain_|.
64 void TruncateMapIfNeeded(); 54 void TruncateMapIfNeeded();
65 55
66 // Returns |true| if events of |event_type| should be processed. 56 // Returns |true| if events of |event_type| and |media_type|
67 bool ShouldProcessEvent(CastLoggingEvent event_type); 57 // should be processed.
58 bool ShouldProcessEvent(CastLoggingEvent event_type,
59 EventMediaType media_type);
68 60
69 const size_t max_size_to_retain_; 61 const size_t max_size_to_retain_;
70 Type type_; 62 EventMediaType type_;
71 63
72 // The key should really be something more than just a RTP timestamp in order 64 // The key should really be something more than just a RTP timestamp in order
73 // to differentiate between video and audio frames, but since the 65 // to differentiate between video and audio frames, but since the
74 // implementation doesn't mix audio and video frame events, RTP timestamp 66 // implementation doesn't mix audio and video frame events, RTP timestamp
75 // only as key is fine. 67 // only as key is fine.
76 RtcpEventMultiMap rtcp_events_; 68 RtcpEventMultiMap rtcp_events_;
77 69
78 // Ensures methods are only called on the main thread. 70 // Ensures methods are only called on the main thread.
79 base::ThreadChecker thread_checker_; 71 base::ThreadChecker thread_checker_;
80 72
81 DISALLOW_COPY_AND_ASSIGN(ReceiverRtcpEventSubscriber); 73 DISALLOW_COPY_AND_ASSIGN(ReceiverRtcpEventSubscriber);
82 }; 74 };
83 75
84 } // namespace cast 76 } // namespace cast
85 } // namespace media 77 } // namespace media
86 78
87 #endif // MEDIA_CAST_RTCP_RECEIVER_RTCP_EVENT_SUBSCRIBER_H_ 79 #endif // MEDIA_CAST_RTCP_RECEIVER_RTCP_EVENT_SUBSCRIBER_H_
OLDNEW
« no previous file with comments | « media/cast/logging/stats_event_subscriber_unittest.cc ('k') | media/cast/rtcp/receiver_rtcp_event_subscriber.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698