24 #include <sys/prctl.h>
27 #ifdef ENABLE_BREAKPAD
28 #include <client/linux/handler/exception_handler.h>
31 #include "rdkmediaplayer.h"
33 #include "glib_tools.h"
36 GMainLoop *gMainLoop = 0;
38 #ifdef ENABLE_BREAKPAD
42 bool breakpadCallback(
const google_breakpad::MinidumpDescriptor& ,
void* ,
bool succeeded) {
47 void installExceptionHandler() {
48 static google_breakpad::ExceptionHandler* excHandler = NULL;
50 excHandler =
new google_breakpad::ExceptionHandler(
51 google_breakpad::MinidumpDescriptor(
"/opt/minidumps"),
63 onEvent(
int argc, rtValue
const* argv, rtValue* result,
void* argp)
68 LOG_TRACE(
"argv[0]:%s", argv[0].toString().cString());
72 rtObjectRef
event = argv[0].toObject();
73 rtString eventName =
event.get<rtString>(
"name");
74 LOG_TRACE(
"Received event: %s", eventName.cString());
81 *result = rtValue(
true);
83 LOG_TRACE(
"******** onEvent - End ********");
87 void* processMessage(
void* args)
91 rtError err = rtRemoteProcessSingleItem();
96 int main(
int argc,
char *argv[]) {
106 pthread_t processMsgThread;
108 const char opendata[256] =
"{\"mediaurl\": \"tune://frequency=306000000&modulation=16&symbol_rate=6900000&pgmno=1001&\",\"mode\": \"MODE_LIVE\",\"manage\": \"MANAGE_NONE\",\"casinitdata\": \"<base64 data>\",\"casocdmid\": \"\"}";
109 const char opendata1[256] =
"{\"mediaurl\": \"tune://frequency=322000000&modulation=16&symbol_rate=6900000&pgmno=1&\",\"mode\": \"MODE_LIVE\",\"manage\": \"MANAGE_NONE\",\"casinitdata\": \"<base64 data>\",\"casocdmid\": \"\"}";
112 const char* objectName = getenv(
"PX_WAYLAND_CLIENT_REMOTE_OBJECT_NAME");
113 if (!objectName) objectName =
"rdkmediaplayer";
116 rtObjectRef playerRef;
117 rc = rtRemoteLocateObject(objectName, playerRef);
118 pthread_create(&processMsgThread, NULL, processMessage, NULL);
120 LOG_INFO(
"found object : %s", objectName);
124 rc = playerRef.get(
"availableSpeeds", supSpeeds);
127 LOG_INFO(
"failed to get availableSpeeds: %d", rc);
131 LOG_INFO(
"supSpeeds = %s", supSpeeds.cString());
136 printf(
"URI was NULL. Use the default json data with url");
137 rc = playerRef.send(
"open", rtString(opendata));
139 else if(strchr(argv[1],
'{') != NULL)
141 printf(
"URI contains json data");
142 rc = playerRef.send(
"open", rtString(argv[1]));
146 printf(
"URL is: %s\n", argv[1] );
147 rc = playerRef.set(
"url", rtString(argv[1]));
152 LOG_INFO(
"failed to set URL: %d", rc);
156 playerRef.send(
"on",
"onMediaOpened",
new rtFunctionCallback(onEvent));
157 playerRef.send(
"on",
"onProgress",
new rtFunctionCallback(onEvent));
158 playerRef.send(
"on",
"onStatus",
new rtFunctionCallback(onEvent));
159 playerRef.send(
"on",
"onWarning",
new rtFunctionCallback(onEvent));
160 playerRef.send(
"on",
"onError",
new rtFunctionCallback(onEvent));
161 playerRef.send(
"on",
"onSpeedChange",
new rtFunctionCallback(onEvent));
162 playerRef.send(
"on",
"onClosed",
new rtFunctionCallback(onEvent));
163 playerRef.send(
"on",
"onPlayerInitialized",
new rtFunctionCallback(onEvent));
164 playerRef.send(
"on",
"onBuffering",
new rtFunctionCallback(onEvent));
165 playerRef.send(
"on",
"onPlaying",
new rtFunctionCallback(onEvent));
166 playerRef.send(
"on",
"onPaused",
new rtFunctionCallback(onEvent));
167 playerRef.send(
"on",
"onComplete",
new rtFunctionCallback(onEvent));
168 playerRef.send(
"on",
"onIndividualizing",
new rtFunctionCallback(onEvent));
169 playerRef.send(
"on",
"onAcquiringLicense",
new rtFunctionCallback(onEvent));
170 playerRef.send(
"on",
"onDRMMetadata",
new rtFunctionCallback(onEvent));
171 playerRef.send(
"on",
"onSegmentStarted",
new rtFunctionCallback(onEvent));
172 playerRef.send(
"on",
"onSegmentCompleted",
new rtFunctionCallback(onEvent));
173 playerRef.send(
"on",
"onSegmentWatched",
new rtFunctionCallback(onEvent));
174 playerRef.send(
"on",
"onBufferWarning",
new rtFunctionCallback(onEvent));
175 playerRef.send(
"on",
"onPlaybackSpeedsChanged",
new rtFunctionCallback(onEvent));
176 playerRef.send(
"on",
"onAdditionalAuthRequired",
new rtFunctionCallback(onEvent));
179 url_out = playerRef.get<rtString>(
"url");
180 LOG_INFO(
"get url value : %s", url_out.cString());
182 rc = playerRef.send(
"play");
185 LOG_INFO(
"failed to set URL to play: %d", rc);
187 LOG_INFO(
"Play the url %s, result: %d", url_out.cString(), rc);
193 printf(
"Playback Options:\n");
194 printf(
"p - Pause Playback\n");
195 printf(
"r - Resume Playback\n");
196 printf(
"s - Stop Playback\n");
197 printf(
"l - Set Audio Language\n");
198 printf(
"t - Set speed\n");
199 printf(
"c - Enable Subt.\n");
200 printf(
"z - Channel Change\n");
201 printf(
"q - Quit\n");
209 rc = playerRef.send(
"pause");
212 LOG_INFO(
"failed to set URL to PAUSE: %d", rc);
214 LOG_INFO(
"PAUSE the url %s, result: %d", url_out.cString(), rc);
218 rc = playerRef.send(
"play");
221 LOG_INFO(
"failed to set URL play: %d", rc);
223 LOG_INFO(
"Play the url %s, result: %d", url_out.cString(), rc);
227 rc = playerRef.send(
"stop");
230 LOG_INFO(
"failed to set URL play: %d", rc);
232 LOG_INFO(
"stop the url %s, result: %d", url_out.cString(), rc);
235 printf(
"e - To Set English Language\n");
236 printf(
"d - To Set deustch Language\n");
242 rc = playerRef.set(
"audioLanguage",
"eng");
245 LOG_INFO(
"failed to set English Language: %d", rc);
250 rc = playerRef.set(
"audioLanguage",
"deu");
253 LOG_INFO(
"failed to set Deustch Language: %d", rc);
268 rc = playerRef.send(
"stop");
271 LOG_INFO(
"failed to set URL play: %d", rc);
273 LOG_INFO(
"stop the url %s, result: %d", url_out.cString(), rc);
278 printf(
"[CC] URI contains json data = %s\n", opendata);
279 rc = playerRef.send(
"open", rtString(opendata));
283 printf(
"[CC] URI contains json data = %s\n", opendata1);
284 rc = playerRef.send(
"open", rtString(opendata1));
287 url_out = playerRef.get<rtString>(
"url");
288 LOG_INFO(
"get url value : %s", url_out.cString());
290 rc = playerRef.send(
"play");
293 LOG_INFO(
"failed to set URL play: %d", rc);
295 LOG_INFO(
"Play the url %s, result: %d", url_out.cString(), rc);
310 rc = rtRemoteShutdown();