[Freeswitch-svn] [commit] r7535 - freeswitch/trunk/src/mod/applications/mod_conference
Freeswitch SVN
anthm at freeswitch.org
Tue Feb 5 20:07:47 EST 2008
Author: anthm
Date: Tue Feb 5 20:07:47 2008
New Revision: 7535
Modified:
freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
Log:
look for iframes in the video to know when to switch (needs more)
Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Tue Feb 5 20:07:47 2008
@@ -737,8 +737,9 @@
switch_frame_t *vid_frame;
switch_status_t status;
int has_vid = 1;
-
+
conference->video_running = 1;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Video thread started for conference %s\n", conference->name);
while (has_vid && conference->video_running == 1 && globals.running && !switch_test_flag(conference, CFLAG_DESTRUCT)) {
if (!conference->floor_holder) {
@@ -758,6 +759,25 @@
continue;
}
+ if (conference->floor_holder != last_member) {
+ int iframe = 0;
+
+ if (vid_frame->codec->implementation->ianacode == 34) { /* h.263 */
+ iframe = (*((int16_t*)vid_frame->data) >> 12 == 6);
+ } else if (vid_frame->codec->implementation->ianacode == 115) { /* h.263-1998 */
+ int y = *((int8_t*)vid_frame->data + 2) & 0xfe;
+ iframe = (y == 0x80 || y == 0x82);
+ } else if (vid_frame->codec->implementation->ianacode == 99) { /* h.264 */
+ iframe = (*((int16_t*)vid_frame->data) >> 5 == 0x11);
+ } else { /* we need more defs */
+ iframe = 1;
+ }
+
+ if (!iframe) {
+ continue;
+ }
+ }
+
last_member = conference->floor_holder;
switch_mutex_lock(conference->member_mutex);
@@ -771,7 +791,7 @@
switch_mutex_unlock(conference->member_mutex);
}
}
-
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Video thread ending for conference %s\n", conference->name);
conference->video_running = 0;
return NULL;
@@ -807,8 +827,8 @@
while (globals.running && !switch_test_flag(conference, CFLAG_DESTRUCT)) {
switch_size_t file_sample_len = samples;
switch_size_t file_data_len = samples * 2;
- int has_file_data = 0;
-
+ int has_file_data = 0, members_with_video = 0;
+
if (conference->perpetual_sound && !conference->async_fnode) {
conference_play_file(conference, conference->perpetual_sound, CONF_DEFAULT_LEADIN, NULL, 1);
} else if (conference->moh_sound && conference->count == 1 && !conference->async_fnode) {
@@ -829,6 +849,10 @@
total++;
imember->read = 0;
+ if (switch_channel_test_flag(switch_core_session_get_channel(imember->session), CF_VIDEO)) {
+ members_with_video++;
+ }
+
switch_clear_flag_locked(imember, MFLAG_HAS_AUDIO);
switch_mutex_lock(imember->audio_in_mutex);
@@ -841,6 +865,10 @@
switch_mutex_unlock(imember->audio_in_mutex);
}
+ if (members_with_video && conference->video_running != 1) {
+ launch_conference_video_thread(conference);
+ }
+
/* If a file or speech event is being played */
if (conference->fnode) {
/* Lead in time */
@@ -1676,11 +1704,6 @@
switch_size_t file_data_len = file_sample_len * 2;
- if (switch_channel_test_flag(channel, CF_VIDEO) && member->conference->video_running != 1) {
- launch_conference_video_thread(member->conference);
- }
-
-
switch_mutex_lock(member->flag_mutex);
More information about the Freeswitch-svn
mailing list