Commit ad7571fa authored by Simon Morlat's avatar Simon Morlat

avoid unnecessary duplications of mblk_t

parent 1e2581a3
......@@ -38,12 +38,22 @@ static void tee_process(MSFilter *f){
TeeData *d=(TeeData*)f->data;
mblk_t *im;
int i;
while((im=ms_queue_get(f->inputs[0]))!=NULL){
int output_count = 0;
mblk_t * outm;
for(i=0;i<f->desc->noutputs;i++){
if (f->outputs[i]!=NULL && !d->muted[i])
ms_queue_put(f->outputs[i],dupmsg(im));
if (f->outputs[i]!=NULL && !d->muted[i]){
if (output_count == 0){
outm = im;
}else{
outm = dupmsg(im);
}
ms_queue_put(f->outputs[i],outm);
output_count++;
}
}
freemsg(im);
}
}
......
......@@ -1427,6 +1427,7 @@ int audio_stream_mixed_record_start(AudioStream *st){
mctl.pin=pin;
mctl.param.enabled=TRUE;
ms_filter_call_method(st->outbound_mixer,MS_AUDIO_MIXER_ENABLE_OUTPUT,&mctl);
if (st->videostream) video_stream_enable_recording(st->videostream, TRUE);
return 0;
}
return -1;
......@@ -1440,11 +1441,13 @@ int audio_stream_mixed_record_stop(AudioStream *st){
if (recorder==NULL) return -1;
ms_filter_call_method(st->recv_tee,MS_TEE_MUTE,&pin);
if (st->videostream) video_stream_enable_recording(st->videostream, FALSE);
mctl.pin=pin;
mctl.param.enabled=FALSE;
ms_filter_call_method(st->outbound_mixer,MS_AUDIO_MIXER_ENABLE_OUTPUT,&mctl);
ms_filter_call_method_noarg(recorder,MS_RECORDER_PAUSE);
ms_filter_call_method_noarg(recorder,MS_RECORDER_CLOSE);
}
return 0;
}
......@@ -1907,6 +1910,7 @@ void audio_stream_unlink_video(AudioStream *stream, VideoStream *video){
stream->videostream=NULL;
if (stream->av_recorder.video_input && video->recorder_output){
ms_filter_call_method(video->recorder_output,MS_ITC_SINK_CONNECT,NULL);
video_stream_enable_recording(video, FALSE);
}
}
......
......@@ -106,6 +106,8 @@ void video_recorder_handle_event(void *userdata, MSFilter *recorder, unsigned in
void ms_audio_flow_control_event_handler(void *user_data, MSFilter *f, unsigned int event, void *eventdata);
void video_stream_enable_recording(VideoStream *stream, int enabled);
#ifdef __cplusplus
}
#endif
......
......@@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "mediastreamer2/zrtp.h"
#include "mediastreamer2/msvideopresets.h"
#include "mediastreamer2/mseventqueue.h"
#include "mediastreamer2/mstee.h"
#include "private.h"
#if __APPLE__
......@@ -1122,6 +1123,7 @@ static int video_stream_start_with_source_and_output(VideoStream *stream, RtpPro
if (stream->recorder_output){
ms_connection_helper_link(&ch,stream->tee3,0,0);
ms_filter_link(stream->tee3,1,stream->recorder_output,0);
video_stream_enable_recording(stream, FALSE);/*until recorder is started, the tee3 is kept muted on pin 1*/
configure_recorder_output(stream);
}
ms_connection_helper_link(&ch,stream->ms.decoder,0,0);
......@@ -1854,6 +1856,15 @@ void video_stream_use_video_preset(VideoStream *stream, const char *preset) {
stream->preset = ms_strdup(preset);
}
/*this function optimizes the processing by enabling the duplication of video packets to the recorder, which is not required to be done
* when the recorder is not recording of course.*/
void video_stream_enable_recording(VideoStream *stream, int enabled){
if (stream->tee3){
int pin = 1;
ms_filter_call_method(stream->tee3, enabled ? MS_TEE_UNMUTE : MS_TEE_MUTE, &pin);
}
}
MSFilter * video_stream_open_remote_play(VideoStream *stream, const char *filename){
MSFilter *source = stream->source;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment