[MPlayer-users] patch for get_time_pos and get_url
Noel Burton-Krahn
noel at bkbox.com
Thu Jun 12 01:57:28 CEST 2003
I needed a command to print the current time in a file and the current URL,
so I added two commands to the mplayer in CVS. Here's from the ChangeLog,
the diff is below. You're free to add this to the mplayer distribution.
ChangeLog
NBK (Noel Burton-Krahn <noel at burton-krahn.com>) Jun 11, 2003
added two new commands:
get_time_pos: prints "ANS_TIME=" the number of seconds in the
current file
get_url: prints "ANS_URL=" the url of the current file
Do the developers watch mplayer-users?
Noel Burton-Krahn
noel at bkbox.com
BKbox - The total remote office solution
http://www.bkbox.com
----------------- diff against 'cvs get -D 20010611
main' -------------------------
? mplayer-cvs-20030611-gkgun.patch
Index: ChangeLog
===================================================================
RCS file: /cvsroot/mplayer/main/ChangeLog,v
retrieving revision 1.44
diff -a -u -r1.44 ChangeLog
--- ChangeLog 9 Feb 2003 17:36:20 -0000 1.44
+++ ChangeLog 11 Jun 2003 23:45:49 -0000
@@ -1,4 +1,8 @@
-
+NBK (Noel Burton-Krahn <noel at burton-krahn.com>) Jun 11, 2003
+ added two new commands:
+ get_time_pos: prints "ANS_TIME=" the number of seconds in the current file
+ get_url: prints "ANS_URL=" the url of the current file
+
mplayer (0.90)
final: "CounterCounter"
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.703
diff -a -u -r1.703 mplayer.c
--- mplayer.c 9 Jun 2003 12:15:40 -0000 1.703
+++ mplayer.c 11 Jun 2003 23:45:50 -0000
@@ -2937,6 +2937,14 @@
mp_msg(MSGT_GLOBAL,MSGL_INFO,"ANS_PERCENT_POSITION=%ld\n",
demuxer_get_percent_pos(demuxer));
} break;
+ // NBK - Jun 11, 2003 - print the current url/time
+ case MP_CMD_GET_TIME_POS : {
+ mp_msg(MSGT_GLOBAL,MSGL_INFO,"ANS_TIME=%lg\n",
demuxer_get_time_pos(demuxer));
+ } break;
+ case MP_CMD_GET_URL : {
+ mp_msg(MSGT_GLOBAL,MSGL_INFO,"ANS_URL=%s\n", demuxer_get_url(demuxer));
+ } break;
+
#ifdef USE_DVDNAV
case MP_CMD_DVDNAV_EVENT: {
dvdnav_priv_t * dvdnav_priv = (dvdnav_priv_t*)(stream->priv);
Index: input/input.c
===================================================================
RCS file: /cvsroot/mplayer/main/input/input.c,v
retrieving revision 1.75
diff -a -u -r1.75 input.c
--- input/input.c 9 Jun 2003 12:15:42 -0000 1.75
+++ input/input.c 11 Jun 2003 23:45:50 -0000
@@ -92,6 +92,8 @@
{ MP_CMD_LOADFILE, "loadfile", 1, { {MP_CMD_ARG_STRING, {0}},
{-1,{0}} } },
{ MP_CMD_LOADLIST, "loadlist", 1, { {MP_CMD_ARG_STRING, {0}},
{-1,{0}} } },
{ MP_CMD_VF_CHANGE_RECTANGLE, "change_rectangle", 2, {
{MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}}}},
+ { MP_CMD_GET_TIME_POS, "get_time_pos", 0, { {-1,{0}} } },
+ { MP_CMD_GET_URL, "get_url", 0, { {-1,{0}} } },
#ifdef HAVE_NEW_GUI
{ MP_CMD_GUI_LOADFILE, "gui_loadfile", 0, { {-1,{0}} } },
Index: input/input.h
===================================================================
RCS file: /cvsroot/mplayer/main/input/input.h,v
retrieving revision 1.31
diff -a -u -r1.31 input.h
--- input/input.h 17 May 2003 09:21:21 -0000 1.31
+++ input/input.h 11 Jun 2003 23:45:50 -0000
@@ -44,6 +44,10 @@
#define MP_CMD_TV_LAST_CHANNEL 40
#define MP_CMD_OSD_SHOW_TEXT 41
+// NBK - Jun 11, 2003 - print the current url/time
+#define MP_CMD_GET_TIME_POS 42
+#define MP_CMD_GET_URL 43
+
#define MP_CMD_GUI_EVENTS 5000
#define MP_CMD_GUI_LOADFILE 5001
#define MP_CMD_GUI_LOADSUBTITLE 5002
Index: libmpdemux/demux_avi.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_avi.c,v
retrieving revision 1.56
diff -a -u -r1.56 demux_avi.c
--- libmpdemux/demux_avi.c 2 Feb 2003 21:32:05 -0000 1.56
+++ libmpdemux/demux_avi.c 11 Jun 2003 23:45:50 -0000
@@ -849,6 +849,12 @@
if (sh_video->video.dwLength<=1) return DEMUXER_CTRL_GUESS;
return DEMUXER_CTRL_OK;
+
+ // NBK - Jun 11, 2003 - print the current url/time
+ case DEMUXER_CTRL_GET_TIME_POS:
+ *((double*)arg)=(double)priv->video_pack_no/sh_video->fps;
+ return DEMUXER_CTRL_OK;
+
default:
return DEMUXER_CTRL_NOTIMPL;
}
Index: libmpdemux/demuxer.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.c,v
retrieving revision 1.146
diff -a -u -r1.146 demuxer.c
--- libmpdemux/demuxer.c 9 Jun 2003 22:01:33 -0000 1.146
+++ libmpdemux/demuxer.c 11 Jun 2003 23:45:50 -0000
@@ -1570,3 +1570,22 @@
return ans;
}
+// NBK - Jun 11, 2003 - print the current url/time
+double demuxer_get_time_pos(demuxer_t *demuxer){
+ double ans;
+
+ if (demux_control(demuxer, DEMUXER_CTRL_GET_TIME_POS, &ans)<=0) {
+ ans=0;
+ }
+ return ans;
+}
+
+// NBK - Jun 11, 2003 - print the current url/time
+char *demuxer_get_url(demuxer_t *demuxer){
+ char *ans;
+
+ if (demux_control(demuxer, DEMUXER_CTRL_GET_URL, &ans)<=0) {
+ ans = (demuxer && demuxer->stream) ? demuxer->stream->url : 0;
+ }
+ return ans;
+}
Index: libmpdemux/demuxer.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.h,v
retrieving revision 1.61
diff -a -u -r1.61 demuxer.h
--- libmpdemux/demuxer.h 9 Jun 2003 00:24:22 -0000 1.61
+++ libmpdemux/demuxer.h 11 Jun 2003 23:45:50 -0000
@@ -67,6 +67,10 @@
#define DEMUXER_CTRL_GET_TIME_LENGTH 10
#define DEMUXER_CTRL_GET_PERCENT_POS 11
+// NBK - Jun 11, 2003 - print the current url/time
+#define DEMUXER_CTRL_GET_TIME_POS 12
+#define DEMUXER_CTRL_GET_URL 13
+
// Holds one packet/frame/whatever
typedef struct demux_packet_st {
int len;
@@ -259,5 +263,9 @@
extern unsigned long demuxer_get_time_length(demuxer_t *demuxer);
extern int demuxer_get_percent_pos(demuxer_t *demuxer);
+
+// NBK - Jun 11, 2003 - print the current url/time
+extern double demuxer_get_time_pos(demuxer_t *demuxer);
+extern char* demuxer_get_url(demuxer_t *demuxer);
extern int demuxer_type_by_filename(char* filename);
More information about the MPlayer-users
mailing list