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 DEMUXER_CAPI_MOCK_H
17 #define DEMUXER_CAPI_MOCK_H
18 
19 #include "demuxer_mock.h"
20 #include "common_mock.h"
21 #include "avcodec_common.h"
22 #include "native_avdemuxer.h"
23 #include "av_common.h"
24 #include "native_avmagic.h"
25 
26 
27 namespace OHOS {
28 namespace MediaAVCodec {
29 class DemuxerCapiMock : public DemuxerMock {
30 public:
DemuxerCapiMock(OH_AVDemuxer * demuxer)31     explicit DemuxerCapiMock(OH_AVDemuxer *demuxer) : demuxer_(demuxer) {}
32     ~DemuxerCapiMock() = default;
33 
34     int32_t Destroy() override;
35     int32_t SelectTrackByID(uint32_t trackIndex) override;
36     int32_t UnselectTrackByID(uint32_t trackIndex) override;
37     int32_t ReadSample(uint32_t trackIndex, std::shared_ptr<AVMemoryMock> sample,
38         AVCodecBufferInfo *bufferInfo, uint32_t &flag, bool checkBufferInfo) override;
39     int32_t SeekToTime(int64_t mSeconds, Media::SeekMode mode) override;
40     int32_t SetMediaKeySystemInfoCallback(bool isNull) override;
41     int32_t SetDemuxerMediaKeySystemInfoCallback(bool isNull) override;
42     int32_t GetMediaKeySystemInfo() override;
43     int32_t GetIndexByRelativePresentationTimeUs(const uint32_t trackIndex,
44         const uint64_t relativePresentationTimeUs, uint32_t &index) override;
45     int32_t GetRelativePresentationTimeUsByIndex(const uint32_t trackIndex,
46         const uint32_t index, uint64_t &relativePresentationTimeUs) override;
47 private:
48     OH_AVDemuxer *demuxer_ = nullptr;
49 };
50 } // namespace MediaAVCodec
51 } // namespace OHOS
52 #endif // DEMUXER_CAPI_MOCK_H