added support for clipStart and clipEnd
This commit is contained in:
parent
60518f7074
commit
f6c9fef31a
|
@ -748,6 +748,24 @@ class Playlist : public Configurable,
|
|||
Ptr<FadeInfo>::Ref fadeInfo)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Set clipStart for a playlist element.
|
||||
*
|
||||
*/
|
||||
void
|
||||
setClipStart(Ptr<UniqueId>::Ref playlistElementId,
|
||||
Ptr<time_duration>::Ref newStart)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Set clipEnd for a playlist element.
|
||||
*
|
||||
*/
|
||||
void
|
||||
setClipEnd(Ptr<UniqueId>::Ref playlistElementId,
|
||||
Ptr<time_duration>::Ref newEnd)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Remove a playlist element from the playlist.
|
||||
*
|
||||
|
|
|
@ -130,6 +130,8 @@ class PlaylistElement : public Configurable
|
|||
* The starting time of the event.
|
||||
*/
|
||||
Ptr<time_duration>::Ref relativeOffset;
|
||||
Ptr<time_duration>::Ref clipStart;
|
||||
Ptr<time_duration>::Ref clipEnd;
|
||||
|
||||
/**
|
||||
* The type of the entry (audio clip or sub-playlist).
|
||||
|
@ -204,6 +206,9 @@ class PlaylistElement : public Configurable
|
|||
this->playable = audioClip;
|
||||
this->fadeInfo = fadeInfo;
|
||||
this->type = AudioClipType;
|
||||
|
||||
setClipStart(Ptr<time_duration>::Ref(new time_duration(0,0,0,0)));
|
||||
setClipEnd(Ptr<time_duration>::Ref(new time_duration(0,0,0,0)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -228,7 +233,10 @@ class PlaylistElement : public Configurable
|
|||
this->playable = audioClip;
|
||||
this->fadeInfo = fadeInfo;
|
||||
this->type = AudioClipType;
|
||||
}
|
||||
|
||||
setClipStart(Ptr<time_duration>::Ref(new time_duration(0,0,0,0)));
|
||||
setClipEnd(Ptr<time_duration>::Ref(new time_duration(0,0,0,0)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new sub-playlist playlist element, with a new UniqueId,
|
||||
|
@ -252,7 +260,10 @@ class PlaylistElement : public Configurable
|
|||
this->playable = playlist;
|
||||
this->fadeInfo = fadeInfo;
|
||||
this->type = PlaylistType;
|
||||
}
|
||||
|
||||
setClipStart(Ptr<time_duration>::Ref(new time_duration(0,0,0,0)));
|
||||
setClipEnd(Ptr<time_duration>::Ref(new time_duration(0,0,0,0)));
|
||||
}
|
||||
|
||||
/**
|
||||
* A virtual destructor, as this class has virtual functions.
|
||||
|
@ -324,6 +335,40 @@ class PlaylistElement : public Configurable
|
|||
return relativeOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
void
|
||||
setClipStart(Ptr<time_duration>::Ref newStart)
|
||||
throw ()
|
||||
{
|
||||
clipStart = newStart;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
Ptr<time_duration>::Ref
|
||||
getClipStart(void) const throw ()
|
||||
{
|
||||
return clipStart;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
void
|
||||
setClipEnd(Ptr<time_duration>::Ref newEnd)
|
||||
throw ()
|
||||
{
|
||||
clipEnd = newEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
Ptr<time_duration>::Ref
|
||||
getClipEnd(void) const throw ()
|
||||
{
|
||||
return clipEnd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the type of this playlist element. If the return
|
||||
* value is PlaylistElement::AudioClipType (resp. PlaylistType),
|
||||
|
|
|
@ -180,6 +180,30 @@ class XmlRpcTools
|
|||
extractRelativeOffset(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Extract the relative offset from the XML-RPC parameters.
|
||||
*
|
||||
* @param xmlRpcValue the XML-RPC parameter to extract from.
|
||||
* @return a time_duration that was found in the XML-RPC parameter.
|
||||
* @exception std::invalid_argument if there was no relativeOffset
|
||||
* member in xmlRpcValue
|
||||
*/
|
||||
static Ptr<time_duration>::Ref
|
||||
extractClipStart(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Extract the relative offset from the XML-RPC parameters.
|
||||
*
|
||||
* @param xmlRpcValue the XML-RPC parameter to extract from.
|
||||
* @return a time_duration that was found in the XML-RPC parameter.
|
||||
* @exception std::invalid_argument if there was no relativeOffset
|
||||
* member in xmlRpcValue
|
||||
*/
|
||||
static Ptr<time_duration>::Ref
|
||||
extractClipEnd(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument);
|
||||
|
||||
/**
|
||||
* Convert a Playlist to an XmlRpcValue
|
||||
*
|
||||
|
|
|
@ -545,6 +545,50 @@ Playlist::setFadeInfo(Ptr<UniqueId>::Ref playlistElementId,
|
|||
it->second->setFadeInfo(fadeInfo);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Change clipStart of a playlist element.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
Playlist::setClipStart(Ptr<UniqueId>::Ref playlistElementId,
|
||||
Ptr<time_duration>::Ref newStart)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
Playlist::iterator it = this->find(playlistElementId);
|
||||
|
||||
if (it == this->end()) {
|
||||
throw std::invalid_argument("no playlist element with this ID");
|
||||
}
|
||||
|
||||
Ptr<time_duration>::Ref endOffset(new time_duration(
|
||||
*it->second->getRelativeOffset()
|
||||
+ *it->second->getPlayable()->getPlaylength() - *newStart));
|
||||
setPlaylength(endOffset);
|
||||
|
||||
it->second->setClipStart(newStart);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Change clipEnd of a playlist element.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
Playlist::setClipEnd(Ptr<UniqueId>::Ref playlistElementId,
|
||||
Ptr<time_duration>::Ref newEnd)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
Playlist::iterator it = this->find(playlistElementId);
|
||||
|
||||
if (it == this->end()) {
|
||||
throw std::invalid_argument("no playlist element with this ID");
|
||||
}
|
||||
|
||||
Ptr<time_duration>::Ref endOffset(new time_duration(
|
||||
*it->second->getRelativeOffset()
|
||||
+ *newEnd - *it->second->getClipStart()));
|
||||
setPlaylength(endOffset);
|
||||
|
||||
it->second->setClipEnd(newEnd);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Remove a playlist element from the playlist.
|
||||
|
|
|
@ -63,6 +63,14 @@ static const std::string idAttrName = "id";
|
|||
*/
|
||||
static const std::string relativeOffsetAttrName = "relativeOffset";
|
||||
|
||||
/**
|
||||
*/
|
||||
static const std::string clipStartAttrName = "clipStart";
|
||||
|
||||
/**
|
||||
*/
|
||||
static const std::string clipEndAttrName = "clipEnd";
|
||||
|
||||
/**
|
||||
* The name of the audio clip child element of the playlist element.
|
||||
*/
|
||||
|
@ -117,6 +125,24 @@ PlaylistElement :: configure(const xmlpp::Element & element)
|
|||
attribute->get_value() ));
|
||||
relativeOffset = TimeConversion::parseTimeDuration(relativeOffsetString);
|
||||
|
||||
// set clip start
|
||||
if (attribute = element.get_attribute(clipStartAttrName)) {
|
||||
Ptr<std::string>::Ref clipStartString(new std::string(
|
||||
attribute->get_value() ));
|
||||
clipStart = TimeConversion::parseTimeDuration(clipStartString);
|
||||
} else {
|
||||
setClipStart(Ptr<time_duration>::Ref(new time_duration(0,0,0,0)));
|
||||
}
|
||||
|
||||
// set clip end
|
||||
if (attribute = element.get_attribute(clipEndAttrName)) {
|
||||
Ptr<std::string>::Ref clipEndString(new std::string(
|
||||
attribute->get_value() ));
|
||||
clipEnd = TimeConversion::parseTimeDuration(clipEndString);
|
||||
} else {
|
||||
setClipEnd(Ptr<time_duration>::Ref(new time_duration(0,0,0,0)));
|
||||
}
|
||||
|
||||
// set audio clip
|
||||
xmlpp::Node::NodeList childNodes
|
||||
= element.get_children(audioClipElementName);
|
||||
|
@ -202,6 +228,12 @@ PlaylistElement :: getXmlElementString(void) throw ()
|
|||
+ "\" ");
|
||||
xmlString->append(relativeOffsetAttrName + "=\""
|
||||
+ toFixedString(relativeOffset)
|
||||
+ "\" ");
|
||||
xmlString->append(clipStartAttrName + "=\""
|
||||
+ toFixedString(clipStart)
|
||||
+ "\" ");
|
||||
xmlString->append(clipEndAttrName + "=\""
|
||||
+ toFixedString(clipEnd)
|
||||
+ "\">\n");
|
||||
|
||||
xmlString->append(*getPlayable()->getXmlElementString() + "\n");
|
||||
|
|
|
@ -81,6 +81,16 @@ const std::string playlistElementIdName = "playlistElementId";
|
|||
*----------------------------------------------------------------------------*/
|
||||
const std::string relativeOffsetName = "relativeOffset";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the relative offset member in the XML-RPC parameter structure
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string clipStartName = "clipStart";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the relative offset member in the XML-RPC parameter structure
|
||||
*----------------------------------------------------------------------------*/
|
||||
const std::string clipEndName = "clipEnd";
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The name of the from member in the XML-RPC parameter structure.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
@ -272,6 +282,42 @@ XmlRpcTools :: extractAudioClipId(XmlRpc::XmlRpcValue & xmlRpcValue)
|
|||
return id;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Extract the relative offset from an XML-RPC function call parameter
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<time_duration>::Ref
|
||||
XmlRpcTools :: extractClipStart(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
if (!xmlRpcValue.hasMember(clipStartName)
|
||||
|| xmlRpcValue[clipStartName].getType()
|
||||
!= XmlRpc::XmlRpcValue::TypeInt) {
|
||||
throw std::invalid_argument("missing clip start argument");
|
||||
}
|
||||
|
||||
Ptr<time_duration>::Ref clipStart(new time_duration(0,0,
|
||||
int(xmlRpcValue[clipStartName]), 0));
|
||||
return clipStart;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Extract the relative offset from an XML-RPC function call parameter
|
||||
*----------------------------------------------------------------------------*/
|
||||
Ptr<time_duration>::Ref
|
||||
XmlRpcTools :: extractClipEnd(XmlRpc::XmlRpcValue & xmlRpcValue)
|
||||
throw (std::invalid_argument)
|
||||
{
|
||||
if (!xmlRpcValue.hasMember(clipEndName)
|
||||
|| xmlRpcValue[clipEndName].getType()
|
||||
!= XmlRpc::XmlRpcValue::TypeInt) {
|
||||
throw std::invalid_argument("missing clip end argument");
|
||||
}
|
||||
|
||||
Ptr<time_duration>::Ref clipEnd(new time_duration(0,0,
|
||||
int(xmlRpcValue[clipEndName]), 0));
|
||||
return clipEnd;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Extract the relative offset from an XML-RPC function call parameter
|
||||
|
|
|
@ -134,7 +134,19 @@ public:
|
|||
}
|
||||
|
||||
void playContext(){
|
||||
gst_element_set_state (m_pipeline, GST_STATE_PLAYING);
|
||||
GstStateChangeReturn st = gst_element_set_state (m_pipeline, GST_STATE_PLAYING);
|
||||
if(NULL != m_audioDescription)
|
||||
{
|
||||
//enforce PLAYING state in case this was an asynch state change
|
||||
//this is essential for seek to succeed
|
||||
if(GST_STATE_CHANGE_ASYNC == st)
|
||||
{
|
||||
GstState state, pending;
|
||||
gst_element_get_state (m_pipeline, &state, &pending, 2000000000);//just in case, do not wait for more than 2 sec
|
||||
}
|
||||
gst_element_seek(m_pipeline, 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET,
|
||||
m_audioDescription->m_clipBegin*GST_NSECOND, GST_SEEK_TYPE_SET, m_audioDescription->m_clipEnd*GST_NSECOND);
|
||||
}
|
||||
g_object_set(G_OBJECT(m_volume), "volume", 1.0, NULL);
|
||||
}
|
||||
|
||||
|
@ -359,7 +371,7 @@ private:
|
|||
* Prepare animations bin.
|
||||
*----------------------------------------------------------------------------*/
|
||||
bool prepareAnimations(){
|
||||
if(m_audioDescription && m_audioDescription->m_animations.size() > 0){
|
||||
if(m_audioDescription && m_audioDescription->m_animations.size() > 0){
|
||||
m_ctrl = gst_controller_new (G_OBJECT (m_volume), "volume", NULL);
|
||||
if (m_ctrl == NULL) {
|
||||
return false;
|
||||
|
|
|
@ -166,6 +166,8 @@ class M3uPlaylist {
|
|||
$gunid2 = StoredFile::CreateGunid();
|
||||
$length = Playlist::secondsToPlaylistTime($length);
|
||||
$offset = '???';
|
||||
$clipStart = '???';
|
||||
$clipEnd = '???';
|
||||
$uri_h = preg_replace("|--|", "d;d;", htmlspecialchars("$uri"));
|
||||
if (preg_match("|\.([a-zA-Z0-9]+)$|", $uri, $va)) {
|
||||
switch (strtolower($ext = $va[1])) {
|
||||
|
@ -184,7 +186,7 @@ class M3uPlaylist {
|
|||
break;
|
||||
}
|
||||
}
|
||||
$res .= "$ind2<playlistElement id=\"$gunid\" relativeOffset=\"$offset\">\n".
|
||||
$res .= "$ind2<playlistElement id=\"$gunid\" relativeOffset=\"$offset\" clipStart=\"$clipStart\" clipEnd=\"$clipEnd\">\n".
|
||||
$acOrPl.
|
||||
"$ind2</playlistElement>\n";
|
||||
}
|
||||
|
|
|
@ -414,6 +414,16 @@ class Playlist extends StoredFile {
|
|||
if (PEAR::isError($offArr)) {
|
||||
return $offArr;
|
||||
}
|
||||
// get clipStart:
|
||||
$startArr = $this->md->getMetadataElement('clipStart', $elId);
|
||||
if (PEAR::isError($startArr)) {
|
||||
return $startArr;
|
||||
}
|
||||
// get clipEnd:
|
||||
$endArr = $this->md->getMetadataElement('clipEnd', $elId);
|
||||
if (PEAR::isError($endArr)) {
|
||||
return $endArr;
|
||||
}
|
||||
$offsetId = $offArr[0]['mid'];
|
||||
$offset = $offArr[0]['value'];
|
||||
// get audioClip:
|
||||
|
@ -460,10 +470,6 @@ class Playlist extends StoredFile {
|
|||
"Playlist::recalculateTimes: fadeIn too big");
|
||||
}
|
||||
}
|
||||
// $peArr[] = array('id'=>$elId, 'gunid'=>$plElGunid, 'len'=>$acLen,
|
||||
// 'offset'=>$offset, 'offsetId'=>$offsetId,
|
||||
// 'fadeIn'=>$fadeIn, 'fadeOut'=>$fadeOut);
|
||||
// set relativeOffset:
|
||||
if ($len > 0) {
|
||||
$len = $len - $fadeInS;
|
||||
}
|
||||
|
|
|
@ -276,7 +276,9 @@ class SmilPlaylistAudioElement {
|
|||
|
||||
$title = basename($tree->attrs['src']->val);
|
||||
$offset = Playlist::secondsToPlaylistTime($tree->attrs['begin']->val);
|
||||
$res = "$ind<playlistElement id=\"$plElGunid\" relativeOffset=\"$offset\">\n".
|
||||
$clipStart = Playlist::secondsToPlaylistTime($tree->attrs['clipStart']->val);
|
||||
$clipEnd = Playlist::secondsToPlaylistTime($tree->attrs['clipEnd']->val);
|
||||
$res = "$ind<playlistElement id=\"$plElGunid\" relativeOffset=\"$offset\" clipStart=\"$clipStart\" clipEnd=\"$clipEnd\">\n".
|
||||
"$ind2<$type id=\"$acGunid\" playlength=\"$playlength\" title=\"$title\"/>\n".
|
||||
$fInfo.
|
||||
"$ind</playlistElement>\n";
|
||||
|
|
|
@ -29,7 +29,7 @@ $playlistFormat = array(
|
|||
'optional'=>array('fadeInfo'),
|
||||
),
|
||||
'attrs'=>array(
|
||||
'required'=>array('id', 'relativeOffset'),
|
||||
'required'=>array('id', 'relativeOffset', 'clipStart', 'clipEnd'),
|
||||
),
|
||||
),
|
||||
'audioClip'=>array(
|
||||
|
|
|
@ -26,8 +26,8 @@ $mdefs = array(
|
|||
"listMethods" => array('m'=>"system.listMethods", 'p'=>NULL, 't'=>NULL),
|
||||
"AddAudioClipToPlaylistMethod" => array(
|
||||
'm'=>'addAudioClipToPlaylist',
|
||||
'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/, 'audioClipId'/*string*/, 'relativeOffset'/*int*/),
|
||||
't'=>array('string', 'string', 'string', 'int'),
|
||||
'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/, 'audioClipId'/*string*/, 'relativeOffset'/*int*/, 'clipStart'/*int*/, 'clipEnd'/*int*/),
|
||||
't'=>array('string', 'string', 'string', 'int', 'int', 'int'),
|
||||
'r'=>array('playlistElementId'/*string*/),
|
||||
'e'=>array(
|
||||
'301'=>'invalid argument format',
|
||||
|
|
|
@ -1175,7 +1175,7 @@ GLiveSupport :: cancelEditedPlaylist(void)
|
|||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
LiveSupport :: GLiveSupport ::
|
||||
GLiveSupport :: addToPlaylist(Ptr<const UniqueId>::Ref id)
|
||||
GLiveSupport :: addToPlaylist(Ptr<UniqueId>::Ref id)
|
||||
throw (XmlRpcException)
|
||||
{
|
||||
if (!editedPlaylist.get()) {
|
||||
|
@ -1188,7 +1188,11 @@ GLiveSupport :: addToPlaylist(Ptr<const UniqueId>::Ref id)
|
|||
editedPlaylist->addPlaylist(playlist, editedPlaylist->getPlaylength());
|
||||
} else if (existsAudioClip(id)) {
|
||||
Ptr<AudioClip>::Ref clip = getAudioClip(id);
|
||||
editedPlaylist->addAudioClip(clip, editedPlaylist->getPlaylength());
|
||||
Ptr<UniqueId>::Ref elid = editedPlaylist->addAudioClip(clip, editedPlaylist->getPlaylength());
|
||||
|
||||
//TODO: for testing only!!!!!!!!!
|
||||
// editedPlaylist->setClipStart(elid, Ptr<time_duration>::Ref(new time_duration(seconds(5))));
|
||||
// editedPlaylist->setClipEnd(elid, Ptr<time_duration>::Ref(new time_duration(seconds(10))));
|
||||
}
|
||||
|
||||
masterPanel->updatePlaylistWindow();
|
||||
|
|
|
@ -906,7 +906,7 @@ class GLiveSupport : public LocalizedConfigurable,
|
|||
* @see #releaseEditedPlaylist
|
||||
*/
|
||||
void
|
||||
addToPlaylist(Ptr<const UniqueId>::Ref id)
|
||||
addToPlaylist(Ptr<UniqueId>::Ref id)
|
||||
throw (XmlRpcException);
|
||||
/**
|
||||
* Save the currently edited playlist in storage.
|
||||
|
|
Loading…
Reference in New Issue