Skip to content

Commit 583fb0d

Browse files
committed
main: vrxtx opt setting simplified
handle the proto-specific tweaks in the vrxtx module itself (iHDTV, RTSP, SDP) iHDTV, while not supposed to work, anyways, had the display device set always since some time, which would disallow running as a sender (because from the display pointer it assumed that it is the receiver).
1 parent 66f9767 commit 583fb0d

File tree

5 files changed

+33
-36
lines changed

5 files changed

+33
-36
lines changed

src/main.cpp

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,34 +1476,14 @@ int main(int argc, char *argv[])
14761476
#endif /* USE_RT */
14771477

14781478
try {
1479-
// iHDTV
1480-
opt.video.capture_device = (opt.video.rxtx_mode & MODE_SENDER) != 0U ? uv.capture_device : nullptr;
1481-
// was but overriden later to uv.display_device unconditionaly:
1482-
// param.display_device = (opt.video_rxtx_mode & MODE_RECEIVER) != 0U ? uv.display_device : nullptr;
1483-
1484-
//RTP
1485-
opt.video.start_time = start_time;
1486-
1487-
// UltraGrid RTP
1488-
opt.video.display_device = uv.display_device;
1489-
1490-
if (strcmp(opt.video_protocol, "rtsp") == 0) {
1491-
rtsp_types_t avType = rtsp_type_none;
1492-
if ((strcmp("none", opt.audio.send_cfg) != 0)) {
1493-
avType = (rtsp_types_t) (avType | rtsp_type_audio); // AStream
1494-
}
1495-
if (strcmp("none", vidcap_params_get_driver(
1496-
opt.vidcap_params_head)) != 0) {
1497-
avType = (rtsp_types_t) (avType | rtsp_type_video); // VStream
1498-
}
1499-
if (avType == rtsp_type_none) {
1500-
printf("[RTSP SERVER CHECK] no stream type... check capture devices input...\n");
1501-
}
1502-
1503-
opt.video.av_type = avType;
1504-
}
1505-
1506-
sdp_set_properties(opt.video.receiver, opt.video.rxtx_mode & MODE_SENDER && strcasecmp(opt.video_protocol, "sdp") == 0, opt.audio.send_port != 0 && strcasecmp(opt.audio.proto, "sdp") == 0);
1479+
opt.video.capture_device = uv.capture_device; // iHDTV
1480+
opt.video.start_time = start_time; // RTP protocols
1481+
opt.video.display_device = uv.display_device; // UltraGrid RTP, iHDTV
1482+
// RTSP + SDP
1483+
opt.video.send_audio = strcmp("none", opt.audio.send_cfg) != 0;
1484+
opt.video.send_video =
1485+
strcmp("none", vidcap_params_get_driver(
1486+
opt.vidcap_params_head)) != 0;
15071487

15081488
uv.state_video_rxtx = video_rxtx::create(opt.video_protocol, &opt.video, &opt.common);
15091489
if (!uv.state_video_rxtx) {

src/video_rxtx.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct video_frame;
6060

6161
struct vrxtx_params {
6262
const char *compression; ///< nullptr selects proto dfl
63-
enum rxtx_mode rxtx_mode;
63+
enum rxtx_mode rxtx_mode; ///< sender, receiver or both
6464
struct display *display_device; ///< only iHDTV, UG RTP
6565
struct vidcap *capture_device; ///< iHDTV only
6666
const char *receiver;
@@ -71,7 +71,8 @@ struct vrxtx_params {
7171
enum video_mode decoder_mode;
7272
const char *protocol_opts;
7373
long long start_time;
74-
long av_type; ///< RTSP only
74+
bool send_audio; ///< RTSP+SDP
75+
bool send_video; ///< RTSP+SDP
7576
struct module *sender_mod; ///< set by video_rxtx::create
7677
struct module *receiver_mod; ///< set by video_rxtx::create
7778
};
@@ -90,7 +91,8 @@ struct vrxtx_params {
9091
.decoder_mode = VIDEO_NORMAL, \
9192
.protocol_opts = "", \
9293
.start_time = 0, \
93-
.av_type = 0, \
94+
.send_audio = false, \
95+
.send_video = false, \
9496
.sender_mod = nullptr, \
9597
.receiver_mod = nullptr, \
9698
}

src/video_rxtx/h264_rtp.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,16 @@ h264_rtp_video_rxtx::h264_rtp_video_rxtx(const struct vrxtx_params *params,
7575
{
7676
rtsp_params.rtsp_port = (unsigned) rtsp_port;
7777
rtsp_params.parent = common->parent;
78-
rtsp_params.avType = (rtsp_types_t) params->av_type;
78+
79+
auto avType = (rtsp_types_t) (params->send_audio ? rtsp_type_audio : 0);
80+
avType = (rtsp_types_t) (avType |
81+
(params->send_video ? rtsp_type_video : 0));
82+
if (avType == rtsp_type_none) {
83+
printf("[RTSP SERVER CHECK] no stream type... check capture devices input...\n");
84+
throw 1;
85+
}
86+
rtsp_params.avType = avType;;
87+
7988
rtsp_params.rtp_port_video = params->rx_port; //server rtp port
8089
}
8190

src/video_rxtx/h264_sdp.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ h264_sdp_video_rxtx::h264_sdp_video_rxtx(const struct vrxtx_params *params,
7979
LOG(LOG_LEVEL_WARNING) << "Warning: SDP support is experimental only. Things may be broken - feel free to report them but the support may be limited.\n";
8080
m_saved_addr = m_requested_receiver;
8181
m_saved_tx_port = params->tx_port;
82+
83+
sdp_set_properties(params->receiver, params->send_video, params->send_audio);
84+
8285
if (int ret = sdp_set_options(opts)) {
8386
throw ret == 1 ? 0 : 1;
8487
}

src/video_rxtx/ihdtv.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
*
5252
*/
5353

54+
#include <cassert> // for assert
5455
#include <cstdio> // for NULL, printf
5556
#include <memory> // for shared_ptr
5657
#include <string> // for basic_string, string
@@ -151,14 +152,15 @@ ihdtv_video_rxtx::ihdtv_video_rxtx(const struct vrxtx_params *params,
151152
printf("Initializing ihdtv protocol\n");
152153

153154
// we cannot act as both together, because parameter parsing would have to be revamped
154-
if (params->capture_device && params->display_device) {
155+
if ((params->rxtx_mode == (MODE_SENDER | MODE_RECEIVER))) {
155156
throw string
156157
("Error: cannot act as both sender and receiver together in ihdtv mode");
157158
}
158159

159-
m_display_device = static_cast<struct display *>(params->display_device);
160+
m_display_device = params->display_device;
160161

161-
if (m_display_device) {
162+
if ((params->rxtx_mode & MODE_RECEIVER) != 0U) {
163+
assert(params->display_device != nullptr);
162164
if (ihdtv_init_rx_session
163165
(&m_rx_connection, (argc == 0) ? NULL : argv[0],
164166
(argc ==
@@ -168,7 +170,8 @@ ihdtv_video_rxtx::ihdtv_video_rxtx(const struct vrxtx_params *params,
168170
}
169171
}
170172

171-
if (params->capture_device != nullptr) {
173+
if ((params->rxtx_mode & MODE_SENDER) != 0U) {
174+
assert(params->capture_device != nullptr);
172175
if (argc == 0) {
173176
throw string("Error: specify the destination address");
174177
}

0 commit comments

Comments
 (0)