static int load_elements (char* pURL)
{
    guint frame_delay = 0;

    /* Create gstreamer elements */
    pipeline = gst_pipeline_new ("Mplayer-Standalone");

    source  = gst_element_factory_make_or_warn (MPLAYER_SOURCE, NULL);
    decoder = gst_element_factory_make_or_warn (MPLAYER_DECODER, NULL);
    v_sink  = gst_element_factory_make_or_warn (MPLAYER_V_SINK, NULL);
    a_conv  = gst_element_factory_make_or_warn (MPLAYER_A_CONV, NULL);
    a_proc  = gst_element_factory_make_or_warn (MPLAYER_A_PROC, NULL);
    a_sink  = gst_element_factory_make_or_warn (MPLAYER_A_SINK, NULL);

    /* Set the source path to get the stream from */
    load_url (pURL);

    /* Add Elements to the pipelines */
    gst_bin_add_many (GST_BIN(pipeline), source, decoder, v_sink, a_conv, a_proc, a_sink, NULL);

    /* we link the elements together */
    gst_element_link (source, decoder);
    gst_element_link (a_conv, a_proc);
    gst_element_link (a_proc, a_sink);

    //listening for End Of Stream (EOS) events, etc.
    GstBus* bin_bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
    gst_bus_add_watch(bin_bus, bus_call, NULL);
    gst_object_unref(bin_bus);

    //will try to connect demux with viddec and audio on the fly
    g_signal_connect (decoder, "new-decoded-pad", G_CALLBACK (on_pad_added), NULL);
    g_signal_connect (decoder, "element-added", G_CALLBACK (on_auto_element_added),  NULL);
    return 0;
}
void mplayer_trickplay(char* pURL)
{
    /* Load the URL */
    load_url (pURL);
     if (GST_STATE_CHANGE_FAILURE == gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PAUSED))
    {
        g_print ("Failed to PAUSE\n");
        return;
    }
           g_print ("mplayer_pause\n");	
    /* Seek the pipeline to avoid the video freeze/jerky */
    if (play_speed >= 0)
        gst_element_seek (GST_ELEMENT(pipeline), play_speed, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, gCurrentPosition * GST_MSECOND, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);

    /* Mute & Unmute the audio */
    if ((play_speed > 2) || (play_speed < 0))
        g_object_set (G_OBJECT (a_sink), "mute", TRUE, NULL);
    else
        g_object_set (G_OBJECT (a_sink), "mute", FALSE, NULL);
}
Example #3
0
File: main.c Project: ebichu/dd-wrt
void end_dump(struct status *stat, void *p)
{
	struct cache_entry *ce = stat->ce;
	int oh = get_output_handle();
	if (oh == -1) return;
	if (ce && ce->redirect && dump_red_count++ < MAX_REDIRECTS) {
		unsigned char *u, *p;
		if (stat->state >= 0) change_connection(stat, NULL, PRI_CANCEL);
		u = join_urls(ce->url, ce->redirect);
		if (!http_bugs.bug_302_redirect) if (!ce->redirect_get && (p = strchr(ce->url, POST_CHAR))) add_to_strn(&u, p);
		load_url(u, stat, PRI_MAIN, 0);
		mem_free(u);
		return;
	}
	if (stat->state >= 0 && stat->state < S_TRANS) return;
	if (stat->state >= S_TRANS && dmp != D_SOURCE) return;
	if (dmp == D_SOURCE) {
		if (ce) {
			struct fragment *frag;
			nextfrag:
			foreach(frag, ce->frag) if (frag->offset <= dump_pos && frag->offset + frag->length > dump_pos) {
				int l = frag->length - (dump_pos - frag->offset);
				int w = hard_write(oh, frag->data + dump_pos - frag->offset, l);
				if (w != l) {
					detach_connection(stat, dump_pos);
					if (w < 0) fprintf(stderr, "Error writing to stdout: %s.\n", strerror(errno));
					else fprintf(stderr, "Can't write to stdout.\n");
					retval = RET_ERROR;
					goto terminate;
				}
				dump_pos += w;
				detach_connection(stat, dump_pos);
				goto nextfrag;
			}
		}
		if (stat->state >= 0) return;
	} else if (ce) {