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 save(base::Stream * stream)40 virtual void save(base::Stream* stream) const {}; load(base::Stream * stream)41 virtual bool load(base::Stream* stream) { return true; }; 42 43 MediaVpxDecoderPlugin() = default; 44 virtual ~MediaVpxDecoderPlugin() = default; 45 46 // solely for snapshot save load purpose 47 enum { 48 PLUGIN_TYPE_NONE = 0, 49 PLUGIN_TYPE_LIBVPX = 1, 50 PLUGIN_TYPE_CUVID = 2, 51 PLUGIN_TYPE_FFMPEG = 3, 52 PLUGIN_TYPE_GENERIC = 4, 53 }; 54 55 // this is required by save/load type()56 virtual int type() const { return PLUGIN_TYPE_NONE; } vpxtype()57 virtual int vpxtype() const { return 8; } version()58 virtual int version() const { return 200; } 59 60 public: 61 }; 62 63 } // namespace emulation 64 } // namespace android 65