OLD | NEW |
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/memory/ref_counted.h" | |
11 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
12 #include "media/cast/logging/logging_defines.h" | 11 #include "media/cast/logging/logging_defines.h" |
13 #include "media/cast/logging/raw_event_subscriber.h" | 12 #include "media/cast/logging/raw_event_subscriber.h" |
14 #include "media/cast/rtcp/rtcp_defines.h" | 13 #include "media/cast/rtcp/rtcp_defines.h" |
15 | 14 |
16 namespace base { | 15 namespace base { |
17 | |
18 class SingleThreadTaskRunner; | 16 class SingleThreadTaskRunner; |
19 } | 17 } |
20 | 18 |
21 namespace media { | 19 namespace media { |
22 namespace cast { | 20 namespace cast { |
23 | 21 |
24 // A RawEventSubscriber implementation with the following properties: | 22 // A RawEventSubscriber implementation with the following properties: |
25 // - Only processes raw event types that are relevant for sending from cast | 23 // - Only processes raw event types that are relevant for sending from cast |
26 // receiver to cast sender via RTCP. | 24 // receiver to cast sender via RTCP. |
27 // - Captures information to be sent over to RTCP from raw event logs into the | 25 // - Captures information to be sent over to RTCP from raw event logs into the |
28 // more compact RtcpEvent struct. | 26 // more compact RtcpEvent struct. |
29 // - Orders events by RTP timestamp with a multimap. | 27 // - Orders events by RTP timestamp with a multimap. |
30 // - Internally, the map is capped at a maximum size configurable by the caller. | 28 // - Internally, the map is capped at a maximum size configurable by the caller. |
31 // The subscriber only keeps the most recent events (determined by RTP | 29 // The subscriber only keeps the most recent events (determined by RTP |
32 // timestamp) up to the size limit. | 30 // timestamp) up to the size limit. |
33 class ReceiverRtcpEventSubscriber : public RawEventSubscriber { | 31 class ReceiverRtcpEventSubscriber : public RawEventSubscriber { |
34 public: | 32 public: |
35 // Identifies whether the subscriber will process audio or video related | 33 // Identifies whether the subscriber will process audio or video related |
36 // frame events. | 34 // frame events. |
37 enum Type { | 35 enum Type { |
38 kAudioEventSubscriber, // Only processes audio events | 36 kAudioEventSubscriber, // Only processes audio events |
39 kVideoEventSubscriber // Only processes video events | 37 kVideoEventSubscriber // Only processes video events |
40 }; | 38 }; |
41 | 39 |
42 // |main_thread_proxy|: Check that the object is created in main thread. | |
43 // This object does not hold a reference on it. | |
44 // |max_size_to_retain|: The object will keep up to |max_size_to_retain| | 40 // |max_size_to_retain|: The object will keep up to |max_size_to_retain| |
45 // events | 41 // events |
46 // in the map. Once threshold has been reached, an event with the smallest | 42 // in the map. Once threshold has been reached, an event with the smallest |
47 // RTP timestamp will be removed. | 43 // RTP timestamp will be removed. |
48 // |type|: Determines whether the subscriber will process only audio or video | 44 // |type|: Determines whether the subscriber will process only audio or video |
49 // events. | 45 // events. |
50 ReceiverRtcpEventSubscriber( | 46 ReceiverRtcpEventSubscriber(const size_t max_size_to_retain, Type type); |
51 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_proxy, | |
52 const size_t max_size_to_retain, Type type); | |
53 | 47 |
54 virtual ~ReceiverRtcpEventSubscriber(); | 48 virtual ~ReceiverRtcpEventSubscriber(); |
55 | 49 |
56 // RawEventSubscriber implementation. | 50 // RawEventSubscriber implementation. |
57 virtual void OnReceiveFrameEvent(const FrameEvent& frame_event) OVERRIDE; | 51 virtual void OnReceiveFrameEvent(const FrameEvent& frame_event) OVERRIDE; |
58 virtual void OnReceivePacketEvent(const PacketEvent& packet_event) OVERRIDE; | 52 virtual void OnReceivePacketEvent(const PacketEvent& packet_event) OVERRIDE; |
59 virtual void OnReceiveGenericEvent(const GenericEvent& generic_event) | 53 virtual void OnReceiveGenericEvent(const GenericEvent& generic_event) |
60 OVERRIDE; | 54 OVERRIDE; |
61 | 55 |
62 // Converts all collected events since last invocation into | 56 // Converts all collected events since last invocation into |
(...skipping 22 matching lines...) Expand all Loading... |
85 // Ensures methods are only called on the main thread. | 79 // Ensures methods are only called on the main thread. |
86 base::ThreadChecker thread_checker_; | 80 base::ThreadChecker thread_checker_; |
87 | 81 |
88 DISALLOW_COPY_AND_ASSIGN(ReceiverRtcpEventSubscriber); | 82 DISALLOW_COPY_AND_ASSIGN(ReceiverRtcpEventSubscriber); |
89 }; | 83 }; |
90 | 84 |
91 } // namespace cast | 85 } // namespace cast |
92 } // namespace media | 86 } // namespace media |
93 | 87 |
94 #endif // MEDIA_CAST_RTCP_RECEIVER_RTCP_EVENT_SUBSCRIBER_H_ | 88 #endif // MEDIA_CAST_RTCP_RECEIVER_RTCP_EVENT_SUBSCRIBER_H_ |
OLD | NEW |