RDK Documentation (Open Sourced RDK Components)
mediaplayer.h
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2018 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 #ifndef _MEDIA_PLAYER_H_
20 #define _MEDIA_PLAYER_H_
21 
22 #include <string>
23 #include <vector>
24 #include "rmfqamsrcpriv.h"
25 
26 class MediaPlayerSink;
27 class IRMFMediaSource;
28 
30  public:
31  virtual void mediaPlayerEngineUpdated() = 0;
32  virtual void mediaPlaybackCompleted() = 0;
33  virtual void mediaFrameReceived() = 0;
34  virtual void mediaWarningReceived() = 0;
35  virtual void volumeChanged(float volume) = 0;
36  virtual void playerStateChanged() = 0;
37  virtual void videoStateChanged() = 0;
38  virtual void durationChanged() = 0;
39  virtual void timeChanged() = 0;
40  virtual void rateChanged() = 0;
41  virtual void videoDecoderHandleReceived() = 0;
42  virtual void eissDataReceived() = 0;
43  virtual void psiReady() = 0;
44  virtual void sectionDataReceived() = 0;
45  virtual void languageChange() = 0;
46  virtual void psiUpdateReceived(uint8_t psiStatus) = 0;
47  virtual void pmtUpdate() = 0;
48  virtual int getCurrentAudioPid() = 0;
49 };
50 
51 class MediaPlayer {
52  public:
53  enum RMFPlayerState {
54  RMF_PLAYER_EMPTY,
55  RMF_PLAYER_IDLE,
56  RMF_PLAYER_LOADING,
57  RMF_PLAYER_LOADED,
58  RMF_PLAYER_FORMATERROR,
59  RMF_PLAYER_NETWORKERROR,
60  RMF_PLAYER_DECODEERROR
61  };
62 
63  enum RMFVideoBufferState {
64  RMF_VIDEO_BUFFER_HAVENOTHING,
65  RMF_VIDEO_BUFFER_HAVEMETADATA,
66  RMF_VIDEO_BUFFER_HAVECURRENTDATA,
67  RMF_VIDEO_BUFFER_HAVEFUTUREDATA,
68  RMF_VIDEO_BUFFER_HAVEENOUGHDATA
69  };
70 
71  virtual ~MediaPlayer() {}
72 
73  virtual MediaPlayer::RMFPlayerState rmf_playerState() const = 0;
74  virtual MediaPlayer::RMFVideoBufferState rmf_videoState() const = 0;
75  virtual bool rmf_load(const std::string &url) = 0;
76  virtual void rmf_play() = 0;
77  virtual void rmf_stop() = 0;
78  virtual void rmf_pause() = 0;
79  virtual bool rmf_canItPlay() const = 0;
80  virtual bool rmf_isPaused() const = 0;
81  virtual void rmf_setRate(float speed) = 0;
82  virtual float rmf_getRate() const = 0;
83  virtual void rmf_setVolume(float volume) = 0;
84  virtual float rmf_getVolume() const = 0;
85  virtual void rmf_setMute(bool mute) = 0;
86  virtual bool rmf_isMuted() const = 0;
87  virtual float rmf_getDuration() const = 0;
88  virtual float rmf_getCurrentTime() const = 0;
89  virtual void rmf_seekToLivePosition() = 0;
90  virtual void rmf_seekToStartPosition() = 0;
91  virtual void rmf_seek(float time) = 0;
92  virtual bool rmf_isSeeking() const = 0;
93  virtual unsigned long rmf_getCCDecoderHandle() const = 0;
94  virtual std::string rmf_getAudioLanguages() const = 0;
95  virtual void rmf_setAudioLanguage(const std::string &audioLang) = 0;
96  virtual void rmf_setAudioMute(bool isMuted) = 0;
97  virtual void rmf_setEissFilterStatus(bool status) = 0;
98  virtual void rmf_setVideoZoom(unsigned short zoomVal) = 0;
99  virtual void rmf_setVideoBufferLength(float bufferLength) = 0;
100  virtual void rmf_setInProgressRecording(bool isInProgress) = 0;
101  virtual bool rmf_isItInProgressRecording() const = 0;
102  virtual std::string rmf_getMediaErrorMessage() const = 0;
103  virtual void rmf_changeSpeed(float speed, short overshootTime) = 0;
104  virtual std::string rmf_getMediaWarnDescription() const = 0;
105  virtual int rmf_getMediaWarnData() const = 0;
106  virtual std::string rmf_getAvailableAudioTracks() const = 0;
107  virtual std::string rmf_getCaptionDescriptor() const = 0;
108  virtual std::string rmf_getEISSDataBuffer() const = 0;
109  virtual void rmf_setNetworkBufferSize(int bufferSize) = 0;
110  virtual int rmf_getNetworkBufferSize() const = 0;
111  virtual void rmf_setVideoRectangle(unsigned x, unsigned y, unsigned w, unsigned h) = 0;
112  virtual MediaPlayerSink* rmf_getPlayerSink() = 0;
113  virtual IRMFMediaSource* rmf_getSource() = 0;
114  virtual void rmf_setVideoKeySlot(const char* str) = 0;
115  virtual void rmf_setAudioKeySlot(const char* str) = 0;
116  virtual void rmf_deleteVideoKeySlot() = 0;
117  virtual void rmf_deleteAudioKeySlot() = 0;
118  virtual int rmf_getVideoPid() = 0;
119  virtual int rmf_getAudioPid() = 0;
120  virtual uint32_t getPATBuffer(std::vector<uint8_t>& buf) = 0;
121  virtual uint32_t getPMTBuffer(std::vector<uint8_t>& buf) = 0;
122  virtual uint32_t getCATBuffer(std::vector<uint8_t>& buf) = 0;
123  virtual bool getAudioPidFromPMT(uint32_t *pid, const std::string& audioLang) = 0;
124  virtual bool getAudioMute() const = 0;
125  virtual void setFilter(uint16_t pid, char* filterParam, uint32_t *pFilterId) = 0;
126  virtual uint32_t getSectionData(uint32_t *filterId, std::vector<uint8_t>& sectionData) = 0;
127  virtual void releaseFilter(uint32_t filterId) = 0;
128  virtual void resumeFilter(uint32_t filterId) = 0;
129  virtual void pauseFilter(uint32_t filterId) = 0;
130 };
131 
132 #define CASE(x) case x: return #x
133 inline const char* StateString(MediaPlayer::MediaPlayer::RMFPlayerState st) {
134  switch (st) {
135  CASE(MediaPlayer::RMF_PLAYER_EMPTY);
136  CASE(MediaPlayer::RMF_PLAYER_IDLE);
137  CASE(MediaPlayer::RMF_PLAYER_LOADING);
138  CASE(MediaPlayer::RMF_PLAYER_LOADED);
139  CASE(MediaPlayer::RMF_PLAYER_FORMATERROR);
140  CASE(MediaPlayer::RMF_PLAYER_NETWORKERROR);
141  CASE(MediaPlayer::RMF_PLAYER_DECODEERROR);
142  default: return "Unknown";
143  }
144 }
145 inline const char* StateString(MediaPlayer::RMFVideoBufferState st) {
146  switch (st) {
147  CASE(MediaPlayer::RMF_VIDEO_BUFFER_HAVENOTHING);
148  CASE(MediaPlayer::RMF_VIDEO_BUFFER_HAVEMETADATA);
149  CASE(MediaPlayer::RMF_VIDEO_BUFFER_HAVECURRENTDATA);
150  CASE(MediaPlayer::RMF_VIDEO_BUFFER_HAVEFUTUREDATA);
151  CASE(MediaPlayer::RMF_VIDEO_BUFFER_HAVEENOUGHDATA);
152  default: return "Unknown";
153  }
154 }
155 #undef CASE
156 
157 #endif // _MEDIA_PLAYER_H_
MediaPlayer
Definition: mediaplayer.h:51
MediaPlayerClient
Definition: mediaplayer.h:29