| 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/base/util.h" | 5 #include "remoting/base/util.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "media/base/video_frame.h" | 12 #include "media/base/video_frame.h" |
| 13 #include "media/base/yuv_convert.h" | 13 #include "media/base/yuv_convert.h" |
| 14 #include "third_party/libyuv/include/libyuv/convert.h" | 14 #include "third_party/libyuv/include/libyuv/convert.h" |
| 15 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" | 15 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" |
| 16 | 16 |
| 17 #if defined(OS_POSIX) | |
| 18 #include <pwd.h> | |
| 19 #include <sys/types.h> | |
| 20 #include <unistd.h> | |
| 21 #endif // defined(OS_POSIX) | |
| 22 | |
| 23 using media::VideoFrame; | 17 using media::VideoFrame; |
| 24 | 18 |
| 25 namespace remoting { | 19 namespace remoting { |
| 26 | 20 |
| 27 enum { kBytesPerPixelRGB32 = 4 }; | 21 enum { kBytesPerPixelRGB32 = 4 }; |
| 28 | 22 |
| 29 // Do not write LOG messages in this routine since it is called from within | 23 // Do not write LOG messages in this routine since it is called from within |
| 30 // our LOG message handler. Bad things will happen. | 24 // our LOG message handler. Bad things will happen. |
| 31 std::string GetTimestampString() { | 25 std::string GetTimestampString() { |
| 32 base::Time t = base::Time::NowFromSystemTime(); | 26 base::Time t = base::Time::NowFromSystemTime(); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 return false; | 300 return false; |
| 307 } | 301 } |
| 308 | 302 |
| 309 ++ptr; | 303 ++ptr; |
| 310 } | 304 } |
| 311 } | 305 } |
| 312 | 306 |
| 313 return true; | 307 return true; |
| 314 } | 308 } |
| 315 | 309 |
| 316 std::string GetUsername() { | |
| 317 #if defined(OS_ANDROID) | |
| 318 struct passwd* passwd = getpwuid(getuid()); | |
| 319 return passwd ? passwd->pw_name : std::string(); | |
| 320 #elif defined(OS_POSIX) | |
| 321 long buf_size = sysconf(_SC_GETPW_R_SIZE_MAX); | |
| 322 if (buf_size <= 0) | |
| 323 return std::string(); | |
| 324 | |
| 325 scoped_ptr<char[]> buf(new char[buf_size]); | |
| 326 struct passwd passwd; | |
| 327 struct passwd* passwd_result = NULL; | |
| 328 getpwuid_r(getuid(), &passwd, buf.get(), buf_size, &passwd_result); | |
| 329 return passwd_result ? passwd_result->pw_name : std::string(); | |
| 330 #else // !defined(OS_POSIX) | |
| 331 return std::string(); | |
| 332 #endif // defined(OS_POSIX) | |
| 333 } | |
| 334 | |
| 335 bool DoesRectContain(const webrtc::DesktopRect& a, | 310 bool DoesRectContain(const webrtc::DesktopRect& a, |
| 336 const webrtc::DesktopRect& b) { | 311 const webrtc::DesktopRect& b) { |
| 337 webrtc::DesktopRect intersection(a); | 312 webrtc::DesktopRect intersection(a); |
| 338 intersection.IntersectWith(b); | 313 intersection.IntersectWith(b); |
| 339 return intersection.equals(b); | 314 return intersection.equals(b); |
| 340 } | 315 } |
| 341 | 316 |
| 342 } // namespace remoting | 317 } // namespace remoting |
| OLD | NEW |