1 /* 2 * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. 3 */ 4 /* 5 * Copyright (C) 2023 Huawei Device Co., Ltd. 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #ifndef DEMUXER_H 20 #define DEMUXER_H 21 22 #include <bits/alltypes.h> 23 #include "napi/native_api.h" 24 #include "multimedia/player_framework/native_avdemuxer.h" 25 #include "sample_info.h" 26 #include "dfx/error/av_codec_sample_error.h" 27 #include "av_codec_sample_log.h" 28 29 30 class Demuxer { 31 public: 32 Demuxer() = default; 33 ~Demuxer(); 34 int32_t Create(SampleInfo &sampleInfo); 35 int32_t ReadSample(int32_t trackId, OH_AVBuffer *buffer, OH_AVCodecBufferAttr &attr); 36 int32_t Release(); 37 int32_t GetVideoTrackId(); 38 int32_t GetAudioTrackId(); 39 int32_t Seek(int64_t millisecond, OH_AVSeekMode mode); 40 41 private: 42 int32_t GetTrackInfo(std::shared_ptr<OH_AVFormat> sourceFormat, SampleInfo &info); 43 44 OH_AVSource *source_; 45 OH_AVDemuxer *demuxer_; 46 int32_t videoTrackId_; 47 int32_t audioTrackId_; 48 }; 49 50 #endif // DEMUXER_H