1 // Copyright (C) 2022 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include "host-common/GoldfishMediaDefs.h"
18 #include "host-common/MediaCodec.h"
19 
20 #include <stddef.h>
21 
22 namespace android {
23 namespace emulation {
24 
25 class MediaHevcDecoder : public MediaCodec {
26 public:
27     // Platform dependent
28     static MediaHevcDecoder* create();
29     virtual ~MediaHevcDecoder() = default;
30 
31     enum class PixelFormat : uint8_t {
32         YUV420P = 0,
33         UYVY422 = 1,
34         BGRA8888 = 2,
35     };
36     enum class Err : int {
37         NoErr = 0,
38         NoDecodedFrame = -1,
39         InitContextFailed = -2,
40         DecoderRestarted =
41                 -3,  // Can happen when receiving a new set of SPS/PPS frames
42         NALUIgnored = -4,  // Can happen if we receive picture data w/o the
43                            // SPS/PPS NALUs.
44     };
45 
46     // For snapshots
47     virtual void save(base::Stream* stream) const = 0;
48     virtual bool load(base::Stream* stream) = 0;
49 
50 protected:
51     MediaHevcDecoder() = default;
52 };
53 
54 }  // namespace emulation
55 }  // namespace android
56