# HG changeset patch # User renatofilho # Date 1201637550 0 # Node ID 715f854a93cd4a0ccd212d9c394d2bb52e3e183e # Parent 9f80dd75cd8abec7835abdb38ff1ec4bcdbd4b6f [svn r903] implemente audio-rate arg diff -r 9f80dd75cd8a -r 715f854a93cd gmyth-stream/gmencoder/src/gmencoder.c --- a/gmyth-stream/gmencoder/src/gmencoder.c Tue Jan 29 18:40:32 2008 +0000 +++ b/gmyth-stream/gmencoder/src/gmencoder.c Tue Jan 29 20:12:30 2008 +0000 @@ -311,16 +311,45 @@ goto error; } - /* - * if (rate > 0) { g_object_set (G_OBJECT (aencode), "bitrate", 32, - * NULL); } - */ + gst_bin_add_many(GST_BIN(abin), aqueue, aconvert, aencode, aqueue_src, NULL); - if (gst_element_link_many(aqueue, aconvert, aencode, aqueue_src, NULL) - == FALSE) { + + if (!gst_element_link (aqueue, aconvert)) + { g_warning("Not Link audio elements"); + goto error; + } + + if (rate > 0) { + GstCaps *caps; + + caps = gst_caps_new_simple ("audio/x-raw-int", + "rate", G_TYPE_INT, rate, NULL); + if (!gst_element_link_filtered (aconvert, aencode, caps)) + { + gst_caps_unref (caps); + g_warning("Not link rate filter"); + goto error; + } + + gst_caps_unref (caps); + } + else + { + if (!gst_element_link (aconvert, aencode)) + { + g_warning ("Fail to link audio elements"); + goto error; + } + } + + + if (!gst_element_link (aencode, aqueue_src)) + { + g_warning("Not Link audio elements"); + goto error; } // TODO: apply audio rate @@ -1021,8 +1050,10 @@ err_str = g_strdup_printf("Error [%d] %s (%s)", error->code, error->message, debug); priv->ready = FALSE; + /* g_signal_emit(user_data, g_mencoder_signals[ERROR], 0, err_str); + */ g_free(err_str); g_clear_error(&error); g_free(debug); @@ -1076,7 +1107,8 @@ } sink_pad = gst_element_get_pad(sink_element, "sink"); - gst_pad_link(pad, sink_pad); + if (!gst_pad_is_linked (sink_pad)) + gst_pad_link(pad, sink_pad); gst_object_unref(sink_element); gst_object_unref(sink_pad);