OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_ | 5 #ifndef CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_ |
6 #define CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_ | 6 #define CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
16 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
17 #include "base/time/default_tick_clock.h" | 17 #include "base/time/default_tick_clock.h" |
18 #include "media/cast/cast_config.h" | 18 #include "media/cast/cast_config.h" |
19 #include "media/cast/cast_sender.h" | 19 #include "media/cast/cast_sender.h" |
20 #include "media/cast/logging/encoding_event_subscriber.h" | |
20 #include "media/cast/logging/logging_defines.h" | 21 #include "media/cast/logging/logging_defines.h" |
22 #include "media/cast/logging/stats_event_subscriber.h" | |
21 | 23 |
22 namespace base { | 24 namespace base { |
23 class BinaryValue; | 25 class BinaryValue; |
24 class DictionaryValue; | 26 class DictionaryValue; |
25 class MessageLoopProxy; | 27 class MessageLoopProxy; |
26 } // namespace base | 28 } // namespace base |
27 | 29 |
28 namespace media { | 30 namespace media { |
29 class VideoFrame; | 31 class VideoFrame; |
30 | 32 |
31 namespace cast { | 33 namespace cast { |
32 class CastEnvironment; | 34 class CastEnvironment; |
33 class EncodingEventSubscriber; | 35 class EncodingEventSubscriber; |
34 class FrameInput; | 36 class FrameInput; |
37 class ReceiverTimeOffsetEstimator; | |
35 class StatsEventSubscriber; | 38 class StatsEventSubscriber; |
36 | 39 |
37 namespace transport { | 40 namespace transport { |
38 class CastTransportSender; | 41 class CastTransportSender; |
39 } // namespace transport | 42 } // namespace transport |
40 } // namespace cast | 43 } // namespace cast |
41 } // namespace media | 44 } // namespace media |
42 | 45 |
46 class RawEventSubscriberBundleForStream { | |
miu
2014/04/18 00:02:03
Have you considered declaring/defining these two n
miu
2014/04/18 00:02:03
Need class comments: What are these being used for
imcheng
2014/04/18 18:20:27
Done.
imcheng
2014/04/18 18:20:27
Done.
| |
47 public: | |
48 RawEventSubscriberBundleForStream( | |
49 bool is_audio, | |
50 media::cast::ReceiverTimeOffsetEstimator* offset_estimator, | |
51 const scoped_refptr<media::cast::CastEnvironment>& cast_environment); | |
miu
2014/04/18 00:02:03
nit: For consistency with a lot of the other cast
imcheng
2014/04/18 18:20:27
Done.
| |
52 ~RawEventSubscriberBundleForStream(); | |
53 media::cast::EncodingEventSubscriber* GetEncodingEventSubscriber(); | |
54 media::cast::StatsEventSubscriber* GetStatsEventSubscriber(); | |
55 | |
56 private: | |
57 scoped_refptr<media::cast::CastEnvironment> cast_environment_; | |
miu
2014/04/18 00:02:03
const scoped_refptr<...>
imcheng
2014/04/18 18:20:27
Done.
| |
58 media::cast::EncodingEventSubscriber event_subscriber_; | |
59 media::cast::StatsEventSubscriber stats_subscriber_; | |
60 }; | |
61 | |
62 class RawEventSubscriberBundle { | |
63 public: | |
64 RawEventSubscriberBundle( | |
miu
2014/04/18 00:02:03
Needs explicit keyword.
imcheng
2014/04/18 18:20:27
Done.
| |
65 const scoped_refptr<media::cast::CastEnvironment>& cast_environment); | |
66 ~RawEventSubscriberBundle(); | |
67 void AddEventSubscribers(bool is_audio); | |
68 void RemoveEventSubscribers(bool is_audio); | |
69 media::cast::EncodingEventSubscriber* GetEncodingEventSubscriber( | |
70 bool is_audio); | |
71 media::cast::StatsEventSubscriber* GetStatsEventSubscriber(bool is_audio); | |
72 | |
73 private: | |
74 // Map from (is_audio) -> RawEventSubscriberBundleForStream. | |
75 // TODO(imcheng): This works because we only have 1 audio and 1 video stream. | |
76 // This needs to scale better. | |
77 typedef std::map<bool, linked_ptr<RawEventSubscriberBundleForStream> > | |
78 SubscribersMapByStream; | |
79 scoped_refptr<media::cast::CastEnvironment> cast_environment_; | |
miu
2014/04/18 00:02:03
const
imcheng
2014/04/18 18:20:27
Done.
| |
80 SubscribersMapByStream subscribers_; | |
81 scoped_ptr<media::cast::ReceiverTimeOffsetEstimator> | |
82 receiver_offset_estimator_; | |
83 }; | |
84 | |
43 // This class hosts CastSender and connects it to audio/video frame input | 85 // This class hosts CastSender and connects it to audio/video frame input |
44 // and network socket. | 86 // and network socket. |
45 // This class is created on the render thread and destroyed on the IO | 87 // This class is created on the render thread and destroyed on the IO |
46 // thread. All methods are accessible only on the IO thread. | 88 // thread. All methods are accessible only on the IO thread. |
47 class CastSessionDelegate { | 89 class CastSessionDelegate { |
48 public: | 90 public: |
49 typedef base::Callback<void(const scoped_refptr< | 91 typedef base::Callback<void(const scoped_refptr< |
50 media::cast::AudioFrameInput>&)> AudioFrameInputAvailableCallback; | 92 media::cast::AudioFrameInput>&)> AudioFrameInputAvailableCallback; |
51 typedef base::Callback<void(const scoped_refptr< | 93 typedef base::Callback<void(const scoped_refptr< |
52 media::cast::VideoFrameInput>&)> VideoFrameInputAvailableCallback; | 94 media::cast::VideoFrameInput>&)> VideoFrameInputAvailableCallback; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 void LogRawEvents(const std::vector<media::cast::PacketEvent>& packet_events); | 141 void LogRawEvents(const std::vector<media::cast::PacketEvent>& packet_events); |
100 | 142 |
101 base::ThreadChecker thread_checker_; | 143 base::ThreadChecker thread_checker_; |
102 scoped_refptr<media::cast::CastEnvironment> cast_environment_; | 144 scoped_refptr<media::cast::CastEnvironment> cast_environment_; |
103 scoped_ptr<media::cast::CastSender> cast_sender_; | 145 scoped_ptr<media::cast::CastSender> cast_sender_; |
104 scoped_ptr<media::cast::transport::CastTransportSender> cast_transport_; | 146 scoped_ptr<media::cast::transport::CastTransportSender> cast_transport_; |
105 | 147 |
106 AudioFrameInputAvailableCallback audio_frame_input_available_callback_; | 148 AudioFrameInputAvailableCallback audio_frame_input_available_callback_; |
107 VideoFrameInputAvailableCallback video_frame_input_available_callback_; | 149 VideoFrameInputAvailableCallback video_frame_input_available_callback_; |
108 | 150 |
109 scoped_ptr<media::cast::EncodingEventSubscriber> audio_event_subscriber_; | 151 scoped_ptr<RawEventSubscriberBundle> event_subscribers_; |
110 scoped_ptr<media::cast::EncodingEventSubscriber> video_event_subscriber_; | |
111 | |
112 scoped_ptr<media::cast::StatsEventSubscriber> audio_stats_subscriber_; | |
113 scoped_ptr<media::cast::StatsEventSubscriber> video_stats_subscriber_; | |
114 | 152 |
115 // Proxy to the IO message loop. | 153 // Proxy to the IO message loop. |
116 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; | 154 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; |
117 base::WeakPtrFactory<CastSessionDelegate> weak_factory_; | 155 base::WeakPtrFactory<CastSessionDelegate> weak_factory_; |
118 | 156 |
119 DISALLOW_COPY_AND_ASSIGN(CastSessionDelegate); | 157 DISALLOW_COPY_AND_ASSIGN(CastSessionDelegate); |
120 }; | 158 }; |
121 | 159 |
122 #endif // CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_ | 160 #endif // CHROME_RENDERER_MEDIA_CAST_SESSION_DELEGATE_H_ |
OLD | NEW |