OLD | NEW |
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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #if defined(OS_NACL) | 10 #if defined(OS_NACL) |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 431 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
432 data->SetInteger("width", size.width()); | 432 data->SetInteger("width", size.width()); |
433 data->SetInteger("height", size.height()); | 433 data->SetInteger("height", size.height()); |
434 if (dpi.x()) | 434 if (dpi.x()) |
435 data->SetInteger("x_dpi", dpi.x()); | 435 data->SetInteger("x_dpi", dpi.x()); |
436 if (dpi.y()) | 436 if (dpi.y()) |
437 data->SetInteger("y_dpi", dpi.y()); | 437 data->SetInteger("y_dpi", dpi.y()); |
438 PostLegacyJsonMessage("onDesktopSize", data.Pass()); | 438 PostLegacyJsonMessage("onDesktopSize", data.Pass()); |
439 } | 439 } |
440 | 440 |
441 void ChromotingInstance::OnVideoShape(const webrtc::DesktopRegion& shape) { | 441 void ChromotingInstance::OnVideoShape(const webrtc::DesktopRegion* shape) { |
442 if (desktop_shape_ && shape.Equals(*desktop_shape_)) | 442 if ((shape && desktop_shape_ && shape->Equals(*desktop_shape_)) || |
| 443 (!shape && !desktop_shape_)) { |
443 return; | 444 return; |
444 | |
445 desktop_shape_.reset(new webrtc::DesktopRegion(shape)); | |
446 | |
447 scoped_ptr<base::ListValue> rects_value(new base::ListValue()); | |
448 for (webrtc::DesktopRegion::Iterator i(shape); !i.IsAtEnd(); i.Advance()) { | |
449 const webrtc::DesktopRect& rect = i.rect(); | |
450 scoped_ptr<base::ListValue> rect_value(new base::ListValue()); | |
451 rect_value->AppendInteger(rect.left()); | |
452 rect_value->AppendInteger(rect.top()); | |
453 rect_value->AppendInteger(rect.width()); | |
454 rect_value->AppendInteger(rect.height()); | |
455 rects_value->Append(rect_value.release()); | |
456 } | 445 } |
457 | 446 |
458 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 447 scoped_ptr<base::DictionaryValue> shape_message(new base::DictionaryValue()); |
459 data->Set("rects", rects_value.release()); | 448 if (shape) { |
460 PostLegacyJsonMessage("onDesktopShape", data.Pass()); | 449 desktop_shape_ = make_scoped_ptr(new webrtc::DesktopRegion(*shape)); |
| 450 scoped_ptr<base::ListValue> rects_value(new base::ListValue()); |
| 451 for (webrtc::DesktopRegion::Iterator i(*shape); !i.IsAtEnd(); i.Advance()) { |
| 452 const webrtc::DesktopRect& rect = i.rect(); |
| 453 scoped_ptr<base::ListValue> rect_value(new base::ListValue()); |
| 454 rect_value->AppendInteger(rect.left()); |
| 455 rect_value->AppendInteger(rect.top()); |
| 456 rect_value->AppendInteger(rect.width()); |
| 457 rect_value->AppendInteger(rect.height()); |
| 458 rects_value->Append(rect_value.release()); |
| 459 } |
| 460 shape_message->Set("rects", rects_value.release()); |
| 461 } |
| 462 |
| 463 PostLegacyJsonMessage("onDesktopShape", shape_message.Pass()); |
461 } | 464 } |
462 | 465 |
463 void ChromotingInstance::OnVideoFrameDirtyRegion( | 466 void ChromotingInstance::OnVideoFrameDirtyRegion( |
464 const webrtc::DesktopRegion& dirty_region) { | 467 const webrtc::DesktopRegion& dirty_region) { |
465 scoped_ptr<base::ListValue> rects_value(new base::ListValue()); | 468 scoped_ptr<base::ListValue> rects_value(new base::ListValue()); |
466 for (webrtc::DesktopRegion::Iterator i(dirty_region); !i.IsAtEnd(); | 469 for (webrtc::DesktopRegion::Iterator i(dirty_region); !i.IsAtEnd(); |
467 i.Advance()) { | 470 i.Advance()) { |
468 const webrtc::DesktopRect& rect = i.rect(); | 471 const webrtc::DesktopRect& rect = i.rect(); |
469 scoped_ptr<base::ListValue> rect_value(new base::ListValue()); | 472 scoped_ptr<base::ListValue> rect_value(new base::ListValue()); |
470 rect_value->AppendInteger(rect.left()); | 473 rect_value->AppendInteger(rect.left()); |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 | 1232 |
1230 #if !defined(OS_NACL) | 1233 #if !defined(OS_NACL) |
1231 // Log messages are forwarded to the webapp only in PNaCl version of the | 1234 // Log messages are forwarded to the webapp only in PNaCl version of the |
1232 // plugin, so ProcessLogToUI() needs to be called explicitly in the non-PNaCl | 1235 // plugin, so ProcessLogToUI() needs to be called explicitly in the non-PNaCl |
1233 // version. | 1236 // version. |
1234 ProcessLogToUI(message); | 1237 ProcessLogToUI(message); |
1235 #endif // !defined(OS_NACL) | 1238 #endif // !defined(OS_NACL) |
1236 } | 1239 } |
1237 | 1240 |
1238 } // namespace remoting | 1241 } // namespace remoting |
OLD | NEW |