Commit 03cbef5c authored by Ronald S. Bultje's avatar Ronald S. Bultje

ext/ffmpeg/: Do some more random property setting. Fix for if there's less...

ext/ffmpeg/: Do some more random property setting. Fix for if there's less than ffmpeg-default-buffersize (32kB) data...

Original commit message from CVS:
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps),
(gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_read):
Do some more random property setting. Fix for if there's less than
ffmpeg-default-buffersize (32kB) data in a file _and_ there's an
event pending. Partially fixes #142320.
parent bc0e141e
2004-06-13 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps),
(gst_ffmpeg_caps_to_codecid):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_read):
Do some more random property setting. Fix for if there's less than
ffmpeg-default-buffersize (32kB) data in a file _and_ there's an
event pending. Partially fixes #142320.
2004-06-06 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
......
common @ 1af22afd
Subproject commit cf0828313f7cea4d5840c0959e9113f13309a56f
Subproject commit 1af22afdec71295108f882c828e08f10d8a3e94b
......@@ -681,11 +681,24 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
case CODEC_TYPE_AUDIO:
mime = g_strdup_printf ("audio/x-gst_ff-%s", codec->name);
caps = GST_FF_AUD_CAPS_NEW (mime, NULL);
if (context)
gst_caps_set (caps, "block_align", context->block_align,
"bitrate", context->bit_rate, NULL);
g_free (mime);
break;
default:
break;
}
/* set private data */
if (context && context->extradata_size > 0) {
GstBuffer *data = gst_buffer_new_and_alloc (context->extradata_size);
memcpy (GST_BUFFER_DATA (data), context->extradata,
context->extradata_size);
gst_caps_set_simple (caps,
"gst_ff_extradata", GST_TYPE_BUFFER, data, NULL);
}
}
}
......@@ -1614,11 +1627,26 @@ gst_ffmpeg_caps_to_codecid (const GstCaps * caps, AVCodecContext * context)
sscanf (mimetype, "%*s/x-gst_ff-%s", ext) == 1) {
if ((codec = avcodec_find_decoder_by_name (ext)) ||
(codec = avcodec_find_encoder_by_name (ext))) {
const GValue *data_v;
const GstBuffer *data;
id = codec->id;
if (mimetype[0] == 'v')
video = TRUE;
else if (mimetype[0] == 'a')
audio = TRUE;
/* extradata */
if ((data_v = gst_structure_get_value (structure,
"gst_ff_extradata")) && context) {
data = g_value_get_boxed (data_v);
if (context->extradata)
av_free (context->extradata);
context->extradata = av_malloc (GST_BUFFER_SIZE (data));
memcpy (context->extradata, GST_BUFFER_DATA (data),
GST_BUFFER_SIZE (data));
context->extradata_size = GST_BUFFER_SIZE (data);
}
}
}
}
......
......@@ -95,6 +95,7 @@ gst_ffmpegdata_read (URLContext * h, unsigned char *buf, int size)
guint32 total, request;
guint8 *data;
GstProtocolInfo *info;
gboolean have_event;
info = (GstProtocolInfo *) h->priv_data;
......@@ -106,6 +107,8 @@ gst_ffmpegdata_read (URLContext * h, unsigned char *buf, int size)
return 0;
do {
have_event = FALSE;
/* prevent EOS */
if (gst_bytestream_tell (bs) + size > gst_bytestream_length (bs)) {
request = (int) (gst_bytestream_length (bs) - gst_bytestream_tell (bs));
......@@ -130,7 +133,7 @@ gst_ffmpegdata_read (URLContext * h, unsigned char *buf, int size)
g_warning ("gstffmpegprotocol: no bytestream event");
return total;
}
have_event = TRUE;
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_DISCONTINUOUS:
gst_bytestream_flush_fast (bs, remaining);
......@@ -139,6 +142,7 @@ gst_ffmpegdata_read (URLContext * h, unsigned char *buf, int size)
case GST_EVENT_EOS:
g_warning ("Unexpected/unwanted eos in data function");
info->eos = TRUE;
have_event = FALSE;
gst_event_unref (event);
break;
default:
......@@ -146,7 +150,7 @@ gst_ffmpegdata_read (URLContext * h, unsigned char *buf, int size)
break;
}
}
} while (!info->eos && total != request);
} while ((!info->eos && total != request) || have_event);
memcpy (buf, data, total);
gst_bytestream_flush_fast (bs, total);
......
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