mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-21 19:40:24 +00:00
Migrated SAGE RX/TX to new API
This commit is contained in:
@@ -148,6 +148,7 @@ ULTRAGRID_OBJS = src/main.o \
|
||||
src/video_rxtx.o \
|
||||
src/video_rxtx/ihdtv.o \
|
||||
src/video_rxtx/rtp.o \
|
||||
src/video_rxtx/sage.o \
|
||||
src/video_rxtx/ultragrid_rtp.o \
|
||||
|
||||
REFLECTOR_OBJS = src/hd-rum-translator/hd-rum-decompress.o \
|
||||
|
||||
@@ -78,8 +78,8 @@ int initialize_video_capture(struct module *parent,
|
||||
}
|
||||
|
||||
int initialize_video_display(const char *requested_display,
|
||||
char *fmt, unsigned int flags,
|
||||
struct display **out)
|
||||
const char *fmt, unsigned int flags,
|
||||
struct display **out)
|
||||
{
|
||||
display_type_t *dt;
|
||||
display_id_t id = 0;
|
||||
|
||||
@@ -108,7 +108,7 @@ struct vidcap;
|
||||
struct display;
|
||||
struct module;
|
||||
int initialize_video_display(const char *requested_display,
|
||||
char *fmt, unsigned int flags,
|
||||
const char *fmt, unsigned int flags,
|
||||
struct display **);
|
||||
|
||||
int initialize_video_capture(struct module *parent,
|
||||
|
||||
19
src/main.cpp
19
src/main.cpp
@@ -80,8 +80,9 @@
|
||||
#include "video_display.h"
|
||||
#include "video_compress.h"
|
||||
#include "video_export.h"
|
||||
#include "video_rxtx/ultragrid_rtp.h"
|
||||
#include "video_rxtx/ihdtv.h"
|
||||
#include "video_rxtx/sage.h"
|
||||
#include "video_rxtx/ultragrid_rtp.h"
|
||||
#include "audio/audio.h"
|
||||
#include "audio/audio_capture.h"
|
||||
#include "audio/codec.h"
|
||||
@@ -1000,19 +1001,9 @@ int main(int argc, char *argv[])
|
||||
requested_mcast_if, requested_video_fec, requested_mtu,
|
||||
packet_rate, decoder_mode, postprocess, uv->display_device);
|
||||
} else { // SAGE
|
||||
#if 0
|
||||
memset(&sage_rxtx, 0, sizeof(sage_rxtx));
|
||||
sage_receiver = uv->requested_receiver;
|
||||
ret = initialize_video_display("sage",
|
||||
sage_opts, 0, &sage_rxtx.sage_tx_device);
|
||||
if(ret != 0) {
|
||||
fprintf(stderr, "Unable to initialize SAGE TX.\n");
|
||||
exit_uv(EXIT_FAIL_NETWORK);
|
||||
goto cleanup;
|
||||
}
|
||||
pthread_create(&sage_rxtx.thread_id, NULL, (void * (*)(void *)) display_run,
|
||||
&sage_rxtx.sage_tx_device);
|
||||
#endif
|
||||
uv->video_rxtx = new sage_video_rxtx(&root_mod, video_exporter,
|
||||
requested_compression, requested_receiver, sage_opts);
|
||||
|
||||
}
|
||||
|
||||
if(rxtx_mode & MODE_RECEIVER) {
|
||||
|
||||
@@ -68,23 +68,14 @@
|
||||
#include "video_rxtx.h"
|
||||
#include "video_rxtx/ihdtv.h"
|
||||
#include "video_rxtx/rtp.h"
|
||||
#include "video_rxtx/sage.h"
|
||||
#include "video_rxtx/ultragrid_rtp.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
static void sage_rxtx_send(void *state, struct video_frame *tx_frame);
|
||||
static void sage_rxtx_done(void *state);
|
||||
static void h264_rtp_send(void *state, struct video_frame *tx_frame);
|
||||
static void h264_rtp_done(void *state);
|
||||
|
||||
struct rx_tx sage_rxtx = {
|
||||
SAGE,
|
||||
"SAGE",
|
||||
sage_rxtx_send,
|
||||
sage_rxtx_done,
|
||||
NULL
|
||||
};
|
||||
|
||||
struct rx_tx h264_rtp = {
|
||||
H264_STD,
|
||||
"H264 standard",
|
||||
@@ -139,41 +130,13 @@ const char *video_rxtx::get_name(enum rxtx_protocol proto) {
|
||||
return "UltraGrid RTP";
|
||||
case IHDTV:
|
||||
return "iHDTV";
|
||||
case SAGE:
|
||||
return "SAGE";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void sage_rxtx_send(void *state, struct video_frame *tx_frame)
|
||||
{
|
||||
struct sage_rxtx_state *data = (struct sage_rxtx_state *) state;
|
||||
|
||||
if(!video_desc_eq(data->saved_vid_desc,
|
||||
video_desc_from_frame(tx_frame))) {
|
||||
display_reconfigure(data->sage_tx_device,
|
||||
video_desc_from_frame(tx_frame));
|
||||
data->saved_vid_desc = video_desc_from_frame(tx_frame);
|
||||
}
|
||||
struct video_frame *frame =
|
||||
display_get_frame(data->sage_tx_device);
|
||||
memcpy(frame->tiles[0].data, tx_frame->tiles[0].data,
|
||||
tx_frame->tiles[0].data_len);
|
||||
display_put_frame(data->sage_tx_device, frame, PUTF_NONBLOCK);
|
||||
|
||||
VIDEO_FRAME_DISPOSE(tx_frame);
|
||||
}
|
||||
|
||||
static void sage_rxtx_done(void *state)
|
||||
{
|
||||
struct sage_rxtx_state *data = (struct sage_rxtx_state *) state;
|
||||
|
||||
// poisoned pill to exit thread
|
||||
display_put_frame(data->sage_tx_device, NULL, PUTF_NONBLOCK);
|
||||
pthread_join(data->thread_id, NULL);
|
||||
|
||||
display_done(data->sage_tx_device);
|
||||
}
|
||||
|
||||
static void h264_rtp_send(void *state, struct video_frame *tx_frame)
|
||||
{
|
||||
struct h264_rtp_state *data = (struct h264_rtp_state *) state;
|
||||
|
||||
@@ -61,16 +61,8 @@ struct rx_tx {
|
||||
void *(*receiver_thread)(void *);
|
||||
};
|
||||
|
||||
extern struct rx_tx ultragrid_rtp;
|
||||
extern struct rx_tx sage_rxtx;
|
||||
extern struct rx_tx h264_rtp;
|
||||
|
||||
struct sage_rxtx_state {
|
||||
struct video_desc saved_vid_desc;
|
||||
struct display *sage_tx_device;
|
||||
pthread_t thread_id;
|
||||
};
|
||||
|
||||
struct h264_rtp_state {
|
||||
int connections_count;
|
||||
struct rtp **network_devices;
|
||||
|
||||
96
src/video_rxtx/sage.cpp
Normal file
96
src/video_rxtx/sage.cpp
Normal file
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* @file video_rxtx/sage.cpp
|
||||
* @author Martin Pulec <pulec@cesnet.cz>
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2013-2014 CESNET z.s.p.o.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, is permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of CESNET nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
|
||||
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#include "config_unix.h"
|
||||
#include "config_win32.h"
|
||||
#endif // HAVE_CONFIG_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "host.h"
|
||||
#include "video_display.h"
|
||||
#include "video_rxtx/sage.h"
|
||||
#include "video.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
sage_video_rxtx::sage_video_rxtx(struct module *parent, struct video_export *video_exporter,
|
||||
const char *requested_compression,
|
||||
const char *requested_receiver, const char *sage_opts) :
|
||||
video_rxtx(parent, video_exporter, requested_compression)
|
||||
{
|
||||
sage_receiver = requested_receiver;
|
||||
int ret = initialize_video_display("sage",
|
||||
sage_opts, 0, &m_sage_tx_device);
|
||||
if(ret != 0) {
|
||||
throw string("Unable to initialize SAGE TX.");
|
||||
}
|
||||
pthread_create(&m_thread_id, NULL, (void * (*)(void *)) display_run,
|
||||
&m_sage_tx_device);
|
||||
memset(&m_saved_video_desc, 0, sizeof(m_saved_video_desc));
|
||||
}
|
||||
|
||||
void sage_video_rxtx::send_frame(struct video_frame *tx_frame)
|
||||
{
|
||||
if(!video_desc_eq(m_saved_video_desc,
|
||||
video_desc_from_frame(tx_frame))) {
|
||||
display_reconfigure(m_sage_tx_device,
|
||||
video_desc_from_frame(tx_frame));
|
||||
m_saved_video_desc = video_desc_from_frame(tx_frame);
|
||||
}
|
||||
struct video_frame *frame =
|
||||
display_get_frame(m_sage_tx_device);
|
||||
memcpy(frame->tiles[0].data, tx_frame->tiles[0].data,
|
||||
tx_frame->tiles[0].data_len);
|
||||
display_put_frame(m_sage_tx_device, frame, PUTF_NONBLOCK);
|
||||
|
||||
VIDEO_FRAME_DISPOSE(tx_frame);
|
||||
}
|
||||
|
||||
sage_video_rxtx::~sage_video_rxtx()
|
||||
{
|
||||
// poisoned pill to exit thread
|
||||
display_put_frame(m_sage_tx_device, NULL, PUTF_NONBLOCK);
|
||||
pthread_join(m_thread_id, NULL);
|
||||
|
||||
display_done(m_sage_tx_device);
|
||||
}
|
||||
|
||||
|
||||
82
src/video_rxtx/sage.h
Normal file
82
src/video_rxtx/sage.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* FILE: video_rxtx/sage.h
|
||||
* AUTHORS: Colin Perkins <csp@csperkins.org>
|
||||
* Ladan Gharai <ladan@isi.edu>
|
||||
* Martin Benes <martinbenesh@gmail.com>
|
||||
* Lukas Hejtmanek <xhejtman@ics.muni.cz>
|
||||
* Petr Holub <hopet@ics.muni.cz>
|
||||
* Milos Liska <xliska@fi.muni.cz>
|
||||
* Jiri Matela <matela@ics.muni.cz>
|
||||
* Dalibor Matura <255899@mail.muni.cz>
|
||||
* Ian Wesley-Smith <iwsmith@cct.lsu.edu>
|
||||
* Martin Pulec <pulec@cesnet.cz>
|
||||
*
|
||||
* Copyright (c) 2005-2014 CESNET z.s.p.o.
|
||||
* Copyright (c) 2001-2004 University of Southern California
|
||||
* Copyright (c) 2003-2004 University of Glasgow
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, is permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
*
|
||||
* This product includes software developed by the University of Southern
|
||||
* California Information Sciences Institute. This product also includes
|
||||
* software developed by CESNET z.s.p.o.
|
||||
*
|
||||
* 4. Neither the name of the University nor of the Institute may be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
|
||||
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
#ifndef VIDEO_RXTX_SAGE_H_
|
||||
#define VIDEO_RXTX_SAGE_H_
|
||||
|
||||
#include "types.h"
|
||||
#include "video_capture.h"
|
||||
#include "video_display.h"
|
||||
#include "video_rxtx.h"
|
||||
|
||||
struct video_frame;
|
||||
struct display;
|
||||
|
||||
class sage_video_rxtx: public video_rxtx {
|
||||
public:
|
||||
sage_video_rxtx(struct module *parent, struct video_export *video_exporter,
|
||||
const char *requested_compression,
|
||||
const char *requested_receiver, const char *sage_opts);
|
||||
~sage_video_rxtx();
|
||||
private:
|
||||
void send_frame(struct video_frame *);
|
||||
void *(*get_receiver_thread())(void *arg) {
|
||||
return NULL;
|
||||
}
|
||||
struct video_desc m_saved_video_desc;
|
||||
struct display *m_sage_tx_device;
|
||||
pthread_t m_thread_id;
|
||||
};
|
||||
|
||||
#endif // VIDEO_RXTX_SAGE_H_
|
||||
|
||||
Reference in New Issue
Block a user