From baf069b7c5c0a03ee478aea76bb1265bf5fef7da Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Fri, 23 Nov 2018 16:07:16 +0100 Subject: [PATCH] H.264 std: simplified a bit Note that RTCP SR are now send slightly in a different way - previously the timestamp used was T-1. --- src/transmit.cpp | 36 +++++++----------------------------- src/video_rxtx/h264_sdp.cpp | 5 ++--- 2 files changed, 9 insertions(+), 32 deletions(-) diff --git a/src/transmit.cpp b/src/transmit.cpp index 2653c56cd..6658dff8a 100644 --- a/src/transmit.cpp +++ b/src/transmit.cpp @@ -948,11 +948,13 @@ void audio_tx_send_standard(struct tx* tx, struct rtp *rtp_session, /** * H.264 standard transmission */ -static void tx_send_base_h264(struct tx *tx, struct video_frame *frame, - struct rtp *rtp_session, uint32_t ts, int send_m, codec_t color_spec, - double input_fps, enum interlacing_t interlacing, - unsigned int substream, int fragment_offset) { - struct tile *tile = &frame->tiles[substream]; +void tx_send_h264(struct tx *tx, struct video_frame *frame, + struct rtp *rtp_session) { + assert(frame->tile_count == 1); // std transmit doesn't handle more than one tile + assert(!frame->fragment || tx->fec_scheme == FEC_NONE); // currently no support for FEC with fragments + assert(!frame->fragment || frame->tile_count); // multiple tiles are not currently supported for fragmented send + uint32_t ts = get_std_video_local_mediatime(); + struct tile *tile = &frame->tiles[0]; char pt = RTPENC_H264_PT; unsigned char hdr[2]; @@ -1056,30 +1058,6 @@ static void tx_send_base_h264(struct tx *tx, struct video_frame *frame, } } -/* - * sends one or more frames (tiles) with same TS in one RTP stream. Only one m-bit is set. - */ -void tx_send_h264(struct tx *tx, struct video_frame *frame, - struct rtp *rtp_session) { - struct timeval curr_time; - static uint32_t ts_prev = 0; - uint32_t ts = 0; - - assert(frame->tile_count == 1); // std transmit doesn't handle more than one tile - assert(!frame->fragment || tx->fec_scheme == FEC_NONE); // currently no support for FEC with fragments - assert(!frame->fragment || frame->tile_count); // multiple tiles are not currently supported for fragmented send - - ts = get_std_video_local_mediatime(); - - gettimeofday(&curr_time, NULL); - rtp_send_ctrl(rtp_session, ts_prev, 0, curr_time); //send RTCP SR - ts_prev = ts; - - tx_send_base_h264(tx, frame, rtp_session, ts, 0, - frame->color_spec, frame->fps, frame->interlacing, 0, - 0); -} - void tx_send_jpeg(struct tx *tx, struct video_frame *frame, struct rtp *rtp_session) { uint32_t ts = 0; diff --git a/src/video_rxtx/h264_sdp.cpp b/src/video_rxtx/h264_sdp.cpp index 20ddc3aee..e5b539dc3 100644 --- a/src/video_rxtx/h264_sdp.cpp +++ b/src/video_rxtx/h264_sdp.cpp @@ -54,6 +54,7 @@ #include "rtp/rtp_callback.h" // PCMA/PCMU packet types #include "rtp/rtpenc_h264.h" #include "transmit.h" +#include "tv.h" #include "utils/sdp.h" #include "video.h" #include "video_rxtx.h" @@ -151,9 +152,7 @@ void h264_sdp_video_rxtx::send_frame(shared_ptr tx_frame) } if ((m_rxtx_mode & MODE_RECEIVER) == 0) { // send RTCP (receiver thread would otherwise do this struct timeval curr_time; - uint32_t ts; - gettimeofday(&curr_time, NULL); - ts = std::chrono::duration_cast>(m_start_time - std::chrono::steady_clock::now()).count() * 90000; + uint32_t ts = get_std_video_local_mediatime(); rtp_update(m_network_devices[0], curr_time); rtp_send_ctrl(m_network_devices[0], ts, 0, curr_time);