Commit f6fb1dc8 authored by Sandrine Avakian's avatar Sandrine Avakian

Android fixes to use MSFactory.

parent cad549db
......@@ -40,8 +40,8 @@ using namespace::fake_android;
static const float audio_buf_ms=0.01;
static MSSndCard * android_snd_card_new(SoundDeviceDescription *d);
static MSFilter * ms_android_snd_read_new(void);
static MSFilter * ms_android_snd_write_new(void);
static MSFilter * ms_android_snd_read_new(MSFactory* factory);
static MSFilter * ms_android_snd_write_new(MSFactory* factory);
static Library *libmedia=0;
static Library *libutils=0;
......@@ -205,13 +205,13 @@ struct AndroidSndWriteData{
};
static MSFilter *android_snd_card_create_reader(MSSndCard *card){
MSFilter *f=ms_android_snd_read_new();
MSFilter *f=ms_android_snd_read_new(ms_snd_card_factory_get(card));
(static_cast<AndroidSndReadData*>(f->data))->setCard(card);
return f;
}
static MSFilter *android_snd_card_create_writer(MSSndCard *card){
MSFilter *f=ms_android_snd_write_new();
MSFilter *f=ms_android_snd_write_new(ms_snd_card_factory_get(card));
(static_cast<AndroidSndWriteData*>(f->data))->setCard((AndroidNativeSndCardData*)card->data);
return f;
}
......@@ -267,6 +267,7 @@ static void android_snd_card_detect(MSSndCardManager *m){
if (audio_record_loaded && audio_track_loaded && audio_system_loaded && string8_loaded && refbase_loaded && !(d->flags & DEVICE_HAS_UNSTANDARD_LIBMEDIA)){
ms_message("Native android sound support available.");
MSSndCard *card=android_snd_card_new(d);
ms_snd_card_set_manager(m,card);
ms_snd_card_manager_add_card(m,card);
return;
}
......@@ -561,8 +562,8 @@ MSFilterDesc android_snd_read_desc={
android_snd_read_methods
};
static MSFilter * ms_android_snd_read_new(){
MSFilter *f=ms_filter_new_from_desc(&android_snd_read_desc);
static MSFilter * ms_android_snd_read_new(MSFactory *factory){
MSFilter *f=ms_factory_create_filter_from_desc(factory, &android_snd_read_desc);
return f;
}
......@@ -817,8 +818,8 @@ MSFilterDesc android_snd_write_desc={
android_snd_write_methods
};
static MSFilter * ms_android_snd_write_new(void){
MSFilter *f=ms_filter_new_from_desc(&android_snd_write_desc);
static MSFilter * ms_android_snd_write_new(MSFactory* factory){
MSFilter *f=ms_factory_create_filter_from_desc(factory, &android_snd_write_desc);
return f;
}
......@@ -569,7 +569,7 @@ static MSFilterDesc msandroid_sound_read_desc={
MSFilter *msandroid_sound_read_new(MSSndCard *card){
ms_debug("msandroid_sound_read_new");
MSFilter *f=ms_filter_new_from_desc(&msandroid_sound_read_desc);
MSFilter *f=ms_factory_new_from_desc(ms_snd_card_factory_get(card), &msandroid_sound_read_desc);
msandroid_sound_read_data *data=new msandroid_sound_read_data();
data->builtin_aec = card->capabilities & MS_SND_CARD_CAP_BUILTIN_ECHO_CANCELLER;
if (card->data != NULL) {
......@@ -895,7 +895,7 @@ static MSFilterDesc msandroid_sound_write_desc={
MSFilter *msandroid_sound_write_new(MSSndCard *card){
ms_debug("msandroid_sound_write_new");
MSFilter *f=ms_filter_new_from_desc(&msandroid_sound_write_desc);
MSFilter *f=ms_filter_new_from_desc(ms_snd_card_factory_get(card), &msandroid_sound_write_desc);
msandroid_sound_write_data *data = new msandroid_sound_write_data();
if (card->data != NULL) {
SoundDeviceDescription *d = (SoundDeviceDescription *)card->data;
......
......@@ -111,8 +111,8 @@ JNIEXPORT void JNICALL Java_org_linphone_mediastream_MediastreamerAndroidContext
using namespace fake_opensles;
static MSSndCard *android_snd_card_new(void);
static MSFilter *ms_android_snd_read_new(void);
static MSFilter *ms_android_snd_write_new(void);
static MSFilter *ms_android_snd_read_new(MSFactory *factory);
static MSFilter *ms_android_snd_write_new(MSFactory* factory);
struct OpenSLESContext {
OpenSLESContext() {
......@@ -251,6 +251,7 @@ static void android_snd_card_detect(MSSndCardManager *m) {
if (initOpenSLES() == 0) { // Try to dlopen libOpenSLES
ms_message("libOpenSLES correctly loaded, creating OpenSLES MS soundcard");
MSSndCard *card = android_snd_card_new();
ms_snd_card_set_manager(m,card);
ms_snd_card_manager_add_card(m, card);
} else {
ms_warning("Failed to dlopen libOpenSLES, OpenSLES MS soundcard unavailable");
......@@ -621,13 +622,13 @@ MSFilterDesc android_snd_opensles_read_desc = {
android_snd_read_methods
};
static MSFilter* ms_android_snd_read_new() {
MSFilter *f = ms_filter_new_from_desc(&android_snd_opensles_read_desc);
static MSFilter* ms_android_snd_read_new(MSFactory *factory) {
MSFilter *f = ms_factory_create_filter_from_desc(factory, &android_snd_opensles_read_desc);
return f;
}
static MSFilter *android_snd_card_create_reader(MSSndCard *card) {
MSFilter *f = ms_android_snd_read_new();
MSFilter *f = ms_android_snd_read_new(ms_snd_card_factory_get(card));
OpenSLESInputContext *ictx = static_cast<OpenSLESInputContext*>(f->data);
ictx->setContext((OpenSLESContext*)card->data);
return f;
......@@ -842,7 +843,7 @@ static OpenSLESOutputContext* opensles_output_context_init() {
}
static MSFilter *android_snd_card_create_writer(MSSndCard *card) {
MSFilter *f = ms_android_snd_write_new();
MSFilter *f = ms_android_snd_write_new(ms_snd_card_factory_get(card));
OpenSLESOutputContext *octx = static_cast<OpenSLESOutputContext*>(f->data);
octx->setContext((OpenSLESContext*)card->data);
return f;
......@@ -983,8 +984,8 @@ MSFilterDesc android_snd_opensles_write_desc = {
android_snd_write_methods
};
static MSFilter* ms_android_snd_write_new(void) {
MSFilter *f = ms_filter_new_from_desc(&android_snd_opensles_write_desc);
static MSFilter* ms_android_snd_write_new(MSFactory* factory) {
MSFilter *f = ms_factory_create_filter_from_desc(factory, &android_snd_opensles_write_desc);
return f;
}
......
......@@ -405,7 +405,7 @@ static void video_capture_cam_init(MSWebCam *cam){
static MSFilter *video_capture_create_reader(MSWebCam *obj){
ms_message("Instanciating Android VIDEO capture MS filter");
MSFilter* lFilter = ms_filter_new_from_desc(&ms_video_capture_desc);
MSFilter* lFilter = ms_factory_create_filter_from_desc(ms_web_cam_factory_get(obj), &ms_video_capture_desc);
getContext(lFilter)->webcam = obj;
return lFilter;
......
......@@ -112,7 +112,7 @@ const MSList * ms_snd_card_manager_get_list(MSSndCardManager *m){
}
void ms_snd_card_set_manager(MSSndCardManager*m, MSSndCard *c){
c->sndcardmanager = m;
if (c->sndcardmanager == NULL) c->sndcardmanager = m;
}
......
......@@ -67,7 +67,7 @@ void Java_org_mediastreamer2_test_Ring_echo(JNIEnv* env,jobject this,jint freq
writer=ms_snd_card_create_writer(card_playback);
if (read_rate !=write_rate) {
resampler = ms_filter_new(MS_RESAMPLE_ID);
resampler = ms_fcatory_create_filter(ms_snd_card_factory_get(card_playback),MS_RESAMPLE_ID);
ms_filter_call_method(resampler,MS_FILTER_SET_SAMPLE_RATE,&read_rate);
ms_filter_call_method(resampler,MS_FILTER_SET_OUTPUT_SAMPLE_RATE,&write_rate);
}
......
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