mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-12 02:40:00 +01:00
Added Stream Discoverer to detect frame size from a gstreamer pipeline
Previous use of Stream are not affected (the discoverer is passively returning the given width and height). But if the Stream is created without dimensions, it will run a discoverer to try to get preroll frames and detect width and height from there.
This commit is contained in:
21
Stream.h
21
Stream.h
@@ -5,6 +5,7 @@
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <future>
|
||||
#include <condition_variable>
|
||||
|
||||
// GStreamer
|
||||
#include <gst/pbutils/pbutils.h>
|
||||
@@ -15,6 +16,23 @@ class Visitor;
|
||||
|
||||
#define N_FRAME 3
|
||||
|
||||
struct StreamInfo {
|
||||
|
||||
guint width;
|
||||
guint height;
|
||||
std::condition_variable discovered;
|
||||
|
||||
StreamInfo() {
|
||||
width = 640;
|
||||
height = 480;
|
||||
}
|
||||
|
||||
StreamInfo(const StreamInfo& b) {
|
||||
width = b.width;
|
||||
height = b.height;
|
||||
}
|
||||
};
|
||||
|
||||
class Stream {
|
||||
|
||||
public:
|
||||
@@ -33,7 +51,7 @@ public:
|
||||
/**
|
||||
* Open a media using gstreamer pipeline keyword
|
||||
* */
|
||||
void open(const std::string &gstreamer_description, guint w = 1024, guint h = 576);
|
||||
void open(const std::string &gstreamer_description, guint w = 0, guint h = 0);
|
||||
/**
|
||||
* Get description string
|
||||
* */
|
||||
@@ -132,6 +150,7 @@ protected:
|
||||
guint height_;
|
||||
bool single_frame_;
|
||||
bool live_;
|
||||
std::future<StreamInfo> discoverer_;
|
||||
|
||||
// GST & Play status
|
||||
GstClockTime position_;
|
||||
|
||||
Reference in New Issue
Block a user