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_SINK_TYPE_H
17 #define PLAYER_SINK_TYPE_H
18 
19 #include <memory>
20 #include <vector>
21 #include "player_define.h"
22 #include "surface.h"
23 
24 using namespace std;
25 
26 namespace OHOS {
27 namespace Media {
28 #define AV_INVALID_PTS -1
29 #define MS_SCALE   1000
30 #define ENABLE_RENDER "enable-render"
31 #define MAX_PIPELINE_SINK_NUM  2
32 
33 typedef enum {
34     SINK_STATE_IDLE,
35     SINK_STATE_INITED,
36     SINK_STATE_PREPARED,
37     SINK_STATE_STARTED, /* normal play and tplay */
38     SINK_STATE_PAUSE,
39     SINK_STATE_STOP,
40     SINK_STATE_COMPLETE,  /* recieve eos */
41     SINK_STATE_ERROR
42 } SinkState;
43 
44 typedef enum  {
45     SINK_TYPE_AUDIO,
46     SINK_TYPE_VIDEO,
47     SINK_TYPE_BUT,
48 } SinkType;
49 
50 typedef enum {
51     DATA_TYPE_U8,
52     DATA_TYPE_S8,
53     DATA_TYPE_U16,
54     DATA_TYPE_S16,
55     DATA_TYPE_U32,
56     DATA_TYPE_S32,
57     DATA_TYPE_U64,
58     DATA_TYPE_S64,
59     DATA_TYPE_FLOAT,
60     DATA_TYPE_DOUBLE,
61     DATA_TYPE_STRING,
62 } dataType;
63 
64 typedef struct {
65     int32_t format;
66     uint32_t sampleFmt;
67     uint32_t sampleRate;
68     uint32_t channel;
69     float volume;
70 } AudioSinkAttr;
71 
72 typedef struct {
73     int32_t width;
74     int32_t height;
75     float frameRate;
76     int32_t format;
77     Surface *surface;
78 } VideoSinkAttr;
79 
80 typedef struct {
81     SinkType sinkType;
82     int32_t trackId;
83     union {
84         VideoSinkAttr vidAttr;
85         AudioSinkAttr audAttr;
86     };
87 } SinkAttr;
88 
89 typedef struct {
90     uint64_t audFrameCount;
91 } AudioSinkStatus;
92 
93 typedef struct {
94     uint64_t vidFrameCount;
95     uint32_t decWidth;
96     uint32_t decHeight;
97     uint32_t fpsInteger;
98     uint32_t fpsDecimal;
99 } VideoSinkStatus;
100 
101 typedef enum {
102     SINK_SUCCESS = 0,
103     SINK_GET_DEVICE_FAILED,
104     SINK_LAOD_DEVICE_FAILED,
105     SINK_OPEN_STREAM_FAILED,
106     SINK_INIT_FAILED,
107     SINK_RENDER_FULL,
108     SINK_RENDER_DELAY,
109     SINK_RENDER_ERROR,
110     SINK_QUE_EMPTY,
111     SINK_RENDER_EOS,
112     SINK_INVALID_OP
113 } SinkRetCode;
114 }  // namespace Media
115 }  // namespace OHOS
116 
117 #endif  // PLAYER_SINK_H
118