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
94665113
Commit
94665113
authored
Apr 25, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(app): add a `SoundPlayer` component
parent
4078767c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
250 additions
and
0 deletions
+250
-0
CMakeLists.txt
linphone-desktop/CMakeLists.txt
+2
-0
App.cpp
linphone-desktop/src/app/App.cpp
+1
-0
Components.hpp
linphone-desktop/src/components/Components.hpp
+6
-0
SoundPlayer.cpp
linphone-desktop/src/components/sound-player/SoundPlayer.cpp
+152
-0
SoundPlayer.hpp
linphone-desktop/src/components/sound-player/SoundPlayer.hpp
+89
-0
No files found.
linphone-desktop/CMakeLists.txt
View file @
94665113
...
...
@@ -114,6 +114,7 @@ set(SOURCES
src/components/sip-addresses/SipAddressesModel.cpp
src/components/sip-addresses/SipAddressObserver.cpp
src/components/smart-search-bar/SmartSearchBarModel.cpp
src/components/sound-player/SoundPlayer.cpp
src/components/timeline/TimelineModel.cpp
src/externals/single-application/SingleApplication.cpp
src/main.cpp
...
...
@@ -154,6 +155,7 @@ set(HEADERS
src/components/sip-addresses/SipAddressesModel.hpp
src/components/sip-addresses/SipAddressObserver.hpp
src/components/smart-search-bar/SmartSearchBarModel.hpp
src/components/sound-player/SoundPlayer.hpp
src/components/timeline/TimelineModel.hpp
src/externals/single-application/SingleApplication.hpp
src/externals/single-application/SingleApplicationPrivate.hpp
...
...
linphone-desktop/src/app/App.cpp
View file @
94665113
...
...
@@ -293,6 +293,7 @@ void App::registerTypes () {
qmlRegisterType
<
ChatProxyModel
>
(
"Linphone"
,
1
,
0
,
"ChatProxyModel"
);
qmlRegisterType
<
ContactsListProxyModel
>
(
"Linphone"
,
1
,
0
,
"ContactsListProxyModel"
);
qmlRegisterType
<
SmartSearchBarModel
>
(
"Linphone"
,
1
,
0
,
"SmartSearchBarModel"
);
qmlRegisterType
<
SoundPlayer
>
(
"Linphone"
,
1
,
0
,
"SoundPlayer"
);
qRegisterMetaType
<
ChatModel
::
EntryType
>
(
"ChatModel::EntryType"
);
...
...
linphone-desktop/src/components/Components.hpp
View file @
94665113
...
...
@@ -20,6 +20,9 @@
* Author: Ronan Abhamon
*/
#ifndef COMPONENTS_H_
#define COMPONENTS_H_
#include "assistant/AssistantModel.hpp"
#include "authentication/Authentication.hpp"
#include "calls/CallsListModel.hpp"
...
...
@@ -33,4 +36,7 @@
#include "presence/OwnPresenceModel.hpp"
#include "settings/AccountSettingsModel.hpp"
#include "smart-search-bar/SmartSearchBarModel.hpp"
#include "sound-player/SoundPlayer.hpp"
#include "timeline/TimelineModel.hpp"
#endif // COMPONENTS_H_
linphone-desktop/src/components/sound-player/SoundPlayer.cpp
0 → 100644
View file @
94665113
/*
* SoundPlayer.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 25, 2017
* Author: Ronan Abhamon
*/
#include "../../Utils.hpp"
#include "../core/CoreManager.hpp"
#include "SoundPlayer.hpp"
// =============================================================================
SoundPlayer
::
SoundPlayer
(
QObject
*
parent
)
:
QObject
(
parent
)
{
mInternalPlayer
=
CoreManager
::
getInstance
()
->
getCore
()
->
createLocalPlayer
(
""
,
""
,
nullptr
);
}
// -----------------------------------------------------------------------------
void
SoundPlayer
::
pause
()
{
if
(
mPlaybackState
==
SoundPlayer
::
PausedState
)
return
;
if
(
mInternalPlayer
->
pause
())
{
setError
(
QStringLiteral
(
"Unable to pause: `%1`"
).
arg
(
mSource
));
return
;
}
mPlaybackState
=
SoundPlayer
::
PausedState
;
emit
paused
();
emit
playbackStateChanged
(
mPlaybackState
);
}
void
SoundPlayer
::
play
()
{
if
(
mPlaybackState
==
SoundPlayer
::
PlayingState
)
return
;
if
(
(
mPlaybackState
==
SoundPlayer
::
StoppedState
||
mPlaybackState
==
SoundPlayer
::
ErrorState
)
&&
mInternalPlayer
->
open
(
::
Utils
::
qStringToLinphoneString
(
mSource
))
)
{
qWarning
()
<<
QStringLiteral
(
"Unable to open: `%1`"
).
arg
(
mSource
);
return
;
}
if
(
mInternalPlayer
->
start
()
)
{
setError
(
QStringLiteral
(
"Unable to play: `%1`"
).
arg
(
mSource
));
return
;
}
mPlaybackState
=
SoundPlayer
::
PlayingState
;
emit
playing
();
emit
playbackStateChanged
(
mPlaybackState
);
}
void
SoundPlayer
::
stop
()
{
if
(
mPlaybackState
==
SoundPlayer
::
StoppedState
)
return
;
mInternalPlayer
->
close
();
mPlaybackState
=
SoundPlayer
::
StoppedState
;
emit
stopped
();
emit
playbackStateChanged
(
mPlaybackState
);
}
// -----------------------------------------------------------------------------
void
SoundPlayer
::
seek
(
int
offset
)
{
mInternalPlayer
->
seek
(
offset
);
}
// -----------------------------------------------------------------------------
int
SoundPlayer
::
getPosition
()
const
{
return
mInternalPlayer
->
getCurrentPosition
();
}
// -----------------------------------------------------------------------------
void
SoundPlayer
::
setError
(
const
QString
&
message
)
{
qWarning
()
<<
message
;
mInternalPlayer
->
close
();
if
(
mPlaybackState
!=
SoundPlayer
::
ErrorState
)
{
mPlaybackState
=
SoundPlayer
::
ErrorState
;
emit
playbackStateChanged
(
mPlaybackState
);
}
}
// -----------------------------------------------------------------------------
QString
SoundPlayer
::
getSource
()
const
{
return
mSource
;
}
void
SoundPlayer
::
setSource
(
const
QString
&
source
)
{
if
(
source
==
mSource
)
return
;
stop
();
mSource
=
source
;
emit
sourceChanged
(
source
);
}
// -----------------------------------------------------------------------------
SoundPlayer
::
PlaybackState
SoundPlayer
::
getPlaybackState
()
const
{
return
mPlaybackState
;
}
void
SoundPlayer
::
setPlaybackState
(
PlaybackState
playbackState
)
{
switch
(
playbackState
)
{
case
PlayingState
:
play
();
break
;
case
PausedState
:
pause
();
break
;
case
StoppedState
:
stop
();
break
;
case
ErrorState
:
break
;
}
}
// -----------------------------------------------------------------------------
int
SoundPlayer
::
getDuration
()
const
{
return
mInternalPlayer
->
getDuration
();
}
linphone-desktop/src/components/sound-player/SoundPlayer.hpp
0 → 100644
View file @
94665113
/*
* SoundPlayer.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 25, 2017
* Author: Ronan Abhamon
*/
#ifndef SOUND_PLAYER_H_
#define SOUND_PLAYER_H_
#include <memory>
#include <QObject>
// =============================================================================
namespace
linphone
{
class
Player
;
}
class
SoundPlayer
:
public
QObject
{
Q_OBJECT
;
Q_PROPERTY
(
QString
source
READ
getSource
WRITE
setSource
NOTIFY
sourceChanged
);
Q_PROPERTY
(
PlaybackState
playbackState
READ
getPlaybackState
WRITE
setPlaybackState
NOTIFY
playbackStateChanged
);
Q_PROPERTY
(
int
duration
READ
getDuration
NOTIFY
sourceChanged
);
public:
enum
PlaybackState
{
PlayingState
,
PausedState
,
StoppedState
,
ErrorState
};
Q_ENUM
(
PlaybackState
);
SoundPlayer
(
QObject
*
parent
=
Q_NULLPTR
);
~
SoundPlayer
()
=
default
;
void
pause
();
void
play
();
void
stop
();
void
seek
(
int
offset
);
int
getPosition
()
const
;
signals:
void
sourceChanged
(
const
QString
&
source
);
void
paused
();
void
playing
();
void
stopped
();
void
playbackStateChanged
(
PlaybackState
playbackState
);
private:
void
setError
(
const
QString
&
message
);
QString
getSource
()
const
;
void
setSource
(
const
QString
&
source
);
PlaybackState
getPlaybackState
()
const
;
void
setPlaybackState
(
PlaybackState
playbackState
);
int
getDuration
()
const
;
std
::
shared_ptr
<
linphone
::
Player
>
mInternalPlayer
;
QString
mSource
;
PlaybackState
mPlaybackState
=
StoppedState
;
};
#endif // SOUND_PLAYER_H_
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