1/* 2 * Copyright (c) 2022 Shenzhen Kaihong DID Co., Ltd. 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#ifndef CODEC_PACKET_READER_H 16#define CODEC_PACKET_READER_H 17#include <cinttypes> 18#include <fstream> 19#include <iostream> 20#include <memory> 21#include "command_parse.h" 22class CodecPacketReader { 23public: 24 using Ptr = std::shared_ptr<CodecPacketReader>; 25 CodecPacketReader() = default; 26 virtual ~CodecPacketReader() = default; 27 28 virtual bool ReadOnePacket(std::ifstream &ioIn, char *buf, uint32_t &filledCount) = 0; 29 30 static Ptr GetPacketReader(const CodecMime &mime); 31}; 32 33class CodecH264Reader : public CodecPacketReader { 34public: 35 using Ptr = std::shared_ptr<CodecPacketReader>; 36 CodecH264Reader(); 37 ~CodecH264Reader() = default; 38 39 bool ReadOnePacket(std::ifstream &ioIn, char *buf, uint32_t &filledCount) override; 40}; 41 42class CodecMpeg4Reader : public CodecPacketReader { 43public: 44 using Ptr = std::shared_ptr<CodecPacketReader>; 45 CodecMpeg4Reader(); 46 ~CodecMpeg4Reader() = default; 47 48 bool ReadOnePacket(std::ifstream &ioIn, char *buf, uint32_t &filledCount) override; 49}; 50 51class CodecVp9Reader : public CodecPacketReader { 52public: 53 using Ptr = std::shared_ptr<CodecVp9Reader>; 54 CodecVp9Reader(); 55 ~CodecVp9Reader() = default; 56 57 bool ReadOnePacket(std::ifstream &ioIn, char *buf, uint32_t &filledCount) override; 58}; 59#endif