mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 19:18:06 +00:00
fix regressions in handling of payload types, due to change in library way to handle PayloadTypes
This commit is contained in:
parent
89e36acf31
commit
a4a56ffd77
6 changed files with 43 additions and 38 deletions
|
|
@ -34,11 +34,11 @@ AudioCodecGetCommand::AudioCodecGetCommand() :
|
|||
}
|
||||
|
||||
void AudioCodecGetCommand::exec(Daemon *app, const char *args) {
|
||||
int ptnum;
|
||||
bool list = false;
|
||||
bool found = false;
|
||||
istringstream ist(args);
|
||||
ostringstream ost;
|
||||
PayloadType *pt=NULL;
|
||||
|
||||
if (ist.peek() == EOF) {
|
||||
found = list = true;
|
||||
|
|
@ -50,7 +50,7 @@ void AudioCodecGetCommand::exec(Daemon *app, const char *args) {
|
|||
app->sendResponse(Response("Incorrect mime type format.", Response::Error));
|
||||
return;
|
||||
}
|
||||
ptnum = parser.payloadTypeNumber();
|
||||
pt = parser.getPayloadType();
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
|
|
@ -58,7 +58,7 @@ void AudioCodecGetCommand::exec(Daemon *app, const char *args) {
|
|||
PayloadType *payload = reinterpret_cast<PayloadType*>(node->data);
|
||||
if (list) {
|
||||
ost << PayloadTypeResponse(app->getCore(), payload, index).getBody() << "\n";
|
||||
} else if (ptnum == linphone_core_get_payload_type_number(app->getCore(), payload)) {
|
||||
} else if (pt == payload) {
|
||||
ost << PayloadTypeResponse(app->getCore(), payload, index).getBody();
|
||||
found = true;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -49,7 +49,14 @@ void AudioCodecMoveCommand::exec(Daemon *app, const char *args) {
|
|||
app->sendResponse(Response("Incorrect mime type format.", Response::Error));
|
||||
return;
|
||||
}
|
||||
int ptnum = parser.payloadTypeNumber();
|
||||
PayloadType *selected_payload = NULL;
|
||||
selected_payload = parser.getPayloadType();
|
||||
|
||||
if (selected_payload == NULL) {
|
||||
app->sendResponse(Response("Audio codec not found.", Response::Error));
|
||||
return;
|
||||
}
|
||||
|
||||
int index;
|
||||
ist >> index;
|
||||
if (ist.fail() || (index < 0)) {
|
||||
|
|
@ -57,19 +64,6 @@ void AudioCodecMoveCommand::exec(Daemon *app, const char *args) {
|
|||
return;
|
||||
}
|
||||
|
||||
PayloadType *selected_payload = NULL;
|
||||
for (const MSList *node = linphone_core_get_audio_codecs(app->getCore()); node != NULL; node = ms_list_next(node)) {
|
||||
PayloadType *payload = reinterpret_cast<PayloadType*>(node->data);
|
||||
if (ptnum == linphone_core_get_payload_type_number(app->getCore(), payload)) {
|
||||
selected_payload = payload;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (selected_payload == NULL) {
|
||||
app->sendResponse(Response("Audio codec not found.", Response::Error));
|
||||
return;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
MSList *mslist = NULL;
|
||||
for (const MSList *node = linphone_core_get_audio_codecs(app->getCore()); node != NULL; node = ms_list_next(node)) {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ static PayloadType *findPayload(LinphoneCore *lc, int payload_type, int *index){
|
|||
PayloadType *payload = reinterpret_cast<PayloadType*>(node->data);
|
||||
if (index) (*index)++;
|
||||
if (payload_type == linphone_core_get_payload_type_number(lc, payload)) {
|
||||
|
||||
return payload;
|
||||
}
|
||||
}
|
||||
|
|
@ -75,7 +74,6 @@ void AudioCodecSetCommand::exec(Daemon *app, const char *args) {
|
|||
app->sendResponse(Response("Incorrect mime type format.", Response::Error));
|
||||
return;
|
||||
}
|
||||
int ptnum = parser.payloadTypeNumber();
|
||||
string param;
|
||||
string value;
|
||||
ist >> param;
|
||||
|
|
@ -86,9 +84,8 @@ void AudioCodecSetCommand::exec(Daemon *app, const char *args) {
|
|||
ist >> value;
|
||||
if (value.length() > 255) value.resize(255);
|
||||
|
||||
PayloadType *payload;
|
||||
int index;
|
||||
if ((payload = findPayload(app->getCore(), ptnum, &index)) != NULL) {
|
||||
PayloadType *payload=parser.getPayloadType();
|
||||
if (payload) {
|
||||
bool handled = false;
|
||||
if (param.compare("clock_rate") == 0) {
|
||||
if (value.length() > 0) {
|
||||
|
|
@ -103,19 +100,22 @@ void AudioCodecSetCommand::exec(Daemon *app, const char *args) {
|
|||
handled = true;
|
||||
} else if (param.compare("number") == 0) {
|
||||
if (value.length() > 0) {
|
||||
PayloadType *conflict = findPayload(app->getCore(), atoi(value.c_str()), NULL);
|
||||
int idx=atoi(value.c_str());
|
||||
PayloadType *conflict=NULL;
|
||||
if (idx!=-1){
|
||||
conflict=findPayload(app->getCore(), atoi(value.c_str()), NULL);
|
||||
}
|
||||
if (conflict) {
|
||||
app->sendResponse(Response("New payload type number is already used.", Response::Error));
|
||||
} else {
|
||||
int idx = atoi(value.c_str());
|
||||
linphone_core_set_payload_type_number(app->getCore(),payload, idx);
|
||||
app->sendResponse(PayloadTypeResponse(app->getCore(), payload, idx));
|
||||
app->sendResponse(PayloadTypeResponse(app->getCore(), payload, parser.getPosition()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (handled) {
|
||||
app->sendResponse(PayloadTypeResponse(app->getCore(), payload, index));
|
||||
app->sendResponse(PayloadTypeResponse(app->getCore(), payload, parser.getPosition()));
|
||||
} else {
|
||||
app->sendResponse(Response("Invalid codec parameter.", Response::Error));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,14 +14,14 @@ void AudioCodecToggleCommand::exec(Daemon *app, const char *args) {
|
|||
app->sendResponse(Response("Missing parameter.", Response::Error));
|
||||
} else {
|
||||
string mime_type;
|
||||
int ptnum = -1;
|
||||
PayloadType *pt = NULL;
|
||||
ist >> mime_type;
|
||||
PayloadTypeParser parser(app->getCore(), mime_type, true);
|
||||
if (!parser.successful()) {
|
||||
app->sendResponse(Response("Incorrect mime type format.", Response::Error));
|
||||
return;
|
||||
}
|
||||
if (!parser.all()) ptnum = parser.payloadTypeNumber();
|
||||
if (!parser.all()) pt = parser.getPayloadType();
|
||||
|
||||
int index = 0;
|
||||
for (const MSList *node = linphone_core_get_audio_codecs(app->getCore()); node != NULL; node = ms_list_next(node)) {
|
||||
|
|
@ -29,7 +29,7 @@ void AudioCodecToggleCommand::exec(Daemon *app, const char *args) {
|
|||
if (parser.all()) {
|
||||
linphone_core_enable_payload_type(app->getCore(), payload, mEnable);
|
||||
} else {
|
||||
if (ptnum == linphone_core_get_payload_type_number(app->getCore(), payload)) {
|
||||
if (pt == payload) {
|
||||
linphone_core_enable_payload_type(app->getCore(), payload, mEnable);
|
||||
app->sendResponse(PayloadTypeResponse(app->getCore(), payload, index));
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -233,13 +233,14 @@ PayloadTypeResponse::PayloadTypeResponse(LinphoneCore *core, const PayloadType *
|
|||
}
|
||||
}
|
||||
|
||||
PayloadTypeParser::PayloadTypeParser(LinphoneCore *core, const string &mime_type, bool accept_all) : mAll(false), mSuccesful(true), mPayloadTypeNumber(-1) {
|
||||
PayloadTypeParser::PayloadTypeParser(LinphoneCore *core, const string &mime_type, bool accept_all) : mAll(false), mSuccesful(true), mPayloadType(NULL),mPosition(-1){
|
||||
int number=-1;
|
||||
if (accept_all && (mime_type.compare("ALL") == 0)) {
|
||||
mAll = true;
|
||||
return;
|
||||
}
|
||||
istringstream ist(mime_type);
|
||||
ist >> mPayloadTypeNumber;
|
||||
ist >> number;
|
||||
if (ist.fail()) {
|
||||
char type[12];
|
||||
int rate, channels;
|
||||
|
|
@ -247,11 +248,15 @@ PayloadTypeParser::PayloadTypeParser(LinphoneCore *core, const string &mime_type
|
|||
mSuccesful = false;
|
||||
return;
|
||||
}
|
||||
const PayloadType *pt = linphone_core_find_payload_type(core, type, rate, channels);
|
||||
if (pt == NULL) {
|
||||
mPayloadTypeNumber = -1;
|
||||
} else {
|
||||
mPayloadTypeNumber = linphone_core_get_payload_type_number(core, pt);
|
||||
mPayloadType = linphone_core_find_payload_type(core, type, rate, channels);
|
||||
if (mPayloadType) mPosition=ms_list_index(linphone_core_get_audio_codecs(core), mPayloadType);
|
||||
}else if (number!=-1){
|
||||
const MSList *elem;
|
||||
for(elem=linphone_core_get_audio_codecs(core);elem!=NULL;elem=elem->next){
|
||||
if (number==linphone_core_get_payload_type_number(core,(PayloadType*)elem->data)){
|
||||
mPayloadType=(PayloadType*)elem->data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,11 +162,17 @@ public:
|
|||
PayloadTypeParser(LinphoneCore *core, const std::string &mime_type, bool accept_all = false);
|
||||
inline bool all() { return mAll; }
|
||||
inline bool successful() { return mSuccesful; }
|
||||
inline int payloadTypeNumber() { return mPayloadTypeNumber; }
|
||||
inline PayloadType * getPayloadType()const{
|
||||
return mPayloadType;
|
||||
}
|
||||
inline int getPosition()const{
|
||||
return mPosition;
|
||||
}
|
||||
private:
|
||||
bool mAll;
|
||||
bool mSuccesful;
|
||||
int mPayloadTypeNumber;
|
||||
PayloadType *mPayloadType;
|
||||
int mPosition;
|
||||
};
|
||||
|
||||
struct AudioStreamAndOther {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue