protobuf_utils.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef MODULES_AUDIO_PROCESSING_TEST_PROTOBUF_UTILS_H_
  11. #define MODULES_AUDIO_PROCESSING_TEST_PROTOBUF_UTILS_H_
  12. #include <memory>
  13. #include <sstream> // no-presubmit-check TODO(webrtc:8982)
  14. #include "rtc_base/ignore_wundef.h"
  15. #include "rtc_base/protobuf_utils.h"
  16. RTC_PUSH_IGNORING_WUNDEF()
  17. #include "modules/audio_processing/debug.pb.h"
  18. RTC_POP_IGNORING_WUNDEF()
  19. namespace webrtc {
  20. // Allocates new memory in the unique_ptr to fit the raw message and returns the
  21. // number of bytes read.
  22. size_t ReadMessageBytesFromFile(FILE* file, std::unique_ptr<uint8_t[]>* bytes);
  23. // Returns true on success, false on error or end-of-file.
  24. bool ReadMessageFromFile(FILE* file, MessageLite* msg);
  25. // Returns true on success, false on error or end of string stream.
  26. bool ReadMessageFromString(
  27. std::stringstream* input, // no-presubmit-check TODO(webrtc:8982)
  28. MessageLite* msg);
  29. } // namespace webrtc
  30. #endif // MODULES_AUDIO_PROCESSING_TEST_PROTOBUF_UTILS_H_