~ubuntu-branches/ubuntu/saucy/gstreamer0.10/saucy

« back to all changes in this revision

Viewing changes to libs/gst/base/gstbasesrc.c

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2011-12-11 18:52:12 UTC
  • mfrom: (32.1.14 experimental)
  • Revision ID: package-import@ubuntu.com-20111211185212-3k215ps4qtyz2qa5
Tags: 0.10.35.2-1
* New upstream pre-release:
  + debian/control.in:
    - Build-depend on GLib >= 2.24.
  + debian/patches/99_ltmain_as-needed.patch:
    - Refreshed to apply cleanly again.
  + debian/libgstreamer.symbols:
    - Update symbols file with new API.
* debian/rules:
  + Remove all dependency_libs from the .la files (Closes: #633319).
* debian/control.in:
  + Put GI package into section introspection.
* debian/compat,
  debian/control.in,
  debian/gir1.2-gstreamer.install,
  debian/libgstreamer-dev.install,
  debian/libgstreamer.install,
  debian/patches/79_multiarch-backwards-compat.patch,
  debian/patches/80_ia32-hack.patch,
  debian/rules:
  + Transition package to multi-arch (Closes: #647481).
    Patch taken from the Ubuntu package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
165
165
#include <stdlib.h>
166
166
#include <string.h>
167
167
 
 
168
/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex
 
169
 * with newer GLib versions (>= 2.31.0) */
 
170
#define GLIB_DISABLE_DEPRECATION_WARNINGS
168
171
#include <gst/gst_private.h>
 
172
#include <gst/glib-compat-private.h>
169
173
 
170
174
#include "gstbasesrc.h"
171
175
#include "gsttypefindhelper.h"
234
238
  GstClockTimeDiff ts_offset;
235
239
 
236
240
  gboolean do_timestamp;
 
241
  volatile gint dynamic_size;
237
242
 
238
243
  /* stream sequence number */
239
244
  guint32 seqnum;
323
328
static GstFlowReturn gst_base_src_get_range (GstBaseSrc * src, guint64 offset,
324
329
    guint length, GstBuffer ** buf);
325
330
static gboolean gst_base_src_seekable (GstBaseSrc * src);
 
331
static gboolean gst_base_src_update_length (GstBaseSrc * src, guint64 offset,
 
332
    guint * length);
326
333
 
327
334
static void
328
335
gst_base_src_base_init (gpointer g_class)
585
592
}
586
593
 
587
594
/**
 
595
 * gst_base_src_set_dynamic_size:
 
596
 * @src: base source instance
 
597
 * @dynamic: new dynamic size mode
 
598
 *
 
599
 * If not @dynamic, size is only updated when needed, such as when trying to
 
600
 * read past current tracked size.  Otherwise, size is checked for upon each
 
601
 * read.
 
602
 *
 
603
 * Since: 0.10.36
 
604
 */
 
605
void
 
606
gst_base_src_set_dynamic_size (GstBaseSrc * src, gboolean dynamic)
 
607
{
 
608
  g_return_if_fail (GST_IS_BASE_SRC (src));
 
609
 
 
610
  g_atomic_int_set (&src->priv->dynamic_size, dynamic);
 
611
}
 
612
 
 
613
/**
588
614
 * gst_base_src_query_latency:
589
615
 * @src: the source
590
616
 * @live: (out) (allow-none): if the source is live
932
958
        {
933
959
          gint64 duration;
934
960
          GstFormat seg_format;
935
 
 
936
 
          GST_OBJECT_LOCK (src);
 
961
          guint length = 0;
 
962
 
 
963
          /* may have to refresh duration */
 
964
          if (g_atomic_int_get (&src->priv->dynamic_size))
 
965
            gst_base_src_update_length (src, 0, &length);
 
966
 
937
967
          /* this is the duration as configured by the subclass. */
 
968
          GST_OBJECT_LOCK (src);
938
969
          duration = src->segment.duration;
939
970
          seg_format = src->segment.format;
940
971
          GST_OBJECT_UNLOCK (src);
1039
1070
      GstClockTime min, max;
1040
1071
      gboolean live;
1041
1072
 
1042
 
      /* Subclasses should override and implement something usefull */
 
1073
      /* Subclasses should override and implement something useful */
1043
1074
      res = gst_base_src_query_latency (src, &live, &min, &max);
1044
1075
 
1045
1076
      GST_LOG_OBJECT (src, "report latency: live %d, min %" GST_TIME_FORMAT
1371
1402
 
1372
1403
  /* If we configured the seeksegment above, don't overwrite it now. Otherwise
1373
1404
   * copy the current segment info into the temp segment that we can actually
1374
 
   * attempt the seek with. We only update the real segment if the seek suceeds. */
 
1405
   * attempt the seek with. We only update the real segment if the seek succeeds. */
1375
1406
  if (!seekseg_configured) {
1376
1407
    memcpy (&seeksegment, &src->segment, sizeof (GstSegment));
1377
1408
 
1426
1457
        gst_event_new_new_segment_full (TRUE,
1427
1458
        src->segment.rate, src->segment.applied_rate, src->segment.format,
1428
1459
        src->segment.start, src->segment.last_stop, src->segment.time);
 
1460
    seeksegment.time = gst_segment_to_stream_time (&src->segment,
 
1461
        src->segment.format, src->segment.last_stop);
 
1462
    seeksegment.start = src->segment.last_stop;
1429
1463
    gst_event_set_seqnum (src->priv->close_segment, seqnum);
1430
1464
  }
1431
1465
 
1560
1594
       *    first and do EOS instead of entering it.
1561
1595
       *  - If we are in the _create function or we did not manage to set the
1562
1596
       *    flag fast enough and we are about to enter the _create function,
1563
 
       *    we unlock it so that we exit with WRONG_STATE immediatly. We then
 
1597
       *    we unlock it so that we exit with WRONG_STATE immediately. We then
1564
1598
       *    check the EOS flag and do the EOS logic.
1565
1599
       */
1566
1600
      g_atomic_int_set (&src->priv->pending_eos, TRUE);
2028
2062
  GstBaseSrcClass *bclass;
2029
2063
  GstFormat format;
2030
2064
  gint64 stop;
 
2065
  gboolean dynamic;
2031
2066
 
2032
2067
  bclass = GST_BASE_SRC_GET_CLASS (src);
2033
2068
 
2052
2087
      ", segment.stop %" G_GINT64_FORMAT ", maxsize %" G_GINT64_FORMAT, offset,
2053
2088
      *length, size, stop, maxsize);
2054
2089
 
 
2090
  dynamic = g_atomic_int_get (&src->priv->dynamic_size);
 
2091
  GST_DEBUG_OBJECT (src, "dynamic size: %d", dynamic);
 
2092
 
2055
2093
  /* check size if we have one */
2056
2094
  if (maxsize != -1) {
2057
2095
    /* if we run past the end, check if the file became bigger and
2058
2096
     * retry. */
2059
 
    if (G_UNLIKELY (offset + *length >= maxsize)) {
 
2097
    if (G_UNLIKELY (offset + *length >= maxsize || dynamic)) {
2060
2098
      /* see if length of the file changed */
2061
2099
      if (bclass->get_size)
2062
2100
        if (!bclass->get_size (src, &size))
2084
2122
   * segment is in bytes, we checked that above. */
2085
2123
  GST_OBJECT_LOCK (src);
2086
2124
  gst_segment_set_duration (&src->segment, GST_FORMAT_BYTES, size);
2087
 
  gst_segment_set_last_stop (&src->segment, GST_FORMAT_BYTES, offset);
2088
2125
  GST_OBJECT_UNLOCK (src);
2089
2126
 
2090
2127
  return TRUE;
2125
2162
  if (G_UNLIKELY (!gst_base_src_update_length (src, offset, &length)))
2126
2163
    goto unexpected_length;
2127
2164
 
 
2165
  /* track position */
 
2166
  GST_OBJECT_LOCK (src);
 
2167
  if (src->segment.format == GST_FORMAT_BYTES)
 
2168
    gst_segment_set_last_stop (&src->segment, GST_FORMAT_BYTES, offset);
 
2169
  GST_OBJECT_UNLOCK (src);
 
2170
 
2128
2171
  /* normally we don't count buffers */
2129
2172
  if (G_UNLIKELY (src->num_buffers_left >= 0)) {
2130
2173
    if (src->num_buffers_left == 0)
3116
3159
       * already did this */
3117
3160
 
3118
3161
      /* FIXME, deprecate this behaviour, it is very dangerous.
3119
 
       * the prefered way of sending EOS downstream is by sending
 
3162
       * the preferred way of sending EOS downstream is by sending
3120
3163
       * the EOS event to the element */
3121
3164
      if (!basesrc->priv->last_sent_eos) {
3122
3165
        GST_DEBUG_OBJECT (basesrc, "Sending EOS event");