Reworked AboutDialog.
[demorecorder] / src / RecordPipeline_Old.vala
1 /*  Demo Recorder for MAEMO 5
2 *   Copyright (C) 2010 Dru Moore <usr@dru-id.co.uk>
3 *   This program is free software; you can redistribute it and/or modify
4 *   it under the terms of the GNU General Public License version 2,
5 *   or (at your option) any later version, as published by the Free
6 *   Software Foundation
7 *
8 *   This program is distributed in the hope that it will be useful,
9 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
10 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 *   GNU General Public License for more details
12 *
13 *   You should have received a copy of the GNU General Public
14 *   License along with this program; if not, write to the
15 *   Free Software Foundation, Inc.,
16 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 */
18 namespace IdWorks {
19
20 public class RecordPipeline_Old : Object {
21
22   Gst.Pipeline pipeline;
23   Gst.Element src;
24   Gst.Element decoder;
25   Gst.Element converter;
26   Gst.Element queue;
27   Gst.Element sink;
28   Gst.Element resampler;
29   Gst.Element encoder;
30   Gst.Element filesink;
31   string name;
32   string location;
33   Gst.Caps caps;
34   Gst.Query duration_query;
35   Gst.Query position_query;
36   int64 position;
37   int64 duration;
38   
39   public signal void position_duration(int64 position, int64 duration);
40   public signal void tag_parsed(string tag, string val);
41   public signal void end_of_stream();
42   public signal void stream_error(string msg);
43   
44   public RecordPipeline_Old(string name, string location, Gst.Caps caps) {
45     this.name = name;
46     this.location = location;
47     this.caps = caps;
48     //set the tag handling delegate
49     //this.handle_tags_delegate = this.handle_tags;
50     //set some default values
51     this.position=0;
52     this.duration=0;
53     this.construct_pipeline(this.name, this.location, this.caps);
54     //define the queries
55     //duration_query = new Gst.Query.duration(Gst.Format.TIME);
56     //position_query = new Gst.Query.position(Gst.Format.TIME);
57   }
58   
59   public string get_location() {
60     return this.location;
61   }
62   
63   public void record() {
64     this.pipeline.set_state(Gst.State.PLAYING);
65   }
66   
67   public void stop() {
68     this.end_of_stream();
69     this.pipeline.set_state(Gst.State.READY);
70   }
71   
72   private void construct_pipeline(string name, string location, Gst.Caps caps) {
73     pipeline = new Gst.Pipeline(name);
74     
75     this.src = Gst.ElementFactory.make("pulsesrc", "input");
76     src.set_property("device", "source.hw0");
77     this.pipeline.add(this.src);
78     
79     this.converter = Gst.ElementFactory.make("audioconvert", "converter");
80     this.pipeline.add(this.converter);
81     
82     this.queue = Gst.ElementFactory.make("queue", "buffer");
83     this.pipeline.add(this.queue);
84     
85     this.resampler = Gst.ElementFactory.make("audioresample", "resampler");
86     this.resampler.set_property("quality", 10);
87     this.pipeline.add(resampler);
88     this.encoder = Gst.ElementFactory.make("wavenc", "encoder");
89     this.pipeline.add(this.encoder);
90     if (null != this.encoder) {
91       stdout.printf("Encoder added!\n");
92       stdout.flush();
93     }
94     this.filesink = Gst.ElementFactory.make("filesink", "fileoutput");
95     if (null != this.filesink) {
96       this.filesink.set_property("location", location);
97       stdout.printf("Location set!\n");
98       stdout.flush();
99       this.pipeline.add(this.filesink);
100       stdout.printf("Filesink added!\n");
101       stdout.flush();
102     }
103     /*if (this.converter.link(this.resampler)) {
104       stdout.printf("Converter linked!\n");
105       stdout.flush();
106     }*/
107     if (this.src.link(this.queue)) {
108       stdout.printf("Source linked!\n");
109       stdout.flush();
110     }
111     if (this.queue.link(this.converter)) {
112       stdout.printf("Queue linked!\n");
113       stdout.flush();
114     }
115     if (this.converter.link(this.resampler)) {
116       stdout.printf("Converter linked!\n");
117       stdout.flush();
118     }
119     if (this.resampler.link_filtered(this.encoder, caps)) {
120       stdout.printf("Resampler linked!\n");
121       stdout.flush();
122     }
123     if (this.encoder.link(this.filesink)) {
124       stdout.printf("Encoder linked!\n");
125       stdout.flush();
126     }
127   }
128   
129   
130 }
131
132 }