• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_DEMUX_H
17 #define PLAYER_DEMUX_H
18 
19 #include "hi_demuxer.h"
20 #include "hi_liteplayer.h"
21 #include <string>
22 #include <memory>
23 #include <vector>
24 #include "player_define.h"
25 
26 using namespace std;
27 
28 namespace OHOS {
29 namespace Media {
30 class PlayerDemuxer {
31 public:
32     PlayerDemuxer();
33     ~PlayerDemuxer();
34     int32_t Init(void);
35     int32_t SetSource(int fd);
36     int32_t SetSource(const char *url);
37     int32_t SetSource(BufferStream &stream);
38     int32_t SetCallBack(PlayEventCallback &callBack);
39     int32_t Prepare(void);
40     int32_t GetFileInfo(FormatFileInfo &fileInfo);
41     int32_t SelectTrack(int32_t programId, int32_t trackId);
42     int32_t UnselectTrack(int32_t programId, int32_t trackId);
43     int32_t GetSelectedTrack(int32_t &programId, int32_t trackId[], int32_t &nums);
44     int32_t Start();
45     int32_t ReadFrame(FormatFrame &frame);
46     int32_t FreeFrame(FormatFrame &frame);
47     int32_t Seek(int32_t streamIndex, int64_t timeStampUs, FormatSeekMode mode);
48     int32_t Stop();
49     int32_t SetParam(int32_t trackId, const ParameterItem *metaData, int32_t metaDataCnt);
50     int32_t GetParam(int32_t trackId, ParameterItem &metaData);
51 
52     static int32_t ErrorEventPro(void *handle, int32_t errorType, int32_t errorCode);
53     static int32_t InfoEventPro(void *handle, int32_t type, int32_t extra);
54 private:
55     int32_t GetFormatDemuxer(void);
56     bool inited_;
57     bool prepared_;
58     bool started_;
59     void *demuxer_;
60     SourceType sourceType_;
61     int32_t fd_;
62     std::string filePath_;
63     BufferStream stream_;
64     PlayEventCallback callBack_;
65     FormatCallback formatListener_;
66 };
67 }  // namespace Media
68 }  // namespace OHOS
69 
70 #endif  // PLAYER_DEMUX_H
71