Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: media/cast/cast_sender_impl.cc

Issue 314593002: [Cast] Cleanup: Remove TransportXXXXXSender, an unnecessary layer of indirection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix CastTransportHostFilterTest.SimpleMessages. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/cast/cast.gyp ('k') | media/cast/transport/cast_transport_config.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "media/base/video_frame.h" 10 #include "media/base/video_frame.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 CHECK(cast_environment); 90 CHECK(cast_environment);
91 } 91 }
92 92
93 void CastSenderImpl::InitializeAudio( 93 void CastSenderImpl::InitializeAudio(
94 const AudioSenderConfig& audio_config, 94 const AudioSenderConfig& audio_config,
95 const CastInitializationCallback& cast_initialization_cb) { 95 const CastInitializationCallback& cast_initialization_cb) {
96 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 96 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
97 CHECK(audio_config.use_external_encoder || 97 CHECK(audio_config.use_external_encoder ||
98 cast_environment_->HasAudioThread()); 98 cast_environment_->HasAudioThread());
99 99
100 VLOG(1) << "CastSenderImpl@" << this << "::InitializeAudio()";
101
100 audio_sender_.reset( 102 audio_sender_.reset(
101 new AudioSender(cast_environment_, audio_config, transport_sender_)); 103 new AudioSender(cast_environment_, audio_config, transport_sender_));
102 104
103 CastInitializationStatus status = audio_sender_->InitializationResult(); 105 const CastInitializationStatus status = audio_sender_->InitializationResult();
104
105 if (status == STATUS_AUDIO_INITIALIZED) { 106 if (status == STATUS_AUDIO_INITIALIZED) {
106 ssrc_of_audio_sender_ = audio_config.incoming_feedback_ssrc; 107 ssrc_of_audio_sender_ = audio_config.incoming_feedback_ssrc;
107 audio_frame_input_ = 108 audio_frame_input_ =
108 new LocalAudioFrameInput(cast_environment_, audio_sender_->AsWeakPtr()); 109 new LocalAudioFrameInput(cast_environment_, audio_sender_->AsWeakPtr());
109 } 110 }
110 cast_initialization_cb.Run(status); 111 cast_initialization_cb.Run(status);
111 } 112 }
112 113
113 void CastSenderImpl::InitializeVideo( 114 void CastSenderImpl::InitializeVideo(
114 const VideoSenderConfig& video_config, 115 const VideoSenderConfig& video_config,
115 const CastInitializationCallback& cast_initialization_cb, 116 const CastInitializationCallback& cast_initialization_cb,
116 const CreateVideoEncodeAcceleratorCallback& create_vea_cb, 117 const CreateVideoEncodeAcceleratorCallback& create_vea_cb,
117 const CreateVideoEncodeMemoryCallback& create_video_encode_mem_cb) { 118 const CreateVideoEncodeMemoryCallback& create_video_encode_mem_cb) {
118 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 119 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
119 CHECK(video_config.use_external_encoder || 120 CHECK(video_config.use_external_encoder ||
120 cast_environment_->HasVideoThread()); 121 cast_environment_->HasVideoThread());
121 VLOG(1) << "CastSender::ctor"; 122
123 VLOG(1) << "CastSenderImpl@" << this << "::InitializeVideo()";
122 124
123 video_sender_.reset(new VideoSender(cast_environment_, 125 video_sender_.reset(new VideoSender(cast_environment_,
124 video_config, 126 video_config,
125 create_vea_cb, 127 create_vea_cb,
126 create_video_encode_mem_cb, 128 create_video_encode_mem_cb,
127 cast_initialization_cb,
128 transport_sender_)); 129 transport_sender_));
129 130
130 ssrc_of_video_sender_ = video_config.incoming_feedback_ssrc; 131 const CastInitializationStatus status = video_sender_->InitializationResult();
131 video_frame_input_ = 132 if (status == STATUS_VIDEO_INITIALIZED) {
132 new LocalVideoFrameInput(cast_environment_, video_sender_->AsWeakPtr()); 133 ssrc_of_video_sender_ = video_config.incoming_feedback_ssrc;
134 video_frame_input_ =
135 new LocalVideoFrameInput(cast_environment_, video_sender_->AsWeakPtr());
136 }
137 cast_initialization_cb.Run(status);
133 } 138 }
134 139
135 CastSenderImpl::~CastSenderImpl() { 140 CastSenderImpl::~CastSenderImpl() {
136 VLOG(1) << "CastSender::dtor"; 141 VLOG(1) << "CastSenderImpl@" << this << "::~CastSenderImpl()";
137 } 142 }
138 143
139 // ReceivedPacket handle the incoming packets to the cast sender 144 // ReceivedPacket handle the incoming packets to the cast sender
140 // it's only expected to receive RTCP feedback packets from the remote cast 145 // it's only expected to receive RTCP feedback packets from the remote cast
141 // receiver. The class verifies that that it is a RTCP packet and based on the 146 // receiver. The class verifies that that it is a RTCP packet and based on the
142 // SSRC of the incoming packet route the packet to the correct sender; audio or 147 // SSRC of the incoming packet route the packet to the correct sender; audio or
143 // video. 148 // video.
144 // 149 //
145 // Definition of SSRC as defined in RFC 3550. 150 // Definition of SSRC as defined in RFC 3550.
146 // Synchronization source (SSRC): The source of a stream of RTP 151 // Synchronization source (SSRC): The source of a stream of RTP
(...skipping 12 matching lines...) Expand all
159 // multimedia session; the binding of the SSRC identifiers is 164 // multimedia session; the binding of the SSRC identifiers is
160 // provided through RTCP (see Section 6.5.1). If a participant 165 // provided through RTCP (see Section 6.5.1). If a participant
161 // generates multiple streams in one RTP session, for example from 166 // generates multiple streams in one RTP session, for example from
162 // separate video cameras, each MUST be identified as a different 167 // separate video cameras, each MUST be identified as a different
163 // SSRC. 168 // SSRC.
164 void CastSenderImpl::ReceivedPacket(scoped_ptr<Packet> packet) { 169 void CastSenderImpl::ReceivedPacket(scoped_ptr<Packet> packet) {
165 DCHECK(cast_environment_); 170 DCHECK(cast_environment_);
166 size_t length = packet->size(); 171 size_t length = packet->size();
167 const uint8_t* data = &packet->front(); 172 const uint8_t* data = &packet->front();
168 if (!Rtcp::IsRtcpPacket(data, length)) { 173 if (!Rtcp::IsRtcpPacket(data, length)) {
169 // We should have no incoming RTP packets. 174 VLOG(1) << "CastSenderImpl@" << this << "::ReceivedPacket() -- "
170 VLOG(1) << "Unexpectedly received a RTP packet in the cast sender"; 175 << "Received an invalid (non-RTCP?) packet in the cast sender.";
171 return; 176 return;
172 } 177 }
173 uint32 ssrc_of_sender = Rtcp::GetSsrcOfSender(data, length); 178 uint32 ssrc_of_sender = Rtcp::GetSsrcOfSender(data, length);
174 if (ssrc_of_sender == ssrc_of_audio_sender_) { 179 if (ssrc_of_sender == ssrc_of_audio_sender_) {
175 if (!audio_sender_) { 180 if (!audio_sender_) {
176 NOTREACHED(); 181 NOTREACHED();
177 return; 182 return;
178 } 183 }
179 cast_environment_->PostTask(CastEnvironment::MAIN, 184 cast_environment_->PostTask(CastEnvironment::MAIN,
180 FROM_HERE, 185 FROM_HERE,
181 base::Bind(&AudioSender::IncomingRtcpPacket, 186 base::Bind(&AudioSender::IncomingRtcpPacket,
182 audio_sender_->AsWeakPtr(), 187 audio_sender_->AsWeakPtr(),
183 base::Passed(&packet))); 188 base::Passed(&packet)));
184 } else if (ssrc_of_sender == ssrc_of_video_sender_) { 189 } else if (ssrc_of_sender == ssrc_of_video_sender_) {
185 if (!video_sender_) { 190 if (!video_sender_) {
186 NOTREACHED(); 191 NOTREACHED();
187 return; 192 return;
188 } 193 }
189 cast_environment_->PostTask(CastEnvironment::MAIN, 194 cast_environment_->PostTask(CastEnvironment::MAIN,
190 FROM_HERE, 195 FROM_HERE,
191 base::Bind(&VideoSender::IncomingRtcpPacket, 196 base::Bind(&VideoSender::IncomingRtcpPacket,
192 video_sender_->AsWeakPtr(), 197 video_sender_->AsWeakPtr(),
193 base::Passed(&packet))); 198 base::Passed(&packet)));
194 } else { 199 } else {
195 VLOG(1) << "Received a RTCP packet with a non matching sender SSRC " 200 VLOG(1) << "CastSenderImpl@" << this << "::ReceivedPacket() -- "
201 << "Received a RTCP packet with a non matching sender SSRC "
196 << ssrc_of_sender; 202 << ssrc_of_sender;
197 } 203 }
198 } 204 }
199 205
200 scoped_refptr<AudioFrameInput> CastSenderImpl::audio_frame_input() { 206 scoped_refptr<AudioFrameInput> CastSenderImpl::audio_frame_input() {
201 return audio_frame_input_; 207 return audio_frame_input_;
202 } 208 }
203 209
204 scoped_refptr<VideoFrameInput> CastSenderImpl::video_frame_input() { 210 scoped_refptr<VideoFrameInput> CastSenderImpl::video_frame_input() {
205 return video_frame_input_; 211 return video_frame_input_;
206 } 212 }
207 213
208 transport::PacketReceiverCallback CastSenderImpl::packet_receiver() { 214 transport::PacketReceiverCallback CastSenderImpl::packet_receiver() {
209 return base::Bind(&CastSenderImpl::ReceivedPacket, 215 return base::Bind(&CastSenderImpl::ReceivedPacket,
210 weak_factory_.GetWeakPtr()); 216 weak_factory_.GetWeakPtr());
211 } 217 }
212 218
213 } // namespace cast 219 } // namespace cast
214 } // namespace media 220 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/cast.gyp ('k') | media/cast/transport/cast_transport_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698