Commit 91a716f9 authored by Wim Taymans's avatar Wim Taymans
Browse files

- Changed plugins for new APIs

Original commit message from CVS:
- Changed plugins for new APIs
- modularized audiofile.
- added seeking, query and convert functions for mad, mpeg2dec,
avidemux, mpegdemux, mpegparse
- sync updates to oss. removed the ossclock for now
parent e9ddec5f
......@@ -350,7 +350,7 @@ gst_aasink_chain (GstPad *pad, GstBuffer *buf)
GST_DEBUG (0,"videosink: clock wait: %llu", GST_BUFFER_TIMESTAMP(buf));
if (aasink->clock) {
gst_element_clock_wait (GST_ELEMENT (aasink), aasink->clock, GST_BUFFER_TIMESTAMP(buf));
gst_element_clock_wait (GST_ELEMENT (aasink), aasink->clock, GST_BUFFER_TIMESTAMP(buf), NULL);
}
aa_render (aasink->context, &aasink->ascii_parms,
......
This diff is collapsed.
......@@ -43,60 +43,71 @@ extern "C" {
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AVI_DEMUX))
#define GST_AVI_DEMUX_UNKNOWN 0 /* initialized state */
#define GST_AVI_DEMUX_REGULAR 1 /* regular parsing */
#define GST_AVI_DEMUX_HDRL 2
#define GST_AVI_DEMUX_STRL 3
#define GST_AVI_DEMUX_MOVI 4
#define GST_AVI_DEMUX_AVIH 5
#define GST_AVI_DEMUX_STRH_VIDS 6
#define GST_AVI_DEMUX_STRH_AUDS 7
#define GST_AVI_DEMUX_STRH_IAVS 8
#define GST_AVI_DEMUX_MAX_AUDIO_PADS 8
#define GST_AVI_DEMUX_MAX_VIDEO_PADS 8
#define GST_AVI_DEMUX_MAX_STREAMS 16
#define CHUNKID_TO_STREAMNR(chunkid) \
(((GUINT32_FROM_BE (chunkid) >> 24) - '0') * 10 + \
((GUINT32_FROM_BE (chunkid) >> 16) & 0xff) - '0')
typedef struct _GstAviDemux GstAviDemux;
typedef struct _GstAviDemuxClass GstAviDemuxClass;
typedef struct
{
gint index_nr;
gint stream_nr;
guint64 ts;
guint32 flags;
guint32 offset;
gint size;
guint64 bytes_before;
guint32 frames_before;
} gst_avi_index_entry;
typedef struct
{
GstPad *pad;
gint num;
gst_riff_strh strh;
guint64 next_ts;
guint32 current_frame;
guint32 current_byte;
guint64 delay;
gboolean need_flush;
guint64 total_bytes;
gint32 total_frames;
guint32 skip;
} avi_stream_context;
struct _GstAviDemux {
GstElement element;
GstElement element;
/* pads */
GstPad *sinkpad,*srcpad;
GstPad *sinkpad, *srcpad;
/* AVI decoding state */
gint state;
guint32 fcc_type;
guint32 fcc_type;
GstByteStream *bs;
gint frame_rate;
gst_riff_index_entry *index_entries;
gulong index_size;
gulong index_offset;
gulong resync_offset;
guint64 next_time;
guint64 time_interval;
gulong tot_frames;
gulong current_frame;
gst_avi_index_entry *index_entries;
gulong index_size;
gulong index_offset;
guint32 flags;
guint32 init_audio;
guint32 audio_rate;
gst_riff_avih avih;
guint num_audio_pads;
guint num_video_pads;
guint num_iavs_pads;
GstPad *audio_pad[GST_AVI_DEMUX_MAX_AUDIO_PADS];
gboolean audio_need_flush[GST_AVI_DEMUX_MAX_AUDIO_PADS];
guint num_streams;
guint num_v_streams;
guint num_a_streams;
GstPad *video_pad[GST_AVI_DEMUX_MAX_VIDEO_PADS];
gboolean video_need_flush[GST_AVI_DEMUX_MAX_VIDEO_PADS];
avi_stream_context stream[GST_AVI_DEMUX_MAX_STREAMS];
gpointer extra_data;
gboolean seek_pending;
gint64 seek_offset;
guint64 last_seek;
};
struct _GstAviDemuxClass {
......
......@@ -789,16 +789,24 @@ gst_avimux_bigfile(GstAviMux *avimux, gboolean last)
if (avimux->is_bigfile)
{
/* sarch back */
event = gst_event_new_seek(GST_SEEK_BYTEOFFSET_SET, avimux->avix_start, TRUE);
gst_pad_send_event(avimux->srcpad, event);
/* rewrite AVIX header */
header = gst_avimux_riff_get_avix_header(avimux->datax_size);
gst_pad_push(avimux->srcpad, header);
/* go back to current location */
event = gst_event_new_seek(GST_SEEK_BYTEOFFSET_SET, avimux->total_data, TRUE);
gst_pad_send_event(avimux->srcpad, event);
event = gst_event_new_seek (GST_FORMAT_BYTES |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH,
avimux->avix_start);
/* if the event succeeds */
if (gst_pad_send_event(avimux->srcpad, event)) {
/* rewrite AVIX header */
header = gst_avimux_riff_get_avix_header(avimux->datax_size);
gst_pad_push(avimux->srcpad, header);
/* go back to current location */
event = gst_event_new_seek (GST_FORMAT_BYTES |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH,
avimux->total_data);
gst_pad_send_event(avimux->srcpad, event);
}
}
avimux->avix_start = avimux->total_data;
......@@ -884,7 +892,9 @@ gst_avimux_stop_file (GstAviMux *avimux)
/* seek and rewrite the header */
header = gst_avimux_riff_get_avi_header(avimux);
event = gst_event_new_seek(GST_SEEK_BYTEOFFSET_SET, 0, TRUE);
event = gst_event_new_seek (GST_FORMAT_BYTES |
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, 0);
gst_pad_send_event(avimux->srcpad, event);
gst_pad_push(avimux->srcpad, header);
......
......@@ -50,7 +50,7 @@ static void gst_osssink_close_audio (GstOssSink *sink);
static gboolean gst_osssink_sync_parms (GstOssSink *osssink);
static GstElementStateReturn gst_osssink_change_state (GstElement *element);
static void gst_osssink_set_clock (GstElement *element, GstClock *clock);
static GstClock* gst_osssink_get_clock (GstElement *element);
//static GstClock* gst_osssink_get_clock (GstElement *element);
static GstPadConnectReturn gst_osssink_sinkconnect (GstPad *pad, GstCaps *caps);
......@@ -217,35 +217,6 @@ gst_osssink_class_init (GstOssSinkClass *klass)
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_osssink_change_state);
}
static GstClockTime
gst_osssink_get_time (GstClock *clock, gpointer data)
{
GstOssSink *osssink = GST_OSSSINK (data);
gint delay;
GstClockTime res;
if (!osssink->bps)
return 0;
ioctl (osssink->fd, SNDCTL_DSP_GETODELAY, &delay);
/* sometimes delay is bigger than the number of bytes sent to the device, which screws
* up this calculation, we assume that everything is still in the device then */
if (delay > osssink->handled) {
res = osssink->offset;
}
else {
res = osssink->offset + (osssink->handled - delay) * 1000000LL / osssink->bps;
}
/*
g_print ("from osssink: %lld %lld %d %lld %d\n", res, osssink->offset, delay, osssink->handled,
osssink->bps);
*/
return res;
}
static void
gst_osssink_init (GstOssSink *osssink)
{
......@@ -268,19 +239,13 @@ gst_osssink_init (GstOssSink *osssink)
#else
osssink->format = AFMT_S16_LE;
#endif /* WORDS_BIGENDIAN */
/* gst_clock_register (osssink->clock, GST_OBJECT (osssink)); */
osssink->bufsize = 4096;
osssink->bps = 0;
osssink->offset = 0LL;
osssink->handled = 0LL;
osssink->resync = FALSE;
/* 6 buffers per chunk by default */
osssink->sinkpool = gst_buffer_pool_get_default (osssink->bufsize, 6);
osssink->provided_clock = NULL;
osssink->provided_clock = GST_CLOCK (gst_oss_clock_new ("ossclock", gst_osssink_get_time, osssink));
GST_ELEMENT (osssink)->setclockfunc = gst_osssink_set_clock;
GST_ELEMENT (osssink)->getclockfunc = gst_osssink_get_clock;
GST_FLAG_SET (osssink, GST_ELEMENT_THREAD_SUGGESTED);
GST_FLAG_SET (osssink, GST_ELEMENT_EVENT_AWARE);
......@@ -427,16 +392,6 @@ gst_osssink_sync_parms (GstOssSink *osssink)
return TRUE;
}
static GstClock*
gst_osssink_get_clock (GstElement *element)
{
GstOssSink *osssink;
osssink = GST_OSSSINK (element);
return GST_CLOCK (osssink->provided_clock);
}
static void
gst_osssink_set_clock (GstElement *element, GstClock *clock)
{
......@@ -457,53 +412,68 @@ gst_osssink_chain (GstPad *pad, GstBuffer *buf)
osssink = GST_OSSSINK (gst_pad_get_parent (pad));
if (GST_IS_EVENT (buf)) {
switch (GST_EVENT_TYPE (buf)) {
GstEvent *event = GST_EVENT (buf);
//gint64 offset;
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
ioctl (osssink->fd, SNDCTL_DSP_SYNC);
gst_pad_event_default (pad, GST_EVENT (buf));
gst_pad_event_default (pad, event);
return;
case GST_EVENT_NEW_MEDIA:
g_print ("new media\n");
return;
case GST_EVENT_DISCONTINUOUS:
{
gint64 value;
ioctl (osssink->fd, SNDCTL_DSP_RESET);
if (gst_event_discont_get_value (event, GST_FORMAT_TIME, &value)) {
gst_clock_handle_discont (osssink->clock, value);
}
osssink->resync = TRUE;
return;
}
default:
gst_pad_event_default (pad, event);
return;
}
gst_event_free (event);
}
buftime = GST_BUFFER_TIMESTAMP (buf);
if (!osssink->bps) {
gst_buffer_unref (buf);
gst_element_error (GST_ELEMENT (osssink), "capsnego was never performed, unknown data type");
return;
}
buftime = GST_BUFFER_TIMESTAMP (buf);
if (osssink->fd >= 0) {
if (!osssink->mute) {
guchar *data = GST_BUFFER_DATA (buf);
gint size = GST_BUFFER_SIZE (buf);
/* gint frag = osssink->fragment; <-- unused, for reason see above */
if (osssink->clock) {
/* FIXME, NEW_MEDIA/DISCONT?. Try to get our start point */
if (!osssink->have_offset && buftime != -1LL) {
GST_INFO (GST_CAT_PLUGIN_INFO,
"osssink: clock at offset: %lld, new offset %lld at time %lld\n",
osssink->offset, buftime, gst_clock_get_time (osssink->clock));
osssink->offset = buftime;
osssink->have_offset = TRUE;
osssink->handled = 0;
gst_element_clock_wait (GST_ELEMENT (osssink), osssink->clock, buftime);
gint delay;
gint64 queued;
GstClockTimeDiff jitter;
ioctl (osssink->fd, SNDCTL_DSP_GETODELAY, &delay);
queued = delay * GST_SECOND / osssink->bps;
if (osssink->resync) {
gst_element_clock_wait (GST_ELEMENT (osssink), osssink->clock,
buftime - queued, &jitter);
if (jitter > 0) {
write (osssink->fd, data, size);
osssink->resync = FALSE;
}
}
else {
write (osssink->fd, data, size);
}
/* this doesn't work on BE machines, apparently
while (size) {
gint tosend = MIN (size, frag);
write (osssink->fd, data, tosend);
data += tosend;
size -= tosend;
osssink->handled += tosend;
} */
write (osssink->fd, data, size);
osssink->handled += size;
}
/* no clock, try to be as fast as possible */
else {
......@@ -514,7 +484,6 @@ gst_osssink_chain (GstPad *pad, GstBuffer *buf)
if (ospace.bytes >= size) {
write (osssink->fd, data, size);
}
osssink->handled += size;
}
}
}
......@@ -708,11 +677,8 @@ gst_osssink_change_state (GstElement *element)
}
break;
case GST_STATE_READY_TO_PAUSED:
osssink->offset = 0LL;
osssink->have_offset = FALSE;
osssink->handled = 0LL;
break;
case GST_STATE_PAUSED_TO_PLAYING:
osssink->resync = TRUE;
break;
case GST_STATE_PLAYING_TO_PAUSED:
{
......
......@@ -63,6 +63,7 @@ struct _GstOssSink {
GstClock *provided_clock;
GstClock *clock;
gboolean resync;
/* device */
gchar *device;
......@@ -77,9 +78,6 @@ struct _GstOssSink {
gboolean mute;
guint bufsize;
guint bps;
gboolean have_offset;
guint64 offset;
guint64 handled;
guint64 fragment_time;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment