예제 #1
0
static gboolean
gst_real_audio_demux_sink_activate_mode (GstPad * sinkpad, GstObject * parent,
    GstPadMode mode, gboolean active)
{
  gboolean res;
  GstRealAudioDemux *demux;

  demux = GST_REAL_AUDIO_DEMUX (parent);

  switch (mode) {
    case GST_PAD_MODE_PUSH:
      demux->seekable = FALSE;
      res = TRUE;
      break;
    case GST_PAD_MODE_PULL:
      if (active) {
        demux->seekable = TRUE;

        res = gst_pad_start_task (sinkpad,
            (GstTaskFunction) gst_real_audio_demux_loop, demux, NULL);
      } else {
        demux->seekable = FALSE;
        res = gst_pad_stop_task (sinkpad);
      }
      break;
    default:
      res = FALSE;
      break;
  }
  return res;
}
/**
 * hls_progress_buffer_activatepush_src()
 *
 * Set the source pad's push mode.
 */
static gboolean hls_progress_buffer_activatepush_src(GstPad *pad, gboolean active)
{
    HLSProgressBuffer *element = HLS_PROGRESS_BUFFER(GST_PAD_PARENT(pad));

    if (active)
    {
        g_mutex_lock(element->lock);
        element->srcresult = GST_FLOW_OK;
        g_mutex_unlock(element->lock);

        if (gst_pad_is_linked(pad))
            return gst_pad_start_task(pad, hls_progress_buffer_loop, element);
        else
            return TRUE;
    }
    else
    {
        g_mutex_lock(element->lock);
        element->srcresult = GST_FLOW_WRONG_STATE;
        g_cond_signal(element->add_cond);
        g_cond_signal(element->del_cond);
        g_mutex_unlock(element->lock);

        return gst_pad_stop_task(pad);
    }
}
예제 #3
0
/**
 * progress_buffer_activatepush_src()
 *
 * Set the source pad's push mode.
 */
static gboolean progress_buffer_activatepush_src(GstPad *pad, GstObject *parent, gboolean active)
{
    ProgressBuffer *element = PROGRESS_BUFFER(parent);

    if (active)
    {
        g_mutex_lock(&element->lock);
        element->srcresult = GST_FLOW_OK;
        // Do not clear pending events, since we might get events before pad is activated.
        reset_eos(element, FALSE);
        element->unexpected = FALSE;
        g_mutex_unlock(&element->lock);

        if (gst_pad_is_linked(pad))
            return gst_pad_start_task(pad, progress_buffer_loop, element, NULL);
        else
            return TRUE;
    }
    else
    {
        g_mutex_lock(&element->lock);
        element->srcresult = GST_FLOW_FLUSHING;
        g_cond_signal(&element->add_cond);
        g_mutex_unlock(&element->lock);

        return gst_pad_stop_task(pad);
    }
}
예제 #4
0
static void
gst_omx_audio_enc_flush (GstAudioEncoder * encoder)
{
  GstOMXAudioEnc *self;

  self = GST_OMX_AUDIO_ENC (encoder);

  GST_DEBUG_OBJECT (self, "Resetting encoder");

  gst_omx_audio_enc_drain (self);

  gst_omx_port_set_flushing (self->enc_in_port, 5 * GST_SECOND, TRUE);
  gst_omx_port_set_flushing (self->enc_out_port, 5 * GST_SECOND, TRUE);

  /* Wait until the srcpad loop is finished */
  GST_AUDIO_ENCODER_STREAM_UNLOCK (self);
  GST_PAD_STREAM_LOCK (GST_AUDIO_ENCODER_SRC_PAD (self));
  GST_PAD_STREAM_UNLOCK (GST_AUDIO_ENCODER_SRC_PAD (self));
  GST_AUDIO_ENCODER_STREAM_LOCK (self);

  gst_omx_port_set_flushing (self->enc_in_port, 5 * GST_SECOND, FALSE);
  gst_omx_port_set_flushing (self->enc_out_port, 5 * GST_SECOND, FALSE);
  gst_omx_port_populate (self->enc_out_port);

  /* Start the srcpad loop again */
  self->last_upstream_ts = 0;
  self->downstream_flow_ret = GST_FLOW_OK;
  self->eos = FALSE;
  gst_pad_start_task (GST_AUDIO_ENCODER_SRC_PAD (self),
      (GstTaskFunction) gst_omx_audio_enc_loop, encoder, NULL);
}
static gboolean
gst_type_find_element_activate_sink (GstPad * pad, GstObject * parent)
{
  GstQuery *query;
  gboolean pull_mode;

  query = gst_query_new_scheduling ();

  if (!gst_pad_peer_query (pad, query)) {
    gst_query_unref (query);
    goto typefind_push;
  }

  pull_mode = gst_query_has_scheduling_mode_with_flags (query,
      GST_PAD_MODE_PULL, GST_SCHEDULING_FLAG_SEEKABLE);

  gst_query_unref (query);

  if (!pull_mode)
    goto typefind_push;

  if (!gst_pad_activate_mode (pad, GST_PAD_MODE_PULL, TRUE))
    goto typefind_push;

  /* only start our task if we ourselves decide to start in pull mode */
  return gst_pad_start_task (pad, (GstTaskFunction) gst_type_find_element_loop,
      pad, NULL);

typefind_push:
  {
    return gst_pad_activate_mode (pad, GST_PAD_MODE_PUSH, TRUE);
  }
}
예제 #6
0
static GstPadLinkReturn
gst_frame_store_link_src (GstPad *pad, GstPad *peer)
{
  GstPadLinkReturn result = GST_PAD_LINK_OK;
  GstFrameStore *fs;
  
  fs = GST_FRAME_STORE(gst_pad_get_parent(pad));

  if (GST_PAD_LINKFUNC (peer)) {
    result = GST_PAD_LINKFUNC(peer) (peer, pad);
  }

  if (GST_PAD_LINK_SUCCESSFUL (result)) {
    g_mutex_lock (fs->lock);
    
fs->srcresult = GST_FLOW_OK;
    if (fs->srcresult == GST_FLOW_OK) {
      gst_pad_start_task (pad, (GstTaskFunction) gst_frame_store_task,
          pad);
    } else {
      GST_DEBUG("not starting task");
      /* not starting task */
    }
    g_mutex_unlock (fs->lock);
  }

  gst_object_unref (fs);

  return result;
}
예제 #7
0
static gboolean
gst_cdxa_parse_do_seek (GstCDXAParse * cdxa, GstEvent * event)
{
  GstSeekFlags flags;
  GstSeekType start_type;
  GstFormat format;
  gint64 start, off, upstream_size;

  gst_event_parse_seek (event, NULL, &format, &flags, &start_type, &start,
      NULL, NULL);

  if (format != GST_FORMAT_BYTES) {
    GST_DEBUG_OBJECT (cdxa, "Can only handle seek in BYTES format");
    return FALSE;
  }

  if (start_type != GST_SEEK_TYPE_SET) {
    GST_DEBUG_OBJECT (cdxa, "Can only handle seek from start (SEEK_TYPE_SET)");
    return FALSE;
  }

  GST_OBJECT_LOCK (cdxa);
  off = gst_cdxa_parse_convert_src_to_sink_offset (cdxa, start);
  upstream_size = cdxa->datasize;
  GST_OBJECT_UNLOCK (cdxa);

  if (off >= upstream_size) {
    GST_DEBUG_OBJECT (cdxa, "Invalid target offset %" G_GINT64_FORMAT ", file "
        "is only %" G_GINT64_FORMAT " bytes in size", off, upstream_size);
    return FALSE;
  }

  /* unlock upstream pull_range */
  gst_pad_push_event (cdxa->sinkpad, gst_event_new_flush_start ());

  /* make sure our loop function exits */
  gst_pad_push_event (cdxa->srcpad, gst_event_new_flush_start ());

  /* wait for streaming to finish */
  GST_PAD_STREAM_LOCK (cdxa->sinkpad);

  /* prepare for streaming again */
  gst_pad_push_event (cdxa->sinkpad, gst_event_new_flush_stop ());
  gst_pad_push_event (cdxa->srcpad, gst_event_new_flush_stop ());

  gst_pad_push_event (cdxa->srcpad,
      gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES,
          start, GST_CLOCK_TIME_NONE, 0));

  GST_OBJECT_LOCK (cdxa);
  cdxa->offset = off;
  GST_OBJECT_UNLOCK (cdxa);

  /* and restart */
  gst_pad_start_task (cdxa->sinkpad,
      (GstTaskFunction) gst_cdxa_parse_loop, cdxa->sinkpad, NULL);

  GST_PAD_STREAM_UNLOCK (cdxa->sinkpad);
  return TRUE;
}
예제 #8
0
static gboolean
gst_rtp_jitter_buffer_src_activate_push (GstPad * pad, gboolean active)
{
  gboolean result = TRUE;
  GstRtpJitterBuffer *jitterbuffer = NULL;

  jitterbuffer = GST_RTP_JITTER_BUFFER (gst_pad_get_parent (pad));

  if (active) {
    /* allow data processing */
    gst_rtp_jitter_buffer_flush_stop (jitterbuffer);

    /* start pushing out buffers */
    GST_DEBUG_OBJECT (jitterbuffer, "Starting task on srcpad");
    gst_pad_start_task (jitterbuffer->priv->srcpad,
        (GstTaskFunction) gst_rtp_jitter_buffer_loop, jitterbuffer);
  } else {
    /* make sure all data processing stops ASAP */
    gst_rtp_jitter_buffer_flush_start (jitterbuffer);

    /* NOTE this will hardlock if the state change is called from the src pad
     * task thread because we will _join() the thread. */
    GST_DEBUG_OBJECT (jitterbuffer, "Stopping task on srcpad");
    result = gst_pad_stop_task (pad);
  }

  gst_object_unref (jitterbuffer);

  return result;
}
예제 #9
0
static gboolean
gst_sctp_enc_src_activate_mode (GstPad * pad, GstObject * parent,
                                GstPadMode mode, gboolean active)
{
    GstSctpEnc *self = GST_SCTP_ENC(parent);
    gboolean ret = FALSE;

    switch (mode) {
    case GST_PAD_MODE_PUSH:
        if (active) {
            self->need_segment = self->need_stream_start_caps = TRUE;
            gst_data_queue_set_flushing(self->outbound_sctp_packet_queue, FALSE);
            gst_pad_start_task(self->src_pad,
                               (GstTaskFunction)gst_sctp_enc_srcpad_loop, self->src_pad, NULL);
            ret = configure_association(self);
        } else {
            sctpenc_cleanup(self);
            ret = TRUE;
        }
        GST_DEBUG_OBJECT (self, "activate_mode: active %d, ret %d", active, ret);
        break;
    default:
        break;
    }

    return ret;
}
예제 #10
0
/* src operating in push mode, we start a task on the source pad that pushes out
 * buffers from the cache */
static inline gboolean
gst_ts_shifter_src_activate (GstPad * pad, GstObject * parent, gboolean active)
{
  GstTSShifter *ts = GST_TS_SHIFTER (parent);
  gboolean ret = FALSE;

  if (active) {
    FLOW_MUTEX_LOCK (ts);
    GST_DEBUG_OBJECT (ts, "activating push mode");
    ts->srcresult = GST_FLOW_OK;
    ts->sinkresult = GST_FLOW_OK;
    ts->is_eos = FALSE;
    ts->unexpected = FALSE;
    ret =
        gst_pad_start_task (pad, (GstTaskFunction) gst_ts_shifter_loop, pad,
        NULL);
    FLOW_MUTEX_UNLOCK (ts);
  } else {
    /* unblock loop function */
    FLOW_MUTEX_LOCK (ts);
    GST_DEBUG_OBJECT (ts, "deactivating push mode");
    ts->srcresult = GST_FLOW_FLUSHING;
    ts->sinkresult = GST_FLOW_FLUSHING;
    /* the item add signal will unblock */
    FLOW_SIGNAL_ADD (ts);
    FLOW_MUTEX_UNLOCK (ts);

    /* step 2, make sure streaming finishes */
    ret = gst_pad_stop_task (pad);
  }

  return ret;
}
예제 #11
0
static gboolean
mpegts_base_sink_activate_mode (GstPad * pad, GstObject * parent,
    GstPadMode mode, gboolean active)
{
  gboolean res;
  MpegTSBase *base = GST_MPEGTS_BASE (parent);

  switch (mode) {
    case GST_PAD_MODE_PUSH:
      base->mode = BASE_MODE_PUSHING;
      res = TRUE;
      break;
    case GST_PAD_MODE_PULL:
      if (active) {
        base->mode = BASE_MODE_SCANNING;
        /* When working pull-based, we always use offsets for estimation */
        base->packetizer->calculate_offset = TRUE;
        base->packetizer->calculate_skew = FALSE;
        gst_segment_init (&base->segment, GST_FORMAT_BYTES);
        res =
            gst_pad_start_task (pad, (GstTaskFunction) mpegts_base_loop, base,
            NULL);
      } else
        res = gst_pad_stop_task (pad);
      break;
    default:
      res = FALSE;
      break;
  }
  return res;
}
static gboolean
gst_rnd_buffer_size_activate_mode (GstPad * pad, GstObject * parent,
    GstPadMode mode, gboolean active)
{
  gboolean res;
  GstRndBufferSize *self = GST_RND_BUFFER_SIZE (parent);

  switch (mode) {
    case GST_PAD_MODE_PULL:
      if (active) {
        GST_INFO_OBJECT (self, "starting pull");
        res =
            gst_pad_start_task (pad, (GstTaskFunction) gst_rnd_buffer_size_loop,
            self, NULL);
        self->need_newsegment = TRUE;
      } else {
        GST_INFO_OBJECT (self, "stopping pull");
        res = gst_pad_stop_task (pad);
      }
      break;
    case GST_PAD_MODE_PUSH:
      GST_INFO_OBJECT (self, "%sactivating in push mode", (active) ? "" : "de");
      res = TRUE;
      break;
    default:
      res = FALSE;
      break;
  }
  return res;
}
예제 #13
0
static gboolean
gst_midi_parse_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
  gboolean res;
  GstMidiParse *midiparse = GST_MIDI_PARSE (parent);

  GST_DEBUG_OBJECT (pad, "%s event received", GST_EVENT_TYPE_NAME (event));

  switch (GST_EVENT_TYPE (event)) {
    case GST_EVENT_EOS:
      midiparse->state = GST_MIDI_PARSE_STATE_PARSE;
      /* now start the parsing task */
      res = gst_pad_start_task (midiparse->sinkpad,
          (GstTaskFunction) gst_midi_parse_loop, midiparse->sinkpad, NULL);
      /* don't forward the event */
      gst_event_unref (event);
      break;
    case GST_EVENT_CAPS:
    case GST_EVENT_STREAM_START:
    case GST_EVENT_SEGMENT:
      res = TRUE;
      gst_event_unref (event);
      break;
    default:
      res = gst_pad_event_default (pad, parent, event);
      break;
  }
  return res;
}
예제 #14
0
static gboolean
gst_live_adder_src_activate_push (GstPad * pad, gboolean active)
{
    gboolean result = TRUE;
    GstLiveAdder *adder = NULL;

    adder = GST_LIVE_ADDER (gst_pad_get_parent (pad));

    if (active) {
        /* Mark as non flushing */
        GST_OBJECT_LOCK (adder);
        adder->srcresult = GST_FLOW_OK;
        GST_OBJECT_UNLOCK (adder);

        /* start pushing out buffers */
        GST_DEBUG_OBJECT (adder, "Starting task on srcpad");
        gst_pad_start_task (adder->srcpad,
                            (GstTaskFunction) gst_live_adder_loop, adder);
    } else {
        /* make sure all data processing stops ASAP */
        gst_live_adder_flush_start (adder);

        /* NOTE this will hardlock if the state change is called from the src pad
         * task thread because we will _join() the thread. */
        GST_DEBUG_OBJECT (adder, "Stopping task on srcpad");
        result = gst_pad_stop_task (pad);
    }

    gst_object_unref (adder);

    return result;
}
static gboolean src_activate_mode(GstPad *pad, GstErDtlsEnc *self, GstPadMode mode, gboolean active)
{
    gboolean success = TRUE;
    g_return_val_if_fail(mode == GST_PAD_MODE_PUSH, FALSE);

    if (active) {
        GST_DEBUG_OBJECT(self, "src pad activating in push mode");

        self->send_initial_events = TRUE;
        success = gst_pad_start_task(pad, (GstTaskFunction) src_task_loop, self->src, NULL);
        if (!success) {
            GST_WARNING_OBJECT(self, "failed to activate pad task");
        }
    } else {
        GST_DEBUG_OBJECT(self, "deactivating src pad");

        g_cond_signal(&self->queue_cond_add);

        success = gst_pad_stop_task(pad);
        if (!success) {
            GST_WARNING_OBJECT(self, "failed to deactivate pad task");
        }
    }

    return success;
}
예제 #16
0
static gboolean gst_sctp_dec_src_event(GstPad *pad, GstSctpDec *self, GstEvent *event)
{
    switch (GST_EVENT_TYPE(event)) {
        case GST_EVENT_RECONFIGURE:
        case GST_EVENT_FLUSH_STOP: {
            GstSctpDecPad *sctpdec_pad = GST_SCTP_DEC_PAD(pad);

            /* Unflush and start task again */
            gst_data_queue_set_flushing(sctpdec_pad->packet_queue, FALSE);
            gst_pad_start_task(pad, (GstTaskFunction)gst_sctp_data_srcpad_loop, pad, NULL);

            return gst_pad_event_default(pad, GST_OBJECT(self), event);
        }
        case GST_EVENT_FLUSH_START: {
            GstSctpDecPad *sctpdec_pad = GST_SCTP_DEC_PAD(pad);

            gst_data_queue_set_flushing(sctpdec_pad->packet_queue, TRUE);
            gst_data_queue_flush(sctpdec_pad->packet_queue);

            return gst_pad_event_default(pad, GST_OBJECT(self), event);
        }
        default:
            return gst_pad_event_default(pad, GST_OBJECT(self), event);
    }
}
예제 #17
0
static void
gst_amc_audio_dec_flush (GstAudioDecoder * decoder, gboolean hard)
{
    GstAmcAudioDec *self;

    self = GST_AMC_AUDIO_DEC (decoder);

    GST_DEBUG_OBJECT (self, "Resetting decoder");

    if (!self->started) {
        GST_DEBUG_OBJECT (self, "Codec not started yet");
        return;
    }

    self->flushing = TRUE;
    /* Wait until the srcpad loop is finished,
     * unlock GST_AUDIO_DECODER_STREAM_LOCK to prevent deadlocks
     * caused by using this lock from inside the loop function */
    GST_AUDIO_DECODER_STREAM_UNLOCK (self);
    GST_PAD_STREAM_LOCK (GST_AUDIO_DECODER_SRC_PAD (self));
    GST_PAD_STREAM_UNLOCK (GST_AUDIO_DECODER_SRC_PAD (self));
    GST_AUDIO_DECODER_STREAM_LOCK (self);
    gst_amc_codec_flush (self->codec);
    self->flushing = FALSE;

    /* Start the srcpad loop again */
    self->last_upstream_ts = 0;
    self->eos = FALSE;
    self->downstream_flow_ret = GST_FLOW_OK;
    gst_pad_start_task (GST_AUDIO_DECODER_SRC_PAD (self),
                        (GstTaskFunction) gst_amc_audio_dec_loop, decoder, NULL);

    GST_DEBUG_OBJECT (self, "Reset decoder");
}
예제 #18
0
static gboolean
gst_asf_parse_sink_activate_mode (GstPad * pad, GstObject * parent,
    GstPadMode mode, gboolean active)
{
  gboolean res;

  switch (mode) {
    case GST_PAD_MODE_PULL:
      if (active) {
        res =
            gst_pad_start_task (pad, (GstTaskFunction) gst_asf_parse_loop, pad,
            NULL);
      } else {
        res = gst_pad_stop_task (pad);
      }
    case GST_PAD_MODE_PUSH:
      res = TRUE;
      break;
    default:
      res = FALSE;
      break;
  }

  return res;
}
예제 #19
0
static void
_start_srcpad_task (GstAggregator * self)
{
  GST_INFO_OBJECT (self, "Starting srcpad task");

  self->priv->running = TRUE;
  gst_pad_start_task (GST_PAD (self->srcpad),
      (GstTaskFunction) iterate_main_context_func, self, NULL);
}
예제 #20
0
static gboolean
gst_rdt_manager_src_activate_mode (GstPad * pad, GstObject * parent,
    GstPadMode mode, gboolean active)
{
  gboolean result;
  GstRDTManager *rdtmanager;
  GstRDTManagerSession *session;

  session = gst_pad_get_element_private (pad);
  rdtmanager = session->dec;

  switch (mode) {
    case GST_PAD_MODE_PUSH:
      if (active) {
        /* allow data processing */
        JBUF_LOCK (session);
        GST_DEBUG_OBJECT (rdtmanager, "Enabling pop on queue");
        /* Mark as non flushing */
        session->srcresult = GST_FLOW_OK;
        gst_segment_init (&session->segment, GST_FORMAT_TIME);
        session->last_popped_seqnum = -1;
        session->last_out_time = -1;
        session->next_seqnum = -1;
        session->eos = FALSE;
        JBUF_UNLOCK (session);

        /* start pushing out buffers */
        GST_DEBUG_OBJECT (rdtmanager, "Starting task on srcpad");
        result =
            gst_pad_start_task (pad, (GstTaskFunction) gst_rdt_manager_loop,
            pad, NULL);
      } else {
        /* make sure all data processing stops ASAP */
        JBUF_LOCK (session);
        /* mark ourselves as flushing */
        session->srcresult = GST_FLOW_FLUSHING;
        GST_DEBUG_OBJECT (rdtmanager, "Disabling pop on queue");
        /* this unblocks any waiting pops on the src pad task */
        JBUF_SIGNAL (session);
        /* unlock clock, we just unschedule, the entry will be released by
         * the locking streaming thread. */
        if (session->clock_id)
          gst_clock_id_unschedule (session->clock_id);
        JBUF_UNLOCK (session);

        /* NOTE this will hardlock if the state change is called from the src pad
         * task thread because we will _join() the thread. */
        GST_DEBUG_OBJECT (rdtmanager, "Stopping task on srcpad");
        result = gst_pad_stop_task (pad);
      }
      break;
    default:
      result = FALSE;
      break;
  }
  return result;
}
예제 #21
0
static gboolean
gst_timidity_activatepull (GstPad * pad, gboolean active)
{
  if (active) {
    return gst_pad_start_task (pad, (GstTaskFunction) gst_timidity_loop, pad);
  } else {
    return gst_pad_stop_task (pad);
  }
}
예제 #22
0
static gboolean
activate_push (GstPad *pad,
               gboolean active)
{
    gboolean result = TRUE;
    GstOmxBaseFilter *self;

    self = GST_OMX_BASE_FILTER (gst_pad_get_parent (pad));

    if (active)
    {
        GST_DEBUG_OBJECT (self, "activate");
        /* task may carry on */
        g_atomic_int_set (&self->last_pad_push_return, GST_FLOW_OK);

        /* we do not start the task yet if the pad is not connected */
        if (gst_pad_is_linked (pad))
        {
            if (self->ready)
            {
                /** @todo link callback function also needed */
                g_omx_port_resume (self->in_port);
                g_omx_port_resume (self->out_port);

                result = gst_pad_start_task (pad, output_loop, pad);
            }
        }
    }
    else
    {
        GST_DEBUG_OBJECT (self, "deactivate");

        /* persuade task to bail out */
        g_atomic_int_set (&self->last_pad_push_return, GST_FLOW_WRONG_STATE);

        if (self->ready)
        {
            /** @todo disable this until we properly reinitialize the buffers. */
#if 0
            /* flush all buffers */
            OMX_SendCommand (self->gomx->omx_handle, OMX_CommandFlush, OMX_ALL, NULL);
#endif

            /* unlock loops */
            g_omx_port_pause (self->in_port);
            g_omx_port_pause (self->out_port);
        }

        /* make sure streaming finishes */
        result = gst_pad_stop_task (pad);
    }

    gst_object_unref (self);

    return result;
}
예제 #23
0
/* this function gets called when we activate ourselves in pull mode.
 * We can perform  random access to the resource and we start a task
 * to start reading */
static gboolean
gst_pngdec_sink_activate_pull (GstPad * sinkpad, gboolean active)
{
  if (active) {
    return gst_pad_start_task (sinkpad, (GstTaskFunction) gst_pngdec_task,
        sinkpad);
  } else {
    return gst_pad_stop_task (sinkpad);
  }
}
예제 #24
0
static gboolean
gst_vaapiencode_set_format (GstVideoEncoder * venc, GstVideoCodecState * state)
{
  GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (venc);
  gboolean ret;

  g_return_val_if_fail (state->caps != NULL, FALSE);

  if (!set_codec_state (encode, state))
    return FALSE;

  if (!gst_vaapi_plugin_base_set_caps (GST_VAAPI_PLUGIN_BASE (encode),
          state->caps, NULL))
    return FALSE;

  if (encode->input_state)
    gst_video_codec_state_unref (encode->input_state);
  encode->input_state = gst_video_codec_state_ref (state);
  encode->input_state_changed = TRUE;

  ret = gst_pad_start_task (GST_VAAPI_PLUGIN_BASE_SRC_PAD (encode),
      (GstTaskFunction) gst_vaapiencode_buffer_loop, encode, NULL);

  if (!ret)
    return FALSE;

  /* Store some tags */
  {
    GstTagList *tags = gst_tag_list_new_empty ();
    const gchar *encoder, *codec;
    guint bitrate = 0;

    g_object_get (encode, "bitrate", &bitrate, NULL);
    gst_tag_list_add (tags, GST_TAG_MERGE_REPLACE, GST_TAG_NOMINAL_BITRATE,
        bitrate, NULL);

    if ((encoder =
            gst_element_class_get_metadata (GST_ELEMENT_GET_CLASS (encode),
                GST_ELEMENT_METADATA_LONGNAME)))
      gst_tag_list_add (tags, GST_TAG_MERGE_REPLACE, GST_TAG_ENCODER, encoder,
          NULL);

    if ((codec =
            gst_vaapi_codec_get_name (gst_vaapi_profile_get_codec
                (gst_vaapi_profile_from_caps (state->caps)))))
      gst_tag_list_add (tags, GST_TAG_MERGE_REPLACE, GST_TAG_CODEC, codec,
          NULL);

    gst_video_encoder_merge_tags (venc, tags, GST_TAG_MERGE_REPLACE);
    gst_tag_list_unref (tags);
  }

  return TRUE;
}
예제 #25
0
static gboolean
gst_tcp_mix_src_pad_start (GstTCPMixSrcPad * pad)
{
  gboolean res = FALSE;

  if (GST_PAD_TASK (pad) == NULL) {
    GstTaskFunction func = (GstTaskFunction) gst_tcp_mix_src_loop;
    res = gst_pad_start_task (GST_PAD (pad), func, GST_PAD (pad), NULL);
  }

  return res;
}
예제 #26
0
static gboolean
gst_rnd_buffer_size_src_event (GstPad * pad, GstObject * parent,
    GstEvent * event)
{
  GstRndBufferSize *self;
  GstSeekType start_type;
  GstSeekFlags flags;
  GstFormat format;
  gint64 start;

  if (GST_EVENT_TYPE (event) != GST_EVENT_SEEK) {
    GST_WARNING_OBJECT (pad, "dropping %s event", GST_EVENT_TYPE_NAME (event));
    return FALSE;
  }

  self = GST_RND_BUFFER_SIZE (parent);
  gst_event_parse_seek (event, NULL, &format, &flags, &start_type, &start,
      NULL, NULL);

  if (format != GST_FORMAT_BYTES) {
    GST_WARNING_OBJECT (pad, "only BYTE format supported");
    return FALSE;
  }
  if (start_type != GST_SEEK_TYPE_SET) {
    GST_WARNING_OBJECT (pad, "only SEEK_TYPE_SET supported");
    return FALSE;
  }

  if ((flags & GST_SEEK_FLAG_FLUSH)) {
    gst_pad_push_event (self->srcpad, gst_event_new_flush_start ());
    gst_pad_push_event (self->sinkpad, gst_event_new_flush_start ());
  } else {
    gst_pad_pause_task (self->sinkpad);
  }

  GST_PAD_STREAM_LOCK (self->sinkpad);

  if ((flags & GST_SEEK_FLAG_FLUSH)) {
    gst_pad_push_event (self->srcpad, gst_event_new_flush_stop (TRUE));
    gst_pad_push_event (self->sinkpad, gst_event_new_flush_stop (TRUE));
  }

  GST_INFO_OBJECT (pad, "seeking to offset %" G_GINT64_FORMAT, start);

  self->offset = start;
  self->need_newsegment = TRUE;

  gst_pad_start_task (self->sinkpad, (GstTaskFunction) gst_rnd_buffer_size_loop,
      self);

  GST_PAD_STREAM_UNLOCK (self->sinkpad);
  return TRUE;
}
예제 #27
0
static void flush_srcpad(const GValue *item, gpointer user_data)
{
    GstSctpDecPad *sctpdec_pad = g_value_get_object(item);
    gboolean flush = GPOINTER_TO_INT(user_data);

    if (flush) {
        gst_data_queue_set_flushing(sctpdec_pad->packet_queue, TRUE);
        gst_data_queue_flush(sctpdec_pad->packet_queue);
    } else {
        gst_data_queue_set_flushing(sctpdec_pad->packet_queue, FALSE);
        gst_pad_start_task(GST_PAD(sctpdec_pad), (GstTaskFunction)gst_sctp_data_srcpad_loop, sctpdec_pad, NULL);
    }
}
예제 #28
0
static gboolean
gst_cdxa_parse_sink_activate_pull (GstPad * sinkpad, gboolean active)
{
  if (active) {
    /* if we have a scheduler we can start the task */
    gst_pad_start_task (sinkpad, (GstTaskFunction) gst_cdxa_parse_loop,
        sinkpad, NULL);
  } else {
    gst_pad_stop_task (sinkpad);
  }

  return TRUE;
}
예제 #29
0
static gboolean
gst_aiff_parse_sink_activate_pull (GstPad * sinkpad, gboolean active)
{
  GstAiffParse *aiff = GST_AIFF_PARSE (GST_OBJECT_PARENT (sinkpad));

  if (active) {
    aiff->segment_running = TRUE;
    return gst_pad_start_task (sinkpad, (GstTaskFunction) gst_aiff_parse_loop,
        sinkpad);
  } else {
    aiff->segment_running = FALSE;
    return gst_pad_stop_task (sinkpad);
  }
};
예제 #30
0
static gboolean
gst_musepackdec_sink_activate_pull (GstPad * sinkpad, gboolean active)
{
    gboolean result;

    if (active) {
        result = gst_pad_start_task (sinkpad,
                                     (GstTaskFunction) gst_musepackdec_loop, sinkpad);
    } else {
        result = gst_pad_stop_task (sinkpad);
    }

    return result;
}