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