Skip to content
Snippets Groups Projects
Commit b30e6dda authored by Adrien Béraud's avatar Adrien Béraud
Browse files

android: implement getHardwareAudioFormat signal

Change-Id: Ibe5fef93d4612089191501e5a01f0154d92f0a84
parent b00ed3f5
No related branches found
No related tags found
No related merge requests found
...@@ -115,8 +115,8 @@ public class Codec implements Parcelable { ...@@ -115,8 +115,8 @@ public class Codec implements Parcelable {
+ "Channels: " + channels; + "Channels: " + channels;
} }
public CharSequence getPayload() { public Long getPayload() {
return Long.toString(payload); return payload;
} }
public CharSequence getName() { public CharSequence getName() {
......
...@@ -73,14 +73,11 @@ public class ConfigurationManagerCallback extends ConfigurationCallback { ...@@ -73,14 +73,11 @@ public class ConfigurationManagerCallback extends ConfigurationCallback {
mService.sendBroadcast(intent); mService.sendBroadcast(intent);
} }
public IntVect configGetHardwareAudioFormat(){ @Override
IntVect result = new IntVect(); public void getHardwareAudioFormat(IntVect ret){
OpenSlParams audioParams = OpenSlParams.createInstance(mService); OpenSlParams audioParams = OpenSlParams.createInstance(mService);
result.add(audioParams.getSampleRate()); ret.add(audioParams.getSampleRate());
result.add(audioParams.getBufferSize()); ret.add(audioParams.getBufferSize());
return result;
} }
} }
...@@ -59,7 +59,12 @@ public class SipService extends Service { ...@@ -59,7 +59,12 @@ public class SipService extends Service {
private Runnable pollEvents = new Runnable() { private Runnable pollEvents = new Runnable() {
@Override @Override
public void run() { public void run() {
Ringservice.pollEvents(); getExecutor().execute(new SipRunnable() {
@Override
protected void doRun() throws SameThreadException {
Ringservice.pollEvents();
}
});
handler.postDelayed(this, POLLING_TIMEOUT); handler.postDelayed(this, POLLING_TIMEOUT);
} }
}; };
...@@ -69,7 +74,7 @@ public class SipService extends Service { ...@@ -69,7 +74,7 @@ public class SipService extends Service {
protected HistoryManager mHistoryManager; protected HistoryManager mHistoryManager;
protected MediaManager mMediaManager; protected MediaManager mMediaManager;
private HashMap<String, Conference> mConferences = new HashMap<String, Conference>(); private HashMap<String, Conference> mConferences = new HashMap<>();
private ConfigurationManagerCallback configurationCallback; private ConfigurationManagerCallback configurationCallback;
private CallManagerCallBack callManagerCallBack; private CallManagerCallBack callManagerCallBack;
...@@ -201,12 +206,11 @@ public class SipService extends Service { ...@@ -201,12 +206,11 @@ public class SipService extends Service {
public void execute(Runnable task) { public void execute(Runnable task) {
// TODO: add wakelock // TODO: add wakelock
Message.obtain(SipServiceExecutor.this, 0/* don't care */, task).sendToTarget(); Message.obtain(SipServiceExecutor.this, 0/* don't care */, task).sendToTarget();
Log.w(TAG, "SenT!"); //Log.w(TAG, "SenT!");
} }
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
Log.w(TAG, "handleMessage");
if (msg.obj instanceof Runnable) { if (msg.obj instanceof Runnable) {
executeInternal((Runnable) msg.obj); executeInternal((Runnable) msg.obj);
} else { } else {
...@@ -535,7 +539,7 @@ public class SipService extends Service { ...@@ -535,7 +539,7 @@ public class SipService extends Service {
// Hashmap runtime cast // Hashmap runtime cast
@Override @Override
public void setAccountDetails(final String accountId, final Map map) { public void setAccountDetails(final String accountId, final Map map) {
final StringMap swigmap = new StringMap(map); final StringMap swigmap = StringMap.toSwig(map);
getExecutor().execute(new SipRunnable() { getExecutor().execute(new SipRunnable() {
@Override @Override
...@@ -585,7 +589,7 @@ public class SipService extends Service { ...@@ -585,7 +589,7 @@ public class SipService extends Service {
} }
} }
final StringMap swigmap = new StringMap(map); final StringMap swigmap = StringMap.toSwig(map);
AddAccount runInstance = new AddAccount(swigmap); AddAccount runInstance = new AddAccount(swigmap);
getExecutor().execute(runInstance); getExecutor().execute(runInstance);
...@@ -983,9 +987,8 @@ public class SipService extends Service { ...@@ -983,9 +987,8 @@ public class SipService extends Service {
for (int i = 0; i < payloads.size(); ++i) { for (int i = 0; i < payloads.size(); ++i) {
boolean isActive = false; boolean isActive = false;
for (Codec co : results) { for (Codec co : results) {
if (co.getPayload().toString().contentEquals(String.valueOf(payloads.get(i)))) if (co.getPayload() == payloads.get(i))
isActive = true; isActive = true;
} }
if (isActive) if (isActive)
continue; continue;
...@@ -1178,7 +1181,7 @@ public class SipService extends Service { ...@@ -1178,7 +1181,7 @@ public class SipService extends Service {
Log.i(TAG, "SipService.setActiveAudioCodecList() thread running..."); Log.i(TAG, "SipService.setActiveAudioCodecList() thread running...");
UintVect list = new UintVect(); UintVect list = new UintVect();
for (Object codec : codecs) { for (Object codec : codecs) {
list.add((Integer) codec); list.add((Long) codec);
} }
Ringservice.setActiveCodecList(accountID, list); Ringservice.setActiveCodecList(accountID, list);
} }
......
...@@ -54,7 +54,7 @@ public class SwigNativeConverter { ...@@ -54,7 +54,7 @@ public class SwigNativeConverter {
VectMap toReturn = new VectMap(); VectMap toReturn = new VectMap();
for (HashMap<String, String> aTodecode : todecode) { for (HashMap<String, String> aTodecode : todecode) {
toReturn.add(new StringMap(aTodecode)); toReturn.add(StringMap.toSwig(aTodecode));
} }
return toReturn; return toReturn;
} }
...@@ -76,7 +76,7 @@ public class SwigNativeConverter { ...@@ -76,7 +76,7 @@ public class SwigNativeConverter {
} }
public static ArrayList<String> convertSwigToNative(StringVect vector) { public static ArrayList<String> convertSwigToNative(StringVect vector) {
ArrayList<String> toReturn = new ArrayList<String>(); ArrayList<String> toReturn = new ArrayList<>();
for (int i = 0; i < vector.size(); ++i) { for (int i = 0; i < vector.size(); ++i) {
toReturn.add(vector.get(i)); toReturn.add(vector.get(i));
} }
......
...@@ -49,7 +49,7 @@ public: ...@@ -49,7 +49,7 @@ public:
virtual void certificateStateChanged(const std::string& /*account_id*/, const std::string& /*certId*/, const std::string& /*state*/){} virtual void certificateStateChanged(const std::string& /*account_id*/, const std::string& /*certId*/, const std::string& /*state*/){}
virtual void errorAlert(int alert){} virtual void errorAlert(int alert){}
virtual std::vector<int32_t> configGetHardwareAudioFormat(void){} virtual void getHardwareAudioFormat(std::vector<int32_t>* /*params_ret*/){}
}; };
%} %}
...@@ -186,5 +186,5 @@ public: ...@@ -186,5 +186,5 @@ public:
virtual void certificateStateChanged(const std::string& /*account_id*/, const std::string& /*certId*/, const std::string& /*state*/){} virtual void certificateStateChanged(const std::string& /*account_id*/, const std::string& /*certId*/, const std::string& /*state*/){}
virtual void errorAlert(int alert){} virtual void errorAlert(int alert){}
virtual std::vector<int32_t> configGetHardwareAudioFormat(void){} virtual void getHardwareAudioFormat(std::vector<int32_t>* /*params_ret*/){}
}; };
\ No newline at end of file
...@@ -63,62 +63,64 @@ ...@@ -63,62 +63,64 @@
namespace std { namespace std {
%typemap(javacode) map<string, string> %{ %typemap(javacode) map<string, string> %{
public $javaclassname(java.util.Map<String,String> in) { public static $javaclassname toSwig(java.util.Map<String,String> in) {
for (java.util.Map.Entry<String, String> entry : in.entrySet()) { $javaclassname n = new $javaclassname();
this.set(entry.getKey(), entry.getValue()); for (java.util.Map.Entry<String, String> entry : in.entrySet()) {
} n.set(entry.getKey(), entry.getValue());
}
public java.util.Map<String,String> toNative() {
java.util.Map<String,String> out = new java.util.HashMap<String,String>();
StringVect keys = keys();
for (String s : keys)
out.put(s, get(s));
return out;
}
%}
%extend map<string, string> {
std::vector<std::string> keys() const {
std::vector<std::string> k;
k.reserve($self->size());
for (const auto& i : *$self)
k.push_back(i.first);
return k;
}
} }
%template(StringMap) map<string, string>; return n;
}
%typemap(javabase) vector<string> "java.util.AbstractList<String>" public java.util.Map<String,String> toNative() {
%typemap(javainterface) vector<string> "java.util.RandomAccess" java.util.Map<String,String> out = new java.util.HashMap<String,String>();
%extend vector<string> { StringVect keys = keys();
value_type set(int i, const value_type& in) throw (std::out_of_range) { for (String s : keys)
const std::string old = $self->at(i); out.put(s, get(s));
$self->at(i) = in; return out;
return old; }
} %}
bool add(const value_type& in) { %extend map<string, string> {
$self->push_back(in); std::vector<std::string> keys() const {
return true; std::vector<std::string> k;
} k.reserve($self->size());
int32_t size() const { for (const auto& i : *$self)
return $self->size(); k.push_back(i.first);
} return k;
} }
%template(StringVect) vector<string>; }
%template(StringMap) map<string, string>;
%typemap(javacode) vector< map<string,string> > %{
public java.util.ArrayList<java.util.Map<String, String>> toNative() { %typemap(javabase) vector<string> "java.util.AbstractList<String>"
java.util.ArrayList<java.util.Map<String, String>> out = new java.util.ArrayList<>(); %typemap(javainterface) vector<string> "java.util.RandomAccess"
for (int i = 0; i < size(); ++i) %extend vector<string> {
out.add(get(i).toNative()); value_type set(int i, const value_type& in) throw (std::out_of_range) {
return out; const std::string old = $self->at(i);
} $self->at(i) = in;
%} return old;
%template(VectMap) vector< map<string,string> >; }
%template(IntegerMap) map<string,int>; bool add(const value_type& in) {
%template(IntVect) vector<int32_t>; $self->push_back(in);
%template(UintVect) vector<uint32_t>; return true;
%template(Blob) vector<uint8_t>; }
int32_t size() const {
return $self->size();
}
}
%template(StringVect) vector<string>;
%typemap(javacode) vector< map<string,string> > %{
public java.util.ArrayList<java.util.Map<String, String>> toNative() {
java.util.ArrayList<java.util.Map<String, String>> out = new java.util.ArrayList<>();
for (int i = 0; i < size(); ++i)
out.add(get(i).toNative());
return out;
}
%}
%template(VectMap) vector< map<string,string> >;
%template(IntegerMap) map<string,int>;
%template(IntVect) vector<int32_t>;
%template(UintVect) vector<uint32_t>;
%template(Blob) vector<uint8_t>;
} }
/* not parsed by SWIG but needed by generated C files */ /* not parsed by SWIG but needed by generated C files */
...@@ -194,6 +196,7 @@ void init(ConfigurationCallback* confM, Callback* callM) { ...@@ -194,6 +196,7 @@ void init(ConfigurationCallback* confM, Callback* callM) {
exportable_callback<ConfigurationSignal::CertificatePathPinned>(bind(&ConfigurationCallback::certificatePathPinned, confM, _1, _2 )), exportable_callback<ConfigurationSignal::CertificatePathPinned>(bind(&ConfigurationCallback::certificatePathPinned, confM, _1, _2 )),
exportable_callback<ConfigurationSignal::CertificateExpired>(bind(&ConfigurationCallback::certificateExpired, confM, _1 )), exportable_callback<ConfigurationSignal::CertificateExpired>(bind(&ConfigurationCallback::certificateExpired, confM, _1 )),
exportable_callback<ConfigurationSignal::CertificateStateChanged>(bind(&ConfigurationCallback::certificateStateChanged, confM, _1, _2, _3 )), exportable_callback<ConfigurationSignal::CertificateStateChanged>(bind(&ConfigurationCallback::certificateStateChanged, confM, _1, _2, _3 )),
exportable_callback<ConfigurationSignal::GetHardwareAudioFormat>(bind(&ConfigurationCallback::getHardwareAudioFormat, confM, _1 )),
}; };
/* /*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment