| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| 11 #include <functional> | 11 #include <functional> |
| 12 #include <iterator> | 12 #include <iterator> |
| 13 #include <memory> | 13 #include <memory> |
| 14 #include <string> | 14 #include <string> |
| 15 #include <utility> | 15 #include <utility> |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "base/location.h" | 18 #include "base/location.h" |
| 19 #include "base/logging.h" | 19 #include "base/logging.h" |
| 20 #include "base/macros.h" | 20 #include "base/macros.h" |
| 21 #include "base/memory/ptr_util.h" | 21 #include "base/memory/ptr_util.h" |
| 22 #include "base/single_thread_task_runner.h" | 22 #include "base/single_thread_task_runner.h" |
| 23 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
| 24 #include "base/sys_info.h" | 24 #include "base/sys_info.h" |
| 25 #include "base/threading/thread_task_runner_handle.h" | 25 #include "base/threading/thread_task_runner_handle.h" |
| 26 #include "base/values.h" |
| 26 #include "chrome/common/extensions/api/cast_streaming_receiver_session.h" | 27 #include "chrome/common/extensions/api/cast_streaming_receiver_session.h" |
| 27 #include "chrome/common/extensions/api/cast_streaming_rtp_stream.h" | 28 #include "chrome/common/extensions/api/cast_streaming_rtp_stream.h" |
| 28 #include "chrome/common/extensions/api/cast_streaming_udp_transport.h" | 29 #include "chrome/common/extensions/api/cast_streaming_udp_transport.h" |
| 29 #include "chrome/renderer/media/cast_receiver_session.h" | 30 #include "chrome/renderer/media/cast_receiver_session.h" |
| 30 #include "chrome/renderer/media/cast_rtp_stream.h" | 31 #include "chrome/renderer/media/cast_rtp_stream.h" |
| 31 #include "chrome/renderer/media/cast_session.h" | 32 #include "chrome/renderer/media/cast_session.h" |
| 32 #include "chrome/renderer/media/cast_udp_transport.h" | 33 #include "chrome/renderer/media/cast_udp_transport.h" |
| 33 #include "content/public/child/v8_value_converter.h" | 34 #include "content/public/child/v8_value_converter.h" |
| 34 #include "content/public/renderer/media_stream_utils.h" | 35 #include "content/public/renderer/media_stream_utils.h" |
| 35 #include "extensions/common/extension.h" | 36 #include "extensions/common/extension.h" |
| (...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 std::make_pair(transport_id, std::move(callback))); | 689 std::make_pair(transport_id, std::move(callback))); |
| 689 | 690 |
| 690 transport->GetStats( | 691 transport->GetStats( |
| 691 base::Bind(&CastStreamingNativeHandler::CallGetStatsCallback, | 692 base::Bind(&CastStreamingNativeHandler::CallGetStatsCallback, |
| 692 weak_factory_.GetWeakPtr(), | 693 weak_factory_.GetWeakPtr(), |
| 693 transport_id)); | 694 transport_id)); |
| 694 } | 695 } |
| 695 | 696 |
| 696 void CastStreamingNativeHandler::CallGetRawEventsCallback( | 697 void CastStreamingNativeHandler::CallGetRawEventsCallback( |
| 697 int transport_id, | 698 int transport_id, |
| 698 std::unique_ptr<base::BinaryValue> raw_events) { | 699 std::unique_ptr<base::Value> raw_events) { |
| 699 v8::Isolate* isolate = context()->isolate(); | 700 v8::Isolate* isolate = context()->isolate(); |
| 700 v8::HandleScope handle_scope(isolate); | 701 v8::HandleScope handle_scope(isolate); |
| 701 v8::Context::Scope context_scope(context()->v8_context()); | 702 v8::Context::Scope context_scope(context()->v8_context()); |
| 702 | 703 |
| 703 RtpStreamCallbackMap::iterator it = | 704 RtpStreamCallbackMap::iterator it = |
| 704 get_raw_events_callbacks_.find(transport_id); | 705 get_raw_events_callbacks_.find(transport_id); |
| 705 if (it == get_raw_events_callbacks_.end()) | 706 if (it == get_raw_events_callbacks_.end()) |
| 706 return; | 707 return; |
| 707 std::unique_ptr<V8ValueConverter> converter(V8ValueConverter::create()); | 708 std::unique_ptr<V8ValueConverter> converter(V8ValueConverter::create()); |
| 708 v8::Local<v8::Value> callback_args[] = { | 709 v8::Local<v8::Value> callback_args[] = { |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 &web_stream)) { | 988 &web_stream)) { |
| 988 LOG(ERROR) << "Failed to add Cast audio track to media stream."; | 989 LOG(ERROR) << "Failed to add Cast audio track to media stream."; |
| 989 } | 990 } |
| 990 if (!content::AddVideoTrackToMediaStream(std::move(video), true, // is_remote | 991 if (!content::AddVideoTrackToMediaStream(std::move(video), true, // is_remote |
| 991 &web_stream)) { | 992 &web_stream)) { |
| 992 LOG(ERROR) << "Failed to add Cast video track to media stream."; | 993 LOG(ERROR) << "Failed to add Cast video track to media stream."; |
| 993 } | 994 } |
| 994 } | 995 } |
| 995 | 996 |
| 996 } // namespace extensions | 997 } // namespace extensions |
| OLD | NEW |