1da853ecaSopenharmony_ci/* 2da853ecaSopenharmony_ci * Copyright (C) 2023 Huawei Device Co., Ltd. 3da853ecaSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4da853ecaSopenharmony_ci * you may not use this file except in compliance with the License. 5da853ecaSopenharmony_ci * You may obtain a copy of the License at 6da853ecaSopenharmony_ci * 7da853ecaSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8da853ecaSopenharmony_ci * 9da853ecaSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10da853ecaSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11da853ecaSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12da853ecaSopenharmony_ci * See the License for the specific language governing permissions and 13da853ecaSopenharmony_ci * limitations under the License. 14da853ecaSopenharmony_ci */ 15da853ecaSopenharmony_ci 16da853ecaSopenharmony_ci#ifndef DEMUXER_MOCK_H 17da853ecaSopenharmony_ci#define DEMUXER_MOCK_H 18da853ecaSopenharmony_ci 19da853ecaSopenharmony_ci#include <cinttypes> 20da853ecaSopenharmony_ci#include <string> 21da853ecaSopenharmony_ci#include <memory> 22da853ecaSopenharmony_ci#include "nocopyable.h" 23da853ecaSopenharmony_ci#include "avformat_mock.h" 24da853ecaSopenharmony_ci#include "avsource_mock.h" 25da853ecaSopenharmony_ci#include "common_mock.h" 26da853ecaSopenharmony_ci#include "av_common.h" 27da853ecaSopenharmony_ci#include "avcodec_common.h" 28da853ecaSopenharmony_ci 29da853ecaSopenharmony_cinamespace OHOS { 30da853ecaSopenharmony_cinamespace MediaAVCodec { 31da853ecaSopenharmony_ciclass DemuxerMock : public NoCopyable { 32da853ecaSopenharmony_cipublic: 33da853ecaSopenharmony_ci virtual ~DemuxerMock() = default; 34da853ecaSopenharmony_ci 35da853ecaSopenharmony_ci virtual int32_t Destroy() = 0; 36da853ecaSopenharmony_ci virtual int32_t SelectTrackByID(uint32_t trackIndex) = 0; 37da853ecaSopenharmony_ci virtual int32_t UnselectTrackByID(uint32_t trackIndex) = 0; 38da853ecaSopenharmony_ci virtual int32_t ReadSample(uint32_t trackIndex, std::shared_ptr<AVMemoryMock> sample, 39da853ecaSopenharmony_ci AVCodecBufferInfo *bufferInfo, uint32_t &flag, bool checkBufferInfo = false) = 0; 40da853ecaSopenharmony_ci virtual int32_t SeekToTime(int64_t mSeconds, Media::SeekMode mode) = 0; 41da853ecaSopenharmony_ci virtual int32_t SetMediaKeySystemInfoCallback(bool isNull) 42da853ecaSopenharmony_ci { 43da853ecaSopenharmony_ci return AV_ERR_OK; 44da853ecaSopenharmony_ci } 45da853ecaSopenharmony_ci virtual int32_t SetDemuxerMediaKeySystemInfoCallback(bool isNull) 46da853ecaSopenharmony_ci { 47da853ecaSopenharmony_ci return AV_ERR_OK; 48da853ecaSopenharmony_ci } 49da853ecaSopenharmony_ci virtual int32_t GetMediaKeySystemInfo() 50da853ecaSopenharmony_ci { 51da853ecaSopenharmony_ci return AV_ERR_OK; 52da853ecaSopenharmony_ci } 53da853ecaSopenharmony_ci virtual int32_t GetIndexByRelativePresentationTimeUs(const uint32_t trackIndex, 54da853ecaSopenharmony_ci const uint64_t relativePresentationTimeUs, uint32_t &index) = 0; 55da853ecaSopenharmony_ci virtual int32_t GetRelativePresentationTimeUsByIndex(const uint32_t trackIndex, 56da853ecaSopenharmony_ci const uint32_t index, uint64_t &relativePresentationTimeUs) = 0; 57da853ecaSopenharmony_ci}; 58da853ecaSopenharmony_ci 59da853ecaSopenharmony_ciclass __attribute__((visibility("default"))) AVDemuxerMockFactory { 60da853ecaSopenharmony_cipublic: 61da853ecaSopenharmony_ci static std::shared_ptr<DemuxerMock> CreateDemuxer(std::shared_ptr<AVSourceMock> source); 62da853ecaSopenharmony_ciprivate: 63da853ecaSopenharmony_ci AVDemuxerMockFactory() = delete; 64da853ecaSopenharmony_ci ~AVDemuxerMockFactory() = delete; 65da853ecaSopenharmony_ci}; 66da853ecaSopenharmony_ci} // namespace MediaAVCodec 67da853ecaSopenharmony_ci} // namespace OHOS 68da853ecaSopenharmony_ci#endif // DEMUXER_MOCK_H