Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/media.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,15 @@ void *aenc_thread(void) {
pthread_mutex_lock(&aencMtx);
if (mp3Buf.offset >= mp3FrmSize) {
send_mp3_to_client(mp3Buf.buf, mp3FrmSize);
pthread_mutex_lock(&mp4Mtx);
mp4_ingest_audio(mp3Buf.buf, mp3FrmSize);
pthread_mutex_unlock(&mp4Mtx);
/* Only the video path empties the MP4 audio buffer, and only while
* an MP4 client or the recorder is there. Fed without one (the
* MP3 encoder also runs for RTSP and RTMP), it grew for as long as
* the program ran. */
if (record_active() || any_http_mp4()) {
pthread_mutex_lock(&mp4Mtx);
mp4_ingest_audio(mp3Buf.buf, mp3FrmSize);
pthread_mutex_unlock(&mp4Mtx);
}
if (app_config.rtsp_enable && !rtsp_g711_active())
rtp_send_mp3(rtspHandle, mp3Buf.buf, mp3FrmSize);
rtmp_ingest_audio(mp3Buf.buf, mp3FrmSize);
Expand Down
9 changes: 9 additions & 0 deletions src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,15 @@ char any_http_audio(void) {
return any;
}

char any_http_mp4(void) {
char any = 0;
pthread_mutex_lock(&client_fds_mutex);
for (unsigned int i = 0; i < HTTP_MAX_CLIENTS; ++i)
if (client_fds[i].sockFd >= 0 && client_fds[i].type == STREAM_MP4) { any = 1; break; }
pthread_mutex_unlock(&client_fds_mutex);
return any;
}

void send_mp4_to_client(char index, hal_vidstream *stream, char isH265) {
char anyClient = 0;
pthread_mutex_lock(&client_fds_mutex);
Expand Down
1 change: 1 addition & 0 deletions src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ void send_mjpeg_to_client(char index, char *buf, ssize_t size);
void send_h26x_to_client(char index, hal_vidstream *stream);
void send_mp3_to_client(char *buf, ssize_t size);
char any_http_audio(void);
char any_http_mp4(void);
void send_mp4_to_client(char index, hal_vidstream *stream, char isH265);
void send_pcm_to_client(hal_audframe *frame);