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_ENGINE_IMPL_H 17 #define DEMUXER_ENGINE_IMPL_H 18 19 #include <map> 20 #include <mutex> 21 #include <condition_variable> 22 #include "i_demuxer_engine.h" 23 #include "demuxer.h" 24 #include "avcodec_common.h" 25 26 namespace OHOS { 27 namespace MediaAVCodec { 28 using namespace Media; 29 class DemuxerEngineImpl : public IDemuxerEngine { 30 public: 31 explicit DemuxerEngineImpl(uintptr_t sourceAddr); 32 ~DemuxerEngineImpl() override; 33 int32_t SelectTrackByID(uint32_t trackIndex) override; 34 int32_t UnselectTrackByID(uint32_t trackIndex) override; 35 int32_t ReadSample(uint32_t trackIndex, std::shared_ptr<AVBuffer> sample) override; 36 int32_t SeekToTime(int64_t millisecond, AVSeekMode mode) override; 37 void SetDrmCallback(const std::shared_ptr<OHOS::MediaAVCodec::AVDemuxerCallback> &callback) override; 38 39 private: 40 uintptr_t sourceAddr_; 41 std::mutex mutex_; 42 std::shared_ptr<Plugin::Demuxer> demuxer_ = nullptr; 43 }; 44 } // namespace MediaAVCodec 45 } // namespace OHOS 46 #endif // DEMUXER_ENGINE_IMPL_H