mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 02:31:03 +00:00
this works for me locally now, however it requires:
Original commit message from CVS: this works for me locally now, however it requires: - my local fix to implement gst_bytestream_tell (which I won't commit until events are redone) - an audiofile patch which is already in debian but don't hold your breath for an upstream release
This commit is contained in:
parent
a175fe373c
commit
5c1e5be283
1 changed files with 65 additions and 36 deletions
|
@ -136,7 +136,7 @@ gst_afparse_class_init (GstAFParseClass *klass)
|
||||||
gobject_class->set_property = gst_afparse_set_property;
|
gobject_class->set_property = gst_afparse_set_property;
|
||||||
gobject_class->get_property = gst_afparse_get_property;
|
gobject_class->get_property = gst_afparse_get_property;
|
||||||
|
|
||||||
gstelement_class->change_state = gst_afparse_change_state;
|
/* gstelement_class->change_state = gst_afparse_change_state;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -186,12 +186,13 @@ gst_afparse_loop(GstElement *element)
|
||||||
|
|
||||||
afparse = GST_AFPARSE(element);
|
afparse = GST_AFPARSE(element);
|
||||||
|
|
||||||
|
afparse->vfile->closure = gst_bytestream_new(afparse->sinkpad);
|
||||||
|
if (gst_afparse_open_file (afparse)){
|
||||||
frames_to_bytes = afparse->channels * afparse->width / 8;
|
frames_to_bytes = afparse->channels * afparse->width / 8;
|
||||||
frames_per_read = afparse->frames_per_read;
|
frames_per_read = afparse->frames_per_read;
|
||||||
bytes_per_read = frames_per_read * frames_to_bytes;
|
bytes_per_read = frames_per_read * frames_to_bytes;
|
||||||
|
|
||||||
bufpool = gst_buffer_pool_get_default (bytes_per_read, 8);
|
bufpool = gst_buffer_pool_get_default (bytes_per_read, 8);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
buf = gst_buffer_new_from_pool (bufpool, 0, 0);
|
buf = gst_buffer_new_from_pool (bufpool, 0, 0);
|
||||||
GST_BUFFER_TIMESTAMP(buf) = afparse->timestamp;
|
GST_BUFFER_TIMESTAMP(buf) = afparse->timestamp;
|
||||||
|
@ -213,9 +214,11 @@ gst_afparse_loop(GstElement *element)
|
||||||
afparse->timestamp += numframes * 1E9 / afparse->rate;
|
afparse->timestamp += numframes * 1E9 / afparse->rate;
|
||||||
}
|
}
|
||||||
while (TRUE);
|
while (TRUE);
|
||||||
|
gst_afparse_close_file (afparse);
|
||||||
|
gst_buffer_pool_unref(bufpool);
|
||||||
|
}
|
||||||
|
|
||||||
gst_bytestream_destroy((GstByteStream*)afparse->vfile->closure);
|
gst_bytestream_destroy((GstByteStream*)afparse->vfile->closure);
|
||||||
gst_buffer_pool_unref(bufpool);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,7 +343,6 @@ gst_afparse_open_file (GstAFParse *afparse)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (!GST_FLAG_IS_SET (afparse, GST_AFPARSE_OPEN), FALSE);
|
g_return_val_if_fail (!GST_FLAG_IS_SET (afparse, GST_AFPARSE_OPEN), FALSE);
|
||||||
|
|
||||||
afparse->vfile->closure = gst_bytestream_new(afparse->srcpad);
|
|
||||||
|
|
||||||
/* open the file */
|
/* open the file */
|
||||||
g_print("opening vfile %p\n", afparse->vfile);
|
g_print("opening vfile %p\n", afparse->vfile);
|
||||||
|
@ -454,16 +456,28 @@ gst_afparse_vf_read (AFvirtualfile *vfile, void *data, size_t nbytes)
|
||||||
{
|
{
|
||||||
GstByteStream *bs = (GstByteStream*)vfile->closure;
|
GstByteStream *bs = (GstByteStream*)vfile->closure;
|
||||||
guint8 *bytes;
|
guint8 *bytes;
|
||||||
g_print("doing read\n");
|
GstEvent *event = NULL;
|
||||||
bytes = gst_bytestream_peek_bytes(bs, nbytes);
|
guint32 waiting;
|
||||||
if (!bytes){
|
gchar *debug_bytes;
|
||||||
/* handle events */
|
|
||||||
|
|
||||||
return 0;
|
while (!(bytes = gst_bytestream_peek_bytes(bs, nbytes))){
|
||||||
|
/* handle events */
|
||||||
|
gst_bytestream_get_status (bs, &waiting, &event);
|
||||||
|
|
||||||
|
if (!event) return 0;
|
||||||
|
if (event){
|
||||||
|
if (GST_EVENT_TYPE(event) == GST_EVENT_EOS) return 0;
|
||||||
|
if (GST_EVENT_TYPE(event) == GST_EVENT_DISCONTINUOUS){
|
||||||
|
g_print("seek done\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memcpy(data, bytes, nbytes);
|
||||||
gst_bytestream_flush_fast(bs, nbytes);
|
gst_bytestream_flush_fast(bs, nbytes);
|
||||||
data = bytes;
|
|
||||||
|
/*g_print("read %d bytes\n", nbytes);*/
|
||||||
|
|
||||||
return nbytes;
|
return nbytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,10 +486,23 @@ gst_afparse_vf_seek (AFvirtualfile *vfile, long offset, int is_relative)
|
||||||
{
|
{
|
||||||
GstByteStream *bs = (GstByteStream*)vfile->closure;
|
GstByteStream *bs = (GstByteStream*)vfile->closure;
|
||||||
GstSeekType type;
|
GstSeekType type;
|
||||||
|
guint64 current_offset = gst_bytestream_tell(bs);
|
||||||
|
|
||||||
|
if (!is_relative){
|
||||||
|
if ((guint64)offset == current_offset) {
|
||||||
|
/* this seems to happen before every read - bad audiofile */
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
type = GST_SEEK_BYTEOFFSET_SET;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (offset == 0) return current_offset;
|
||||||
|
type = GST_SEEK_BYTEOFFSET_CUR;
|
||||||
|
}
|
||||||
|
|
||||||
g_print("doing seek\n");
|
|
||||||
type = is_relative ? GST_SEEK_BYTEOFFSET_CUR : GST_SEEK_BYTEOFFSET_SET;
|
|
||||||
if (gst_bytestream_seek(bs, type, (gint64)offset)){
|
if (gst_bytestream_seek(bs, type, (gint64)offset)){
|
||||||
|
g_print("doing seek to %d\n", (gint)offset);
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -510,10 +537,12 @@ gst_afparse_vf_destroy(AFvirtualfile *vfile)
|
||||||
static long
|
static long
|
||||||
gst_afparse_vf_tell (AFvirtualfile *vfile)
|
gst_afparse_vf_tell (AFvirtualfile *vfile)
|
||||||
{
|
{
|
||||||
/*GstByteStream *bs = (GstByteStream*)vfile->closure;*/
|
GstByteStream *bs = (GstByteStream*)vfile->closure;
|
||||||
g_print("doing tell\n");
|
guint64 offset;
|
||||||
/* return gst_bytestream_tell(bs);*/
|
|
||||||
return 0;
|
offset = gst_bytestream_tell(bs);
|
||||||
|
g_print("doing tell: %llu\n", offset);
|
||||||
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstCaps*
|
static GstCaps*
|
||||||
|
|
Loading…
Reference in a new issue