half-finished the rewrite of acquirePlaylist(); committed for backup

This commit is contained in:
fgerlits 2005-07-01 16:13:53 +00:00
parent d30d0e1423
commit 42f420efea
2 changed files with 184 additions and 115 deletions

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.39 $ Version : $Revision: 1.40 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClient.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/TestStorageClient.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -87,46 +87,85 @@ static const std::string smilLanguageAttrName = "xmlns";
static const std::string smilLanguageAttrValue static const std::string smilLanguageAttrValue
= "http://www.w3.org/2001/SMIL20/Language"; = "http://www.w3.org/2001/SMIL20/Language";
/*------------------------------------------------------------------------------
* The name of the SMIL real networks extension attribute.
*----------------------------------------------------------------------------*/
static const std::string smilExtensionsAttrName = "xmlns:rn";
/*------------------------------------------------------------------------------
* The value of the SMIL real networks extension attribute.
*----------------------------------------------------------------------------*/
static const std::string smilExtensionsAttrValue
= "http://features.real.com/2001/SMIL20/Extensions";
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* The name of the body node in the SMIL file. * The name of the body node in the SMIL file.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
static const std::string smilBodyNodeName = "body"; static const std::string smilBodyNodeName = "body";
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* The name of the sequential audio clip list node in the SMIL file. * The name of the parallel audio clip list node in the SMIL file.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
static const std::string smilSeqNodeName = "seq"; static const std::string smilParNodeName = "par";
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* The name of the audio clip element node in the SMIL file. * The name of the audio clip or playlist element node in the SMIL file.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
static const std::string smilAudioClipNodeName = "audio"; static const std::string smilPlayableNodeName = "audio";
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* The name of the attribute containing the URI of the audio clip element. * The name of the attribute containing the URI of the Playable element.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
static const std::string smilAudioClipUriAttrName = "src"; static const std::string smilPlayableUriAttrName = "src";
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* The name of the sub-playlist element node in the SMIL file. * The name of the attribute containing the relative offset of the element.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
static const std::string smilPlaylistNodeName = "audio"; static const std::string smilRelativeOffsetAttrName = "begin";
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* The name of the attribute containing the URI of the sub-playlist element. * The name of the animation element in the SMIL file.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
static const std::string smilPlaylistUriAttrName = "src"; static const std::string smilAnimateNodeName = "animate";
/*------------------------------------------------------------------------------
* The name of the "attribute name" attribute of the animation element.
*----------------------------------------------------------------------------*/
static const std::string smilAnimateNameAttrName = "attributeName";
/*------------------------------------------------------------------------------
* The value of the "attribute name" attribute of the animation element.
*----------------------------------------------------------------------------*/
static const std::string smilAnimateNameAttrValue = "soundLevel";
/*------------------------------------------------------------------------------
* The name of the starting sound level % attribute of the animation element.
*----------------------------------------------------------------------------*/
static const std::string smilAnimateFromAttrName = "from";
/*------------------------------------------------------------------------------
* The name of the ending sound level % attribute of the animation element.
*----------------------------------------------------------------------------*/
static const std::string smilAnimateToAttrName = "to";
/*------------------------------------------------------------------------------
* The name of the "calculation mode" attribute of the animation element.
*----------------------------------------------------------------------------*/
static const std::string smilAnimateCalcModeAttrName = "calcMode";
/*------------------------------------------------------------------------------
* The value of the "calculation mode" attribute of the animation element.
*----------------------------------------------------------------------------*/
static const std::string smilAnimateCalcModeAttrValue = "linear";
/*------------------------------------------------------------------------------
* The name of the rel. offset of the start of the animation attribute.
*----------------------------------------------------------------------------*/
static const std::string smilAnimateBeginAttrName = "begin";
/*------------------------------------------------------------------------------
* The name of the rel. offset of the end of the animation attribute.
*----------------------------------------------------------------------------*/
static const std::string smilAnimateEndAttrName = "end";
/*------------------------------------------------------------------------------
* The name of the "what to do after done" attribute of the animation element.
*----------------------------------------------------------------------------*/
static const std::string smilAnimateFillAttrName = "fill";
/*------------------------------------------------------------------------------
* The value of the "what to do after done" attribute of the animation element.
*----------------------------------------------------------------------------*/
static const std::string smilAnimateFillAttrValue = "freeze";
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* The version string, returned by getVersion * The version string, returned by getVersion
@ -419,13 +458,11 @@ TestStorageClient :: acquirePlaylist(Ptr<SessionId>::Ref sessionId,
= smilDocument->create_root_node(smilRootNodeName); = smilDocument->create_root_node(smilRootNodeName);
smilRootNode->set_attribute(smilLanguageAttrName, smilRootNode->set_attribute(smilLanguageAttrName,
smilLanguageAttrValue); smilLanguageAttrValue);
smilRootNode->set_attribute(smilExtensionsAttrName,
smilExtensionsAttrValue);
xmlpp::Element * smilBodyNode xmlpp::Element * smilBodyNode
= smilRootNode->add_child(smilBodyNodeName); = smilRootNode->add_child(smilBodyNodeName);
xmlpp::Element * smilSeqNode xmlpp::Element * smilParNode
= smilBodyNode->add_child(smilSeqNodeName); = smilBodyNode->add_child(smilParNodeName);
Playlist::const_iterator it = oldPlaylist->begin(); Playlist::const_iterator it = oldPlaylist->begin();
@ -433,41 +470,44 @@ TestStorageClient :: acquirePlaylist(Ptr<SessionId>::Ref sessionId,
Ptr<PlaylistElement>::Ref plElement = it->second; Ptr<PlaylistElement>::Ref plElement = it->second;
Ptr<FadeInfo>::Ref fadeInfo = plElement->getFadeInfo(); Ptr<FadeInfo>::Ref fadeInfo = plElement->getFadeInfo();
if (plElement->getType() == PlaylistElement::AudioClipType) { Ptr<time_duration>::Ref
Ptr<AudioClip>::Ref audioClip relativeOffset = plElement->getRelativeOffset();
= acquireAudioClip(sessionId, plElement
->getAudioClip()
->getId());
Ptr<time_duration>::Ref relativeOffset
= plElement->getRelativeOffset();
newPlaylist->addAudioClip(audioClip, relativeOffset, fadeInfo);
xmlpp::Element* smilAudioClipNode long offsetMilliseconds = relativeOffset->total_milliseconds();
= smilSeqNode->add_child(smilAudioClipNodeName); std::stringstream offsetStringStream;
smilAudioClipNode->set_attribute( offsetStringStream << offsetMilliseconds / 1000l
smilAudioClipUriAttrName, << '.'
*(audioClip->getUri()) ); << offsetMilliseconds % 1000
++it; << 's';
} else if (plElement->getType() == PlaylistElement::PlaylistType) {
Ptr<Playlist>::Ref playlist
= acquirePlaylist(sessionId, plElement
->getPlaylist()
->getId());
Ptr<time_duration>::Ref relativeOffset
= plElement->getRelativeOffset();
newPlaylist->addPlaylist(playlist, relativeOffset, fadeInfo);
xmlpp::Element* smilPlaylistNode Ptr<Playable>::Ref playable;
= smilSeqNode->add_child(smilPlaylistNodeName); switch (plElement->getType()) {
smilPlaylistNode->set_attribute( case PlaylistElement::AudioClipType :
smilPlaylistUriAttrName, playable = acquireAudioClip(sessionId, plElement
*(playlist->getUri()) ); ->getAudioClip()
++it; ->getId());
} else { // this should never happen break;
throw XmlRpcInvalidArgumentException( case PlaylistElement::PlaylistType :
playable = acquirePlaylist(sessionId, plElement
->getPlaylist()
->getId());
break;
default : // this should never happen
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
= smilParNode->add_child(smilPlayableNodeName);
smilPlayableNode->set_attribute(
smilPlayableUriAttrName,
*(playable->getUri()) );
smilPlayableNode->set_attribute(
smilRelativeOffsetAttrName,
offsetStringStream.str() );
++it;
} }
@ -475,7 +515,7 @@ TestStorageClient :: acquirePlaylist(Ptr<SessionId>::Ref sessionId,
fileName << localTempStorage << std::string(*newPlaylist->getId()) fileName << localTempStorage << std::string(*newPlaylist->getId())
<< "-" << std::rand() << ".smil"; << "-" << std::rand() << ".smil";
smilDocument->write_to_file(fileName.str(), "UTF-8"); smilDocument->write_to_file_formatted(fileName.str(), "UTF-8");
Ptr<std::string>::Ref playlistUri(new std::string(fileName.str())); Ptr<std::string>::Ref playlistUri(new std::string(fileName.str()));
newPlaylist->setUri(playlistUri); newPlaylist->setUri(playlistUri);

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.43 $ Version : $Revision: 1.44 $
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 $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -124,17 +124,6 @@ static const std::string smilLanguageAttrName = "xmlns";
static const std::string smilLanguageAttrValue static const std::string smilLanguageAttrValue
= "http://www.w3.org/2001/SMIL20/Language"; = "http://www.w3.org/2001/SMIL20/Language";
/*------------------------------------------------------------------------------
* The name of the SMIL real networks extension attribute.
*----------------------------------------------------------------------------*/
static const std::string smilExtensionsAttrName = "xmlns:rn";
/*------------------------------------------------------------------------------
* The value of the SMIL real networks extension attribute.
*----------------------------------------------------------------------------*/
static const std::string smilExtensionsAttrValue
= "http://features.real.com/2001/SMIL20/Extensions";
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* The name of the body node in the SMIL file. * The name of the body node in the SMIL file.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
@ -146,25 +135,75 @@ static const std::string smilBodyNodeName = "body";
static const std::string smilParNodeName = "par"; static const std::string smilParNodeName = "par";
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* The name of the audio clip element node in the SMIL file. * The name of the audio clip or playlist element node in the SMIL file.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
static const std::string smilAudioClipNodeName = "audio"; static const std::string smilPlayableNodeName = "audio";
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* The name of the sub-playlist element node in the SMIL file. * The name of the attribute containing the URI of the Playable element.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
static const std::string smilPlaylistNodeName = "audio"; static const std::string smilPlayableUriAttrName = "src";
/*------------------------------------------------------------------------------
* The name of the attribute containing the URI of the element.
*----------------------------------------------------------------------------*/
static const std::string smilUriAttrName = "src";
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* The name of the attribute containing the relative offset of the element. * The name of the attribute containing the relative offset of the element.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
static const std::string smilRelativeOffsetAttrName = "begin"; static const std::string smilRelativeOffsetAttrName = "begin";
/*------------------------------------------------------------------------------
* The name of the animation element in the SMIL file.
*----------------------------------------------------------------------------*/
static const std::string smilAnimateNodeName = "animate";
/*------------------------------------------------------------------------------
* The name of the "attribute name" attribute of the animation element.
*----------------------------------------------------------------------------*/
static const std::string smilAnimateNameAttrName = "attributeName";
/*------------------------------------------------------------------------------
* The value of the "attribute name" attribute of the animation element.
*----------------------------------------------------------------------------*/
static const std::string smilAnimateNameAttrValue = "soundLevel";
/*------------------------------------------------------------------------------
* The name of the starting sound level % attribute of the animation element.
*----------------------------------------------------------------------------*/
static const std::string smilAnimateFromAttrName = "from";
/*------------------------------------------------------------------------------
* The name of the ending sound level % attribute of the animation element.
*----------------------------------------------------------------------------*/
static const std::string smilAnimateToAttrName = "to";
/*------------------------------------------------------------------------------
* The name of the "calculation mode" attribute of the animation element.
*----------------------------------------------------------------------------*/
static const std::string smilAnimateCalcModeAttrName = "calcMode";
/*------------------------------------------------------------------------------
* The value of the "calculation mode" attribute of the animation element.
*----------------------------------------------------------------------------*/
static const std::string smilAnimateCalcModeAttrValue = "linear";
/*------------------------------------------------------------------------------
* The name of the rel. offset of the start of the animation attribute.
*----------------------------------------------------------------------------*/
static const std::string smilAnimateBeginAttrName = "begin";
/*------------------------------------------------------------------------------
* The name of the rel. offset of the end of the animation attribute.
*----------------------------------------------------------------------------*/
static const std::string smilAnimateEndAttrName = "end";
/*------------------------------------------------------------------------------
* The name of the "what to do after done" attribute of the animation element.
*----------------------------------------------------------------------------*/
static const std::string smilAnimateFillAttrName = "fill";
/*------------------------------------------------------------------------------
* The value of the "what to do after done" attribute of the animation element.
*----------------------------------------------------------------------------*/
static const std::string smilAnimateFillAttrValue = "freeze";
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ storage server constants: error reports */ /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ storage server constants: error reports */
@ -1155,8 +1194,6 @@ WebStorageClient :: acquirePlaylist(Ptr<SessionId>::Ref sessionId,
= smilDocument->create_root_node(smilRootNodeName); = smilDocument->create_root_node(smilRootNodeName);
smilRootNode->set_attribute(smilLanguageAttrName, smilRootNode->set_attribute(smilLanguageAttrName,
smilLanguageAttrValue); smilLanguageAttrValue);
smilRootNode->set_attribute(smilExtensionsAttrName,
smilExtensionsAttrValue);
xmlpp::Element * smilBodyNode xmlpp::Element * smilBodyNode
= smilRootNode->add_child(smilBodyNodeName); = smilRootNode->add_child(smilBodyNodeName);
@ -1179,50 +1216,42 @@ WebStorageClient :: acquirePlaylist(Ptr<SessionId>::Ref sessionId,
<< offsetMilliseconds % 1000 << offsetMilliseconds % 1000
<< 's'; << 's';
if (plElement->getType() == PlaylistElement::AudioClipType) { Ptr<Playable>::Ref playable;
Ptr<AudioClip>::Ref audioClip switch (plElement->getType()) {
= acquireAudioClip(sessionId, plElement case PlaylistElement::AudioClipType :
->getAudioClip() playable = acquireAudioClip(sessionId, plElement
->getId()); ->getAudioClip()
newPlaylist->addAudioClip(audioClip, relativeOffset, fadeInfo); ->getId());
break;
xmlpp::Element* smilAudioClipNode case PlaylistElement::PlaylistType :
= smilParNode->add_child(smilAudioClipNodeName); playable = acquirePlaylist(sessionId, plElement
smilAudioClipNode->set_attribute( ->getPlaylist()
smilUriAttrName, ->getId());
*(audioClip->getUri()) ); break;
smilAudioClipNode->set_attribute( default : // this should never happen
smilRelativeOffsetAttrName, throw XmlRpcInvalidArgumentException(
offsetStringStream.str() );
++it;
} else if (plElement->getType() == PlaylistElement::PlaylistType) {
Ptr<Playlist>::Ref playlist
= acquirePlaylist(sessionId, plElement
->getPlaylist()
->getId());
newPlaylist->addPlaylist(playlist, relativeOffset, fadeInfo);
xmlpp::Element* smilPlaylistNode
= smilParNode->add_child(smilPlaylistNodeName);
smilPlaylistNode->set_attribute(
smilUriAttrName,
*(playlist->getUri()) );
smilPlaylistNode->set_attribute(
smilRelativeOffsetAttrName,
offsetStringStream.str() );
++it;
} else { // this should never happen
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
= smilParNode->add_child(smilPlayableNodeName);
smilPlayableNode->set_attribute(
smilPlayableUriAttrName,
*(playable->getUri()) );
smilPlayableNode->set_attribute(
smilRelativeOffsetAttrName,
offsetStringStream.str() );
++it;
} }
std::stringstream fileName; std::stringstream fileName;
fileName << localTempStorage << std::string(*newPlaylist->getId()) fileName << localTempStorage << std::string(*newPlaylist->getId())
<< "-" << std::rand() << ".smil"; << "-" << std::rand() << ".smil";
smilDocument->write_to_file(fileName.str(), "UTF-8"); smilDocument->write_to_file_formatted(fileName.str(), "UTF-8");
Ptr<std::string>::Ref playlistUri(new std::string(fileName.str())); Ptr<std::string>::Ref playlistUri(new std::string(fileName.str()));
newPlaylist->setUri(playlistUri); newPlaylist->setUri(playlistUri);