mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-03 20:46:28 +00:00
Handle Content-Encoding in C++ Content object.
This commit is contained in:
parent
307e27e635
commit
ead7221c97
6 changed files with 33 additions and 2 deletions
|
|
@ -310,6 +310,10 @@ void ClientGroupChatRoom::addParticipants (
|
|||
content.setBody(getResourceLists(addressesList));
|
||||
content.setContentType("application/resource-lists+xml");
|
||||
content.setContentDisposition("recipient-list");
|
||||
// TODO: Activate compression
|
||||
//if (linphone_core_content_encoding_supported(getCore()->getCCore(), "deflate"))
|
||||
// content.setContentEncoding("deflate");
|
||||
// TODO: Activate compression
|
||||
|
||||
shared_ptr<CallSession> session = dConference->focus->getPrivate()->getSession();
|
||||
if (session)
|
||||
|
|
|
|||
|
|
@ -372,6 +372,10 @@ void LocalConferenceEventHandlerPrivate::notifyParticipantDevice (const string &
|
|||
content,
|
||||
multipart ? "mixed;boundary=---------------------------14737809831466499882746641449" : "conference-info"
|
||||
);
|
||||
// TODO: Activate compression
|
||||
//if (linphone_core_content_encoding_supported(conf->getCore()->getCCore(), "deflate"))
|
||||
// linphone_content_set_encoding(content, "deflate");
|
||||
// TODO: Activate compression
|
||||
linphone_event_notify(ev, content);
|
||||
linphone_content_unref(content);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ private:
|
|||
std::vector<char> body;
|
||||
ContentType contentType;
|
||||
std::string contentDisposition;
|
||||
std::string contentEncoding;
|
||||
std::list<std::pair<std::string, std::string>> headers;
|
||||
|
||||
L_DECLARE_PUBLIC(Content);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ Content::Content (const Content &other) : ClonableObject(*new ContentPrivate), A
|
|||
L_D();
|
||||
d->body = other.getBody();
|
||||
d->contentType = other.getContentType();
|
||||
d->contentDisposition = other.getContentDisposition();;
|
||||
d->contentDisposition = other.getContentDisposition();
|
||||
d->contentEncoding = other.getContentEncoding();
|
||||
d->headers = other.getHeaders();
|
||||
}
|
||||
|
||||
|
|
@ -50,6 +51,7 @@ Content::Content (Content &&other) : ClonableObject(*new ContentPrivate), AppDat
|
|||
d->body = move(dOther->body);
|
||||
d->contentType = move(dOther->contentType);
|
||||
d->contentDisposition = move(dOther->contentDisposition);
|
||||
d->contentEncoding = move(dOther->contentEncoding);
|
||||
d->headers = move(dOther->headers);
|
||||
}
|
||||
|
||||
|
|
@ -71,6 +73,7 @@ Content &Content::operator= (const Content &other) {
|
|||
d->body = other.getBody();
|
||||
d->contentType = other.getContentType();
|
||||
d->contentDisposition = other.getContentDisposition();
|
||||
d->contentEncoding = other.getContentEncoding();
|
||||
d->headers = other.getHeaders();
|
||||
}
|
||||
return *this;
|
||||
|
|
@ -83,6 +86,7 @@ Content &Content::operator= (Content &&other) {
|
|||
d->body = move(dOther->body);
|
||||
d->contentType = move(dOther->contentType);
|
||||
d->contentDisposition = move(dOther->contentDisposition);
|
||||
d->contentEncoding = move(dOther->contentEncoding);
|
||||
d->headers = move(dOther->headers);
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -92,6 +96,7 @@ bool Content::operator== (const Content &other) const {
|
|||
return d->contentType == other.getContentType() &&
|
||||
d->body == other.getBody() &&
|
||||
d->contentDisposition == other.getContentDisposition() &&
|
||||
d->contentEncoding == other.getContentEncoding() &&
|
||||
d->headers == other.getHeaders();
|
||||
}
|
||||
|
||||
|
|
@ -120,6 +125,16 @@ void Content::setContentDisposition (const string &contentDisposition) {
|
|||
d->contentDisposition = contentDisposition;
|
||||
}
|
||||
|
||||
const string &Content::getContentEncoding () const {
|
||||
L_D();
|
||||
return d->contentEncoding;
|
||||
}
|
||||
|
||||
void Content::setContentEncoding (const string &contentEncoding) {
|
||||
L_D();
|
||||
d->contentEncoding = contentEncoding;
|
||||
}
|
||||
|
||||
const vector<char> &Content::getBody () const {
|
||||
L_D();
|
||||
return d->body;
|
||||
|
|
|
|||
|
|
@ -54,6 +54,9 @@ public:
|
|||
const std::string &getContentDisposition () const;
|
||||
void setContentDisposition (const std::string &contentDisposition);
|
||||
|
||||
const std::string &getContentEncoding () const;
|
||||
void setContentEncoding (const std::string &contentEncoding);
|
||||
|
||||
const std::vector<char> &getBody () const;
|
||||
std::string getBodyAsString () const;
|
||||
std::string getBodyAsUtf8String () const;
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ belle_sip_header_allow_t *SalCallOp::create_allow(bool_t enable_update) {
|
|||
int SalCallOp::set_custom_body(belle_sip_message_t *msg, const Content &body) {
|
||||
ContentType contentType = body.getContentType();
|
||||
string contentDisposition = body.getContentDisposition();
|
||||
string contentEncoding = body.getContentEncoding();
|
||||
size_t bodySize = body.getBody().size();
|
||||
|
||||
if (bodySize > SIP_MESSAGE_BODY_LIMIT) {
|
||||
|
|
@ -118,12 +119,15 @@ int SalCallOp::set_custom_body(belle_sip_message_t *msg, const Content &body) {
|
|||
belle_sip_header_content_disposition_t *contentDispositionHeader = belle_sip_header_content_disposition_create(contentDisposition.c_str());
|
||||
belle_sip_message_add_header(msg, BELLE_SIP_HEADER(contentDispositionHeader));
|
||||
}
|
||||
if (!contentEncoding.empty())
|
||||
belle_sip_message_add_header(msg, belle_sip_header_create("Content-Encoding", contentEncoding.c_str()));
|
||||
belle_sip_header_content_length_t *content_length = belle_sip_header_content_length_create(bodySize);
|
||||
belle_sip_message_add_header(msg, BELLE_SIP_HEADER(content_length));
|
||||
|
||||
if (bodySize > 0) {
|
||||
char *buffer = bctbx_new(char, bodySize);
|
||||
char *buffer = bctbx_new(char, bodySize + 1);
|
||||
memcpy(buffer, body.getBody().data(), bodySize);
|
||||
buffer[bodySize] = '\0';
|
||||
belle_sip_message_assign_body(msg, buffer, bodySize);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue