[xiph-commits] r3073 - liboggplay/trunk/plugin
tahn at svn.annodex.net
tahn at svn.annodex.net
Tue Jun 26 18:54:30 PDT 2007
Author: tahn
Date: 2007-06-26 18:54:30 -0700 (Tue, 26 Jun 2007)
New Revision: 3073
Modified:
liboggplay/trunk/plugin/plugin.cpp
liboggplay/trunk/plugin/plugin_oggplay.c
liboggplay/trunk/plugin/plugin_oggplay.h
Log:
Get duration and buffered time.
Modified: liboggplay/trunk/plugin/plugin.cpp
===================================================================
--- liboggplay/trunk/plugin/plugin.cpp 2007-06-27 01:51:14 UTC (rev 3072)
+++ liboggplay/trunk/plugin/plugin.cpp 2007-06-27 01:54:30 UTC (rev 3073)
@@ -631,6 +631,7 @@
bool
nsPluginInstance::setPlayPosition(long milliseconds) {
+printf("-- seek to %ld --\n", milliseconds);//!
return set_oggplay_play_position(mOggHandle, milliseconds);
}
@@ -661,14 +662,12 @@
long
nsPluginInstance::getBufferedTime() {
-//!todo
- return 0;
+ return get_oggplay_available(mOggHandle);
}
long
nsPluginInstance::getMovieLength() {
-//!todo
- return 0;
+ return get_oggplay_duration(mOggHandle);
}
char *
Modified: liboggplay/trunk/plugin/plugin_oggplay.c
===================================================================
--- liboggplay/trunk/plugin/plugin_oggplay.c 2007-06-27 01:51:14 UTC (rev 3072)
+++ liboggplay/trunk/plugin/plugin_oggplay.c 2007-06-27 01:54:30 UTC (rev 3073)
@@ -81,6 +81,9 @@
int video_rate;
int audio_channels;
int callback_period;
+ int reference_track;
+ int duration;
+ int available;
} PluginPointers;
int get_audio_rate(void *ptrs) {
@@ -205,6 +208,17 @@
}
#endif
+ pointers->duration = oggplay_get_duration(pointers->player);
+
+ /*
+ * There are certain bits of info that the caller thinks of as applying
+ * to the ogg media stream as a whole, but are actually different for each
+ * track (for example, the audio track can reach end-of-stream before the
+ * video track). So we need to choose one of the tracks as a reference, and
+ * treat its status as representative of the whole media stream.
+ */
+ pointers->reference_track = (video_track != -1) ? video_track : audio_track;
+
printf("video rate: %f audio rate: %d audio channels: %d callback pd: %f\n",
pointers->video_rate / 65536.0, pointers->audio_rate,
pointers->audio_channels, pointers->callback_period/65536.0);
@@ -226,7 +240,7 @@
}
r = oggplay_step_decoding(pointers->player);
-
+ pointers->available = oggplay_get_available(pointers->player);
}
if (r != E_OGGPLAY_CONTINUE && r != E_OGGPLAY_USER_INTERRUPT) {
@@ -274,6 +288,9 @@
pointers->audio_rate = 0;
pointers->audio_channels = 0;
pointers->callback_period = 0;
+ pointers->reference_track = -1;
+ pointers->duration = -1;
+ pointers->available = -1;
pointers->seek_flag = 0;
pointers->seek_pos = 0;
@@ -490,34 +507,19 @@
}
-
OggPlayStreamInfo
get_oggplay_stream_info(void *handle, PluginOggFrame *frame_data) {
PluginPointers * pointers = (PluginPointers *)handle;
OggPlayCallbackInfo ** track_info = frame_data->oggplay_info;
- OggPlayDataType data_type;
- int i;
+ int ref_track = pointers->reference_track;
- if (track_info == NULL) {
+ if (track_info == NULL || ref_track == -1) {
return E_OGGPLAY_BAD_CALLBACK_INFO;
}
-
- /*
- * Use the video track if it's present, otherwise use audio.
- */
- data_type =
- (pointers->video_rate > 0) ? OGGPLAY_YUV_VIDEO : OGGPLAY_FLOATS_AUDIO;
-
- for (i = 0; i < oggplay_get_num_tracks(pointers->player); i++) {
- if (oggplay_callback_info_get_type(track_info[i]) == data_type) {
- return oggplay_callback_info_get_stream_info(track_info[i]);
- }
- }
- return E_OGGPLAY_BAD_CALLBACK_INFO;
+ return oggplay_callback_info_get_stream_info(track_info[ref_track]);
}
-
/**
* Scripting, dude, ... scripting
*/
@@ -545,3 +547,14 @@
}
return (pointers->seek_err == E_OGGPLAY_OK);
}
+
+int
+get_oggplay_available(void *handle) {
+ return ((PluginPointers *)handle)->available;
+}
+
+int
+get_oggplay_duration(void *handle) {
+ return ((PluginPointers *)handle)->duration;
+}
+
Modified: liboggplay/trunk/plugin/plugin_oggplay.h
===================================================================
--- liboggplay/trunk/plugin/plugin_oggplay.h 2007-06-27 01:51:14 UTC (rev 3072)
+++ liboggplay/trunk/plugin/plugin_oggplay.h 2007-06-27 01:54:30 UTC (rev 3073)
@@ -89,6 +89,12 @@
int
set_oggplay_play_position(void *handle, long milliseconds);
+int
+get_oggplay_available(void *handle);
+
+int
+get_oggplay_duration(void *handle);
+
int get_audio_rate(void *ptrs);
int get_audio_channels(void *ptrs);
int get_video_rate(void *ptrs);
More information about the commits
mailing list