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 | 4 |
5 #include "chrome/renderer/extensions/cast_streaming_native_handler.h" | 5 #include "chrome/renderer/extensions/cast_streaming_native_handler.h" |
6 | 6 |
7 #include <functional> | 7 #include <functional> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 args.GetIsolate()->ThrowException(v8::Exception::TypeError( | 317 args.GetIsolate()->ThrowException(v8::Exception::TypeError( |
318 v8::String::NewFromUtf8(args.GetIsolate(), kUnableToConvertArgs))); | 318 v8::String::NewFromUtf8(args.GetIsolate(), kUnableToConvertArgs))); |
319 return; | 319 return; |
320 } | 320 } |
321 scoped_ptr<UdpParams> udp_params = UdpParams::FromValue(*udp_params_value); | 321 scoped_ptr<UdpParams> udp_params = UdpParams::FromValue(*udp_params_value); |
322 if (!udp_params) { | 322 if (!udp_params) { |
323 args.GetIsolate()->ThrowException(v8::Exception::TypeError( | 323 args.GetIsolate()->ThrowException(v8::Exception::TypeError( |
324 v8::String::NewFromUtf8(args.GetIsolate(), kInvalidUdpParams))); | 324 v8::String::NewFromUtf8(args.GetIsolate(), kInvalidUdpParams))); |
325 return; | 325 return; |
326 } | 326 } |
327 transport->Start(net::HostPortPair(udp_params->address, udp_params->port)); | 327 net::IPAddressNumber ip; |
| 328 if (!net::ParseIPLiteralToNumber(udp_params->address, &ip)) { |
| 329 args.GetIsolate()->ThrowException(v8::Exception::TypeError( |
| 330 v8::String::NewFromUtf8(args.GetIsolate(), kInvalidUdpParams))); |
| 331 return; |
| 332 } |
| 333 transport->Start(net::IPEndPoint(ip, udp_params->port)); |
328 } | 334 } |
329 | 335 |
330 CastRtpStream* CastStreamingNativeHandler::GetRtpStreamOrThrow( | 336 CastRtpStream* CastStreamingNativeHandler::GetRtpStreamOrThrow( |
331 int transport_id) const { | 337 int transport_id) const { |
332 RtpStreamMap::const_iterator iter = rtp_stream_map_.find( | 338 RtpStreamMap::const_iterator iter = rtp_stream_map_.find( |
333 transport_id); | 339 transport_id); |
334 if (iter != rtp_stream_map_.end()) | 340 if (iter != rtp_stream_map_.end()) |
335 return iter->second.get(); | 341 return iter->second.get(); |
336 v8::Isolate* isolate = context()->v8_context()->GetIsolate(); | 342 v8::Isolate* isolate = context()->v8_context()->GetIsolate(); |
337 isolate->ThrowException(v8::Exception::RangeError(v8::String::NewFromUtf8( | 343 isolate->ThrowException(v8::Exception::RangeError(v8::String::NewFromUtf8( |
338 isolate, kRtpStreamNotFound))); | 344 isolate, kRtpStreamNotFound))); |
339 return NULL; | 345 return NULL; |
340 } | 346 } |
341 | 347 |
342 CastUdpTransport* CastStreamingNativeHandler::GetUdpTransportOrThrow( | 348 CastUdpTransport* CastStreamingNativeHandler::GetUdpTransportOrThrow( |
343 int transport_id) const { | 349 int transport_id) const { |
344 UdpTransportMap::const_iterator iter = udp_transport_map_.find( | 350 UdpTransportMap::const_iterator iter = udp_transport_map_.find( |
345 transport_id); | 351 transport_id); |
346 if (iter != udp_transport_map_.end()) | 352 if (iter != udp_transport_map_.end()) |
347 return iter->second.get(); | 353 return iter->second.get(); |
348 v8::Isolate* isolate = context()->v8_context()->GetIsolate(); | 354 v8::Isolate* isolate = context()->v8_context()->GetIsolate(); |
349 isolate->ThrowException(v8::Exception::RangeError( | 355 isolate->ThrowException(v8::Exception::RangeError( |
350 v8::String::NewFromUtf8(isolate, kUdpTransportNotFound))); | 356 v8::String::NewFromUtf8(isolate, kUdpTransportNotFound))); |
351 return NULL; | 357 return NULL; |
352 } | 358 } |
353 | 359 |
354 } // namespace extensions | 360 } // namespace extensions |
OLD | NEW |