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_SENDER_RTCP_EVENT_SUBSCRIBER_H_ | 5 #ifndef MEDIA_CAST_RTCP_SENDER_RTCP_EVENT_SUBSCRIBER_H_ |
6 #define MEDIA_CAST_RTCP_SENDER_RTCP_EVENT_SUBSCRIBER_H_ | 6 #define MEDIA_CAST_RTCP_SENDER_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 { | |
17 | |
18 class SingleThreadTaskRunner; | |
19 } | |
20 | |
21 namespace media { | 15 namespace media { |
22 namespace cast { | 16 namespace cast { |
23 | 17 |
24 // The key should really be something more than just a RTP timestamp in order | 18 // The key should really be something more than just a RTP timestamp in order |
25 // to differentiate between video and audio frames, but since the implementation | 19 // to differentiate between video and audio frames, but since the implementation |
26 // only process video frame events, RTP timestamp only as key is fine. | 20 // only process video frame events, RTP timestamp only as key is fine. |
27 typedef std::map<RtpTimestamp, RtcpEvent> RtcpEventMap; | 21 typedef std::map<RtpTimestamp, RtcpEvent> RtcpEventMap; |
28 | 22 |
29 // A RawEventSubscriber implementation with the following properties: | 23 // A RawEventSubscriber implementation with the following properties: |
30 // - Only processes raw event types that are relevant for sending from cast | 24 // - Only processes raw event types that are relevant for sending from cast |
31 // sender to cast receiver via RTCP. | 25 // sender to cast receiver via RTCP. |
32 // - Captures information to be sent over to RTCP from raw event logs into the | 26 // - Captures information to be sent over to RTCP from raw event logs into the |
33 // more compact RtcpEvent struct. | 27 // more compact RtcpEvent struct. |
34 // - Orders events by RTP timestamp with a map. | 28 // - Orders events by RTP timestamp with a map. |
35 // - Internally, the map is capped at a maximum size configurable by the caller. | 29 // - Internally, the map is capped at a maximum size configurable by the caller. |
36 // The subscriber only keeps the most recent events (determined by RTP | 30 // The subscriber only keeps the most recent events (determined by RTP |
37 // timestamp) up to the size limit. | 31 // timestamp) up to the size limit. |
38 class SenderRtcpEventSubscriber : public RawEventSubscriber { | 32 class SenderRtcpEventSubscriber : public RawEventSubscriber { |
39 public: | 33 public: |
40 // |main_thread_proxy|: Check that the object is created in main thread. | |
41 // This object does not hold a reference on it. | |
42 // |max_size_to_retain|: The object will keep up to |max_size_to_retain| | 34 // |max_size_to_retain|: The object will keep up to |max_size_to_retain| |
43 // events | 35 // events |
44 // in the map. Once threshold has been reached, an event with the smallest | 36 // in the map. Once threshold has been reached, an event with the smallest |
45 // RTP timestamp will be removed. | 37 // RTP timestamp will be removed. |
46 SenderRtcpEventSubscriber( | 38 SenderRtcpEventSubscriber(const size_t max_size_to_retain); |
47 const scoped_refptr<base::SingleThreadTaskRunner>& main_thread_proxy, | 39 |
48 const size_t max_size_to_retain); | |
49 virtual ~SenderRtcpEventSubscriber(); | 40 virtual ~SenderRtcpEventSubscriber(); |
50 | 41 |
51 // RawEventSubscriber implementation. | 42 // RawEventSubscriber implementation. |
52 virtual void OnReceiveFrameEvent(const FrameEvent& frame_event) OVERRIDE; | 43 virtual void OnReceiveFrameEvent(const FrameEvent& frame_event) OVERRIDE; |
53 virtual void OnReceivePacketEvent(const PacketEvent& packet_event) OVERRIDE; | 44 virtual void OnReceivePacketEvent(const PacketEvent& packet_event) OVERRIDE; |
54 virtual void OnReceiveGenericEvent(const GenericEvent& generic_event) | 45 virtual void OnReceiveGenericEvent(const GenericEvent& generic_event) |
55 OVERRIDE; | 46 OVERRIDE; |
56 | 47 |
57 // Assigns all collected events since last invocation to |rtcp_events|, and | 48 // Assigns all collected events since last invocation to |rtcp_events|, and |
58 // clears |rtcp_events_|. | 49 // clears |rtcp_events_|. |
(...skipping 12 matching lines...) Expand all Loading... |
71 // Ensures methods are only called on the main thread. | 62 // Ensures methods are only called on the main thread. |
72 base::ThreadChecker thread_checker_; | 63 base::ThreadChecker thread_checker_; |
73 | 64 |
74 DISALLOW_COPY_AND_ASSIGN(SenderRtcpEventSubscriber); | 65 DISALLOW_COPY_AND_ASSIGN(SenderRtcpEventSubscriber); |
75 }; | 66 }; |
76 | 67 |
77 } // namespace cast | 68 } // namespace cast |
78 } // namespace media | 69 } // namespace media |
79 | 70 |
80 #endif // MEDIA_CAST_RTCP_SENDER_RTCP_EVENT_SUBSCRIBER_H_ | 71 #endif // MEDIA_CAST_RTCP_SENDER_RTCP_EVENT_SUBSCRIBER_H_ |
OLD | NEW |