1 // Copyright (C) 2019 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/VpxPingInfoParser.h"
19 
20 #include <stddef.h>
21 #include <vector>
22 
23 namespace android {
24 namespace emulation {
25 
26 // this is an interface for platform specific implementations
27 // such as libvpx, CUVID, etc
28 class MediaVpxDecoderPlugin {
29 public:
30     using InitContextParam = VpxPingInfoParser::InitContextParam;
31     using DecodeFrameParam = VpxPingInfoParser::DecodeFrameParam;
32     using GetImageParam = VpxPingInfoParser::GetImageParam;
33 
34     virtual void initVpxContext(void* ptr) = 0;
35     virtual void destroyVpxContext(void* ptr) = 0;
36     virtual void decodeFrame(void* ptr) = 0;
37     virtual void flush(void* ptr) = 0;
38     virtual void getImage(void* ptr) = 0;
39     virtual void sendMetadata(void* ptr) = 0;
40 
save(base::Stream * stream)41     virtual void save(base::Stream* stream) const {};
load(base::Stream * stream)42     virtual bool load(base::Stream* stream) { return true; };
43 
44     MediaVpxDecoderPlugin() = default;
45     virtual ~MediaVpxDecoderPlugin() = default;
46 
47     // solely for snapshot save load purpose
48     enum {
49         PLUGIN_TYPE_NONE = 0,
50         PLUGIN_TYPE_LIBVPX = 1,
51         PLUGIN_TYPE_CUVID = 2,
52         PLUGIN_TYPE_FFMPEG = 3,
53         PLUGIN_TYPE_GENERIC = 4,
54     };
55 
56     // this is required by save/load
type()57     virtual int type() const { return PLUGIN_TYPE_NONE; }
vpxtype()58     virtual int vpxtype() const { return 8; }
version()59     virtual int version() const { return 200; }
60 
61 public:
62 };
63 
64 }  // namespace emulation
65 }  // namespace android
66