xref: /OK3568_Linux_fs/external/rockit/tgi/sdk/include/RTMediaPlayer.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  *                  fxw@rock-chips.com
18  *   date: 2020-04-27
19  * module: RTMediaPlayer
20  */
21 
22 #ifndef SRC_RT_PLAYER_RTMEDIAPLAYER_H_
23 #define SRC_RT_PLAYER_RTMEDIAPLAYER_H_
24 
25 #include <sys/types.h>
26 #include <inttypes.h>
27 #include "rt_header.h"                  // NOLINT
28 #include "RTPlayerDef.h"                // NOLINT
29 #include "RTMediaPlayerInterface.h"     // NOLINT
30 
31 class  IMediaDataSource;
32 class  RTPlayerListener;
33 struct RTMediaPlayerContexts;
34 
35 class RTMediaPlayer : public RTMediaPlayerInterface {
36  public:
37     RTMediaPlayer();
38     ~RTMediaPlayer();
39 
40  public:
41     /* parameter operations */
42     virtual rt_status setUID(uid_t uid);
43     virtual rt_status setDataSource(const char *url, const char *headers);
44     virtual rt_status setDataSource(INT32 fd, INT64 offset, INT64 length);
45     virtual rt_status setDataSource(IMediaDataSource *source);
46     virtual rt_status setLooping(INT32 loop);
47     virtual rt_status setListener(RTPlayerListener *listener);
48 
49     /* control operations */
50     virtual rt_status initCheck();
51     virtual rt_status prepare();
52     virtual rt_status prepareAsync();
53     virtual rt_status seekTo(INT64 usec);
54     virtual rt_status start();
55     virtual rt_status stop();
56     virtual rt_status pause();
57     virtual rt_status reset();
58     virtual rt_status wait(INT64 timeUs = 0);
59 
60     /* parameter query operations */
61     virtual rt_status getState();
62     virtual rt_status getCurrentPosition(INT64 *usec);
63     virtual rt_status getDuration(INT64 *usec);
64     virtual rt_status dump(INT32 fd, const char *args);
65 
66     /* advanced query/control operations */
67     virtual rt_status invoke(RtMetaData *request, RtMetaData *reply);
68     virtual rt_status setParameter(INT32 key, RtMetaData *request);
69     virtual rt_status getParameter(INT32 key, RtMetaData *reply);
70 
71     /* configuration video/audio/subtitle sink */
72     virtual rt_status setVideoSink(const void *videoSink);
73     virtual rt_status setAudioSink(const void *audioSink);
74     virtual rt_status setSubteSink(const void *subteSink);
75 
76  public:
77     /* extension interface for player, and cautiously modified. */
78     rt_status setVolume(float leftVolume, float rightVolume);
79 
80  private:
81     struct RTMediaPlayerContexts *mPlayerCtx;
82 };
83 
84 
85 #ifdef  __cplusplus
86 extern "C" {
87 #endif
88 
89 void *createRockitPlayer();
90 void  destroyRockitPlayer(void **player);
91 
92 #ifdef  __cplusplus
93 }
94 #endif
95 
96 #endif  // SRC_RT_PLAYER_RTMEDIAPLAYER_H_
97