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

Side by Side Diff: remoting/client/plugin/chromoting_instance.cc

Issue 136763009: Add VideoProcessor interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | « remoting/client/plugin/chromoting_instance.h ('k') | remoting/client/plugin/pepper_view.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "remoting/client/plugin/chromoting_instance.h" 5 #include "remoting/client/plugin/chromoting_instance.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 21 matching lines...) Expand all
32 #include "remoting/base/util.h" 32 #include "remoting/base/util.h"
33 #include "remoting/client/chromoting_client.h" 33 #include "remoting/client/chromoting_client.h"
34 #include "remoting/client/client_config.h" 34 #include "remoting/client/client_config.h"
35 #include "remoting/client/frame_consumer_proxy.h" 35 #include "remoting/client/frame_consumer_proxy.h"
36 #include "remoting/client/plugin/delegating_signal_strategy.h" 36 #include "remoting/client/plugin/delegating_signal_strategy.h"
37 #include "remoting/client/plugin/pepper_audio_player.h" 37 #include "remoting/client/plugin/pepper_audio_player.h"
38 #include "remoting/client/plugin/pepper_input_handler.h" 38 #include "remoting/client/plugin/pepper_input_handler.h"
39 #include "remoting/client/plugin/pepper_port_allocator.h" 39 #include "remoting/client/plugin/pepper_port_allocator.h"
40 #include "remoting/client/plugin/pepper_token_fetcher.h" 40 #include "remoting/client/plugin/pepper_token_fetcher.h"
41 #include "remoting/client/plugin/pepper_view.h" 41 #include "remoting/client/plugin/pepper_view.h"
42 #include "remoting/client/rectangle_update_decoder.h" 42 #include "remoting/client/software_video_renderer.h"
43 #include "remoting/protocol/connection_to_host.h" 43 #include "remoting/protocol/connection_to_host.h"
44 #include "remoting/protocol/host_stub.h" 44 #include "remoting/protocol/host_stub.h"
45 #include "remoting/protocol/libjingle_transport_factory.h" 45 #include "remoting/protocol/libjingle_transport_factory.h"
46 #include "third_party/libjingle/source/talk/base/helpers.h" 46 #include "third_party/libjingle/source/talk/base/helpers.h"
47 #include "url/gurl.h" 47 #include "url/gurl.h"
48 48
49 // Windows defines 'PostMessage', so we have to undef it. 49 // Windows defines 'PostMessage', so we have to undef it.
50 #if defined(PostMessage) 50 #if defined(PostMessage)
51 #undef PostMessage 51 #undef PostMessage
52 #endif 52 #endif
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 const std::string& local_jid) { 627 const std::string& local_jid) {
628 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); 628 DCHECK(plugin_task_runner_->BelongsToCurrentThread());
629 629
630 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); 630 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop();
631 631
632 632
633 view_.reset(new PepperView(this, &context_)); 633 view_.reset(new PepperView(this, &context_));
634 view_weak_factory_.reset( 634 view_weak_factory_.reset(
635 new base::WeakPtrFactory<FrameConsumer>(view_.get())); 635 new base::WeakPtrFactory<FrameConsumer>(view_.get()));
636 636
637 // RectangleUpdateDecoder runs on a separate thread so for now we wrap 637 // SoftwareVideoRenderer runs on a separate thread so for now we wrap
638 // PepperView with a ref-counted proxy object. 638 // PepperView with a ref-counted proxy object.
639 scoped_refptr<FrameConsumerProxy> consumer_proxy = 639 scoped_refptr<FrameConsumerProxy> consumer_proxy =
640 new FrameConsumerProxy(plugin_task_runner_, 640 new FrameConsumerProxy(plugin_task_runner_,
641 view_weak_factory_->GetWeakPtr()); 641 view_weak_factory_->GetWeakPtr());
642 642
643 SoftwareVideoRenderer* decoder =
644 new SoftwareVideoRenderer(context_.main_task_runner(),
645 context_.decode_task_runner(),
646 consumer_proxy);
647 view_->Initialize(decoder);
648 video_renderer_.reset(decoder);
649
643 host_connection_.reset(new protocol::ConnectionToHost(true)); 650 host_connection_.reset(new protocol::ConnectionToHost(true));
644 scoped_ptr<AudioPlayer> audio_player(new PepperAudioPlayer(this)); 651 scoped_ptr<AudioPlayer> audio_player(new PepperAudioPlayer(this));
645 client_.reset(new ChromotingClient(config, &context_, 652 client_.reset(new ChromotingClient(config, &context_, host_connection_.get(),
646 host_connection_.get(), this, 653 this, video_renderer_.get(),
647 consumer_proxy, audio_player.Pass())); 654 audio_player.Pass()));
648 655
649 view_->Initialize(client_->GetFrameProducer()); 656 if (!plugin_view_.is_null())
650
651 if (!plugin_view_.is_null()) {
652 view_->SetView(plugin_view_); 657 view_->SetView(plugin_view_);
653 }
654 658
655 // Connect the input pipeline to the protocol stub & initialize components. 659 // Connect the input pipeline to the protocol stub & initialize components.
656 mouse_input_filter_.set_input_stub(host_connection_->input_stub()); 660 mouse_input_filter_.set_input_stub(host_connection_->input_stub());
657 mouse_input_filter_.set_input_size(view_->get_view_size_dips()); 661 mouse_input_filter_.set_input_size(view_->get_view_size_dips());
658 662
659 VLOG(0) << "Connecting to " << config.host_jid 663 VLOG(0) << "Connecting to " << config.host_jid
660 << ". Local jid: " << local_jid << "."; 664 << ". Local jid: " << local_jid << ".";
661 665
662 // Setup the signal strategy. 666 // Setup the signal strategy.
663 signal_strategy_.reset(new DelegatingSignalStrategy( 667 signal_strategy_.reset(new DelegatingSignalStrategy(
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 message.set_type(type); 903 message.set_type(type);
900 message.set_data(message_data); 904 message.set_data(message_data);
901 host_connection_->host_stub()->DeliverClientMessage(message); 905 host_connection_->host_stub()->DeliverClientMessage(message);
902 } 906 }
903 907
904 void ChromotingInstance::HandleAllowMouseLockMessage() { 908 void ChromotingInstance::HandleAllowMouseLockMessage() {
905 input_handler_.AllowMouseLock(); 909 input_handler_.AllowMouseLock();
906 } 910 }
907 911
908 ChromotingStats* ChromotingInstance::GetStats() { 912 ChromotingStats* ChromotingInstance::GetStats() {
909 if (!client_.get()) 913 if (!video_renderer_.get())
910 return NULL; 914 return NULL;
911 return client_->GetStats(); 915 return video_renderer_->GetStats();
912 } 916 }
913 917
914 void ChromotingInstance::PostChromotingMessage( 918 void ChromotingInstance::PostChromotingMessage(
915 const std::string& method, 919 const std::string& method,
916 scoped_ptr<base::DictionaryValue> data) { 920 scoped_ptr<base::DictionaryValue> data) {
917 scoped_ptr<base::DictionaryValue> message(new base::DictionaryValue()); 921 scoped_ptr<base::DictionaryValue> message(new base::DictionaryValue());
918 message->SetString("method", method); 922 message->SetString("method", method);
919 message->Set("data", data.release()); 923 message->Set("data", data.release());
920 924
921 std::string message_json; 925 std::string message_json;
922 base::JSONWriter::Write(message.get(), &message_json); 926 base::JSONWriter::Write(message.get(), &message_json);
923 PostMessage(pp::Var(message_json)); 927 PostMessage(pp::Var(message_json));
924 } 928 }
925 929
926 void ChromotingInstance::SendTrappedKey(uint32 usb_keycode, bool pressed) { 930 void ChromotingInstance::SendTrappedKey(uint32 usb_keycode, bool pressed) {
927 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); 931 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
928 data->SetInteger("usbKeycode", usb_keycode); 932 data->SetInteger("usbKeycode", usb_keycode);
929 data->SetBoolean("pressed", pressed); 933 data->SetBoolean("pressed", pressed);
930 PostChromotingMessage("trappedKeyEvent", data.Pass()); 934 PostChromotingMessage("trappedKeyEvent", data.Pass());
931 } 935 }
932 936
933 void ChromotingInstance::SendOutgoingIq(const std::string& iq) { 937 void ChromotingInstance::SendOutgoingIq(const std::string& iq) {
934 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); 938 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
935 data->SetString("iq", iq); 939 data->SetString("iq", iq);
936 PostChromotingMessage("sendOutgoingIq", data.Pass()); 940 PostChromotingMessage("sendOutgoingIq", data.Pass());
937 } 941 }
938 942
939 void ChromotingInstance::SendPerfStats() { 943 void ChromotingInstance::SendPerfStats() {
940 if (!client_.get()) { 944 if (!video_renderer_.get()) {
941 return; 945 return;
942 } 946 }
943 947
944 plugin_task_runner_->PostDelayedTask( 948 plugin_task_runner_->PostDelayedTask(
945 FROM_HERE, base::Bind(&ChromotingInstance::SendPerfStats, 949 FROM_HERE, base::Bind(&ChromotingInstance::SendPerfStats,
946 weak_factory_.GetWeakPtr()), 950 weak_factory_.GetWeakPtr()),
947 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs)); 951 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs));
948 952
949 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); 953 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
950 ChromotingStats* stats = client_->GetStats(); 954 ChromotingStats* stats = video_renderer_->GetStats();
951 data->SetDouble("videoBandwidth", stats->video_bandwidth()->Rate()); 955 data->SetDouble("videoBandwidth", stats->video_bandwidth()->Rate());
952 data->SetDouble("videoFrameRate", stats->video_frame_rate()->Rate()); 956 data->SetDouble("videoFrameRate", stats->video_frame_rate()->Rate());
953 data->SetDouble("captureLatency", stats->video_capture_ms()->Average()); 957 data->SetDouble("captureLatency", stats->video_capture_ms()->Average());
954 data->SetDouble("encodeLatency", stats->video_encode_ms()->Average()); 958 data->SetDouble("encodeLatency", stats->video_encode_ms()->Average());
955 data->SetDouble("decodeLatency", stats->video_decode_ms()->Average()); 959 data->SetDouble("decodeLatency", stats->video_decode_ms()->Average());
956 data->SetDouble("renderLatency", stats->video_paint_ms()->Average()); 960 data->SetDouble("renderLatency", stats->video_paint_ms()->Average());
957 data->SetDouble("roundtripLatency", stats->round_trip_ms()->Average()); 961 data->SetDouble("roundtripLatency", stats->round_trip_ms()->Average());
958 PostChromotingMessage("onPerfStats", data.Pass()); 962 PostChromotingMessage("onPerfStats", data.Pass());
959 } 963 }
960 964
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 url_components.scheme.len); 1079 url_components.scheme.len);
1076 return url_scheme == kChromeExtensionUrlScheme; 1080 return url_scheme == kChromeExtensionUrlScheme;
1077 } 1081 }
1078 1082
1079 bool ChromotingInstance::IsConnected() { 1083 bool ChromotingInstance::IsConnected() {
1080 return host_connection_.get() && 1084 return host_connection_.get() &&
1081 (host_connection_->state() == protocol::ConnectionToHost::CONNECTED); 1085 (host_connection_->state() == protocol::ConnectionToHost::CONNECTED);
1082 } 1086 }
1083 1087
1084 } // namespace remoting 1088 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/plugin/chromoting_instance.h ('k') | remoting/client/plugin/pepper_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698