Compare commits

...

3 Commits
v6.2 ... v6.3

Author SHA1 Message Date
Maxim Devaev
05804e309f Bump version: 6.2 → 6.3 2024-03-14 16:36:20 +02:00
Maxim Devaev
1d8c93d3ad Issue #253: Added m2m encoder timeout 2024-03-14 16:06:32 +02:00
Maxim Devaev
f48695a04e refactoring 2024-03-13 13:09:27 +02:00
13 changed files with 59 additions and 52 deletions

View File

@@ -1,7 +1,7 @@
[bumpversion] [bumpversion]
commit = True commit = True
tag = True tag = True
current_version = 6.2 current_version = 6.3
parse = (?P<major>\d+)\.(?P<minor>\d+) parse = (?P<major>\d+)\.(?P<minor>\d+)
serialize = serialize =
{major}.{minor} {major}.{minor}

View File

@@ -42,12 +42,12 @@
#include "uslibs/list.h" #include "uslibs/list.h"
#include "uslibs/ring.h" #include "uslibs/ring.h"
#include "uslibs/memsinksh.h" #include "uslibs/memsinksh.h"
#include "uslibs/tc358743.h"
#include "const.h" #include "const.h"
#include "logging.h" #include "logging.h"
#include "client.h" #include "client.h"
#include "audio.h" #include "audio.h"
#include "tc358743.h"
#include "rtp.h" #include "rtp.h"
#include "rtpv.h" #include "rtpv.h"
#include "rtpa.h" #include "rtpa.h"
@@ -188,6 +188,22 @@ static void *_video_sink_thread(void *arg) {
return NULL; return NULL;
} }
static int _check_tc358743_audio(uint *audio_hz) {
int fd;
if ((fd = open(_g_config->tc358743_dev_path, O_RDWR)) < 0) {
US_JLOG_PERROR("audio", "Can't open TC358743 V4L2 device");
return -1;
}
const int checked = us_tc358743_xioctl_get_audio_hz(fd, audio_hz);
if (checked < 0) {
US_JLOG_PERROR("audio", "Can't check TC358743 audio state (%d)", checked);
close(fd);
return -1;
}
close(fd);
return 0;
}
static void *_audio_thread(void *arg) { static void *_audio_thread(void *arg) {
(void)arg; (void)arg;
US_THREAD_SETTLE("us_audio"); US_THREAD_SETTLE("us_audio");
@@ -204,32 +220,27 @@ static void *_audio_thread(void *arg) {
continue; continue;
} }
us_tc358743_info_s info = {0}; uint audio_hz = 0;
us_audio_s *audio = NULL; us_audio_s *audio = NULL;
if (us_tc358743_read_info(_g_config->tc358743_dev_path, &info) < 0) { if (_check_tc358743_audio(&audio_hz) < 0) {
goto close_audio; goto close_audio;
} }
if (!info.has_audio) { if (audio_hz == 0) {
US_ONCE({ US_JLOG_INFO("audio", "No audio presented from the host"); }); US_ONCE({ US_JLOG_INFO("audio", "No audio presented from the host"); });
goto close_audio; goto close_audio;
} }
US_ONCE({ US_JLOG_INFO("audio", "Detected host audio"); }); US_ONCE({ US_JLOG_INFO("audio", "Detected host audio"); });
if ((audio = us_audio_init(_g_config->audio_dev_name, info.audio_hz)) == NULL) { if ((audio = us_audio_init(_g_config->audio_dev_name, audio_hz)) == NULL) {
goto close_audio; goto close_audio;
} }
once = 0; once = 0;
while (!_STOP && _HAS_WATCHERS && _HAS_LISTENERS) { while (!_STOP && _HAS_WATCHERS && _HAS_LISTENERS) {
if ( if (_check_tc358743_audio(&audio_hz) < 0 || audio->pcm_hz != audio_hz) {
us_tc358743_read_info(_g_config->tc358743_dev_path, &info) < 0
|| !info.has_audio
|| audio->pcm_hz != info.audio_hz
) {
goto close_audio; goto close_audio;
} }
uz size = US_RTP_DATAGRAM_SIZE - US_RTP_HEADER_SIZE; uz size = US_RTP_DATAGRAM_SIZE - US_RTP_HEADER_SIZE;
u8 data[size]; u8 data[size];
u64 pts; u64 pts;

1
janus/src/uslibs/tc358743.c Symbolic link
View File

@@ -0,0 +1 @@
../../../src/libs/tc358743.c

1
janus/src/uslibs/tc358743.h Symbolic link
View File

@@ -0,0 +1 @@
../../../src/libs/tc358743.h

View File

@@ -1,6 +1,6 @@
.\" Manpage for ustreamer-dump. .\" Manpage for ustreamer-dump.
.\" Open an issue or pull request to https://github.com/pikvm/ustreamer to correct errors or typos .\" Open an issue or pull request to https://github.com/pikvm/ustreamer to correct errors or typos
.TH USTREAMER-DUMP 1 "version 6.2" "January 2021" .TH USTREAMER-DUMP 1 "version 6.3" "January 2021"
.SH NAME .SH NAME
ustreamer-dump \- Dump uStreamer's memory sink to file ustreamer-dump \- Dump uStreamer's memory sink to file

View File

@@ -1,6 +1,6 @@
.\" Manpage for ustreamer. .\" Manpage for ustreamer.
.\" Open an issue or pull request to https://github.com/pikvm/ustreamer to correct errors or typos .\" Open an issue or pull request to https://github.com/pikvm/ustreamer to correct errors or typos
.TH USTREAMER 1 "version 6.2" "November 2020" .TH USTREAMER 1 "version 6.3" "November 2020"
.SH NAME .SH NAME
ustreamer \- stream MJPEG video from any V4L2 device to the network ustreamer \- stream MJPEG video from any V4L2 device to the network

View File

@@ -3,7 +3,7 @@
pkgname=ustreamer pkgname=ustreamer
pkgver=6.2 pkgver=6.3
pkgrel=1 pkgrel=1
pkgdesc="Lightweight and fast MJPEG-HTTP streamer" pkgdesc="Lightweight and fast MJPEG-HTTP streamer"
url="https://github.com/pikvm/ustreamer" url="https://github.com/pikvm/ustreamer"

View File

@@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=ustreamer PKG_NAME:=ustreamer
PKG_VERSION:=6.2 PKG_VERSION:=6.3
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_MAINTAINER:=Maxim Devaev <mdevaev@gmail.com> PKG_MAINTAINER:=Maxim Devaev <mdevaev@gmail.com>

View File

@@ -17,7 +17,7 @@ def _find_sources(suffix: str) -> list[str]:
if __name__ == "__main__": if __name__ == "__main__":
setup( setup(
name="ustreamer", name="ustreamer",
version="6.2", version="6.3",
description="uStreamer tools", description="uStreamer tools",
author="Maxim Devaev", author="Maxim Devaev",
author_email="mdevaev@gmail.com", author_email="mdevaev@gmail.com",

View File

@@ -26,7 +26,7 @@
#define US_VERSION_MAJOR 6 #define US_VERSION_MAJOR 6
#define US_VERSION_MINOR 2 #define US_VERSION_MINOR 3
#define US_MAKE_VERSION2(_major, _minor) #_major "." #_minor #define US_MAKE_VERSION2(_major, _minor) #_major "." #_minor
#define US_MAKE_VERSION1(_major, _minor) US_MAKE_VERSION2(_major, _minor) #define US_MAKE_VERSION1(_major, _minor) US_MAKE_VERSION2(_major, _minor)

View File

@@ -28,11 +28,9 @@
#include <linux/videodev2.h> #include <linux/videodev2.h>
#include <linux/v4l2-controls.h> #include <linux/v4l2-controls.h>
#include "uslibs/types.h" #include "types.h"
#include "uslibs/tools.h" #include "tools.h"
#include "uslibs/xioctl.h" #include "xioctl.h"
#include "logging.h"
#ifndef V4L2_CID_USER_TC358743_BASE #ifndef V4L2_CID_USER_TC358743_BASE
@@ -46,28 +44,22 @@
#endif #endif
int us_tc358743_read_info(const char *path, us_tc358743_info_s *info) { int us_tc358743_xioctl_get_audio_hz(int fd, uint *audio_hz) {
US_MEMSET_ZERO(*info); *audio_hz = 0;
int fd = -1; struct v4l2_control ctl = {.id = TC358743_CID_AUDIO_PRESENT};
if ((fd = open(path, O_RDWR)) < 0) { if (us_xioctl(fd, VIDIOC_G_CTRL, &ctl) < 0) {
US_JLOG_PERROR("audio", "Can't open TC358743 V4L2 device");
return -1; return -1;
} }
if (!ctl.value) {
return 0; // No audio
}
# define READ_CID(x_cid, x_field) { \ US_MEMSET_ZERO(ctl);
struct v4l2_control m_ctl = {.id = x_cid}; \ ctl.id = TC358743_CID_AUDIO_SAMPLING_RATE;
if (us_xioctl(fd, VIDIOC_G_CTRL, &m_ctl) < 0) { \ if (us_xioctl(fd, VIDIOC_G_CTRL, &ctl) < 0) {
US_JLOG_PERROR("audio", "Can't get value of " #x_cid); \ return -2;
close(fd); \ }
return -1; \ *audio_hz = ctl.value;
} \
info->x_field = m_ctl.value; \
}
READ_CID(TC358743_CID_AUDIO_PRESENT, has_audio);
READ_CID(TC358743_CID_AUDIO_SAMPLING_RATE, audio_hz);
# undef READ_CID
close(fd);
return 0; return 0;
} }

View File

@@ -22,13 +22,7 @@
#pragma once #pragma once
#include "uslibs/types.h" #include "types.h"
typedef struct { int us_tc358743_xioctl_get_audio_hz(int fd, uint *audio_hz);
bool has_audio;
uint audio_hz;
} us_tc358743_info_s;
int us_tc358743_read_info(const char *path, us_tc358743_info_s *info);

View File

@@ -487,9 +487,17 @@ static int _m2m_encoder_compress_raw(us_m2m_encoder_s *enc, const us_frame_s *sr
// Для не-DMA отправка буфера по факту являтся освобождением этого буфера // Для не-DMA отправка буфера по факту являтся освобождением этого буфера
bool input_released = !run->p_dma; bool input_released = !run->p_dma;
while (true) { // https://github.com/pikvm/ustreamer/issues/253
struct pollfd enc_poll = {run->fd, POLLIN, 0}; // За секунду точно должно закодироваться.
const ldf deadline_ts = us_get_now_monotonic() + 1;
while (true) {
if (us_get_now_monotonic() > deadline_ts) {
_E_LOG_ERROR("Waiting for the encoder is too long");
goto error;
}
struct pollfd enc_poll = {run->fd, POLLIN, 0};
_E_LOG_DEBUG("Polling encoder ..."); _E_LOG_DEBUG("Polling encoder ...");
if (poll(&enc_poll, 1, 1000) < 0 && errno != EINTR) { if (poll(&enc_poll, 1, 1000) < 0 && errno != EINTR) {
_E_LOG_PERROR("Can't poll encoder"); _E_LOG_PERROR("Can't poll encoder");