[Freeswitch-svn] [commit] r7565 - in freeswitch/trunk/src: . include include/private mod/endpoints/mod_sofia

Freeswitch SVN anthm at freeswitch.org
Fri Feb 8 19:38:24 EST 2008


Author: anthm
Date: Fri Feb  8 19:38:23 2008
New Revision: 7565

Modified:
   freeswitch/trunk/src/include/private/switch_core_pvt.h
   freeswitch/trunk/src/include/switch_core.h
   freeswitch/trunk/src/include/switch_types.h
   freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
   freeswitch/trunk/src/switch_core_codec.c

Log:
few core tweaks

Modified: freeswitch/trunk/src/include/private/switch_core_pvt.h
==============================================================================
--- freeswitch/trunk/src/include/private/switch_core_pvt.h	(original)
+++ freeswitch/trunk/src/include/private/switch_core_pvt.h	Fri Feb  8 19:38:23 2008
@@ -101,6 +101,8 @@
 	switch_io_event_hooks_t event_hooks;
 	switch_codec_t *read_codec;
 	switch_codec_t *write_codec;
+	switch_codec_t *video_read_codec;
+	switch_codec_t *video_write_codec;
 
 	switch_buffer_t *raw_write_buffer;
 	switch_frame_t raw_write_frame;

Modified: freeswitch/trunk/src/include/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/switch_core.h	(original)
+++ freeswitch/trunk/src/include/switch_core.h	Fri Feb  8 19:38:23 2008
@@ -1084,6 +1084,36 @@
 */
 SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_write_codec(_In_ switch_core_session_t *session);
 
+/*! 
+  \brief Assign the video_read codec to a given session
+  \param session session to add the codec to
+  \param codec the codec to add
+  \return SWITCH_STATUS_SUCCESS if successful
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_session_set_video_read_codec(_In_ switch_core_session_t *session, switch_codec_t *codec);
+
+/*! 
+  \brief Retrieve the video_read codec from a given session
+  \param session session to retrieve from
+  \return a pointer to the codec
+*/
+SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_video_read_codec(_In_ switch_core_session_t *session);
+
+/*! 
+  \brief Assign the video_write codec to a given session
+  \param session session to add the codec to
+  \param codec the codec to add
+  \return SWITCH_STATUS_SUCCESS if successful
+*/
+SWITCH_DECLARE(switch_status_t) switch_core_session_set_video_write_codec(_In_ switch_core_session_t *session, switch_codec_t *codec);
+
+/*! 
+  \brief Retrieve the video_write codec from a given session
+  \param session session to retrieve from
+  \return a pointer to the codec
+*/
+SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_video_write_codec(_In_ switch_core_session_t *session);
+
 ///\}
 ///\defgroup db Database Functions
 ///\ingroup core1

Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h	(original)
+++ freeswitch/trunk/src/include/switch_types.h	Fri Feb  8 19:38:23 2008
@@ -386,6 +386,40 @@
 	SWITCH_RTP_FLAG_SECURE_RECV_RESET = (1 << 17)
 } switch_rtp_flag_t;
 
+
+#ifdef _MSC_VER
+#pragma pack(push, r1, 1)
+#endif
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+typedef struct {
+	unsigned version:2;   /* protocol version       */
+	unsigned p:1;     /* padding flag           */
+	unsigned x:1;     /* header extension flag  */
+	unsigned cc:4;    /* CSRC count             */
+	unsigned m:1;     /* marker bit             */
+	unsigned pt:7;    /* payload type           */
+	unsigned seq:16;      /* sequence number        */
+	unsigned ts:32;       /* timestamp              */
+	unsigned ssrc:32; /* synchronization source */
+} switch_rtp_hdr_t;
+
+#else /*  BIG_ENDIAN */
+
+typedef struct {
+	unsigned cc:4;    /* CSRC count             */
+	unsigned x:1;     /* header extension flag  */
+	unsigned p:1;     /* padding flag           */
+	unsigned version:2;   /* protocol version       */
+	unsigned pt:7;    /* payload type           */
+	unsigned m:1;     /* marker bit             */
+	unsigned seq:16;      /* sequence number        */
+	unsigned ts:32;       /* timestamp              */
+	unsigned ssrc:32; /* synchronization source */
+} switch_rtp_hdr_t;
+
+#endif
+
 /*!
   \enum switch_priority_t
   \brief Priority Indication

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c	Fri Feb  8 19:38:23 2008
@@ -47,6 +47,7 @@
 	int use_cng = 1;
 	const char *val;
 	const char *pass_fmtp = switch_channel_get_variable(tech_pvt->channel, "sip_video_fmtp");
+	const char *ov_fmtp = switch_channel_get_variable(tech_pvt->channel, "sip_force_video_fmtp");
 
 	if (sofia_test_pflag(tech_pvt->profile, PFLAG_SUPRESS_CNG) || 
 		((val = switch_channel_get_variable(tech_pvt->channel, "supress_cng")) && switch_true(val))) {
@@ -261,21 +262,22 @@
 				rate = tech_pvt->video_rm_rate;
 				switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%ld\n", tech_pvt->video_pt, tech_pvt->video_rm_encoding, tech_pvt->video_rm_rate);
 				
-				
+				pass_fmtp = NULL;
+
 				if (switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE)) {
 					if ((of = switch_channel_get_variable_partner(tech_pvt->channel, "sip_video_fmtp"))) {
 						pass_fmtp = of;
 					}
 				} 
 				
-				if (!pass_fmtp) {
-					pass_fmtp = tech_pvt->video_fmtp_out;
+				if (ov_fmtp) {
+					pass_fmtp = ov_fmtp;
 				}
 
 				if (pass_fmtp) {
 					switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=fmtp:%d %s\n", tech_pvt->video_pt, pass_fmtp);
 				}
-				
+
 			} else if (tech_pvt->num_codecs) {
 				int i;
 				int already_did[128] = { 0 };
@@ -1063,7 +1065,8 @@
 			tech_pvt->video_read_frame.codec = &tech_pvt->video_read_codec;
 			
 			tech_pvt->video_fmtp_out = switch_core_session_strdup(tech_pvt->session, tech_pvt->video_write_codec.fmtp_out);
-
+			switch_core_session_set_video_read_codec(tech_pvt->session, &tech_pvt->video_read_codec);
+			switch_core_session_set_video_write_codec(tech_pvt->session, &tech_pvt->video_write_codec);
 		}
 	}
 	return SWITCH_STATUS_SUCCESS;

Modified: freeswitch/trunk/src/switch_core_codec.c
==============================================================================
--- freeswitch/trunk/src/switch_core_codec.c	(original)
+++ freeswitch/trunk/src/switch_core_codec.c	Fri Feb  8 19:38:23 2008
@@ -98,6 +98,62 @@
 	return session->write_codec;
 }
 
+
+
+SWITCH_DECLARE(switch_status_t) switch_core_session_set_video_read_codec(switch_core_session_t *session, switch_codec_t *codec)
+{
+	switch_event_t *event;
+	switch_channel_t *channel = switch_core_session_get_channel(session);
+	char tmp[30];
+
+	if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
+		switch_channel_event_set_data(session->channel, event);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-video-read-codec-name", "%s", codec->implementation->iananame);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-video-read-codec-rate", "%d", codec->implementation->actual_samples_per_second);
+		switch_event_fire(&event);
+	}
+
+	switch_channel_set_variable(channel, "video_read_codec", codec->implementation->iananame);
+	switch_snprintf(tmp, sizeof(tmp), "%d", codec->implementation->actual_samples_per_second);
+	switch_channel_set_variable(channel, "video_read_rate", tmp);
+
+	session->video_read_codec = codec;
+
+	return SWITCH_STATUS_SUCCESS;
+}
+
+SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_video_read_codec(switch_core_session_t *session)
+{
+	return session->video_read_codec;
+}
+
+SWITCH_DECLARE(switch_status_t) switch_core_session_set_video_write_codec(switch_core_session_t *session, switch_codec_t *codec)
+{
+	switch_event_t *event;
+	switch_channel_t *channel = switch_core_session_get_channel(session);
+	char tmp[30];
+
+	if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
+		switch_channel_event_set_data(session->channel, event);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-video-write-codec-name", "%s", codec->implementation->iananame);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-video-write-codec-rate", "%d", codec->implementation->actual_samples_per_second);
+		switch_event_fire(&event);
+	}
+
+	switch_channel_set_variable(channel, "video_write_codec", codec->implementation->iananame);
+	switch_snprintf(tmp, sizeof(tmp), "%d", codec->implementation->actual_samples_per_second);
+	switch_channel_set_variable(channel, "video_write_rate", tmp);
+
+	session->video_write_codec = codec;
+	return SWITCH_STATUS_SUCCESS;
+}
+
+SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_video_write_codec(switch_core_session_t *session)
+{
+	return session->video_write_codec;
+}
+
+
 SWITCH_DECLARE(switch_status_t) switch_core_codec_init(switch_codec_t *codec, char *codec_name, char *fmtp,
 													   uint32_t rate, int ms, int channels, uint32_t flags,
 													   const switch_codec_settings_t *codec_settings, switch_memory_pool_t *pool)



More information about the Freeswitch-svn mailing list