[xiph-commits] r3065 - in liboggplay/trunk: include/oggplay
src/liboggplay
shans at svn.annodex.net
shans at svn.annodex.net
Tue Jun 26 04:38:36 PDT 2007
Author: shans
Date: 2007-06-26 04:38:36 -0700 (Tue, 26 Jun 2007)
New Revision: 3065
Modified:
liboggplay/trunk/include/oggplay/oggplay_reader.h
liboggplay/trunk/src/liboggplay/Version_script.in
liboggplay/trunk/src/liboggplay/oggplay.c
liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c
liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.h
Log:
Added oggplay_get_duration function
Modified: liboggplay/trunk/include/oggplay/oggplay_reader.h
===================================================================
--- liboggplay/trunk/include/oggplay/oggplay_reader.h 2007-06-26 11:15:14 UTC (rev 3064)
+++ liboggplay/trunk/include/oggplay/oggplay_reader.h 2007-06-26 11:38:36 UTC (rev 3065)
@@ -54,6 +54,7 @@
int (*available)(struct _OggPlayReader *me,
ogg_int64_t current_bytes,
ogg_int64_t current_time);
+ double (*duration)(struct _OggPlayReader *me);
/* low-level io functions for oggz */
size_t (*io_read)(void *user_handle, void *buf, size_t n);
Modified: liboggplay/trunk/src/liboggplay/Version_script.in
===================================================================
--- liboggplay/trunk/src/liboggplay/Version_script.in 2007-06-26 11:15:14 UTC (rev 3064)
+++ liboggplay/trunk/src/liboggplay/Version_script.in 2007-06-26 11:38:36 UTC (rev 3065)
@@ -61,6 +61,7 @@
oggplay_seek;
oggplay_get_available;
+ oggplay_get_duration;
local:
*;
};
Modified: liboggplay/trunk/src/liboggplay/oggplay.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay.c 2007-06-26 11:15:14 UTC (rev 3064)
+++ liboggplay/trunk/src/liboggplay/oggplay.c 2007-06-26 11:38:36 UTC (rev 3065)
@@ -561,6 +561,16 @@
}
+double
+oggplay_get_duration(OggPlay *me) {
+
+ if (me == NULL) {
+ return E_OGGPLAY_BAD_OGGPLAY;
+ }
+
+ return me->reader->duration(me->reader);
+}
+
ogg_int64_t
oggplay_sys_time_in_ms(void) {
#ifdef WIN32
Modified: liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c 2007-06-26 11:15:14 UTC (rev 3064)
+++ liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.c 2007-06-26 11:38:36 UTC (rev 3065)
@@ -335,7 +335,10 @@
}
START_TIMEOUT(time_ref);
+ me->duration = -1;
while (1) {
+ char *dpos;
+
remaining = TCP_READER_MAX_IN_MEMORY - me->amount_in_memory;
#ifdef WIN32
nbytes = recv(me->socket, (char*)(me->buffer + me->amount_in_memory),
@@ -361,6 +364,12 @@
return E_OGGPLAY_END_OF_FILE;
}
me->buffer[me->amount_in_memory + nbytes] = '\0';
+
+ dpos = strstr((char *)me->buffer, "X-Content-Duration:");
+ if (dpos != NULL) {
+ me->duration = strtod(dpos + 20, NULL);
+ }
+
pos = strstr((char *)(me->buffer), "OggS");
if (pos != NULL) {
break;
@@ -370,6 +379,7 @@
strncmp((char *)me->buffer, "HTTP/1.0 200 OK", 15) != 0) {
return E_OGGPLAY_BAD_INPUT;
}
+
if (nbytes > 4) {
memmove(me->buffer, me->buffer + nbytes - 4, 4);
me->amount_in_memory = 4;
@@ -518,6 +528,12 @@
}
+double
+oggplay_tcp_reader_duration(OggPlayReader * opr) {
+ OggPlayTCPReader *me = (OggPlayTCPReader *)opr;
+ return me->duration;
+}
+
static size_t
oggplay_tcp_reader_io_read(void * user_handle, void * buf, size_t n) {
@@ -577,6 +593,7 @@
me->functions.destroy = &oggplay_tcp_reader_destroy;
me->functions.seek = NULL;
me->functions.available = &oggplay_tcp_reader_available;
+ me->functions.duration = &oggplay_tcp_reader_duration;
me->functions.io_read = &oggplay_tcp_reader_io_read;
me->functions.io_seek = &oggplay_tcp_reader_io_seek;
me->functions.io_tell = &oggplay_tcp_reader_io_tell;
Modified: liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.h
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.h 2007-06-26 11:15:14 UTC (rev 3064)
+++ liboggplay/trunk/src/liboggplay/oggplay_tcp_reader.h 2007-06-26 11:38:36 UTC (rev 3065)
@@ -80,6 +80,7 @@
FILE * backing_store;
int stored_offset;
dataLocation mode;
+ float duration;
} OggPlayTCPReader;
#endif
More information about the commits
mailing list