mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-08 18:39:54 +00:00
5d25c00e4b
Original commit message from CVS: gst-indent
113 lines
2 KiB
C
113 lines
2 KiB
C
#ifdef HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
|
|
#include "gstmikmod.h"
|
|
|
|
extern int need_sync;
|
|
|
|
static BOOL GST_READER_Eof (MREADER * reader);
|
|
static BOOL GST_READER_Read (MREADER * reader, void *ptr, size_t size);
|
|
static int GST_READER_Get (MREADER * reader);
|
|
static BOOL GST_READER_Seek (MREADER * reader, long offset, int whence);
|
|
static long GST_READER_Tell (MREADER * reader);
|
|
|
|
|
|
static BOOL
|
|
GST_READER_Eof (MREADER * reader)
|
|
{
|
|
GST_READER *gst_reader;
|
|
|
|
gst_reader = (GST_READER *) reader;
|
|
|
|
return gst_reader->eof;
|
|
}
|
|
|
|
|
|
static BOOL
|
|
GST_READER_Read (MREADER * reader, void *ptr, size_t size)
|
|
{
|
|
GST_READER *gst_reader;
|
|
|
|
gst_reader = (GST_READER *) reader;
|
|
|
|
memcpy (ptr, GST_BUFFER_DATA (gst_reader->mik->Buffer) + gst_reader->offset,
|
|
size);
|
|
gst_reader->offset = gst_reader->offset + size;
|
|
|
|
return 1;
|
|
}
|
|
|
|
|
|
static int
|
|
GST_READER_Get (MREADER * reader)
|
|
{
|
|
GST_READER *gst_reader;
|
|
int res;
|
|
|
|
gst_reader = (GST_READER *) reader;
|
|
|
|
res = *(GST_BUFFER_DATA (gst_reader->mik->Buffer) + gst_reader->offset);
|
|
gst_reader->offset += 1;
|
|
|
|
return res;
|
|
}
|
|
|
|
|
|
static BOOL
|
|
GST_READER_Seek (MREADER * reader, long offset, int whence)
|
|
{
|
|
GST_READER *gst_reader;
|
|
|
|
gst_reader = (GST_READER *) reader;
|
|
|
|
if (whence == SEEK_SET)
|
|
gst_reader->offset = offset;
|
|
else
|
|
gst_reader->offset += offset;
|
|
|
|
return 1;
|
|
}
|
|
|
|
|
|
static long
|
|
GST_READER_Tell (MREADER * reader)
|
|
{
|
|
GST_READER *gst_reader;
|
|
|
|
gst_reader = (GST_READER *) reader;
|
|
|
|
return gst_reader->offset;
|
|
}
|
|
|
|
|
|
MREADER *
|
|
GST_READER_new (GstMikMod * mik)
|
|
{
|
|
GST_READER *gst_reader;
|
|
|
|
gst_reader = (GST_READER *) g_malloc (sizeof (GST_READER));
|
|
gst_reader->offset = 0;
|
|
gst_reader->eof = 0;
|
|
gst_reader->mik = mik;
|
|
if (gst_reader) {
|
|
gst_reader->core.Eof = &GST_READER_Eof;
|
|
gst_reader->core.Read = &GST_READER_Read;
|
|
gst_reader->core.Get = &GST_READER_Get;
|
|
gst_reader->core.Seek = &GST_READER_Seek;
|
|
gst_reader->core.Tell = &GST_READER_Tell;
|
|
}
|
|
|
|
return (MREADER *) gst_reader;
|
|
}
|
|
|
|
|
|
void
|
|
GST_READER_free (MREADER * reader)
|
|
{
|
|
if (reader)
|
|
g_free (reader);
|
|
}
|