gstreamer 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +6 -6
- data/ext/gstreamer/rbgst.c +36 -22
- data/lib/gst.rb +35 -5
- data/lib/gst/bus.rb +16 -0
- data/lib/gst/controller_loader.rb +20 -0
- data/sample/audio-example.rb +68 -0
- data/sample/framestep1.rb +137 -0
- data/sample/helloworld.rb +0 -2
- data/sample/mp3parselaunch.rb +0 -2
- data/sample/queue.rb +1 -3
- data/sample/stream-status.rb +106 -0
- data/sample/text-color-example.rb +84 -0
- data/sample/typefind.rb +0 -2
- metadata +15 -10
data/Rakefile
CHANGED
@@ -83,7 +83,7 @@ package = GNOME2Package.new do |_package|
|
|
83
83
|
:name => "gstreamer",
|
84
84
|
:download_base_url => "#{freedesktop_download_url_base}/gstreamer",
|
85
85
|
:label => "GStreamer",
|
86
|
-
:version => "1.0.
|
86
|
+
:version => "1.0.7",
|
87
87
|
:compression_method => "xz",
|
88
88
|
:windows => {
|
89
89
|
:configure_args => [
|
@@ -97,7 +97,7 @@ package = GNOME2Package.new do |_package|
|
|
97
97
|
:name => "gst-plugins-base",
|
98
98
|
:download_base_url => "#{freedesktop_download_url_base}/gst-plugins-base",
|
99
99
|
:label => "GStreamer plugins (base)",
|
100
|
-
:version => "1.0.
|
100
|
+
:version => "1.0.7",
|
101
101
|
:compression_method => "xz",
|
102
102
|
:windows => {
|
103
103
|
:configure_args => [
|
@@ -110,7 +110,7 @@ package = GNOME2Package.new do |_package|
|
|
110
110
|
:name => "gst-plugins-good",
|
111
111
|
:download_base_url => "#{freedesktop_download_url_base}/gst-plugins-good",
|
112
112
|
:label => "GStreamer plugins (good)",
|
113
|
-
:version => "1.0.
|
113
|
+
:version => "1.0.7",
|
114
114
|
:compression_method => "xz",
|
115
115
|
:windows => {
|
116
116
|
:configure_args => [
|
@@ -122,7 +122,7 @@ package = GNOME2Package.new do |_package|
|
|
122
122
|
:name => "gst-plugins-bad",
|
123
123
|
:download_base_url => "#{freedesktop_download_url_base}/gst-plugins-bad",
|
124
124
|
:label => "GStreamer plugins (bad)",
|
125
|
-
:version => "1.0.
|
125
|
+
:version => "1.0.7",
|
126
126
|
:compression_method => "xz",
|
127
127
|
:windows => {
|
128
128
|
:configure_args => ["--disable-librfb"],
|
@@ -132,7 +132,7 @@ package = GNOME2Package.new do |_package|
|
|
132
132
|
# :name => "gst-plugins-ugly",
|
133
133
|
# :download_base_url => "#{freedesktop_download_url_base}/gst-plugins-ugly",
|
134
134
|
# :label => "GStreamer plugins (ugly)",
|
135
|
-
# :version => "1.0.
|
135
|
+
# :version => "1.0.7",
|
136
136
|
# :compression_method => "xz",
|
137
137
|
# :windows => {
|
138
138
|
# :configure_args => [],
|
@@ -142,7 +142,7 @@ package = GNOME2Package.new do |_package|
|
|
142
142
|
:name => "gst-libav",
|
143
143
|
:download_base_url => "#{freedesktop_download_url_base}/gst-libav",
|
144
144
|
:label => "GStreamer libav",
|
145
|
-
:version => "1.0.
|
145
|
+
:version => "1.0.7",
|
146
146
|
:compression_method => "xz",
|
147
147
|
:windows => {
|
148
148
|
:configure_args => ["--with-libav-extra-configure=" +
|
data/ext/gstreamer/rbgst.c
CHANGED
@@ -25,24 +25,24 @@
|
|
25
25
|
extern void Init_gstreamer (void);
|
26
26
|
|
27
27
|
static gboolean
|
28
|
-
|
28
|
+
name_equal(GIArgInfo *info, const gchar *target_name)
|
29
29
|
{
|
30
30
|
GITypeInfo type_info;
|
31
31
|
GIBaseInfo *interface_info;
|
32
32
|
const gchar *namespace;
|
33
33
|
const gchar *name;
|
34
|
-
gboolean
|
34
|
+
gboolean equal_name_p = FALSE;
|
35
35
|
|
36
36
|
g_arg_info_load_type(info, &type_info);
|
37
37
|
interface_info = g_type_info_get_interface(&type_info);
|
38
38
|
namespace = g_base_info_get_namespace(interface_info);
|
39
39
|
name = g_base_info_get_name(interface_info);
|
40
|
-
if (strcmp(namespace, "Gst") == 0 && strcmp(name,
|
41
|
-
|
40
|
+
if (strcmp(namespace, "Gst") == 0 && strcmp(name, target_name) == 0) {
|
41
|
+
equal_name_p = TRUE;
|
42
42
|
}
|
43
43
|
g_base_info_unref(interface_info);
|
44
44
|
|
45
|
-
return
|
45
|
+
return equal_name_p;
|
46
46
|
}
|
47
47
|
|
48
48
|
static gboolean
|
@@ -65,31 +65,38 @@ rg_gst_bus_func_callback(GstBus *bus, GstMessage *message, gpointer user_data)
|
|
65
65
|
static gpointer
|
66
66
|
rg_gst_bus_func_callback_finder(GIArgInfo *info)
|
67
67
|
{
|
68
|
-
if (!
|
68
|
+
if (!name_equal(info, "BusFunc")) {
|
69
69
|
return NULL;
|
70
70
|
}
|
71
71
|
return rg_gst_bus_func_callback;
|
72
72
|
}
|
73
73
|
|
74
74
|
static gboolean
|
75
|
-
|
75
|
+
rg_gst_bus_sync_handler_callback(GstBus *bus, GstMessage *message,
|
76
|
+
gpointer user_data)
|
76
77
|
{
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
const gchar *name;
|
81
|
-
gboolean gst_tag_foreach_func_p = FALSE;
|
78
|
+
RBGICallbackData *callback_data = user_data;
|
79
|
+
VALUE rb_bus_sync_reply;
|
80
|
+
ID id_call;
|
82
81
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
82
|
+
CONST_ID(id_call, "call");
|
83
|
+
rb_bus_sync_reply =
|
84
|
+
rb_funcall(callback_data->rb_callback, id_call, 2,
|
85
|
+
GOBJ2RVAL(bus),
|
86
|
+
BOXED2RVAL(message, GST_MINI_OBJECT_TYPE(message)));
|
87
|
+
if (callback_data->metadata->scope_type == GI_SCOPE_TYPE_ASYNC) {
|
88
|
+
rb_gi_callback_data_free(callback_data);
|
89
89
|
}
|
90
|
-
|
90
|
+
return RVAL2GENUM(rb_bus_sync_reply, GST_TYPE_BUS_SYNC_REPLY);
|
91
|
+
}
|
91
92
|
|
92
|
-
|
93
|
+
static gpointer
|
94
|
+
rg_gst_bus_sync_handler_callback_finder(GIArgInfo *info)
|
95
|
+
{
|
96
|
+
if (!name_equal(info, "BusSyncHandler")) {
|
97
|
+
return NULL;
|
98
|
+
}
|
99
|
+
return rg_gst_bus_sync_handler_callback;
|
93
100
|
}
|
94
101
|
|
95
102
|
static void
|
@@ -101,7 +108,13 @@ rg_gst_tag_foreach_func_callback(const GstTagList *list, const gchar *tag,
|
|
101
108
|
|
102
109
|
CONST_ID(id_call, "call");
|
103
110
|
rb_funcall(callback_data->rb_callback, id_call, 2,
|
104
|
-
|
111
|
+
/*
|
112
|
+
* XXX: Use gst_tag_list_copy() instead if we don't trust
|
113
|
+
* users. Users should not use destructive methods such as
|
114
|
+
* #insert. If many users use these methods, we shuold use
|
115
|
+
* gst_tag_list_copy().
|
116
|
+
*/
|
117
|
+
BOXED2RVAL((GstTagList *)list, GST_MINI_OBJECT_TYPE(list)),
|
105
118
|
CSTR2RVAL(tag));
|
106
119
|
if (callback_data->metadata->scope_type == GI_SCOPE_TYPE_ASYNC) {
|
107
120
|
rb_gi_callback_data_free(callback_data);
|
@@ -111,7 +124,7 @@ rg_gst_tag_foreach_func_callback(const GstTagList *list, const gchar *tag,
|
|
111
124
|
static gpointer
|
112
125
|
rg_gst_tag_foreach_func_callback_finder(GIArgInfo *info)
|
113
126
|
{
|
114
|
-
if (!
|
127
|
+
if (!name_equal(info, "TagForeachFunc")) {
|
115
128
|
return NULL;
|
116
129
|
}
|
117
130
|
return rg_gst_tag_foreach_func_callback;
|
@@ -121,5 +134,6 @@ void
|
|
121
134
|
Init_gstreamer (void)
|
122
135
|
{
|
123
136
|
rb_gi_callback_register_finder(rg_gst_bus_func_callback_finder);
|
137
|
+
rb_gi_callback_register_finder(rg_gst_bus_sync_handler_callback_finder);
|
124
138
|
rb_gi_callback_register_finder(rg_gst_tag_foreach_func_callback_finder);
|
125
139
|
}
|
data/lib/gst.rb
CHANGED
@@ -33,17 +33,28 @@ module Gst
|
|
33
33
|
LOG_DOMAIN = "GStreamer"
|
34
34
|
GLib::Log.set_log_domain(LOG_DOMAIN)
|
35
35
|
|
36
|
-
@initialized = false
|
37
36
|
class << self
|
37
|
+
def const_missing(name)
|
38
|
+
init()
|
39
|
+
if const_defined?(name)
|
40
|
+
const_get(name)
|
41
|
+
else
|
42
|
+
super
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
38
46
|
def init(*argv)
|
39
|
-
return if @initialized
|
40
|
-
@initialized = true
|
41
47
|
loader = Loader.new(self, argv)
|
42
48
|
loader.load("Gst")
|
43
49
|
require "gst/bin"
|
44
50
|
require "gst/bus"
|
45
51
|
require "gst/element"
|
46
52
|
init_base
|
53
|
+
init_controller
|
54
|
+
class << self
|
55
|
+
remove_method(:init)
|
56
|
+
remove_method(:const_missing)
|
57
|
+
end
|
47
58
|
end
|
48
59
|
|
49
60
|
private
|
@@ -52,6 +63,12 @@ module Gst
|
|
52
63
|
base_loader = BaseLoader.new(self)
|
53
64
|
base_loader.load("GstBase")
|
54
65
|
end
|
66
|
+
|
67
|
+
def init_controller
|
68
|
+
require "gst/controller_loader"
|
69
|
+
controller_loader = ControllerLoader.new(self)
|
70
|
+
controller_loader.load("GstController")
|
71
|
+
end
|
55
72
|
end
|
56
73
|
|
57
74
|
class Loader < GObjectIntrospection::Loader
|
@@ -63,8 +80,11 @@ module Gst
|
|
63
80
|
private
|
64
81
|
def pre_load(repository, namespace)
|
65
82
|
init_check = repository.find(namespace, "init_check")
|
66
|
-
|
67
|
-
|
83
|
+
arguments = [
|
84
|
+
1 + @init_arguments.size,
|
85
|
+
[$0] + @init_arguments,
|
86
|
+
]
|
87
|
+
succeeded, argc, argv, error = init_check.invoke(arguments)
|
68
88
|
@init_arguments.replace(argv[1..-1])
|
69
89
|
raise error unless succeeded
|
70
90
|
end
|
@@ -97,5 +117,15 @@ module Gst
|
|
97
117
|
def rubyish_method_name(function_info)
|
98
118
|
RENAME_MAP[function_info.name] || super
|
99
119
|
end
|
120
|
+
|
121
|
+
UNLOCK_GVL_METHODS = {
|
122
|
+
"Gst::Element#set_state" => true,
|
123
|
+
"Gst::Element#get_state" => true,
|
124
|
+
"Gst::Element#query_state" => true,
|
125
|
+
"Gst::Element#send_event" => true,
|
126
|
+
}
|
127
|
+
def should_unlock_gvl?(function_info, klass)
|
128
|
+
UNLOCK_GVL_METHODS["#{klass}\##{function_info.name}"] || super
|
129
|
+
end
|
100
130
|
end
|
101
131
|
end
|
data/lib/gst/bus.rb
CHANGED
@@ -20,5 +20,21 @@ module Gst
|
|
20
20
|
def add_watch(priority=GLib::PRIORITY_DEFAULT, &block)
|
21
21
|
add_watch_full(priority, &block)
|
22
22
|
end
|
23
|
+
|
24
|
+
def sync_handler(&block)
|
25
|
+
@sync_handler = lambda do |bus, message|
|
26
|
+
begin
|
27
|
+
block.call(bus, message)
|
28
|
+
rescue Exception
|
29
|
+
$stderr.puts("An exception is raised in " +
|
30
|
+
"#{self.class}\##{__method__} callback: #{block}")
|
31
|
+
$stderr.puts("#{$!.class}: #{$!.message}")
|
32
|
+
$stderr.puts($@)
|
33
|
+
BusSyncReply::DROP
|
34
|
+
end
|
35
|
+
end
|
36
|
+
set_sync_handler(&@sync_handler)
|
37
|
+
end
|
38
|
+
private :set_sync_handler
|
23
39
|
end
|
24
40
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Copyright (C) 2013 Ruby-GNOME2 Project Team
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License, or (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This library 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 GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
16
|
+
|
17
|
+
module Gst
|
18
|
+
class ControllerLoader < GObjectIntrospection::Loader
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
#
|
4
|
+
# audio-example.rb
|
5
|
+
#
|
6
|
+
# Builds a pipeline with [ audiotestsource ! autoaudiosink ] and sweeps
|
7
|
+
# frequency and volume.
|
8
|
+
#
|
9
|
+
# Needs gst-plugin-base + gst-plugins-good installed.
|
10
|
+
#
|
11
|
+
# This sample code is a port of
|
12
|
+
# gstreamer/tests/examples/controller/audio-example.c. It is licensed
|
13
|
+
# under the terms of the GNU Library General Public License, version
|
14
|
+
# 2 or (at your option) later.
|
15
|
+
#
|
16
|
+
# Copyright (C) 2013 Ruby-GNOME2 Project Team
|
17
|
+
#
|
18
|
+
# This library is free software; you can redistribute it and/or
|
19
|
+
# modify it under the terms of the GNU Lesser General Public
|
20
|
+
# License as published by the Free Software Foundation; either
|
21
|
+
# version 2.1 of the License, or (at your option) any later version.
|
22
|
+
#
|
23
|
+
# This library is distributed in the hope that it will be useful,
|
24
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
25
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
26
|
+
# Lesser General Public License for more details.
|
27
|
+
#
|
28
|
+
# You should have received a copy of the GNU Lesser General Public
|
29
|
+
# License along with this library; if not, write to the Free Software
|
30
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
31
|
+
|
32
|
+
require "gst"
|
33
|
+
|
34
|
+
bin = Gst::Pipeline.new("pipeline")
|
35
|
+
clock = bin.clock
|
36
|
+
src = Gst::ElementFactory.make("audiotestsrc", nil)
|
37
|
+
raise "need audiotestsrc from gst-plugins-base" if src.nil?
|
38
|
+
sink = Gst::ElementFactory.make("autoaudiosink", nil)
|
39
|
+
raise "need autoaudiosink from gst-plugins-good" if sink.nil?
|
40
|
+
|
41
|
+
bin << src << sink
|
42
|
+
src >> sink
|
43
|
+
|
44
|
+
# setup control sources
|
45
|
+
cs1 = Gst::InterpolationControlSource.new
|
46
|
+
cs2 = Gst::InterpolationControlSource.new
|
47
|
+
|
48
|
+
src.add_control_binding(Gst::DirectControlBinding.new(src, "volume", cs1))
|
49
|
+
src.add_control_binding(Gst::DirectControlBinding.new(src, "freq", cs2))
|
50
|
+
|
51
|
+
# set interpolation mode
|
52
|
+
cs1.mode = Gst::InterpolationMode::LINEAR
|
53
|
+
cs2.mode = Gst::InterpolationMode::LINEAR
|
54
|
+
|
55
|
+
# set control values
|
56
|
+
cs1.set(0 * Gst::SECOND, 0.0)
|
57
|
+
cs1.set(5 * Gst::SECOND, 1.0)
|
58
|
+
|
59
|
+
cs2.set(0 * Gst::SECOND, 220.0 / 20000.0)
|
60
|
+
cs2.set(3 * Gst::SECOND, 3520.0 / 20000.0)
|
61
|
+
cs2.set(6 * Gst::SECOND, 440.0 / 20000.0)
|
62
|
+
|
63
|
+
# run for 7 seconds
|
64
|
+
clock_id = clock.new_single_shot_id(clock.time + (7 * Gst::SECOND))
|
65
|
+
bin.play
|
66
|
+
wait_ret, jitter = Gst::Clock.id_wait(clock_id)
|
67
|
+
$stderr.puts "Clock::id_wait returned: #{wait_ret}" if wait_ret != Gst::ClockReturn::OK
|
68
|
+
bin.stop
|
@@ -0,0 +1,137 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
#
|
4
|
+
# This sample code is a port of
|
5
|
+
# gstreamer/tests/examples/stepping/framestep1.c. It is licensed
|
6
|
+
# under the terms of the GNU Library General Public License, version
|
7
|
+
# 2 or (at your option) later.
|
8
|
+
#
|
9
|
+
# Copyright (C) 2013 Ruby-GNOME2 Project Team
|
10
|
+
#
|
11
|
+
# This library is free software; you can redistribute it and/or
|
12
|
+
# modify it under the terms of the GNU Lesser General Public
|
13
|
+
# License as published by the Free Software Foundation; either
|
14
|
+
# version 2.1 of the License, or (at your option) any later version.
|
15
|
+
#
|
16
|
+
# This library is distributed in the hope that it will be useful,
|
17
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
19
|
+
# Lesser General Public License for more details.
|
20
|
+
#
|
21
|
+
# You should have received a copy of the GNU Lesser General Public
|
22
|
+
# License along with this library; if not, write to the Free Software
|
23
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
24
|
+
|
25
|
+
require "gst"
|
26
|
+
|
27
|
+
def event_loop(pipe)
|
28
|
+
running = true
|
29
|
+
|
30
|
+
bus = pipe.bus
|
31
|
+
|
32
|
+
while running
|
33
|
+
message = bus.timed_pop_filtered(Gst::CLOCK_TIME_NONE, Gst::MessageType::ANY)
|
34
|
+
raise "message nil" if message.nil?
|
35
|
+
|
36
|
+
case message.type
|
37
|
+
when Gst::MessageType::EOS
|
38
|
+
puts "got EOS"
|
39
|
+
running = false
|
40
|
+
when Gst::MessageType::WARNING
|
41
|
+
warning, debug = message.parse_warning
|
42
|
+
puts "Debugging info: #{debug || 'none'}"
|
43
|
+
puts "Warning: #{warning.message}"
|
44
|
+
when Gst::MessageType::ERROR
|
45
|
+
error, debug = message.parse_error
|
46
|
+
puts "Debugging info: #{debug || 'none'}"
|
47
|
+
puts "Error: #{error.message}"
|
48
|
+
running = false
|
49
|
+
when Gst::MessageType::STEP_DONE
|
50
|
+
format, amount, rate, flush, intermediate, duration, eos =
|
51
|
+
message.parse_step_done
|
52
|
+
if format == Gst::Format::DEFAULT
|
53
|
+
puts "step done: #{gst_time(duration)} skipped in #{gst_time(amount)} frames"
|
54
|
+
else
|
55
|
+
puts "step done: #{gst_time(duration)} skipped"
|
56
|
+
end
|
57
|
+
running = false
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def gst_time(time)
|
63
|
+
Time.at(time / 1000000000.0).utc.strftime("%H:%M:%S.%N")
|
64
|
+
end
|
65
|
+
|
66
|
+
# create a new bin to hold the elements
|
67
|
+
bin = Gst::Pipeline.new("pipeline")
|
68
|
+
raise "'pipeline' gstreamer plugin missing" if bin.nil?
|
69
|
+
|
70
|
+
# create a fake source
|
71
|
+
videotestsrc = Gst::ElementFactory.make("videotestsrc", "videotestsrc")
|
72
|
+
raise "'videotestsrc' gstreamer plugin missing" if videotestsrc.nil?
|
73
|
+
videotestsrc.num_buffers = 10
|
74
|
+
|
75
|
+
# and a fake sink
|
76
|
+
appsink = Gst::ElementFactory.make("appsink", "appsink")
|
77
|
+
raise "'appsink' gstreamer plugin missing" if appsink.nil?
|
78
|
+
appsink.emit_signals = true
|
79
|
+
appsink.sync = true
|
80
|
+
appsink.signal_connect("new-preroll") do |appsink|
|
81
|
+
# signalled when a new preroll buffer is available
|
82
|
+
sample = appsink.pull_preroll
|
83
|
+
puts "have new-preroll sample #{sample}, timestamp #{gst_time(sample.buffer.pts)}"
|
84
|
+
Gst::FlowReturn::OK
|
85
|
+
end
|
86
|
+
|
87
|
+
# add objects to the main pipeline
|
88
|
+
bin << videotestsrc << appsink
|
89
|
+
|
90
|
+
# link the elements
|
91
|
+
videotestsrc >> appsink
|
92
|
+
|
93
|
+
# go to the PAUSED state and wait for preroll
|
94
|
+
puts "prerolling first frame"
|
95
|
+
bin.pause
|
96
|
+
bin.get_state(Gst::CLOCK_TIME_NONE)
|
97
|
+
|
98
|
+
# step two frames, flush so that new preroll is queued
|
99
|
+
puts "stepping three frames"
|
100
|
+
unless bin.send_event(Gst::Event.new(Gst::Format::BUFFERS, 2, 1.0, true, false))
|
101
|
+
raise "Failed to send STEP event!"
|
102
|
+
end
|
103
|
+
|
104
|
+
# blocks and returns when we received the step done message
|
105
|
+
event_loop(bin)
|
106
|
+
|
107
|
+
# wait for step to really complete
|
108
|
+
bin.get_state(Gst::CLOCK_TIME_NONE)
|
109
|
+
|
110
|
+
result, pos = bin.query_position(Gst::Format::TIME)
|
111
|
+
puts "stepped two frames, now at #{gst_time(pos)}"
|
112
|
+
|
113
|
+
# step 3 frames, flush so that new preroll is queued
|
114
|
+
puts "stepping 120 milliseconds"
|
115
|
+
unless bin.send_event(Gst::Event.new(Gst::Format::TIME, 120 * Gst::MSECOND, 1.0,
|
116
|
+
true, false))
|
117
|
+
raise "Failed to send STEP event!"
|
118
|
+
end
|
119
|
+
|
120
|
+
# blocks and returns when we received the step done message
|
121
|
+
event_loop(bin)
|
122
|
+
|
123
|
+
# wait for step to really complete
|
124
|
+
bin.get_state(Gst::CLOCK_TIME_NONE)
|
125
|
+
|
126
|
+
result, pos = bin.query_position(Gst::Format::TIME)
|
127
|
+
puts "stepped 120ms frames, now at #{gst_time(pos)}"
|
128
|
+
|
129
|
+
puts "playing until EOS"
|
130
|
+
bin.play
|
131
|
+
|
132
|
+
# Run event loop listening for bus messages until EOS or ERROR
|
133
|
+
event_loop(bin)
|
134
|
+
puts "finished"
|
135
|
+
|
136
|
+
# stop the bin
|
137
|
+
bin.stop
|
data/sample/helloworld.rb
CHANGED
data/sample/mp3parselaunch.rb
CHANGED
data/sample/queue.rb
CHANGED
@@ -34,7 +34,7 @@ def event_loop(pipe)
|
|
34
34
|
running = true
|
35
35
|
bus = pipe.bus
|
36
36
|
|
37
|
-
while running
|
37
|
+
while running
|
38
38
|
message = bus.poll(Gst::MessageType::ANY, -1)
|
39
39
|
|
40
40
|
case message.type
|
@@ -53,8 +53,6 @@ def event_loop(pipe)
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
Gst.init
|
57
|
-
|
58
56
|
if ARGV.length < 1
|
59
57
|
puts "usage: #{$0} <filename>"
|
60
58
|
exit(false)
|
@@ -0,0 +1,106 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
#
|
4
|
+
# This sample code is a port of
|
5
|
+
# gstreamer/tests/examples/streams/stream-status.c. It is licensed
|
6
|
+
# under the terms of the GNU Library General Public License, version
|
7
|
+
# 2 or (at your option) later.
|
8
|
+
#
|
9
|
+
# Copyright (C) 2013 Ruby-GNOME2 Project Team
|
10
|
+
#
|
11
|
+
# This library is free software; you can redistribute it and/or
|
12
|
+
# modify it under the terms of the GNU Lesser General Public
|
13
|
+
# License as published by the Free Software Foundation; either
|
14
|
+
# version 2.1 of the License, or (at your option) any later version.
|
15
|
+
#
|
16
|
+
# This library is distributed in the hope that it will be useful,
|
17
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
19
|
+
# Lesser General Public License for more details.
|
20
|
+
#
|
21
|
+
# You should have received a copy of the GNU Lesser General Public
|
22
|
+
# License along with this library; if not, write to the Free Software
|
23
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
24
|
+
|
25
|
+
require "gst"
|
26
|
+
|
27
|
+
def event_loop(bus, pipe)
|
28
|
+
|
29
|
+
loop do
|
30
|
+
message = bus.poll(Gst::MessageType::ANY, Gst::CLOCK_TIME_NONE)
|
31
|
+
raise "message nil" if message.nil?
|
32
|
+
|
33
|
+
case message.type
|
34
|
+
when Gst::MessageType::EOS
|
35
|
+
puts "received EOS"
|
36
|
+
return
|
37
|
+
when Gst::MessageType::WARNING
|
38
|
+
warning, debug = message.parse_warning
|
39
|
+
puts "#{message} #{warning.message}"
|
40
|
+
when Gst::MessageType::ERROR
|
41
|
+
error, debug = message.parse_error
|
42
|
+
puts "#{message} #{error.message}"
|
43
|
+
return
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
# create a new bin to hold the elements
|
50
|
+
bin = Gst::Pipeline.new("pipeline")
|
51
|
+
raise "'pipeline' gstreamer plugin missing" if bin.nil?
|
52
|
+
|
53
|
+
# create a source
|
54
|
+
fakesrc = Gst::ElementFactory.make("fakesrc", "fakesrc")
|
55
|
+
raise "'fakesrc' gstreamer plugin missing" if fakesrc.nil?
|
56
|
+
|
57
|
+
# and a sink
|
58
|
+
fakesink = Gst::ElementFactory.make("fakesink", "fakesink")
|
59
|
+
raise "'fakesink' gstreamer plugin missing" if fakesink.nil?
|
60
|
+
|
61
|
+
# add objects to the main pipeline
|
62
|
+
bin << fakesrc << fakesink
|
63
|
+
|
64
|
+
# link the elements
|
65
|
+
fakesrc >> fakesink
|
66
|
+
|
67
|
+
# get the bus, we need to install a sync handler
|
68
|
+
bin.bus.sync_handler do |bus, message|
|
69
|
+
|
70
|
+
case message.type
|
71
|
+
when Gst::MessageType::STREAM_STATUS
|
72
|
+
type, owner = message.parse_stream_status
|
73
|
+
|
74
|
+
val = message.stream_status_object
|
75
|
+
|
76
|
+
puts "type: #{type}"
|
77
|
+
puts "source: #{message.src.path_string}"
|
78
|
+
puts "owner: #{owner.path_string}"
|
79
|
+
puts "object: type #{val.type.name}, value #{val.value}"
|
80
|
+
|
81
|
+
# see if we know how to deal with this object
|
82
|
+
if val.type == Gst::Task
|
83
|
+
task = val.value
|
84
|
+
end
|
85
|
+
|
86
|
+
case type
|
87
|
+
when Gst::StreamStatusType::CREATE
|
88
|
+
puts "created task #{task}"
|
89
|
+
when Gst::StreamStatusType::ENTER
|
90
|
+
# puts "raising task priority"
|
91
|
+
# setpriority(PRIO_PROCESS, 0, -10)
|
92
|
+
when Gst::StreamStatusType::LEAVE
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
Gst::BusSyncReply::PASS
|
97
|
+
end
|
98
|
+
|
99
|
+
# start playing
|
100
|
+
bin.play
|
101
|
+
|
102
|
+
# run event loop listening for bus messages until EOS or ERROR
|
103
|
+
event_loop(bus, bin)
|
104
|
+
|
105
|
+
# stop the bin
|
106
|
+
bin.stop
|
@@ -0,0 +1,84 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
#
|
4
|
+
# text-color-example.rb
|
5
|
+
#
|
6
|
+
# Builds a pipeline with [videotestsrc ! textoverlay ! ximagesink] and
|
7
|
+
# modulates color, text and text pos.
|
8
|
+
#
|
9
|
+
# Needs gst-plugin-base installed.
|
10
|
+
#
|
11
|
+
# This sample code is a port of
|
12
|
+
# gstreamer/tests/examples/controller/text-color-example.c. It is
|
13
|
+
# licensed under the terms of the GNU Library General Public License,
|
14
|
+
# version 2 or (at your option) later.
|
15
|
+
#
|
16
|
+
# Copyright (C) 2013 Ruby-GNOME2 Project Team
|
17
|
+
#
|
18
|
+
# This library is free software; you can redistribute it and/or
|
19
|
+
# modify it under the terms of the GNU Lesser General Public
|
20
|
+
# License as published by the Free Software Foundation; either
|
21
|
+
# version 2.1 of the License, or (at your option) any later version.
|
22
|
+
#
|
23
|
+
# This library is distributed in the hope that it will be useful,
|
24
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
25
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
26
|
+
# Lesser General Public License for more details.
|
27
|
+
#
|
28
|
+
# You should have received a copy of the GNU Lesser General Public
|
29
|
+
# License along with this library; if not, write to the Free Software
|
30
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
31
|
+
|
32
|
+
require "gst"
|
33
|
+
|
34
|
+
bin = Gst::Pipeline.new("pipeline")
|
35
|
+
clock = bin.clock
|
36
|
+
src = Gst::ElementFactory.make("videotestsrc", nil)
|
37
|
+
raise "need videotestsrc from gst-plugins-base" if src.nil?
|
38
|
+
src.pattern = 10 # checkers-8
|
39
|
+
text = Gst::ElementFactory.make("textoverlay", nil)
|
40
|
+
raise "need textoverlay from gst-plugins-base" if text.nil?
|
41
|
+
text.text = "GStreamer rocks!"
|
42
|
+
text.font_desc = "Sans, 30"
|
43
|
+
text.halignment = 4 # position
|
44
|
+
text.valignment = 3 # position
|
45
|
+
sink = Gst::ElementFactory.make("ximagesink", nil)
|
46
|
+
raise "need ximagesink from gst-plugins-base" if sink.nil?
|
47
|
+
|
48
|
+
bin << src << text << sink
|
49
|
+
src >> text >> sink
|
50
|
+
|
51
|
+
# setup control sources
|
52
|
+
cs = Gst::LFOControlSource.new
|
53
|
+
cs.frequency = 0.11
|
54
|
+
cs.amplitude = 0.2
|
55
|
+
cs.offset = 0.5
|
56
|
+
text.add_control_binding(Gst::DirectControlBinding.new(text, "xpos", cs))
|
57
|
+
|
58
|
+
cs = Gst::LFOControlSource.new
|
59
|
+
cs.frequency = 0.04
|
60
|
+
cs.amplitude = 0.4
|
61
|
+
cs.offset = 0.5
|
62
|
+
text.add_control_binding(Gst::DirectControlBinding.new(text, "ypos", cs))
|
63
|
+
|
64
|
+
cs_r = Gst::LFOControlSource.new
|
65
|
+
cs_r.frequency = 0.19
|
66
|
+
cs_r.amplitude = 0.5
|
67
|
+
cs_r.offset = 0.5
|
68
|
+
cs_g = Gst::LFOControlSource.new
|
69
|
+
cs_g.frequency = 0.27
|
70
|
+
cs_g.amplitude = 0.5
|
71
|
+
cs_g.offset = 0.5
|
72
|
+
cs_b = Gst::LFOControlSource.new
|
73
|
+
cs_b.frequency = 0.13
|
74
|
+
cs_b.amplitude = 0.5
|
75
|
+
cs_b.offset = 0.5
|
76
|
+
text.add_control_binding(Gst::ARGBControlBinding.new(text, "color", nil,
|
77
|
+
cs_r, cs_g, cs_b))
|
78
|
+
|
79
|
+
# run for 10 seconds
|
80
|
+
clock_id = clock.new_single_shot_id(clock.time + (30 * Gst::SECOND))
|
81
|
+
bin.play
|
82
|
+
wait_ret, jitter = Gst::Clock.id_wait(clock_id)
|
83
|
+
$stderr.puts "Clock.id_wait returned: #{wait_ret}" if wait_ret != Gst::ClockReturn::OK
|
84
|
+
bin.stop
|
data/sample/typefind.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gstreamer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,40 +9,40 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: glib2
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 2.0.
|
21
|
+
version: 2.0.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 2.0.
|
29
|
+
version: 2.0.1
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: gobject-introspection
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
|
-
- -
|
35
|
+
- - '='
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 2.0.
|
37
|
+
version: 2.0.1
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - '='
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 2.0.
|
45
|
+
version: 2.0.1
|
46
46
|
description: Ruby/GStreamer is a Ruby binding for GStreamer.
|
47
47
|
email: ruby-gnome2-devel-en@lists.sourceforge.net
|
48
48
|
executables: []
|
@@ -56,13 +56,18 @@ files:
|
|
56
56
|
- lib/gst/base_loader.rb
|
57
57
|
- lib/gst/bin.rb
|
58
58
|
- lib/gst/bus.rb
|
59
|
+
- lib/gst/controller_loader.rb
|
59
60
|
- lib/gst/element.rb
|
60
61
|
- ext/gstreamer/depend
|
61
62
|
- ext/gstreamer/extconf.rb
|
62
63
|
- ext/gstreamer/rbgst.c
|
64
|
+
- sample/audio-example.rb
|
65
|
+
- sample/framestep1.rb
|
63
66
|
- sample/helloworld.rb
|
64
67
|
- sample/mp3parselaunch.rb
|
65
68
|
- sample/queue.rb
|
69
|
+
- sample/stream-status.rb
|
70
|
+
- sample/text-color-example.rb
|
66
71
|
- sample/typefind.rb
|
67
72
|
homepage: http://ruby-gnome2.sourceforge.jp/
|
68
73
|
licenses: []
|