rcheck.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2014 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.
  4. #ifndef MEDIA_FORMATS_MP4_RCHECK_H_
  5. #define MEDIA_FORMATS_MP4_RCHECK_H_
  6. #include "base/logging.h"
  7. #include "media/base/media_log.h"
  8. // Evaluate |condition| once. If the result is false, log |msg| to |media_log|,
  9. // and (early) return false from the containing function.
  10. #define RCHECK_MEDIA_LOGGED(condition, media_log, msg) \
  11. do { \
  12. if (!(condition)) { \
  13. DLOG(ERROR) << "Failure while parsing MP4: " #condition; \
  14. MEDIA_LOG(ERROR, media_log) << "Failure parsing MP4: " << (msg); \
  15. return false; \
  16. } \
  17. } while (0)
  18. // Evaluate |condition| once. If the result is false, (early) return false from
  19. // the containing function.
  20. // TODO(wolenetz,chcunningham): Where appropriate, replace usage of this macro
  21. // in favor of RCHECK_MEDIA_LOGGED. See https://crbug.com/487410.
  22. #define RCHECK(condition) \
  23. do { \
  24. if (!(condition)) { \
  25. DLOG(ERROR) << "Failure while parsing MP4: " #condition; \
  26. return false; \
  27. } \
  28. } while (0)
  29. #endif // MEDIA_FORMATS_MP4_RCHECK_H_