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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 414 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
415 data->SetInteger("width", size.width()); | 415 data->SetInteger("width", size.width()); |
416 data->SetInteger("height", size.height()); | 416 data->SetInteger("height", size.height()); |
417 if (dpi.x()) | 417 if (dpi.x()) |
418 data->SetInteger("x_dpi", dpi.x()); | 418 data->SetInteger("x_dpi", dpi.x()); |
419 if (dpi.y()) | 419 if (dpi.y()) |
420 data->SetInteger("y_dpi", dpi.y()); | 420 data->SetInteger("y_dpi", dpi.y()); |
421 PostLegacyJsonMessage("onDesktopSize", data.Pass()); | 421 PostLegacyJsonMessage("onDesktopSize", data.Pass()); |
422 } | 422 } |
423 | 423 |
424 void ChromotingInstance::OnVideoShape(const webrtc::DesktopRegion& shape) { | 424 void ChromotingInstance::OnVideoShape(const webrtc::DesktopRegion* shape) { |
425 if (desktop_shape_ && shape.Equals(*desktop_shape_)) | 425 if ((shape && desktop_shape_ && shape->Equals(*desktop_shape_)) || |
| 426 (!shape && !desktop_shape_)) { |
426 return; | 427 return; |
427 | |
428 desktop_shape_.reset(new webrtc::DesktopRegion(shape)); | |
429 | |
430 scoped_ptr<base::ListValue> rects_value(new base::ListValue()); | |
431 for (webrtc::DesktopRegion::Iterator i(shape); !i.IsAtEnd(); i.Advance()) { | |
432 const webrtc::DesktopRect& rect = i.rect(); | |
433 scoped_ptr<base::ListValue> rect_value(new base::ListValue()); | |
434 rect_value->AppendInteger(rect.left()); | |
435 rect_value->AppendInteger(rect.top()); | |
436 rect_value->AppendInteger(rect.width()); | |
437 rect_value->AppendInteger(rect.height()); | |
438 rects_value->Append(rect_value.release()); | |
439 } | 428 } |
440 | 429 |
441 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 430 scoped_ptr<base::DictionaryValue> shape_message(new base::DictionaryValue()); |
442 data->Set("rects", rects_value.release()); | 431 if (shape) { |
443 PostLegacyJsonMessage("onDesktopShape", data.Pass()); | 432 desktop_shape_ = make_scoped_ptr(new webrtc::DesktopRegion(*shape)); |
| 433 scoped_ptr<base::ListValue> rects_value(new base::ListValue()); |
| 434 for (webrtc::DesktopRegion::Iterator i(*shape); !i.IsAtEnd(); i.Advance()) { |
| 435 const webrtc::DesktopRect& rect = i.rect(); |
| 436 scoped_ptr<base::ListValue> rect_value(new base::ListValue()); |
| 437 rect_value->AppendInteger(rect.left()); |
| 438 rect_value->AppendInteger(rect.top()); |
| 439 rect_value->AppendInteger(rect.width()); |
| 440 rect_value->AppendInteger(rect.height()); |
| 441 rects_value->Append(rect_value.release()); |
| 442 } |
| 443 shape_message->Set("rects", rects_value.release()); |
| 444 } |
| 445 |
| 446 PostLegacyJsonMessage("onDesktopShape", shape_message.Pass()); |
444 } | 447 } |
445 | 448 |
446 void ChromotingInstance::OnVideoFrameDirtyRegion( | 449 void ChromotingInstance::OnVideoFrameDirtyRegion( |
447 const webrtc::DesktopRegion& dirty_region) { | 450 const webrtc::DesktopRegion& dirty_region) { |
448 scoped_ptr<base::ListValue> rects_value(new base::ListValue()); | 451 scoped_ptr<base::ListValue> rects_value(new base::ListValue()); |
449 for (webrtc::DesktopRegion::Iterator i(dirty_region); !i.IsAtEnd(); | 452 for (webrtc::DesktopRegion::Iterator i(dirty_region); !i.IsAtEnd(); |
450 i.Advance()) { | 453 i.Advance()) { |
451 const webrtc::DesktopRect& rect = i.rect(); | 454 const webrtc::DesktopRect& rect = i.rect(); |
452 scoped_ptr<base::ListValue> rect_value(new base::ListValue()); | 455 scoped_ptr<base::ListValue> rect_value(new base::ListValue()); |
453 rect_value->AppendInteger(rect.left()); | 456 rect_value->AppendInteger(rect.left()); |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 | 1199 |
1197 #if !defined(OS_NACL) | 1200 #if !defined(OS_NACL) |
1198 // Log messages are forwarded to the webapp only in PNaCl version of the | 1201 // Log messages are forwarded to the webapp only in PNaCl version of the |
1199 // plugin, so ProcessLogToUI() needs to be called explicitly in the non-PNaCl | 1202 // plugin, so ProcessLogToUI() needs to be called explicitly in the non-PNaCl |
1200 // version. | 1203 // version. |
1201 ProcessLogToUI(message); | 1204 ProcessLogToUI(message); |
1202 #endif // !defined(OS_NACL) | 1205 #endif // !defined(OS_NACL) |
1203 } | 1206 } |
1204 | 1207 |
1205 } // namespace remoting | 1208 } // namespace remoting |
OLD | NEW |