Commit 4d3ab5f2 authored by Simon Morlat's avatar Simon Morlat

implement play-to_remote features, not tested yet.

parent 11063b34
......@@ -113,7 +113,8 @@ MS2_PUBLIC void ms_media_stream_sessions_uninit(MSMediaStreamSessions *sessions)
typedef enum _MSStreamState{
MSStreamInitialized,
MSStreamPreparing,
MSStreamStarted
MSStreamStarted,
MSStreamStopped
}MSStreamState;
#define AudioStreamType MSAudio
......@@ -295,16 +296,25 @@ struct _AudioStream
MSFilter *write_resampler;
MSFilter *equalizer;
MSFilter *dummy;
MSFilter *send_tee;
MSFilter *recv_tee;
MSFilter *recorder_mixer;
MSFilter *recorder;
MSFilter *outbound_mixer;
struct {
MSFilter *resampler;
MSFilter *encoder;
MSFilter *recorder;
MSFilter *video_input;
}av_recorder;
struct _AVPlayer{
MSFilter *player;
MSFilter *resampler;
MSFilter *decoder;
MSFilter *video_output;
int audiopin;
int videopin;
bool_t plumbed;
}av_player;
char *recorder_file;
EchoLimiterType el_type; /*use echo limiter: two MSVolume, measured input level controlling local output level*/
EqualizerLocation eq_loc;
......@@ -395,6 +405,7 @@ MS2_PUBLIC AudioStream *audio_stream_new_with_sessions(const MSMediaStreamSessio
#define AUDIO_STREAM_FEATURE_DTMF_ECHO (1 << 6)
#define AUDIO_STREAM_FEATURE_MIXED_RECORDING (1 << 7)
#define AUDIO_STREAM_FEATURE_LOCAL_PLAYING (1 << 8)
#define AUDIO_STREAM_FEATURE_REMOTE_PLAYING (1 << 9)
#define AUDIO_STREAM_FEATURE_ALL (\
AUDIO_STREAM_FEATURE_PLC | \
......@@ -405,7 +416,8 @@ MS2_PUBLIC AudioStream *audio_stream_new_with_sessions(const MSMediaStreamSessio
AUDIO_STREAM_FEATURE_DTMF | \
AUDIO_STREAM_FEATURE_DTMF_ECHO |\
AUDIO_STREAM_FEATURE_MIXED_RECORDING |\
AUDIO_STREAM_FEATURE_LOCAL_PLAYING \
AUDIO_STREAM_FEATURE_LOCAL_PLAYING | \
AUDIO_STREAM_FEATURE_REMOTE_PLAYING \
)
......@@ -514,6 +526,12 @@ MS2_PUBLIC int audio_stream_mixed_record_start(AudioStream *st);
MS2_PUBLIC int audio_stream_mixed_record_stop(AudioStream *st);
/**
* Open a player to play an audio/video file to remote end.
* The player is returned as a MSFilter so that application can make usual player controls on it using the MSPlayerInterface.
**/
MS2_PUBLIC MSFilter * audio_stream_open_remote_play(AudioStream *stream, const char *filename);
MS2_PUBLIC void audio_stream_set_default_card(int cardindex);
/* retrieve RTP statistics*/
......
......@@ -25,15 +25,18 @@ typedef struct MSAudioMixerCtl{
int pin;
union param_t {
float gain; /**<gain correction */
int active; /**< to mute or unmute the channel */
int active; /**< to mute or unmute the input channel */
int enabled; /**< to mute/unmute the output channel*/
} param;
} MSAudioMixerCtl;
#define MS_AUDIO_MIXER_SET_INPUT_GAIN MS_FILTER_METHOD(MS_AUDIO_MIXER_ID,0,MSAudioMixerCtl)
#define MS_AUDIO_MIXER_SET_ACTIVE MS_FILTER_METHOD(MS_AUDIO_MIXER_ID,1,MSAudioMixerCtl)
#define MS_AUDIO_MIXER_ENABLE_CONFERENCE_MODE MS_FILTER_METHOD(MS_AUDIO_MIXER_ID,2,int)
/** Tells whether channel contributes to the mix.*/
#define MS_AUDIO_MIXER_SET_ACTIVE MS_FILTER_METHOD(MS_AUDIO_MIXER_ID,1,MSAudioMixerCtl)
#define MS_AUDIO_MIXER_ENABLE_CONFERENCE_MODE MS_FILTER_METHOD(MS_AUDIO_MIXER_ID,2,int)
/**The master channel is the one that is used to synchronize the others. No flow control is done on the master channel*/
#define MS_AUDIO_MIXER_SET_MASTER_CHANNEL MS_FILTER_METHOD(MS_AUDIO_MIXER_ID,3,int)
#define MS_AUDIO_MIXER_ENABLE_OUTPUT MS_FILTER_METHOD(MS_AUDIO_MIXER_ID,4,MSAudioMixerCtl)
#endif
......@@ -54,17 +54,19 @@ typedef struct Channel{
MSBufferizer bufferizer;
int16_t *input; /*the channel contribution, for removal at output*/
float gain;
int active;
int min_fullness;
uint64_t last_flow_control;
uint64_t last_activity;
bool_t active;
bool_t output_enabled;
} Channel;
static void channel_init(Channel *chan){
ms_bufferizer_init(&chan->bufferizer);
chan->input=NULL;
chan->gain=1.0;
chan->active=1;
chan->active=TRUE;
chan->output_enabled=TRUE;
}
static void channel_prepare(Channel *chan, int bytes_per_tick){
......@@ -172,11 +174,12 @@ static void mixer_uninit(MSFilter *f){
ms_free(s);
}
static bool_t has_single_output(MSFilter *f){
static bool_t has_single_output(MSFilter *f, MixerState *s){
int i;
int count=0;
for (i=0;i<f->desc->noutputs;++i){
if (f->outputs[i]) count++;
Channel *chan=&s->channels[i];
if (f->outputs[i] && chan->output_enabled) count++;
}
return count==1;
}
......@@ -192,7 +195,7 @@ static void mixer_preprocess(MSFilter *f){
/*ms_message("bytespertick=%i, purgeoffset=%i",s->bytespertick,s->purgeoffset);*/
s->skip_threshold=s->bytespertick*2;
s->bypass_mode=FALSE;
s->single_output=has_single_output(f);
s->single_output=has_single_output(f,s);
}
static void mixer_postprocess(MSFilter *f){
......@@ -219,7 +222,8 @@ static void mixer_dispatch_output(MSFilter *f, MixerState*s, MSQueue *inq){
int i;
for (i=0;i<f->desc->noutputs;i++){
MSQueue *outq=f->outputs[i];
if (outq){
Channel *chan=&s->channels[i];
if (outq && chan->output_enabled){
mblk_t *m;
if (s->single_output){
while((m=ms_queue_get(inq))!=NULL){
......@@ -286,8 +290,11 @@ static void mixer_process(MSFilter *f){
int skip=0;
bool_t got_something=FALSE;
if (mixer_check_bypass(f,s))
ms_filter_lock(f);
if (mixer_check_bypass(f,s)){
ms_filter_unlock(f);
return;
}
memset(s->sum,0,nwords*sizeof(int32_t));
......@@ -312,7 +319,8 @@ static void mixer_process(MSFilter *f){
mblk_t *om=NULL;
for(i=0;i<MIXER_MAX_CHANNELS;++i){
MSQueue *q=f->outputs[i];
if (q){
Channel *chan=&s->channels[i];
if (q && chan->output_enabled){
if (om==NULL){
om=make_output(s->sum,nwords);
}else{
......@@ -324,12 +332,14 @@ static void mixer_process(MSFilter *f){
}else{
for(i=0;i<MIXER_MAX_CHANNELS;++i){
MSQueue *q=f->outputs[i];
if (q){
Channel *chan=&s->channels[i];
if (q && chan->output_enabled){
ms_queue_put(q,channel_process_out(&s->channels[i],s->sum,nwords));
}
}
}
}
ms_filter_unlock(f);
}
static int mixer_set_rate(MSFilter *f, void *data){
......@@ -378,6 +388,21 @@ static int mixer_set_active(MSFilter *f, void *data){
return 0;
}
static int mixer_enable_output(MSFilter *f, void *data){
MixerState *s=(MixerState *)f->data;
MSAudioMixerCtl *ctl=(MSAudioMixerCtl*)data;
if (ctl->pin<0 || ctl->pin>=MIXER_MAX_CHANNELS){
ms_warning("mixer_enable_output: invalid pin number %i",ctl->pin);
return -1;
}
ms_filter_lock(f);
s->channels[ctl->pin].output_enabled=ctl->param.enabled;
s->single_output=has_single_output(f,s);
ms_filter_unlock(f);
return 0;
}
static int mixer_set_conference_mode(MSFilter *f, void *data){
MixerState *s=(MixerState *)f->data;
s->conf_mode=*(int*)data;
......@@ -401,6 +426,7 @@ static MSFilterMethod methods[]={
{ MS_AUDIO_MIXER_SET_ACTIVE , mixer_set_active },
{ MS_AUDIO_MIXER_ENABLE_CONFERENCE_MODE, mixer_set_conference_mode },
{ MS_AUDIO_MIXER_SET_MASTER_CHANNEL , mixer_set_master_channel },
{ MS_AUDIO_MIXER_ENABLE_OUTPUT, mixer_enable_output },
{0,NULL}
};
......
This diff is collapsed.
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