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/MediaCodec.h" 19 20 #include <stddef.h> 21 22 namespace android { 23 namespace emulation { 24 25 class MediaH264Decoder : public MediaCodec { 26 public: 27 // Platform dependent 28 static MediaH264Decoder* create(); 29 virtual ~MediaH264Decoder() = 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 = -3, // Can happen when receiving a new set of SPS/PPS frames 41 NALUIgnored = -4, // Can happen if we receive picture data w/o the SPS/PPS NALUs. 42 }; 43 44 // For snapshots 45 virtual void save(base::Stream* stream) const = 0; 46 virtual bool load(base::Stream* stream) = 0; 47 protected: 48 MediaH264Decoder() = default; 49 }; 50 51 } // namespace emulation 52 } // namespace android 53