~stianse/playraw/0.1

« back to all changes in this revision

Viewing changes to src/rawplayer.vala

  • Committer: Stian Selnes
  • Date: 2008-11-23 19:07:41 UTC
  • Revision ID: stian.selnes@gmail.com-20081123190741-ttd9em7ctxd090n6
- Added statusbar that shows current frame and total frames

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
        public signal void file_loaded ();
7
7
        public signal void file_closed ();
 
8
        public signal void frame_changed (int current_frame, int total_frames);
 
9
 
8
10
 
9
11
        // FIXME: Restrict access on these properties
10
12
        public string filename      {get; set;}
21
23
        private Pipeline pipeline;
22
24
        private dynamic Element suppresscolor;
23
25
        private bool loading_complete;
 
26
        private int64 duration = -1;
24
27
 
25
28
 
26
29
        ~RawPlayer () {
74
77
 
75
78
                src.link_many (videoparse, suppresscolor, colorspace, sink);
76
79
 
 
80
                var sink_pad = sink.get_static_pad ("sink");
 
81
                sink_pad.add_buffer_probe (on_sink_buffer);
 
82
 
77
83
                // Set state to playing so we push the first frame to the sink.
78
84
                // Will be paused after first frame is shown.
79
85
                pipeline.set_state (State.PLAYING);
171
177
                        State old_state, new_state, pending_state;
172
178
                        message.parse_state_changed (out old_state, out new_state, out pending_state);
173
179
                        if (old_state == State.READY && new_state == State.PAUSED) {
 
180
                                loading_complete = true;
174
181
                                file_loaded ();
175
 
                                loading_complete = true;
176
182
                        }
177
183
                }
178
184
        }
197
203
                // FIXME: should push the latest frame again to update
198
204
                pipeline.set_state (state);
199
205
        }
 
206
 
 
207
        private bool on_sink_buffer (Pad pad, Buffer buffer) {
 
208
                var format = Format.DEFAULT;
 
209
                int64 pos;
 
210
 
 
211
                if (duration < 0) {
 
212
                        if (pipeline.query_duration (ref format, out duration) == false) {
 
213
                                debug ("Failed to query length of sequence");
 
214
                        }
 
215
                }
 
216
 
 
217
                if (pipeline.query_position (ref format, out pos)) {
 
218
                        frame_changed ((int) pos, (int) duration);
 
219
                }
 
220
                return true;
 
221
        }
200
222
}