static void kms_recorder_endpoint_send_eos_to_appsrcs (KmsRecorderEndpoint * self) { GstElement *audiosrc, *videosrc; g_object_get (self->priv->mux, KMS_MUXING_PIPELINE_AUDIO_APPSRC, &audiosrc, NULL); g_object_get (self->priv->mux, KMS_MUXING_PIPELINE_VIDEO_APPSRC, &videosrc, NULL); if (audiosrc == NULL && videosrc == NULL) { kms_muxing_pipeline_set_state (self->priv->mux, GST_STATE_NULL); kms_recorder_endpoint_state_changed (self, KMS_URI_ENDPOINT_STATE_STOP); return; } kms_muxing_pipeline_set_state (self->priv->mux, GST_STATE_PLAYING); if (audiosrc != NULL) { send_eos (audiosrc); g_object_unref (audiosrc); } if (videosrc != NULL) { send_eos (videosrc); g_object_unref (videosrc); } }
static void kms_recorder_endpoint_send_eos_to_appsrcs (KmsRecorderEndpoint * self) { GstElement *audiosrc = gst_bin_get_by_name (GST_BIN (self->priv->pipeline), AUDIO_APPSRC); GstElement *videosrc = gst_bin_get_by_name (GST_BIN (self->priv->pipeline), VIDEO_APPSRC); if (audiosrc == NULL && videosrc == NULL) { gst_element_set_state (self->priv->pipeline, GST_STATE_NULL); kms_recorder_endpoint_state_changed (self, KMS_URI_ENDPOINT_STATE_STOP); return; } gst_element_set_state (self->priv->pipeline, GST_STATE_PLAYING); if (audiosrc != NULL) { send_eos (audiosrc); g_object_unref (audiosrc); } if (videosrc != NULL) { send_eos (videosrc); g_object_unref (videosrc); } }
static void recv_eos (GstAppSink * appsink, gpointer user_data) { GstElement *appsrc = GST_ELEMENT (user_data); send_eos (appsrc); }
static void kms_recorder_end_point_send_eos_to_appsrcs (KmsRecorderEndPoint * self) { GstElement *audiosrc = gst_bin_get_by_name (GST_BIN (self->priv->pipeline), AUDIO_APPSRC); GstElement *videosrc = gst_bin_get_by_name (GST_BIN (self->priv->pipeline), VIDEO_APPSRC); if (audiosrc != NULL) { send_eos (audiosrc); g_object_unref (audiosrc); } if (videosrc != NULL) { send_eos (videosrc); g_object_unref (videosrc); } }
/* Called with splitmux lock held to check if this output * context needs to sleep to wait for the release of the * next GOP, or to send EOS to close out the current file */ static void complete_or_wait_on_out (GstSplitMuxSink * splitmux, MqStreamCtx * ctx) { do { GST_LOG_OBJECT (ctx->srcpad, "Checking running time %" GST_TIME_FORMAT " against max %" GST_TIME_FORMAT, GST_TIME_ARGS (ctx->out_running_time), GST_TIME_ARGS (splitmux->max_out_running_time)); if (splitmux->max_out_running_time == GST_CLOCK_TIME_NONE || ctx->out_running_time < splitmux->max_out_running_time) return; if (ctx->flushing || splitmux->state == SPLITMUX_STATE_STOPPED) return; if (splitmux->state == SPLITMUX_STATE_ENDING_FILE) { if (ctx->out_eos == FALSE) { send_eos (splitmux, ctx); continue; } } else if (splitmux->state == SPLITMUX_STATE_START_NEXT_FRAGMENT) { start_next_fragment (splitmux); continue; } GST_INFO_OBJECT (ctx->srcpad, "Sleeping for running time %" GST_TIME_FORMAT " (max %" GST_TIME_FORMAT ")", GST_TIME_ARGS (ctx->out_running_time), GST_TIME_ARGS (splitmux->max_out_running_time)); ctx->out_blocked = TRUE; /* Expand the mq if needed before sleeping */ check_queue_length (splitmux, ctx); GST_SPLITMUX_WAIT (splitmux); ctx->out_blocked = FALSE; GST_INFO_OBJECT (ctx->srcpad, "Woken for new max running time %" GST_TIME_FORMAT, GST_TIME_ARGS (splitmux->max_out_running_time)); } while (1); }
static void send_eos_cb (gchar * id, GstElement * appsrc, gpointer user_data) { send_eos (appsrc); }
/* xlate_out_filter() handles (almost) arbitrary conversions from one charset * to another... * translation is determined in the fixup hook (find_code_page), which is * where the filter's context data is set up... the context data gives us * the translation handle */ static apr_status_t xlate_out_filter(ap_filter_t *f, apr_bucket_brigade *bb) { charset_req_t *reqinfo = ap_get_module_config(f->r->request_config, &charset_lite_module); charset_dir_t *dc = ap_get_module_config(f->r->per_dir_config, &charset_lite_module); charset_filter_ctx_t *ctx = f->ctx; apr_bucket *dptr, *consumed_bucket; const char *cur_str; apr_size_t cur_len, cur_avail; char tmp[OUTPUT_XLATE_BUF_SIZE]; apr_size_t space_avail; int done; apr_status_t rv = APR_SUCCESS; if (!ctx) { /* this is SetOutputFilter path; grab the preallocated context, * if any; note that if we decided not to do anything in an earlier * handler, we won't even have a reqinfo */ if (reqinfo) { ctx = f->ctx = reqinfo->output_ctx; reqinfo->output_ctx = NULL; /* prevent SNAFU if user coded us twice * in the filter chain; we can't have two * instances using the same context */ } if (!ctx) { /* no idea how to translate; don't do anything */ ctx = f->ctx = apr_pcalloc(f->r->pool, sizeof(charset_filter_ctx_t)); ctx->dc = dc; ctx->noop = 1; } } /* Check the mime type to see if translation should be performed. */ if (!ctx->noop && ctx->xlate == NULL) { const char *mime_type = f->r->content_type; if (mime_type && (strncasecmp(mime_type, "text/", 5) == 0 || #if APR_CHARSET_EBCDIC /* On an EBCDIC machine, be willing to translate mod_autoindex- * generated output. Otherwise, it doesn't look too cool. * * XXX This isn't a perfect fix because this doesn't trigger us * to convert from the charset of the source code to ASCII. The * general solution seems to be to allow a generator to set an * indicator in the r specifying that the body is coded in the * implementation character set (i.e., the charset of the source * code). This would get several different types of documents * translated properly: mod_autoindex output, mod_status output, * mod_info output, hard-coded error documents, etc. */ strcmp(mime_type, DIR_MAGIC_TYPE) == 0 || #endif strncasecmp(mime_type, "message/", 8) == 0 || dc->force_xlate == FX_FORCE)) { rv = apr_xlate_open(&ctx->xlate, dc->charset_default, dc->charset_source, f->r->pool); if (rv != APR_SUCCESS) { ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, f->r, APLOGNO(01453) "can't open translation %s->%s", dc->charset_source, dc->charset_default); ctx->noop = 1; } else { if (apr_xlate_sb_get(ctx->xlate, &ctx->is_sb) != APR_SUCCESS) { ctx->is_sb = 0; } } } else { ctx->noop = 1; if (mime_type) { ap_log_rerror(APLOG_MARK, APLOG_TRACE6, 0, f->r, "mime type is %s; no translation selected", mime_type); } } } ap_log_rerror(APLOG_MARK, APLOG_TRACE6, 0, f->r, "xlate_out_filter() - " "charset_source: %s charset_default: %s", dc && dc->charset_source ? dc->charset_source : "(none)", dc && dc->charset_default ? dc->charset_default : "(none)"); if (!ctx->ran) { /* filter never ran before */ chk_filter_chain(f); ctx->ran = 1; if (!ctx->noop && !ctx->is_sb) { /* We're not converting between two single-byte charsets, so unset * Content-Length since it is unlikely to remain the same. */ apr_table_unset(f->r->headers_out, "Content-Length"); } } if (ctx->noop) { return ap_pass_brigade(f->next, bb); } dptr = APR_BRIGADE_FIRST(bb); done = 0; cur_len = 0; space_avail = sizeof(tmp); consumed_bucket = NULL; while (!done) { if (!cur_len) { /* no bytes left to process in the current bucket... */ if (consumed_bucket) { apr_bucket_delete(consumed_bucket); consumed_bucket = NULL; } if (dptr == APR_BRIGADE_SENTINEL(bb)) { break; } if (APR_BUCKET_IS_EOS(dptr)) { cur_len = -1; /* XXX yuck, but that tells us to send * eos down; when we minimize our bb construction * we'll fix this crap */ if (ctx->saved) { /* Oops... we have a partial char from the previous bucket * that won't be completed because there's no more data. */ rv = APR_INCOMPLETE; ctx->ees = EES_INCOMPLETE_CHAR; } break; } if (APR_BUCKET_IS_METADATA(dptr)) { apr_bucket *metadata_bucket; metadata_bucket = dptr; dptr = APR_BUCKET_NEXT(dptr); APR_BUCKET_REMOVE(metadata_bucket); rv = send_bucket_downstream(f, metadata_bucket); if (rv != APR_SUCCESS) { done = 1; } continue; } rv = apr_bucket_read(dptr, &cur_str, &cur_len, APR_BLOCK_READ); if (rv != APR_SUCCESS) { ctx->ees = EES_BUCKET_READ; break; } consumed_bucket = dptr; /* for axing when we're done reading it */ dptr = APR_BUCKET_NEXT(dptr); /* get ready for when we access the * next bucket */ } /* Try to fill up our tmp buffer with translated data. */ cur_avail = cur_len; if (cur_len) { /* maybe we just hit the end of a pipe (len = 0) ? */ if (ctx->saved) { /* Rats... we need to finish a partial character from the previous * bucket. */ char *tmp_tmp; tmp_tmp = tmp + sizeof(tmp) - space_avail; rv = finish_partial_char(ctx, &cur_str, &cur_len, &tmp_tmp, &space_avail); } else { rv = apr_xlate_conv_buffer(ctx->xlate, cur_str, &cur_avail, tmp + sizeof(tmp) - space_avail, &space_avail); /* Update input ptr and len after consuming some bytes */ cur_str += cur_len - cur_avail; cur_len = cur_avail; if (rv == APR_INCOMPLETE) { /* partial character at end of input */ /* We need to save the final byte(s) for next time; we can't * convert it until we look at the next bucket. */ rv = set_aside_partial_char(ctx, cur_str, cur_len); cur_len = 0; } } } if (rv != APR_SUCCESS) { /* bad input byte or partial char too big to store */ done = 1; } if (space_avail < XLATE_MIN_BUFF_LEFT) { /* It is time to flush, as there is not enough space left in the * current output buffer to bother with converting more data. */ rv = send_downstream(f, tmp, sizeof(tmp) - space_avail); if (rv != APR_SUCCESS) { done = 1; } /* tmp is now empty */ space_avail = sizeof(tmp); } } if (rv == APR_SUCCESS) { if (space_avail < sizeof(tmp)) { /* gotta write out what we converted */ rv = send_downstream(f, tmp, sizeof(tmp) - space_avail); } } if (rv == APR_SUCCESS) { if (cur_len == -1) { rv = send_eos(f); } } else { log_xlate_error(f, rv); } return rv; }