2002-11-06 23:53:46 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
ext/ffmpeg/: Welcome the demuxers to 0.10 :)
Original commit message from CVS:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_init), (gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_handle_seek), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_add), (gst_ffmpegdemux_open),
(gst_ffmpegdemux_loop), (gst_ffmpegdemux_sink_activate),
(gst_ffmpegdemux_sink_activate_pull),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_read),
(gst_ffmpegdata_write), (gst_ffmpegdata_seek),
(gst_ffmpegdata_close):
Welcome the demuxers to 0.10 :)
For the time being the demuxers work only pull-based.
Seeking, querying works.
2006-02-10 19:42:19 +00:00
|
|
|
* <2006> Edward Hervey <bilboed@bilboed.com>
|
2002-11-06 23:53:46 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-04 00:22:16 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2002-11-06 23:53:46 +00:00
|
|
|
*/
|
|
|
|
|
2004-01-12 04:15:46 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2002-11-06 23:53:46 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
2012-09-10 15:08:00 +00:00
|
|
|
|
2008-10-30 12:05:45 +00:00
|
|
|
#include <libavformat/avformat.h>
|
2002-11-26 14:50:05 +00:00
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2012-09-10 15:53:54 +00:00
|
|
|
#include "gstav.h"
|
2012-12-22 09:49:52 +00:00
|
|
|
#include "gstavprotocol.h"
|
2002-11-06 23:53:46 +00:00
|
|
|
|
|
|
|
typedef struct _GstProtocolInfo GstProtocolInfo;
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
struct _GstProtocolInfo
|
|
|
|
{
|
|
|
|
GstPad *pad;
|
2002-11-06 23:53:46 +00:00
|
|
|
|
ext/ffmpeg/: Welcome the demuxers to 0.10 :)
Original commit message from CVS:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_init), (gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_handle_seek), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_add), (gst_ffmpegdemux_open),
(gst_ffmpegdemux_loop), (gst_ffmpegdemux_sink_activate),
(gst_ffmpegdemux_sink_activate_pull),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_read),
(gst_ffmpegdata_write), (gst_ffmpegdata_seek),
(gst_ffmpegdata_close):
Welcome the demuxers to 0.10 :)
For the time being the demuxers work only pull-based.
Seeking, querying works.
2006-02-10 19:42:19 +00:00
|
|
|
guint64 offset;
|
2004-03-29 16:39:18 +00:00
|
|
|
gboolean eos;
|
ext/ffmpeg/: Welcome the demuxers to 0.10 :)
Original commit message from CVS:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_init), (gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_handle_seek), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_add), (gst_ffmpegdemux_open),
(gst_ffmpegdemux_loop), (gst_ffmpegdemux_sink_activate),
(gst_ffmpegdemux_sink_activate_pull),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_read),
(gst_ffmpegdata_write), (gst_ffmpegdata_seek),
(gst_ffmpegdata_close):
Welcome the demuxers to 0.10 :)
For the time being the demuxers work only pull-based.
Seeking, querying works.
2006-02-10 19:42:19 +00:00
|
|
|
gint set_streamheader;
|
2002-11-06 23:53:46 +00:00
|
|
|
};
|
|
|
|
|
2004-03-29 16:39:18 +00:00
|
|
|
static int
|
2012-12-12 12:09:32 +00:00
|
|
|
gst_ffmpegdata_peek (void *priv_data, unsigned char *buf, int size)
|
2002-11-06 23:53:46 +00:00
|
|
|
{
|
|
|
|
GstProtocolInfo *info;
|
ext/ffmpeg/: Welcome the demuxers to 0.10 :)
Original commit message from CVS:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_init), (gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_handle_seek), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_add), (gst_ffmpegdemux_open),
(gst_ffmpegdemux_loop), (gst_ffmpegdemux_sink_activate),
(gst_ffmpegdemux_sink_activate_pull),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_read),
(gst_ffmpegdata_write), (gst_ffmpegdata_seek),
(gst_ffmpegdata_close):
Welcome the demuxers to 0.10 :)
For the time being the demuxers work only pull-based.
Seeking, querying works.
2006-02-10 19:42:19 +00:00
|
|
|
GstBuffer *inbuf = NULL;
|
2006-02-12 16:47:50 +00:00
|
|
|
GstFlowReturn ret;
|
ext/ffmpeg/: gst-indent cleanup.
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.c: (gst_ffmpeg_avcodec_open),
(gst_ffmpeg_avcodec_close), (gst_ffmpeg_av_find_stream_info),
(gst_ffmpeg_log_callback), (plugin_init):
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context), (gst_ffmpeg_cfg_finalize):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_save_incoming_values),
(gst_ffmpegdec_get_best_values), (gst_ffmpegdec_video_frame):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_src_query):
* ext/ffmpeg/gstffmpegenc.c: (ffmpegenc_setup_working_buf),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_flush_buffers):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_read),
(gst_ffmpegdata_write), (gst_ffmpegdata_seek),
(gst_ffmpegdata_close):
gst-indent cleanup.
2007-11-03 16:14:53 +00:00
|
|
|
int total = 0;
|
|
|
|
|
2012-12-12 12:09:32 +00:00
|
|
|
info = (GstProtocolInfo *) priv_data;
|
2003-06-08 14:35:32 +00:00
|
|
|
|
2009-05-09 08:57:55 +00:00
|
|
|
GST_DEBUG ("Pulling %d bytes at position %" G_GUINT64_FORMAT, size,
|
|
|
|
info->offset);
|
ext/ffmpeg/gstffmpegdemux.c: Rework the demuxer, implement all seeking stuff including seek in ready.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_class_init), (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_push_event),
(gst_ffmpegdemux_set_flags), (gst_ffmpegdemux_is_eos),
(gst_ffmpegdemux_do_seek), (gst_ffmpegdemux_perform_seek),
(gst_ffmpegdemux_src_event), (gst_ffmpegdemux_send_event),
(gst_ffmpegdemux_src_query), (gst_ffmpegdemux_src_convert),
(gst_ffmpegdemux_get_stream), (my_safe_copy),
(gst_ffmpegdemux_read_tags), (gst_ffmpegdemux_open),
(gst_ffmpegdemux_loop), (gst_ffmpegdemux_sink_activate),
(gst_ffmpegdemux_sink_activate_pull),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
Rework the demuxer, implement all seeking stuff including
seek in ready.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_peek),
(gst_ffmpegdata_close):
Handle some more cases.
2006-04-13 16:22:53 +00:00
|
|
|
|
ext/ffmpeg/: gst-indent cleanup.
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.c: (gst_ffmpeg_avcodec_open),
(gst_ffmpeg_avcodec_close), (gst_ffmpeg_av_find_stream_info),
(gst_ffmpeg_log_callback), (plugin_init):
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context), (gst_ffmpeg_cfg_finalize):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_save_incoming_values),
(gst_ffmpegdec_get_best_values), (gst_ffmpegdec_video_frame):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_src_query):
* ext/ffmpeg/gstffmpegenc.c: (ffmpegenc_setup_working_buf),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_flush_buffers):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_read),
(gst_ffmpegdata_write), (gst_ffmpegdata_seek),
(gst_ffmpegdata_close):
gst-indent cleanup.
2007-11-03 16:14:53 +00:00
|
|
|
ret = gst_pad_pull_range (info->pad, info->offset, (guint) size, &inbuf);
|
2006-02-12 16:47:50 +00:00
|
|
|
|
ext/ffmpeg/gstffmpegdemux.c: Rework the demuxer, implement all seeking stuff including seek in ready.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_class_init), (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_push_event),
(gst_ffmpegdemux_set_flags), (gst_ffmpegdemux_is_eos),
(gst_ffmpegdemux_do_seek), (gst_ffmpegdemux_perform_seek),
(gst_ffmpegdemux_src_event), (gst_ffmpegdemux_send_event),
(gst_ffmpegdemux_src_query), (gst_ffmpegdemux_src_convert),
(gst_ffmpegdemux_get_stream), (my_safe_copy),
(gst_ffmpegdemux_read_tags), (gst_ffmpegdemux_open),
(gst_ffmpegdemux_loop), (gst_ffmpegdemux_sink_activate),
(gst_ffmpegdemux_sink_activate_pull),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
Rework the demuxer, implement all seeking stuff including
seek in ready.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_peek),
(gst_ffmpegdata_close):
Handle some more cases.
2006-04-13 16:22:53 +00:00
|
|
|
switch (ret) {
|
|
|
|
case GST_FLOW_OK:
|
2011-04-04 10:23:05 +00:00
|
|
|
total = (gint) gst_buffer_get_size (inbuf);
|
|
|
|
gst_buffer_extract (inbuf, 0, buf, total);
|
2006-02-12 16:47:50 +00:00
|
|
|
gst_buffer_unref (inbuf);
|
ext/ffmpeg/gstffmpegdemux.c: Rework the demuxer, implement all seeking stuff including seek in ready.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_class_init), (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_push_event),
(gst_ffmpegdemux_set_flags), (gst_ffmpegdemux_is_eos),
(gst_ffmpegdemux_do_seek), (gst_ffmpegdemux_perform_seek),
(gst_ffmpegdemux_src_event), (gst_ffmpegdemux_send_event),
(gst_ffmpegdemux_src_query), (gst_ffmpegdemux_src_convert),
(gst_ffmpegdemux_get_stream), (my_safe_copy),
(gst_ffmpegdemux_read_tags), (gst_ffmpegdemux_open),
(gst_ffmpegdemux_loop), (gst_ffmpegdemux_sink_activate),
(gst_ffmpegdemux_sink_activate_pull),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
Rework the demuxer, implement all seeking stuff including
seek in ready.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_peek),
(gst_ffmpegdata_close):
Handle some more cases.
2006-04-13 16:22:53 +00:00
|
|
|
break;
|
2012-01-03 14:27:54 +00:00
|
|
|
case GST_FLOW_EOS:
|
ext/ffmpeg/gstffmpegdemux.c: Rework the demuxer, implement all seeking stuff including seek in ready.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_class_init), (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_push_event),
(gst_ffmpegdemux_set_flags), (gst_ffmpegdemux_is_eos),
(gst_ffmpegdemux_do_seek), (gst_ffmpegdemux_perform_seek),
(gst_ffmpegdemux_src_event), (gst_ffmpegdemux_send_event),
(gst_ffmpegdemux_src_query), (gst_ffmpegdemux_src_convert),
(gst_ffmpegdemux_get_stream), (my_safe_copy),
(gst_ffmpegdemux_read_tags), (gst_ffmpegdemux_open),
(gst_ffmpegdemux_loop), (gst_ffmpegdemux_sink_activate),
(gst_ffmpegdemux_sink_activate_pull),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
Rework the demuxer, implement all seeking stuff including
seek in ready.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_peek),
(gst_ffmpegdata_close):
Handle some more cases.
2006-04-13 16:22:53 +00:00
|
|
|
total = 0;
|
|
|
|
break;
|
2012-02-08 15:41:19 +00:00
|
|
|
case GST_FLOW_FLUSHING:
|
ext/ffmpeg/gstffmpegdemux.c: Rework the demuxer, implement all seeking stuff including seek in ready.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_class_init), (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_push_event),
(gst_ffmpegdemux_set_flags), (gst_ffmpegdemux_is_eos),
(gst_ffmpegdemux_do_seek), (gst_ffmpegdemux_perform_seek),
(gst_ffmpegdemux_src_event), (gst_ffmpegdemux_send_event),
(gst_ffmpegdemux_src_query), (gst_ffmpegdemux_src_convert),
(gst_ffmpegdemux_get_stream), (my_safe_copy),
(gst_ffmpegdemux_read_tags), (gst_ffmpegdemux_open),
(gst_ffmpegdemux_loop), (gst_ffmpegdemux_sink_activate),
(gst_ffmpegdemux_sink_activate_pull),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
Rework the demuxer, implement all seeking stuff including
seek in ready.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_peek),
(gst_ffmpegdata_close):
Handle some more cases.
2006-04-13 16:22:53 +00:00
|
|
|
total = -1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
case GST_FLOW_ERROR:
|
|
|
|
total = -2;
|
|
|
|
break;
|
ext/ffmpeg/: Welcome the demuxers to 0.10 :)
Original commit message from CVS:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_init), (gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_handle_seek), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_add), (gst_ffmpegdemux_open),
(gst_ffmpegdemux_loop), (gst_ffmpegdemux_sink_activate),
(gst_ffmpegdemux_sink_activate_pull),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_read),
(gst_ffmpegdata_write), (gst_ffmpegdata_seek),
(gst_ffmpegdata_close):
Welcome the demuxers to 0.10 :)
For the time being the demuxers work only pull-based.
Seeking, querying works.
2006-02-10 19:42:19 +00:00
|
|
|
}
|
2002-11-06 23:53:46 +00:00
|
|
|
|
ext/ffmpeg/: gst-indent cleanup.
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.c: (gst_ffmpeg_avcodec_open),
(gst_ffmpeg_avcodec_close), (gst_ffmpeg_av_find_stream_info),
(gst_ffmpeg_log_callback), (plugin_init):
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context), (gst_ffmpeg_cfg_finalize):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_save_incoming_values),
(gst_ffmpegdec_get_best_values), (gst_ffmpegdec_video_frame):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_src_query):
* ext/ffmpeg/gstffmpegenc.c: (ffmpegenc_setup_working_buf),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_flush_buffers):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_read),
(gst_ffmpegdata_write), (gst_ffmpegdata_seek),
(gst_ffmpegdata_close):
gst-indent cleanup.
2007-11-03 16:14:53 +00:00
|
|
|
GST_DEBUG ("Got %d (%s) return result %d", ret, gst_flow_get_name (ret),
|
|
|
|
total);
|
ext/ffmpeg/gstffmpegdemux.c: Rework the demuxer, implement all seeking stuff including seek in ready.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_class_init), (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_push_event),
(gst_ffmpegdemux_set_flags), (gst_ffmpegdemux_is_eos),
(gst_ffmpegdemux_do_seek), (gst_ffmpegdemux_perform_seek),
(gst_ffmpegdemux_src_event), (gst_ffmpegdemux_send_event),
(gst_ffmpegdemux_src_query), (gst_ffmpegdemux_src_convert),
(gst_ffmpegdemux_get_stream), (my_safe_copy),
(gst_ffmpegdemux_read_tags), (gst_ffmpegdemux_open),
(gst_ffmpegdemux_loop), (gst_ffmpegdemux_sink_activate),
(gst_ffmpegdemux_sink_activate_pull),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
Rework the demuxer, implement all seeking stuff including
seek in ready.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_peek),
(gst_ffmpegdata_close):
Handle some more cases.
2006-04-13 16:22:53 +00:00
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
2004-12-19 00:32:13 +00:00
|
|
|
static int
|
2012-12-12 12:09:32 +00:00
|
|
|
gst_ffmpegdata_read (void *priv_data, unsigned char *buf, int size)
|
2004-12-19 00:32:13 +00:00
|
|
|
{
|
|
|
|
gint res;
|
|
|
|
GstProtocolInfo *info;
|
|
|
|
|
2012-12-12 12:09:32 +00:00
|
|
|
info = (GstProtocolInfo *) priv_data;
|
ext/ffmpeg/: Welcome the demuxers to 0.10 :)
Original commit message from CVS:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_init), (gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_handle_seek), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_add), (gst_ffmpegdemux_open),
(gst_ffmpegdemux_loop), (gst_ffmpegdemux_sink_activate),
(gst_ffmpegdemux_sink_activate_pull),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_read),
(gst_ffmpegdata_write), (gst_ffmpegdata_seek),
(gst_ffmpegdata_close):
Welcome the demuxers to 0.10 :)
For the time being the demuxers work only pull-based.
Seeking, querying works.
2006-02-10 19:42:19 +00:00
|
|
|
|
2009-05-09 08:57:55 +00:00
|
|
|
GST_DEBUG ("Reading %d bytes of data at position %" G_GUINT64_FORMAT, size,
|
|
|
|
info->offset);
|
ext/ffmpeg/: Welcome the demuxers to 0.10 :)
Original commit message from CVS:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_init), (gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_handle_seek), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_add), (gst_ffmpegdemux_open),
(gst_ffmpegdemux_loop), (gst_ffmpegdemux_sink_activate),
(gst_ffmpegdemux_sink_activate_pull),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_read),
(gst_ffmpegdata_write), (gst_ffmpegdata_seek),
(gst_ffmpegdata_close):
Welcome the demuxers to 0.10 :)
For the time being the demuxers work only pull-based.
Seeking, querying works.
2006-02-10 19:42:19 +00:00
|
|
|
|
2012-12-12 12:09:32 +00:00
|
|
|
res = gst_ffmpegdata_peek (priv_data, buf, size);
|
2006-02-12 16:47:50 +00:00
|
|
|
if (res >= 0)
|
|
|
|
info->offset += res;
|
2004-12-19 00:32:13 +00:00
|
|
|
|
2004-12-19 01:07:21 +00:00
|
|
|
GST_DEBUG ("Returning %d bytes", res);
|
|
|
|
|
2004-12-19 00:32:13 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2003-06-08 14:35:32 +00:00
|
|
|
static int
|
2012-12-12 12:09:32 +00:00
|
|
|
gst_ffmpegdata_write (void *priv_data, uint8_t * buf, int size)
|
2003-06-08 14:35:32 +00:00
|
|
|
{
|
|
|
|
GstProtocolInfo *info;
|
|
|
|
GstBuffer *outbuf;
|
|
|
|
|
2004-12-19 01:07:21 +00:00
|
|
|
GST_DEBUG ("Writing %d bytes", size);
|
2012-12-12 12:09:32 +00:00
|
|
|
info = (GstProtocolInfo *) priv_data;
|
2003-06-08 14:35:32 +00:00
|
|
|
|
|
|
|
/* create buffer and push data further */
|
2011-04-29 16:35:55 +00:00
|
|
|
outbuf = gst_buffer_new_and_alloc (size);
|
ext/ffmpeg/: gst-indent cleanup.
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.c: (gst_ffmpeg_avcodec_open),
(gst_ffmpeg_avcodec_close), (gst_ffmpeg_av_find_stream_info),
(gst_ffmpeg_log_callback), (plugin_init):
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context), (gst_ffmpeg_cfg_finalize):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_save_incoming_values),
(gst_ffmpegdec_get_best_values), (gst_ffmpegdec_video_frame):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_src_query):
* ext/ffmpeg/gstffmpegenc.c: (ffmpegenc_setup_working_buf),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_flush_buffers):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_read),
(gst_ffmpegdata_write), (gst_ffmpegdata_seek),
(gst_ffmpegdata_close):
gst-indent cleanup.
2007-11-03 16:14:53 +00:00
|
|
|
|
2011-04-04 10:23:05 +00:00
|
|
|
gst_buffer_fill (outbuf, 0, buf, size);
|
2003-06-08 14:35:32 +00:00
|
|
|
|
ext/ffmpeg/: gst-indent cleanup.
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.c: (gst_ffmpeg_avcodec_open),
(gst_ffmpeg_avcodec_close), (gst_ffmpeg_av_find_stream_info),
(gst_ffmpeg_log_callback), (plugin_init):
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context), (gst_ffmpeg_cfg_finalize):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_save_incoming_values),
(gst_ffmpegdec_get_best_values), (gst_ffmpegdec_video_frame):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_src_query):
* ext/ffmpeg/gstffmpegenc.c: (ffmpegenc_setup_working_buf),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_flush_buffers):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_read),
(gst_ffmpegdata_write), (gst_ffmpegdata_seek),
(gst_ffmpegdata_close):
gst-indent cleanup.
2007-11-03 16:14:53 +00:00
|
|
|
if (gst_pad_push (info->pad, outbuf) != GST_FLOW_OK)
|
ext/ffmpeg/: Welcome the demuxers to 0.10 :)
Original commit message from CVS:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_init), (gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_handle_seek), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_add), (gst_ffmpegdemux_open),
(gst_ffmpegdemux_loop), (gst_ffmpegdemux_sink_activate),
(gst_ffmpegdemux_sink_activate_pull),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_read),
(gst_ffmpegdata_write), (gst_ffmpegdata_seek),
(gst_ffmpegdata_close):
Welcome the demuxers to 0.10 :)
For the time being the demuxers work only pull-based.
Seeking, querying works.
2006-02-10 19:42:19 +00:00
|
|
|
return 0;
|
2003-06-08 14:35:32 +00:00
|
|
|
|
ext/ffmpeg/: Welcome the demuxers to 0.10 :)
Original commit message from CVS:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_init), (gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_handle_seek), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_add), (gst_ffmpegdemux_open),
(gst_ffmpegdemux_loop), (gst_ffmpegdemux_sink_activate),
(gst_ffmpegdemux_sink_activate_pull),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_read),
(gst_ffmpegdata_write), (gst_ffmpegdata_seek),
(gst_ffmpegdata_close):
Welcome the demuxers to 0.10 :)
For the time being the demuxers work only pull-based.
Seeking, querying works.
2006-02-10 19:42:19 +00:00
|
|
|
info->offset += size;
|
ext/ffmpeg/: Fix up demuxer. Works now for all my files that I tried, even quicktime. I basically hack around the sup...
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_query), (gst_ffmpegdemux_src_convert),
(gst_ffmpegdemux_open), (gst_ffmpegdemux_loop):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_read), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek):
Fix up demuxer. Works now for all my files that I tried, even
quicktime. I basically hack around the super-oversimplistic file
I/O handling in ffmpeg in several ways together, and I also hack
around the fairly annoying EOS-will-pause-the-source-element in
GStreamer itself.
This code is not pretty.
2004-05-14 14:11:00 +00:00
|
|
|
return size;
|
2003-06-08 14:35:32 +00:00
|
|
|
}
|
|
|
|
|
2008-10-30 12:05:45 +00:00
|
|
|
static int64_t
|
2012-12-12 12:09:32 +00:00
|
|
|
gst_ffmpegdata_seek (void *priv_data, int64_t pos, int whence)
|
2002-11-06 23:53:46 +00:00
|
|
|
{
|
2003-06-08 14:35:32 +00:00
|
|
|
GstProtocolInfo *info;
|
2011-06-02 14:23:19 +00:00
|
|
|
guint64 newpos = 0, oldpos;
|
2003-06-08 14:35:32 +00:00
|
|
|
|
2010-01-22 10:43:39 +00:00
|
|
|
GST_DEBUG ("Seeking to %" G_GINT64_FORMAT ", whence=%d",
|
|
|
|
(gint64) pos, whence);
|
2004-12-19 01:07:21 +00:00
|
|
|
|
2012-12-12 12:09:32 +00:00
|
|
|
info = (GstProtocolInfo *) priv_data;
|
2003-06-08 14:35:32 +00:00
|
|
|
|
2006-02-12 16:47:50 +00:00
|
|
|
/* TODO : if we are push-based, we need to return sensible info */
|
2012-12-12 12:09:32 +00:00
|
|
|
|
|
|
|
if (GST_PAD_IS_SINK (info->pad)) {
|
2012-12-04 16:47:20 +00:00
|
|
|
/* sinkpad */
|
|
|
|
switch (whence) {
|
|
|
|
case SEEK_SET:
|
|
|
|
newpos = (guint64) pos;
|
|
|
|
break;
|
|
|
|
case SEEK_CUR:
|
|
|
|
newpos = info->offset + pos;
|
|
|
|
break;
|
|
|
|
case SEEK_END:
|
|
|
|
case AVSEEK_SIZE:
|
|
|
|
/* ffmpeg wants to know the current end position in bytes ! */
|
|
|
|
{
|
|
|
|
gint64 duration;
|
|
|
|
|
|
|
|
GST_DEBUG ("Seek end");
|
|
|
|
|
|
|
|
if (gst_pad_is_linked (info->pad))
|
|
|
|
if (gst_pad_query_duration (GST_PAD_PEER (info->pad),
|
|
|
|
GST_FORMAT_BYTES, &duration))
|
|
|
|
newpos = ((guint64) duration) + pos;
|
ext/ffmpeg/: Fix up demuxer. Works now for all my files that I tried, even quicktime. I basically hack around the sup...
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_query), (gst_ffmpegdemux_src_convert),
(gst_ffmpegdemux_open), (gst_ffmpegdemux_loop):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_read), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek):
Fix up demuxer. Works now for all my files that I tried, even
quicktime. I basically hack around the super-oversimplistic file
I/O handling in ffmpeg in several ways together, and I also hack
around the fairly annoying EOS-will-pause-the-source-element in
GStreamer itself.
This code is not pretty.
2004-05-14 14:11:00 +00:00
|
|
|
}
|
2012-12-04 16:47:20 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert (0);
|
|
|
|
break;
|
ext/ffmpeg/: Fix up demuxer. Works now for all my files that I tried, even quicktime. I basically hack around the sup...
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_query), (gst_ffmpegdemux_src_convert),
(gst_ffmpegdemux_open), (gst_ffmpegdemux_loop):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_read), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek):
Fix up demuxer. Works now for all my files that I tried, even
quicktime. I basically hack around the super-oversimplistic file
I/O handling in ffmpeg in several ways together, and I also hack
around the fairly annoying EOS-will-pause-the-source-element in
GStreamer itself.
This code is not pretty.
2004-05-14 14:11:00 +00:00
|
|
|
}
|
2012-12-04 16:47:20 +00:00
|
|
|
/* FIXME : implement case for push-based behaviour */
|
|
|
|
if (whence != AVSEEK_SIZE)
|
|
|
|
info->offset = newpos;
|
2012-12-12 12:09:32 +00:00
|
|
|
} else if (GST_PAD_IS_SRC (info->pad)) {
|
2012-12-04 16:47:20 +00:00
|
|
|
GstSegment segment;
|
2011-06-02 14:23:19 +00:00
|
|
|
|
2012-12-04 16:47:20 +00:00
|
|
|
oldpos = info->offset;
|
|
|
|
|
|
|
|
/* srcpad */
|
|
|
|
switch (whence) {
|
|
|
|
case SEEK_SET:
|
|
|
|
{
|
|
|
|
info->offset = (guint64) pos;
|
|
|
|
break;
|
2011-06-02 14:23:19 +00:00
|
|
|
}
|
2012-12-04 16:47:20 +00:00
|
|
|
case SEEK_CUR:
|
|
|
|
info->offset += pos;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
newpos = info->offset;
|
|
|
|
|
|
|
|
if (newpos != oldpos) {
|
|
|
|
gst_segment_init (&segment, GST_FORMAT_BYTES);
|
|
|
|
segment.start = newpos;
|
|
|
|
segment.time = newpos;
|
|
|
|
gst_pad_push_event (info->pad, gst_event_new_segment (&segment));
|
2011-06-02 14:23:19 +00:00
|
|
|
}
|
2012-12-12 12:09:32 +00:00
|
|
|
} else {
|
|
|
|
g_assert_not_reached ();
|
2003-06-08 14:35:32 +00:00
|
|
|
}
|
2002-11-06 23:53:46 +00:00
|
|
|
|
2009-05-09 08:57:55 +00:00
|
|
|
GST_DEBUG ("Now at offset %" G_GUINT64_FORMAT " (returning %" G_GUINT64_FORMAT
|
|
|
|
")", info->offset, newpos);
|
ext/ffmpeg/: Fix up demuxer. Works now for all my files that I tried, even quicktime. I basically hack around the sup...
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_query), (gst_ffmpegdemux_src_convert),
(gst_ffmpegdemux_open), (gst_ffmpegdemux_loop):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_read), (gst_ffmpegdata_write),
(gst_ffmpegdata_seek):
Fix up demuxer. Works now for all my files that I tried, even
quicktime. I basically hack around the super-oversimplistic file
I/O handling in ffmpeg in several ways together, and I also hack
around the fairly annoying EOS-will-pause-the-source-element in
GStreamer itself.
This code is not pretty.
2004-05-14 14:11:00 +00:00
|
|
|
return newpos;
|
2002-11-06 23:53:46 +00:00
|
|
|
}
|
|
|
|
|
2012-12-12 12:09:32 +00:00
|
|
|
int
|
|
|
|
gst_ffmpegdata_close (AVIOContext * h)
|
2002-11-06 23:53:46 +00:00
|
|
|
{
|
2003-06-08 14:35:32 +00:00
|
|
|
GstProtocolInfo *info;
|
|
|
|
|
2017-07-11 06:04:03 +00:00
|
|
|
if (h == NULL)
|
|
|
|
return 0;
|
|
|
|
|
2012-12-12 12:09:32 +00:00
|
|
|
info = (GstProtocolInfo *) h->opaque;
|
ext/ffmpeg/gstffmpegdemux.c: Rework the demuxer, implement all seeking stuff including seek in ready.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_class_init), (gst_ffmpegdemux_init),
(gst_ffmpegdemux_close), (gst_ffmpegdemux_push_event),
(gst_ffmpegdemux_set_flags), (gst_ffmpegdemux_is_eos),
(gst_ffmpegdemux_do_seek), (gst_ffmpegdemux_perform_seek),
(gst_ffmpegdemux_src_event), (gst_ffmpegdemux_send_event),
(gst_ffmpegdemux_src_query), (gst_ffmpegdemux_src_convert),
(gst_ffmpegdemux_get_stream), (my_safe_copy),
(gst_ffmpegdemux_read_tags), (gst_ffmpegdemux_open),
(gst_ffmpegdemux_loop), (gst_ffmpegdemux_sink_activate),
(gst_ffmpegdemux_sink_activate_pull),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
Rework the demuxer, implement all seeking stuff including
seek in ready.
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_peek),
(gst_ffmpegdata_close):
Handle some more cases.
2006-04-13 16:22:53 +00:00
|
|
|
if (info == NULL)
|
|
|
|
return 0;
|
2003-06-08 14:35:32 +00:00
|
|
|
|
2004-12-19 01:07:21 +00:00
|
|
|
GST_LOG ("Closing file");
|
|
|
|
|
2012-12-12 12:09:32 +00:00
|
|
|
if (GST_PAD_IS_SRC (info->pad)) {
|
2012-12-04 16:47:20 +00:00
|
|
|
/* send EOS - that closes down the stream */
|
|
|
|
gst_pad_push_event (info->pad, gst_event_new_eos ());
|
ext/ffmpeg/: Welcome the demuxers to 0.10 :)
Original commit message from CVS:
* ext/ffmpeg/Makefile.am:
* ext/ffmpeg/gstffmpeg.c: (plugin_init):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_init), (gst_ffmpegdemux_stream_from_pad),
(gst_ffmpegdemux_handle_seek), (gst_ffmpegdemux_src_event),
(gst_ffmpegdemux_src_query_list), (gst_ffmpegdemux_src_query),
(gst_ffmpegdemux_add), (gst_ffmpegdemux_open),
(gst_ffmpegdemux_loop), (gst_ffmpegdemux_sink_activate),
(gst_ffmpegdemux_sink_activate_pull),
(gst_ffmpegdemux_change_state), (gst_ffmpegdemux_register):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_read),
(gst_ffmpegdata_write), (gst_ffmpegdata_seek),
(gst_ffmpegdata_close):
Welcome the demuxers to 0.10 :)
For the time being the demuxers work only pull-based.
Seeking, querying works.
2006-02-10 19:42:19 +00:00
|
|
|
}
|
ext/ffmpeg/: gst-indent cleanup.
Original commit message from CVS:
* ext/ffmpeg/gstffmpeg.c: (gst_ffmpeg_avcodec_open),
(gst_ffmpeg_avcodec_close), (gst_ffmpeg_av_find_stream_info),
(gst_ffmpeg_log_callback), (plugin_init):
* ext/ffmpeg/gstffmpegcfg.c: (gst_ffmpeg_mb_decision_get_type),
(gst_ffmpeg_flags_get_type), (gst_ffmpeg_cfg_init),
(gst_ffmpeg_cfg_codec_has_pspec),
(gst_ffmpeg_cfg_install_property), (gst_ffmpeg_cfg_set_property),
(gst_ffmpeg_cfg_get_property), (gst_ffmpeg_cfg_set_defaults),
(gst_ffmpeg_cfg_fill_context), (gst_ffmpeg_cfg_finalize):
* ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_codecid_to_caps):
* ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_open),
(gst_ffmpegdec_setcaps), (gst_ffmpegdec_save_incoming_values),
(gst_ffmpegdec_get_best_values), (gst_ffmpegdec_video_frame):
* ext/ffmpeg/gstffmpegdemux.c: (gst_ffmpegdemux_base_init),
(gst_ffmpegdemux_src_query):
* ext/ffmpeg/gstffmpegenc.c: (ffmpegenc_setup_working_buf),
(gst_ffmpegenc_chain_video), (gst_ffmpegenc_flush_buffers):
* ext/ffmpeg/gstffmpegprotocol.c: (gst_ffmpegdata_open),
(gst_ffmpegdata_peek), (gst_ffmpegdata_read),
(gst_ffmpegdata_write), (gst_ffmpegdata_seek),
(gst_ffmpegdata_close):
gst-indent cleanup.
2007-11-03 16:14:53 +00:00
|
|
|
|
2003-06-08 14:35:32 +00:00
|
|
|
/* clean up data */
|
|
|
|
g_free (info);
|
2012-12-12 12:09:32 +00:00
|
|
|
h->opaque = NULL;
|
|
|
|
|
|
|
|
av_freep (&h->buffer);
|
|
|
|
av_free (h);
|
2003-06-08 14:35:32 +00:00
|
|
|
|
2002-11-06 23:53:46 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-12 12:09:32 +00:00
|
|
|
int
|
|
|
|
gst_ffmpegdata_open (GstPad * pad, int flags, AVIOContext ** context)
|
|
|
|
{
|
|
|
|
GstProtocolInfo *info;
|
|
|
|
static const int buffer_size = 4096;
|
|
|
|
unsigned char *buffer = NULL;
|
2006-09-06 15:15:05 +00:00
|
|
|
|
2012-12-12 12:09:32 +00:00
|
|
|
info = g_new0 (GstProtocolInfo, 1);
|
2009-01-27 10:39:18 +00:00
|
|
|
|
2012-12-12 12:09:32 +00:00
|
|
|
info->set_streamheader = flags & GST_FFMPEG_URL_STREAMHEADER;
|
|
|
|
flags &= ~GST_FFMPEG_URL_STREAMHEADER;
|
2009-01-27 10:39:18 +00:00
|
|
|
|
2012-12-12 12:09:32 +00:00
|
|
|
/* we don't support R/W together */
|
|
|
|
if ((flags & AVIO_FLAG_WRITE) && (flags & AVIO_FLAG_READ)) {
|
|
|
|
GST_WARNING ("Only read-only or write-only are supported");
|
2017-10-03 08:27:24 +00:00
|
|
|
g_free (info);
|
2012-12-12 12:09:32 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2009-01-27 10:39:18 +00:00
|
|
|
|
2012-12-12 12:09:32 +00:00
|
|
|
/* make sure we're a pad and that we're of the right type */
|
|
|
|
g_return_val_if_fail (GST_IS_PAD (pad), -EINVAL);
|
2009-01-27 10:39:18 +00:00
|
|
|
|
2012-12-12 12:09:32 +00:00
|
|
|
if ((flags & AVIO_FLAG_READ))
|
|
|
|
g_return_val_if_fail (GST_PAD_IS_SINK (pad), -EINVAL);
|
|
|
|
if ((flags & AVIO_FLAG_WRITE))
|
|
|
|
g_return_val_if_fail (GST_PAD_IS_SRC (pad), -EINVAL);
|
2009-01-27 10:39:18 +00:00
|
|
|
|
2012-12-12 12:09:32 +00:00
|
|
|
info->eos = FALSE;
|
|
|
|
info->pad = pad;
|
|
|
|
info->offset = 0;
|
2009-01-27 10:39:18 +00:00
|
|
|
|
2012-12-12 12:09:32 +00:00
|
|
|
buffer = av_malloc (buffer_size);
|
|
|
|
if (buffer == NULL) {
|
|
|
|
GST_WARNING ("Failed to allocate buffer");
|
2017-10-03 08:27:24 +00:00
|
|
|
g_free (info);
|
2012-12-12 12:09:32 +00:00
|
|
|
return -ENOMEM;
|
2009-01-27 10:39:18 +00:00
|
|
|
}
|
|
|
|
|
2012-12-12 12:09:32 +00:00
|
|
|
*context =
|
|
|
|
avio_alloc_context (buffer, buffer_size, flags, (void *) info,
|
|
|
|
gst_ffmpegdata_read, gst_ffmpegdata_write, gst_ffmpegdata_seek);
|
2017-07-11 06:04:03 +00:00
|
|
|
if (*context == NULL) {
|
|
|
|
GST_WARNING ("Failed to allocate memory");
|
2017-10-03 08:27:24 +00:00
|
|
|
g_free (info);
|
2017-07-11 06:04:03 +00:00
|
|
|
av_free (buffer);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2012-12-12 12:09:32 +00:00
|
|
|
(*context)->seekable = AVIO_SEEKABLE_NORMAL;
|
|
|
|
if (!(flags & AVIO_FLAG_WRITE)) {
|
|
|
|
(*context)->buf_ptr = (*context)->buf_end;
|
|
|
|
(*context)->write_flag = 0;
|
|
|
|
}
|
2009-01-27 10:39:18 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-12 12:09:32 +00:00
|
|
|
/* specialized protocol for cross-thread pushing,
|
|
|
|
* based on ffmpeg's pipe protocol */
|
|
|
|
|
2009-01-27 10:39:18 +00:00
|
|
|
static int
|
2012-12-12 12:09:32 +00:00
|
|
|
gst_ffmpeg_pipe_read (void *priv_data, uint8_t * buf, int size)
|
2009-01-27 10:39:18 +00:00
|
|
|
{
|
|
|
|
GstFFMpegPipe *ffpipe;
|
|
|
|
guint available;
|
|
|
|
|
2012-12-12 12:09:32 +00:00
|
|
|
ffpipe = (GstFFMpegPipe *) priv_data;
|
2009-01-27 10:39:18 +00:00
|
|
|
|
|
|
|
GST_LOG ("requested size %d", size);
|
|
|
|
|
|
|
|
GST_FFMPEG_PIPE_MUTEX_LOCK (ffpipe);
|
2009-03-09 12:45:22 +00:00
|
|
|
|
|
|
|
GST_LOG ("requested size %d", size);
|
|
|
|
|
2009-01-27 10:39:18 +00:00
|
|
|
while ((available = gst_adapter_available (ffpipe->adapter)) < size
|
|
|
|
&& !ffpipe->eos) {
|
2009-03-09 12:45:22 +00:00
|
|
|
GST_DEBUG ("Available:%d, requested:%d", available, size);
|
2009-01-27 10:39:18 +00:00
|
|
|
ffpipe->needed = size;
|
|
|
|
GST_FFMPEG_PIPE_SIGNAL (ffpipe);
|
|
|
|
GST_FFMPEG_PIPE_WAIT (ffpipe);
|
|
|
|
}
|
|
|
|
|
|
|
|
size = MIN (available, size);
|
|
|
|
if (size) {
|
2009-03-09 12:45:22 +00:00
|
|
|
GST_LOG ("Getting %d bytes", size);
|
2011-04-04 10:23:05 +00:00
|
|
|
gst_adapter_copy (ffpipe->adapter, buf, 0, size);
|
2009-01-27 10:39:18 +00:00
|
|
|
gst_adapter_flush (ffpipe->adapter, size);
|
2012-02-27 05:26:02 +00:00
|
|
|
GST_LOG ("%" G_GSIZE_FORMAT " bytes left in adapter",
|
2009-03-09 12:45:22 +00:00
|
|
|
gst_adapter_available (ffpipe->adapter));
|
2009-01-27 10:39:18 +00:00
|
|
|
ffpipe->needed = 0;
|
|
|
|
}
|
|
|
|
GST_FFMPEG_PIPE_MUTEX_UNLOCK (ffpipe);
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2012-12-12 12:09:32 +00:00
|
|
|
int
|
|
|
|
gst_ffmpeg_pipe_close (AVIOContext * h)
|
2009-01-27 10:39:18 +00:00
|
|
|
{
|
|
|
|
GST_LOG ("Closing pipe");
|
|
|
|
|
2017-07-11 06:04:03 +00:00
|
|
|
if (h == NULL)
|
|
|
|
return 0;
|
|
|
|
|
2012-12-12 12:09:32 +00:00
|
|
|
h->opaque = NULL;
|
|
|
|
av_freep (&h->buffer);
|
|
|
|
av_free (h);
|
2009-01-27 10:39:18 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-12 12:09:32 +00:00
|
|
|
int
|
|
|
|
gst_ffmpeg_pipe_open (GstFFMpegPipe * ffpipe, int flags, AVIOContext ** context)
|
|
|
|
{
|
|
|
|
static const int buffer_size = 4096;
|
|
|
|
unsigned char *buffer = NULL;
|
|
|
|
|
|
|
|
/* sanity check */
|
|
|
|
g_return_val_if_fail (GST_IS_ADAPTER (ffpipe->adapter), -EINVAL);
|
|
|
|
|
|
|
|
buffer = av_malloc (buffer_size);
|
|
|
|
if (buffer == NULL) {
|
|
|
|
GST_WARNING ("Failed to allocate buffer");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
*context =
|
|
|
|
avio_alloc_context (buffer, buffer_size, 0, (void *) ffpipe,
|
|
|
|
gst_ffmpeg_pipe_read, NULL, NULL);
|
2017-07-11 06:04:03 +00:00
|
|
|
if (*context == NULL) {
|
|
|
|
GST_WARNING ("Failed to allocate memory");
|
|
|
|
av_free (buffer);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2012-12-12 12:09:32 +00:00
|
|
|
(*context)->seekable = 0;
|
|
|
|
(*context)->buf_ptr = (*context)->buf_end;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|