63
65
if (instance->mediaCompleteCallback != NULL)
64
66
NPN_GetURL(instance->mInstance,
65
67
instance->mediaCompleteCallback, "_self");
68
if (instance->mediaCompleteWithErrorCallback != NULL)
69
NPN_GetURL(instance->mInstance,
70
instance->mediaCompleteWithErrorCallback, "_self");
104
109
printf("In launchPlayerThread, state = %d\n", instance->state);
106
if (instance->threadlaunched == 1)
111
if (instance->threadlaunched == 1) {
113
printf("launchPlayerThread - joining thread\n");
107
114
pthread_join(instance->player_thread, &thread_return);
109
116
if (instance->js_state == JS_STATE_UNDEFINED) {
118
printf("launchPlayerThread - creating new thread\n");
111
119
pthread_create(&(instance->player_thread),
112
120
&(instance->thread_attr), playPlaylist,
113
121
(void *) (instance->td));
148
156
pthread_cond_signal(&(instance->playlist_complete_cond));
149
157
pthread_mutex_unlock(&(instance->playlist_cond_mutex));
150
158
instance->threadsignaled = 1;
151
pthread_mutex_unlock(&(instance->control_mutex));
154
161
printf("****Player thread did not start correctly****\n");
155
pthread_mutex_unlock(&(instance->control_mutex));
163
pthread_mutex_unlock(&(instance->control_mutex));
159
FILE *mypopen(char **argv, pid_t * pid, int *control)
166
FILE *mypopen(char **argv, pid_t * pid, int *control,
167
nsPluginInstance * instance)
161
int filedesr[2], filedesw[2];
169
int filedesr[2], filedesw[2], err;
164
172
sigset_t newmask;
189
197
sigaddset(&newmask, SIGKILL);
190
198
pthread_sigmask(SIG_UNBLOCK, &newmask, 0L);
192
if (execvp(argv[0], argv) < 0)
200
if (execvp(argv[0], argv) < 0) {
203
snprintf(instance->lastmessage, 1024, "Error: %i - %s", err,
205
g_idle_add(gtkgui_message, instance);
254
270
instance->td->list = instance->list;
257
274
if (instance->href) {
259
276
printf("using href for url\n");
260
277
snprintf(instance->td->list->url, 1024, "%s", instance->href);
261
} else if (instance->fname) {
280
if (instance->fname) {
263
282
printf("using fname for url\n");
264
283
snprintf(instance->td->list->url, 1024, "%s", instance->fname);
268
287
snprintf(instance->td->list->url, 1024, "%s", instance->url);
290
if ((instance->fname == NULL) && (instance->url == NULL)) {
292
printf("using href for url\n");
293
snprintf(instance->td->list->url, 1024, "%s", instance->href);
271
296
if (instance->mode == NP_FULL) {
272
297
snprintf(xval, 32, "%i", instance->window_width);
273
298
snprintf(yval, 32, "%i", instance->window_height);
275
300
snprintf(xval, 32, "%i", instance->embed_width);
276
snprintf(yval, 32, "%i", instance->embed_height);
301
if (instance->maintain_aspect == 0 && instance->showcontrols == 1) {
302
snprintf(yval, 32, "%i", instance->embed_height - 16);
304
snprintf(yval, 32, "%i", instance->embed_height);
370
399
gtk_fixed_put(GTK_FIXED(instance->fixed_container),
371
400
instance->drawing_area, 0, 0);
372
401
gtk_widget_show(instance->drawing_area);
402
if (instance->targetplayer == 1)
403
gtk_widget_show(instance->gtkwidget);
373
404
instance->player_window =
374
405
GDK_WINDOW_XWINDOW(instance->drawing_area->window);
406
if (instance->targetplayer == 1)
407
gtk_widget_hide(instance->gtkwidget);
375
408
snprintf(buffer, 1024, "0x%x", (int) instance->player_window);
376
409
instance->td->argv[i++] = strdup(buffer);
411
g_signal_connect_after(G_OBJECT(instance->gtkwidget),
412
"visibility-notify-event",
413
G_CALLBACK(window_visible), instance);
379
417
instance->player_window = 0;
431
if (isRemoteDisplay == false) {
469
if ((isRemoteDisplay == false)
470
&& (instance->targetplayer == 0)) {
432
471
if (instance->maintain_aspect == 1) {
433
472
snprintf(buffer, 1024, "-xy");
434
473
instance->td->argv[i++] = strdup(buffer);
451
if (instance->rtsp_use_tcp == 1) {
452
snprintf(buffer, 1024, "-rtsp-stream-over-tcp");
453
instance->td->argv[i++] = strdup(buffer);
490
// if (instance->rtsp_use_tcp == 1) {
491
// snprintf(buffer, 1024, "-rtsp-stream-over-tcp");
492
// instance->td->argv[i++] = strdup(buffer);
455
494
// if (instance->cachesize > 0) {
456
495
// snprintf(buffer, 1024, "-cache");
457
496
// instance->td->argv[i++] = strdup(buffer);
472
511
instance->td->argv[i++] = strdup(buffer);
473
512
snprintf(buffer, 1024, "%s", instance->vo);
474
513
instance->td->argv[i++] = strdup(buffer);
475
if ((strcmp(buffer, "x11") == 0)
514
if ((strncmp(buffer, "x11", 3) == 0)
476
515
|| (strstr(buffer, ",x11") != NULL)) {
477
516
snprintf(buffer, 1024, "-zoom"); /* -vo x11 needs -zoom for rescaling */
478
517
instance->td->argv[i++] = strdup(buffer);
486
525
instance->td->argv[i++] = strdup(buffer);
529
snprintf(buffer, 1024, "-af");
530
instance->td->argv[i++] = strdup(buffer);
531
snprintf(buffer, 1024, "%s", instance->af);
532
instance->td->argv[i++] = strdup(buffer);
489
535
if (instance->output_display) {
490
536
snprintf(buffer, 1024, "-display");
491
537
instance->td->argv[i++] = strdup(buffer);
645
692
//return true if we should try to play this again immediately, false if not
647
int playNode(ThreadData * local_td, Node * local_list, char *local_url,
648
int local_mmsstream, int *usefps, int *nomouseinput,
694
PlayResult *playNode(ThreadData * local_td, Node * local_list,
695
char *local_url, int local_mmsstream, int *usefps,
696
int *nomouseinput, int *maybeplaylist)
699
PlayResult *result = (PlayResult *) NPN_MemAlloc(sizeof(PlayResult));
652
700
char buffer[1024];
653
701
char message[1024];
665
712
int zerocfbytes_count = 0;
666
713
char url_copy[1024];
715
int length_request_count = 0;
716
float lastmedialength = -1.0;
717
int lastmediapercent = -1;
718
int lastpercent = -1;
668
719
#ifdef GTK_ENABLED
669
720
int fsupdated = 0;
671
#define TRYAGAIN_FALSE 0
672
#define TRYAGAIN_TRUE 1
673
#define TRYAGAIN_FALLBACK 2
675
int tryagain = TRYAGAIN_FALLBACK;
723
result->errorcode = ERROR_NO_ERROR;
724
result->tryagain = TRYAGAIN_FALLBACK;
725
result->retval = FALSE;
679
728
the meaning of the above is as follows:
692
741
(void *) &(local_td->instance->control_mutex));
693
742
pthread_mutex_lock(&(local_td->instance->control_mutex));
694
743
sendCommand(local_td->instance, "get_time_length");
744
local_td->instance->mediaLength = 0.0;
695
745
pthread_mutex_unlock(&(local_td->instance->control_mutex));
696
746
pthread_cleanup_pop(0);
748
g_idle_add(gtkgui_save_enable, local_td->instance);
749
// g_idle_add(gtkgui_refreshbuttonstate, local_td->instance);
752
// set this to 0 for every new media file;
753
local_td->instance->movie_height = 0;
754
local_td->instance->movie_width = 0;
699
757
pthread_testcancel();
700
758
if (local_td->instance->player == NULL)
732
791
pthread_testcancel();
733
c = fgetc(local_td->instance->player);
792
// need to lock around the read
793
pthread_mutex_lock(&(local_td->instance->read_mutex));
795
if ((local_td->instance->cancelled == 0) && (local_td->instance->player != NULL)) {
796
// c = fgetc(local_td->instance->player);
797
fread(&c,1,1,local_td->instance->player);
801
pthread_mutex_unlock(&(local_td->instance->read_mutex));
735
804
buffer[i] = '\0';
780
849
// Only update the display if there is something worth displaying
781
850
if (strstr(eos, "Cache fill:") != NULL) {
782
851
cf = strstr(eos, "Cache fill:");
852
lastpercent = (int)cfpercent;
783
853
i = sscanf(cf, "Cache fill: %lf %% (%ld bytes)",
784
854
&cfpercent, &cfbytes);
785
855
//the following is a workaround for an mplayer bug
795
865
if (zerocfbytes_count >= 1 &&
796
866
((strncmp(local_url, "mms://", 6) == 0) ||
798
&& strncmp(local_url, "http://", 7) == 0)) {
868
&& strncmp(local_url, "http://", 7) == 0))) {
801
871
printf("Exiting. Will try again with mmst://\n");
803
tryagain = TRYAGAIN_FALLBACK;
873
result->tryagain = TRYAGAIN_FALLBACK;
814
884
#ifdef GTK_ENABLED
815
885
snprintf(local_td->instance->lastmessage, 1024, "%s",
817
g_idle_add(gtkgui_message, local_td->instance);
818
local_td->instance->percent = (cfpercent / 100.0);
819
g_idle_add(gtkgui_progress, local_td->instance);
888
local_td->instance->percent = (cfpercent / 100.0);
889
if (lastpercent != cfpercent) {
890
g_idle_add(gtkgui_message, local_td->instance);
891
g_idle_add(gtkgui_progress, local_td->instance);
894
pthread_mutex_lock(&(local_td->instance->control_mutex));
895
local_td->instance->js_state = JS_STATE_BUFFERING;
896
pthread_mutex_unlock(&(local_td->instance->control_mutex));
833
910
snprintf(local_td->instance->lastmessage, 1024, "%s", message);
834
911
g_idle_add(gtkgui_message, local_td->instance);
913
pthread_mutex_lock(&(local_td->instance->control_mutex));
914
local_td->instance->js_state = JS_STATE_PLAYING;
915
pthread_mutex_unlock(&(local_td->instance->control_mutex));
838
918
pthread_testcancel();
852
932
local_td->instance->embed_height -
853
933
local_list->play_y;
855
if (local_td->instance->player_window != 0) {
935
if (local_td->instance->player_window != 0 && local_td->instance->movie_height != local_list->play_y) {
857
937
local_td->instance->movie_height = local_list->play_y;
858
938
local_td->instance->movie_width = local_list->play_x;
871
951
local_td->instance->panel_height = 16;
872
local_td->instance->movie_height = local_list->play_y;
873
local_td->instance->movie_width = local_list->play_x;
874
if (local_td->instance->player_window != 0) {
952
if (local_td->instance->player_window != 0 && local_td->instance->movie_height != local_list->play_y) {
953
local_td->instance->movie_height = local_list->play_y;
954
local_td->instance->movie_width = local_list->play_x;
876
956
#ifdef GTK_ENABLED
877
957
g_idle_add(gtkgui_resize, local_td->instance);
906
986
pthread_testcancel();
907
987
// mplayer answer back messages
908
988
if (strstr(buffer, "ANS_LENGTH") != 0) {
989
if ((int) local_td->instance->mediaLength != 0)
990
lastmedialength = local_td->instance->mediaLength;
909
991
msg = strstr(buffer, "ANS_LENGTH");
910
992
sscanf(msg, "ANS_LENGTH=%f",
911
993
&(local_td->instance->mediaLength));
917
999
pthread_testcancel();
1000
// mplayer answer back messages
1001
if (strstr(buffer, "ANS_TIME_POSITION") != 0) {
1002
msg = strstr(buffer, "ANS_TIME_POSITION");
1003
sscanf(msg, "ANS_TIME_POSITION=%f",
1004
&(local_td->instance->mediaPos));
1006
printf("Media Position = %f\n",
1007
local_td->instance->mediaPos);
1008
if ((int) local_td->instance->mediaLength > 1) {
1009
lastmediapercent = local_td->instance->mediaPercent;
1010
local_td->instance->mediaPercent =
1011
(int) ((local_td->instance->mediaPos * 100) /
1012
local_td->instance->mediaLength);
1014
if (lastmediapercent != local_td->instance->mediaPercent) {
1015
g_idle_add(gtkgui_drawMediaProgress, local_td->instance);
1016
g_idle_add(gtkgui_refreshbuttonstate, local_td->instance);
1022
pthread_testcancel();
918
1023
if (strstr(buffer, "ANS_PERCENT_POSITION") != 0) {
919
1024
msg = strstr(buffer, "ANS_PERCENT_POSITION");
920
1025
sscanf(msg, "ANS_PERCENT_POSITION=%i",
921
1026
&(local_td->instance->mediaPercent));
922
1027
if (local_td->instance->mediaPercent == 0) {
923
if (local_td->instance->mediaLength != 0)
1028
if ((int) local_td->instance->mediaLength > 1)
1029
lastmediapercent = local_td->instance->mediaPercent;
924
1030
local_td->instance->mediaPercent =
925
(int) ((local_td->instance->mediaTime * 100) /
1031
(int) ((local_td->instance->mediaPos * 100) /
926
1032
local_td->instance->mediaLength);
1034
if (lastmediapercent != local_td->instance->mediaPercent) {
1035
g_idle_add(gtkgui_drawMediaProgress, local_td->instance);
1036
g_idle_add(gtkgui_refreshbuttonstate, local_td->instance);
929
1041
printf("Percent Played = %i\n",
930
1042
local_td->instance->mediaPercent);
932
g_idle_add(gtkgui_drawMediaProgress, local_td->instance);
936
1045
pthread_testcancel();
944
1053
printf("mediaTime = %f\n",
945
1054
local_td->instance->mediaTime);
946
1055
#ifdef GTK_ENABLED
947
g_idle_add(gtkgui_draw, local_td->instance);
1056
// g_idle_add(gtkgui_draw, local_td->instance);
950
1059
msg = strstr(buffer, "\rV:");
969
1078
pthread_mutex_unlock(&(local_td->instance->control_mutex));
970
1079
pthread_cleanup_pop(0);
1080
pthread_testcancel();
971
1081
if (local_td->instance->paused == 0) {
972
1082
pthread_cleanup_push((void (*)(void *))
973
1083
pthread_mutex_unlock,
974
1084
(void *) &(local_td->instance->
975
1085
control_mutex));
976
1086
pthread_mutex_lock(&(local_td->instance->control_mutex));
977
sendCommand(local_td->instance, "get_percent_pos");
1087
if ((int) local_td->instance->mediaLength > 1)
1088
sendCommand(local_td->instance, "get_time_pos");
1089
if (local_td->instance->mediaLength > lastmedialength) {
1090
sendCommand(local_td->instance, "get_time_length");
1092
if (length_request_count < 10) {
1093
sendCommand(local_td->instance, "get_time_length");
1094
length_request_count++;
978
1097
pthread_mutex_unlock(&(local_td->instance->control_mutex));
979
1098
pthread_cleanup_pop(0);
980
1099
#ifdef GTK_ENABLED
999
1118
snprintf(local_td->instance->lastmessage, 1024, "%s", message);
1000
1119
g_idle_add(gtkgui_message, local_td->instance);
1121
pthread_mutex_lock(&(local_td->instance->control_mutex));
1122
local_td->instance->js_state = JS_STATE_WAITING;
1123
pthread_mutex_unlock(&(local_td->instance->control_mutex));
1127
pthread_testcancel();
1128
if (strstr(buffer, "Initiated") != NULL) {
1129
snprintf(message, 1024, "%s", buffer);
1131
DrawUI(local_td->instance->widget,
1132
local_td->instance, message, 0, -1);
1135
snprintf(local_td->instance->lastmessage, 1024, "%s", message);
1136
g_idle_add(gtkgui_message, local_td->instance);
1004
1140
pthread_testcancel();
1012
1148
snprintf(local_td->instance->lastmessage, 1024, "%s", message);
1013
1149
g_idle_add(gtkgui_message, local_td->instance);
1151
result->tryagain = TRYAGAIN_FALSE;
1152
result->errorcode = ERROR_NO_STREAM;
1018
1157
pthread_testcancel();
1019
1158
if (strstr(buffer, "Example: mplayer -playlist ") != NULL) {
1020
1159
if (*maybeplaylist == 0) {
1021
tryagain = TRYAGAIN_TRUE;
1160
result->tryagain = TRYAGAIN_TRUE;
1022
1161
*maybeplaylist = 1;
1024
tryagain = TRYAGAIN_FALSE;
1163
result->tryagain = TRYAGAIN_FALSE;
1164
result->errorcode = ERROR_NOT_PLAYLIST;
1028
1169
pthread_testcancel();
1029
if (strstr(buffer, "Stream not seekable") != NULL) {
1030
if (*maybeplaylist == 0) {
1031
tryagain = TRYAGAIN_TRUE;
1034
tryagain = TRYAGAIN_FALSE;
1170
if (strstr(buffer, "File not found") != NULL) {
1171
result->tryagain = TRYAGAIN_FALSE;
1172
result->errorcode = ERROR_FILE_NOT_FOUND;
1038
1176
pthread_testcancel();
1039
1177
if (strstr(buffer, "Error while decoding") != NULL) {
1040
if (!isMms(local_url)) {
1178
if (!isMms(local_url, local_td->instance->nomediacache)) {
1042
1180
printf("Resetting stream, 1 sec rewind\n");
1043
1181
pthread_suspend(1000);
1059
1197
printf("----player thread: breaking read loop - Quit\n");
1060
1198
local_td->instance->js_state = JS_STATE_UNDEFINED;
1061
tryagain = TRYAGAIN_FALSE;
1199
result->tryagain = TRYAGAIN_FALSE;
1203
pthread_testcancel();
1206
"MPlayer interrupted by signal 13 in module: demux_open") !=
1210
("----player thread: breaking read loop - demux_open\n");
1211
local_td->instance->js_state = JS_STATE_UNDEFINED;
1212
if (local_td->instance->rtsp_use_tcp == 1) {
1213
local_td->instance->rtsp_use_tcp = 0;
1214
result->tryagain = TRYAGAIN_TRUE;
1216
result->tryagain = TRYAGAIN_FALSE;
1217
result->errorcode = ERROR_PLAYER_INTERRUPTED;
1065
1223
pthread_testcancel();
1066
1224
// detect Quicktime file with old codec
1071
1229
("----player thread: waiting to download entire movie\n");
1073
tryagain = TRYAGAIN_TRUE;
1231
result->tryagain = TRYAGAIN_TRUE;
1075
1233
pthread_testcancel();
1077
1235
pthread_testcancel();
1236
pthread_mutex_lock(&(local_td->instance->control_mutex));
1237
local_td->instance->js_state = JS_STATE_BUFFERING;
1238
pthread_mutex_unlock(&(local_td->instance->control_mutex));
1078
1239
pthread_mutex_lock(&(local_td->instance->playlist_mutex));
1079
1240
local_td->instance->state = STATE_DOWNLOADING;
1080
1241
if (local_list->retrieved == 1) {
1081
1242
local_td->instance->state = STATE_PLAYING;
1243
pthread_mutex_lock(&(local_td->instance->control_mutex));
1244
local_td->instance->js_state = JS_STATE_PLAYING;
1245
pthread_mutex_unlock(&(local_td->instance->control_mutex));
1082
1246
pthread_mutex_unlock(&
1083
1247
(local_td->instance->
1084
1248
playlist_mutex));
1101
1265
pthread_testcancel();
1102
1266
if (strstr(buffer, "nomouseinput") != NULL) {
1103
1267
*nomouseinput = 0;
1104
tryagain = TRYAGAIN_TRUE;
1268
result->tryagain = TRYAGAIN_TRUE;
1107
// Possible work around for cinema now site
1108
// if (strstr(buffer, "ASF file format detected") != NULL) {
1109
// tryagain = TRYAGAIN_TRUE;
1110
// local_list->playlist = 1;
1115
1272
pthread_testcancel();
1116
1273
if (strstr(buffer, "Exiting") != NULL) {
1135
1293
("----player thread: breaking read loop - interrupted\n");
1294
if (strstr(buffer, "video_read_frame") != NULL) {
1295
local_td->instance->js_state = JS_STATE_UNDEFINED;
1296
if (local_td->instance->rtsp_use_tcp == 1) {
1297
local_td->instance->rtsp_use_tcp = 0;
1298
result->tryagain = TRYAGAIN_TRUE;
1301
snprintf(local_td->instance->lastmessage, 1024,
1302
"Error: %s", buffer);
1303
g_idle_add(gtkgui_message, local_td->instance);
1305
result->tryagain = TRYAGAIN_FALSE;
1306
result->errorcode = ERROR_PLAYER_INTERRUPTED;
1312
pthread_testcancel();
1313
if (strstr(buffer, "execv") != NULL) {
1316
("----player thread: breaking read loop - execv failed\n");
1317
local_td->instance->js_state = JS_STATE_UNDEFINED;
1319
snprintf(local_td->instance->lastmessage, 1024, "Error: %s %s",
1320
local_td->argv[0], buffer);
1321
g_idle_add(gtkgui_message, local_td->instance);
1323
result->tryagain = TRYAGAIN_FALSE;
1324
result->errorcode = ERROR_EXECV;
1140
1329
if (strstr(buffer, "explicit kill") != NULL) {
1142
1331
printf("----player thread: breaking read loop - killed\n");
1332
result->tryagain = TRYAGAIN_FALSE;
1333
result->errorcode = ERROR_EXPLICIT_KILL;
1146
1337
pthread_testcancel();
1338
/* commmented out to make BBC site work
1147
1339
if (strstr(buffer, "everything done") != NULL) {
1150
1342
("----player thread: breaking read loop - codec issue\n");
1343
result->tryagain = TRYAGAIN_FALSE;
1344
result->errorcode = ERROR_CODEC_FAILURE;
1155
1349
assert(local_td->instance->player != NULL);
1157
1351
} // end of READ LOOP
1160
printf("----player thread: tryagain = %d\n", tryagain);
1354
printf("----player thread: tryagain = %d\n", result->tryagain);
1162
1356
//we always return either true or false
1163
if (tryagain == TRYAGAIN_TRUE) {
1167
if (tryagain == TRYAGAIN_FALSE) {
1171
if (tryagain == TRYAGAIN_FALLBACK) {
1357
if (result->tryagain == TRYAGAIN_TRUE) {
1358
result->retval = TRUE;
1361
if (result->tryagain == TRYAGAIN_FALSE) {
1362
result->retval = FALSE;
1365
if (result->tryagain == TRYAGAIN_FALLBACK) {
1172
1366
//fallback to msst if we can
1173
1367
strlcpy(url_copy, local_url, 1023);
1174
1368
url_copy[1023] = '\0';
1176
1370
if (strncmp(local_url, "mms://", 6) == 0) {
1177
1371
snprintf(local_url, 1023, "mmst://%s", url_copy + 6);
1372
result->retval = TRUE;
1179
1373
} else if (local_mmsstream &&
1180
1374
strncmp(local_url, "http://", 7) == 0) {
1182
1376
snprintf(local_url, 1023, "mmst://%s", url_copy + 7);
1377
result->retval = TRUE;
1379
result->retval = FALSE;
1383
if (strstr(local_td->instance->lastmessage, "Error") == NULL) {
1384
snprintf(local_td->instance->lastmessage, 1024, _("Stopped"));
1385
g_idle_add(gtkgui_message, local_td->instance);
1192
1391
void *playPlaylist(void *td)
1394
PlayResult *result = NULL;
1195
1395
FILE *playlist;
1196
1396
char cmd[2048];
1197
1397
char message[1024];
1198
1398
char mmsplaylist[1024];
1199
1399
char buffer[1024]; // scratch pad
1400
char *p; // pointer to find the ( in the callback
1201
1402
int argc = 0, base_argc = 0;
1202
1403
ThreadData *local_td;
1241
1443
if (local_td->instance->state < STATE_STARTED_PLAYER) {
1242
1444
// wait for playlist_complete_cond to be signalled
1243
1445
// this should happen when we have completed getting all the playlist elements
1446
local_td->instance->state = STATE_WAITING_FOR_SIGNAL;
1244
1447
pthread_cond_wait(&(local_td->instance->playlist_complete_cond),
1245
1448
&(local_td->instance->playlist_cond_mutex));
1246
1449
pthread_mutex_unlock(&(local_td->instance->playlist_cond_mutex));
1248
1451
pthread_testcancel();
1250
// playlist_cond_mutex should be locked now
1453
// playlist_cond_mutex should be unlocked now
1251
1454
if (local_td != NULL) {
1253
1456
printf("local_td = %p\n", local_td);
1418
1623
printf("----player thread: nothing on the list to play\n");
1420
1625
local_mmsstream = 0;
1626
// update MediaCompleteWithError Callback with PLAYLIST EMPTY but only if we have not played anything
1627
if ((local_td->instance->mediaCompleteWithErrorCallback !=
1628
NULL) && (lasterror == -1)) {
1630
printf("mediaCompleteWithError(before) = %s\n",
1631
local_td->instance->
1632
mediaCompleteWithErrorCallback);
1634
local_td->instance->mediaCompleteWithErrorCallback,
1636
p = index(message, '(');
1638
p = message + strlen(message);
1641
snprintf(buffer, 1024, "%s(%i);", message,
1642
ERROR_PLAYLIST_EMPTY);
1643
NPN_MemFree(local_td->instance->
1644
mediaCompleteWithErrorCallback);
1645
local_td->instance->mediaCompleteWithErrorCallback =
1646
(char *) NPN_MemAlloc(strlen(buffer));
1647
strlcpy(local_td->instance->mediaCompleteWithErrorCallback,
1648
buffer, strlen(buffer));
1650
printf("mediaCompleteWithError(after) = %s\n",
1651
local_td->instance->
1652
mediaCompleteWithErrorCallback);
1422
1655
//we have a node to play
1523
1766
if (strlen(local_list->fname) == 0) {
1767
if (local_list->playlist == 1 || maybeplaylist != 0)
1768
local_td->argv[argc++] = strdup("-playlist");
1524
1769
local_td->argv[argc++] = strdup(local_url);
1526
1771
local_td->argv[argc++] = strdup("-nocache");
1772
if (local_list->playlist == 1 || maybeplaylist != 0)
1773
local_td->argv[argc++] = strdup("-playlist");
1527
1774
local_td->argv[argc++] = strdup(local_list->fname);
1531
if (local_list->playlist == 1 || maybeplaylist != 0)
1532
local_td->argv[argc++] = strdup("-playlist");
1535
1780
printf("----player thread: URL: %s\n", local_url);
1550
1795
local_td->instance->player =
1551
1796
mypopen(local_td->argv, &(local_td->instance->pid),
1552
&(local_td->instance->control));
1797
&(local_td->instance->control),
1798
local_td->instance);
1553
1799
if (local_td->instance->player != NULL) {
1554
1800
local_td->instance->js_state = JS_STATE_PLAYING;
1566
1812
local_td->instance->mediaLength = 0.0;
1567
1813
local_td->instance->mediaPercent = 0;
1570
1816
playNode(local_td, local_list, local_url,
1571
1817
local_mmsstream, &usefps, &nomouseinput,
1572
1818
&maybeplaylist);
1820
pthread_mutex_lock(&(local_td->instance->control_mutex));
1821
local_td->instance->js_state = JS_STATE_TRANSITIONING;
1822
pthread_mutex_unlock(&(local_td->instance->control_mutex));
1576
1826
("----player thread: playNode returned = %d\n",
1579
1829
pthread_testcancel();
1580
1830
assert(local_list != NULL);
1587
1837
// this cancels the download of this media
1588
1838
// if there are more than 1, saves bandwidth
1589
//also revents us from playing it again
1839
// also revents us from playing it again
1590
1840
pthread_mutex_lock(&(local_td->instance->playlist_mutex));
1841
if (!(result->retval)) {
1592
1842
local_list->played = 1;
1594
1844
pthread_mutex_unlock(&
1597
1847
assert(local_td->instance != NULL);
1599
1849
//close the pipes to mplayer
1600
pthread_mutex_lock(&(local_td->instance->control_mutex));
1601
local_td->instance->js_state = JS_STATE_TRANSITIONING;
1602
pthread_mutex_unlock(&(local_td->instance->control_mutex));
1605
1852
assert(local_td->instance->control > 0);
1616
1863
local_td->instance->state = STATE_PLAYLIST_NEXT;
1866
// update MediaCompleteWithError Callback
1867
if (local_td->instance->mediaCompleteWithErrorCallback != NULL) {
1869
printf("mediaCompleteWithError(before) = %s\n",
1870
local_td->instance->
1871
mediaCompleteWithErrorCallback);
1873
local_td->instance->mediaCompleteWithErrorCallback,
1875
p = index(message, '(');
1877
p = message + strlen(message);
1880
snprintf(buffer, 1024, "%s(%i);", message,
1882
NPN_MemFree(local_td->instance->
1883
mediaCompleteWithErrorCallback);
1884
local_td->instance->mediaCompleteWithErrorCallback =
1885
(char *) NPN_MemAlloc(strlen(buffer));
1886
strlcpy(local_td->instance->mediaCompleteWithErrorCallback,
1887
buffer, strlen(buffer));
1889
printf("mediaCompleteWithError(after) = %s\n",
1890
local_td->instance->
1891
mediaCompleteWithErrorCallback);
1894
} while (result->retval);
1621
1896
local_td->instance->currentnode = NULL;
1656
1931
g_idle_add(mediacallback, local_td->instance);
1935
if (local_td->instance->mediaCompleteCallback != NULL)
1936
NPN_GetURL(local_td->instance->mInstance,
1937
local_td->instance->mediaCompleteCallback, "_self");
1938
if (local_td->instance->mediaCompleteWithErrorCallback != NULL)
1939
NPN_GetURL(local_td->instance->mInstance,
1940
local_td->instance->mediaCompleteWithErrorCallback,
1944
if (GTK_IS_WIDGET(local_td->instance->src_event_box)) {
1945
gtk_widget_show(local_td->instance->src_event_box);
1661
1949
printf("----player thread: callbacks complete\n");