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 #include <iterator> | 8 #include <iterator> |
9 | 9 |
| 10 #include "base/location.h" |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 #include "base/message_loop/message_loop.h" | 12 #include "base/single_thread_task_runner.h" |
12 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/thread_task_runner_handle.h" |
13 #include "chrome/common/extensions/api/cast_streaming_receiver_session.h" | 15 #include "chrome/common/extensions/api/cast_streaming_receiver_session.h" |
14 #include "chrome/common/extensions/api/cast_streaming_rtp_stream.h" | 16 #include "chrome/common/extensions/api/cast_streaming_rtp_stream.h" |
15 #include "chrome/common/extensions/api/cast_streaming_udp_transport.h" | 17 #include "chrome/common/extensions/api/cast_streaming_udp_transport.h" |
16 #include "chrome/renderer/media/cast_receiver_session.h" | 18 #include "chrome/renderer/media/cast_receiver_session.h" |
17 #include "chrome/renderer/media/cast_rtp_stream.h" | 19 #include "chrome/renderer/media/cast_rtp_stream.h" |
18 #include "chrome/renderer/media/cast_session.h" | 20 #include "chrome/renderer/media/cast_session.h" |
19 #include "chrome/renderer/media/cast_udp_transport.h" | 21 #include "chrome/renderer/media/cast_udp_transport.h" |
20 #include "content/public/child/v8_value_converter.h" | 22 #include "content/public/child/v8_value_converter.h" |
21 #include "content/public/renderer/media_stream_api.h" | 23 #include "content/public/renderer/media_stream_api.h" |
22 #include "extensions/renderer/script_context.h" | 24 #include "extensions/renderer/script_context.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 } | 254 } |
253 stream2.reset(new CastRtpStream(track.component(), session)); | 255 stream2.reset(new CastRtpStream(track.component(), session)); |
254 } | 256 } |
255 scoped_ptr<CastUdpTransport> udp_transport( | 257 scoped_ptr<CastUdpTransport> udp_transport( |
256 new CastUdpTransport(session)); | 258 new CastUdpTransport(session)); |
257 | 259 |
258 // TODO(imcheng): Use a weak reference to ensure we don't call into an | 260 // TODO(imcheng): Use a weak reference to ensure we don't call into an |
259 // invalid context when the callback is invoked. | 261 // invalid context when the callback is invoked. |
260 create_callback_.Reset(isolate, args[2].As<v8::Function>()); | 262 create_callback_.Reset(isolate, args[2].As<v8::Function>()); |
261 | 263 |
262 base::MessageLoop::current()->PostTask( | 264 base::ThreadTaskRunnerHandle::Get()->PostTask( |
263 FROM_HERE, | 265 FROM_HERE, |
264 base::Bind( | 266 base::Bind(&CastStreamingNativeHandler::CallCreateCallback, |
265 &CastStreamingNativeHandler::CallCreateCallback, | 267 weak_factory_.GetWeakPtr(), base::Passed(&stream1), |
266 weak_factory_.GetWeakPtr(), | 268 base::Passed(&stream2), base::Passed(&udp_transport))); |
267 base::Passed(&stream1), | |
268 base::Passed(&stream2), | |
269 base::Passed(&udp_transport))); | |
270 } | 269 } |
271 | 270 |
272 void CastStreamingNativeHandler::CallCreateCallback( | 271 void CastStreamingNativeHandler::CallCreateCallback( |
273 scoped_ptr<CastRtpStream> stream1, | 272 scoped_ptr<CastRtpStream> stream1, |
274 scoped_ptr<CastRtpStream> stream2, | 273 scoped_ptr<CastRtpStream> stream2, |
275 scoped_ptr<CastUdpTransport> udp_transport) { | 274 scoped_ptr<CastUdpTransport> udp_transport) { |
276 v8::Isolate* isolate = context()->isolate(); | 275 v8::Isolate* isolate = context()->isolate(); |
277 v8::HandleScope handle_scope(isolate); | 276 v8::HandleScope handle_scope(isolate); |
278 v8::Context::Scope context_scope(context()->v8_context()); | 277 v8::Context::Scope context_scope(context()->v8_context()); |
279 | 278 |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 void CastStreamingNativeHandler::AddTracksToMediaStream( | 846 void CastStreamingNativeHandler::AddTracksToMediaStream( |
848 const std::string& url, | 847 const std::string& url, |
849 const media::AudioParameters& params, | 848 const media::AudioParameters& params, |
850 scoped_refptr<media::AudioCapturerSource> audio, | 849 scoped_refptr<media::AudioCapturerSource> audio, |
851 scoped_ptr<media::VideoCapturerSource> video) { | 850 scoped_ptr<media::VideoCapturerSource> video) { |
852 content::AddAudioTrackToMediaStream(audio, params, true, true, url); | 851 content::AddAudioTrackToMediaStream(audio, params, true, true, url); |
853 content::AddVideoTrackToMediaStream(video.Pass(), true, true, url); | 852 content::AddVideoTrackToMediaStream(video.Pass(), true, true, url); |
854 } | 853 } |
855 | 854 |
856 } // namespace extensions | 855 } // namespace extensions |
OLD | NEW |