Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linphone-desktop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
linphone-desktop
Commits
7ac68672
Commit
7ac68672
authored
Apr 05, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(src/components/codecs): remove proxy
parent
37797ea0
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
134 additions
and
251 deletions
+134
-251
CMakeLists.txt
linphone-desktop/CMakeLists.txt
+0
-2
AbstractCodecsModel.cpp
...one-desktop/src/components/codecs/AbstractCodecsModel.cpp
+95
-5
AbstractCodecsModel.hpp
...one-desktop/src/components/codecs/AbstractCodecsModel.hpp
+35
-4
AudioCodecsModel.cpp
linphone-desktop/src/components/codecs/AudioCodecsModel.cpp
+2
-6
AudioCodecsModel.hpp
linphone-desktop/src/components/codecs/AudioCodecsModel.hpp
+0
-3
CodecsModel.cpp
linphone-desktop/src/components/codecs/CodecsModel.cpp
+0
-136
CodecsModel.hpp
linphone-desktop/src/components/codecs/CodecsModel.hpp
+0
-79
VideoCodecsModel.cpp
linphone-desktop/src/components/codecs/VideoCodecsModel.cpp
+2
-6
VideoCodecsModel.hpp
linphone-desktop/src/components/codecs/VideoCodecsModel.hpp
+0
-3
CoreManager.cpp
linphone-desktop/src/components/core/CoreManager.cpp
+0
-1
CoreManager.hpp
linphone-desktop/src/components/core/CoreManager.hpp
+0
-6
No files found.
linphone-desktop/CMakeLists.txt
View file @
7ac68672
...
...
@@ -94,7 +94,6 @@ set(SOURCES
src/components/chat/ChatProxyModel.cpp
src/components/codecs/AbstractCodecsModel.cpp
src/components/codecs/AudioCodecsModel.cpp
src/components/codecs/CodecsModel.cpp
src/components/codecs/VideoCodecsModel.cpp
src/components/contact/ContactModel.cpp
src/components/contact/VcardModel.cpp
...
...
@@ -130,7 +129,6 @@ set(HEADERS
src/components/calls/CallsListModel.hpp
src/components/chat/ChatModel.hpp
src/components/chat/ChatProxyModel.hpp
src/components/codecs/CodecsModel.hpp
src/components/codecs/AbstractCodecsModel.hpp
src/components/codecs/AudioCodecsModel.hpp
src/components/codecs/VideoCodecsModel.hpp
...
...
linphone-desktop/src/components/codecs/AbstractCodecsModel.cpp
View file @
7ac68672
/*
* Abstract
CodecsModel.c
pp
* Abstract
AbstractCodecsModel.cBase::
pp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* This program is free software; you can redistribute it and/or
...
...
@@ -20,15 +20,105 @@
* Author: Ronan Abhamon
*/
#include "CodecsModel.hpp"
#include <linphone++/linphone.hh>
#include "../../utils.hpp"
#include "AbstractCodecsModel.hpp"
// =============================================================================
AbstractCodecsModel
::
AbstractCodecsModel
(
QObject
*
parent
)
:
QSortFilterProxyModel
(
parent
)
{}
AbstractCodecsModel
::
AbstractCodecsModel
(
QObject
*
parent
)
:
QAbstractListModel
(
parent
)
{}
int
AbstractCodecsModel
::
rowCount
(
const
QModelIndex
&
)
const
{
return
m_codecs
.
count
();
}
QHash
<
int
,
QByteArray
>
AbstractCodecsModel
::
roleNames
()
const
{
QHash
<
int
,
QByteArray
>
roles
;
roles
[
Qt
::
DisplayRole
]
=
"$codec"
;
return
roles
;
}
QVariant
AbstractCodecsModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
{
int
row
=
index
.
row
();
if
(
!
index
.
isValid
()
||
row
<
0
||
row
>=
m_codecs
.
count
())
return
QVariant
();
if
(
role
==
Qt
::
DisplayRole
)
return
m_codecs
[
row
];
return
QVariant
();
}
bool
AbstractCodecsModel
::
moveRow
(
const
QModelIndex
&
source_parent
,
int
source_row
,
const
QModelIndex
&
destination_parent
,
int
destination_child
)
{
return
moveRows
(
source_parent
,
source_row
,
1
,
destination_parent
,
destination_child
);
}
bool
AbstractCodecsModel
::
moveRows
(
const
QModelIndex
&
source_parent
,
int
source_row
,
int
count
,
const
QModelIndex
&
destination_parent
,
int
destination_child
)
{
int
limit
=
source_row
+
count
-
1
;
if
(
source_row
<
0
||
count
<
0
||
limit
>=
m_codecs
.
count
())
return
false
;
beginMoveRows
(
source_parent
,
source_row
,
limit
,
destination_parent
,
destination_child
);
if
(
destination_child
<
source_row
)
{
for
(
int
i
=
source_row
;
i
<=
limit
;
++
i
)
m_codecs
.
move
(
source_row
,
destination_child
+
i
-
source_row
);
}
else
{
for
(
int
i
=
source_row
;
i
<=
limit
;
++
i
)
m_codecs
.
move
(
source_row
,
destination_child
+
i
);
}
endRemoveRows
();
return
true
;
}
// -----------------------------------------------------------------------------
void
AbstractCodecsModel
::
enableCodec
(
int
id
,
bool
status
)
{
QModelIndex
source_index
=
mapToSource
(
index
(
id
,
0
));
static_cast
<
CodecsModel
*>
(
sourceModel
())
->
enableCodec
(
source_index
.
row
(),
status
);
Q_ASSERT
(
id
>=
0
&&
id
<
m_codecs
.
count
());
QVariantMap
&
map
=
m_codecs
[
id
];
shared_ptr
<
linphone
::
PayloadType
>
codec
=
map
.
value
(
"__codec"
).
value
<
shared_ptr
<
linphone
::
PayloadType
>
>
();
codec
->
enable
(
status
);
map
[
"enabled"
]
=
status
;
emit
dataChanged
(
index
(
id
,
0
),
index
(
id
,
0
));
}
// -----------------------------------------------------------------------------
void
AbstractCodecsModel
::
addCodec
(
std
::
shared_ptr
<
linphone
::
PayloadType
>
&
codec
)
{
QVariantMap
map
;
map
[
"bitrate"
]
=
codec
->
getNormalBitrate
();
map
[
"channels"
]
=
codec
->
getChannels
();
map
[
"clockRate"
]
=
codec
->
getClockRate
();
map
[
"description"
]
=
::
Utils
::
linphoneStringToQString
(
codec
->
getDescription
());
map
[
"enabled"
]
=
codec
->
enabled
();
map
[
"encoderDescription"
]
=
::
Utils
::
linphoneStringToQString
(
codec
->
getEncoderDescription
());
map
[
"isUsable"
]
=
codec
->
isUsable
();
map
[
"isVbr"
]
=
codec
->
isVbr
();
map
[
"mime"
]
=
::
Utils
::
linphoneStringToQString
(
codec
->
getMimeType
());
map
[
"number"
]
=
codec
->
getNumber
();
map
[
"recvFmtp"
]
=
::
Utils
::
linphoneStringToQString
(
codec
->
getRecvFmtp
());
map
[
"__codec"
]
=
QVariant
::
fromValue
(
codec
);
m_codecs
<<
map
;
}
linphone-desktop/src/components/codecs/AbstractCodecsModel.hpp
View file @
7ac68672
...
...
@@ -23,21 +23,52 @@
#ifndef ABSTRACT_CODECS_MODEL_H_
#define ABSTRACT_CODECS_MODEL_H_
#include <QSortFilterProxyModel>
#include <memory>
#include <QAbstractListModel>
// =============================================================================
class
AbstractCodecsModel
:
public
QSortFilterProxyModel
{
namespace
linphone
{
class
PayloadType
;
}
class
AbstractCodecsModel
:
public
QAbstractListModel
{
Q_OBJECT
;
public:
AbstractCodecsModel
(
QObject
*
parent
=
Q_NULLPTR
);
virtual
~
AbstractCodecsModel
()
=
default
;
Q_INVOKABLE
void
enableCodec
(
int
id
,
bool
status
);
int
rowCount
(
const
QModelIndex
&
index
=
QModelIndex
())
const
override
;
QHash
<
int
,
QByteArray
>
roleNames
()
const
override
;
QVariant
data
(
const
QModelIndex
&
index
,
int
role
=
Qt
::
DisplayRole
)
const
override
;
bool
moveRow
(
const
QModelIndex
&
source_parent
,
int
source_row
,
const
QModelIndex
&
destination_parent
,
int
destination_child
);
bool
moveRows
(
const
QModelIndex
&
source_parent
,
int
source_row
,
int
count
,
const
QModelIndex
&
destination_parent
,
int
destination_child
)
override
;
void
enableCodec
(
int
id
,
bool
status
);
protected:
virtual
bool
filterAcceptsRow
(
int
source_row
,
const
QModelIndex
&
source_parent
)
const
override
=
0
;
void
addCodec
(
std
::
shared_ptr
<
linphone
::
PayloadType
>
&
codec
);
private:
QList
<
QVariantMap
>
m_codecs
;
};
Q_DECLARE_METATYPE
(
std
::
shared_ptr
<
linphone
::
PayloadType
>
);
#endif // ABSTRACT_CODECS_MODEL_H_
linphone-desktop/src/components/codecs/AudioCodecsModel.cpp
View file @
7ac68672
...
...
@@ -27,10 +27,6 @@
// =============================================================================
AudioCodecsModel
::
AudioCodecsModel
(
QObject
*
parent
)
:
AbstractCodecsModel
(
parent
)
{
setSourceModel
(
CoreManager
::
getInstance
()
->
getCodecsModel
());
}
bool
AudioCodecsModel
::
filterAcceptsRow
(
int
source_row
,
const
QModelIndex
&
source_parent
)
const
{
const
QModelIndex
&
index
=
sourceModel
()
->
index
(
source_row
,
0
,
source_parent
);
return
index
.
data
().
toMap
()[
"type"
]
==
CodecsModel
::
AudioCodec
;
for
(
auto
&
codec
:
CoreManager
::
getInstance
()
->
getCore
()
->
getAudioPayloadTypes
())
addCodec
(
codec
);
}
linphone-desktop/src/components/codecs/AudioCodecsModel.hpp
View file @
7ac68672
...
...
@@ -33,9 +33,6 @@ class AudioCodecsModel : public AbstractCodecsModel {
public:
AudioCodecsModel
(
QObject
*
parent
=
Q_NULLPTR
);
~
AudioCodecsModel
()
=
default
;
protected:
bool
filterAcceptsRow
(
int
source_row
,
const
QModelIndex
&
source_parent
)
const
override
;
};
#endif // AUDIO_CODECS_MODEL_H_
linphone-desktop/src/components/codecs/CodecsModel.cpp
deleted
100644 → 0
View file @
37797ea0
/*
* CodecsModel.cpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: April 3, 2017
* Author: Ronan Abhamon
*/
#include "../../utils.hpp"
#include "../core/CoreManager.hpp"
#include "CodecsModel.hpp"
// ============================================================================
template
<
typename
T
>
inline
void
addCodecToList
(
QList
<
QVariantMap
>
&
list
,
const
T
&
codec
,
CodecsModel
::
CodecType
type
)
{
QVariantMap
map
;
map
[
"bitrate"
]
=
codec
->
getNormalBitrate
();
map
[
"channels"
]
=
codec
->
getChannels
();
map
[
"clockRate"
]
=
codec
->
getClockRate
();
map
[
"description"
]
=
::
Utils
::
linphoneStringToQString
(
codec
->
getDescription
());
map
[
"enabled"
]
=
codec
->
enabled
();
map
[
"encoderDescription"
]
=
::
Utils
::
linphoneStringToQString
(
codec
->
getEncoderDescription
());
map
[
"isUsable"
]
=
codec
->
isUsable
();
map
[
"isVbr"
]
=
codec
->
isVbr
();
map
[
"mime"
]
=
::
Utils
::
linphoneStringToQString
(
codec
->
getMimeType
());
map
[
"number"
]
=
codec
->
getNumber
();
map
[
"type"
]
=
type
;
map
[
"recvFmtp"
]
=
::
Utils
::
linphoneStringToQString
(
codec
->
getRecvFmtp
());
map
[
"__codec"
]
=
QVariant
::
fromValue
(
codec
);
list
<<
map
;
}
// -----------------------------------------------------------------------------
CodecsModel
::
CodecsModel
(
QObject
*
parent
)
:
QAbstractListModel
(
parent
)
{
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
for
(
const
auto
&
codec
:
core
->
getAudioPayloadTypes
())
addCodecToList
(
m_codecs
,
codec
,
AudioCodec
);
for
(
const
auto
&
codec
:
core
->
getVideoPayloadTypes
())
addCodecToList
(
m_codecs
,
codec
,
VideoCodec
);
for
(
const
auto
&
codec
:
core
->
getTextPayloadTypes
())
addCodecToList
(
m_codecs
,
codec
,
TextCodec
);
}
int
CodecsModel
::
rowCount
(
const
QModelIndex
&
)
const
{
return
m_codecs
.
count
();
}
QHash
<
int
,
QByteArray
>
CodecsModel
::
roleNames
()
const
{
QHash
<
int
,
QByteArray
>
roles
;
roles
[
Qt
::
DisplayRole
]
=
"$codec"
;
return
roles
;
}
QVariant
CodecsModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
{
int
row
=
index
.
row
();
if
(
!
index
.
isValid
()
||
row
<
0
||
row
>=
m_codecs
.
count
())
return
QVariant
();
if
(
role
==
Qt
::
DisplayRole
)
return
m_codecs
[
row
];
return
QVariant
();
}
bool
CodecsModel
::
moveRow
(
const
QModelIndex
&
source_parent
,
int
source_row
,
const
QModelIndex
&
destination_parent
,
int
destination_child
)
{
return
moveRows
(
source_parent
,
source_row
,
1
,
destination_parent
,
destination_child
);
}
bool
CodecsModel
::
moveRows
(
const
QModelIndex
&
source_parent
,
int
source_row
,
int
count
,
const
QModelIndex
&
destination_parent
,
int
destination_child
)
{
int
limit
=
source_row
+
count
-
1
;
if
(
source_row
<
0
||
count
<
0
||
limit
>=
m_codecs
.
count
())
return
false
;
beginMoveRows
(
source_parent
,
source_row
,
limit
,
destination_parent
,
destination_child
);
if
(
destination_child
<
source_row
)
{
for
(
int
i
=
source_row
;
i
<=
limit
;
++
i
)
m_codecs
.
move
(
source_row
,
destination_child
+
i
-
source_row
);
}
else
{
for
(
int
i
=
source_row
;
i
<=
limit
;
++
i
)
m_codecs
.
move
(
source_row
,
destination_child
+
i
);
}
endRemoveRows
();
return
true
;
}
// -----------------------------------------------------------------------------
void
CodecsModel
::
enableCodec
(
int
id
,
bool
status
)
{
Q_ASSERT
(
id
>=
0
&&
id
<
m_codecs
.
count
());
QVariantMap
&
map
=
m_codecs
[
id
];
shared_ptr
<
linphone
::
PayloadType
>
codec
=
map
.
value
(
"__codec"
).
value
<
shared_ptr
<
linphone
::
PayloadType
>
>
();
codec
->
enable
(
status
);
map
[
"enabled"
]
=
status
;
emit
dataChanged
(
index
(
id
,
0
),
index
(
id
,
0
));
}
linphone-desktop/src/components/codecs/CodecsModel.hpp
deleted
100644 → 0
View file @
37797ea0
/*
* CodecsModel.hpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Created on: April 3, 2017
* Author: Ronan Abhamon
*/
#ifndef CODECS_MODEL_H_
#define CODECS_MODEL_H_
#include <memory>
#include <QAbstractListModel>
// =============================================================================
namespace
linphone
{
class
PayloadType
;
}
class
CodecsModel
:
public
QAbstractListModel
{
Q_OBJECT
;
public:
enum
CodecType
{
AudioCodec
,
VideoCodec
,
TextCodec
};
Q_ENUMS
(
CodecType
);
CodecsModel
(
QObject
*
parent
=
Q_NULLPTR
);
~
CodecsModel
()
=
default
;
int
rowCount
(
const
QModelIndex
&
index
=
QModelIndex
())
const
override
;
QHash
<
int
,
QByteArray
>
roleNames
()
const
override
;
QVariant
data
(
const
QModelIndex
&
index
,
int
role
=
Qt
::
DisplayRole
)
const
override
;
bool
moveRow
(
const
QModelIndex
&
source_parent
,
int
source_row
,
const
QModelIndex
&
destination_parent
,
int
destination_child
);
bool
moveRows
(
const
QModelIndex
&
source_parent
,
int
source_row
,
int
count
,
const
QModelIndex
&
destination_parent
,
int
destination_child
)
override
;
void
enableCodec
(
int
id
,
bool
status
);
private:
QList
<
QVariantMap
>
m_codecs
;
};
Q_DECLARE_METATYPE
(
std
::
shared_ptr
<
linphone
::
PayloadType
>
);
#endif // CODECS_MODEL_H_
linphone-desktop/src/components/codecs/VideoCodecsModel.cpp
View file @
7ac68672
...
...
@@ -27,10 +27,6 @@
// =============================================================================
VideoCodecsModel
::
VideoCodecsModel
(
QObject
*
parent
)
:
AbstractCodecsModel
(
parent
)
{
setSourceModel
(
CoreManager
::
getInstance
()
->
getCodecsModel
());
}
bool
VideoCodecsModel
::
filterAcceptsRow
(
int
source_row
,
const
QModelIndex
&
source_parent
)
const
{
const
QModelIndex
&
index
=
sourceModel
()
->
index
(
source_row
,
0
,
source_parent
);
return
index
.
data
().
toMap
()[
"type"
]
==
CodecsModel
::
VideoCodec
;
for
(
auto
&
codec
:
CoreManager
::
getInstance
()
->
getCore
()
->
getVideoPayloadTypes
())
addCodec
(
codec
);
}
linphone-desktop/src/components/codecs/VideoCodecsModel.hpp
View file @
7ac68672
...
...
@@ -33,9 +33,6 @@ class VideoCodecsModel : public AbstractCodecsModel {
public:
VideoCodecsModel
(
QObject
*
parent
=
Q_NULLPTR
);
~
VideoCodecsModel
()
=
default
;
protected:
bool
filterAcceptsRow
(
int
source_row
,
const
QModelIndex
&
source_parent
)
const
override
;
};
#endif // VIDEO_CODECS_MODEL_H_
linphone-desktop/src/components/core/CoreManager.cpp
View file @
7ac68672
...
...
@@ -44,7 +44,6 @@ CoreManager::CoreManager (QObject *parent, const QString &config_path) : QObject
m_instance
->
m_calls_list_model
=
new
CallsListModel
(
m_instance
);
m_instance
->
m_contacts_list_model
=
new
ContactsListModel
(
m_instance
);
m_instance
->
m_sip_addresses_model
=
new
SipAddressesModel
(
m_instance
);
m_instance
->
m_codecs_model
=
new
CodecsModel
(
m_instance
);
m_instance
->
m_settings_model
=
new
SettingsModel
(
m_instance
);
emit
m_instance
->
linphoneCoreCreated
();
...
...
linphone-desktop/src/components/core/CoreManager.hpp
View file @
7ac68672
...
...
@@ -24,7 +24,6 @@
#define CORE_MANAGER_H_
#include "../calls/CallsListModel.hpp"
#include "../codecs/CodecsModel.hpp"
#include "../contacts/ContactsListModel.hpp"
#include "../settings/SettingsModel.hpp"
#include "../sip-addresses/SipAddressesModel.hpp"
...
...
@@ -83,10 +82,6 @@ public:
return
m_sip_addresses_model
;
}
CodecsModel
*
getCodecsModel
()
const
{
return
m_codecs_model
;
}
SettingsModel
*
getSettingsModel
()
const
{
return
m_settings_model
;
}
...
...
@@ -129,7 +124,6 @@ private:
CallsListModel
*
m_calls_list_model
;
ContactsListModel
*
m_contacts_list_model
;
SipAddressesModel
*
m_sip_addresses_model
;
CodecsModel
*
m_codecs_model
;
SettingsModel
*
m_settings_model
;
QTimer
*
m_cbs_timer
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment