Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / remoting / base / util.h
blobd022a16b35ccaeab8251760412a41540fe826473
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
3 // found in the LICENSE file.
5 #ifndef REMOTING_BASE_UTIL_H_
6 #define REMOTING_BASE_UTIL_H_
8 #include <stdint.h>
9 #include <string>
11 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
13 namespace remoting {
15 // Return a string that contains the current date formatted as 'MMDD/HHMMSS:'.
16 std::string GetTimestampString();
18 int RoundToTwosMultiple(int x);
20 // Align the sides of the rectangle to multiples of 2 (expanding outwards).
21 webrtc::DesktopRect AlignRect(const webrtc::DesktopRect& rect);
23 // Copy content of a rectangle in a RGB32 image.
24 void CopyRGB32Rect(const uint8_t* source_buffer,
25 int source_stride,
26 const webrtc::DesktopRect& source_buffer_rect,
27 uint8_t* dest_buffer,
28 int dest_stride,
29 const webrtc::DesktopRect& dest_buffer_rect,
30 const webrtc::DesktopRect& dest_rect);
32 // Replaces every occurrence of "\n" in a string by "\r\n".
33 std::string ReplaceLfByCrLf(const std::string& in);
35 // Replaces every occurrence of "\r\n" in a string by "\n".
36 std::string ReplaceCrLfByLf(const std::string& in);
38 // Checks if the given string is a valid UTF-8 string.
39 bool StringIsUtf8(const char* data, size_t length);
41 bool DoesRectContain(const webrtc::DesktopRect& a,
42 const webrtc::DesktopRect& b);
44 } // namespace remoting
46 #endif // REMOTING_BASE_UTIL_H_