|| GST_EVENT_TYPE (event) == GST_EVENT_FLUSH_STOP)
return gst_pad_push_event (decoder->base_video_codec.srcpad, event);
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (decoder);
decoder->current_frame_events =
g_list_prepend (decoder->current_frame_events, event);
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (decoder);
return TRUE;
}
GST_DEBUG_OBJECT (base_video_decoder, "setcaps %" GST_PTR_FORMAT, caps);
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_decoder);
+
memset (&state, 0, sizeof (state));
state.caps = gst_caps_ref (caps);
gst_caps_replace (&state.caps, NULL);
}
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_decoder);
g_object_unref (base_video_decoder);
return ret;
case GST_EVENT_EOS:
{
GstFlowReturn flow_ret;
- ;
+
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_decoder);
if (!base_video_decoder->packetized) {
do {
flow_ret =
if (flow_ret == GST_FLOW_OK)
ret = gst_base_video_decoder_push_src_event (base_video_decoder, event);
- }
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_decoder);
break;
+ }
case GST_EVENT_NEWSEGMENT:
{
gboolean update;
gint64 pos;
GstSegment *segment = &GST_BASE_VIDEO_CODEC (base_video_decoder)->segment;
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_decoder);
gst_event_parse_new_segment_full (event, &update, &rate,
&arate, &format, &start, &stop, &pos);
event = gst_event_new_new_segment_full (update, rate, arate,
GST_FORMAT_TIME, start, stop, pos);
} else {
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_decoder);
goto newseg_wrong_format;
}
}
update, rate, arate, format, start, stop, pos);
ret = gst_base_video_decoder_push_src_event (base_video_decoder, event);
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_decoder);
break;
}
case GST_EVENT_FLUSH_STOP:
{
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_decoder);
/* well, this is kind of worse than a DISCONT */
gst_base_video_decoder_flush (base_video_decoder, TRUE);
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_decoder);
}
default:
/* FIXME this changes the order of events */
{
GST_DEBUG_OBJECT (base_video_decoder, "reset full %d", full);
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_decoder);
+
if (full) {
gst_segment_init (&GST_BASE_VIDEO_CODEC (base_video_decoder)->segment,
GST_FORMAT_UNDEFINED);
GST_CLOCK_TIME_NONE;
GST_BASE_VIDEO_CODEC (base_video_decoder)->proportion = 0.5;
GST_OBJECT_UNLOCK (base_video_decoder);
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_decoder);
}
static GstFlowReturn
gst_base_video_decoder_chain (GstPad * pad, GstBuffer * buf)
{
GstBaseVideoDecoder *base_video_decoder;
+ GstFlowReturn ret = GST_FLOW_OK;
base_video_decoder = GST_BASE_VIDEO_DECODER (GST_PAD_PARENT (pad));
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)), GST_BUFFER_SIZE (buf));
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_decoder);
+
/* NOTE:
* requiring the pad to be negotiated makes it impossible to use
* oggdemux or filesrc ! decoder */
ret = gst_base_video_decoder_push_src_event (base_video_decoder, event);
if (!ret) {
GST_ERROR_OBJECT (base_video_decoder, "new segment event ret=%d", ret);
- return GST_FLOW_ERROR;
+ ret = GST_FLOW_ERROR;
+ goto done;
}
}
}
if (GST_BASE_VIDEO_CODEC (base_video_decoder)->segment.rate > 0.0)
- return gst_base_video_decoder_chain_forward (base_video_decoder, buf);
+ ret = gst_base_video_decoder_chain_forward (base_video_decoder, buf);
else
- return gst_base_video_decoder_chain_reverse (base_video_decoder, buf);
+ ret = gst_base_video_decoder_chain_reverse (base_video_decoder, buf);
+
+done:
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_decoder);
+ return ret;
}
static GstStateChangeReturn
if (base_video_decoder_class->stop) {
base_video_decoder_class->stop (base_video_decoder);
}
+
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_decoder);
gst_base_video_decoder_reset (base_video_decoder, TRUE);
g_list_foreach (base_video_decoder->current_frame_events,
(GFunc) gst_event_unref, NULL);
g_list_free (base_video_decoder->current_frame_events);
base_video_decoder->current_frame_events = NULL;
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_decoder);
break;
default:
break;
{
GstVideoFrame *frame;
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_decoder);
frame =
gst_base_video_codec_new_frame (GST_BASE_VIDEO_CODEC
(base_video_decoder));
frame->events = base_video_decoder->current_frame_events;
base_video_decoder->current_frame_events = NULL;
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_decoder);
+
return frame;
}
GList *l, *events = NULL;
GST_LOG_OBJECT (base_video_decoder, "finish frame");
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_decoder);
+
#ifndef GST_DISABLE_GST_DEBUG
- GST_OBJECT_LOCK (base_video_decoder);
GST_LOG_OBJECT (base_video_decoder, "n %d in %d out %d",
g_list_length (GST_BASE_VIDEO_CODEC (base_video_decoder)->frames),
gst_adapter_available (base_video_decoder->input_adapter),
gst_adapter_available (base_video_decoder->output_adapter));
- GST_OBJECT_UNLOCK (base_video_decoder);
#endif
GST_LOG_OBJECT (base_video_decoder,
GST_TIME_ARGS (frame->presentation_timestamp));
/* Push all pending events that arrived before this frame */
- GST_OBJECT_LOCK (base_video_decoder);
for (l = base_video_decoder->base_video_codec.frames; l; l = l->next) {
GstVideoFrame *tmp = l->data;
if (tmp == frame)
break;
}
- GST_OBJECT_UNLOCK (base_video_decoder);
for (l = g_list_last (events); l; l = l->next)
gst_pad_push_event (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_decoder),
GST_TIME_ARGS (segment->start),
GST_TIME_ARGS (segment->stop), GST_TIME_ARGS (segment->time));
gst_buffer_unref (src_buffer);
- return GST_FLOW_OK;
+ ret = GST_FLOW_OK;
+ goto done;
}
}
}
done:
- GST_OBJECT_LOCK (base_video_decoder);
GST_BASE_VIDEO_CODEC (base_video_decoder)->frames =
g_list_remove (GST_BASE_VIDEO_CODEC (base_video_decoder)->frames, frame);
- GST_OBJECT_UNLOCK (base_video_decoder);
gst_base_video_codec_free_frame (frame);
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_decoder);
+
return ret;
}
if (n_bytes == 0)
return;
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_decoder);
if (gst_adapter_available (base_video_decoder->output_adapter) == 0) {
base_video_decoder->frame_offset = base_video_decoder->input_offset -
gst_adapter_available (base_video_decoder->input_adapter);
buf = gst_adapter_take_buffer (base_video_decoder->input_adapter, n_bytes);
gst_adapter_push (base_video_decoder->output_adapter, buf);
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_decoder);
}
static guint64
int n_available;
GstClockTime timestamp;
GstClockTime duration;
+ GstFlowReturn ret = GST_FLOW_OK;
GST_LOG_OBJECT (base_video_decoder, "have_frame");
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_decoder);
+
n_available = gst_adapter_available (base_video_decoder->output_adapter);
if (n_available) {
buffer = gst_adapter_take_buffer (base_video_decoder->output_adapter,
"ts %" GST_TIME_FORMAT ", dur %" GST_TIME_FORMAT,
n_available, GST_TIME_ARGS (timestamp), GST_TIME_ARGS (duration));
- return gst_base_video_decoder_have_frame_2 (base_video_decoder);
+ ret = gst_base_video_decoder_have_frame_2 (base_video_decoder);
+
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_decoder);
+
+ return ret;
}
static GstFlowReturn
GST_TIME_ARGS (frame->decode_timestamp));
GST_LOG_OBJECT (base_video_decoder, "dist %d", frame->distance_from_sync);
- GST_OBJECT_LOCK (base_video_decoder);
GST_BASE_VIDEO_CODEC (base_video_decoder)->frames =
g_list_append (GST_BASE_VIDEO_CODEC (base_video_decoder)->frames, frame);
- GST_OBJECT_UNLOCK (base_video_decoder);
frame->deadline =
gst_segment_to_running_time (&GST_BASE_VIDEO_CODEC
GST_DEBUG_OBJECT (base_video_decoder, "lost_sync");
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_decoder);
+
if (gst_adapter_available (base_video_decoder->input_adapter) >= 1) {
gst_adapter_flush (base_video_decoder->input_adapter, 1);
}
base_video_decoder->have_sync = FALSE;
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_decoder);
}
/* FIXME not quite exciting; get rid of this ? */
{
GST_DEBUG_OBJECT (base_video_decoder, "set_sync_point");
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_decoder);
base_video_decoder->current_frame->is_sync_point = TRUE;
base_video_decoder->distance_from_sync = 0;
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_decoder);
}
/**
{
GList *g;
- GST_OBJECT_LOCK (base_video_decoder);
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_decoder);
g = g_list_first (GST_BASE_VIDEO_CODEC (base_video_decoder)->frames);
- GST_OBJECT_UNLOCK (base_video_decoder);
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_decoder);
if (g == NULL)
return NULL;
GList *g;
GstVideoFrame *frame = NULL;
- GST_OBJECT_LOCK (base_video_decoder);
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_decoder);
for (g = g_list_first (GST_BASE_VIDEO_CODEC (base_video_decoder)->frames);
g; g = g_list_next (g)) {
GstVideoFrame *tmp = g->data;
break;
}
}
- GST_OBJECT_UNLOCK (base_video_decoder);
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_decoder);
return frame;
}
g_return_val_if_fail (state->width != 0, FALSE);
g_return_val_if_fail (state->height != 0, FALSE);
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_decoder);
+
/* sanitize */
if (state->fps_n == 0 || state->fps_d == 0) {
state->fps_n = 0;
state->bytes_per_picture =
gst_video_format_get_size (state->format, state->width, state->height);
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_decoder);
+
return ret;
}
GST_DEBUG ("alloc src buffer caps=%" GST_PTR_FORMAT,
GST_PAD_CAPS (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_decoder)));
+
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_decoder);
+
flow_ret =
gst_pad_alloc_buffer_and_set_caps (GST_BASE_VIDEO_CODEC_SRC_PAD
(base_video_decoder), GST_BUFFER_OFFSET_NONE, num_bytes,
GST_PAD_CAPS (GST_BASE_VIDEO_CODEC_SRC_PAD (base_video_decoder)));
}
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_decoder);
return buffer;
}
(base_video_decoder)) != NULL, GST_FLOW_ERROR);
GST_LOG_OBJECT (base_video_decoder, "alloc buffer size %d", num_bytes);
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_decoder);
+
flow_ret =
gst_pad_alloc_buffer_and_set_caps (GST_BASE_VIDEO_CODEC_SRC_PAD
(base_video_decoder), GST_BUFFER_OFFSET_NONE, num_bytes,
gst_flow_get_name (flow_ret));
}
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_decoder);
+
return flow_ret;
}
GstClockTimeDiff deadline;
GstClockTime earliest_time;
+ GST_OBJECT_LOCK (base_video_decoder);
earliest_time = GST_BASE_VIDEO_CODEC (base_video_decoder)->earliest_time;
if (GST_CLOCK_TIME_IS_VALID (earliest_time))
deadline = GST_CLOCK_DIFF (earliest_time, frame->deadline);
GST_TIME_ARGS (earliest_time), GST_TIME_ARGS (frame->deadline),
GST_TIME_ARGS (deadline));
+ GST_OBJECT_UNLOCK (base_video_decoder);
+
return deadline;
}
static void
gst_base_video_encoder_reset (GstBaseVideoEncoder * base_video_encoder)
{
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_encoder);
+
base_video_encoder->presentation_frame_number = 0;
base_video_encoder->distance_from_sync = 0;
base_video_encoder->force_keyframe = FALSE;
(GFunc) gst_event_unref, NULL);
g_list_free (base_video_encoder->current_frame_events);
base_video_encoder->current_frame_events = NULL;
+
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_encoder);
}
static void
GST_DEBUG_OBJECT (base_video_encoder, "setcaps %" GST_PTR_FORMAT, caps);
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_encoder);
+
state = &GST_BASE_VIDEO_CODEC (base_video_encoder)->state;
memset (&tmp_state, 0, sizeof (tmp_state));
}
exit:
- g_object_unref (base_video_encoder);
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_encoder);
if (!ret) {
GST_WARNING_OBJECT (base_video_encoder, "rejected caps %" GST_PTR_FORMAT,
caps);
}
+ g_object_unref (base_video_encoder);
+
return ret;
}
{
GstFlowReturn flow_ret;
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_encoder);
base_video_encoder->a.at_eos = TRUE;
if (base_video_encoder_class->finish) {
}
ret = (flow_ret == GST_BASE_VIDEO_ENCODER_FLOW_DROPPED);
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_encoder);
break;
}
case GST_EVENT_NEWSEGMENT:
gint64 stop;
gint64 position;
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_encoder);
gst_event_parse_new_segment_full (event, &update, &rate, &applied_rate,
&format, &start, &stop, &position);
if (format != GST_FORMAT_TIME) {
GST_DEBUG_OBJECT (base_video_encoder, "received non TIME newsegment");
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_encoder);
break;
}
gst_segment_set_newsegment_full (&GST_BASE_VIDEO_CODEC
(base_video_encoder)->segment, update, rate, applied_rate, format,
start, stop, position);
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_encoder);
break;
}
case GST_EVENT_CUSTOM_DOWNSTREAM:
|| GST_EVENT_TYPE (event) == GST_EVENT_FLUSH_STOP) {
ret = gst_pad_push_event (enc->base_video_codec.srcpad, event);
} else {
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (enc);
enc->current_frame_events =
g_list_prepend (enc->current_frame_events, event);
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (enc);
}
}
g_return_val_if_fail (klass->handle_frame != NULL, GST_FLOW_ERROR);
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_encoder);
+
if (!GST_PAD_CAPS (pad)) {
- return GST_FLOW_NOT_NEGOTIATED;
+ ret = GST_FLOW_NOT_NEGOTIATED;
+ goto done;
}
GST_LOG_OBJECT (base_video_encoder,
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
if (base_video_encoder->a.at_eos) {
- return GST_FLOW_UNEXPECTED;
+ ret = GST_FLOW_UNEXPECTED;
+ goto done;
}
if (base_video_encoder->sink_clipping) {
frame->force_keyframe = base_video_encoder->force_keyframe;
base_video_encoder->force_keyframe = FALSE;
- GST_OBJECT_LOCK (base_video_encoder);
GST_BASE_VIDEO_CODEC (base_video_encoder)->frames =
g_list_append (GST_BASE_VIDEO_CODEC (base_video_encoder)->frames, frame);
- GST_OBJECT_UNLOCK (base_video_encoder);
/* new data, more finish needed */
base_video_encoder->drained = FALSE;
ret = klass->handle_frame (base_video_encoder, frame);
done:
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_encoder);
+
g_object_unref (base_video_encoder);
return ret;
GST_LOG_OBJECT (base_video_encoder,
"finish frame fpn %d", frame->presentation_frame_number);
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_encoder);
+
/* Push all pending events that arrived before this frame */
for (l = base_video_encoder->base_video_codec.frames; l; l = l->next) {
GstVideoFrame *tmp = l->data;
done:
/* handed out */
- GST_OBJECT_LOCK (base_video_encoder);
GST_BASE_VIDEO_CODEC (base_video_encoder)->frames =
g_list_remove (GST_BASE_VIDEO_CODEC (base_video_encoder)->frames, frame);
- GST_OBJECT_UNLOCK (base_video_encoder);
gst_base_video_codec_free_frame (frame);
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_encoder);
+
return ret;
}
{
GList *g;
- GST_OBJECT_LOCK (base_video_encoder);
+ GST_BASE_VIDEO_CODEC_STREAM_LOCK (base_video_encoder);
g = g_list_first (GST_BASE_VIDEO_CODEC (base_video_encoder)->frames);
- GST_OBJECT_UNLOCK (base_video_encoder);
+ GST_BASE_VIDEO_CODEC_STREAM_UNLOCK (base_video_encoder);
if (g == NULL)
return NULL;