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

Side by Side Diff: chrome/renderer/media/cast_session_delegate.cc

Issue 555563003: Cast: Flow hw encoder initialization error to extensions API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 6 years, 3 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
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 4
5 #include "chrome/renderer/media/cast_session_delegate.h" 5 #include "chrome/renderer/media/cast_session_delegate.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "chrome/common/chrome_version_info.h" 10 #include "chrome/common/chrome_version_info.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 if (!cast_transport_ || !cast_sender_) { 49 if (!cast_transport_ || !cast_sender_) {
50 error_callback.Run("Destination not set."); 50 error_callback.Run("Destination not set.");
51 return; 51 return;
52 } 52 }
53 53
54 audio_frame_input_available_callback_ = callback; 54 audio_frame_input_available_callback_ = callback;
55 cast_sender_->InitializeAudio( 55 cast_sender_->InitializeAudio(
56 config, 56 config,
57 base::Bind(&CastSessionDelegate::InitializationResultCB, 57 base::Bind(&CastSessionDelegate::InitializationResultCB,
58 weak_factory_.GetWeakPtr())); 58 weak_factory_.GetWeakPtr(), error_callback));
59 } 59 }
60 60
61 void CastSessionDelegate::StartVideo( 61 void CastSessionDelegate::StartVideo(
62 const VideoSenderConfig& config, 62 const VideoSenderConfig& config,
63 const VideoFrameInputAvailableCallback& callback, 63 const VideoFrameInputAvailableCallback& callback,
64 const ErrorCallback& error_callback, 64 const ErrorCallback& error_callback,
65 const media::cast::CreateVideoEncodeAcceleratorCallback& create_vea_cb, 65 const media::cast::CreateVideoEncodeAcceleratorCallback& create_vea_cb,
66 const media::cast::CreateVideoEncodeMemoryCallback& 66 const media::cast::CreateVideoEncodeMemoryCallback&
67 create_video_encode_mem_cb) { 67 create_video_encode_mem_cb) {
68 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); 68 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());
69 69
70 if (!cast_transport_ || !cast_sender_) { 70 if (!cast_transport_ || !cast_sender_) {
71 error_callback.Run("Destination not set."); 71 error_callback.Run("Destination not set.");
72 return; 72 return;
73 } 73 }
74 74
75 video_frame_input_available_callback_ = callback; 75 video_frame_input_available_callback_ = callback;
76 76
77 cast_sender_->InitializeVideo( 77 cast_sender_->InitializeVideo(
78 config, 78 config,
79 base::Bind(&CastSessionDelegate::InitializationResultCB, 79 base::Bind(&CastSessionDelegate::InitializationResultCB,
80 weak_factory_.GetWeakPtr()), 80 weak_factory_.GetWeakPtr(), error_callback),
81 create_vea_cb, 81 create_vea_cb,
82 create_video_encode_mem_cb); 82 create_video_encode_mem_cb);
83 } 83 }
84 84
85 void CastSessionDelegate::StartUDP(const net::IPEndPoint& remote_endpoint) { 85 void CastSessionDelegate::StartUDP(const net::IPEndPoint& remote_endpoint) {
86 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); 86 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());
87 87
88 // CastSender uses the renderer's IO thread as the main thread. This reduces 88 // CastSender uses the renderer's IO thread as the main thread. This reduces
89 // thread hopping for incoming video frames and outgoing network packets. 89 // thread hopping for incoming video frames and outgoing network packets.
90 cast_environment_ = new CastEnvironment( 90 cast_environment_ = new CastEnvironment(
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 callback.Run(stats.Pass()); 196 callback.Run(stats.Pass());
197 } 197 }
198 198
199 void CastSessionDelegate::StatusNotificationCB( 199 void CastSessionDelegate::StatusNotificationCB(
200 media::cast::CastTransportStatus unused_status) { 200 media::cast::CastTransportStatus unused_status) {
201 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); 201 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());
202 // TODO(hubbe): Call javascript UDPTransport error function. 202 // TODO(hubbe): Call javascript UDPTransport error function.
203 } 203 }
204 204
205 void CastSessionDelegate::InitializationResultCB( 205 void CastSessionDelegate::InitializationResultCB(
206 const ErrorCallback& error_callback,
206 media::cast::CastInitializationStatus result) const { 207 media::cast::CastInitializationStatus result) const {
207 DCHECK(cast_sender_); 208 DCHECK(cast_sender_);
208 209
209 // TODO(pwestin): handle the error codes.
210 if (result == media::cast::STATUS_AUDIO_INITIALIZED) { 210 if (result == media::cast::STATUS_AUDIO_INITIALIZED) {
hubbe 2014/09/09 19:11:03 Make this part of the switch() ?
Alpha Left Google 2014/09/09 19:41:18 Done.
211 audio_frame_input_available_callback_.Run( 211 audio_frame_input_available_callback_.Run(
212 cast_sender_->audio_frame_input()); 212 cast_sender_->audio_frame_input());
213 } else if (result == media::cast::STATUS_VIDEO_INITIALIZED) { 213 } else if (result == media::cast::STATUS_VIDEO_INITIALIZED) {
214 video_frame_input_available_callback_.Run( 214 video_frame_input_available_callback_.Run(
215 cast_sender_->video_frame_input()); 215 cast_sender_->video_frame_input());
216 } else if (result > media::cast::STATUS_VIDEO_INITIALIZED) {
217 switch (status) {
218 case media::cast::STATUS_INVALID_CAST_ENVIRONMENT:
219 error_callback.Run("Invalid cast environment.");
hubbe 2014/09/09 19:11:03 break?
Alpha Left Google 2014/09/09 19:41:17 Whooooops. Done.
220 case media::cast::STATUS_INVALID_CRYPTO_CONFIGURATION:
221 error_callback.Run("Invalid encryption keys.");
hubbe 2014/09/09 19:11:03 break?
222 case media::cast::STATUS_UNSUPPORTED_AUDIO_CODEC:
223 error_callback.Run("Audio codec not supported.");
hubbe 2014/09/09 19:11:03 break?
224 case media::cast::STATUS_UNSUPPORTED_VIDEO_CODEC:
225 error_callback.Run("Video codec not supported.");
hubbe 2014/09/09 19:11:03 break?
226 case media::cast::STATUS_INVALID_AUDIO_CONFIGURATION:
227 error_callback.Run("Invalid audio configuration.");
hubbe 2014/09/09 19:11:03 break?
228 case media::cast::STATUS_INVALID_VIDEO_CONFIGURATION:
229 error_callback.Run("Invalid video configuration.");
hubbe 2014/09/09 19:11:03 break?
230 case media::cast::STATUS_HW_VIDEO_ENCODER_NOT_SUPPORTED:
231 error_callback.Run("Hardware video encoder not supported.");
hubbe 2014/09/09 19:11:03 break?
232 case media::cast::STATUS_AUDIO_UNINITIALIZED:
233 case media::cast::STATUS_VIDEO_UNINITIALIZED:
234 case media::cast::STATUS_AUDIO_INITIALIZED:
235 case media::cast::STATUS_VIDEO_INITIALIZED:
236 NOTREACHED() << "Not an error.";
237 }
216 } 238 }
217 } 239 }
218 240
219 void CastSessionDelegate::LogRawEvents( 241 void CastSessionDelegate::LogRawEvents(
220 const std::vector<media::cast::PacketEvent>& packet_events, 242 const std::vector<media::cast::PacketEvent>& packet_events,
221 const std::vector<media::cast::FrameEvent>& frame_events) { 243 const std::vector<media::cast::FrameEvent>& frame_events) {
222 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread()); 244 DCHECK(io_message_loop_proxy_->BelongsToCurrentThread());
223 245
224 for (std::vector<media::cast::PacketEvent>::const_iterator it = 246 for (std::vector<media::cast::PacketEvent>::const_iterator it =
225 packet_events.begin(); 247 packet_events.begin();
(...skipping 23 matching lines...) Expand all
249 } else { 271 } else {
250 cast_environment_->Logging()->InsertFrameEvent( 272 cast_environment_->Logging()->InsertFrameEvent(
251 it->timestamp, 273 it->timestamp,
252 it->type, 274 it->type,
253 it->media_type, 275 it->media_type,
254 it->rtp_timestamp, 276 it->rtp_timestamp,
255 it->frame_id); 277 it->frame_id);
256 } 278 }
257 } 279 }
258 } 280 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698