#include "cores/dvdplayer/DVDDemuxers/DVDDemuxUtils.h"
#include "cores/dvdplayer/DVDStreamInfo.h"
#include "cores/dvdplayer/DVDCodecs/DVDFactoryCodec.h"
+#include "music/tags/TagLoaderTagLib.h"
#include "utils/log.h"
#include "settings/Settings.h"
#include "URL.h"
CURL urlFile(strFile);
if (urlFile.GetProtocol() == "shout" )
- strFileToOpen.Replace("shout://","http://");
+ strFileToOpen.replace(0, 8, "http://");
m_pInputStream = CDVDFactoryInputStream::CreateInputStream(NULL, strFileToOpen, m_strContentType);
if (!m_pInputStream)
return false;
}
+ // Extract ReplayGain info
+ // tagLoaderTagLib.Load will try to determine tag type by file extension, so set fallback by contentType
+ CStdString strFallbackFileExtension = "";
+ if (m_strContentType.Equals("audio/aacp") || m_strContentType.Equals("audio/aacp" "audio/aac"))
+ strFallbackFileExtension = "m4a";
+ else if (m_strContentType.Equals("audio/x-ms-wma"))
+ strFallbackFileExtension = "wma";
+ else if (m_strContentType.Equals("audio/x-ape") || m_strContentType.Equals("audio/ape"))
+ strFallbackFileExtension = "ape";
+ CTagLoaderTagLib tagLoaderTagLib;
+ tagLoaderTagLib.Load(strFile, m_tag, strFallbackFileExtension);
+
// we have to decode initial data in order to get channels/samplerate
// for sanity - we read no more than 10 packets
int nErrors = 0;
m_EncodedSampleRate = m_pAudioCodec->GetEncodedSampleRate();
m_Channels = m_pAudioCodec->GetChannels();
m_ChannelInfo = m_pAudioCodec->GetChannelMap();
-
+ m_BitsPerCodedSample = static_cast<CDemuxStreamAudio*>(pStream)->iBitsPerSample;
}
if (nErrors >= 10)
{
return false;
}
- m_nDecodedLen = 0;
+ // test if seeking is supported
+ m_bCanSeek = false;
+ if (m_pInputStream->Seek(0, SEEK_POSSIBLE))
+ {
+ // reset eof flag of stream, with eof set seek returns always success
+ m_pInputStream->Seek(0, SEEK_SET);
+ if (Seek(1) != DVD_NOPTS_VALUE)
+ {
+ // rewind stream to beginning
+ Seek(0);
+ }
+ else
+ {
+ m_pInputStream->Seek(0, SEEK_SET);
+ m_pDemuxer->Reset();
+ }
+ }
if (m_Channels == 0) // no data - just guess and hope for the best
m_Channels = 2;
m_TotalTime = m_pDemuxer->GetStreamLength();
m_Bitrate = m_pAudioCodec->GetBitRate();
+ if (!m_Bitrate && m_TotalTime)
+ {
+ m_Bitrate = (int)(((m_pInputStream->GetLength()*1000) / m_TotalTime) * 8);
+ }
m_pDemuxer->GetStreamCodecName(m_nAudioStream,m_CodecName);
m_strFileName = strFile;
CDVDDemuxUtils::FreeDemuxPacket(m_pPacket);
m_pPacket = NULL;
- m_pDemuxer->SeekTime((int)iSeekTime, false);
+ bool ret = m_pDemuxer->SeekTime((int)iSeekTime, false);
m_pAudioCodec->Reset();
m_decoded = NULL;
m_nDecodedLen = 0;
+ if (!ret)
+ return DVD_NOPTS_VALUE;
+
return iSeekTime;
}
bool DVDPlayerCodec::CanSeek()
{
- return true;
+ return m_bCanSeek;
}