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_TEST_IN_PROCESS_RECEIVER_H_ | 5 #ifndef MEDIA_CAST_TEST_IN_PROCESS_RECEIVER_H_ |
6 #define MEDIA_CAST_TEST_IN_PROCESS_RECEIVER_H_ | 6 #define MEDIA_CAST_TEST_IN_PROCESS_RECEIVER_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 public: | 42 public: |
43 // Construct a receiver with the given configuration. |remote_end_point| can | 43 // Construct a receiver with the given configuration. |remote_end_point| can |
44 // be left empty, if the transport should automatically mate with the first | 44 // be left empty, if the transport should automatically mate with the first |
45 // remote sender it encounters. | 45 // remote sender it encounters. |
46 InProcessReceiver(const scoped_refptr<CastEnvironment>& cast_environment, | 46 InProcessReceiver(const scoped_refptr<CastEnvironment>& cast_environment, |
47 const net::IPEndPoint& local_end_point, | 47 const net::IPEndPoint& local_end_point, |
48 const net::IPEndPoint& remote_end_point, | 48 const net::IPEndPoint& remote_end_point, |
49 const AudioReceiverConfig& audio_config, | 49 const AudioReceiverConfig& audio_config, |
50 const VideoReceiverConfig& video_config); | 50 const VideoReceiverConfig& video_config); |
51 | 51 |
52 // Must be destroyed on the cast MAIN thread. See DestroySoon(). | |
53 virtual ~InProcessReceiver(); | 52 virtual ~InProcessReceiver(); |
54 | 53 |
55 // Convenience accessors. | 54 // Convenience accessors. |
56 scoped_refptr<CastEnvironment> cast_env() const { return cast_environment_; } | 55 scoped_refptr<CastEnvironment> cast_env() const { return cast_environment_; } |
57 const AudioReceiverConfig& audio_config() const { return audio_config_; } | 56 const AudioReceiverConfig& audio_config() const { return audio_config_; } |
58 const VideoReceiverConfig& video_config() const { return video_config_; } | 57 const VideoReceiverConfig& video_config() const { return video_config_; } |
59 | 58 |
60 // Begin delivering any received audio/video frames to the OnXXXFrame() | 59 // Begin delivering any received audio/video frames to the OnXXXFrame() |
61 // methods. | 60 // methods. |
62 void Start(); | 61 virtual void Start(); |
63 | |
64 // Schedules destruction on the cast MAIN thread. Any external references to | |
65 // the InProcessReceiver instance become invalid. | |
66 // Deprecated: Use Stop instead. | |
67 // TODO(hubbe): Remove this function and change callers to use Stop. | |
68 void DestroySoon(); | |
69 | 62 |
70 // Destroy the sub-compontents of this class. | 63 // Destroy the sub-compontents of this class. |
71 // After this call, it is safe to destroy this object on any thread. | 64 // After this call, it is safe to destroy this object on any thread. |
72 void Stop(); | 65 virtual void Stop(); |
73 | 66 |
74 protected: | 67 protected: |
75 // To be implemented by subclasses. These are called on the Cast MAIN thread | 68 // To be implemented by subclasses. These are called on the Cast MAIN thread |
76 // as each frame is received. | 69 // as each frame is received. |
77 virtual void OnAudioFrame(scoped_ptr<AudioBus> audio_frame, | 70 virtual void OnAudioFrame(scoped_ptr<AudioBus> audio_frame, |
78 const base::TimeTicks& playout_time, | 71 const base::TimeTicks& playout_time, |
79 bool is_continuous) = 0; | 72 bool is_continuous) = 0; |
80 virtual void OnVideoFrame(const scoped_refptr<VideoFrame>& video_frame, | 73 virtual void OnVideoFrame(const scoped_refptr<VideoFrame>& video_frame, |
81 const base::TimeTicks& playout_time, | 74 const base::TimeTicks& playout_time, |
82 bool is_continuous) = 0; | 75 bool is_continuous) = 0; |
(...skipping 19 matching lines...) Expand all Loading... |
102 // argument description and semantics. | 95 // argument description and semantics. |
103 void GotAudioFrame(scoped_ptr<AudioBus> audio_frame, | 96 void GotAudioFrame(scoped_ptr<AudioBus> audio_frame, |
104 const base::TimeTicks& playout_time, | 97 const base::TimeTicks& playout_time, |
105 bool is_continuous); | 98 bool is_continuous); |
106 void GotVideoFrame(const scoped_refptr<VideoFrame>& video_frame, | 99 void GotVideoFrame(const scoped_refptr<VideoFrame>& video_frame, |
107 const base::TimeTicks& playout_time, | 100 const base::TimeTicks& playout_time, |
108 bool is_continuous); | 101 bool is_continuous); |
109 void PullNextAudioFrame(); | 102 void PullNextAudioFrame(); |
110 void PullNextVideoFrame(); | 103 void PullNextVideoFrame(); |
111 | 104 |
112 // Invoked just before the destruction of |receiver| on the cast MAIN thread. | |
113 static void WillDestroyReceiver(InProcessReceiver* receiver); | |
114 | |
115 const scoped_refptr<CastEnvironment> cast_environment_; | 105 const scoped_refptr<CastEnvironment> cast_environment_; |
116 const net::IPEndPoint local_end_point_; | 106 const net::IPEndPoint local_end_point_; |
117 const net::IPEndPoint remote_end_point_; | 107 const net::IPEndPoint remote_end_point_; |
118 const AudioReceiverConfig audio_config_; | 108 const AudioReceiverConfig audio_config_; |
119 const VideoReceiverConfig video_config_; | 109 const VideoReceiverConfig video_config_; |
120 | 110 |
121 scoped_ptr<transport::UdpTransport> transport_; | 111 scoped_ptr<transport::UdpTransport> transport_; |
122 scoped_ptr<CastReceiver> cast_receiver_; | 112 scoped_ptr<CastReceiver> cast_receiver_; |
123 | 113 |
124 // NOTE: Weak pointers must be invalidated before all other member variables. | 114 // NOTE: Weak pointers must be invalidated before all other member variables. |
125 base::WeakPtrFactory<InProcessReceiver> weak_factory_; | 115 base::WeakPtrFactory<InProcessReceiver> weak_factory_; |
126 | 116 |
127 DISALLOW_COPY_AND_ASSIGN(InProcessReceiver); | 117 DISALLOW_COPY_AND_ASSIGN(InProcessReceiver); |
128 }; | 118 }; |
129 | 119 |
130 } // namespace cast | 120 } // namespace cast |
131 } // namespace media | 121 } // namespace media |
132 | 122 |
133 #endif // MEDIA_CAST_TEST_IN_PROCESS_RECEIVER_H_ | 123 #endif // MEDIA_CAST_TEST_IN_PROCESS_RECEIVER_H_ |
OLD | NEW |