2
* Copyright (C) 2009 Nokia Corporation.
4
* Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
5
* <zeeshan.ali@nokia.com>
7
* This file is part of Rygel.
9
* Rygel is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU Lesser General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
12
* (at your option) any later version.
14
* Rygel is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU Lesser General Public License for more details.
19
* You should have received a copy of the GNU Lesser General Public License
20
* along with this program; if not, write to the Free Software Foundation,
21
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26
internal enum Rygel.MP3Layer {
32
* A Gst.Bin derivative that implements transcoding of any type of media (using
33
* decodebin2) to mpeg 1 layer 2 and 3 format.
35
internal class Rygel.MP3TranscoderBin : Gst.Bin {
36
private const string DECODEBIN = "decodebin2";
38
private const string AUDIO_SRC_PAD = "audio-src-pad";
39
private const string AUDIO_SINK_PAD = "audio-sink-pad";
41
private dynamic Element audio_enc;
43
public MP3TranscoderBin (MediaItem item,
45
MP3Transcoder transcoder) throws Error {
46
Element decodebin = GstUtils.create_element (DECODEBIN, DECODEBIN);
48
this.audio_enc = transcoder.create_encoder (item,
52
this.add_many (src, decodebin, this.audio_enc);
55
var src_pad = this.audio_enc.get_static_pad (AUDIO_SRC_PAD);
56
var ghost = new GhostPad (null, src_pad);
59
decodebin.pad_added.connect (this.decodebin_pad_added);
62
private void decodebin_pad_added (Element decodebin, Pad new_pad) {
63
Pad enc_pad = this.audio_enc.get_pad (AUDIO_SINK_PAD);
64
if (!new_pad.can_link (enc_pad)) {
68
if (new_pad.link (enc_pad) != PadLinkReturn.OK) {
69
var error = new GstError.LINK (_("Failed to link pad %s to %s"),
72
GstUtils.post_error (this, error);