[svn r903] implemente audio-rate arg trunk
authorrenatofilho
Tue Jan 29 20:12:30 2008 +0000 (2008-01-29)
branchtrunk
changeset 897715f854a93cd
parent 896 9f80dd75cd8a
child 898 4fbbacbbca34
[svn r903] implemente audio-rate arg
gmyth-stream/gmencoder/src/gmencoder.c
     1.1 --- a/gmyth-stream/gmencoder/src/gmencoder.c	Tue Jan 29 18:40:32 2008 +0000
     1.2 +++ b/gmyth-stream/gmencoder/src/gmencoder.c	Tue Jan 29 20:12:30 2008 +0000
     1.3 @@ -311,16 +311,45 @@
     1.4          goto error;
     1.5      }
     1.6  
     1.7 -    /*
     1.8 -     * if (rate > 0) { g_object_set (G_OBJECT (aencode), "bitrate", 32,
     1.9 -     * NULL); } 
    1.10 -     */
    1.11 +
    1.12  
    1.13      gst_bin_add_many(GST_BIN(abin), aqueue, aconvert, aencode, aqueue_src,
    1.14                       NULL);
    1.15 -    if (gst_element_link_many(aqueue, aconvert, aencode, aqueue_src, NULL)
    1.16 -        == FALSE) {
    1.17 +
    1.18 +    if (!gst_element_link (aqueue, aconvert))
    1.19 +    {
    1.20          g_warning("Not Link audio elements");
    1.21 +        goto error;
    1.22 +    }
    1.23 +
    1.24 +    if (rate > 0) {
    1.25 +        GstCaps *caps;
    1.26 +
    1.27 +        caps = gst_caps_new_simple ("audio/x-raw-int",
    1.28 +                                    "rate", G_TYPE_INT, rate, NULL);
    1.29 +        if (!gst_element_link_filtered (aconvert, aencode, caps))
    1.30 +        {
    1.31 +            gst_caps_unref (caps);
    1.32 +            g_warning("Not link rate filter");
    1.33 +            goto error;
    1.34 +        }
    1.35 +
    1.36 +        gst_caps_unref (caps);
    1.37 +    }
    1.38 +    else
    1.39 +    {
    1.40 +        if (!gst_element_link (aconvert, aencode))
    1.41 +        {
    1.42 +            g_warning ("Fail to link audio elements");
    1.43 +            goto error;
    1.44 +        }
    1.45 +    }
    1.46 +
    1.47 +
    1.48 +    if (!gst_element_link (aencode, aqueue_src))
    1.49 +    {
    1.50 +        g_warning("Not Link audio elements");
    1.51 +        goto error;
    1.52      }
    1.53      // TODO: apply audio rate
    1.54  
    1.55 @@ -1021,8 +1050,10 @@
    1.56              err_str = g_strdup_printf("Error [%d] %s (%s)", error->code,
    1.57                                        error->message, debug);
    1.58              priv->ready = FALSE;
    1.59 +            /*
    1.60              g_signal_emit(user_data, g_mencoder_signals[ERROR], 0,
    1.61                            err_str);
    1.62 +                          */
    1.63              g_free(err_str);
    1.64              g_clear_error(&error);
    1.65              g_free(debug);
    1.66 @@ -1076,7 +1107,8 @@
    1.67      }
    1.68  
    1.69      sink_pad = gst_element_get_pad(sink_element, "sink");
    1.70 -    gst_pad_link(pad, sink_pad);
    1.71 +    if (!gst_pad_is_linked (sink_pad))
    1.72 +        gst_pad_link(pad, sink_pad);
    1.73  
    1.74      gst_object_unref(sink_element);
    1.75      gst_object_unref(sink_pad);