mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
To confirm: working implementation of SHM and UDP streaming connection
This commit is contained in:
@@ -104,7 +104,7 @@ void NetworkStream::open(const std::string &nameconnection)
|
||||
}
|
||||
}
|
||||
if (receiver_ == nullptr) {
|
||||
Log::Notify("Cannot open %s.", nameconnection);
|
||||
Log::Notify("Cannot open %s. Please try again.", nameconnection);
|
||||
failed_ = true;
|
||||
return;
|
||||
}
|
||||
@@ -176,15 +176,19 @@ void NetworkStream::update()
|
||||
#endif
|
||||
// build the pipeline depending on stream info
|
||||
std::ostringstream pipeline;
|
||||
if (config_.protocol == NetworkToolkit::TCP_JPEG || config_.protocol == NetworkToolkit::TCP_H264) {
|
||||
if (config_.protocol == NetworkToolkit::UDP_JPEG || config_.protocol == NetworkToolkit::UDP_H264) {
|
||||
|
||||
pipeline << "tcpclientsrc name=src timeout=1 port=" << config_.port;
|
||||
pipeline << "udpsrc port=" << config_.port;
|
||||
}
|
||||
else if (config_.protocol == NetworkToolkit::TCP_JPEG || config_.protocol == NetworkToolkit::TCP_H264) {
|
||||
|
||||
pipeline << "tcpclientsrc timeout=1 port=" << config_.port;
|
||||
}
|
||||
else if (config_.protocol == NetworkToolkit::SHM_RAW) {
|
||||
|
||||
std::string path = SystemToolkit::full_filename(SystemToolkit::settings_path(), "shm");
|
||||
path += std::to_string(config_.port);
|
||||
pipeline << "shmsrc name=src is-live=true socket-path=" << path;
|
||||
pipeline << "shmsrc is-live=true socket-path=" << path;
|
||||
// TODO rename SHM socket "shm_PORT"
|
||||
}
|
||||
|
||||
|
||||
@@ -22,17 +22,21 @@ const char* NetworkToolkit::protocol_name[NetworkToolkit::DEFAULT] = {
|
||||
|
||||
const std::vector<std::string> NetworkToolkit::protocol_send_pipeline {
|
||||
|
||||
"video/x-raw, format=I420, framerate=30/1 ! queue max-size-buffers=3 ! jpegenc ! rtpjpegpay ! udpsink name=sink",
|
||||
"video/x-raw, format=I420, framerate=30/1 ! queue max-size-buffers=3 ! x264enc tune=\"zerolatency\" threads=2 ! rtph264pay ! udpsink name=sink",
|
||||
"video/x-raw, format=RGB, framerate=30/1 ! queue max-size-buffers=3 ! shmsink buffer-time=100000 name=sink",
|
||||
"video/x-raw, format=I420 ! queue max-size-buffers=3 ! jpegenc ! rtpjpegpay ! rtpstreampay ! tcpserversink name=sink",
|
||||
"video/x-raw, format=I420 ! queue max-size-buffers=3 ! x264enc tune=\"zerolatency\" threads=2 ! rtph264pay ! rtpstreampay ! tcpserversink name=sink",
|
||||
"video/x-raw, format=RGB, framerate=30/1 ! queue max-size-buffers=3 ! shmsink buffer-time=100000 name=sink"
|
||||
};
|
||||
|
||||
|
||||
const std::vector<std::string> NetworkToolkit::protocol_receive_pipeline {
|
||||
|
||||
" ! application/x-rtp,encoding-name=JPEG,payload=26 ! rtpjpegdepay ! jpegdec",
|
||||
" ! application/x-rtp,media=video,encoding-name=H264,payload=96,clock-rate=90000 ! rtph264depay ! avdec_h264",
|
||||
" ! video/x-raw, format=RGB, framerate=30/1",
|
||||
" ! application/x-rtp-stream,media=video,encoding-name=JPEG,payload=26 ! rtpstreamdepay ! rtpjpegdepay ! jpegdec",
|
||||
" ! application/x-rtp-stream,media=video,encoding-name=H264,payload=96,clock-rate=90000 ! rtpstreamdepay ! rtph264depay ! avdec_h264",
|
||||
" ! video/x-raw, format=RGB, framerate=30/1"
|
||||
};
|
||||
|
||||
|
||||
@@ -52,7 +56,7 @@ const std::vector<std::string> NetworkToolkit::protocol_receive_pipeline {
|
||||
*
|
||||
* UDP unicast
|
||||
* SND
|
||||
* gst-launch-1.0 videotestsrc is-live=true ! jpegenc ! rtpjpegpay ! udpsink port=5000 host=127.0.0.1 sync=false
|
||||
* gst-launch-1.0 videotestsrc is-live=true ! videoconvert ! video/x-raw, format=RGB, framerate=30/1 ! queue max-size-buffers=3 ! jpegenc ! rtpjpegpay ! udpsink port=5000 host=127.0.0.1
|
||||
* RCV
|
||||
* gst-launch-1.0 udpsrc port=5000 ! application/x-rtp,encoding-name=JPEG,payload=26 ! rtpjpegdepay ! jpegdec ! autovideosink
|
||||
*
|
||||
|
||||
@@ -22,9 +22,11 @@ namespace NetworkToolkit
|
||||
{
|
||||
|
||||
typedef enum {
|
||||
TCP_JPEG = 0,
|
||||
TCP_H264,
|
||||
UDP_JPEG = 0,
|
||||
UDP_H264,
|
||||
SHM_RAW,
|
||||
TCP_JPEG,
|
||||
TCP_H264,
|
||||
DEFAULT
|
||||
} Protocol;
|
||||
|
||||
|
||||
10
Streamer.cpp
10
Streamer.cpp
@@ -181,8 +181,9 @@ void Streaming::addStream(const std::string &sender, int reply_to)
|
||||
}
|
||||
// any other IP : offer UDP streaming
|
||||
else {
|
||||
conf.protocol = NetworkToolkit::TCP_JPEG;
|
||||
conf.protocol = NetworkToolkit::UDP_JPEG;
|
||||
}
|
||||
// conf.protocol = NetworkToolkit::UDP_JPEG;
|
||||
|
||||
// build OSC message
|
||||
char buffer[IP_MTU_SIZE];
|
||||
@@ -272,7 +273,7 @@ void VideoStreamer::addFrame (FrameBuffer *frame_buffer, float dt)
|
||||
std::string description = "appsrc name=src ! videoconvert ! ";
|
||||
|
||||
if (config_.protocol < 0 || config_.protocol >= NetworkToolkit::DEFAULT)
|
||||
config_.protocol = NetworkToolkit::TCP_JPEG;
|
||||
config_.protocol = NetworkToolkit::UDP_JPEG;
|
||||
description += NetworkToolkit::protocol_send_pipeline[config_.protocol];
|
||||
|
||||
// parse pipeline descriptor
|
||||
@@ -286,7 +287,7 @@ void VideoStreamer::addFrame (FrameBuffer *frame_buffer, float dt)
|
||||
}
|
||||
|
||||
// setup streaming sink
|
||||
if (config_.protocol == NetworkToolkit::TCP_JPEG || config_.protocol == NetworkToolkit::TCP_H264) {
|
||||
if (config_.protocol == NetworkToolkit::UDP_JPEG || config_.protocol == NetworkToolkit::UDP_H264) {
|
||||
g_object_set (G_OBJECT (gst_bin_get_by_name (GST_BIN (pipeline_), "sink")),
|
||||
"host", config_.client_address.c_str(),
|
||||
"port", config_.port, NULL);
|
||||
@@ -345,7 +346,8 @@ void VideoStreamer::addFrame (FrameBuffer *frame_buffer, float dt)
|
||||
}
|
||||
|
||||
// all good
|
||||
Log::Info("VideoStreamer start (%s %d x %d)", config_.client_address.c_str(), width_, height_);
|
||||
Log::Info("Streaming video to %s:%d (%d x %d)",
|
||||
config_.client_address.c_str(), config_.port, width_, height_);
|
||||
|
||||
// start streaming !!
|
||||
streaming_ = true;
|
||||
|
||||
Reference in New Issue
Block a user