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 #include "media/cast/cast_sender_impl.h" | 4 #include "media/cast/cast_sender_impl.h" |
5 | 5 |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 | 10 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 } | 48 } |
49 | 49 |
50 virtual void InsertCodedAudioFrame(const EncodedAudioFrame* audio_frame, | 50 virtual void InsertCodedAudioFrame(const EncodedAudioFrame* audio_frame, |
51 const base::TimeTicks& recorded_time, | 51 const base::TimeTicks& recorded_time, |
52 const base::Closure callback) OVERRIDE { | 52 const base::Closure callback) OVERRIDE { |
53 cast_thread_->PostTask(CastThread::MAIN, FROM_HERE, | 53 cast_thread_->PostTask(CastThread::MAIN, FROM_HERE, |
54 base::Bind(&AudioSender::InsertCodedAudioFrame, audio_sender_, | 54 base::Bind(&AudioSender::InsertCodedAudioFrame, audio_sender_, |
55 audio_frame, recorded_time, callback)); | 55 audio_frame, recorded_time, callback)); |
56 } | 56 } |
57 | 57 |
58 protected: | |
59 virtual ~LocalFrameInput() {} | |
60 | |
61 private: | 58 private: |
62 friend class base::RefCountedThreadSafe<LocalFrameInput>; | |
63 | |
64 scoped_refptr<CastThread> cast_thread_; | 59 scoped_refptr<CastThread> cast_thread_; |
65 base::WeakPtr<AudioSender> audio_sender_; | 60 base::WeakPtr<AudioSender> audio_sender_; |
66 base::WeakPtr<VideoSender> video_sender_; | 61 base::WeakPtr<VideoSender> video_sender_; |
67 }; | 62 }; |
68 | 63 |
69 // LocalCastSenderPacketReceiver handle the incoming packets to the cast sender | 64 // LocalCastSenderPacketReceiver handle the incoming packets to the cast sender |
70 // it's only expected to receive RTCP feedback packets from the remote cast | 65 // it's only expected to receive RTCP feedback packets from the remote cast |
71 // receiver. The class verifies that that it is a RTCP packet and based on the | 66 // receiver. The class verifies that that it is a RTCP packet and based on the |
72 // SSRC of the incoming packet route the packet to the correct sender; audio or | 67 // SSRC of the incoming packet route the packet to the correct sender; audio or |
73 // video. | 68 // video. |
(...skipping 24 matching lines...) Expand all Loading... |
98 base::WeakPtr<AudioSender> audio_sender, | 93 base::WeakPtr<AudioSender> audio_sender, |
99 base::WeakPtr<VideoSender> video_sender, | 94 base::WeakPtr<VideoSender> video_sender, |
100 uint32 ssrc_of_audio_sender, | 95 uint32 ssrc_of_audio_sender, |
101 uint32 ssrc_of_video_sender) | 96 uint32 ssrc_of_video_sender) |
102 : cast_thread_(cast_thread), | 97 : cast_thread_(cast_thread), |
103 audio_sender_(audio_sender), | 98 audio_sender_(audio_sender), |
104 video_sender_(video_sender), | 99 video_sender_(video_sender), |
105 ssrc_of_audio_sender_(ssrc_of_audio_sender), | 100 ssrc_of_audio_sender_(ssrc_of_audio_sender), |
106 ssrc_of_video_sender_(ssrc_of_video_sender) {} | 101 ssrc_of_video_sender_(ssrc_of_video_sender) {} |
107 | 102 |
| 103 virtual ~LocalCastSenderPacketReceiver() {} |
| 104 |
108 virtual void ReceivedPacket(const uint8* packet, | 105 virtual void ReceivedPacket(const uint8* packet, |
109 int length, | 106 int length, |
110 const base::Closure callback) OVERRIDE { | 107 const base::Closure callback) OVERRIDE { |
111 if (!Rtcp::IsRtcpPacket(packet, length)) { | 108 if (!Rtcp::IsRtcpPacket(packet, length)) { |
112 // We should have no incoming RTP packets. | 109 // We should have no incoming RTP packets. |
113 // No action; just log and call the callback informing that we are done | 110 // No action; just log and call the callback informing that we are done |
114 // with the packet. | 111 // with the packet. |
115 VLOG(1) << "Unexpectedly received a RTP packet in the cast sender"; | 112 VLOG(1) << "Unexpectedly received a RTP packet in the cast sender"; |
116 cast_thread_->PostTask(CastThread::MAIN, FROM_HERE, callback); | 113 cast_thread_->PostTask(CastThread::MAIN, FROM_HERE, callback); |
117 return; | 114 return; |
(...skipping 10 matching lines...) Expand all Loading... |
128 } else { | 125 } else { |
129 // No action; just log and call the callback informing that we are done | 126 // No action; just log and call the callback informing that we are done |
130 // with the packet. | 127 // with the packet. |
131 VLOG(1) << "Received a RTCP packet with a non matching sender SSRC " | 128 VLOG(1) << "Received a RTCP packet with a non matching sender SSRC " |
132 << ssrc_of_sender; | 129 << ssrc_of_sender; |
133 | 130 |
134 cast_thread_->PostTask(CastThread::MAIN, FROM_HERE, callback); | 131 cast_thread_->PostTask(CastThread::MAIN, FROM_HERE, callback); |
135 } | 132 } |
136 } | 133 } |
137 | 134 |
138 protected: | |
139 virtual ~LocalCastSenderPacketReceiver() {} | |
140 | |
141 private: | 135 private: |
142 friend class base::RefCountedThreadSafe<LocalCastSenderPacketReceiver>; | |
143 | |
144 scoped_refptr<CastThread> cast_thread_; | 136 scoped_refptr<CastThread> cast_thread_; |
145 base::WeakPtr<AudioSender> audio_sender_; | 137 base::WeakPtr<AudioSender> audio_sender_; |
146 base::WeakPtr<VideoSender> video_sender_; | 138 base::WeakPtr<VideoSender> video_sender_; |
147 uint32 ssrc_of_audio_sender_; | 139 uint32 ssrc_of_audio_sender_; |
148 uint32 ssrc_of_video_sender_; | 140 uint32 ssrc_of_video_sender_; |
149 }; | 141 }; |
150 | 142 |
151 CastSender* CastSender::CreateCastSender( | 143 CastSender* CastSender::CreateCastSender( |
152 scoped_refptr<CastThread> cast_thread, | 144 scoped_refptr<CastThread> cast_thread, |
153 const AudioSenderConfig& audio_config, | 145 const AudioSenderConfig& audio_config, |
(...skipping 19 matching lines...) Expand all Loading... |
173 &pacer_), | 165 &pacer_), |
174 frame_input_(new LocalFrameInput(cast_thread, audio_sender_.AsWeakPtr(), | 166 frame_input_(new LocalFrameInput(cast_thread, audio_sender_.AsWeakPtr(), |
175 video_sender_.AsWeakPtr())), | 167 video_sender_.AsWeakPtr())), |
176 packet_receiver_(new LocalCastSenderPacketReceiver(cast_thread, | 168 packet_receiver_(new LocalCastSenderPacketReceiver(cast_thread, |
177 audio_sender_.AsWeakPtr(), video_sender_.AsWeakPtr(), | 169 audio_sender_.AsWeakPtr(), video_sender_.AsWeakPtr(), |
178 audio_config.incoming_feedback_ssrc, | 170 audio_config.incoming_feedback_ssrc, |
179 video_config.incoming_feedback_ssrc)) {} | 171 video_config.incoming_feedback_ssrc)) {} |
180 | 172 |
181 CastSenderImpl::~CastSenderImpl() {} | 173 CastSenderImpl::~CastSenderImpl() {} |
182 | 174 |
183 scoped_refptr<FrameInput> CastSenderImpl::frame_input() { | |
184 return frame_input_; | |
185 } | |
186 | |
187 scoped_refptr<PacketReceiver> CastSenderImpl::packet_receiver() { | |
188 return packet_receiver_; | |
189 } | |
190 | |
191 } // namespace cast | 175 } // namespace cast |
192 } // namespace media | 176 } // namespace media |
OLD | NEW |