summaryrefslogtreecommitdiff
path: root/chromium/media/formats/mp4/parse_result.h
blob: 714ebd9a864046ca0af9e2513ed1214e6e9a6b8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_FORMATS_MP4_PARSE_RESULT_H_
#define MEDIA_FORMATS_MP4_PARSE_RESULT_H_

namespace media {
namespace mp4 {

enum class ParseResult {
  kOk,            // Parsing was successful.
  kError,         // The data is invalid (usually unrecoverable).
  kNeedMoreData,  // More data is required to parse successfully.
};

// Evaluate |expr| once. If the result is not ParseResult::kOk, (early) return
// it from the containing function.
#define RCHECK_OK_PARSE_RESULT(expr)                      \
  do {                                                    \
    ::media::mp4::ParseResult result = (expr);            \
    if (result == ::media::mp4::ParseResult::kError)      \
      DLOG(ERROR) << "Failure while parsing MP4: " #expr; \
    if (result != ::media::mp4::ParseResult::kOk)         \
      return result;                                      \
  } while (0)

}  // namespace mp4
}  // namespace media

#endif  // MEDIA_FORMATS_MP4_PARSE_RESULT_H_