]> git.sesse.net Git - nageru/commitdiff
Hook up the cut button to Lua, so that it actually does something.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 7 Oct 2015 22:00:54 +0000 (00:00 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 7 Oct 2015 22:00:54 +0000 (00:00 +0200)
mainwindow.cpp
mixer.cpp
mixer.h
theme.cpp
theme.h
theme.lua

index ad0808c6d5c9d20a0043ecd64b2746e1d68664bf..f3c674d269b4b3611e98799f999b2c5a09a48a28 100644 (file)
@@ -23,6 +23,5 @@ MainWindow::MainWindow()
 
 void MainWindow::cut()
 {
-       static int i = 0;
-       global_mixer->cut(Mixer::Source((++i) % 3));
+       global_mixer->transition_clicked(0, 0.0f);  // FIXME: real values
 }
index 83bb7a52ddecdd9990989f9f145d117d41f1ed5b..99aa33cbecd33f06e08a9a5ee8cc2f3dd8b2b9b6 100644 (file)
--- a/mixer.cpp
+++ b/mixer.cpp
@@ -271,6 +271,7 @@ void Mixer::thread_func()
        while (!should_quit) {
                ++frame;
 
+#if 0
                //int width0 = lrintf(848 * (1.0 + 0.2 * sin(frame * 0.02)));
                int width0 = 848;
                int height0 = lrintf(width0 * 9.0 / 16.0);
@@ -327,7 +328,6 @@ void Mixer::thread_func()
                        right1 = right1 * scale0 + tx0;
                }
 
-#if 0
                place_rectangle(resample_effect, padding_effect, left0, top0, right0, bottom0);
                place_rectangle(resample2_effect, padding2_effect, left1, top1, right1, bottom1);
 #endif
@@ -531,9 +531,9 @@ void Mixer::quit()
        mixer_thread.join();
 }
 
-void Mixer::cut(Source source)
+void Mixer::transition_clicked(int transition_num, float t)
 {
-       current_source = source;
+       theme->transition_clicked(transition_num, t);
 }
 
 void Mixer::OutputChannel::output_frame(DisplayFrame frame)
diff --git a/mixer.h b/mixer.h
index 80d18ff00395c3651ff461b72b03e72da51b7f7a..b4eaad9b0d2a1338d9c099fe5302edeb6f2c4e48 100644 (file)
--- a/mixer.h
+++ b/mixer.h
@@ -32,12 +32,7 @@ public:
        void start();
        void quit();
 
-       enum Source {
-               SOURCE_INPUT1,
-               SOURCE_INPUT2,
-               SOURCE_SBS,
-       };
-       void cut(Source source);
+       void transition_clicked(int transition_num, float t);
 
        enum Output {
                OUTPUT_LIVE = 0,
@@ -98,7 +93,6 @@ private:
        // Effects part of <display_chain>. Owned by <display_chain>.
        movit::FlatInput *display_input;
 
-       Source current_source = SOURCE_INPUT1;
        int frame = 0;
 
        std::mutex bmusb_mutex;
index 26f793721b77128ae9777c7e3e5402405371f491..5d42c3d661d8a05d99f05613bb18c1eb2470e4c7 100644 (file)
--- a/theme.cpp
+++ b/theme.cpp
@@ -248,3 +248,16 @@ void Theme::connect_signal(YCbCrInput *input, int signal_num)
        input->set_texture_num(0, input_textures[signal_num].tex_y);
        input->set_texture_num(1, input_textures[signal_num].tex_cbcr);
 }
+
+void Theme::transition_clicked(int transition_num, float t)
+{
+       unique_lock<mutex> lock(m);
+       lua_getglobal(L, "transition_clicked");
+       lua_pushnumber(L, transition_num);
+       lua_pushnumber(L, t);
+
+       if (lua_pcall(L, 2, 0, 0) != 0) {
+               fprintf(stderr, "error running function `transition_clicked': %s", lua_tostring(L, -1));
+               exit(1);
+       }
+}
diff --git a/theme.h b/theme.h
index 2e0634718fe9c90c16a3e078beda168497e35da9..f58681d080666dfe8fb3861512dc44b4de9bdd68 100644 (file)
--- a/theme.h
+++ b/theme.h
@@ -26,6 +26,7 @@ public:
        }
 
        void connect_signal(movit::YCbCrInput *input, int signal_num);
+       void transition_clicked(int transition_num, float t);
 
 private:
        std::mutex m;
index 95a765b345e5de04b9be17abd80e248dc7a57217..fbe2cbf4e0b0c7f3b31da707e0514a1757b5375c 100644 (file)
--- a/theme.lua
+++ b/theme.lua
@@ -8,12 +8,14 @@
 -- C++ side and you generally just build chains.
 io.write("hello from lua\n");
 
+local live_signal_num = 0;
+local preview_signal_num = 1;
+
 -- The main live chain. Currently just about input 0 with some color correction.
 local main_chain = EffectChain.new(16, 9);
 local input0 = main_chain:add_live_input();
 input0:connect_signal(0);
 local wb_effect = main_chain:add_effect(WhiteBalanceEffect.new(), input0);
-wb_effect:set_float("output_color_temperature", 1234.0);
 main_chain:finalize(true);
 -- local input1 = main_chain.add_input(Inputs.create(1));
 -- local resample_effect = main_chain.add_effect(ResampleEffect.new(), input0);
@@ -37,8 +39,10 @@ function get_transitions()
 end
 
 function transition_clicked(num, t)
-       -- Presumably do some sort of transition here.
-       io.write("STUB: transition_clicked\n");
+       -- Only a cut for now.
+       local temp = live_signal_num;
+       live_signal_num = preview_signal_num;
+       preview_signal_num = temp;
 end
 
 function channel_clicked(num, t)
@@ -60,14 +64,14 @@ end
 function get_chain(num, t, width, height)
        if num == 0 then  -- Live.
                prepare = function()
-                       input0:connect_signal(1);
+                       input0:connect_signal(live_signal_num);
                        wb_effect:set_float("output_color_temperature", 3500.0 + t * 100.0);
                end
                return main_chain, prepare;
        end
        if num == 1 then  -- Preview.
                prepare = function()
-                       simple_chain_input:connect_signal(0);
+                       simple_chain_input:connect_signal(preview_signal_num);
                end
                return simple_chain, prepare;
        end