xref: /OK3568_Linux_fs/external/rockit/tgi/sdk/include/RTPlayerDef.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright 2019 Rockchip Electronics Co. LTD
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * Author: martin.cheng@rock-chips.com
17  *   Date: 2019/03/10
18  *   Task: build player streamline with node bus.
19  */
20 
21 #ifndef SRC_RT_PLAYER_RTPLAYERDEF_H_
22 #define SRC_RT_PLAYER_RTPLAYERDEF_H_
23 
24 #include "rt_type.h" // NOLINT
25 
26 #define DEBUG_LEVEL_HIGH 1
27 #define DEBUG_LEVEL_LOW  0
28 
29 enum RTMediaState {
30     RT_STATE_ERROR              = 0,
31     RT_STATE_IDLE               = 1 << 0,
32     RT_STATE_INITIALIZED        = 1 << 1,
33     RT_STATE_PREPARING          = 1 << 2,
34     RT_STATE_PREPARED           = 1 << 3,
35     RT_STATE_STARTED            = 1 << 4,
36     RT_STATE_PAUSED             = 1 << 5,
37     RT_STATE_STOPPED            = 1 << 6,
38     RT_STATE_COMPLETE           = 1 << 7
39 };
40 
41 enum RTMediaInfo {
42     // 0xx
43     RT_INFO_UNKNOWN = 1,
44     // The player was started because it was used as the next player for another
45     // player, which just completed playback
46     RT_INFO_STARTED_AS_NEXT = 2,
47     // The player just pushed the very first video frame for rendering
48     RT_INFO_RENDERING_START = 3,
49 
50     // 7xx
51     // The video is too complex for the decoder: it can't decode frames fast
52     // enough. Possibly only the audio plays fine at this stage.
53     RT_INFO_VIDEO_TRACK_LAGGING = 700,
54     // pause playback internally in order to buffer more data.
55     RT_INFO_BUFFERING_START = 701,
56     // resume playback after filling enough buffers.
57     RT_INFO_BUFFERING_END = 702,
58     // Bandwidth in recent past
59     RT_INFO_NETWORK_BANDWIDTH = 703,
60     // buffering percent of demuxer
61     RT_INFO_BUFFERING_PERCENT = 705,
62     // loading percent of demuxer
63     RT_INFO_LOADING_PERCENT = 706,
64 
65     // 8xx
66     // Bad interleaving means that a media has been improperly interleaved or not
67     // interleaved at all, e.g has all the video samples first then all the audio
68     // ones. Video is playing but a lot of disk seek may be happening.
69     RT_INFO_BAD_INTERLEAVING = 800,
70     // The media is not seekable (e.g live stream).
71     RT_INFO_NOT_SEEKABLE     = 801,
72     // New media metadata is available.
73     RT_INFO_METADATA_UPDATE  = 802,
74 
75     // 9xx
76     RT_INFO_TIMED_TEXT_ERROR = 900,
77     RT_INFO_PLAYING_START    = 901,
78 };
79 
80 enum RTMediaError {
81     // 0xx
82     RT_MEDIA_ERROR_UNKNOWN = 1,
83     // 1xx
84     RT_MEDIA_ERROR_SERVER_DIED = 100,
85     // 2xx
86     RT_MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK = 200,
87     // 3xx
88 };
89 
90 enum RTSeekType {
91     RT_SEEK_NO         = 0,
92     RT_SEEK_DOING,
93     RT_SEEK_VIDEO_ONLY,
94     RT_SEEK_DONE,
95     RT_SEEK_MAX,
96 };
97 
98 typedef struct _RTMediaUri {
99     char  *mUri;
100     INT32  mUriLength;
101     char   mHeaders[4096];
102     char   mVersion[32];
103     void  *mDataSource;
104 } RTMediaUri;
105 
106 enum RTWriteDataType {
107     RT_WRITEDATA_PCM = 0,
108     RT_WRITEDATA_TS,
109     RT_WRITEDATA_ES,
110 };
111 
112 typedef enum  _RTInvokeIds {
113     RT_INVOKE_ID_GET_TRACK_INFO = 1,
114     RT_INVOKE_ID_ADD_EXTERNAL_SOURCE = 2,
115     RT_INVOKE_ID_ADD_EXTERNAL_SOURCE_FD = 3,
116     RT_INVOKE_ID_SELECT_TRACK = 4,
117     RT_INVOKE_ID_UNSELECT_TRACK = 5,
118     RT_INVOKE_ID_SET_VIDEO_SCALING_MODE = 6,
119     RT_INVOKE_ID_GET_SELECTED_TRACK = 7,
120 
121     // rockit private key, must keep sync with rockit client
122     RT_INVOKE_PRIVATE_KEY = 10000,
123     RT_INVOKE_SET_PLAY_SPEED = RT_INVOKE_PRIVATE_KEY,
124     RT_INVOKE_GET_PLAY_SPEED,
125     RT_INVOKE_SET_SUB_VISIBLE,
126 } RTInvokeIds;
127 
128 class RTPlayerUtil {
129  public:
130     static const char*  getStateName(UINT32 player_state);
131     static void         dumpStateError(UINT32 state, const char* caller);
132 };
133 
134 #endif  // SRC_RT_PLAYER_RTPLAYERDEF_H_
135