summaryrefslogtreecommitdiff
path: root/chromium/media/base/decode_status.h
blob: d17d8573f711c37cfed8af870b7d5df9938dfdf2 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MEDIA_BASE_DECODE_STATUS_H_
#define MEDIA_BASE_DECODE_STATUS_H_

#include <iosfwd>

#include "media/base/decoder_buffer.h"
#include "media/base/media_export.h"
#include "media/base/status_codes.h"

namespace media {

class Status;

// TODO(crbug.com/1129662): This is temporary, to allow DecodeStatus::OK to
// work, while we replace DecodeStatus with actual status codes.
using DecodeStatus = StatusCode;

MEDIA_EXPORT const char* GetDecodeStatusString(DecodeStatus status);

// Helper class for ensuring that Decode() traces are properly unique and closed
// if the Decode is aborted via a WeakPtr invalidation. We use the |this|
// pointer of the ScopedDecodeTrace object itself as the id. Since the callback
// owns the class it's guaranteed to be unique.
class MEDIA_EXPORT ScopedDecodeTrace {
 public:
  // Returns true if tracing is enabled for the media category. If false,
  // clients should avoid creating ScopedDecodeTrace objects.
  static bool IsEnabled();

  // Begins an asynchronous trace with the given name and properties. Providing
  // the DecoderBuffer itself yields the most information in the trace.
  ScopedDecodeTrace(const char* trace_name, const DecoderBuffer& buffer);
  ScopedDecodeTrace(const char* trace_name,
                    bool is_key_frame,
                    base::TimeDelta timestamp);
  ~ScopedDecodeTrace();

  // Completes the Decode() trace with the given status.
  void EndTrace(const Status& status);

 private:
  const char* trace_name_;
  bool closed_ = false;

  DISALLOW_COPY_AND_ASSIGN(ScopedDecodeTrace);
};

}  // namespace media

#endif  // MEDIA_BASE_DECODE_STATUS_H_