Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoherbelin committed Oct 5, 2024
2 parents 9b7b407 + 2de9ca1 commit b90b246
Show file tree
Hide file tree
Showing 13 changed files with 131 additions and 105 deletions.
27 changes: 14 additions & 13 deletions src/DeviceSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,24 +163,25 @@ void Device::add(GstDevice *device)
auto handle = std::find_if(handles_.cbegin(), handles_.cend(), hasDeviceName(device_name) );
if ( handle == handles_.cend() ) {

// add if not in the list and valid
std::string p = pipelineForDevice(device, handles_.size());
GstToolkit::PipelineConfigSet confs = GstToolkit::getPipelineConfigs(p);
if (!p.empty()) {

// add if not in the list and valid
if (!p.empty() && !confs.empty()) {
DeviceHandle dev;
dev.name = device_name;
dev.pipeline = p;
dev.configs = confs;
dev.properties = get_device_properties (device);
GstToolkit::PipelineConfigSet confs = GstToolkit::getPipelineConfigs(p);
if (!confs.empty()) {
DeviceHandle dev;
dev.name = device_name;
dev.pipeline = p;
dev.configs = confs;
dev.properties = get_device_properties (device);
#ifdef DEVICE_DEBUG
GstStructure *stru = gst_device_get_properties(device);
g_print("\n%s: %s\n", device_name, gst_structure_to_string(stru) );
GstStructure *stru = gst_device_get_properties(device);
g_print("\n%s: %s\n", device_name, gst_structure_to_string(stru) );
#endif
handles_.push_back(dev);
Log::Info("Device '%s' is plugged-in.", device_name);
handles_.push_back(dev);
Log::Info("Device '%s' is plugged-in.", device_name);
}
}

}
// unlock access
access_.unlock();
Expand Down
26 changes: 19 additions & 7 deletions src/ImGuiVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,15 @@ void ImGuiVisitor::visit (Source& s)
if (s.ready()) {
ImGui::SetCursorPos( ImVec2(pos.x + 0.5f * (preview_width-width), pos.y + 0.5f * (preview_height-height-space)) );
ImGui::Image((void*)(uintptr_t) s.frame()->texture(), ImVec2(width, height));
} else {
ImGuiToolkit::PushFont(ImGuiToolkit::FONT_LARGE);
ImGui::SetCursorPos(
ImVec2(pos.x + (preview_width - ImGui::GetFrameHeight()) * 0.5f,
pos.y + (preview_height - ImGui::GetFrameHeight()) * 0.5f));
ImGui::Text(ICON_FA_HOURGLASS_HALF);
ImGui::PopFont();
}

// inform on visibility status
ImGui::SetCursorPos( ImVec2(preview_width + 20, pos.y ) );
if (s.active()) {
Expand Down Expand Up @@ -637,9 +645,9 @@ void ImGuiVisitor::visit (Source& s)
ImGui::Image((void*)(uintptr_t) s.frame()->texture(), ImVec2(width, height));

// centered icon of failed (skull)
ImGui::SetCursorPos( ImVec2(pos.x + (width -ImGui::GetFrameHeightWithSpacing())* 0.5f ,
pos.y + (height -ImGui::GetFrameHeightWithSpacing()) * 0.5f) );
ImGuiToolkit::PushFont(ImGuiToolkit::FONT_LARGE);
ImGui::SetCursorPos( ImVec2(pos.x + (preview_width -ImGui::GetFrameHeight())* 0.5f ,
pos.y + (preview_height -ImGui::GetFrameHeight()) * 0.5f) );
ImGui::Text(ICON_FA_SKULL);
ImGui::PopFont();

Expand Down Expand Up @@ -753,10 +761,12 @@ void ImGuiVisitor::visit (MediaSource& s)
ImGui::SetCursorPos(botom);

// because sometimes the error comes from gpu decoding
if ( Settings::application.render.gpu_decoding && SystemToolkit::file_exists(s.path()) )
if ( Settings::application.render.gpu_decoding &&
SystemToolkit::file_exists(s.path()) &&
!s.mediaplayer()->softwareDecodingForced() )
{
// offer to reload the source without hardware decoding
if ( ImGui::Button( ICON_FA_REDO_ALT " Try again without\nhardware decoding", ImVec2(IMGUI_RIGHT_ALIGN, 0)) ) {
if ( ImGui::Button( ICON_FA_REDO_ALT " Try again ", ImVec2(IMGUI_RIGHT_ALIGN, 0)) ) {
// replace current source with one created with a flag forcing software decoding
Mixer::manager().replaceSource(Mixer::manager().currentSource(),
Mixer::manager().createSourceFile(s.path(), true));
Expand Down Expand Up @@ -1420,8 +1430,10 @@ void ImGuiVisitor::visit (PatternSource& s)
{
for (uint p = 0; p < Pattern::count(); ++p){
pattern_descriptor pattern = Pattern::get(p);
std::string label = pattern.label + (pattern.animated ? " " ICON_FA_PLAY_CIRCLE : " ");
if (pattern.available && ImGui::Selectable( label.c_str(), p == s.pattern()->type() )) {
std::string label = pattern.label;
if (pattern.available &&
pattern.animated == s.playable() &&
ImGui::Selectable( label.c_str(), p == s.pattern()->type() )) {
s.setPattern(p, s.pattern()->resolution());
info.reset();
std::ostringstream oss;
Expand All @@ -1448,7 +1460,7 @@ void ImGuiVisitor::visit (PatternSource& s)
top.x += ImGui::GetFrameHeight();
}
ImGui::SetCursorPos(top);
if (ImGuiToolkit::IconButton(ICON_FA_COPY, "Copy"))
if (ImGuiToolkit::IconButton(ICON_FA_COPY, "Copy gstreamer code"))
ImGui::SetClipboardText(Pattern::get( s.pattern()->type() ).pipeline.c_str());
}
else
Expand Down
4 changes: 2 additions & 2 deletions src/ImageFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ const char* BlurFilter::method_label[BlurFilter::BLUR_INVALID] = {
};

std::vector< FilteringProgram > BlurFilter::programs_ = {
FilteringProgram("Gaussian", "shaders/filters/blur_1.glsl", "shaders/filters/blur_2.glsl", { { "Radius", 0.5} }),
FilteringProgram("Gaussian", "shaders/filters/blur_1.glsl", "shaders/filters/blur_2.glsl", { { "Radius", 0.55} }),
FilteringProgram("Scattered","shaders/filters/hashedblur.glsl", "", { { "Radius", 0.5}, { "Iterations", 0.25 } }),
FilteringProgram("Opening", "shaders/filters/hashederosion.glsl", "shaders/filters/hasheddilation.glsl", { { "Radius", 0.5} }),
FilteringProgram("Closing", "shaders/filters/hasheddilation.glsl","shaders/filters/hashederosion.glsl", { { "Radius", 0.5} }),
Expand Down Expand Up @@ -800,7 +800,7 @@ const char* SharpenFilter::method_label[SharpenFilter::SHARPEN_INVALID] = {
};

std::vector< FilteringProgram > SharpenFilter::programs_ = {
FilteringProgram("UnsharpMask", "shaders/filters/sharpen_1.glsl", "shaders/filters/sharpen_2.glsl", { { "Amount", 0.5} }),
FilteringProgram("UnsharpMask", "shaders/filters/sharpen_1.glsl", "shaders/filters/sharpen_2.glsl", { { "Amount", 0.25} }),
FilteringProgram("Sharpen", "shaders/filters/sharpen.glsl", "", { { "Amount", 0.5} }),
FilteringProgram("Sharp Edge", "shaders/filters/sharpenedge.glsl","", { { "Amount", 0.25} }),
FilteringProgram("TopHat", "shaders/filters/erosion.glsl", "shaders/filters/tophat.glsl", { { "Radius", 0.5} }),
Expand Down
2 changes: 1 addition & 1 deletion src/MediaPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,7 @@ void MediaPlayer::execute_seek_command(GstClockTime target, bool force)
if (seek_event && gst_element_send_event(pipeline_, seek_event) ) {
seeking_ = true;
#ifdef MEDIA_PLAYER_DEBUG
g_printerr("MediaPlayer %s Seek %ld %.1f", std::to_string(id_).c_str(), seek_pos, rate_);
g_printerr("MediaPlayer %s Seek %ld %.1f\n", std::to_string(id_).c_str(), seek_pos, rate_);
#endif
}
else
Expand Down
8 changes: 6 additions & 2 deletions src/RenderingManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,17 +735,21 @@ class WindowSurface : public MeshSurface
}
};

// pattern source can be shared because all windows render the same framebuffer resolution
class Stream *RenderingWindow::pattern_ = new Stream;

RenderingWindow::RenderingWindow() : window_(NULL), master_(NULL),
index_(-1), dpi_scale_(1.f), textureid_(0), fbo_(0), surface_(nullptr), request_change_fullscreen_(false)
{
pattern_ = new Stream;

}

RenderingWindow::~RenderingWindow()
{
if (window_ != NULL)
terminate();
delete pattern_;
// delete pattern_;
RenderingWindow::pattern_->close();
}

void RenderingWindow::setTitle(const std::string &title)
Expand Down
2 changes: 1 addition & 1 deletion src/RenderingManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class RenderingWindow
// objects to render
uint textureid_;
uint fbo_;
Stream *pattern_;
static Stream *pattern_;
class WindowSurface *surface_;
class ImageFilteringShader *shader_;

Expand Down
23 changes: 3 additions & 20 deletions src/ScreenCaptureSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,9 @@
**/

#include <algorithm>
#include <thread>
#include <chrono>
#include <sstream>
#include <glm/gtc/matrix_transform.hpp>

#include <gst/pbutils/gstdiscoverer.h>
#include <gst/pbutils/pbutils.h>
#include <gst/gst.h>
#include <thread>

#include "Log.h"
#include "Decorations.h"
Expand All @@ -47,7 +42,7 @@ std::string gst_plugin_vidcap = "ximagesrc show-pointer=false";

#include <xcb/xcb.h>
#include <X11/Xlib.h>
#include <X11/Xproto.h>
#include <xcb/xproto.h>
int X11_error_handler(Display *d, XErrorEvent *e);
std::map<unsigned long, std::string> getListX11Windows();

Expand Down Expand Up @@ -87,18 +82,6 @@ struct hasAssociatedSource

void ScreenCaptureHandle::update(const std::string &newname)
{
GstToolkit::PipelineConfigSet confs = GstToolkit::getPipelineConfigs(pipeline);

if (!confs.empty()) {
GstToolkit::PipelineConfig best = *confs.rbegin();
GstToolkit::PipelineConfigSet confscreen;
// limit framerate to 30fps
best.fps_numerator = MIN( best.fps_numerator, 30);
best.fps_denominator = 1;
confscreen.insert(best);

configs = confscreen;
}
name = newname;
}

Expand Down Expand Up @@ -159,7 +142,7 @@ void ScreenCapture::remove(const std::string &windowname, unsigned long id)

// just inform if there is no source connected
if (handle->associated_sources.empty()) {
Log::Info("Window %s closed.", windowname.c_str());
Log::Info("Window %s available.", windowname.c_str());
}
else {
// otherwise unplug all sources and close their streams
Expand Down
2 changes: 0 additions & 2 deletions src/ScreenCaptureSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

#include <string>
#include <vector>
#include <set>
#include <map>

#include "GstToolkit.h"
#include "StreamSource.h"
Expand Down
41 changes: 33 additions & 8 deletions src/SourceCallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "MediaPlayer.h"
#include "Visitor.h"
#include "Log.h"
#include "Mixer.h"

#include "SourceCallback.h"

Expand Down Expand Up @@ -216,7 +217,10 @@ void ResetGeometry::update(Source *s, float dt)
{
SourceCallback::update(s, dt);

if (s->locked())
if (s->locked() ||
(s->mode() == Source::CURRENT
&& Mixer::manager().view()->mode() == View::GEOMETRY
&& Mixer::manager().view()->initiated()) )
status_ = FINISHED;

// apply when ready
Expand Down Expand Up @@ -250,7 +254,10 @@ void SetAlpha::update(Source *s, float dt)
{
SourceCallback::update(s, dt);

if (s->locked())
if (s->locked() ||
(s->mode() == Source::CURRENT
&& Mixer::manager().view()->mode() == View::MIXING
&& Mixer::manager().view()->initiated()) )
status_ = FINISHED;

// set start position on first time it is ready
Expand Down Expand Up @@ -367,7 +374,10 @@ void Loom::update(Source *s, float dt)
{
SourceCallback::update(s, dt);

if (s->locked())
if (s->locked() ||
(s->mode() == Source::CURRENT
&& Mixer::manager().view()->mode() == View::MIXING
&& Mixer::manager().view()->initiated()) )
status_ = FINISHED;

// current position
Expand Down Expand Up @@ -429,7 +439,10 @@ void SetDepth::update(Source *s, float dt)
{
SourceCallback::update(s, dt);

if (s->locked())
if (s->locked() ||
(s->mode() == Source::CURRENT
&& Mixer::manager().view()->mode() == View::LAYER
&& Mixer::manager().view()->initiated()) )
status_ = FINISHED;

// set start position on first time it is ready
Expand Down Expand Up @@ -724,7 +737,10 @@ void SetGeometry::update(Source *s, float dt)
{
SourceCallback::update(s, dt);

if (s->locked())
if (s->locked() ||
(s->mode() == Source::CURRENT
&& Mixer::manager().view()->mode() == View::GEOMETRY
&& Mixer::manager().view()->initiated()) )
status_ = FINISHED;

// set start position on first time it is ready
Expand Down Expand Up @@ -791,7 +807,10 @@ void Grab::update(Source *s, float dt)
{
SourceCallback::update(s, dt);

if (s->locked())
if (s->locked() ||
(s->mode() == Source::CURRENT
&& Mixer::manager().view()->mode() == View::GEOMETRY
&& Mixer::manager().view()->initiated()) )
status_ = FINISHED;

// set start on first time it is ready
Expand Down Expand Up @@ -839,7 +858,10 @@ void Resize::update(Source *s, float dt)
{
SourceCallback::update(s, dt);

if (s->locked())
if (s->locked() ||
(s->mode() == Source::CURRENT
&& Mixer::manager().view()->mode() == View::GEOMETRY
&& Mixer::manager().view()->initiated()) )
status_ = FINISHED;

if ( status_ == READY )
Expand Down Expand Up @@ -881,7 +903,10 @@ void Turn::update(Source *s, float dt)
{
SourceCallback::update(s, dt);

if (s->locked())
if (s->locked() ||
(s->mode() == Source::CURRENT
&& Mixer::manager().view()->mode() == View::GEOMETRY
&& Mixer::manager().view()->initiated()) )
status_ = FINISHED;

// set start on first time it is ready
Expand Down
7 changes: 2 additions & 5 deletions src/Stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,18 @@ GstFlowReturn callback_stream_discoverer (GstAppSink *sink, gpointer p)
StreamInfo *info = static_cast<StreamInfo *>(p);
// get caps of the sample
GstVideoInfo v_frame_video_info_;
GstCaps *caps = gst_sample_get_caps(sample);
if (gst_video_info_from_caps (&v_frame_video_info_, caps)) {
if (gst_video_info_from_caps (&v_frame_video_info_, gst_sample_get_caps(sample))) {
// fill the info
info->width = v_frame_video_info_.width;
info->height = v_frame_video_info_.height;
// release info to let StreamDiscoverer go forward
info->discovered.notify_all();
}
gst_caps_unref(caps);
gst_sample_unref (sample);
}
else
ret = GST_FLOW_FLUSHING;

gst_sample_unref (sample);

return ret;
}

Expand Down
4 changes: 2 additions & 2 deletions src/TextSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ glm::ivec2 TextSource::icon() const
std::string TextSource::info() const
{
if ( contents()->isSubtitle() )
return "Subtitle text";
return "Subtitle file";
else
return "Free text";
return "Text";
}
Loading

0 comments on commit b90b246

Please sign in to comment.