summaryrefslogtreecommitdiffstats
path: root/ext/mplex
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2002-10-25 19:06:39 +0000
committerWim Taymans <wim.taymans@gmail.com>2002-10-25 19:06:39 +0000
commitcd3adce1fbee0f4a5878bf772f023fed661526a0 (patch)
treec493135c2d3b1feb9141f68db7738c6c2e089036 /ext/mplex
parent8bca9f16bb88f33064d077f7bb9aa70d32f8219c (diff)
downloadgst-plugins-bad-cd3adce1fbee0f4a5878bf772f023fed661526a0.tar.gz
gst-plugins-bad-cd3adce1fbee0f4a5878bf772f023fed661526a0.tar.bz2
gst-plugins-bad-cd3adce1fbee0f4a5878bf772f023fed661526a0.zip
Removed dead .cc file
Original commit message from CVS: Removed dead .cc file Added some params, act on EOS
Diffstat (limited to 'ext/mplex')
-rw-r--r--ext/mplex/gstmplex.cc52
-rw-r--r--ext/mplex/gstmplex.h3
-rw-r--r--ext/mplex/interact.cc196
3 files changed, 50 insertions, 201 deletions
diff --git a/ext/mplex/gstmplex.cc b/ext/mplex/gstmplex.cc
index 73d78f06..a3723bb0 100644
--- a/ext/mplex/gstmplex.cc
+++ b/ext/mplex/gstmplex.cc
@@ -186,7 +186,7 @@ gst_mplex_class_init (GstMPlex *klass)
20, 2000, 20, (GParamFlags) G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_SYNC_OFFSET,
g_param_spec_int ("sync_offset", "Sync offset", "Specify offset of timestamps (video-audio) in mSec",
- 0, G_MAXINT, 0, (GParamFlags) G_PARAM_READWRITE));
+ G_MININT, G_MAXINT, 0, (GParamFlags) G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_SECTOR_SIZE,
g_param_spec_int ("sector_size", "Sector size", "Specify sector size in bytes for generic formats",
256, 16384, 2028, (GParamFlags) G_PARAM_READWRITE));
@@ -219,7 +219,7 @@ gst_mplex_init (GstMPlex *mplex)
mplex->state = GST_MPLEX_OPEN_STREAMS;
- mplex->ostrm->opt_mux_format = MPEG_FORMAT_DVD;
+ mplex->ostrm->opt_mux_format = 0;
(void)mjpeg_default_handler_verbosity(mplex->ostrm->opt_verbosity);
}
@@ -252,6 +252,7 @@ gst_mplex_request_new_pad (GstElement *element,
stream->pad = pad;
stream->bitstream = new IBitStream();
stream->bytestream = gst_bytestream_new (pad);
+ stream->eos = FALSE;
mplex->streams = g_list_prepend (mplex->streams, stream);
@@ -271,14 +272,29 @@ gst_mplex_read_callback (BitStream *bitstream, uint8_t *dest, size_t size, void
stream = (GstMPlexStream *) user_data;
+ if (stream->eos)
+ return 0;
+
len = gst_bytestream_peek_bytes (stream->bytestream, &data, size);
if (len < size) {
- g_print ("got %d bytes out of %d\n", len, size);
+ guint32 avail= 0;
+ GstEvent *event = NULL;
+
+ gst_bytestream_get_status (stream->bytestream, &avail, &event);
+ if (event != NULL) {
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_EOS:
+ stream->eos = TRUE;
+ break;
+ default:
+ break;
+ }
+ }
}
memcpy (dest, data, len);
- gst_bytestream_flush_fast (stream->bytestream, len);
+ gst_bytestream_flush (stream->bytestream, len);
return len;
}
@@ -380,20 +396,38 @@ gst_mplex_set_property (GObject *object, guint prop_id, const GValue *value, GPa
switch(prop_id) {
case ARG_MUX_FORMAT:
+ mplex->ostrm->opt_mux_format = g_value_get_enum (value);
break;
case ARG_MUX_BITRATE:
+ mplex->data_rate = g_value_get_int (value);
+ mplex->ostrm->opt_data_rate = ((mplex->data_rate * 1000 / 8 + 49) / 50) * 50;
break;
case ARG_VIDEO_BUFFER:
+ mplex->ostrm->opt_buffer_size = g_value_get_int (value);
break;
case ARG_SYNC_OFFSET:
+ {
+ mplex->sync_offset = g_value_get_int (value);
+ if (mplex->sync_offset < 0) {
+ mplex->ostrm->opt_audio_offset = -mplex->sync_offset;
+ mplex->ostrm->opt_video_offset = 0;
+ }
+ else {
+ mplex->ostrm->opt_video_offset = mplex->sync_offset;
+ }
break;
+ }
case ARG_SECTOR_SIZE:
+ mplex->ostrm->opt_sector_size = g_value_get_int (value);
break;
case ARG_VBR:
+ mplex->ostrm->opt_VBR = g_value_get_boolean (value);
break;
case ARG_PACKETS_PER_PACK:
+ mplex->ostrm->opt_packets_per_pack = g_value_get_int (value);
break;
case ARG_SYSTEM_HEADERS:
+ mplex->ostrm->opt_always_system_headers = g_value_get_boolean (value);
break;
default:
//G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -410,20 +444,28 @@ gst_mplex_get_property (GObject *object, guint prop_id, GValue *value, GParamSpe
switch(prop_id) {
case ARG_MUX_FORMAT:
+ g_value_set_enum (value, mplex->ostrm->opt_mux_format);
break;
case ARG_MUX_BITRATE:
+ g_value_set_int (value, mplex->data_rate);
break;
case ARG_VIDEO_BUFFER:
+ g_value_set_int (value, mplex->ostrm->opt_buffer_size);
break;
case ARG_SYNC_OFFSET:
+ g_value_set_int (value, mplex->sync_offset);
break;
case ARG_SECTOR_SIZE:
+ g_value_set_int (value, mplex->ostrm->opt_sector_size);
break;
case ARG_VBR:
+ g_value_set_boolean (value, mplex->ostrm->opt_VBR);
break;
case ARG_PACKETS_PER_PACK:
+ g_value_set_int (value, mplex->ostrm->opt_packets_per_pack);
break;
case ARG_SYSTEM_HEADERS:
+ g_value_set_boolean (value, mplex->ostrm->opt_always_system_headers);
break;
default:
//G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -444,7 +486,7 @@ plugin_init (GModule *module, GstPlugin *plugin)
factory = gst_element_factory_new ("mplex",GST_TYPE_MPLEX,
&gst_mplex_details);
g_return_val_if_fail (factory != NULL, FALSE);
- gst_element_factory_set_rank (factory, GST_ELEMENT_RANK_PRIMARY);
+ gst_element_factory_set_rank (factory, GST_ELEMENT_RANK_MARGINAL);
gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (src_factory));
gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (audio_sink_factory));
diff --git a/ext/mplex/gstmplex.h b/ext/mplex/gstmplex.h
index 9266eb12..381b0af1 100644
--- a/ext/mplex/gstmplex.h
+++ b/ext/mplex/gstmplex.h
@@ -71,6 +71,7 @@ struct _GstMPlexStream {
GstPad *pad;
GstMPlexStreamType type;
GstByteStream *bytestream;
+ gboolean eos;
};
struct _GstMPlex {
@@ -84,6 +85,8 @@ struct _GstMPlex {
vector<ElementaryStream *> *strms;
OutputStream *ostrm;
PS_Stream *ps_stream;
+ gint data_rate;
+ gint sync_offset;
};
struct _GstMPlexClass {
diff --git a/ext/mplex/interact.cc b/ext/mplex/interact.cc
deleted file mode 100644
index 2191d552..00000000
--- a/ext/mplex/interact.cc
+++ /dev/null
@@ -1,196 +0,0 @@
-#include <config.h>
-#include <stdlib.h>
-#include <unistd.h>
-#ifdef HAVE_GETOPT_H
-#include <getopt.h>
-#endif
-#include <sys/stat.h>
-
-#include <mjpeg_logging.h>
-#include <format_codes.h>
-
-#include "interact.hh"
-#include "videostrm.hh"
-#include "audiostrm.hh"
-#include "mplexconsts.hh"
-
-
-#if 0
-int opt_verbosity = 1;
-int opt_buffer_size = 46;
-int opt_data_rate = 0; /* 3486 = 174300B/sec would be right for VCD */
-int opt_video_offset = 0;
-int opt_audio_offset = 0;
-int opt_sector_size = 2324;
-int opt_VBR = 0;
-int opt_mpeg = 1;
-int opt_mux_format = 0; /* Generic MPEG-1 stream as default */
-int opt_multifile_segment = 0;
-int opt_always_system_headers = 0;
-int opt_packets_per_pack = 20;
-bool opt_ignore_underrun = false;
-off_t opt_max_segment_size = 0;
-
-/*************************************************************************
- Startbildschirm und Anzahl der Argumente
-
- Intro Screen and argument check
-*************************************************************************/
-
-static void
-Usage (char *str)
-{
- fprintf (stderr,
- "mjpegtools mplex version " VERSION "\n"
- "Usage: %s [params] -o <output filename pattern> <input file>... \n"
- " %%d in the output file name is by segment count\n"
- " where possible params are:\n"
- "--verbose|-v num\n"
- " Level of verbosity. 0 = quiet, 1 = normal 2 = verbose/debug\n"
- "--format|-f fmt\n"
- " Set defaults for particular MPEG profiles\n"
- " [0 = Generic MPEG1, 1 = VCD, 2 = user-rate VCD, 3 = Generic MPEG2,\n"
- " 4 = SVCD, 5 = user-rate SVCD\n"
- " 6 = VCD Stills, 7 = SVCD Stills, 8 = DVD]\n"
- "--mux-bitrate|-r num\n"
- " Specify data rate of output stream in kbit/sec\n"
- " (default 0=Compute from source streams)\n"
- "--video-buffer|-b num\n"
- " Specifies decoder buffers size in kB. [ 20...2000]\n"
- "--mux-limit|-l num\n"
- " Multiplex only num seconds of material (default 0=multiplex all)\n"
- "--sync-offset|-O num\n"
- " Specify offset of timestamps (video-audio) in mSec\n"
- "--sector-size|-s num\n"
- " Specify sector size in bytes for generic formats [256..16384]\n"
- "--vbr|-V\n"
- " Multiplex variable bit-rate video\n"
- "--packets-per-pack|-p num\n"
- " Number of packets per pack generic formats [1..100]\n"
- "--system-headers|-h\n"
- " Create System header in every pack in generic formats\n"
- "--max-segment-size|-S size\n"
- " Maximum size of output file(s) in Mbyte (default: 2000) (0 = no limit)\n"
- "--split-segment|-M\n"
- " Simply split a sequence across files rather than building run-out/run-in\n"
- "--help|-?\n" " Print this lot out!\n", str);
- exit (1);
-}
-
-static const char short_options[] = "o:b:r:O:v:m:f:l:s:S:q:p:VXMeh";
-
-#if defined(HAVE_GETOPT_LONG)
-static struct option long_options[] = {
- {"verbose", 1, 0, 'v'},
- {"format", 1, 0, 'f'},
- {"mux-bitrate", 1, 0, 'r'},
- {"video-buffer", 1, 0, 'b'},
- {"output", 1, 0, 'o'},
- {"sync-offset", 1, 0, 'O'},
- {"vbr", 1, 0, 'V'},
- {"system-headers", 1, 0, 'h'},
- {"split-segment", 0, &opt_multifile_segment, 1},
- {"max-segment-size", 1, 0, 'S'},
- {"mux-upto", 1, 0, 'l'},
- {"packets-per-pack", 1, 0, 'p'},
- {"sector-size", 1, 0, 's'},
- {"help", 0, 0, '?'},
- {0, 0, 0, 0}
-};
-#endif
-
-int
-intro_and_options (int argc, char *argv[], char **multplex_outfile)
-{
- int n;
-
-#if defined(HAVE_GETOPT_LONG)
- while ((n = getopt_long (argc, argv, short_options, long_options, NULL)) != -1)
-#else
- while ((n = getopt (argc, argv, short_options)) != -1)
-#endif
- {
- switch (n) {
- case 0:
- break;
- case 'm':
- opt_mpeg = atoi (optarg);
- if (opt_mpeg < 1 || opt_mpeg > 2)
- Usage (argv[0]);
-
- break;
- case 'v':
- opt_verbosity = atoi (optarg);
- if (opt_verbosity < 0 || opt_verbosity > 2)
- Usage (argv[0]);
- break;
-
- case 'V':
- opt_VBR = 1;
- break;
-
- case 'h':
- opt_always_system_headers = 1;
- break;
-
- case 'b':
- opt_buffer_size = atoi (optarg);
- if (opt_buffer_size < 0 || opt_buffer_size > 1000)
- Usage (argv[0]);
- break;
-
- case 'r':
- opt_data_rate = atoi (optarg);
- if (opt_data_rate < 0)
- Usage (argv[0]);
- /* Convert from kbit/sec (user spec) to 50B/sec units... */
- opt_data_rate = ((opt_data_rate * 1000 / 8 + 49) / 50) * 50;
- break;
-
- case 'O':
- opt_video_offset = atoi (optarg);
- if (opt_video_offset < 0) {
- opt_audio_offset = -opt_video_offset;
- opt_video_offset = 0;
- }
- break;
-
- case 'p':
- opt_packets_per_pack = atoi (optarg);
- if (opt_packets_per_pack < 1 || opt_packets_per_pack > 100)
- Usage (argv[0]);
- break;
-
-
- case 'f':
- opt_mux_format = atoi (optarg);
- if (opt_mux_format != MPEG_FORMAT_DVD &&
- (opt_mux_format < MPEG_FORMAT_MPEG1 || opt_mux_format > MPEG_FORMAT_LAST)
- )
- Usage (argv[0]);
- break;
- case 's':
- opt_sector_size = atoi (optarg);
- if (opt_sector_size < 256 || opt_sector_size > 16384)
- Usage (argv[0]);
- break;
- case 'S':
- opt_max_segment_size = atoi (optarg);
- if (opt_max_segment_size < 0)
- Usage (argv[0]);
- opt_max_segment_size *= 1024 * 1024;
- break;
- case 'M':
- opt_multifile_segment = 1;
- break;
- case '?':
- default:
- Usage (argv[0]);
- break;
- }
- }
- (void) mjpeg_default_handler_verbosity (opt_verbosity);
- mjpeg_info ("mplex version %s (%s)", MPLEX_VER, MPLEX_DATE);
- return optind - 1;
-}
-#endif