File tree Expand file tree Collapse file tree 6 files changed +46
-19
lines changed
Expand file tree Collapse file tree 6 files changed +46
-19
lines changed Original file line number Diff line number Diff line change @@ -1072,16 +1072,10 @@ static int adjust_params(struct ug_options *opt) {
10721072 }
10731073
10741074 // default values for different RXTX protocols
1075- if (strcasecmp (opt->video_protocol , " rtsp" ) == 0 || strcasecmp (opt->video_protocol , " sdp" ) == 0 ) {
1076- if (opt->requested_compression == nullptr ) {
1077- if (strcasecmp (opt->video_protocol , " rtsp" ) == 0 ) {
1078- opt->requested_compression = " lavc:enc=libx264:safe" ;
1079- } else {
1080- opt->requested_compression = " none" ; // will be set later by h264_sdp_video_rxtx::send_frame()
1081- }
1082- }
1083- } else {
1084- if (opt->requested_compression == nullptr ) {
1075+ if (opt->requested_compression == nullptr ) {
1076+ if (strcasecmp (opt->video_protocol , " rtsp" ) == 0 || strcasecmp (opt->video_protocol , " sdp" ) == 0 ) {
1077+ opt->requested_compression = " none" ; // will be set later by video_rxtx::send_frame()
1078+ } else {
10851079 opt->requested_compression = DEFAULT_VIDEO_COMPRESSION;
10861080 }
10871081 }
Original file line number Diff line number Diff line change 3737 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
3838 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3939 */
40+
4041#ifdef HAVE_CONFIG_H
4142#include " config.h"
4243#include " config_unix.h"
5556#include " module.h"
5657#include " utils/list.h"
5758#include " utils/lock_guard.h"
59+ #include " utils/macros.h" // for snprintf_ch
5860
5961#define MAX_MESSAGES 100
6062#define MAX_MESSAGES_FOR_NOT_EXISTING_RECV 10
@@ -402,3 +404,21 @@ struct message *check_message(struct module *mod)
402404 }
403405}
404406
407+ /* *
408+ * send compress change
409+ * @param mod any module that can reach the root module
410+ * @param compression compression to be used
411+ */
412+ void
413+ send_compess_change (struct module *mod, const char *compression)
414+ {
415+ auto *msg = (struct msg_change_compress_data *) new_message (
416+ sizeof (struct msg_change_compress_data ));
417+ msg->what = CHANGE_COMPRESS;
418+ snprintf_ch (msg->config_string , " %s" , compression);
419+
420+ const char *path = " sender.compress" ;
421+ auto *resp =
422+ send_message (get_root_module (mod), path, (struct message *) msg);
423+ free_response (resp);
424+ }
Original file line number Diff line number Diff line change @@ -180,6 +180,8 @@ struct message *check_message(struct module *);
180180
181181void free_message_for_child (void * m , struct response * r );
182182
183+ void send_compess_change (struct module * mod , const char * compression );
184+
183185#ifdef __cplusplus
184186}
185187#endif
Original file line number Diff line number Diff line change 5050#include " debug.h"
5151#include " host.h"
5252#include " lib_common.h"
53+ #include " messaging.h"
5354#include " rtp/rtp.h"
5455#include " rtsp/rtsp_utils.h" // for rtsp_types_t
5556#include " transmit.h"
6162#include " video_rxtx.hpp"
6263#include " video_rxtx/h264_rtp.hpp"
6364
65+ constexpr char DEFAULT_RTSP_COMPRESSION[] = " lavc:enc=libx264:safe" ;
6466#define MOD_NAME " [vrxtx/h264_rtp] "
6567
6668using std::shared_ptr;
@@ -109,6 +111,16 @@ h264_rtp_video_rxtx::configure_rtsp_server_video()
109111void
110112h264_rtp_video_rxtx::send_frame (shared_ptr<video_frame> tx_frame) noexcept
111113{
114+ // requestt compress reconfiguration if receivng raw data
115+ if (!is_codec_opaque (tx_frame->color_spec )) {
116+ if (!m_sent_compress_change) {
117+ send_compess_change (m_common.parent ,
118+ DEFAULT_RTSP_COMPRESSION);
119+ m_sent_compress_change = true ;
120+ }
121+ return ;
122+ }
123+
112124 if (m_rtsp_server == nullptr ) {
113125 rtsp_params.video_codec = tx_frame->color_spec ;
114126 configure_rtsp_server_video ();
@@ -117,6 +129,11 @@ h264_rtp_video_rxtx::send_frame(shared_ptr<video_frame> tx_frame) noexcept
117129 return ;
118130 }
119131
132+ if (tx_frame->color_spec != rtsp_params.video_codec ) {
133+ MSG (ERROR, " Video codec reconfiguration is not supported!\n " );
134+ return ;
135+ }
136+
120137 tx_send_std (m_tx, tx_frame.get (), m_network_device);
121138
122139 if ((m_rxtx_mode & MODE_RECEIVER) == 0 ) { // send RTCP (receiver thread would otherwise do this
Original file line number Diff line number Diff line change @@ -72,6 +72,8 @@ class h264_rtp_video_rxtx : public rtp_video_rxtx {
7272 rtsp_serv_t *m_rtsp_server = nullptr ;
7373 void (*tx_send_std)(struct tx *tx_session, struct video_frame *frame,
7474 struct rtp *rtp_session) = nullptr ;
75+
76+ bool m_sent_compress_change = false ;
7577};
7678
7779#endif // VIDEO_RXTX_H264_RTP_H_
Original file line number Diff line number Diff line change @@ -122,15 +122,7 @@ h264_sdp_video_rxtx::send_frame(shared_ptr<video_frame> tx_frame) noexcept
122122 if (m_sent_compress_change) {
123123 return ;
124124 }
125- auto msg = (struct msg_change_compress_data *)
126- new_message (sizeof (struct msg_change_compress_data ));
127- msg->what = CHANGE_COMPRESS;
128- strncpy (msg->config_string , DEFAULT_SDP_COMPRESSION, sizeof (msg->config_string ) - 1 );
129-
130- const char *path = " sender.compress" ;
131- auto *resp = send_message (get_root_module (m_common.parent ), path,
132- (struct message *) msg);
133- free_response (resp);
125+ send_compess_change (m_common.parent , DEFAULT_SDP_COMPRESSION);
134126 m_sent_compress_change = true ;
135127 return ;
136128 }
You can’t perform that action at this time.
0 commit comments