rygel r758 - trunk/src/rygel
- From: zeeshanak svn gnome org
- To: svn-commits-list gnome org
- Subject: rygel r758 - trunk/src/rygel
- Date: Sat, 28 Mar 2009 00:45:32 +0000 (UTC)
Author: zeeshanak
Date: Sat Mar 28 00:45:32 2009
New Revision: 758
URL: http://svn.gnome.org/viewvc/rygel?rev=758&view=rev
Log:
Put gst transcoder bins into separate files.
Added:
trunk/src/rygel/rygel-l16-transcoder-bin.vala
- copied, changed from r757, /trunk/src/rygel/rygel-l16-transcoder.vala
trunk/src/rygel/rygel-mp2ts-transcoder-bin.vala
- copied, changed from r757, /trunk/src/rygel/rygel-mp2ts-transcoder.vala
trunk/src/rygel/rygel-mp3-transcoder-bin.vala
- copied, changed from r757, /trunk/src/rygel/rygel-mp3-transcoder.vala
Modified:
trunk/src/rygel/Makefile.am
trunk/src/rygel/rygel-l16-transcoder.vala
trunk/src/rygel/rygel-mp2ts-transcoder.vala
trunk/src/rygel/rygel-mp3-transcoder.vala
Modified: trunk/src/rygel/Makefile.am
==============================================================================
--- trunk/src/rygel/Makefile.am (original)
+++ trunk/src/rygel/Makefile.am Sat Mar 28 00:45:32 2009
@@ -132,7 +132,13 @@
rygel-mp3-transcoder.h \
rygel-mp3-transcoder.c \
rygel-l16-transcoder.h \
- rygel-l16-transcoder.c
+ rygel-l16-transcoder.c \
+ rygel-mp2ts-transcoder-bin.h \
+ rygel-mp2ts-transcoder-bin.c \
+ rygel-mp3-transcoder-bin.h \
+ rygel-mp3-transcoder-bin.c \
+ rygel-l16-transcoder-bin.h \
+ rygel-l16-transcoder-bin.c
rygel.stamp: $(filter %.vala,$(rygel_SOURCES))
$(VALAC) -C --vapidir=$(srcdir) \
@@ -174,7 +180,10 @@
rygel-transcoder.vala \
rygel-mp2ts-transcoder.vala \
rygel-mp3-transcoder.vala \
- rygel-l16-transcoder.vala
+ rygel-l16-transcoder.vala \
+ rygel-mp2ts-transcoder-bin.vala \
+ rygel-mp3-transcoder-bin.vala \
+ rygel-l16-transcoder-bin.vala
rygel-1.0.vapi: $(VAPI_SOURCE_FILES)
$(VALAC) -C --library=rygel-1.0 \
Copied: trunk/src/rygel/rygel-l16-transcoder-bin.vala (from r757, /trunk/src/rygel/rygel-l16-transcoder.vala)
==============================================================================
--- /trunk/src/rygel/rygel-l16-transcoder.vala (original)
+++ trunk/src/rygel/rygel-l16-transcoder-bin.vala Sat Mar 28 00:45:32 2009
@@ -22,50 +22,8 @@
*/
using Rygel;
using Gst;
-using GUPnP;
-using Gee;
-internal class Rygel.L16Transcoder : Rygel.Transcoder {
- private const int CHANNELS = 2;
- private const int FREQUENCY = 44100;
- private const int WIDTH = 16;
- private const int DEPTH = 16;
- private const int ENDIANNESS = ByteOrder.BIG_ENDIAN; // Network byte order
- private const bool SIGNED = true; // Network byte order
-
- public L16Transcoder () {
- var mime_type = "audio/L" + L16Transcoder.WIDTH.to_string () +
- ";rate=" + L16Transcoder.FREQUENCY.to_string () +
- ";channels=" + L16Transcoder.CHANNELS.to_string ();
-
- base (mime_type, "LPCM");
- }
-
- public override Element create_source (Element src) throws Error {
- return new L16TranscoderBin (src,
- L16Transcoder.CHANNELS,
- L16Transcoder.FREQUENCY,
- L16Transcoder.WIDTH,
- L16Transcoder.DEPTH,
- L16Transcoder.ENDIANNESS,
- L16Transcoder.SIGNED);
- }
-
- public override DIDLLiteResource create_resource (
- MediaItem item,
- TranscodeManager manager)
- throws Error {
- var res = base.create_resource (item, manager);
-
- res.sample_freq = L16Transcoder.FREQUENCY;
- res.n_audio_channels = L16Transcoder.CHANNELS;
- res.bits_per_sample = L16Transcoder.WIDTH;
-
- return res;
- }
-}
-
-private class Rygel.L16TranscoderBin : Rygel.TranscoderBin {
+internal class Rygel.L16TranscoderBin : Rygel.TranscoderBin {
private const string DECODEBIN = "decodebin2";
private const string AUDIO_CONVERT = "audioconvert";
private const string AUDIO_RESAMPLE = "audioresample";
Modified: trunk/src/rygel/rygel-l16-transcoder.vala
==============================================================================
--- trunk/src/rygel/rygel-l16-transcoder.vala (original)
+++ trunk/src/rygel/rygel-l16-transcoder.vala Sat Mar 28 00:45:32 2009
@@ -23,7 +23,6 @@
using Rygel;
using Gst;
using GUPnP;
-using Gee;
internal class Rygel.L16Transcoder : Rygel.Transcoder {
private const int CHANNELS = 2;
@@ -64,103 +63,3 @@
return res;
}
}
-
-private class Rygel.L16TranscoderBin : Rygel.TranscoderBin {
- private const string DECODEBIN = "decodebin2";
- private const string AUDIO_CONVERT = "audioconvert";
- private const string AUDIO_RESAMPLE = "audioresample";
- private const string CAPS_FILTER = "capsfilter";
-
- private const string AUDIO_SRC_PAD = "audio-src-pad";
- private const string AUDIO_SINK_PAD = "audio-sink-pad";
-
- private dynamic Element audio_enc;
-
- public L16TranscoderBin (Element src,
- int channels,
- int frequency,
- int width,
- int depth,
- int endianness,
- bool signed_)
- throws Error {
- Element decodebin = TranscoderBin.create_element (DECODEBIN, DECODEBIN);
-
- this.audio_enc = L16TranscoderBin.create_encoder (AUDIO_SRC_PAD,
- AUDIO_SINK_PAD,
- channels,
- frequency,
- width,
- depth,
- endianness,
- signed_);
-
- this.add_many (src, decodebin, this.audio_enc);
- src.link (decodebin);
-
- var src_pad = this.audio_enc.get_static_pad (AUDIO_SRC_PAD);
- var ghost = new GhostPad (null, src_pad);
- this.add_pad (ghost);
-
- decodebin.pad_added += this.decodebin_pad_added;
- }
-
- private void decodebin_pad_added (Element decodebin, Pad new_pad) {
- Pad enc_pad = this.audio_enc.get_pad (AUDIO_SINK_PAD);
- if (!new_pad.can_link (enc_pad)) {
- return;
- }
-
- if (new_pad.link (enc_pad) != PadLinkReturn.OK) {
- this.post_error (new LiveResponseError.LINK (
- "Failed to link pad %s to %s",
- new_pad.name,
- enc_pad.name));
- return;
- }
- }
-
- public static Element create_encoder (string? src_pad_name,
- string? sink_pad_name,
- int channels,
- int frequency,
- int width,
- int depth,
- int endianness,
- bool signed_)
- throws Error {
- dynamic Element convert1 = TranscoderBin.create_element (AUDIO_CONVERT,
- null);
- dynamic Element resample = TranscoderBin.create_element (
- AUDIO_RESAMPLE,
- AUDIO_RESAMPLE);
- dynamic Element convert2 = TranscoderBin.create_element (AUDIO_CONVERT,
- null);
- dynamic Element capsfilter = TranscoderBin.create_element (CAPS_FILTER,
- CAPS_FILTER);
-
- var bin = new Bin ("audio-encoder-bin");
- bin.add_many (convert1, resample, convert2, capsfilter);
-
- capsfilter.caps = new Caps.simple (
- "audio/x-raw-int",
- "channels", typeof (int), channels,
- "rate", typeof (int), frequency,
- "width", typeof (int), width,
- "depth", typeof (int), depth,
- "endianness", typeof (int), endianness,
- "signed", typeof (bool), signed_);
-
- convert1.link_many (resample, convert2, capsfilter);
-
- var pad = convert1.get_static_pad ("sink");
- var ghost = new GhostPad (sink_pad_name, pad);
- bin.add_pad (ghost);
-
- pad = capsfilter.get_static_pad ("src");
- ghost = new GhostPad (src_pad_name, pad);
- bin.add_pad (ghost);
-
- return bin;
- }
-}
Copied: trunk/src/rygel/rygel-mp2ts-transcoder-bin.vala (from r757, /trunk/src/rygel/rygel-mp2ts-transcoder.vala)
==============================================================================
--- /trunk/src/rygel/rygel-mp2ts-transcoder.vala (original)
+++ trunk/src/rygel/rygel-mp2ts-transcoder-bin.vala Sat Mar 28 00:45:32 2009
@@ -22,47 +22,8 @@
*/
using Rygel;
using Gst;
-using GUPnP;
-using Gee;
-internal enum Rygel.MP2TSProfile {
- SD = 0,
- HD
-}
-
-internal class Rygel.MP2TSTranscoder : Rygel.Transcoder {
- // HD
- private const int[] WIDTH = {640, 1920};
- private const int[] HEIGHT = {480, 1080};
- private const string[] PROFILES = {"MPEG_TS_SD_NA", "MPEG_TS_HD_NA"};
-
- private MP2TSProfile profile;
-
- public MP2TSTranscoder (MP2TSProfile profile) {
- base ("video/mpeg", PROFILES[profile]);
-
- this.profile = profile;
- }
-
- public override Element create_source (Element src) throws Error {
- return new MP2TSTranscoderBin (src,
- MP2TSTranscoder.WIDTH[this.profile],
- MP2TSTranscoder.HEIGHT[this.profile]);
- }
-
- public override DIDLLiteResource create_resource (MediaItem item,
- TranscodeManager manager)
- throws Error {
- var res = base.create_resource (item, manager);
-
- res.width = WIDTH[profile];
- res.height = HEIGHT[profile];
-
- return res;
- }
-}
-
-private class Rygel.MP2TSTranscoderBin : Rygel.TranscoderBin {
+internal class Rygel.MP2TSTranscoderBin : Rygel.TranscoderBin {
private const string DECODEBIN = "decodebin2";
private const string VIDEO_ENCODER = "mpeg2enc";
private const string COLORSPACE_CONVERT = "ffmpegcolorspace";
Modified: trunk/src/rygel/rygel-mp2ts-transcoder.vala
==============================================================================
--- trunk/src/rygel/rygel-mp2ts-transcoder.vala (original)
+++ trunk/src/rygel/rygel-mp2ts-transcoder.vala Sat Mar 28 00:45:32 2009
@@ -23,7 +23,6 @@
using Rygel;
using Gst;
using GUPnP;
-using Gee;
internal enum Rygel.MP2TSProfile {
SD = 0,
@@ -61,110 +60,3 @@
return res;
}
}
-
-private class Rygel.MP2TSTranscoderBin : Rygel.TranscoderBin {
- private const string DECODEBIN = "decodebin2";
- private const string VIDEO_ENCODER = "mpeg2enc";
- private const string COLORSPACE_CONVERT = "ffmpegcolorspace";
- private const string VIDEO_RATE = "videorate";
- private const string VIDEO_SCALE = "videoscale";
- private const string MUXER = "mpegtsmux";
-
- private const string AUDIO_ENC_SINK = "audio-enc-sink-pad";
- private const string VIDEO_ENC_SINK = "sink";
-
- private dynamic Element audio_enc;
- private dynamic Element video_enc;
- private dynamic Element muxer;
-
- public MP2TSTranscoderBin (Element src,
- int width,
- int height)
- throws Error {
- Element decodebin = TranscoderBin.create_element (DECODEBIN, DECODEBIN);
- this.audio_enc = MP3TranscoderBin.create_encoder (MP3Layer.TWO,
- null,
- AUDIO_ENC_SINK);
- this.video_enc = MP2TSTranscoderBin.create_encoder (null,
- VIDEO_ENC_SINK,
- width,
- height);
- this.muxer = TranscoderBin.create_element (MUXER, MUXER);
-
- this.add_many (src,
- decodebin,
- this.audio_enc,
- this.video_enc,
- this.muxer);
- src.link (decodebin);
-
- var src_pad = muxer.get_static_pad ("src");
- var ghost = new GhostPad (null, src_pad);
- this.add_pad (ghost);
-
- decodebin.pad_added += this.decodebin_pad_added;
- }
-
- private void decodebin_pad_added (Element decodebin, Pad new_pad) {
- Element encoder;
- Pad enc_pad;
-
- var audio_enc_pad = this.audio_enc.get_pad (AUDIO_ENC_SINK);
- var video_enc_pad = this.video_enc.get_pad (VIDEO_ENC_SINK);
-
- // Check which encoder to use
- if (new_pad.can_link (audio_enc_pad)) {
- encoder = this.audio_enc;
- enc_pad = audio_enc_pad;
- } else if (new_pad.can_link (video_enc_pad)) {
- encoder = this.video_enc;
- enc_pad = video_enc_pad;
- } else {
- return;
- }
-
- encoder.link (this.muxer);
-
- if (new_pad.link (enc_pad) != PadLinkReturn.OK) {
- this.post_error (new LiveResponseError.LINK (
- "Failed to link pad %s to %s",
- new_pad.name,
- enc_pad.name));
- return;
- }
- }
-
- internal static Element create_encoder (string? src_pad_name,
- string? sink_pad_name,
- int width,
- int height)
- throws Error {
- var videorate = TranscoderBin.create_element (VIDEO_RATE, VIDEO_RATE);
- var videoscale = TranscoderBin.create_element (VIDEO_SCALE,
- VIDEO_SCALE);
- var convert = TranscoderBin.create_element (COLORSPACE_CONVERT,
- COLORSPACE_CONVERT);
- var encoder = TranscoderBin.create_element (VIDEO_ENCODER,
- VIDEO_ENCODER);
-
- var bin = new Bin ("video-encoder-bin");
- bin.add_many (videorate, videoscale, convert, encoder);
-
- var caps = new Caps.simple ("video/x-raw-yuv",
- "width", typeof (int), width,
- "height", typeof (int), height);
- videorate.link (convert);
- convert.link (videoscale);
- videoscale.link_filtered (encoder, caps);
-
- var pad = videorate.get_static_pad ("sink");
- var ghost = new GhostPad (sink_pad_name, pad);
- bin.add_pad (ghost);
-
- pad = encoder.get_static_pad ("src");
- ghost = new GhostPad (src_pad_name, pad);
- bin.add_pad (ghost);
-
- return bin;
- }
-}
Copied: trunk/src/rygel/rygel-mp3-transcoder-bin.vala (from r757, /trunk/src/rygel/rygel-mp3-transcoder.vala)
==============================================================================
--- /trunk/src/rygel/rygel-mp3-transcoder.vala (original)
+++ trunk/src/rygel/rygel-mp3-transcoder-bin.vala Sat Mar 28 00:45:32 2009
@@ -22,29 +22,13 @@
*/
using Rygel;
using Gst;
-using GUPnP;
-using Gee;
internal enum Rygel.MP3Layer {
TWO = 1,
THREE = 2
}
-internal class Rygel.MP3Transcoder : Rygel.Transcoder {
- private MP3Layer layer;
-
- public MP3Transcoder (MP3Layer layer) {
- base ("audio/mpeg", "MP3");
-
- this.layer = layer;
- }
-
- public override Element create_source (Element src) throws Error {
- return new MP3TranscoderBin (src, this.layer);
- }
-}
-
-private class Rygel.MP3TranscoderBin : Rygel.TranscoderBin {
+internal class Rygel.MP3TranscoderBin : Rygel.TranscoderBin {
private const string DECODEBIN = "decodebin2";
private const string AUDIO_CONVERT = "audioconvert";
private const string[] AUDIO_ENCODER = {null, "twolame", "lame"};
Modified: trunk/src/rygel/rygel-mp3-transcoder.vala
==============================================================================
--- trunk/src/rygel/rygel-mp3-transcoder.vala (original)
+++ trunk/src/rygel/rygel-mp3-transcoder.vala Sat Mar 28 00:45:32 2009
@@ -22,13 +22,6 @@
*/
using Rygel;
using Gst;
-using GUPnP;
-using Gee;
-
-internal enum Rygel.MP3Layer {
- TWO = 1,
- THREE = 2
-}
internal class Rygel.MP3Transcoder : Rygel.Transcoder {
private MP3Layer layer;
@@ -43,88 +36,3 @@
return new MP3TranscoderBin (src, this.layer);
}
}
-
-private class Rygel.MP3TranscoderBin : Rygel.TranscoderBin {
- private const string DECODEBIN = "decodebin2";
- private const string AUDIO_CONVERT = "audioconvert";
- private const string[] AUDIO_ENCODER = {null, "twolame", "lame"};
- private const string AUDIO_PARSER = "mp3parse";
- private const string AUDIO_RESAMPLE = "audioresample";
-
- private const string AUDIO_SRC_PAD = "audio-src-pad";
- private const string AUDIO_SINK_PAD = "audio-sink-pad";
-
- private dynamic Element audio_enc;
-
- public MP3TranscoderBin (Element src, MP3Layer layer) throws Error {
- Element decodebin = TranscoderBin.create_element (DECODEBIN, DECODEBIN);
-
- this.audio_enc = MP3TranscoderBin.create_encoder (layer,
- AUDIO_SRC_PAD,
- AUDIO_SINK_PAD);
-
- this.add_many (src, decodebin, this.audio_enc);
- src.link (decodebin);
-
- var src_pad = this.audio_enc.get_static_pad (AUDIO_SRC_PAD);
- var ghost = new GhostPad (null, src_pad);
- this.add_pad (ghost);
-
- decodebin.pad_added += this.decodebin_pad_added;
- }
-
- public static Element create_encoder (MP3Layer layer,
- string? src_pad_name,
- string? sink_pad_name)
- throws Error {
- dynamic Element convert = TranscoderBin.create_element (AUDIO_CONVERT,
- AUDIO_CONVERT);
- dynamic Element resample = TranscoderBin.create_element (
- AUDIO_RESAMPLE,
- AUDIO_RESAMPLE);
- dynamic Element encoder = TranscoderBin.create_element (
- AUDIO_ENCODER[layer],
- AUDIO_ENCODER[layer]);
- dynamic Element parser = TranscoderBin.create_element (AUDIO_PARSER,
- AUDIO_PARSER);
-
- if (layer == MP3Layer.THREE) {
- // Best quality
- encoder.quality = 0;
- }
-
- encoder.bitrate = 256;
-
- var bin = new Bin ("audio-encoder-bin");
- bin.add_many (convert, resample, encoder, parser);
-
- var filter = Caps.from_string ("audio/x-raw-int");
- convert.link_filtered (encoder, filter);
- encoder.link (parser);
-
- var pad = convert.get_static_pad ("sink");
- var ghost = new GhostPad (sink_pad_name, pad);
- bin.add_pad (ghost);
-
- pad = parser.get_static_pad ("src");
- ghost = new GhostPad (src_pad_name, pad);
- bin.add_pad (ghost);
-
- return bin;
- }
-
- private void decodebin_pad_added (Element decodebin, Pad new_pad) {
- Pad enc_pad = this.audio_enc.get_pad (AUDIO_SINK_PAD);
- if (!new_pad.can_link (enc_pad)) {
- return;
- }
-
- if (new_pad.link (enc_pad) != PadLinkReturn.OK) {
- this.post_error (new LiveResponseError.LINK (
- "Failed to link pad %s to %s",
- new_pad.name,
- enc_pad.name));
- return;
- }
- }
-}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]