~ubuntu-branches/ubuntu/quantal/gst-plugins-bad-multiverse0.10/quantal

« back to all changes in this revision

Viewing changes to ext/mplex/gstmplexjob.cc

  • Committer: Bazaar Package Importer
  • Author(s): Onkar Shinde
  • Date: 2009-02-23 02:23:58 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20090223022358-9yhx5izc7dz60yc8
Tags: 0.10.10-0ubuntu1
* New upstream release.
* debian/rules
  - Disable some plugins which get built by default but we do not ship in 
    multiverse package.
  - Do not build docs as there is no multiverse-doc package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GStreamer mplex (mjpegtools) wrapper
 
2
 * (c) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
 
3
 *
 
4
 * gstmplexjob.hh: gstreamer/mplex multiplex-job wrapper
 
5
 *
 
6
 * This library is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU Library General Public
 
8
 * License as published by the Free Software Foundation; either
 
9
 * version 2 of the License, or (at your option) any later version.
 
10
 *
 
11
 * This library is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
 * Library General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU Library General Public
 
17
 * License along with this library; if not, write to the
 
18
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
19
 * Boston, MA 02111-1307, USA.
 
20
 */
 
21
 
 
22
#ifdef HAVE_CONFIG_H
 
23
#include "config.h"
 
24
#endif
 
25
 
 
26
#include "gstmplexjob.hh"
 
27
 
 
28
 
 
29
enum
 
30
{
 
31
  ARG_0,
 
32
  ARG_FORMAT,
 
33
  ARG_MUX_BITRATE,
 
34
  ARG_VBR,
 
35
  ARG_SYSTEM_HEADERS,
 
36
  ARG_SPLIT_SEQUENCE,
 
37
  ARG_SEGMENT_SIZE,
 
38
  ARG_PACKETS_PER_PACK,
 
39
  ARG_SECTOR_SIZE,
 
40
  ARG_BUFSIZE
 
41
      /* FILL ME */
 
42
};
 
43
 
 
44
/*
 
45
 * Property enumeration types.
 
46
 */
 
47
 
 
48
#define GST_TYPE_MPLEX_FORMAT \
 
49
  (gst_mplex_format_get_type ())
 
50
 
 
51
static GType
 
52
gst_mplex_format_get_type (void)
 
53
{
 
54
  static GType mplex_format_type = 0;
 
55
 
 
56
  if (!mplex_format_type) {
 
57
    static const GEnumValue mplex_formats[] = {
 
58
      {0, "Generic MPEG-1", "0"},
 
59
      {1, "Standard VCD", "1"},
 
60
      {2, "User VCD", "2"},
 
61
      {3, "Generic MPEG-2", "3"},
 
62
      {4, "Standard SVCD", "4"},
 
63
      {5, "User SVCD", "5"},
 
64
      {6, "VCD Stills sequences", "6"},
 
65
      {7, "SVCD Stills sequences", "7"},
 
66
      {8, "DVD MPEG-2 for dvdauthor", "8"},
 
67
      {9, "DVD MPEG-2", "9"},
 
68
      {0, NULL, NULL},
 
69
    };
 
70
 
 
71
    mplex_format_type =
 
72
        g_enum_register_static ("GstMplexFormat", mplex_formats);
 
73
  }
 
74
 
 
75
  return mplex_format_type;
 
76
}
 
77
 
 
78
/*
 
79
 * Class init functions.
 
80
 */
 
81
 
 
82
GstMplexJob::GstMplexJob (void):
 
83
MultiplexJob ()
 
84
{
 
85
  /* blabla */
 
86
  bufsize = 0;
 
87
}
 
88
 
 
89
/*
 
90
 * GObject properties.
 
91
 */
 
92
 
 
93
void
 
94
GstMplexJob::initProperties (GObjectClass * klass)
 
95
{
 
96
  /* encoding profile */
 
97
  g_object_class_install_property (klass, ARG_FORMAT,
 
98
      g_param_spec_enum ("format", "Format", "Encoding profile format",
 
99
          GST_TYPE_MPLEX_FORMAT, 0, (GParamFlags) G_PARAM_READWRITE));
 
100
 
 
101
  /* total stream datarate. Normally, this shouldn't be needed, but
 
102
   * some DVD/VCD/SVCD players really need strict values to handle
 
103
   * the created files correctly. */
 
104
  g_object_class_install_property (klass, ARG_MUX_BITRATE,
 
105
      g_param_spec_int ("mux-bitrate", "Mux. bitrate",
 
106
          "Bitrate of output stream in kbps (0 = autodetect)",
 
107
          0, 15 * 1024, 0, (GParamFlags) G_PARAM_READWRITE));
 
108
 
 
109
  /* override decode buffer size otherwise determined by format */
 
110
  g_object_class_install_property (klass, ARG_BUFSIZE,
 
111
      g_param_spec_int ("bufsize", "Decoder buf. size",
 
112
          "Target decoders video buffer size (kB) "
 
113
          "[default determined by format if not explicitly set]",
 
114
          20, 4000, 46, (GParamFlags) G_PARAM_READWRITE));
 
115
 
 
116
  /* some boolean stuff for headers */
 
117
  g_object_class_install_property (klass, ARG_VBR,
 
118
      g_param_spec_boolean ("vbr", "VBR",
 
119
          "Whether the input video stream is variable bitrate",
 
120
          FALSE, (GParamFlags) G_PARAM_READWRITE));
 
121
  g_object_class_install_property (klass, ARG_SYSTEM_HEADERS,
 
122
      g_param_spec_boolean ("system-headers", "System headers",
 
123
          "Create system header in every pack for generic formats",
 
124
          FALSE, (GParamFlags) G_PARAM_READWRITE));
 
125
#if 0                           /* not supported */
 
126
  g_object_class_install_property (klass, ARG_SPLIT_SEQUENCE,
 
127
      g_param_spec_boolean ("split-sequence", "Split sequence",
 
128
          "Simply split a sequence across files "
 
129
          "(rather than building run-out/run-in)",
 
130
          FALSE, (GParamFlags) G_PARAM_READWRITE));
 
131
 
 
132
  /* size of a segment */
 
133
  g_object_class_install_property (klass, ARG_SEGMENT_SIZE,
 
134
      g_param_spec_int ("max-segment-size", "Max. segment size",
 
135
          "Max. size per segment/file in MB (0 = unlimited)",
 
136
          0, 10 * 1024, 0, (GParamFlags) G_PARAM_READWRITE));
 
137
#endif
 
138
 
 
139
  /* packets per pack (generic formats) */
 
140
  g_object_class_install_property (klass, ARG_PACKETS_PER_PACK,
 
141
      g_param_spec_int ("packets-per-pack", "Packets per pack",
 
142
          "Number of packets per pack for generic formats",
 
143
          1, 100, 1, (GParamFlags) G_PARAM_READWRITE));
 
144
 
 
145
  /* size of one sector */
 
146
  g_object_class_install_property (klass, ARG_SECTOR_SIZE,
 
147
      g_param_spec_int ("sector-size", "Sector size",
 
148
          "Specify sector size in bytes for generic formats",
 
149
          256, 16384, 2048, (GParamFlags) G_PARAM_READWRITE));
 
150
}
 
151
 
 
152
/*
 
153
 * set/get gobject properties.
 
154
 */
 
155
 
 
156
void
 
157
GstMplexJob::getProperty (guint prop_id, GValue * value)
 
158
{
 
159
  switch (prop_id) {
 
160
    case ARG_FORMAT:
 
161
      g_value_set_enum (value, mux_format);
 
162
      break;
 
163
    case ARG_MUX_BITRATE:
 
164
      /* convert from bytes back to bits */
 
165
      g_value_set_int (value, (data_rate * 8) / 1000);
 
166
      break;
 
167
    case ARG_VBR:
 
168
      g_value_set_boolean (value, VBR);
 
169
      break;
 
170
    case ARG_SYSTEM_HEADERS:
 
171
      g_value_set_boolean (value, always_system_headers);
 
172
      break;
 
173
    case ARG_SPLIT_SEQUENCE:
 
174
      g_value_set_boolean (value, multifile_segment);
 
175
      break;
 
176
    case ARG_SEGMENT_SIZE:
 
177
      g_value_set_int (value, max_segment_size);
 
178
      break;
 
179
    case ARG_PACKETS_PER_PACK:
 
180
      g_value_set_int (value, packets_per_pack);
 
181
      break;
 
182
    case ARG_SECTOR_SIZE:
 
183
      g_value_set_int (value, sector_size);
 
184
      break;
 
185
    case ARG_BUFSIZE:
 
186
      g_value_set_int (value, bufsize);
 
187
      break;
 
188
    default:
 
189
      break;
 
190
  }
 
191
}
 
192
 
 
193
void
 
194
GstMplexJob::setProperty (guint prop_id, const GValue * value)
 
195
{
 
196
  switch (prop_id) {
 
197
    case ARG_FORMAT:
 
198
      mux_format = g_value_get_enum (value);
 
199
      break;
 
200
    case ARG_MUX_BITRATE:
 
201
      /* data_rate expects bytes (don't ask me why the property itself is
 
202
       * in bits, I'm just staying compatible to mjpegtools options), and
 
203
       * rounded up to 50-bytes. */
 
204
      data_rate = ((g_value_get_int (value) * 1000 / 8 + 49) / 50) * 50;
 
205
      break;
 
206
    case ARG_VBR:
 
207
      VBR = g_value_get_boolean (value);
 
208
      break;
 
209
    case ARG_SYSTEM_HEADERS:
 
210
      always_system_headers = g_value_get_boolean (value);
 
211
      break;
 
212
    case ARG_SPLIT_SEQUENCE:
 
213
      multifile_segment = g_value_get_boolean (value);
 
214
      break;
 
215
    case ARG_SEGMENT_SIZE:
 
216
      max_segment_size = g_value_get_int (value);
 
217
      break;
 
218
    case ARG_PACKETS_PER_PACK:
 
219
      packets_per_pack = g_value_get_int (value);
 
220
      break;
 
221
    case ARG_SECTOR_SIZE:
 
222
      sector_size = g_value_get_int (value);
 
223
      break;
 
224
    case ARG_BUFSIZE:
 
225
      bufsize = g_value_get_int (value);
 
226
      break;
 
227
    default:
 
228
      break;
 
229
  }
 
230
}