1 /* 2 * Copyright (C) 2023 Huawei Device 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 16 #ifndef INNER_DEMUXER_DEMO_H 17 #define INNER_DEMUXER_DEMO_H 18 19 #include <iostream> 20 #include "avdemuxer.h" 21 22 namespace OHOS { 23 namespace MediaAVCodec { 24 class InnerDemuxerDemo { 25 public: 26 InnerDemuxerDemo(); 27 ~InnerDemuxerDemo(); 28 int32_t CreateWithSource(std::shared_ptr<AVSource> source); 29 void Destroy(); 30 int32_t SelectTrackByID(uint32_t trackIndex); 31 int32_t UnselectTrackByID(uint32_t trackIndex); 32 int32_t PrintInfo(int32_t tracks); 33 int32_t ReadAllSamples(std::shared_ptr<AVSharedMemory> mem, int32_t tracks); 34 int32_t ReadSample(uint32_t trackIndex, std::shared_ptr<AVSharedMemory> mem, 35 AVCodecBufferInfo &bufInfo, uint32_t &bufferFlag); 36 int32_t SeekToTime(int64_t millisecond, Media::SeekMode mode); 37 bool isEOS(std::map<uint32_t, bool>& countFlag); 38 AVCodecBufferInfo sampleInfo; 39 std::map<int32_t, int64_t> frames_; 40 std::map<int32_t, int64_t> key_frames_; 41 private: 42 std::shared_ptr<AVSource> avsource_ = nullptr; 43 std::shared_ptr<AVDemuxer> demuxer_ = nullptr; 44 std::shared_ptr<OHOS::MediaAVCodec::AVSharedMemory> sharedMemory_ = nullptr; 45 Format source_format_; 46 Format track_format_; 47 }; 48 } 49 } 50 #endif 51