1 /* 2 * Copyright (c) 2020-2021 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 PLAYER_SOURCE_H 17 #define PLAYER_SOURCE_H 18 19 #include "player_demux.h" 20 #include <memory> 21 #include <vector> 22 23 using namespace std; 24 25 namespace OHOS { 26 namespace Media { 27 class PlayerDemuxer; 28 class PlayerSource { 29 friend PlayerDemuxer; 30 public: 31 PlayerSource(); 32 ~PlayerSource(); 33 int32_t Init(); 34 int32_t SetSource(int32_t fd); 35 int32_t SetSource(const char *url); 36 int32_t SetSource(BufferStream &stream); 37 int32_t SetCallBack(PlayEventCallback &callBack); 38 int32_t Prepare(void); 39 int32_t GetFileInfo(FormatFileInfo &fileInfo); 40 int32_t SelectTrack(int32_t programId, int32_t trackId); 41 int32_t UnselectTrack(int32_t programId, int32_t trackId); 42 int32_t GetSelectedTrack(int32_t &programId, int32_t trackId[], int32_t &nums); 43 int32_t Start(); 44 int32_t ReadFrame(FormatFrame &frame); 45 int32_t FreeFrame(FormatFrame &frame); 46 int32_t Seek(int32_t streamIndex, int64_t timeStampUs, FormatSeekMode mode); 47 int32_t Stop(); 48 int32_t SetParam(int32_t trackId, const ParameterItem *metaData, int32_t metaDataCnt); 49 int32_t GetParam(int32_t trackId, ParameterItem &metaData); 50 private: 51 bool inited_; 52 bool prepared_; 53 bool started_; 54 std::shared_ptr<PlayerDemuxer> demuxer_; 55 }; 56 } // namespace Media 57 } // namespace OHOS 58 59 #endif // PLAYER_SOURCE_H 60