incorporated changes for recursive acquiring of playlists
see issue http://bugs.campware.org/view.php?id=1438
This commit is contained in:
parent
89bcc935e5
commit
b3b80d424f
2 changed files with 126 additions and 45 deletions
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: maroy $
|
Author : $Author: maroy $
|
||||||
Version : $Revision: 1.48 $
|
Version : $Revision: 1.49 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -43,7 +43,6 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||||
#include <XmlRpcClient.h>
|
#include <XmlRpcClient.h>
|
||||||
#include <XmlRpcValue.h>
|
|
||||||
#include <XmlRpcUtil.h>
|
#include <XmlRpcUtil.h>
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include <curl/easy.h>
|
#include <curl/easy.h>
|
||||||
|
@ -64,6 +63,7 @@ using namespace XmlRpc;
|
||||||
using namespace LiveSupport::Core;
|
using namespace LiveSupport::Core;
|
||||||
using namespace LiveSupport::Storage;
|
using namespace LiveSupport::Storage;
|
||||||
|
|
||||||
|
|
||||||
/* =================================================== local data structures */
|
/* =================================================== local data structures */
|
||||||
|
|
||||||
|
|
||||||
|
@ -409,6 +409,11 @@ static const std::string getPlaylistUrlParamName = "url";
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
static const std::string getPlaylistTokenParamName = "token";
|
static const std::string getPlaylistTokenParamName = "token";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The name of the content parameter returned (for open) or input (for close)
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
static const std::string getPlaylistContentParamName = "content";
|
||||||
|
|
||||||
|
|
||||||
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ storage server constants: editPlaylist */
|
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ storage server constants: editPlaylist */
|
||||||
|
|
||||||
|
@ -914,7 +919,8 @@ WebStorageClient :: existsPlaylist(Ptr<SessionId>::Ref sessionId,
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
Ptr<Playlist>::Ref
|
Ptr<Playlist>::Ref
|
||||||
WebStorageClient :: getPlaylist(Ptr<SessionId>::Ref sessionId,
|
WebStorageClient :: getPlaylist(Ptr<SessionId>::Ref sessionId,
|
||||||
Ptr<UniqueId>::Ref id) const
|
Ptr<UniqueId>::Ref id,
|
||||||
|
bool deep) const
|
||||||
throw (Core::XmlRpcException)
|
throw (Core::XmlRpcException)
|
||||||
{
|
{
|
||||||
EditedPlaylistsType::const_iterator
|
EditedPlaylistsType::const_iterator
|
||||||
|
@ -932,12 +938,9 @@ WebStorageClient :: getPlaylist(Ptr<SessionId>::Ref sessionId,
|
||||||
storageServerPath.c_str(), false);
|
storageServerPath.c_str(), false);
|
||||||
|
|
||||||
parameters.clear();
|
parameters.clear();
|
||||||
parameters[getPlaylistSessionIdParamName]
|
parameters[getPlaylistSessionIdParamName] = sessionId->getId();
|
||||||
= sessionId->getId();
|
parameters[getPlaylistPlaylistIdParamName] = std::string(*id);
|
||||||
parameters[getPlaylistPlaylistIdParamName]
|
parameters[getPlaylistRecursiveParamName] = deep;
|
||||||
= std::string(*id);
|
|
||||||
parameters[getPlaylistRecursiveParamName]
|
|
||||||
= false;
|
|
||||||
|
|
||||||
result.clear();
|
result.clear();
|
||||||
if (!xmlRpcClient.execute(getPlaylistOpenMethodName.c_str(),
|
if (!xmlRpcClient.execute(getPlaylistOpenMethodName.c_str(),
|
||||||
|
@ -957,7 +960,6 @@ WebStorageClient :: getPlaylist(Ptr<SessionId>::Ref sessionId,
|
||||||
<< result;
|
<< result;
|
||||||
throw Core::XmlRpcMethodFaultException(eMsg.str());
|
throw Core::XmlRpcMethodFaultException(eMsg.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! result.hasMember(getPlaylistUrlParamName)
|
if (! result.hasMember(getPlaylistUrlParamName)
|
||||||
|| result[getPlaylistUrlParamName].getType()
|
|| result[getPlaylistUrlParamName].getType()
|
||||||
!= XmlRpcValue::TypeString
|
!= XmlRpcValue::TypeString
|
||||||
|
@ -993,6 +995,10 @@ WebStorageClient :: getPlaylist(Ptr<SessionId>::Ref sessionId,
|
||||||
"error parsing playlist metafile");
|
"error parsing playlist metafile");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (deep) {
|
||||||
|
playlist = acquirePlaylist(playlist, result);
|
||||||
|
}
|
||||||
|
|
||||||
parameters.clear();
|
parameters.clear();
|
||||||
parameters[getPlaylistSessionIdParamName] = sessionId->getId();
|
parameters[getPlaylistSessionIdParamName] = sessionId->getId();
|
||||||
parameters[getPlaylistTokenParamName] = token;
|
parameters[getPlaylistTokenParamName] = token;
|
||||||
|
@ -1075,6 +1081,9 @@ WebStorageClient :: editPlaylist(Ptr<SessionId>::Ref sessionId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Opens the playlist for editing, and returns its URL.
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
WebStorageClient :: editPlaylistGetUrl(Ptr<SessionId>::Ref sessionId,
|
WebStorageClient :: editPlaylistGetUrl(Ptr<SessionId>::Ref sessionId,
|
||||||
Ptr<UniqueId>::Ref id,
|
Ptr<UniqueId>::Ref id,
|
||||||
|
@ -1267,12 +1276,12 @@ WebStorageClient :: revertPlaylist(Ptr<const std::string>::Ref playlistToken)
|
||||||
* Acquire resources for a playlist.
|
* Acquire resources for a playlist.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
Ptr<Playlist>::Ref
|
Ptr<Playlist>::Ref
|
||||||
WebStorageClient :: acquirePlaylist(Ptr<SessionId>::Ref sessionId,
|
WebStorageClient :: acquirePlaylist(Ptr<Playlist>::Ref oldPlaylist,
|
||||||
Ptr<UniqueId>::Ref id) const
|
XmlRpcValue & result) const
|
||||||
throw (Core::XmlRpcException)
|
throw (Core::XmlRpcException)
|
||||||
{
|
{
|
||||||
Ptr<Playlist>::Ref oldPlaylist = getPlaylist(sessionId, id);
|
XmlRpcValue content;
|
||||||
|
int index;
|
||||||
Ptr<time_duration>::Ref playlength = oldPlaylist->getPlaylength();
|
Ptr<time_duration>::Ref playlength = oldPlaylist->getPlaylength();
|
||||||
Ptr<Playlist>::Ref newPlaylist(new Playlist(oldPlaylist->getId(),
|
Ptr<Playlist>::Ref newPlaylist(new Playlist(oldPlaylist->getId(),
|
||||||
playlength));
|
playlength));
|
||||||
|
@ -1293,31 +1302,53 @@ WebStorageClient :: acquirePlaylist(Ptr<SessionId>::Ref sessionId,
|
||||||
= smilBodyNode->add_child(smilParNodeName);
|
= smilBodyNode->add_child(smilParNodeName);
|
||||||
|
|
||||||
Playlist::const_iterator it = oldPlaylist->begin();
|
Playlist::const_iterator it = oldPlaylist->begin();
|
||||||
|
if (result.hasMember(getPlaylistContentParamName)) {
|
||||||
|
content = result[getPlaylistContentParamName];
|
||||||
|
}
|
||||||
|
// if there is no content parameter, leave the original, empty content
|
||||||
|
|
||||||
|
index = 0;
|
||||||
|
// assume that it is as long as the size of the content array
|
||||||
while (it != oldPlaylist->end()) {
|
while (it != oldPlaylist->end()) {
|
||||||
Ptr<PlaylistElement>::Ref plElement = it->second;
|
Ptr<PlaylistElement>::Ref plElement = it->second;
|
||||||
Ptr<time_duration>::Ref relativeOffset
|
Ptr<time_duration>::Ref relativeOffset
|
||||||
= plElement->getRelativeOffset();
|
= plElement->getRelativeOffset();
|
||||||
Ptr<FadeInfo>::Ref fadeInfo = plElement->getFadeInfo();
|
Ptr<FadeInfo>::Ref fadeInfo = plElement->getFadeInfo();
|
||||||
|
|
||||||
Ptr<Playable>::Ref playable;
|
if (index >= content.size()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
XmlRpcValue contents = content[index];
|
||||||
|
++index;
|
||||||
|
if (!contents.hasMember(getPlaylistUrlParamName)) {
|
||||||
|
// TODO: maybe signal error?
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ptr<Playable>::Ref playable;
|
||||||
|
Ptr<const std::string>::Ref url;
|
||||||
|
Ptr<AudioClip>::Ref audioClip;
|
||||||
|
Ptr<Playlist>::Ref playlist;
|
||||||
switch (plElement->getType()) {
|
switch (plElement->getType()) {
|
||||||
case PlaylistElement::AudioClipType :
|
case PlaylistElement::AudioClipType :
|
||||||
playable = acquireAudioClip(sessionId, plElement
|
url.reset(new std::string(contents[getPlaylistUrlParamName]));
|
||||||
->getAudioClip()
|
audioClip.reset(new AudioClip(*plElement->getAudioClip()));
|
||||||
->getId());
|
audioClip->setUri(url);
|
||||||
|
url.reset();
|
||||||
|
newPlaylist->addPlayable(audioClip, relativeOffset, fadeInfo);
|
||||||
|
playable = audioClip;
|
||||||
break;
|
break;
|
||||||
case PlaylistElement::PlaylistType :
|
case PlaylistElement::PlaylistType :
|
||||||
playable = acquirePlaylist(sessionId, plElement
|
playlist.reset(new Playlist(*plElement->getPlaylist()));
|
||||||
->getPlaylist()
|
playlist = acquirePlaylist(playlist, contents);
|
||||||
->getId());
|
newPlaylist->addPlayable(playlist, relativeOffset, fadeInfo);
|
||||||
|
playable = playlist;
|
||||||
break;
|
break;
|
||||||
default : // this should never happen
|
default : // this should never happen
|
||||||
throw XmlRpcInvalidArgumentException(
|
throw XmlRpcInvalidArgumentException(
|
||||||
"unexpected playlist element type "
|
"unexpected playlist element type "
|
||||||
"(neither audio clip nor playlist)");
|
"(neither audio clip nor playlist)");
|
||||||
}
|
}
|
||||||
newPlaylist->addPlayable(playable, relativeOffset, fadeInfo);
|
|
||||||
|
|
||||||
xmlpp::Element* smilPlayableNode
|
xmlpp::Element* smilPlayableNode
|
||||||
= smilParNode->add_child(smilPlayableNodeName);
|
= smilParNode->add_child(smilPlayableNodeName);
|
||||||
|
@ -1440,13 +1471,8 @@ WebStorageClient :: releasePlaylist(Ptr<Playlist>::Ref playlist) const
|
||||||
while (it != playlist->end()) {
|
while (it != playlist->end()) {
|
||||||
Ptr<PlaylistElement>::Ref plElement = it->second;
|
Ptr<PlaylistElement>::Ref plElement = it->second;
|
||||||
if (plElement->getType() == PlaylistElement::AudioClipType) {
|
if (plElement->getType() == PlaylistElement::AudioClipType) {
|
||||||
try {
|
// don't have to release, as it will be done by the storage server
|
||||||
releaseAudioClip(it->second->getAudioClip());
|
// for clips inside the playlist
|
||||||
}
|
|
||||||
catch (XmlRpcException &e) {
|
|
||||||
eMsg += e.what();
|
|
||||||
eMsg += "\n";
|
|
||||||
}
|
|
||||||
++it;
|
++it;
|
||||||
} else if (plElement->getType() == PlaylistElement::PlaylistType) {
|
} else if (plElement->getType() == PlaylistElement::PlaylistType) {
|
||||||
try {
|
try {
|
||||||
|
@ -1457,8 +1483,9 @@ WebStorageClient :: releasePlaylist(Ptr<Playlist>::Ref playlist) const
|
||||||
eMsg += "\n";
|
eMsg += "\n";
|
||||||
}
|
}
|
||||||
++it;
|
++it;
|
||||||
} else { // this should never happen
|
} else {
|
||||||
eMsg += "unexpected playlist element type\n";
|
// this should never happen
|
||||||
|
eMsg += "unexpected playlist element type\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2230,7 +2257,7 @@ WebStorageClient :: getAllPlaylists(Ptr<SessionId>::Ref sessionId,
|
||||||
playlists->push_back(getPlaylist(sessionId, *it));
|
playlists->push_back(getPlaylist(sessionId, *it));
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
|
||||||
return playlists;
|
return playlists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
Author : $Author: maroy $
|
||||||
Version : $Revision: 1.32 $
|
Version : $Revision: 1.33 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.h,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.h,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -42,6 +42,8 @@
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
#include <XmlRpcValue.h>
|
||||||
|
|
||||||
#include "LiveSupport/Core/Playlist.h"
|
#include "LiveSupport/Core/Playlist.h"
|
||||||
#include "LiveSupport/Core/Configurable.h"
|
#include "LiveSupport/Core/Configurable.h"
|
||||||
#include "LiveSupport/Storage/StorageClientInterface.h"
|
#include "LiveSupport/Storage/StorageClientInterface.h"
|
||||||
|
@ -50,6 +52,8 @@
|
||||||
namespace LiveSupport {
|
namespace LiveSupport {
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
|
|
||||||
|
using namespace XmlRpc;
|
||||||
|
|
||||||
using namespace LiveSupport;
|
using namespace LiveSupport;
|
||||||
using namespace LiveSupport::Core;
|
using namespace LiveSupport::Core;
|
||||||
|
|
||||||
|
@ -95,8 +99,8 @@ using namespace LiveSupport::Core;
|
||||||
* <!ATTLIST location path CDATA #REQUIRED >
|
* <!ATTLIST location path CDATA #REQUIRED >
|
||||||
* </code></pre>
|
* </code></pre>
|
||||||
*
|
*
|
||||||
* @author $Author: fgerlits $
|
* @author $Author: maroy $
|
||||||
* @version $Revision: 1.32 $
|
* @version $Revision: 1.33 $
|
||||||
*/
|
*/
|
||||||
class WebStorageClient :
|
class WebStorageClient :
|
||||||
virtual public Configurable,
|
virtual public Configurable,
|
||||||
|
@ -140,6 +144,18 @@ class WebStorageClient :
|
||||||
*/
|
*/
|
||||||
EditedPlaylistsType editedPlaylists;
|
EditedPlaylistsType editedPlaylists;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A vector containing the unique IDs of the audio clips returned
|
||||||
|
* by reset() (for testing) or by search().
|
||||||
|
*/
|
||||||
|
Ptr<std::vector<Ptr<UniqueId>::Ref> >::Ref audioClipIds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A vector containing the unique IDs of the playlists returned
|
||||||
|
* by reset() (for testing) or by search().
|
||||||
|
*/
|
||||||
|
Ptr<std::vector<Ptr<UniqueId>::Ref> >::Ref playlistIds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Auxilliary method used by editPlaylist() and createPlaylist().
|
* Auxilliary method used by editPlaylist() and createPlaylist().
|
||||||
* Opens the playlist for editing, and returns its URL.
|
* Opens the playlist for editing, and returns its URL.
|
||||||
|
@ -160,16 +176,47 @@ class WebStorageClient :
|
||||||
throw (XmlRpcException);
|
throw (XmlRpcException);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A vector containing the unique IDs of the audio clips returned
|
* Return a playlist with the specified id to be displayed.
|
||||||
* by reset() (for testing) or by search().
|
* If the playlist is being edited, and this method is called
|
||||||
|
* by the same user who is editing the playlist,
|
||||||
|
* (i.e., the method is called with the same sessionId and playlistId
|
||||||
|
* that editPlaylist() was), then the working copy of the playlist
|
||||||
|
* is returned.
|
||||||
|
* Any other user gets the old (pre-editPlaylist()) copy from storage.
|
||||||
|
*
|
||||||
|
* @param sessionId the session ID from the authentication client
|
||||||
|
* @param id the id of the playlist to return.
|
||||||
|
* @param deep signal if all playable objects are to be accessed
|
||||||
|
* and locked, that are referenced by this playlist, or
|
||||||
|
* any playlist contained in this one.
|
||||||
|
* @return the requested playlist.
|
||||||
|
* @exception XmlRpcInvalidDataException if the audio clip we got
|
||||||
|
* from the storage is invalid.
|
||||||
|
* @exception XmlRpcException if there is a problem with the XML-RPC
|
||||||
|
* call or no playlist with the specified id exists.
|
||||||
*/
|
*/
|
||||||
Ptr<std::vector<Ptr<UniqueId>::Ref> >::Ref audioClipIds;
|
Ptr<Playlist>::Ref
|
||||||
|
getPlaylist(Ptr<SessionId>::Ref sessionId,
|
||||||
|
Ptr<UniqueId>::Ref id,
|
||||||
|
bool deep) const
|
||||||
|
throw (XmlRpcException);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A vector containing the unique IDs of the playlists returned
|
* Do the final stages of acquring a playlist: generate SMIL
|
||||||
* by reset() (for testing) or by search().
|
* files, etc.
|
||||||
|
*
|
||||||
|
* @param oldPlaylist the playlist to work on.
|
||||||
|
* @param result the XML-RPC result from getPlaylist() call
|
||||||
|
* with deep == true
|
||||||
|
* @return a playlist which has a URI filed, and all things below
|
||||||
|
* it are openned properly and processed as well.
|
||||||
|
* @exception XmlRpcException if there is a problem with the XML-RPC
|
||||||
|
* call or no playlist with the specified id exists.
|
||||||
*/
|
*/
|
||||||
Ptr<std::vector<Ptr<UniqueId>::Ref> >::Ref playlistIds;
|
Ptr<Playlist>::Ref
|
||||||
|
acquirePlaylist(Ptr<Playlist>::Ref oldPlaylist,
|
||||||
|
XmlRpcValue & result) const
|
||||||
|
throw (XmlRpcException);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -266,8 +313,10 @@ class WebStorageClient :
|
||||||
virtual Ptr<Playlist>::Ref
|
virtual Ptr<Playlist>::Ref
|
||||||
getPlaylist(Ptr<SessionId>::Ref sessionId,
|
getPlaylist(Ptr<SessionId>::Ref sessionId,
|
||||||
Ptr<UniqueId>::Ref id) const
|
Ptr<UniqueId>::Ref id) const
|
||||||
throw (XmlRpcException);
|
throw (XmlRpcException)
|
||||||
|
{
|
||||||
|
return getPlaylist(sessionId, id, false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a playlist with the specified id to be edited.
|
* Return a playlist with the specified id to be edited.
|
||||||
|
@ -352,7 +401,12 @@ class WebStorageClient :
|
||||||
virtual Ptr<Playlist>::Ref
|
virtual Ptr<Playlist>::Ref
|
||||||
acquirePlaylist(Ptr<SessionId>::Ref sessionId,
|
acquirePlaylist(Ptr<SessionId>::Ref sessionId,
|
||||||
Ptr<UniqueId>::Ref id) const
|
Ptr<UniqueId>::Ref id) const
|
||||||
throw (XmlRpcException);
|
throw (XmlRpcException)
|
||||||
|
{
|
||||||
|
// FIXME: silently, with deep == true, getPlaylist will also
|
||||||
|
// generate all related SMIL files, etc.
|
||||||
|
return getPlaylist(sessionId, id, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Release the resources (audio clips, other playlists) used
|
* Release the resources (audio clips, other playlists) used
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue